Skip to content

Commit

Permalink
fix arbitrum trace methods, handle quorum for for special methods
Browse files Browse the repository at this point in the history
  • Loading branch information
msizov committed Jul 16, 2024
1 parent a06e997 commit 54a87cf
Showing 1 changed file with 64 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class DefaultEthereumMethods(
"eth_newPendingTransactionFilter",
)

var traceMethods = listOf(
val traceMethods = listOf(
"trace_call",
"trace_callMany",
"trace_rawTransaction",
Expand All @@ -61,6 +61,17 @@ class DefaultEthereumMethods(
"trace_transaction",
)

var arbitrumTraceMethods = listOf(
"arbtrace_call",
"arbtrace_callMany",
"arbtrace_replayBlockTransactions",
"arbtrace_replayTransaction",
"arbtrace_block",
"arbtrace_filter",
"arbtrace_get",
"arbtrace_transaction",
)

val debugMethods = listOf(
"debug_storageRangeAt",
"debug_traceBlock",
Expand Down Expand Up @@ -118,6 +129,30 @@ class DefaultEthereumMethods(
"hmyv2_getCXReceiptByHash",
)

private val klayPossibleNotIndexedMethods = listOf(
"klay_blockNumber",
"klay_getBlockByHash",
"klay_getBlockReceipts",
"klay_getBlockTransactionCountByNumber",
"klay_getBlockWithConsensusInfoByNumber",
"klay_getBlockByNumber",
"klay_getBlockTransactionCountByHash",
"klay_getHeaderByNumber",
"klay_getHeaderByHash",
"klay_getBlockWithConsensusInfoByNumberRange",
"klay_getBlockWithConsensusInfoByHash",
"klay_getDecodedAnchoringTransactionByHash",
"klay_getRawTransactionByBlockNumberAndIndex",
"klay_getRawTransactionByBlockHashAndIndex",
"klay_getRawTransactionByHash",
"klay_getTransactionByBlockNumberAndIndex",
"klay_getTransactionBySenderTxHash",
"klay_getTransactionByBlockHashAndIndex",
"klay_getTransactionByHash",
"klay_getTransactionReceipt",
"klay_getTransactionReceiptBySenderTxHash",
)

private val firstValueMethods = listOf(
"eth_call",
"eth_getStorageAt",
Expand All @@ -141,6 +176,11 @@ class DefaultEthereumMethods(
"hmy_getTransactionCount",
)

private val klaySpecialMethods = listOf(
"klay_sendRawTransaction",
"klay_getTransactionCount",
)

private val headVerifiedMethods = listOf(
"eth_getBlockTransactionCountByNumber",
"eth_getUncleCountByBlockNumber",
Expand Down Expand Up @@ -174,49 +214,26 @@ class DefaultEthereumMethods(
"klay_getAccount",
"klay_getAccount",
"klay_sign",
"klay_getTransactionCount",
"klay_isContractAccount",

"klay_blockNumber",
"klay_getBlockByHash",
"klay_getBlockReceipts",
"klay_getBlockTransactionCountByNumber",
"klay_getBlockWithConsensusInfoByNumber",
"klay_getCommittee",
"klay_getCommitteeSize",
"klay_getCouncil",
"klay_getCouncilSize",
"klay_getBlockByNumber",
"klay_getBlockTransactionCountByHash",
"klay_getHeaderByNumber",
"klay_getHeaderByHash",

"klay_getRewards",
"klay_getStorageAt",
"klay_syncing",
"klay_getBlockWithConsensusInfoByNumberRange",
"klay_getBlockWithConsensusInfoByHash",

"klay_call",
"klay_getDecodedAnchoringTransactionByHash",

"klay_estimateGas",
"klay_getTransactionByBlockNumberAndIndex",
"klay_getTransactionBySenderTxHash",
"klay_getTransactionByBlockHashAndIndex",
"klay_getTransactionByHash",
"klay_getTransactionReceipt",
"klay_sendRawTransaction",

"klay_estimateComputationCost",
"klay_sendTransaction",
"klay_sendTransactionAsFeePayer",
"klay_signTransaction",
"klay_signTransactionAsFeePayer",
"klay_pendingTransactions",
"klay_getTransactionReceiptBySenderTxHash",
"klay_createAccessList",
"klay_getRawTransactionByBlockHashAndIndex",
"klay_getRawTransactionByHash",

"klay_resend",
"klay_getRawTransactionByBlockNumberAndIndex",

"klay_chainID",
"klay_clientVersion",
Expand Down Expand Up @@ -323,24 +340,15 @@ class DefaultEthereumMethods(
chainUnsupportedMethods(chain) +
getDrpcVendorMethods(chain) +
getChainSpecificMethods(chain)

// add trace method for arbitrum
traceMethods.plus(
when (chain) {
Chain.ARBITRUM__MAINNET, Chain.ARBITRUM__SEPOLIA, Chain.ARBITRUM_NOVA__MAINNET, Chain.ARB_BLUEBERRY__TESTNET ->
listOf("arbtrace_call")
else -> emptyList<String>()
},
)
}

override fun createQuorumFor(method: String): CallQuorum {
return when {
possibleNotIndexedMethods.contains(method) || harmonyPossibleNotIndexedMethods.contains(method) -> NotNullQuorum()
specialMethods.contains(method) || harmonySpecialMethods.contains(method) -> {
possibleNotIndexedMethods.contains(method) || harmonyPossibleNotIndexedMethods.contains(method) || klayPossibleNotIndexedMethods.contains(method) -> NotNullQuorum()
specialMethods.contains(method) || harmonySpecialMethods.contains(method) || klaySpecialMethods.contains(method) -> {
when (method) {
"eth_getTransactionCount", "hmy_getTransactionCount" -> MaximumValueQuorum()
"eth_sendRawTransaction", "hmy_sendRawStakingTransaction", "hmy_sendRawTransaction" -> BroadcastQuorum()
"eth_getTransactionCount", "hmy_getTransactionCount", "klay_getTransactionCount" -> MaximumValueQuorum()
"eth_sendRawTransaction", "hmy_sendRawStakingTransaction", "hmy_sendRawTransaction", "klay_sendRawTransaction" -> BroadcastQuorum()
else -> AlwaysQuorum()
}
}
Expand Down Expand Up @@ -374,6 +382,8 @@ class DefaultEthereumMethods(
)
Chain.KLAYTN__MAINNET, Chain.KLAYTN__BAOBAB ->
klayMethods
.plus(klaySpecialMethods)
.plus(klayPossibleNotIndexedMethods)
Chain.MANTLE__MAINNET, Chain.MANTLE__SEPOLIA ->
listOf(
"rollup_gasPrices",
Expand Down Expand Up @@ -521,14 +531,24 @@ class DefaultEthereumMethods(
return json.toByteArray()
}

override fun getGroupMethods(groupName: String): Set<String> =
when (groupName) {
override fun getGroupMethods(groupName: String): Set<String> {
val isArbitrum = when (chain) {
Chain.ARBITRUM__MAINNET, Chain.ARB_BLUEBERRY__TESTNET -> true
Chain.ARBITRUM__SEPOLIA, Chain.ARBITRUM_NOVA__MAINNET -> true
else -> false
}
return when (groupName) {
"filter" -> filterMethods
"trace" -> traceMethods
"trace" -> if (isArbitrum) {
arbitrumTraceMethods
} else {
traceMethods
}
"debug" -> debugMethods
"default" -> getSupportedMethods()
else -> emptyList()
}.toSet()
}

override fun getSupportedMethods(): Set<String> {
return allowedMethods.plus(hardcodedMethods).toSortedSet()
Expand Down

0 comments on commit 54a87cf

Please sign in to comment.