Repository navigation
Conversation
- eth_call / eth_estimateGas: contract revert changes from -32000 to 3 - data a node does not have (pruned on a LiteNode, or receipts with transHistory.switch off) returns 4444 "Pruned history unavailable"
- 4444 no longer carries the earliest available block in data, as geth - remove ResultCodeUtil; constant calls record only REVERT - test that a reverted constant call sets contractRet to REVERT
…ove init methods to the top - rename probeLowestBlockNumOfReceiptStore to initLowestBlockNumOfReceiptStore - move init and initLowestBlockNumOfReceiptStore to the top of ChainBaseManager methods
|
A few points from the parameter-handling review. These issues predate this PR, but the new
Some optional naming improvements:
The existing issues outside this PR’s scope can be handled in this PR or follow-ups. |
@317787106 Thanks. |
…sonrpc-revert-and-pruned-history # Conflicts: # framework/src/main/java/org/tron/core/services/jsonrpc/TronJsonRpcImpl.java # framework/src/test/java/org/tron/core/jsonrpc/JsonrpcServiceTest.java # framework/src/test/java/org/tron/core/services/jsonrpc/JsonRpcErrorResolverTest.java
waynercheung
left a comment
There was a problem hiding this comment.
Re-checked 66b53b5 against release_v4.8.3 at 7ebc2eb.
The merge preserves the relevant validation order: eth_getBlockByNumber validates fullTransactionObjects before the pruning check, and both by-index methods validate the index before lookup. The receipt-floor rules and direct JsonRpcException inheritance match the design settled in #6676, and the 4444 response keeps the specified message without cutoff metadata.
I did not find a blocking correctness issue. Please address the two test gaps noted inline and make sure CI passes on the final head before approval.
[SHOULD] Please document the retained-body receipt gap as a known limitation. Between the body floor and the receipt floor, body queries still return receipt-derived fields as zero (block gasUsed, transaction gas). This is existing behavior under the agreed availability policy, but clients cannot tell missing receipt data from actual zero usage.
[SHOULD] Please update the reference.conf / config.conf comments to say that transHistory.switch = off also disables receipt/log queries even when receipts remain on disk (genesis-only queries excepted). The PR description already lists this change; please carry it into the release notes.
[QUESTION] The revert message stays REVERT opcode executed[: reason], while geth uses execution reverted[: reason]. Is keeping it intentional? If so, please state it in the description.
[QUESTION] Could you link the tracking issues for the deferred eth_call block-object validation, estimateGas parameter-error handling, Toolkit receipt retention, and the docs-en / docs-zh error-code updates?
[NIT]
TransactionRetStore.getLowestBlockNum()shares its name withChainBaseManager.getLowestBlockNum()/Wallet.getLowestBlockNum(), which mean the body floor;getLowestReceiptBlockNum()would avoid the ambiguity.- Description:
contractRet: REVERTalso reachestriggersmartcontractwhen its selector is a constant ABI function. - Description: pin or remove the empty-revert comparison with geth; v1.17.5 returns code 3 for empty revert data.
- Description: narrow the unknown-hash "null" wording;
eth_getLogs/eth_newFilterkeep returning-32602 invalid blockHash.
- rename TransactionRetStore.getLowestBlockNum to getLowestReceiptBlockNum - note that transHistory.switch off disables receipt and log queries
@waynercheung Thanks for the re-check.
|
waynercheung
left a comment
There was a problem hiding this comment.
Re-reviewed 6e84880 and tested a local merge with release_v4.8.3 at 4db3688. The merge is clean.
Both previous test gaps are addressed. On the merged tree, removing the 4444 mappings, removing the 3 mappings, removing the Manager init call, or replacing Long.MAX_VALUE with getHeadBlockNum() + 1 each fails a test.
I rechecked the revert classification, receipt-floor initialization, pruning boundaries and validation order, and found no blocking issues. GitHub CI for the PR head is green.
[NIT] Please link the Toolkit receipt-retention issue once it is open, and update the request-envelope follow-up to reference the merged PR #7032.
Approved.
- run the constant revert test with debug on to skip the cpu time limit - clarify transHistory.switch comment in reference.conf and config.conf - drop unused throws from getFilterChanges
lxcmyf
left a comment
There was a problem hiding this comment.
Reviewed the revert classification and pruned-history handling on 6e84880, including startup receipt-floor initialization, body/receipt/log cutoff boundaries, genesis exceptions, error-code resolution, and validation order. Targeted tests and static security scans pass. No additional blocking issues found.
@waynercheung Thanks. The request-envelope follow-up now references #7032. I'll link the Toolkit issue once it is open. |
…sonrpc-revert-and-pruned-history
First of two PRs for #6676; request validation is split out (see Follow up).
What does this PR do?
Aligns two JSON-RPC error behaviors with the Ethereum Execution API:
Contract revert returns code
3.eth_callandeth_estimateGasreturncode: 3instead of-32000; other execution failures stay-32000.Wallet.callConstantContractnow recordscontractReton the result, so the JSON-RPC layer classifies on the enum rather than on the error message.Pruned history returns
4444 "Pruned history unavailable".eth_getBlockByNumber,eth_getBlockTransactionCountByNumber,eth_getTransactionByBlockNumberAndIndex): on a LiteNode, heights below the lowest stored block. Genesis stays queryable.eth_getBlockReceipts,eth_getLogs,eth_newFilter), including when the block is selected by hash: on any node whentransHistory.switch = off; otherwise on a LiteNode, heights below the lowest receipt block (the first block intransactionRetStore, read at startup). A FullNode has no such check — receipts from before June 2019 may still be served fromTransactionHistoryStore, so the store's first key is not a lower bound — and receipt gaps on a FullNode keep the current behavior.datais the"{}"placeholder every java-tron JSON-RPC error has.earliestresolves to the lowest block with all persisted data: on a LiteNode the lowest receipt block (the lowest stored block when receipts are not persisted), on a FullNode 0.Why are these changes required?
-32000, a contract revert cannot be told apart from out-of-energy or any other TVM failure.nullfor pruned blocks, which reads as "block does not exist", andeth_getLogsacross the cutoff returns incomplete results without an error.Breaking changes (release-note items):
eth_call/eth_estimateGas: a contract revert returns3instead of-32000.4444instead ofnullon block-body methods, and instead of-32000or incomplete results on receipt and log methods.transHistory.switch = off: receipt and log queries return4444, including for receipts already on disk.earlieston a LiteNode resolves to the lowest available block instead of 0.eth_getTransactionByBlockNumberAndIndex/eth_getTransactionByBlockHashAndIndex: an invalid index returns-32602instead ofnullwhen the block is missing or pruned.This PR has been tested by:
4444/3mappings on every affectedTronJsonRpcmethod, and resolver declaration-order independence.Follow up
jsonrpcversion, non-stringmethod, explicitid: null): done in feat(jsonrpc): validate jsonrpc version, method and null id #7032.eth_call/eth_estimateGasparameter validation: the block object falling back tolatest, and malformed call arguments returning-32000(tracked in [Feature]Standardize JSON-RPC error handling(revert codes, LiteNode pruned-history responses, request fields validation) #6676, [Feature]Standardize JSON-RPC error handling(revert codes, LiteNode pruned-history responses, request fields validation) #6676 (comment)).3and4444with the 4.8.3 release.Extra details
triggerConstantContractresponses now carrycontractRet: REVERTwhen the call reverts, and so doestriggerSmartContractwhen its selector is a constant ABI function.3, including one with empty revert data.eth_getLogsfrom0x0to a later block on a LiteNode returns4444, as geth does.null, or-32602 invalid blockHashoneth_getLogs/eth_newFilter. Wheneth_getBlockReceiptsoreth_getLogsdoes find the block by hash, its number is known and the receipt rules above apply.eth_getBlockByHash,eth_getTransactionByHashandeth_getTransactionReceiptare unchanged.Known limitations
gasUsedand transactiongas. Clients cannot tell missing receipt data from actual zero usage. This follows from the availability rules above and goes away once the Toolkit follow-up aligns the two boundaries.