fix specific methods

This commit is contained in:
Maksim Fomenkov
2022-11-23 06:02:21 +04:00
parent fc9f7e0fa6
commit b26dd989f5
3 changed files with 34 additions and 32 deletions

View File

@@ -258,9 +258,6 @@ open class NativeCall(
if (method in listOf( if (method in listOf(
"eth_getFilterChanges", "eth_getFilterChanges",
"eth_uninstallFilter", "eth_uninstallFilter",
"shh_getFilterChanges",
"shh_uninstallFilter",
"shh_getMessages"
) )
) )
GetFilterUpdatesDecorator() GetFilterUpdatesDecorator()
@@ -392,7 +389,6 @@ open class NativeCall(
"eth_newFilter", "eth_newFilter",
"eth_newBlockFilter", "eth_newBlockFilter",
"eth_newPendingTransactionFilter", "eth_newPendingTransactionFilter",
"shh_newFilter",
) )
} }
override fun processResult(result: QuorumRpcReader.Result): ByteArray { override fun processResult(result: QuorumRpcReader.Result): ByteArray {

View File

@@ -92,13 +92,6 @@ class DefaultEthereumMethods(
"eth_chainId" "eth_chainId"
) )
private val bscFilterMethods = listOf(
"shh_newFilter",
"shh_uninstallFilter",
"shh_getFilterChanges",
"shh_getMessages",
)
private val allowedMethods: List<String> private val allowedMethods: List<String>
init { init {
@@ -130,19 +123,14 @@ class DefaultEthereumMethods(
} }
getChainSpecificMethods(chain).contains(method) -> { getChainSpecificMethods(chain).contains(method) -> {
if (bscFilterMethods.contains(method)) { when (method) {
NotLaggingQuorum(1) "eth_getBlockRange" -> NotLaggingQuorum(1)
} else { "bor_getAuthor" -> NotLaggingQuorum(0)
when (method) { "bor_getCurrentValidators" -> NotLaggingQuorum(0)
"eth_getBlockRange" -> NotLaggingQuorum(1) "bor_getCurrentProposer" -> NotLaggingQuorum(0)
"bor_getAuthor" -> NotLaggingQuorum(0) "bor_getRootHash" -> NotLaggingQuorum(1)
"bor_getCurrentValidators" -> NotLaggingQuorum(0) "eth_getRootHash" -> NotLaggingQuorum(1)
"bor_getCurrentProposer" -> NotLaggingQuorum(0) else -> AlwaysQuorum()
"bor_getRootHash" -> NotLaggingQuorum(1)
"eth_getRootHash" -> NotLaggingQuorum(1)
"shh_hasIdentity" -> NotLaggingQuorum(1)
else -> AlwaysQuorum()
}
} }
} }
else -> AlwaysQuorum() else -> AlwaysQuorum()
@@ -163,20 +151,13 @@ class DefaultEthereumMethods(
"bor_getSignersAtHash", "bor_getSignersAtHash",
"eth_getRootHash" "eth_getRootHash"
) )
Chain.BSC -> bscFilterMethods + listOf(
"shh_post",
"shh_version",
"shh_newIdentity",
"shh_hasIdentity",
"shh_addToGroup",
)
else -> emptyList() else -> emptyList()
} }
} }
private fun chainUnsupportedMethods(chain: Chain): Set<String> { private fun chainUnsupportedMethods(chain: Chain): Set<String> {
if (chain == Chain.OPTIMISM) { if (chain == Chain.OPTIMISM) {
return setOf("eth_getAccounts", "eth_sendTransaction") return setOf("eth_getAccounts")
} }
return emptySet() return emptySet()
} }

View File

@@ -44,4 +44,29 @@ class DefaultEthereumMethodsSpec extends Specification {
Chain.TESTNET_RINKEBY | '"0x4"' Chain.TESTNET_RINKEBY | '"0x4"'
Chain.TESTNET_ROPSTEN | '"0x3"' Chain.TESTNET_ROPSTEN | '"0x3"'
} }
def "Optimism chain unsupported methods"() {
setup:
def methods = new DefaultEthereumMethods(Chain.OPTIMISM)
when:
def acc = methods.isAvailable("eth_getAccounts")
def trans = methods.isAvailable("eth_sendTransaction")
then:
!acc
!trans
}
def "Has supported specific methods"() {
expect:
new DefaultEthereumMethods(chain).getSupportedMethods().containsAll(methods)
where:
chain | methods
Chain.POLYGON | ["bor_getAuthor",
"bor_getCurrentValidators",
"bor_getCurrentProposer",
"bor_getRootHash",
"bor_getSignersAtHash",
"eth_getRootHash"]
Chain.OPTIMISM | ["eth_getBlockRange", "rollup_gasPrices"]
}
} }