fix: report tx_execution_result as None when the light decode can't know it - #114
Open
2TheMoom wants to merge 1 commit into
Open
Conversation
…now it from_transaction_data() (used by get_transaction()) hardcoded tx_execution_result=0 for both the Asimov (v04) and Bradbury (v06) ABI shapes, even though that field isn't present in the light getTransaction response at all -- only getTransactionAllData (from_all_transaction_data) actually reads a real value. 0 isn't a placeholder here, it's the numeric code for ExecutionResult.NOT_VOTED, so every light-decoded transaction silently claimed "not voted" instead of "unknown". Widen tx_execution_result to Optional[int] and return None from both light-path decoders instead. decode()'s tx_execution_result_name lookup already falls back to NOT_VOTED for any non-matching key, so the public dict shape and existing callers are unaffected -- only the raw dataclass field becomes honestly nullable.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
GenLayerRawTransaction.from_transaction_data()(the light decode path behindget_transaction()) hardcodedtx_execution_result=0for both the Asimov (v04, 21-field) and Bradbury (v06, 23-field) ABI shapes.That field genuinely isn't present in the light
getTransactionresponse on either shape — onlygetTransactionAllData(from_all_transaction_data) actually reads a real value, as the existing code comment onGenLayerTransaction.tx_execution_resultalready notes (# tx_execution_result: testnet (from getTransactionAllData)).0isn't a neutral placeholder here — it's the numeric code forExecutionResult.NOT_VOTED. So every transaction decoded via the light path silently claimed "not voted" instead of "we don't actually know," making it impossible for calling code to tell a real not-voted result from an unread one.Fix
GenLayerRawTransaction.tx_execution_resulttoOptional[int](this already matches the publicGenLayerTransactionTypedDict's declared type).Nonefrom_from_v04and_from_v06instead of0.decode()'stx_execution_result_namelookup already falls back toExecutionResult.NOT_VOTEDfor any key that doesn't matchEXECUTION_RESULT_NUMBER_TO_NAME(whichNone/"None"doesn't), so the public dict's_namefield is unchanged — only the rawtx_execution_resultvalue becomes honestly nullable instead of a false0.from_all_transaction_datauntouched; it already receives a real value from the caller and a regression test pins that.Related
This started from genlayerlabs/genlayer-cli#308, which reports the same bug but against this repo's code under the wrong repository, and suggests reading
tx_data[9]as the fix — that's incorrect, sincetx_data[9]in the v06 shape istxExecutionHash, abytes32hash, not a result code (see the existing comment a few lines above it). There's no field to remap; the light ABI just doesn't carry this data.Testing
Added
tests/unit/transactions/test_raw_transaction_execution_result.py:tx_execution_result is Nonedecode()still reportstx_execution_result_name == "NOT_VOTED"for the unknown case (back-compat)from_all_transaction_data(the real, non-light path) is unaffected and still returns a real intRan the full
tests/unit/suite locally: 96 passed, 2 pre-existing failures unrelated to this change (live-network smoke tests againstrpc-bradbury.genlayer.com/rpc-asimov.genlayer.comhitting a transient TLS error in my environment — reproduced identically on a cleanv0.18checkout before my change).