Commit 6c7f9b3c authored by protolambda's avatar protolambda Committed by GitHub

Fix fork tests (#9031)

* op-e2e: fix fork tests

go.mod: update to include ecotone l1 fee scalar receipts nil check

review fixes

* op-e2e: fix lint

* op-e2e: start making L1-fees test a bit more compatible, but GPO contract still has shortcomings
parent a7e473e1
...@@ -219,7 +219,7 @@ require ( ...@@ -219,7 +219,7 @@ require (
rsc.io/tmplfunc v0.0.3 // indirect rsc.io/tmplfunc v0.0.3 // indirect
) )
replace github.com/ethereum/go-ethereum v1.13.5 => github.com/ethereum-optimism/op-geth v1.101305.2-rc.2 replace github.com/ethereum/go-ethereum v1.13.5 => github.com/ethereum-optimism/op-geth v1.101305.2-rc.2.0.20240117002010-d5f142e54a0a
//replace github.com/ethereum-optimism/superchain-registry/superchain => ../superchain-registry/superchain //replace github.com/ethereum-optimism/superchain-registry/superchain => ../superchain-registry/superchain
//replace github.com/ethereum/go-ethereum v1.13.5 => ../go-ethereum //replace github.com/ethereum/go-ethereum v1.13.5 => ../go-ethereum
...@@ -170,8 +170,8 @@ github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/ ...@@ -170,8 +170,8 @@ github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/
github.com/elastic/gosigar v0.14.2/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= github.com/elastic/gosigar v0.14.2/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z8veEq5ZO3DfIhZ7xgRP9WTc= github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3 h1:RWHKLhCrQThMfch+QJ1Z8veEq5ZO3DfIhZ7xgRP9WTc=
github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs= github.com/ethereum-optimism/go-ethereum-hdwallet v0.1.3/go.mod h1:QziizLAiF0KqyLdNJYD7O5cpDlaFMNZzlxYNcWsJUxs=
github.com/ethereum-optimism/op-geth v1.101305.2-rc.2 h1:UQVo1JKEjZ80JdrL4meey1KhHmdbT/l6kmc8SzIbp3s= github.com/ethereum-optimism/op-geth v1.101305.2-rc.2.0.20240117002010-d5f142e54a0a h1:QX7fp0vyIFYefxCXP9h5iki+EPfdizIXCNeXS12EaZ4=
github.com/ethereum-optimism/op-geth v1.101305.2-rc.2/go.mod h1:HGpRaQiUONEEfsL/hq9/jg8YnR9TCHCPqjmaPoFBhto= github.com/ethereum-optimism/op-geth v1.101305.2-rc.2.0.20240117002010-d5f142e54a0a/go.mod h1:HGpRaQiUONEEfsL/hq9/jg8YnR9TCHCPqjmaPoFBhto=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240103191009-655947053753 h1:DL667cfM6peU8H9Ut/uu9h9Bd4gQCcJrjq+yYsfYwjk= github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240103191009-655947053753 h1:DL667cfM6peU8H9Ut/uu9h9Bd4gQCcJrjq+yYsfYwjk=
github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240103191009-655947053753/go.mod h1:/70H/KqrtKcvWvNGVj6S3rAcLC+kUPr3t2aDmYIS+Xk= github.com/ethereum-optimism/superchain-registry/superchain v0.0.0-20240103191009-655947053753/go.mod h1:/70H/KqrtKcvWvNGVj6S3rAcLC+kUPr3t2aDmYIS+Xk=
github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY= github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY=
......
...@@ -371,6 +371,34 @@ func (d *DeployConfig) Check() error { ...@@ -371,6 +371,34 @@ func (d *DeployConfig) Check() error {
if d.RecommendedProtocolVersion == (params.ProtocolVersion{}) { if d.RecommendedProtocolVersion == (params.ProtocolVersion{}) {
log.Warn("RecommendedProtocolVersion is empty") log.Warn("RecommendedProtocolVersion is empty")
} }
// checkFork checks that fork A is before or at the same time as fork B
checkFork := func(a, b *hexutil.Uint64, aName, bName string) error {
if a == nil && b == nil {
return nil
}
if a == nil && b != nil {
return fmt.Errorf("fork %s set (to %d), but prior fork %s missing", bName, *b, aName)
}
if a != nil && b == nil {
return nil
}
if *a > *b {
return fmt.Errorf("fork %s set to %d, but prior fork %s has higher offset %d", bName, *b, aName, *a)
}
return nil
}
if err := checkFork(d.L2GenesisRegolithTimeOffset, d.L2GenesisCanyonTimeOffset, "regolith", "canyon"); err != nil {
return err
}
if err := checkFork(d.L2GenesisCanyonTimeOffset, d.L2GenesisDeltaTimeOffset, "canyon", "delta"); err != nil {
return err
}
if err := checkFork(d.L2GenesisDeltaTimeOffset, d.L2GenesisEcotoneTimeOffset, "delta", "ecotone"); err != nil {
return err
}
if err := checkFork(d.L2GenesisEcotoneTimeOffset, d.L2GenesisFjordTimeOffset, "ecotone", "fjord"); err != nil {
return err
}
return nil return nil
} }
......
...@@ -64,6 +64,7 @@ func NewL2Genesis(config *DeployConfig, block *types.Block) (*core.Genesis, erro ...@@ -64,6 +64,7 @@ func NewL2Genesis(config *DeployConfig, block *types.Block) (*core.Genesis, erro
RegolithTime: config.RegolithTime(block.Time()), RegolithTime: config.RegolithTime(block.Time()),
CanyonTime: config.CanyonTime(block.Time()), CanyonTime: config.CanyonTime(block.Time()),
ShanghaiTime: config.CanyonTime(block.Time()), ShanghaiTime: config.CanyonTime(block.Time()),
EcotoneTime: config.EcotoneTime(block.Time()), // separate from Dencun, for Blob-fees support activation
CancunTime: nil, // no Dencun on L2 yet. CancunTime: nil, // no Dencun on L2 yet.
InteropTime: config.InteropTime(block.Time()), InteropTime: config.InteropTime(block.Time()),
Optimism: &params.OptimismConfig{ Optimism: &params.OptimismConfig{
......
...@@ -157,9 +157,8 @@ func (s *L2Sequencer) ActBuildToL1HeadExclUnsafe(t Testing) { ...@@ -157,9 +157,8 @@ func (s *L2Sequencer) ActBuildToL1HeadExclUnsafe(t Testing) {
} }
} }
func (s *L2Sequencer) ActBuildL2ToRegolith(t Testing) { func (s *L2Sequencer) ActBuildL2ToTime(t Testing, target uint64) {
require.NotNil(t, s.rollupCfg.RegolithTime, "cannot activate Regolith when it is not scheduled") for s.L2Unsafe().Time < target {
for s.L2Unsafe().Time < *s.rollupCfg.RegolithTime {
s.ActL2StartBlock(t) s.ActL2StartBlock(t)
s.ActL2EndBlock(t) s.ActL2EndBlock(t)
} }
......
...@@ -58,10 +58,18 @@ type L2API interface { ...@@ -58,10 +58,18 @@ type L2API interface {
OutputV0AtBlock(ctx context.Context, blockHash common.Hash) (*eth.OutputV0, error) OutputV0AtBlock(ctx context.Context, blockHash common.Hash) (*eth.OutputV0, error)
} }
type EmptyBlobsSource struct {
}
func (b *EmptyBlobsSource) GetBlobs(ctx context.Context, ref eth.L1BlockRef, hashes []eth.IndexedBlobHash) ([]*eth.Blob, error) {
return nil, nil
}
func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher, eng L2API, cfg *rollup.Config, syncCfg *sync.Config) *L2Verifier { func NewL2Verifier(t Testing, log log.Logger, l1 derive.L1Fetcher, eng L2API, cfg *rollup.Config, syncCfg *sync.Config) *L2Verifier {
metrics := &testutils.TestDerivationMetrics{} metrics := &testutils.TestDerivationMetrics{}
engine := derive.NewEngineController(eng, log, metrics, cfg, syncCfg.SyncMode) engine := derive.NewEngineController(eng, log, metrics, cfg, syncCfg.SyncMode)
pipeline := derive.NewDerivationPipeline(log, cfg, l1, nil, eng, engine, metrics, syncCfg) blobsSrc := &EmptyBlobsSource{}
pipeline := derive.NewDerivationPipeline(log, cfg, l1, blobsSrc, eng, engine, metrics, syncCfg)
pipeline.Reset() pipeline.Reset()
rollupNode := &L2Verifier{ rollupNode := &L2Verifier{
......
package actions package actions
import ( import (
"fmt"
"math/rand" "math/rand"
"testing" "testing"
...@@ -14,14 +15,40 @@ import ( ...@@ -14,14 +15,40 @@ import (
) )
type hardforkScheduledTest struct { type hardforkScheduledTest struct {
name string
regolithTime *hexutil.Uint64 regolithTime *hexutil.Uint64
canyonTime *hexutil.Uint64
deltaTime *hexutil.Uint64 deltaTime *hexutil.Uint64
activateRegolith bool ecotoneTime *hexutil.Uint64
activateDelta bool fjordTime *hexutil.Uint64
runToFork string
} }
// TestCrossLayerUser tests that common actions of the CrossLayerUser actor work in various regolith configurations: func (tc *hardforkScheduledTest) SetFork(fork string, v uint64) {
*tc.fork(fork) = (*hexutil.Uint64)(&v)
}
func (tc *hardforkScheduledTest) GetFork(fork string) *uint64 {
return (*uint64)(*tc.fork(fork))
}
func (tc *hardforkScheduledTest) fork(fork string) **hexutil.Uint64 {
switch fork {
case "fjord":
return &tc.fjordTime
case "ecotone":
return &tc.ecotoneTime
case "delta":
return &tc.deltaTime
case "canyon":
return &tc.canyonTime
case "regolith":
return &tc.regolithTime
default:
panic(fmt.Errorf("unrecognized fork: %s", fork))
}
}
// TestCrossLayerUser tests that common actions of the CrossLayerUser actor work in various hardfork configurations:
// - transact on L1 // - transact on L1
// - transact on L2 // - transact on L2
// - deposit on L1 // - deposit on L1
...@@ -30,26 +57,49 @@ type hardforkScheduledTest struct { ...@@ -30,26 +57,49 @@ type hardforkScheduledTest struct {
// - wait 1 week + 1 second // - wait 1 week + 1 second
// - finalize withdrawal on L1 // - finalize withdrawal on L1
func TestCrossLayerUser(t *testing.T) { func TestCrossLayerUser(t *testing.T) {
zeroTime := hexutil.Uint64(0) futureTime := uint64(20)
futureTime := hexutil.Uint64(20) farFutureTime := uint64(2000)
farFutureTime := hexutil.Uint64(2000)
tests := []hardforkScheduledTest{ forks := []string{
{name: "NoRegolith", regolithTime: nil, activateRegolith: false, deltaTime: nil, activateDelta: false}, "regolith",
{name: "NotYetRegolith", regolithTime: &farFutureTime, activateRegolith: false, deltaTime: nil, activateDelta: false}, "canyon",
{name: "RegolithAtGenesis", regolithTime: &zeroTime, activateRegolith: true, deltaTime: nil, activateDelta: false}, "delta",
{name: "RegolithAfterGenesis", regolithTime: &futureTime, activateRegolith: true, deltaTime: nil, activateDelta: false}, "ecotone",
{name: "NoDelta", regolithTime: &zeroTime, activateRegolith: true, deltaTime: nil, activateDelta: false}, "fjord",
{name: "NotYetDelta", regolithTime: &zeroTime, activateRegolith: true,
deltaTime: &farFutureTime, activateDelta: false},
{name: "DeltaAtGenesis", regolithTime: &zeroTime, activateRegolith: true,
deltaTime: &zeroTime, activateDelta: true},
{name: "DeltaAfterGenesis", regolithTime: &zeroTime, activateRegolith: true,
deltaTime: &futureTime, activateDelta: true},
} }
for _, test := range tests { for i, fork := range forks {
test := test // Use a fixed reference as the tests run in parallel i := i
t.Run(test.name, func(gt *testing.T) { fork := fork
runCrossLayerUserTest(gt, test) t.Run("fork_"+fork, func(t *testing.T) {
t.Run("at_genesis", func(t *testing.T) {
tc := hardforkScheduledTest{}
for _, f := range forks[:i+1] { // activate, all up to and incl this fork, at genesis
tc.SetFork(f, 0)
}
runCrossLayerUserTest(t, tc)
})
t.Run("after_genesis", func(t *testing.T) {
tc := hardforkScheduledTest{}
for _, f := range forks[:i] { // activate, all up to this fork, at genesis
tc.SetFork(f, 0)
}
// activate this fork after genesis
tc.SetFork(fork, futureTime)
tc.runToFork = fork
runCrossLayerUserTest(t, tc)
})
t.Run("not_yet", func(t *testing.T) {
tc := hardforkScheduledTest{}
for _, f := range forks[:i] { // activate, all up to this fork, at genesis
tc.SetFork(f, 0)
}
// activate this fork later
tc.SetFork(fork, farFutureTime)
if i > 0 {
tc.runToFork = forks[i-1]
}
runCrossLayerUserTest(t, tc)
})
}) })
} }
} }
...@@ -57,8 +107,21 @@ func TestCrossLayerUser(t *testing.T) { ...@@ -57,8 +107,21 @@ func TestCrossLayerUser(t *testing.T) {
func runCrossLayerUserTest(gt *testing.T, test hardforkScheduledTest) { func runCrossLayerUserTest(gt *testing.T, test hardforkScheduledTest) {
t := NewDefaultTesting(gt) t := NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, defaultRollupTestParams) dp := e2eutils.MakeDeployParams(t, defaultRollupTestParams)
// This overwrites all deploy-config settings,
// so even when the deploy-config defaults change, we test the right transitions.
dp.DeployConfig.L2GenesisRegolithTimeOffset = test.regolithTime dp.DeployConfig.L2GenesisRegolithTimeOffset = test.regolithTime
dp.DeployConfig.L2GenesisCanyonTimeOffset = test.canyonTime
dp.DeployConfig.L2GenesisDeltaTimeOffset = test.deltaTime dp.DeployConfig.L2GenesisDeltaTimeOffset = test.deltaTime
dp.DeployConfig.L2GenesisEcotoneTimeOffset = test.ecotoneTime
dp.DeployConfig.L2GenesisFjordTimeOffset = test.fjordTime
if test.canyonTime != nil {
require.Zero(t, uint64(*test.canyonTime)%uint64(dp.DeployConfig.L2BlockTime), "canyon fork must be aligned")
}
if test.ecotoneTime != nil {
require.Zero(t, uint64(*test.ecotoneTime)%uint64(dp.DeployConfig.L2BlockTime), "ecotone fork must be aligned")
}
sd := e2eutils.Setup(t, dp, defaultAlloc) sd := e2eutils.Setup(t, dp, defaultAlloc)
log := testlog.Logger(t, log.LvlDebug) log := testlog.Logger(t, log.LvlDebug)
...@@ -107,16 +170,18 @@ func runCrossLayerUserTest(gt *testing.T, test hardforkScheduledTest) { ...@@ -107,16 +170,18 @@ func runCrossLayerUserTest(gt *testing.T, test hardforkScheduledTest) {
seq.ActL2StartBlock(t) seq.ActL2StartBlock(t)
seq.ActL2EndBlock(t) seq.ActL2EndBlock(t)
if test.activateRegolith { if test.runToFork != "" {
// advance L2 enough to activate regolith fork forkTime := test.GetFork(test.runToFork)
seq.ActBuildL2ToRegolith(t) require.NotNil(t, forkTime, "fork we are running up to must be configured")
// advance L2 enough to activate the fork we are running up to
seq.ActBuildL2ToTime(t, *forkTime)
} }
// Check Regolith is active or not by confirming the system info tx is not a system tx // Check Regolith is active or not by confirming the system info tx is not a system tx
infoTx, err := l2Cl.TransactionInBlock(t.Ctx(), seq.L2Unsafe().Hash, 0) infoTx, err := l2Cl.TransactionInBlock(t.Ctx(), seq.L2Unsafe().Hash, 0)
require.NoError(t, err) require.NoError(t, err)
require.True(t, infoTx.IsDepositTx()) require.True(t, infoTx.IsDepositTx())
// Should only be a system tx if regolith is not enabled // Should only be a system tx if regolith is not enabled
require.Equal(t, !test.activateRegolith, infoTx.IsSystemTx()) require.Equal(t, !seq.rollupCfg.IsRegolith(seq.L2Unsafe().Time), infoTx.IsSystemTx())
// regular L2 tx, in new L2 block // regular L2 tx, in new L2 block
alice.L2.ActResetTxOpts(t) alice.L2.ActResetTxOpts(t)
...@@ -218,5 +283,5 @@ func runCrossLayerUserTest(gt *testing.T, test hardforkScheduledTest) { ...@@ -218,5 +283,5 @@ func runCrossLayerUserTest(gt *testing.T, test hardforkScheduledTest) {
require.NoError(t, err) require.NoError(t, err)
require.True(t, infoTx.IsDepositTx()) require.True(t, infoTx.IsDepositTx())
// Should only be a system tx if regolith is not enabled // Should only be a system tx if regolith is not enabled
require.Equal(t, !test.activateRegolith, infoTx.IsSystemTx()) require.Equal(t, !seq.rollupCfg.IsRegolith(seq.L2Unsafe().Time), infoTx.IsSystemTx())
} }
...@@ -57,8 +57,7 @@ func MakeDeployParams(t require.TestingT, tp *TestParams) *DeployParams { ...@@ -57,8 +57,7 @@ func MakeDeployParams(t require.TestingT, tp *TestParams) *DeployParams {
deployConfig.SequencerWindowSize = tp.SequencerWindowSize deployConfig.SequencerWindowSize = tp.SequencerWindowSize
deployConfig.ChannelTimeout = tp.ChannelTimeout deployConfig.ChannelTimeout = tp.ChannelTimeout
deployConfig.L1BlockTime = tp.L1BlockTime deployConfig.L1BlockTime = tp.L1BlockTime
deployConfig.L2GenesisRegolithTimeOffset = nil ApplyDeployConfigForks(deployConfig)
deployConfig.L2GenesisCanyonTimeOffset = CanyonTimeOffset()
require.NoError(t, deployConfig.Check()) require.NoError(t, deployConfig.Check())
require.Equal(t, addresses.Batcher, deployConfig.BatchSenderAddress) require.Equal(t, addresses.Batcher, deployConfig.BatchSenderAddress)
...@@ -188,10 +187,20 @@ func SystemConfigFromDeployConfig(deployConfig *genesis.DeployConfig) eth.System ...@@ -188,10 +187,20 @@ func SystemConfigFromDeployConfig(deployConfig *genesis.DeployConfig) eth.System
} }
} }
func CanyonTimeOffset() *hexutil.Uint64 { func ApplyDeployConfigForks(deployConfig *genesis.DeployConfig) {
if os.Getenv("OP_E2E_USE_CANYON") == "true" { isFjord := os.Getenv("OP_E2E_USE_FJORD") == "true"
offset := hexutil.Uint64(0) isEcotone := isFjord || os.Getenv("OP_E2E_USE_ECOTONE") == "true"
return &offset isDelta := isEcotone || os.Getenv("OP_E2E_USE_DELTA") == "true"
if isDelta {
deployConfig.L2GenesisDeltaTimeOffset = new(hexutil.Uint64)
} }
return nil if isEcotone {
deployConfig.L2GenesisEcotoneTimeOffset = new(hexutil.Uint64)
}
if isFjord {
deployConfig.L2GenesisFjordTimeOffset = new(hexutil.Uint64)
}
// Canyon and lower is activated by default
deployConfig.L2GenesisCanyonTimeOffset = new(hexutil.Uint64)
deployConfig.L2GenesisRegolithTimeOffset = new(hexutil.Uint64)
} }
...@@ -91,7 +91,7 @@ func DefaultSystemConfig(t *testing.T) SystemConfig { ...@@ -91,7 +91,7 @@ func DefaultSystemConfig(t *testing.T) SystemConfig {
require.NoError(t, err) require.NoError(t, err)
deployConfig := config.DeployConfig.Copy() deployConfig := config.DeployConfig.Copy()
deployConfig.L1GenesisBlockTimestamp = hexutil.Uint64(time.Now().Unix()) deployConfig.L1GenesisBlockTimestamp = hexutil.Uint64(time.Now().Unix())
deployConfig.L2GenesisCanyonTimeOffset = e2eutils.CanyonTimeOffset() e2eutils.ApplyDeployConfigForks(deployConfig)
require.NoError(t, deployConfig.Check(), "Deploy config is invalid, do you need to run make devnet-allocs?") require.NoError(t, deployConfig.Check(), "Deploy config is invalid, do you need to run make devnet-allocs?")
l1Deployments := config.L1Deployments.Copy() l1Deployments := config.L1Deployments.Copy()
require.NoError(t, l1Deployments.Check()) require.NoError(t, l1Deployments.Check())
...@@ -512,6 +512,7 @@ func (cfg SystemConfig) Start(t *testing.T, _opts ...SystemConfigOption) (*Syste ...@@ -512,6 +512,7 @@ func (cfg SystemConfig) Start(t *testing.T, _opts ...SystemConfigOption) (*Syste
require.NoError(t, bcn.Start("127.0.0.1:0")) require.NoError(t, bcn.Start("127.0.0.1:0"))
beaconApiAddr := bcn.BeaconAddr() beaconApiAddr := bcn.BeaconAddr()
require.NotEmpty(t, beaconApiAddr, "beacon API listener must be up") require.NotEmpty(t, beaconApiAddr, "beacon API listener must be up")
sys.L1BeaconAPIAddr = beaconApiAddr
// Initialize nodes // Initialize nodes
l1Node, l1Backend, err := geth.InitL1(cfg.DeployConfig.L1ChainID, cfg.DeployConfig.L1BlockTime, l1Genesis, c, l1Node, l1Backend, err := geth.InitL1(cfg.DeployConfig.L1ChainID, cfg.DeployConfig.L1BlockTime, l1Genesis, c,
...@@ -561,9 +562,12 @@ func (cfg SystemConfig) Start(t *testing.T, _opts ...SystemConfigOption) (*Syste ...@@ -561,9 +562,12 @@ func (cfg SystemConfig) Start(t *testing.T, _opts ...SystemConfigOption) (*Syste
// Configure connections to L1 and L2 for rollup nodes. // Configure connections to L1 and L2 for rollup nodes.
// TODO: refactor testing to allow use of in-process rpc connections instead // TODO: refactor testing to allow use of in-process rpc connections instead
// of only websockets (which are required for external eth client tests). // of only websockets (which are required for external eth client tests).
for name, rollupCfg := range cfg.Nodes { for name, nodeCfg := range cfg.Nodes {
configureL1(rollupCfg, sys.EthInstances["l1"]) configureL1(nodeCfg, sys.EthInstances["l1"])
configureL2(rollupCfg, sys.EthInstances[name], cfg.JWTSecret) configureL2(nodeCfg, sys.EthInstances[name], cfg.JWTSecret)
if sys.RollupConfig.EcotoneTime != nil {
nodeCfg.Beacon = &rollupNode.L1BeaconEndpointConfig{BeaconAddr: sys.L1BeaconAPIAddr}
}
} }
// Geth Clients // Geth Clients
......
...@@ -1067,14 +1067,45 @@ func (sga *stateGetterAdapter) GetState(addr common.Address, key common.Hash) co ...@@ -1067,14 +1067,45 @@ func (sga *stateGetterAdapter) GetState(addr common.Address, key common.Hash) co
} }
// TestFees checks that L1/L2 fees are handled. // TestFees checks that L1/L2 fees are handled.
func TestFees(t *testing.T) { func TestL1Fees(t *testing.T) {
InitParallel(t) InitParallel(t)
t.Run("pre-regolith", func(t *testing.T) {
cfg := DefaultSystemConfig(t) cfg := DefaultSystemConfig(t)
// This test only works with these config values modified cfg.DeployConfig.L1GenesisBlockBaseFeePerGas = (*hexutil.Big)(big.NewInt(7))
cfg.DeployConfig.L2GenesisRegolithTimeOffset = nil cfg.DeployConfig.L2GenesisRegolithTimeOffset = nil
cfg.DeployConfig.L2GenesisCanyonTimeOffset = nil
cfg.DeployConfig.L2GenesisDeltaTimeOffset = nil
cfg.DeployConfig.L2GenesisEcotoneTimeOffset = nil
testL1Fees(t, cfg)
})
t.Run("regolith", func(t *testing.T) {
t.Skip("getL1GasUsed in GPO does not support Regolith, it returns the Bedrock L1 cost, incl 68*16 gas overhead")
cfg := DefaultSystemConfig(t)
cfg.DeployConfig.L1GenesisBlockBaseFeePerGas = (*hexutil.Big)(big.NewInt(7))
cfg.DeployConfig.L2GenesisRegolithTimeOffset = new(hexutil.Uint64)
cfg.DeployConfig.L2GenesisCanyonTimeOffset = nil
cfg.DeployConfig.L2GenesisDeltaTimeOffset = nil
cfg.DeployConfig.L2GenesisEcotoneTimeOffset = nil
testL1Fees(t, cfg)
})
t.Run("ecotone", func(t *testing.T) {
t.Skip("when activating Ecotone at Genesis we do not yet call setEcotone() on GPO")
cfg := DefaultSystemConfig(t)
cfg.DeployConfig.L1GenesisBlockBaseFeePerGas = (*hexutil.Big)(big.NewInt(7)) cfg.DeployConfig.L1GenesisBlockBaseFeePerGas = (*hexutil.Big)(big.NewInt(7))
cfg.DeployConfig.L2GenesisRegolithTimeOffset = new(hexutil.Uint64)
cfg.DeployConfig.L2GenesisCanyonTimeOffset = new(hexutil.Uint64)
cfg.DeployConfig.L2GenesisDeltaTimeOffset = new(hexutil.Uint64)
cfg.DeployConfig.L2GenesisEcotoneTimeOffset = new(hexutil.Uint64)
testL1Fees(t, cfg)
})
}
func testL1Fees(t *testing.T, cfg SystemConfig) {
sys, err := cfg.Start(t) sys, err := cfg.Start(t)
require.Nil(t, err, "Error starting up system") require.Nil(t, err, "Error starting up system")
defer sys.Close() defer sys.Close()
...@@ -1083,13 +1114,7 @@ func TestFees(t *testing.T) { ...@@ -1083,13 +1114,7 @@ func TestFees(t *testing.T) {
l2Verif := sys.Clients["verifier"] l2Verif := sys.Clients["verifier"]
l1 := sys.Clients["l1"] l1 := sys.Clients["l1"]
config := &params.ChainConfig{ config := sys.L2Genesis().Config
Optimism: &params.OptimismConfig{
EIP1559Elasticity: cfg.DeployConfig.EIP1559Elasticity,
EIP1559Denominator: cfg.DeployConfig.EIP1559Denominator,
},
BedrockBlock: big.NewInt(0),
}
sga := &stateGetterAdapter{ sga := &stateGetterAdapter{
ctx: context.Background(), ctx: context.Background(),
......
...@@ -182,7 +182,11 @@ func (info *L1BlockInfo) marshalBinaryEcotone() ([]byte, error) { ...@@ -182,7 +182,11 @@ func (info *L1BlockInfo) marshalBinaryEcotone() ([]byte, error) {
if err := solabi.WriteUint256(w, info.BaseFee); err != nil { if err := solabi.WriteUint256(w, info.BaseFee); err != nil {
return nil, err return nil, err
} }
if err := solabi.WriteUint256(w, info.BlobBaseFee); err != nil { blobBasefee := info.BlobBaseFee
if blobBasefee == nil {
blobBasefee = big.NewInt(1) // set to 1, to match the min blob basefee as defined in EIP-4844
}
if err := solabi.WriteUint256(w, blobBasefee); err != nil {
return nil, err return nil, err
} }
if err := solabi.WriteHash(w, info.BlockHash); err != nil { if err := solabi.WriteHash(w, info.BlockHash); err != nil {
......
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