Commit 6cb984ed authored by Mark Tyneway's avatar Mark Tyneway

op-e2e: enable shanghai on L1

Changes the genesis generation in `op-chain-ops` so that the L1 genesis
includes shanghai. This impacts `op-e2e` that uses the libraries in
`op-chain-ops` such that now `op-e2e` will run with shanghai enabled
for L1. Note that shanghai is not yet enabled on L2. This commit
updates the `fakepos` utility to use the post shanghai execution api.

This commit also deletes the `fork_test` in which a test existed for
the upgrade to shapella but has already happened. Keeping that test
around adds extra burden to the maintainers and isn't particularly
necessary to keep around anymore now that the network has upgraded
successfully.
Co-authored-by: default avatarprotolambda <proto@protolambda.com>
parent a19535eb
......@@ -40,11 +40,19 @@ type Deployment struct {
type Deployer func(*backends.SimulatedBackend, *bind.TransactOpts, Constructor) (*types.Transaction, error)
// NewBackend returns a SimulatedBackend suitable for L1. It has
// the latest L1 hardforks enabled.
func NewBackend() *backends.SimulatedBackend {
return NewBackendWithGenesisTimestamp(0)
return NewBackendWithGenesisTimestamp(0, true)
}
func NewBackendWithGenesisTimestamp(ts uint64) *backends.SimulatedBackend {
// NewL2Backend returns a SimulatedBackend suitable for L2.
// It has the latest L2 hardforks enabled.
func NewL2Backend() *backends.SimulatedBackend {
return NewBackendWithGenesisTimestamp(0, false)
}
func NewBackendWithGenesisTimestamp(ts uint64, shanghai bool) *backends.SimulatedBackend {
chainConfig := params.ChainConfig{
ChainID: ChainID,
HomesteadBlock: big.NewInt(0),
......@@ -70,6 +78,10 @@ func NewBackendWithGenesisTimestamp(ts uint64) *backends.SimulatedBackend {
TerminalTotalDifficultyPassed: true,
}
if shanghai {
chainConfig.ShanghaiTime = u64ptr(0)
}
return backends.NewSimulatedBackendWithOpts(
backends.WithCacheConfig(&core.CacheConfig{
Preimages: true,
......@@ -132,3 +144,7 @@ func Deploy(backend *backends.SimulatedBackend, constructors []Constructor, cb D
return results, nil
}
func u64ptr(n uint64) *uint64 {
return &n
}
......@@ -127,6 +127,7 @@ func NewL1Genesis(config *DeployConfig) (*core.Genesis, error) {
LondonBlock: big.NewInt(0),
ArrowGlacierBlock: big.NewInt(0),
GrayGlacierBlock: big.NewInt(0),
ShanghaiTime: u64ptr(0),
}
if config.CliqueSignerAddress != (common.Address{}) {
......@@ -180,3 +181,7 @@ func NewL1Genesis(config *DeployConfig) (*core.Genesis, error) {
Alloc: map[common.Address]core.GenesisAccount{},
}, nil
}
func u64ptr(n uint64) *uint64 {
return &n
}
......@@ -76,7 +76,8 @@ func BuildL1DeveloperGenesis(config *DeployConfig) (*core.Genesis, error) {
return nil, err
}
backend := deployer.NewBackendWithGenesisTimestamp(uint64(config.L1GenesisBlockTimestamp))
// Enable shanghai
backend := deployer.NewBackendWithGenesisTimestamp(uint64(config.L1GenesisBlockTimestamp), true)
deployments, err := deployL1Contracts(config, backend)
if err != nil {
......
......@@ -158,7 +158,7 @@ func BuildOptimism(immutable ImmutableConfig) (DeploymentResults, error) {
// can be properly set. The bytecode returned in the results is suitable to be
// inserted into the state via state surgery.
func BuildL2(constructors []deployer.Constructor) (DeploymentResults, error) {
deployments, err := deployer.Deploy(deployer.NewBackend(), constructors, l2Deployer)
deployments, err := deployer.Deploy(deployer.NewL2Backend(), constructors, l2Deployer)
if err != nil {
return nil, err
}
......
package actions
import (
"testing"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils"
"github.com/ethereum-optimism/optimism/op-node/testlog"
)
func TestShapellaL1Fork(gt *testing.T) {
t := NewDefaultTesting(gt)
dp := e2eutils.MakeDeployParams(t, defaultRollupTestParams)
sd := e2eutils.Setup(t, dp, defaultAlloc)
activation := sd.L1Cfg.Timestamp + 24
sd.L1Cfg.Config.ShanghaiTime = &activation
log := testlog.Logger(t, log.LvlDebug)
_, _, miner, sequencer, _, verifier, _, batcher := setupReorgTestActors(t, dp, sd, log)
require.False(t, sd.L1Cfg.Config.IsShanghai(miner.l1Chain.CurrentBlock().Time), "not active yet")
// start op-nodes
sequencer.ActL2PipelineFull(t)
verifier.ActL2PipelineFull(t)
// build empty L1 blocks, crossing the fork boundary
miner.ActEmptyBlock(t)
miner.ActEmptyBlock(t)
miner.ActEmptyBlock(t)
// verify Shanghai is active
l1Head := miner.l1Chain.CurrentBlock()
require.True(t, sd.L1Cfg.Config.IsShanghai(l1Head.Time))
// build L2 chain up to and including L2 blocks referencing shanghai L1 blocks
sequencer.ActL1HeadSignal(t)
sequencer.ActBuildToL1Head(t)
miner.ActL1StartBlock(12)(t)
batcher.ActSubmitAll(t)
miner.ActL1IncludeTx(batcher.batcherAddr)(t)
miner.ActL1EndBlock(t)
// sync verifier
verifier.ActL1HeadSignal(t)
verifier.ActL2PipelineFull(t)
// verify verifier accepted shanghai L1 inputs
require.Equal(t, l1Head.Hash(), verifier.SyncStatus().SafeL2.L1Origin.Hash, "verifier synced L1 chain that includes shanghai headers")
require.Equal(t, sequencer.SyncStatus().UnsafeL2, verifier.SyncStatus().UnsafeL2, "verifier and sequencer agree")
}
......@@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/beacon/engine"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth/catalyst"
"github.com/ethereum/go-ethereum/event"
......@@ -63,7 +64,7 @@ func (f *fakePoS) Start() error {
// We're a long way behind, let's skip some blocks...
newBlockTime = uint64(f.clock.Now().Unix())
}
res, err := f.engineAPI.ForkchoiceUpdatedV1(engine.ForkchoiceStateV1{
res, err := f.engineAPI.ForkchoiceUpdatedV2(engine.ForkchoiceStateV1{
HeadBlockHash: head.Hash(),
SafeBlockHash: safe.Hash(),
FinalizedBlockHash: finalized.Hash(),
......@@ -71,6 +72,7 @@ func (f *fakePoS) Start() error {
Timestamp: newBlockTime,
Random: common.Hash{},
SuggestedFeeRecipient: head.Coinbase,
Withdrawals: make([]*types.Withdrawal, 0),
})
if err != nil {
f.log.Error("failed to start building L1 block", "err", err)
......@@ -90,17 +92,17 @@ func (f *fakePoS) Start() error {
tim.Stop()
return nil
}
payload, err := f.engineAPI.GetPayloadV1(*res.PayloadID)
envelope, err := f.engineAPI.GetPayloadV2(*res.PayloadID)
if err != nil {
f.log.Error("failed to finish building L1 block", "err", err)
continue
}
if _, err := f.engineAPI.NewPayloadV1(*payload); err != nil {
if _, err := f.engineAPI.NewPayloadV2(*envelope.ExecutionPayload); err != nil {
f.log.Error("failed to insert built L1 block", "err", err)
continue
}
if _, err := f.engineAPI.ForkchoiceUpdatedV1(engine.ForkchoiceStateV1{
HeadBlockHash: payload.BlockHash,
if _, err := f.engineAPI.ForkchoiceUpdatedV2(engine.ForkchoiceStateV1{
HeadBlockHash: envelope.ExecutionPayload.BlockHash,
SafeBlockHash: safe.Hash(),
FinalizedBlockHash: finalized.Hash(),
}, nil); 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