Refactor transaction result types to align with execution-apis spec#10113
Merged
Conversation
TransactionCompleteResult to extend TransactionPendingResult
c7913ad to
f724a59
Compare
TransactionCompleteResult to extend TransactionPendingResultf724a59 to
ab335f3
Compare
Eliminates ~200 lines of duplication by making TransactionCompleteResult extend TransactionPendingResult instead of re-implementing all transaction fields. The complete result now only adds blockHash, blockNumber, blockTimestamp, and transactionIndex on top of the base class. Additional changes: - Add EIP-7702 authorizationList to TransactionPendingResult so pending code-delegation transactions are correctly represented - Compute gasPrice as effectiveGasPrice(baseFee) for mined transactions instead of returning maxFeePerGas - Use null-safe Optional.map() for block metadata instead of .get() - Tighten Optional<Object> to Optional<TransactionPendingResult> in EthGetTransactionByHash Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2b6582c to
8bf7fb5
Compare
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.
Summary
During the development of #10111, I found that
TransactionPendingResultwas missing new fields related to EIP-7702 txs, while they were present inTransactionCompleteResult. This was caused by the duplication across both classes — new fields had to be added in two places and it was easy to miss one.This PR eliminates that duplication and aligns the class hierarchy with the execution-apis spec:
TransactionBaseResult— new base class containing only the fields defined in the spec; block metadata getters returnnull(correct for pending transactions)TransactionWithMetadataResult— extendsTransactionBaseResult, overrides block metadata getters with real values from the mined block (replacesTransactionCompleteResult)TransactionPendingResult— extendsTransactionBaseResult, retains onlypublicKeyandrawas Besu-specific extensions (used bytxpool_content/txpool_contentFrom)Changes
TransactionBaseResult(new): spec-compliant base class with all transaction fields and getters;gasPricefor EIP-1559/blob transactions is computed aseffectiveGasPrice(baseFee)when a base fee is provided, or falls back tomaxFeePerGasfor pending transactionsTransactionWithMetadataResult(new): replacesTransactionCompleteResult; overridesblockHash,blockNumber,blockTimestamp, andtransactionIndexTransactionPendingResult: now extendsTransactionBaseResult; only retainspublicKeyandrawfieldsEthGetTransactionByHash: pending transactions now useTransactionBaseResultdirectly (nopublicKey/raw), aligning with the specBehaviour change
eth_getTransactionByHashno longer includespublicKeyandrawin the response for pending transactions. These are Besu extensions appropriate for txpool introspection methods (txpool_content,txpool_contentFrom), not foreth_getTransactionByHash.Test plan
EthGetTransactionByHashTestpassesTransactionWithMetadataResultTestpasses (covers EIP-1559, legacy pre/post London, and access-list transactions)02_cancun_get_blob_tx.jsonpasses (verifies removal ofpublicKey/rawfrometh_getTransactionByHashfor pending blob tx)authorizationListis present in EIP-7702 transaction responsesgasPriceis the effective gas price for mined EIP-1559 transactions🤖 Generated with Claude Code