-
Notifications
You must be signed in to change notification settings - Fork 719
Report filtered delayed transactions to filtering-report service - NIT-4644 #4632
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
Open
mahdy-nasr
wants to merge
14
commits into
master
Choose a base branch
from
report-filtered-delayed-transactions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5d91439
Report filtered delayed transactions to filtering-report service
mahdy-nasr 2a36d7a
Populate redeem cacading filtered addresses
mahdy-nasr da4fbe2
Merge branch 'add-report-filtered-txn-api-2' into report-filtered-del…
mahdy-nasr 50934a3
propegate positionInBlock in other hooks
mahdy-nasr a615380
support txn reporting in tests
mahdy-nasr a19760a
change time to utc
mahdy-nasr 0fd2625
Merge branch 'add-report-filtered-txn-api-2' into report-filtered-del…
mahdy-nasr 110d981
refactor how we plump reporting fields for txn filting
mahdy-nasr 01a3b5d
minor comment
mahdy-nasr 08f6070
Merge branch 'master' into report-filtered-delayed-transactions
mahdy-nasr 53017e1
enhance the error workflow and system tests
mahdy-nasr 177a108
pass userTx instead of userTxHash
mahdy-nasr b5e169d
Merge branch 'master' into report-filtered-delayed-transactions
mahdy-nasr 3ec0fd9
add retryable tests
mahdy-nasr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import ( | |
| "math" | ||
| "math/big" | ||
|
|
||
| "github.com/ethereum/go-ethereum/arbitrum/filter" | ||
| "github.com/ethereum/go-ethereum/arbitrum_types" | ||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/ethereum/go-ethereum/core" | ||
|
|
@@ -42,13 +43,19 @@ var EmitTicketCreatedEvent func(*vm.EVM, [32]byte) error | |
|
|
||
| // ErrFilteredCascadingRedeem is returned via TxFailed when a redeem's | ||
| // inner execution touches a filtered address, requiring the entire tx group | ||
| // (originating user tx + all its redeems) to be reverted. | ||
| // (originating user tx + all its redeems) to be reverted. All fields are | ||
| // captured before the group rollback so TxFailed can build a fully populated | ||
| // FilteredTxReport without late-filling. | ||
| type ErrFilteredCascadingRedeem struct { | ||
| OriginatingTxHash common.Hash | ||
| OriginatingTx *types.Transaction | ||
| FilteredAddresses []filter.FilteredAddressRecord | ||
| BlockNumber uint64 | ||
| ParentBlockHash common.Hash | ||
| PositionInBlock int // receipt index of the originating user tx | ||
| } | ||
|
|
||
| func (e *ErrFilteredCascadingRedeem) Error() string { | ||
| return fmt.Sprintf("cascading redeem filtered (originating tx: %s)", e.OriginatingTxHash.Hex()) | ||
| return fmt.Sprintf("cascading redeem filtered (originating tx: %s)", e.OriginatingTx.Hash().Hex()) | ||
| } | ||
|
|
||
| // A helper struct that implements String() by marshalling to JSON. | ||
|
|
@@ -95,14 +102,14 @@ type groupCheckpoint struct { | |
| userTxsProcessed int | ||
| completeLen int | ||
| receiptsLen int | ||
| userTxHash common.Hash | ||
| userTx *types.Transaction | ||
| } | ||
|
|
||
| // saveGroupCheckpoint snapshots the loop state so the entire tx group can be | ||
| // rolled back if a descendant redeem is filtered. header is passed separately | ||
| // because only GasUsed is checkpointed; the rest of the header is immutable | ||
| // during the loop. | ||
| func (s *blockBuildState) saveGroupCheckpoint(header *types.Header, snap int, userTxHash common.Hash) error { | ||
| func (s *blockBuildState) saveGroupCheckpoint(header *types.Header, snap int, userTx *types.Transaction) error { | ||
| if len(s.redeems) != 0 { | ||
| return errors.New("saveGroupCheckpoint called with pending redeems") | ||
| } | ||
|
|
@@ -115,7 +122,7 @@ func (s *blockBuildState) saveGroupCheckpoint(header *types.Header, snap int, us | |
| userTxsProcessed: s.userTxsProcessed, | ||
| completeLen: len(s.complete), | ||
| receiptsLen: len(s.receipts), | ||
| userTxHash: userTxHash, | ||
| userTx: userTx, | ||
| } | ||
| return nil | ||
| } | ||
|
|
@@ -213,10 +220,10 @@ type SequencingHooks interface { | |
| // SupportsGroupRollback returns whether the hooks support checkpointing and | ||
| // rolling back a group of transactions (user tx + its scheduled redeems). | ||
| SupportsGroupRollback() bool | ||
| // PreTxFilter rejects a tx before execution. | ||
| PreTxFilter(*params.ChainConfig, *types.Header, *state.StateDB, *arbosState.ArbosState, *types.Transaction, *arbitrum_types.ConditionalOptions, common.Address, *L1Info) error | ||
| // PostTxFilter rejects a tx after execution. | ||
| PostTxFilter(*types.Header, *state.StateDB, *arbosState.ArbosState, *types.Transaction, common.Address, uint64, *core.ExecutionResult) error | ||
| // PreTxFilter rejects a tx before execution. positionInBlock is len(receipts) at call time. | ||
| PreTxFilter(*params.ChainConfig, *types.Header, *state.StateDB, *arbosState.ArbosState, *types.Transaction, *arbitrum_types.ConditionalOptions, common.Address, *L1Info, int) error | ||
| // PostTxFilter rejects a tx after execution. positionInBlock is len(receipts) at call time. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to remove this positionInBlock comment. |
||
| PostTxFilter(*types.Header, *state.StateDB, *arbosState.ArbosState, *types.Transaction, common.Address, uint64, *core.ExecutionResult, int) error | ||
| // BlockFilter rejects an entire block after all txs have been applied. | ||
| BlockFilter(*types.Header, *state.StateDB, types.Transactions, types.Receipts) error | ||
| // TxSucceeded records that the last user tx from NextTxToSequence executed successfully. | ||
|
|
@@ -244,11 +251,11 @@ func (n *NoopSequencingHooks) NextTxToSequence() (*types.Transaction, *arbitrum_ | |
|
|
||
| func (n *NoopSequencingHooks) CanDiscardTx() bool { return false } | ||
|
|
||
| func (n *NoopSequencingHooks) PreTxFilter(config *params.ChainConfig, header *types.Header, db *state.StateDB, a *arbosState.ArbosState, transaction *types.Transaction, options *arbitrum_types.ConditionalOptions, address common.Address, info *L1Info) error { | ||
| func (n *NoopSequencingHooks) PreTxFilter(config *params.ChainConfig, header *types.Header, db *state.StateDB, a *arbosState.ArbosState, transaction *types.Transaction, options *arbitrum_types.ConditionalOptions, address common.Address, info *L1Info, positionInBlock int) error { | ||
| return nil | ||
| } | ||
|
|
||
| func (n *NoopSequencingHooks) PostTxFilter(header *types.Header, db *state.StateDB, a *arbosState.ArbosState, transaction *types.Transaction, address common.Address, u uint64, result *core.ExecutionResult) error { | ||
| func (n *NoopSequencingHooks) PostTxFilter(header *types.Header, db *state.StateDB, a *arbosState.ArbosState, transaction *types.Transaction, address common.Address, u uint64, result *core.ExecutionResult, positionInBlock int) error { | ||
| return nil | ||
| } | ||
|
|
||
|
|
@@ -426,7 +433,7 @@ func ProduceBlockAdvanced( | |
|
|
||
| // Writes to statedb object should be avoided to prevent invalid state from permeating as statedb snapshot is not taken | ||
| if isUserTx { | ||
| if err = sequencingHooks.PreTxFilter(chainConfig, header, buildState.statedb, buildState.arbState, tx, options, sender, l1Info); err != nil { | ||
| if err = sequencingHooks.PreTxFilter(chainConfig, header, buildState.statedb, buildState.arbState, tx, options, sender, l1Info, len(buildState.receipts)); err != nil { | ||
| return nil, nil, err | ||
| } | ||
| } | ||
|
|
@@ -489,15 +496,15 @@ func ProduceBlockAdvanced( | |
| &header.GasUsed, | ||
| runCtx, | ||
| func(result *core.ExecutionResult) error { | ||
| if err := sequencingHooks.PostTxFilter(header, buildState.statedb, buildState.arbState, tx, sender, dataGas, result); err != nil { | ||
| if err := sequencingHooks.PostTxFilter(header, buildState.statedb, buildState.arbState, tx, sender, dataGas, result, len(buildState.receipts)); err != nil { | ||
| return err | ||
| } | ||
| // Additional post-transaction validity check | ||
| if err = extraPostTxFilter(chainConfig, header, buildState.statedb, buildState.arbState, tx, options, sender, l1Info, result); err != nil { | ||
| return err | ||
| } | ||
| if isUserTx && len(result.ScheduledTxes) > 0 && sequencingHooks.SupportsGroupRollback() { | ||
| if err := buildState.saveGroupCheckpoint(header, snap, tx.Hash()); err != nil { | ||
| if err := buildState.saveGroupCheckpoint(header, snap, tx); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
@@ -519,11 +526,19 @@ func ProduceBlockAdvanced( | |
| // active group checkpoint, roll back the entire group (user tx + all | ||
| // redeems) to the pre-group state. | ||
| if !isUserTx && buildState.activeGroupCP != nil && errors.Is(err, state.ErrArbTxFilter) { | ||
| userTxHash := buildState.activeGroupCP.userTxHash | ||
| // Capture everything before rollback — addressCheckerStateß | ||
| cp := buildState.activeGroupCP | ||
| _, filteredAddresses := buildState.statedb.IsAddressFiltered() | ||
| if err := buildState.rollbackToGroupCheckpoint(header); err != nil { | ||
| return nil, nil, nil, err | ||
| } | ||
| sequencingHooks.TxFailed(&ErrFilteredCascadingRedeem{OriginatingTxHash: userTxHash}) | ||
| sequencingHooks.TxFailed(&ErrFilteredCascadingRedeem{ | ||
| OriginatingTx: cp.userTx, | ||
| FilteredAddresses: filteredAddresses, | ||
| BlockNumber: header.Number.Uint64(), | ||
| ParentBlockHash: header.ParentHash, | ||
| PositionInBlock: cp.receiptsLen, | ||
| }) | ||
| continue | ||
| } | ||
| if isUserTx { | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ### Added | ||
| - Report filtered delayed transactions to filtering-report service with structured FilteredTxReport |
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Better to remove this positionInBlock comment.
Arguments are not named here.