Skip to content

Commit

Permalink
op-e2e: Nuke allocs (#13364)
Browse files Browse the repository at this point in the history
* op-e2e: Nuke allocs

This PR integrates op-deployer with op-e2e for the purposes of generating L1/L2 allocs on-the-fly. As a result, there is no longer any need to run `make devnet-allocs` or otherwise continue maintaining the legacy Python devnet. The generated allocs are at parity with those generated by the Python devnet - i.e., they contain the Alphabet VM, the fast fault game, and the deploy config customizations in `devnetL1.json`.

One notable change here is that the ability to generate new allocs files for L2OO chains will no longer be possible post-Holocene. To continue supporting the L2OO tests for the time being, the L2OO allocs files have been archived at the Holocene fork.

Cleaning up the old devnet will be handled separately.

* fix broken tests

* bring back l2oo test

* swap more keys

* more keys

* swap prestates

* remove dead code

* fix prestate proof

* Code review updates

* toml fields
  • Loading branch information
mslipper authored Dec 14, 2024
1 parent a602c5c commit 6823d67
Show file tree
Hide file tree
Showing 40 changed files with 763 additions and 166 deletions.
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ require (
github.com/libp2p/go-libp2p-mplex v0.9.0
github.com/libp2p/go-libp2p-pubsub v0.12.0
github.com/libp2p/go-libp2p-testing v0.12.0
github.com/lmittmann/w3 v0.17.1
github.com/mattn/go-isatty v0.0.20
github.com/minio/minio-go/v7 v7.0.81
github.com/multiformats/go-base32 v0.1.0
Expand Down Expand Up @@ -157,7 +158,7 @@ require (
github.com/libp2p/go-yamux/v4 v4.0.1 // indirect
github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mholt/archiver v3.1.1+incompatible // indirect
github.com/miekg/dns v1.1.62 // indirect
github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b // indirect
Expand Down Expand Up @@ -208,7 +209,7 @@ require (
github.com/quic-go/quic-go v0.46.0 // indirect
github.com/quic-go/webtransport-go v0.8.0 // indirect
github.com/raulk/go-watchdog v1.3.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rs/cors v1.11.0 // indirect
github.com/rs/xid v1.6.0 // indirect
Expand Down
10 changes: 6 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,8 @@ github.com/libp2p/go-reuseport v0.4.0 h1:nR5KU7hD0WxXCJbmw7r2rhRYruNRl2koHw8fQsc
github.com/libp2p/go-reuseport v0.4.0/go.mod h1:ZtI03j/wO5hZVDFo2jKywN6bYKWLOy8Se6DrI2E1cLU=
github.com/libp2p/go-yamux/v4 v4.0.1 h1:FfDR4S1wj6Bw2Pqbc8Uz7pCxeRBPbwsBbEdfwiCypkQ=
github.com/libp2p/go-yamux/v4 v4.0.1/go.mod h1:NWjl8ZTLOGlozrXSOZ/HlfG++39iKNnM5wwmtQP1YB4=
github.com/lmittmann/w3 v0.17.1 h1:zdXIimmNmYfqOFur+Jqc9Yqwtq6jwnsQufbTOnSAtW4=
github.com/lmittmann/w3 v0.17.1/go.mod h1:WVUGMbL83WYBu4Sge3SVlW3qIG4VaHe+S8+UUnwz9Eg=
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
Expand All @@ -509,8 +511,8 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mholt/archiver v3.1.1+incompatible h1:1dCVxuqs0dJseYEhi5pl7MYPH9zDa1wBi7mF09cbNkU=
github.com/mholt/archiver v3.1.1+incompatible/go.mod h1:Dh2dOXnSdiLxRiPoVfIr/fI1TwETms9B8CTWfeh7ROU=
Expand Down Expand Up @@ -711,8 +713,8 @@ github.com/quic-go/webtransport-go v0.8.0/go.mod h1:N99tjprW432Ut5ONql/aUhSLT0YV
github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk=
github.com/raulk/go-watchdog v1.3.0/go.mod h1:fIvOnLbF0b0ZwkB9YU4mOW9Did//4vPZtDqv66NfsMU=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
Expand Down
13 changes: 12 additions & 1 deletion op-chain-ops/foundry/allocs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package foundry

import (
"bytes"
"encoding/json"
"fmt"
"maps"
Expand Down Expand Up @@ -76,9 +77,19 @@ func (d *forgeAllocsDump) OnAccount(address *common.Address, account state.DumpA
}
}

// Copy returns a deep copy of the ForgeAllocs. We can't
// perform a shallow copy here because some tests modify
// the accounts individually.
func (d *ForgeAllocs) Copy() *ForgeAllocs {
out := make(types.GenesisAlloc, len(d.Accounts))
maps.Copy(out, d.Accounts)
for k, v := range d.Accounts {
out[k] = types.Account{
Code: bytes.Clone(v.Code),
Storage: maps.Clone(v.Storage),
Balance: new(big.Int).Set(v.Balance),
Nonce: v.Nonce,
}
}
return &ForgeAllocs{Accounts: out}
}

Expand Down
1 change: 1 addition & 0 deletions op-chain-ops/interopgen/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func DeployL2ToL1(l1Host *script.Host, superCfg *SuperchainConfig, superDeployme
DisputeSplitDepth: cfg.DisputeSplitDepth,
DisputeClockExtension: cfg.DisputeClockExtension,
DisputeMaxClockDuration: cfg.DisputeMaxClockDuration,
StartingAnchorRoots: opcm.PermissionedGameStartingAnchorRoots,
})
if err != nil {
return nil, fmt.Errorf("failed to deploy L2 OP chain: %w", err)
Expand Down
9 changes: 9 additions & 0 deletions op-deployer/pkg/deployer/artifacts/locator.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ type Locator struct {
Tag string
}

func NewFileLocator(path string) (*Locator, error) {
u, err := url.Parse("file://" + path)
if err != nil {
return nil, fmt.Errorf("failed to parse URL: %w", err)
}

return &Locator{URL: u}, nil
}

func (a *Locator) UnmarshalText(text []byte) error {
str := string(text)

Expand Down
33 changes: 33 additions & 0 deletions op-deployer/pkg/deployer/inspect/l1.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package inspect
import (
"fmt"

"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"

"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/pipeline"
"github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/state"

Expand All @@ -18,6 +20,33 @@ type L1Contracts struct {
ImplementationsDeployment ImplementationsDeployment `json:"implementationsDeployment"`
}

func (l L1Contracts) AsL1Deployments() *genesis.L1Deployments {
return &genesis.L1Deployments{
AddressManager: l.OpChainDeployment.AddressManagerAddress,
DisputeGameFactory: l.ImplementationsDeployment.DisputeGameFactoryImplAddress,
DisputeGameFactoryProxy: l.OpChainDeployment.DisputeGameFactoryProxyAddress,
L1CrossDomainMessenger: l.ImplementationsDeployment.L1CrossDomainMessengerImplAddress,
L1CrossDomainMessengerProxy: l.OpChainDeployment.L1CrossDomainMessengerProxyAddress,
L1ERC721Bridge: l.ImplementationsDeployment.L1ERC721BridgeImplAddress,
L1ERC721BridgeProxy: l.OpChainDeployment.L1ERC721BridgeProxyAddress,
L1StandardBridge: l.ImplementationsDeployment.L1StandardBridgeImplAddress,
L1StandardBridgeProxy: l.OpChainDeployment.L1StandardBridgeProxyAddress,
L2OutputOracle: common.Address{},
L2OutputOracleProxy: common.Address{},
OptimismMintableERC20Factory: l.ImplementationsDeployment.OptimismMintableERC20FactoryImplAddress,
OptimismMintableERC20FactoryProxy: l.OpChainDeployment.OptimismMintableERC20FactoryProxyAddress,
OptimismPortal: l.ImplementationsDeployment.OptimismPortalImplAddress,
OptimismPortalProxy: l.OpChainDeployment.OptimismPortalProxyAddress,
ProxyAdmin: l.OpChainDeployment.ProxyAdminAddress,
SystemConfig: l.ImplementationsDeployment.SystemConfigImplAddress,
SystemConfigProxy: l.OpChainDeployment.SystemConfigProxyAddress,
ProtocolVersions: l.SuperchainDeployment.ProtocolVersionsImplAddress,
ProtocolVersionsProxy: l.SuperchainDeployment.ProtocolVersionsProxyAddress,
DataAvailabilityChallenge: l.OpChainDeployment.DataAvailabilityChallengeImplAddress,
DataAvailabilityChallengeProxy: l.OpChainDeployment.DataAvailabilityChallengeProxyAddress,
}
}

type SuperchainDeployment struct {
ProxyAdminAddress common.Address `json:"proxyAdminAddress"`
SuperchainConfigProxyAddress common.Address `json:"superchainConfigProxyAddress"`
Expand All @@ -42,6 +71,8 @@ type OpChainDeployment struct {
PermissionedDisputeGameAddress common.Address `json:"permissionedDisputeGameAddress"`
DelayedWETHPermissionedGameProxyAddress common.Address `json:"delayedWETHPermissionedGameProxyAddress"`
// DelayedWETHPermissionlessGameProxyAddress common.Address `json:"delayedWETHPermissionlessGameProxyAddress"`
DataAvailabilityChallengeProxyAddress common.Address `json:"dataAvailabilityChallengeProxyAddress"`
DataAvailabilityChallengeImplAddress common.Address `json:"dataAvailabilityChallengeImplAddress"`
}

type ImplementationsDeployment struct {
Expand Down Expand Up @@ -110,6 +141,8 @@ func L1(globalState *state.State, chainID common.Hash) (*L1Contracts, error) {
FaultDisputeGameAddress: chainState.FaultDisputeGameAddress,
PermissionedDisputeGameAddress: chainState.PermissionedDisputeGameAddress,
DelayedWETHPermissionedGameProxyAddress: chainState.DelayedWETHPermissionedGameProxyAddress,
DataAvailabilityChallengeProxyAddress: chainState.DataAvailabilityChallengeProxyAddress,
DataAvailabilityChallengeImplAddress: chainState.DataAvailabilityChallengeImplAddress,
// DelayedWETHPermissionlessGameProxyAddress: chainState.DelayedWETHPermissionlessGameProxyAddress,
},
ImplementationsDeployment: ImplementationsDeployment{
Expand Down
34 changes: 19 additions & 15 deletions op-deployer/pkg/deployer/integration_test/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,7 @@ func TestApplyExistingOPCM(t *testing.T) {
func testApplyExistingOPCM(t *testing.T, l1ChainID uint64, forkRPCUrl string, versions standard.L1Versions) {
op_e2e.InitParallel(t)

anvil.Test(t)

if forkRPCUrl == "" {
t.Skip("no fork RPC URL provided")
}
require.NotEmpty(t, forkRPCUrl, "no fork RPC URL provided")

lgr := testlog.Logger(t, slog.LevelDebug)

Expand Down Expand Up @@ -406,7 +402,6 @@ func testApplyExistingOPCM(t *testing.T, l1ChainID uint64, forkRPCUrl string, ve
//Use a custom equality function to compare the genesis allocs
//because the reflect-based one is really slow
actAllocs := st.Chains[0].Allocs.Data.Accounts
require.Equal(t, len(expAllocs), len(actAllocs))
for addr, expAcc := range expAllocs {
actAcc, ok := actAllocs[addr]
require.True(t, ok)
Expand All @@ -420,11 +415,17 @@ func testApplyExistingOPCM(t *testing.T, l1ChainID uint64, forkRPCUrl string, ve
}
storageChecker(addr, actAcc.Storage)
}
for addr := range actAllocs {
if _, ok := expAllocs[addr]; ok {
continue
}

t.Logf("unexpected account: %s", addr.Hex())
}
}

func TestGlobalOverrides(t *testing.T) {
op_e2e.InitParallel(t)
kurtosisutil.Test(t)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -499,9 +500,9 @@ func TestProofParamOverrides(t *testing.T) {

opts, intent, st := setupGenesisChain(t, defaultL1ChainID)
intent.GlobalDeployOverrides = map[string]any{
"withdrawalDelaySeconds": standard.WithdrawalDelaySeconds + 1,
"minProposalSizeBytes": standard.MinProposalSizeBytes + 1,
"challengePeriodSeconds": standard.ChallengePeriodSeconds + 1,
"faultGameWithdrawalDelay": standard.WithdrawalDelaySeconds + 1,
"preimageOracleMinProposalSize": standard.MinProposalSizeBytes + 1,
"preimageOracleChallengePeriod": standard.ChallengePeriodSeconds + 1,
"proofMaturityDelaySeconds": standard.ProofMaturityDelaySeconds + 1,
"disputeGameFinalityDelaySeconds": standard.DisputeGameFinalityDelaySeconds + 1,
"mipsVersion": standard.MIPSVersion + 1,
Expand Down Expand Up @@ -529,17 +530,17 @@ func TestProofParamOverrides(t *testing.T) {
address common.Address
}{
{
"withdrawalDelaySeconds",
"faultGameWithdrawalDelay",
uint64Caster,
st.ImplementationsDeployment.DelayedWETHImplAddress,
},
{
"minProposalSizeBytes",
"preimageOracleMinProposalSize",
uint64Caster,
st.ImplementationsDeployment.PreimageOracleSingletonAddress,
},
{
"challengePeriodSeconds",
"preimageOracleChallengePeriod",
uint64Caster,
st.ImplementationsDeployment.PreimageOracleSingletonAddress,
},
Expand Down Expand Up @@ -708,7 +709,9 @@ func TestAdditionalDisputeGames(t *testing.T) {
defer cancel()

opts, intent, st := setupGenesisChain(t, defaultL1ChainID)
(&intent.Chains[0].Roles).L1ProxyAdminOwner = crypto.PubkeyToAddress(opts.DeployerPrivateKey.PublicKey)
deployerAddr := crypto.PubkeyToAddress(opts.DeployerPrivateKey.PublicKey)
(&intent.Chains[0].Roles).L1ProxyAdminOwner = deployerAddr
intent.SuperchainRoles.Guardian = deployerAddr
intent.GlobalDeployOverrides = map[string]any{
"challengePeriodSeconds": 1,
}
Expand All @@ -726,6 +729,7 @@ func TestAdditionalDisputeGames(t *testing.T) {
UseCustomOracle: true,
OracleMinProposalSize: 10000,
OracleChallengePeriodSeconds: 120,
MakeRespected: true,
VMType: state.VMTypeAlphabet,
},
}
Expand Down Expand Up @@ -848,7 +852,7 @@ func newIntent(
ProtocolVersionsOwner: addrFor(t, dk, devkeys.SuperchainDeployerKey.Key(l1ChainID)),
Guardian: addrFor(t, dk, devkeys.SuperchainConfigGuardianKey.Key(l1ChainID)),
},
FundDevAccounts: true,
FundDevAccounts: false,
L1ContractsLocator: l1Loc,
L2ContractsLocator: l2Loc,
Chains: []*state.ChainIntent{
Expand Down
55 changes: 55 additions & 0 deletions op-deployer/pkg/deployer/opcm/anchor_roots.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package opcm

import (
"fmt"
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/lmittmann/w3"
)

var anchorRootFunc = w3.MustNewFunc(`
dummy((uint32 gameType, (bytes32 root, uint256 l2BlockNumber) outputRoot)[] roots)
`, "")

type StartingAnchorRoot struct {
GameType uint32
Root common.Hash
L2BlockNumber *big.Int
}

var DefaultStartingAnchorRoot = StartingAnchorRoot{
GameType: 1,
Root: common.Hash{0xde, 0xad},
L2BlockNumber: common.Big0,
}

type encodingStartingAnchorRoot struct {
GameType uint32
OutputRoot struct {
Root common.Hash
L2BlockNumber *big.Int
}
}

func EncodeStartingAnchorRoots(roots []StartingAnchorRoot) ([]byte, error) {
args := make([]encodingStartingAnchorRoot, len(roots))
for i, root := range roots {
args[i] = encodingStartingAnchorRoot{
GameType: root.GameType,
OutputRoot: struct {
Root common.Hash
L2BlockNumber *big.Int
}{
Root: root.Root,
L2BlockNumber: root.L2BlockNumber,
},
}
}
encoded, err := anchorRootFunc.EncodeArgs(args)
if err != nil {
return nil, fmt.Errorf("error encoding anchor roots: %w", err)
}
// Chop off the function selector since w3 can't serialize structs directly
return encoded[4:], nil
}
42 changes: 42 additions & 0 deletions op-deployer/pkg/deployer/opcm/anchor_roots_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package opcm

import (
"math/big"
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
)

func TestEncodeStartingAnchorRoots(t *testing.T) {
encoded, err := EncodeStartingAnchorRoots([]StartingAnchorRoot{
DefaultStartingAnchorRoot,
})
require.NoError(t, err)
require.EqualValues(t, PermissionedGameStartingAnchorRoots, encoded)

encoded, err = EncodeStartingAnchorRoots([]StartingAnchorRoot{
{
GameType: 0,
L2BlockNumber: common.Big0,
},
{
GameType: 1,
Root: common.Hash{0xde, 0xad},
L2BlockNumber: big.NewInt(0),
},
})
require.NoError(t, err)
require.EqualValues(t,
common.Hex2Bytes(
"0000000000000000000000000000000000000000000000000000000000000020"+
"0000000000000000000000000000000000000000000000000000000000000002"+
"0000000000000000000000000000000000000000000000000000000000000000"+
"0000000000000000000000000000000000000000000000000000000000000000"+
"0000000000000000000000000000000000000000000000000000000000000000"+
"0000000000000000000000000000000000000000000000000000000000000001"+
"dead000000000000000000000000000000000000000000000000000000000000"+
"0000000000000000000000000000000000000000000000000000000000000000"),
encoded,
)
}
8 changes: 5 additions & 3 deletions op-deployer/pkg/deployer/opcm/dispute_game_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import (
)

type SetDisputeGameImplInput struct {
Factory common.Address
Impl common.Address
GameType uint32
Factory common.Address
Impl common.Address
Portal common.Address
AnchorStateRegistry common.Address
GameType uint32
}

func SetDisputeGameImpl(
Expand Down
Loading

0 comments on commit 6823d67

Please sign in to comment.