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-deployer: Default gov token to disabled #13378

Merged
merged 1 commit into from
Dec 13, 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
80 changes: 73 additions & 7 deletions op-deployer/pkg/deployer/integration_test/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func TestEndToEndApply(t *testing.T) {
))

validateSuperchainDeployment(t, st, cg)
validateOPChainDeployment(t, cg, st, intent)
validateOPChainDeployment(t, cg, st, intent, false)
})

t.Run("chain with tagged artifacts", func(t *testing.T) {
Expand Down Expand Up @@ -232,6 +232,12 @@ func testApplyExistingOPCM(t *testing.T, l1ChainID uint64, forkRPCUrl string, ve
artifacts.MustNewLocatorFromTag("op-contracts/v1.6.0"),
artifacts.MustNewLocatorFromTag("op-contracts/v1.7.0-beta.1+l2-contracts"),
)
// NOTE: the reference allocs for version 1.6 contain the gov token, so we need to enable it
// via override here.
intent.GlobalDeployOverrides = map[string]any{
"enableGovernance": true,
}

// Define a new create2 salt to avoid contract address collisions
_, err = rand.Read(st.Create2Salt[:])
require.NoError(t, err)
Expand All @@ -248,7 +254,7 @@ func testApplyExistingOPCM(t *testing.T, l1ChainID uint64, forkRPCUrl string, ve
},
))

validateOPChainDeployment(t, ethClientCodeGetter(ctx, l1Client), st, intent)
validateOPChainDeployment(t, ethClientCodeGetter(ctx, l1Client), st, intent, true)

releases := versions.Releases["op-contracts/v1.6.0"]

Expand Down Expand Up @@ -480,7 +486,7 @@ func TestApplyGenesisStrategy(t *testing.T) {

for i := range intent.Chains {
t.Run(fmt.Sprintf("chain-%d", i), func(t *testing.T) {
validateOPChainDeployment(t, cg, st, intent)
validateOPChainDeployment(t, cg, st, intent, false)
})
}
}
Expand Down Expand Up @@ -736,6 +742,60 @@ func TestAdditionalDisputeGames(t *testing.T) {
require.NotEqual(t, st.ImplementationsDeployment.PreimageOracleSingletonAddress, gameInfo.OracleAddress)
}

func TestIntentConfiguration(t *testing.T) {
op_e2e.InitParallel(t)

tests := []struct {
name string
mutator func(*state.Intent)
assertions func(t *testing.T, st *state.State)
}{
{
"governance token disabled by default",
func(intent *state.Intent) {},
func(t *testing.T, st *state.State) {
l2Genesis := st.Chains[0].Allocs.Data
_, ok := l2Genesis.Accounts[predeploys.GovernanceTokenAddr]
require.False(t, ok)
},
},
{
"governance token enabled via override",
func(intent *state.Intent) {
intent.GlobalDeployOverrides = map[string]any{
"enableGovernance": true,
"governanceTokenOwner": common.Address{'O'}.Hex(),
}
},
func(t *testing.T, st *state.State) {
l2Genesis := st.Chains[0].Allocs.Data
_, ok := l2Genesis.Accounts[predeploys.GovernanceTokenAddr]
require.True(t, ok)
checkStorageSlot(
t,
l2Genesis.Accounts,
predeploys.GovernanceTokenAddr,
common.Hash{31: 0x0a},
common.BytesToHash(common.Address{'O'}.Bytes()),
)
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

opts, intent, st := setupGenesisChain(t, defaultL1ChainID)
tt.mutator(intent)
require.NoError(t, deployer.ApplyPipeline(ctx, opts))
tt.assertions(t, st)
})
}
}

func setupGenesisChain(t *testing.T, l1ChainID uint64) (deployer.ApplyPipelineOpts, *state.Intent, *state.State) {
lgr := testlog.Logger(t, slog.LevelDebug)

Expand Down Expand Up @@ -862,7 +922,7 @@ func validateSuperchainDeployment(t *testing.T, st *state.State, cg codeGetter)
}
}

func validateOPChainDeployment(t *testing.T, cg codeGetter, st *state.State, intent *state.Intent) {
func validateOPChainDeployment(t *testing.T, cg codeGetter, st *state.State, intent *state.Intent, govEnabled bool) {
// Validate that the implementation addresses are always set, even in subsequent deployments
// that pull from an existing OPCM deployment.
implAddrs := []struct {
Expand Down Expand Up @@ -929,9 +989,15 @@ func validateOPChainDeployment(t *testing.T, cg codeGetter, st *state.State, int
// slot 0
ownerSlot := common.Hash{}
checkStorageSlot(t, alloc, predeploys.ProxyAdminAddr, ownerSlot, addrAsSlot)
var defaultGovOwner common.Hash
defaultGovOwner.SetBytes(common.HexToAddress("0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAdDEad").Bytes())
checkStorageSlot(t, alloc, predeploys.GovernanceTokenAddr, common.Hash{31: 0x0a}, defaultGovOwner)

if govEnabled {
var defaultGovOwner common.Hash
defaultGovOwner.SetBytes(common.HexToAddress("0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAdDEad").Bytes())
checkStorageSlot(t, alloc, predeploys.GovernanceTokenAddr, common.Hash{31: 0x0a}, defaultGovOwner)
} else {
_, ok := alloc[predeploys.GovernanceTokenAddr]
require.False(t, ok, "governance token should not be deployed by default")
}

require.Equal(t, int(chainIntent.Eip1559Denominator), 50, "EIP1559Denominator should be set")
require.Equal(t, int(chainIntent.Eip1559Elasticity), 6, "EIP1559Elasticity should be set")
Expand Down
2 changes: 1 addition & 1 deletion op-deployer/pkg/deployer/state/deploy_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func CombineDeployConfig(intent *Intent, chainIntent *ChainIntent, state *State,
SequencerFeeVaultRecipient: chainIntent.SequencerFeeVaultRecipient,
},
GovernanceDeployConfig: genesis.GovernanceDeployConfig{
EnableGovernance: true,
EnableGovernance: false,
GovernanceTokenSymbol: "OP",
GovernanceTokenName: "Optimism",
GovernanceTokenOwner: common.HexToAddress("0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAdDEad"),
Expand Down