Commit 86c37b94 authored by Blaine Malone's avatar Blaine Malone Committed by GitHub

op-deployer: Fee Recipients and Gas Params added to intent (#12404)

* op-deployer: Fee Recipients and Gas Params added to intent

* fix: retrieved fee recipients from docs.

* fix: added a loose test for checking fee vault recipients and gas params.

* fix: programmatically retrieving the proxy impl address to check the immutable.

* fix: fee recipient per chain
parent f259ee0d
...@@ -106,6 +106,11 @@ func Init(cfg InitConfig) error { ...@@ -106,6 +106,11 @@ func Init(cfg InitConfig) error {
l2ChainIDBig := l2ChainID.Big() l2ChainIDBig := l2ChainID.Big()
intent.Chains = append(intent.Chains, &state.ChainIntent{ intent.Chains = append(intent.Chains, &state.ChainIntent{
ID: l2ChainID, ID: l2ChainID,
BaseFeeVaultRecipient: common.Address{},
L1FeeVaultRecipient: common.Address{},
SequencerFeeVaultRecipient: common.Address{},
Eip1559Denominator: 50,
Eip1559Elasticity: 6,
Roles: state.ChainRoles{ Roles: state.ChainRoles{
ProxyAdminOwner: addrFor(devkeys.L2ProxyAdminOwnerRole.Key(l2ChainIDBig)), ProxyAdminOwner: addrFor(devkeys.L2ProxyAdminOwnerRole.Key(l2ChainIDBig)),
SystemConfigOwner: addrFor(devkeys.SystemConfigOwner.Key(l2ChainIDBig)), SystemConfigOwner: addrFor(devkeys.SystemConfigOwner.Key(l2ChainIDBig)),
......
...@@ -9,22 +9,25 @@ import ( ...@@ -9,22 +9,25 @@ import (
"os" "os"
"path" "path"
"runtime" "runtime"
"strings"
"testing" "testing"
"time" "time"
"github.com/ethereum-optimism/optimism/op-service/testutils/anvil"
crypto "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer" "github.com/ethereum-optimism/optimism/op-chain-ops/deployer"
"github.com/holiman/uint256" "github.com/holiman/uint256"
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/pipeline" "github.com/ethereum-optimism/optimism/op-chain-ops/deployer/pipeline"
"github.com/ethereum-optimism/optimism/op-chain-ops/deployer/state" "github.com/ethereum-optimism/optimism/op-chain-ops/deployer/state"
"github.com/ethereum-optimism/optimism/op-chain-ops/devkeys" "github.com/ethereum-optimism/optimism/op-chain-ops/devkeys"
"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto" opcrypto "github.com/ethereum-optimism/optimism/op-service/crypto"
"github.com/ethereum-optimism/optimism/op-service/predeploys"
"github.com/ethereum-optimism/optimism/op-service/testlog" "github.com/ethereum-optimism/optimism/op-service/testlog"
"github.com/ethereum-optimism/optimism/op-service/testutils/anvil"
"github.com/ethereum-optimism/optimism/op-service/testutils/kurtosisutil" "github.com/ethereum-optimism/optimism/op-service/testutils/kurtosisutil"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethclient"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
...@@ -141,7 +144,7 @@ func TestEndToEndApply(t *testing.T) { ...@@ -141,7 +144,7 @@ func TestEndToEndApply(t *testing.T) {
}) })
} }
validateOPChainDeployment(t, ctx, l1Client, st) validateOPChainDeployment(t, ctx, l1Client, st, intent)
}) })
t.Run("subsequent chain", func(t *testing.T) { t.Run("subsequent chain", func(t *testing.T) {
...@@ -172,7 +175,7 @@ func TestEndToEndApply(t *testing.T) { ...@@ -172,7 +175,7 @@ func TestEndToEndApply(t *testing.T) {
}) })
} }
validateOPChainDeployment(t, ctx, l1Client, st) validateOPChainDeployment(t, ctx, l1Client, st, intent)
}) })
} }
...@@ -208,6 +211,11 @@ func makeIntent( ...@@ -208,6 +211,11 @@ func makeIntent(
Chains: []*state.ChainIntent{ Chains: []*state.ChainIntent{
{ {
ID: l2ChainID.Bytes32(), ID: l2ChainID.Bytes32(),
BaseFeeVaultRecipient: addrFor(devkeys.BaseFeeVaultRecipientRole.Key(l1ChainID)),
L1FeeVaultRecipient: addrFor(devkeys.L1FeeVaultRecipientRole.Key(l1ChainID)),
SequencerFeeVaultRecipient: addrFor(devkeys.SequencerFeeVaultRecipientRole.Key(l1ChainID)),
Eip1559Denominator: 50,
Eip1559Elasticity: 6,
Roles: state.ChainRoles{ Roles: state.ChainRoles{
ProxyAdminOwner: addrFor(devkeys.L2ProxyAdminOwnerRole.Key(l1ChainID)), ProxyAdminOwner: addrFor(devkeys.L2ProxyAdminOwnerRole.Key(l1ChainID)),
SystemConfigOwner: addrFor(devkeys.SystemConfigOwner.Key(l1ChainID)), SystemConfigOwner: addrFor(devkeys.SystemConfigOwner.Key(l1ChainID)),
...@@ -226,7 +234,7 @@ func makeIntent( ...@@ -226,7 +234,7 @@ func makeIntent(
return intent, st return intent, st
} }
func validateOPChainDeployment(t *testing.T, ctx context.Context, l1Client *ethclient.Client, st *state.State) { func validateOPChainDeployment(t *testing.T, ctx context.Context, l1Client *ethclient.Client, st *state.State, intent *state.Intent) {
for _, chainState := range st.Chains { for _, chainState := range st.Chains {
chainAddrs := []struct { chainAddrs := []struct {
name string name string
...@@ -261,10 +269,40 @@ func validateOPChainDeployment(t *testing.T, ctx context.Context, l1Client *ethc ...@@ -261,10 +269,40 @@ func validateOPChainDeployment(t *testing.T, ctx context.Context, l1Client *ethc
t.Run("l2 genesis", func(t *testing.T) { t.Run("l2 genesis", func(t *testing.T) {
require.Greater(t, len(chainState.Allocs), 0) require.Greater(t, len(chainState.Allocs), 0)
l2Allocs, _ := chainState.UnmarshalAllocs()
alloc := l2Allocs.Copy().Accounts
firstChainIntent := intent.Chains[0]
checkImmutable(t, alloc, predeploys.BaseFeeVaultAddr, firstChainIntent.BaseFeeVaultRecipient)
checkImmutable(t, alloc, predeploys.L1FeeVaultAddr, firstChainIntent.L1FeeVaultRecipient)
checkImmutable(t, alloc, predeploys.SequencerFeeVaultAddr, firstChainIntent.SequencerFeeVaultRecipient)
require.Equal(t, int(firstChainIntent.Eip1559Denominator), 50, "EIP1559Denominator should be set")
require.Equal(t, int(firstChainIntent.Eip1559Elasticity), 6, "EIP1559Elasticity should be set")
}) })
} }
} }
func getEIP1967ImplementationAddress(t *testing.T, allocations types.GenesisAlloc, proxyAddress common.Address) common.Address {
storage := allocations[proxyAddress].Storage
storageValue := storage[genesis.ImplementationSlot]
require.NotEmpty(t, storageValue, "Implementation address for %s should be set", proxyAddress)
return common.HexToAddress(storageValue.Hex())
}
func checkImmutable(t *testing.T, allocations types.GenesisAlloc, proxyContract common.Address, feeRecipient common.Address) {
implementationAddress := getEIP1967ImplementationAddress(t, allocations, proxyContract)
account, ok := allocations[implementationAddress]
require.True(t, ok, "%s not found in allocations", implementationAddress.Hex())
require.NotEmpty(t, account.Code, "%s should have code", implementationAddress.Hex())
require.Contains(
t,
strings.ToLower(common.Bytes2Hex(account.Code)),
strings.ToLower(strings.TrimPrefix(feeRecipient.Hex(), "0x")),
"%s code should contain %s immutable", implementationAddress.Hex(), feeRecipient.Hex(),
)
}
func TestApplyExistingOPCM(t *testing.T) { func TestApplyExistingOPCM(t *testing.T) {
anvil.Test(t) anvil.Test(t)
...@@ -321,7 +359,7 @@ func TestApplyExistingOPCM(t *testing.T) { ...@@ -321,7 +359,7 @@ func TestApplyExistingOPCM(t *testing.T) {
st, st,
)) ))
validateOPChainDeployment(t, ctx, l1Client, st) validateOPChainDeployment(t, ctx, l1Client, st, intent)
} }
func TestL2BlockTimeOverride(t *testing.T) { func TestL2BlockTimeOverride(t *testing.T) {
......
...@@ -18,7 +18,7 @@ var ( ...@@ -18,7 +18,7 @@ var (
vaultMinWithdrawalAmount = mustHexBigFromHex("0x8ac7230489e80000") vaultMinWithdrawalAmount = mustHexBigFromHex("0x8ac7230489e80000")
) )
func DefaultDeployConfig() genesis.DeployConfig { func DefaultDeployConfig(chainIntent *ChainIntent) genesis.DeployConfig {
return genesis.DeployConfig{ return genesis.DeployConfig{
L2InitializationConfig: genesis.L2InitializationConfig{ L2InitializationConfig: genesis.L2InitializationConfig{
L2GenesisBlockDeployConfig: genesis.L2GenesisBlockDeployConfig{ L2GenesisBlockDeployConfig: genesis.L2GenesisBlockDeployConfig{
...@@ -32,6 +32,9 @@ func DefaultDeployConfig() genesis.DeployConfig { ...@@ -32,6 +32,9 @@ func DefaultDeployConfig() genesis.DeployConfig {
SequencerFeeVaultMinimumWithdrawalAmount: vaultMinWithdrawalAmount, SequencerFeeVaultMinimumWithdrawalAmount: vaultMinWithdrawalAmount,
BaseFeeVaultMinimumWithdrawalAmount: vaultMinWithdrawalAmount, BaseFeeVaultMinimumWithdrawalAmount: vaultMinWithdrawalAmount,
L1FeeVaultMinimumWithdrawalAmount: vaultMinWithdrawalAmount, L1FeeVaultMinimumWithdrawalAmount: vaultMinWithdrawalAmount,
BaseFeeVaultRecipient: chainIntent.BaseFeeVaultRecipient,
L1FeeVaultRecipient: chainIntent.L1FeeVaultRecipient,
SequencerFeeVaultRecipient: chainIntent.SequencerFeeVaultRecipient,
}, },
GovernanceDeployConfig: genesis.GovernanceDeployConfig{ GovernanceDeployConfig: genesis.GovernanceDeployConfig{
EnableGovernance: true, EnableGovernance: true,
...@@ -43,9 +46,9 @@ func DefaultDeployConfig() genesis.DeployConfig { ...@@ -43,9 +46,9 @@ func DefaultDeployConfig() genesis.DeployConfig {
GasPriceOracleBlobBaseFeeScalar: 810949, GasPriceOracleBlobBaseFeeScalar: 810949,
}, },
EIP1559DeployConfig: genesis.EIP1559DeployConfig{ EIP1559DeployConfig: genesis.EIP1559DeployConfig{
EIP1559Denominator: 50, EIP1559Denominator: chainIntent.Eip1559Denominator,
EIP1559DenominatorCanyon: 250, EIP1559DenominatorCanyon: 250,
EIP1559Elasticity: 6, EIP1559Elasticity: chainIntent.Eip1559Elasticity,
}, },
UpgradeScheduleDeployConfig: genesis.UpgradeScheduleDeployConfig{ UpgradeScheduleDeployConfig: genesis.UpgradeScheduleDeployConfig{
L2GenesisRegolithTimeOffset: u64UtilPtr(0), L2GenesisRegolithTimeOffset: u64UtilPtr(0),
...@@ -76,7 +79,8 @@ func DefaultDeployConfig() genesis.DeployConfig { ...@@ -76,7 +79,8 @@ func DefaultDeployConfig() genesis.DeployConfig {
} }
func CombineDeployConfig(intent *Intent, chainIntent *ChainIntent, state *State, chainState *ChainState) (genesis.DeployConfig, error) { func CombineDeployConfig(intent *Intent, chainIntent *ChainIntent, state *State, chainState *ChainState) (genesis.DeployConfig, error) {
cfg := DefaultDeployConfig() firstChainIntent := intent.Chains[0]
cfg := DefaultDeployConfig(firstChainIntent)
var err error var err error
if len(intent.GlobalDeployOverrides) > 0 { if len(intent.GlobalDeployOverrides) > 0 {
......
...@@ -97,6 +97,16 @@ type SuperchainRoles struct { ...@@ -97,6 +97,16 @@ type SuperchainRoles struct {
type ChainIntent struct { type ChainIntent struct {
ID common.Hash `json:"id" toml:"id"` ID common.Hash `json:"id" toml:"id"`
BaseFeeVaultRecipient common.Address `json:"baseFeeVaultRecipient" toml:"baseFeeVaultRecipient"`
L1FeeVaultRecipient common.Address `json:"l1FeeVaultRecipient" toml:"l1FeeVaultRecipient"`
SequencerFeeVaultRecipient common.Address `json:"sequencerFeeVaultRecipient" toml:"sequencerFeeVaultRecipient"`
Eip1559Denominator uint64 `json:"eip1559Denominator" toml:"eip1559Denominator"`
Eip1559Elasticity uint64 `json:"eip1559Elasticity" toml:"eip1559Elasticity"`
Roles ChainRoles `json:"roles" toml:"roles"` Roles ChainRoles `json:"roles" toml:"roles"`
DeployOverrides map[string]any `json:"deployOverrides" toml:"deployOverrides"` DeployOverrides map[string]any `json:"deployOverrides" toml:"deployOverrides"`
......
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