Skip to content
Merged
Show file tree
Hide file tree
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 Feb 4, 2026
c3703c2
op-supernode: Add unit tests for block invalidation
axelKingsley Feb 4, 2026
aecad4e
Wire up block invalidation from interop activity to chain container
axelKingsley Feb 4, 2026
e712178
Fix block invalidation: use eth.Unsafe label and improve test resilience
axelKingsley Feb 4, 2026
d344c0c
op-node: add SuperAuthority interface for payload denial
axelKingsley Feb 5, 2026
1194228
op-supernode: add ResetOn method to Activity interface
axelKingsley Feb 5, 2026
8b09932
op-supernode: add SetResetCallback to ChainContainer
axelKingsley Feb 5, 2026
9d8ae51
op-supernode: implement ResetOn in Interop activity
axelKingsley Feb 5, 2026
c44538e
op-acceptance-tests: add replacement block assertions
axelKingsley Feb 5, 2026
c4690af
fill in missing unit tests
axelKingsley Feb 6, 2026
882d008
address review feedback: genesis block guard and docs
axelKingsley Feb 6, 2026
4bb97f3
op-acceptance-tests: rename halt package to reorg, consolidate tests
axelKingsley Feb 6, 2026
490412e
sub-feature 6: interop test control (PauseInterop/ResumeInterop)
axelKingsley Feb 9, 2026
0a814ac
Updates from Self Review
axelKingsley Feb 9, 2026
c68e3e2
lint
axelKingsley Feb 9, 2026
7d33d82
datadir for unit tests
axelKingsley Feb 9, 2026
8c57ec8
Add functions to DSL
axelKingsley Feb 10, 2026
21e224c
PR comments: Rename Functions ; Remove non-holocene replacement logic
axelKingsley Feb 11, 2026
7516c45
refactor: cleanup DSL, tests, and interop activity
axelKingsley Feb 11, 2026
af28ee6
Refacor Tests to Test Cases
axelKingsley Feb 11, 2026
7aa96dc
Delete AI Diary
axelKingsley Feb 11, 2026
7c2817b
Final PR Comments
axelKingsley Feb 11, 2026
06b1cbe
More tests to sub-cases
axelKingsley Feb 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package halt
package reorg

import (
"os"
Expand All @@ -8,7 +8,7 @@ import (
)

// TestMain creates an isolated two-L2 setup with a shared supernode that has interop enabled.
// This package tests invalid message scenarios that would pollute other tests if run on a shared devnet.
// This package tests block invalidation and reorg scenarios that would pollute other tests if run on a shared devnet.
func TestMain(m *testing.M) {
_ = os.Setenv("DEVSTACK_L2CL_KIND", "supernode")
presets.DoMain(m, presets.WithTwoL2SupernodeInterop(0))
Expand Down
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
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)
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 {
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,
)
}
Loading