Commit 0e294749 authored by clabby's avatar clabby Committed by GitHub

add sequence window expiry test (#11897)

parent 9e1f077f
...@@ -41,13 +41,13 @@ func NewL2FaultProofEnv(t actions.Testing, tp *e2eutils.TestParams, dp *e2eutils ...@@ -41,13 +41,13 @@ func NewL2FaultProofEnv(t actions.Testing, tp *e2eutils.TestParams, dp *e2eutils
miner := actions.NewL1Miner(t, log.New("role", "l1-miner"), sd.L1Cfg) miner := actions.NewL1Miner(t, log.New("role", "l1-miner"), sd.L1Cfg)
l1F, err := sources.NewL1Client(miner.RPCClient(), log, nil, sources.L1ClientDefaultConfig(sd.RollupCfg, false, sources.RPCKindStandard)) l1Cl, err := sources.NewL1Client(miner.RPCClient(), log, nil, sources.L1ClientDefaultConfig(sd.RollupCfg, false, sources.RPCKindStandard))
require.NoError(t, err) require.NoError(t, err)
engine := actions.NewL2Engine(t, log.New("role", "sequencer-engine"), sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath, actions.EngineWithP2P()) engine := actions.NewL2Engine(t, log.New("role", "sequencer-engine"), sd.L2Cfg, sd.RollupCfg.Genesis.L1, jwtPath, actions.EngineWithP2P())
l2Cl, err := sources.NewEngineClient(engine.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg)) l2EngineCl, err := sources.NewEngineClient(engine.RPCClient(), log, nil, sources.EngineClientDefaultConfig(sd.RollupCfg))
require.NoError(t, err) require.NoError(t, err)
sequencer := actions.NewL2Sequencer(t, log.New("role", "sequencer"), l1F, miner.BlobStore(), altda.Disabled, l2Cl, sd.RollupCfg, 0, cfg.InteropBackend) sequencer := actions.NewL2Sequencer(t, log.New("role", "sequencer"), l1Cl, miner.BlobStore(), altda.Disabled, l2EngineCl, sd.RollupCfg, 0, cfg.InteropBackend)
miner.ActL1SetFeeRecipient(common.Address{0xCA, 0xFE, 0xBA, 0xBE}) miner.ActL1SetFeeRecipient(common.Address{0xCA, 0xFE, 0xBA, 0xBE})
sequencer.ActL2PipelineFull(t) sequencer.ActL2PipelineFull(t)
engCl := engine.EngineClient(t, sd.RollupCfg) engCl := engine.EngineClient(t, sd.RollupCfg)
...@@ -57,14 +57,22 @@ func NewL2FaultProofEnv(t actions.Testing, tp *e2eutils.TestParams, dp *e2eutils ...@@ -57,14 +57,22 @@ func NewL2FaultProofEnv(t actions.Testing, tp *e2eutils.TestParams, dp *e2eutils
batcher := actions.NewL2Batcher(log, sd.RollupCfg, batcherCfg, sequencer.RollupClient(), miner.EthClient(), engine.EthClient(), engCl) batcher := actions.NewL2Batcher(log, sd.RollupCfg, batcherCfg, sequencer.RollupClient(), miner.EthClient(), engine.EthClient(), engCl)
addresses := e2eutils.CollectAddresses(sd, dp) addresses := e2eutils.CollectAddresses(sd, dp)
cl := engine.EthClient() l1EthCl := miner.EthClient()
l2EthCl := engine.EthClient()
l1UserEnv := &actions.BasicUserEnv[*actions.L1Bindings]{
EthCl: l1EthCl,
Signer: types.LatestSigner(sd.L1Cfg.Config),
AddressCorpora: addresses,
Bindings: actions.NewL1Bindings(t, l1EthCl),
}
l2UserEnv := &actions.BasicUserEnv[*actions.L2Bindings]{ l2UserEnv := &actions.BasicUserEnv[*actions.L2Bindings]{
EthCl: cl, EthCl: l2EthCl,
Signer: types.LatestSigner(sd.L2Cfg.Config), Signer: types.LatestSigner(sd.L2Cfg.Config),
AddressCorpora: addresses, AddressCorpora: addresses,
Bindings: actions.NewL2Bindings(t, cl, engine.GethClient()), Bindings: actions.NewL2Bindings(t, l2EthCl, engine.GethClient()),
} }
alice := actions.NewCrossLayerUser(log, dp.Secrets.Alice, rand.New(rand.NewSource(0xa57b))) alice := actions.NewCrossLayerUser(log, dp.Secrets.Alice, rand.New(rand.NewSource(0xa57b)))
alice.L1.SetUserEnv(l1UserEnv)
alice.L2.SetUserEnv(l2UserEnv) alice.L2.SetUserEnv(l2UserEnv)
return &L2FaultProofEnv{ return &L2FaultProofEnv{
......
package proofs
import (
"testing"
"github.com/ethereum-optimism/optimism/op-e2e/actions"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-program/client/claim"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/stretchr/testify/require"
)
// Run a test that proves a deposit-only block generated due to sequence window expiry.
func runSequenceWindowExpireTest(gt *testing.T, checkResult func(gt *testing.T, err error), inputParams ...FixtureInputParam) {
t := actions.NewDefaultTesting(gt)
tp := NewTestParams()
dp := NewDeployParams(t, func(dp *e2eutils.DeployParams) {
genesisBlock := hexutil.Uint64(0)
// Enable Cancun on L1 & Granite on L2 at genesis
dp.DeployConfig.L1CancunTimeOffset = &genesisBlock
dp.DeployConfig.L2GenesisRegolithTimeOffset = &genesisBlock
dp.DeployConfig.L2GenesisCanyonTimeOffset = &genesisBlock
dp.DeployConfig.L2GenesisDeltaTimeOffset = &genesisBlock
dp.DeployConfig.L2GenesisEcotoneTimeOffset = &genesisBlock
dp.DeployConfig.L2GenesisFjordTimeOffset = &genesisBlock
dp.DeployConfig.L2GenesisGraniteTimeOffset = &genesisBlock
})
bCfg := NewBatcherCfg()
env := NewL2FaultProofEnv(t, tp, dp, bCfg)
// Mine an empty block for gas estimation purposes.
env.miner.ActEmptyBlock(t)
// Expire the sequence window by building `SequenceWindow + 1` empty blocks on L1.
for i := 0; i < int(tp.SequencerWindowSize)+1; i++ {
env.alice.L1.ActResetTxOpts(t)
env.alice.ActDeposit(t)
env.miner.ActL1StartBlock(12)(t)
env.miner.ActL1IncludeTx(env.alice.Address())(t)
env.miner.ActL1EndBlock(t)
env.miner.ActL1SafeNext(t)
env.miner.ActL1FinalizeNext(t)
}
// Ensure the safe head is still 0.
l2SafeHead := env.engine.L2Chain().CurrentSafeBlock()
require.EqualValues(t, 0, l2SafeHead.Number.Uint64())
// Ask the sequencer to derive the deposit-only L2 chain.
env.sequencer.ActL1HeadSignal(t)
env.sequencer.ActL2PipelineFull(t)
// Ensure the safe head advanced forcefully.
l2SafeHead = env.engine.L2Chain().CurrentSafeBlock()
require.Greater(t, l2SafeHead.Number.Uint64(), uint64(0))
// Run the FPP on one of the auto-derived blocks.
err := env.RunFaultProofProgram(t, gt, l2SafeHead.Number.Uint64()/2, inputParams...)
checkResult(gt, err)
}
func Test_ProgramAction_SequenceWindowExpired_HonestClaim_Granite(gt *testing.T) {
runSequenceWindowExpireTest(gt, func(gt *testing.T, err error) {
require.NoError(gt, err, "fault proof program should have succeeded")
})
}
func Test_ProgramAction_SequenceWindowExpired_JunkClaim_Granite(gt *testing.T) {
runSequenceWindowExpireTest(
gt,
func(gt *testing.T, err error) {
require.ErrorIs(gt, err, claim.ErrClaimNotValid, "fault proof program should have failed")
},
func(f *FixtureInputs) {
f.L2Claim = common.HexToHash("0xdeadbeef")
},
)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment