PR: Fix inconsistent method decoding in data-decoder endpoint, Resolve #2508 #2509
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR: Fix inconsistent method decoding in data-decoder endpoint
Resolves #2508
Description
This PR addresses the issue where the
/api/v1/data-decoder
endpoint fails to decode methods from verified contracts that have their ABIs loaded in the transaction service.The core problem was in the
get_abi_function
method of theDbTxDecoder
class, which first checked if a function selector existed in the preloaded ABIs before attempting to use contract-specific ABIs. This meant that contract methods not included in the hardcoded ABIs (decoder_abis directory) or not loaded at service initialization time were never decoded, even if the contract was verified and its ABI was available in the database.Before & After Examples
Mainnet Example
Contract:
0xB4EFd85c19999D84251304bDA99E90B92300Bd93
Method:
setSaleContractFinalised
Method: setSaleContractFinalised (not in decoder_abis)
Before:
After:
Polygon Example
Contract:
0x062FfE63b7A0d7f27A8105e717c6Ea45E5848AD3
Method:
add
Method: add (not in decoder_abis)
Before:
After:
Base Example
Contract:
0x2C8bC3198903DE6b61C1E1aA449578863Af3ccE7
Method:
initialize
Method: initialize (not in decoder_abis)
Before:
After:
Solution
The solution inverts the order of ABI checking:
Benefits
This change ensures:
Testing
Two tests have been added to verify the fix:
test_db_tx_decoder_with_contract_specific_abi
: Verifies that contract-specific ABIs are used even when the method selector isn't in the preloaded ABIstest_db_tx_decoder_priority
: Confirms that contract-specific ABIs take priority over preloaded ABIs when there's a conflictThese tests ensure that the data-decoder endpoint will now correctly handle all methods from verified contracts across all networks.