forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
op-node: op-node interop block verification (devnet-1 scope) (ethereu…
…m-optimism#11611) * op-node: experimental interop block verification * op-node: supervisor RPC init * op-e2e/actions: test interop safety checks * op-e2e/op-node: test fixes * op-node: update comments * op-node: unit-test interop deriver, trigger cross-safe updates on driver step, to poll for supervisor safety changes * op-node: add more comments, fix flag description * op-e2e: fix rebase, add missing argument
- Loading branch information
1 parent
58132de
commit c801597
Showing
25 changed files
with
903 additions
and
55 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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 actions | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/ethereum/go-ethereum/log" | ||
|
||
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils" | ||
"github.com/ethereum-optimism/optimism/op-node/rollup/interop" | ||
"github.com/ethereum-optimism/optimism/op-node/rollup/sync" | ||
"github.com/ethereum-optimism/optimism/op-service/testlog" | ||
"github.com/ethereum-optimism/optimism/op-service/testutils" | ||
"github.com/ethereum-optimism/optimism/op-supervisor/supervisor/types" | ||
) | ||
|
||
var _ interop.InteropBackend = (*testutils.MockInteropBackend)(nil) | ||
|
||
func TestInteropVerifier(gt *testing.T) { | ||
t := NewDefaultTesting(gt) | ||
dp := e2eutils.MakeDeployParams(t, defaultRollupTestParams) | ||
sd := e2eutils.Setup(t, dp, defaultAlloc) | ||
// Temporary work-around: interop needs to be active, for cross-safety to not be instant. | ||
// The state genesis in this test is pre-interop however. | ||
sd.RollupCfg.InteropTime = new(uint64) | ||
logger := testlog.Logger(t, log.LevelDebug) | ||
seqMockBackend := &testutils.MockInteropBackend{} | ||
l1Miner, seqEng, seq := setupSequencerTest(t, sd, logger, | ||
WithVerifierOpts(WithInteropBackend(seqMockBackend))) | ||
|
||
batcher := NewL2Batcher(logger, sd.RollupCfg, DefaultBatcherCfg(dp), | ||
seq.RollupClient(), l1Miner.EthClient(), seqEng.EthClient(), seqEng.EngineClient(t, sd.RollupCfg)) | ||
|
||
verMockBackend := &testutils.MockInteropBackend{} | ||
_, ver := setupVerifier(t, sd, logger, | ||
l1Miner.L1Client(t, sd.RollupCfg), l1Miner.BlobStore(), &sync.Config{}, | ||
WithInteropBackend(verMockBackend)) | ||
|
||
seq.ActL2PipelineFull(t) | ||
ver.ActL2PipelineFull(t) | ||
|
||
l2ChainID := types.ChainIDFromBig(sd.RollupCfg.L2ChainID) | ||
seqMockBackend.ExpectCheckBlock(l2ChainID, 1, types.Unsafe, nil) | ||
// create an unsafe L2 block | ||
seq.ActL2StartBlock(t) | ||
seq.ActL2EndBlock(t) | ||
seq.ActL2PipelineFull(t) | ||
seqMockBackend.AssertExpectations(t) | ||
status := seq.SyncStatus() | ||
require.Equal(t, uint64(1), status.UnsafeL2.Number) | ||
require.Equal(t, uint64(0), status.CrossUnsafeL2.Number) | ||
require.Equal(t, uint64(0), status.LocalSafeL2.Number) | ||
require.Equal(t, uint64(0), status.SafeL2.Number) | ||
|
||
// promote it to cross-unsafe in the backend | ||
// and see if the node picks up on it | ||
seqMockBackend.ExpectCheckBlock(l2ChainID, 1, types.CrossUnsafe, nil) | ||
seq.ActInteropBackendCheck(t) | ||
seq.ActL2PipelineFull(t) | ||
seqMockBackend.AssertExpectations(t) | ||
status = seq.SyncStatus() | ||
require.Equal(t, uint64(1), status.UnsafeL2.Number) | ||
require.Equal(t, uint64(1), status.CrossUnsafeL2.Number, "cross unsafe now") | ||
require.Equal(t, uint64(0), status.LocalSafeL2.Number) | ||
require.Equal(t, uint64(0), status.SafeL2.Number) | ||
|
||
// submit all new L2 blocks | ||
batcher.ActSubmitAll(t) | ||
// new L1 block with L2 batch | ||
l1Miner.ActL1StartBlock(12)(t) | ||
l1Miner.ActL1IncludeTx(sd.RollupCfg.Genesis.SystemConfig.BatcherAddr)(t) | ||
l1Miner.ActL1EndBlock(t) | ||
|
||
// Sync the L1 block, to verify the L2 block as local-safe. | ||
seqMockBackend.ExpectCheckBlock(l2ChainID, 1, types.CrossUnsafe, nil) // not cross-safe yet | ||
seq.ActL1HeadSignal(t) | ||
seq.ActL2PipelineFull(t) | ||
seqMockBackend.AssertExpectations(t) | ||
|
||
status = seq.SyncStatus() | ||
require.Equal(t, uint64(1), status.UnsafeL2.Number) | ||
require.Equal(t, uint64(1), status.CrossUnsafeL2.Number) | ||
require.Equal(t, uint64(1), status.LocalSafeL2.Number, "local safe changed") | ||
require.Equal(t, uint64(0), status.SafeL2.Number) | ||
|
||
// Now mark it as cross-safe | ||
seqMockBackend.ExpectCheckBlock(l2ChainID, 1, types.CrossSafe, nil) | ||
seq.ActInteropBackendCheck(t) | ||
seq.ActL2PipelineFull(t) | ||
seqMockBackend.AssertExpectations(t) | ||
|
||
status = seq.SyncStatus() | ||
require.Equal(t, uint64(1), status.UnsafeL2.Number) | ||
require.Equal(t, uint64(1), status.CrossUnsafeL2.Number) | ||
require.Equal(t, uint64(1), status.LocalSafeL2.Number) | ||
require.Equal(t, uint64(1), status.SafeL2.Number, "cross-safe reached") | ||
require.Equal(t, uint64(0), status.FinalizedL2.Number) | ||
|
||
// The verifier might not see the L2 block that was just derived from L1 as cross-verified yet. | ||
verMockBackend.ExpectCheckBlock(l2ChainID, 1, types.Unsafe, nil) // for the local unsafe check | ||
verMockBackend.ExpectCheckBlock(l2ChainID, 1, types.Unsafe, nil) // for the local safe check | ||
ver.ActL1HeadSignal(t) | ||
ver.ActL2PipelineFull(t) | ||
verMockBackend.AssertExpectations(t) | ||
status = ver.SyncStatus() | ||
require.Equal(t, uint64(1), status.UnsafeL2.Number, "synced the block") | ||
require.Equal(t, uint64(0), status.CrossUnsafeL2.Number, "not cross-verified yet") | ||
require.Equal(t, uint64(1), status.LocalSafeL2.Number, "derived from L1, thus local-safe") | ||
require.Equal(t, uint64(0), status.SafeL2.Number, "not yet cross-safe") | ||
require.Equal(t, uint64(0), status.FinalizedL2.Number) | ||
|
||
// signal that L1 finalized; the cross-safe block we have should get finalized too | ||
l1Miner.ActL1SafeNext(t) | ||
l1Miner.ActL1FinalizeNext(t) | ||
seq.ActL1SafeSignal(t) | ||
seq.ActL1FinalizedSignal(t) | ||
seq.ActL2PipelineFull(t) | ||
seqMockBackend.AssertExpectations(t) | ||
|
||
status = seq.SyncStatus() | ||
require.Equal(t, uint64(1), status.FinalizedL2.Number, "finalized the block") | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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.