Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

op-e2e: Nuke allocs #13364

Merged
merged 10 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
mslipper marked this conversation as resolved.
Show resolved Hide resolved
}

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 @@ -400,7 +396,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 @@ -414,11 +409,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 @@ -493,9 +494,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 @@ -523,17 +524,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 @@ -702,7 +703,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 @@ -720,6 +723,7 @@ func TestAdditionalDisputeGames(t *testing.T) {
UseCustomOracle: true,
OracleMinProposalSize: 10000,
OracleChallengePeriodSeconds: 120,
MakeRespected: true,
VMType: state.VMTypeAlphabet,
},
}
Expand Down Expand Up @@ -788,7 +792,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