-
Notifications
You must be signed in to change notification settings - Fork 3.9k
op-supernode: Block Replacement #19091
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
e6817fd
op-supernode: Add block invalidation and deny list to chain container
axelKingsley c3703c2
op-supernode: Add unit tests for block invalidation
axelKingsley aecad4e
Wire up block invalidation from interop activity to chain container
axelKingsley e712178
Fix block invalidation: use eth.Unsafe label and improve test resilience
axelKingsley d344c0c
op-node: add SuperAuthority interface for payload denial
axelKingsley 1194228
op-supernode: add ResetOn method to Activity interface
axelKingsley 8b09932
op-supernode: add SetResetCallback to ChainContainer
axelKingsley 9d8ae51
op-supernode: implement ResetOn in Interop activity
axelKingsley c44538e
op-acceptance-tests: add replacement block assertions
axelKingsley c4690af
fill in missing unit tests
axelKingsley 882d008
address review feedback: genesis block guard and docs
axelKingsley 4bb97f3
op-acceptance-tests: rename halt package to reorg, consolidate tests
axelKingsley 490412e
sub-feature 6: interop test control (PauseInterop/ResumeInterop)
axelKingsley 0a814ac
Updates from Self Review
axelKingsley c68e3e2
lint
axelKingsley 7d33d82
datadir for unit tests
axelKingsley 8c57ec8
Add functions to DSL
axelKingsley 21e224c
PR comments: Rename Functions ; Remove non-holocene replacement logic
axelKingsley 7516c45
refactor: cleanup DSL, tests, and interop activity
axelKingsley af28ee6
Refacor Tests to Test Cases
axelKingsley 7aa96dc
Delete AI Diary
axelKingsley 7c2817b
Final PR Comments
axelKingsley 06b1cbe
More tests to sub-cases
axelKingsley 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
251 changes: 0 additions & 251 deletions
251
op-acceptance-tests/tests/supernode/interop/halt/invalid_message_halt_test.go
This file was deleted.
Oops, something went wrong.
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
123 changes: 123 additions & 0 deletions
123
op-acceptance-tests/tests/supernode/interop/reorg/invalid_message_reorg_test.go
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,123 @@ | ||
| package reorg | ||
|
|
||
| import ( | ||
| "errors" | ||
| "math/rand" | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/ethereum/go-ethereum" | ||
| "github.com/stretchr/testify/require" | ||
|
|
||
| "github.com/ethereum-optimism/optimism/op-devstack/devtest" | ||
| "github.com/ethereum-optimism/optimism/op-devstack/presets" | ||
| "github.com/ethereum-optimism/optimism/op-service/bigs" | ||
| "github.com/ethereum-optimism/optimism/op-service/eth" | ||
| ) | ||
|
|
||
| // TestSupernodeInteropInvalidMessageReplacement tests that: | ||
| // WHEN: an invalid Executing Message is included in a chain | ||
| // THEN: | ||
| // - The interop activity detects the invalid block | ||
| // - The chain container is told to invalidate the block | ||
| // - A reset/rewind is triggered if the chain is using that block | ||
| // - A replacement block is built at the same height (deposits-only) | ||
| // - The replacement block's timestamp eventually becomes verified | ||
axelKingsley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| func TestSupernodeInteropInvalidMessageReplacement(gt *testing.T) { | ||
|
|
||
| t := devtest.SerialT(gt) | ||
| sys := presets.NewTwoL2SupernodeInterop(t, 0) | ||
|
|
||
| ctx := t.Ctx() | ||
|
|
||
| // Create funded EOAs on both chains | ||
| alice := sys.FunderA.NewFundedEOA(eth.OneEther) | ||
| bob := sys.FunderB.NewFundedEOA(eth.OneEther) | ||
|
|
||
| // Deploy event logger on chain A | ||
| eventLoggerA := alice.DeployEventLogger() | ||
|
|
||
| // Sync chains | ||
| sys.L2B.CatchUpTo(sys.L2A) | ||
| sys.L2A.CatchUpTo(sys.L2B) | ||
|
|
||
| rng := rand.New(rand.NewSource(12345)) | ||
|
|
||
| // Send an initiating message on chain A | ||
| initTx, initReceipt := alice.SendRandomInitMessage(rng, eventLoggerA, 2, 10) | ||
|
|
||
| t.Logger().Info("initiating message sent on chain A", | ||
| "block", initReceipt.BlockNumber, | ||
| "hash", initReceipt.BlockHash, | ||
| ) | ||
|
|
||
| // Wait for chain B to catch up | ||
| sys.L2B.WaitForBlock() | ||
|
|
||
| // Wait for some timestamps to be verified first | ||
| targetTimestamp := sys.L2A.TimestampForBlockNum(2) | ||
| // set supernode to pause verification just after this timestamp | ||
| sys.Supernode.PauseInterop(targetTimestamp + 1) | ||
| sys.Supernode.AwaitValidatedTimestamp(targetTimestamp) | ||
|
|
||
| t.Logger().Info("initial verification confirmed", "timestamp", targetTimestamp) | ||
|
|
||
| // Send an INVALID executing message on chain B | ||
| _, invalidExecReceipt := bob.SendInvalidExecMessage(initTx, 0) | ||
| invalidBlockNumber := bigs.Uint64Strict(invalidExecReceipt.BlockNumber) | ||
| invalidBlockHash := invalidExecReceipt.BlockHash | ||
| invalidBlockTimestamp := sys.L2B.TimestampForBlockNum(invalidBlockNumber) | ||
| t.Logger().Info("invalid executing message sent on chain B", | ||
| "block", invalidBlockNumber, | ||
| "hash", invalidBlockHash, | ||
| "timestamp", invalidBlockTimestamp, | ||
| ) | ||
|
|
||
| // Wait for local safety to include the invalid block | ||
| require.Eventually(t, func() bool { | ||
| numSafe := sys.L2BCL.SyncStatus().LocalSafeL2.Number >= invalidBlockNumber | ||
| return numSafe | ||
| }, 60*time.Second, time.Second, "invalid block should become locally safe") | ||
|
|
||
| // Resume interop and observe reorg | ||
| // Interop activity will proceed and invalidate the block, triggering a rewind, and building a replacement block | ||
| // We observe resets and replacements, but only proceed on replacement (we may miss reset if it happens quickly) | ||
axelKingsley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| sys.Supernode.ResumeInterop() | ||
| require.Eventually(t, func() bool { | ||
| // Check if the block hash at the invalid block number changed or block doesn't exist | ||
| // Use the EthClient directly to handle errors (block may not exist after rewind) | ||
| currentBlock, err := sys.L2ELB.Escape().EthClient().BlockRefByNumber(ctx, invalidBlockNumber) | ||
| if err != nil { | ||
axelKingsley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if errors.Is(eth.MaybeAsNotFoundErr(err), ethereum.NotFound) { | ||
| t.Logger().Info("RESET DETECTED! Block no longer exists (rewound)", | ||
| "block_number", invalidBlockNumber, | ||
| ) | ||
| } else { | ||
| t.Logger().Warn("unexpected error checking block", | ||
| "block_number", invalidBlockNumber, | ||
| "err", err, | ||
| ) | ||
| } | ||
| } else if currentBlock.Hash != invalidBlockHash { | ||
| t.Logger().Info("RESET DETECTED! Block hash changed", | ||
| "block_number", invalidBlockNumber, | ||
| "old_hash", invalidBlockHash, | ||
| "new_hash", currentBlock.Hash, | ||
| ) | ||
| return true | ||
| } | ||
| return false | ||
| }, 60*time.Second, time.Second, "reset should be detected") | ||
|
|
||
| // Wait for interop to proceed and verify the replacement block at the timestamp | ||
| sys.Supernode.AwaitValidatedTimestamp(invalidBlockTimestamp) | ||
|
|
||
| // ASSERTION: The invalid transaction no longer exists in the chain | ||
| // The invalid exec message transaction should NOT be in the replacement block | ||
| sys.L2ELB.AssertTxNotInBlock(invalidBlockNumber, invalidExecReceipt.TxHash) | ||
|
|
||
| t.Logger().Info("test complete: invalid block was replaced and verified", | ||
| "invalid_block_number", invalidBlockNumber, | ||
| "invalid_block_hash", invalidBlockHash, | ||
| ) | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.