-
Notifications
You must be signed in to change notification settings - Fork 583
feat: add inclusion status to tx-receipt #19733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c10c9e3 to
c2217cb
Compare
| if (blockNumber <= finalizedBlockNumber) { | ||
| status = TxStatus.FINALIZED; | ||
| } else if (blockNumber <= provenBlockNumber) { | ||
| status = TxStatus.PROVEN; | ||
| } else if (blockNumber <= checkpointedBlockNumber) { | ||
| status = TxStatus.CHECKPOINTED; | ||
| } else { | ||
| status = TxStatus.PROPOSED; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels like this is going to be used in multiple places in the codebase so maybe it should be a utility in foundation (alongside getFinalizedL2BlockNumber() so that it's easy to change in the future?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, I see this is the source for the 'finalized' definition. Ignore the part about creating helpers in foundation.
| // ); | ||
|
|
||
| expect(txReceipt.status).toBe(TxStatus.SUCCESS); | ||
| expect(txReceipt.isMined() && txReceipt.isSuccess()).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, are these flags orthogonal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooo mined=included in a block while success=executed correctly. I'd rename isSuccess to make it clearer. Maybe hasExecutedSuccessfully?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird because separating the status like this makes think an unmined but successfully executed tx is possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Renamed to hasExecutionSucceeded and hasExecutionReverted.
59968d2 to
342c421
Compare
342c421 to
fc1c705
Compare
This PR splits
TxReceipt.statusinto two separate fields tobetter distinguish between block finalization level and transaction
execution outcome.
New
TxStatusvalues (block finalization level):DROPPED- Tx dropped by P2P nodePENDING- Tx pending in mempoolPROPOSED- Tx included in a proposed blockCHECKPOINTED- Block checkpointed on L1PROVEN- Checkpoint proven on L1FINALIZED- Proven on a finalized L1 blockNew
TxExecutionResultenum (execution outcome):SUCCESS- Transaction executed successfullyAPP_LOGIC_REVERTED- App logic revertedTEARDOWN_REVERTED- Teardown phase revertedBOTH_REVERTED- Both app logic and teardown revertedThis PR also adds an option to
waitForTxReceiptso that the user can choose the finalization status of the receipt. This is set to default toCHECKPOINTED, so we can preserve old behaviour where we do not proceed with an action until the tx was checkpointed to L1.Key changes:
TxReceiptclass with new fields and helper methods(
isSuccess(),isReverted(),isMined(),isPending(),isDropped())getFinalizedL2BlockNumber()andgetCheckpointedL2BlockNumber()methods
getSettledTxReceiptin BlockStore to determine properfinalization level based on archiver state
waitForStatustoCHECKPOINTED🤖 Generated with Claude Code