diff --git a/op-deployer/pkg/deployer/integration_test/apply_test.go b/op-deployer/pkg/deployer/integration_test/apply_test.go index 211bae3cb44..4161f9bec86 100644 --- a/op-deployer/pkg/deployer/integration_test/apply_test.go +++ b/op-deployer/pkg/deployer/integration_test/apply_test.go @@ -247,7 +247,7 @@ func TestEndToEndApply(t *testing.T) { // CGT config for L2 genesis amount := new(big.Int) amount.SetString("1000000000000000000000", 10) - intent.Chains[0].CustomGasToken = &state.CustomGasToken{ + intent.Chains[0].CustomGasToken = state.CustomGasToken{ Enabled: true, Name: "Custom Gas Token", Symbol: "CGT", @@ -766,7 +766,7 @@ func newChainIntent(t *testing.T, dk *devkeys.MnemonicDevKeys, l1ChainID *big.In Proposer: addrFor(t, dk, devkeys.ProposerRole.Key(l1ChainID)), Challenger: addrFor(t, dk, devkeys.ChallengerRole.Key(l1ChainID)), }, - CustomGasToken: &state.CustomGasToken{ + CustomGasToken: state.CustomGasToken{ Enabled: false, Name: "", Symbol: "", diff --git a/op-deployer/pkg/deployer/pipeline/l2genesis.go b/op-deployer/pkg/deployer/pipeline/l2genesis.go index cdafc262b42..08bce853eb9 100644 --- a/op-deployer/pkg/deployer/pipeline/l2genesis.go +++ b/op-deployer/pkg/deployer/pipeline/l2genesis.go @@ -154,8 +154,9 @@ func calculateL2GenesisOverrides(intent *state.Intent, thisIntent *state.ChainIn } } - if thisIntent.CustomGasToken == nil { - thisIntent.CustomGasToken = &state.CustomGasToken{ + // If CustomGasToken is not enabled, update it with override values + if !thisIntent.CustomGasToken.Enabled { + thisIntent.CustomGasToken = state.CustomGasToken{ Enabled: overrides.UseCustomGasToken, Name: overrides.GasPayingTokenName, Symbol: overrides.GasPayingTokenSymbol, diff --git a/op-deployer/pkg/deployer/state/chain_intent.go b/op-deployer/pkg/deployer/state/chain_intent.go index 9eaf5be1b4b..4286d718082 100644 --- a/op-deployer/pkg/deployer/state/chain_intent.go +++ b/op-deployer/pkg/deployer/state/chain_intent.go @@ -81,7 +81,7 @@ type ChainIntent struct { OperatorFeeConstant uint64 `json:"operatorFeeConstant,omitempty" toml:"operatorFeeConstant,omitempty"` L1StartBlockHash *common.Hash `json:"l1StartBlockHash,omitempty" toml:"l1StartBlockHash,omitempty"` MinBaseFee uint64 `json:"minBaseFee,omitempty" toml:"minBaseFee,omitempty"` - CustomGasToken *CustomGasToken `json:"customGasToken" toml:"customGasToken"` + CustomGasToken CustomGasToken `json:"customGasToken" toml:"customGasToken"` // Optional. For development purposes only. Only enabled if the operation mode targets a genesis-file output. L2DevGenesisParams *L2DevGenesisParams `json:"l2DevGenesisParams,omitempty" toml:"l2DevGenesisParams,omitempty"` } @@ -127,7 +127,7 @@ func (c *ChainIntent) Check() error { return fmt.Errorf("%w: chainId=%s", ErrFeeVaultZeroAddress, c.ID) } - if c.CustomGasToken != nil && c.CustomGasToken.Enabled { + if c.CustomGasToken.Enabled { if c.CustomGasToken.Name == "" { return fmt.Errorf("%w: CustomGasToken.Name cannot be empty when enabled, chainId=%s", ErrIncompatibleValue, c.ID) } @@ -150,7 +150,7 @@ func (c *ChainIntent) Check() error { // GetNativeAssetLiquidityAmount returns the native asset liquidity amount for the chain. // If not set, returns the default value of zero. func (c *ChainIntent) GetNativeAssetLiquidityAmount() *big.Int { - if c.CustomGasToken != nil && c.CustomGasToken.NativeAssetLiquidityAmount != nil { + if c.CustomGasToken.NativeAssetLiquidityAmount != nil { return c.CustomGasToken.NativeAssetLiquidityAmount.ToInt() } diff --git a/op-deployer/pkg/deployer/state/deploy_config_test.go b/op-deployer/pkg/deployer/state/deploy_config_test.go index 6e9bfd0d06d..324b6598335 100644 --- a/op-deployer/pkg/deployer/state/deploy_config_test.go +++ b/op-deployer/pkg/deployer/state/deploy_config_test.go @@ -1,6 +1,7 @@ package state import ( + "math/big" "testing" "github.com/ethereum-optimism/optimism/op-chain-ops/addresses" @@ -33,10 +34,11 @@ func TestCombineDeployConfig(t *testing.T) { UnsafeBlockSigner: common.HexToAddress("0xabc"), Batcher: common.HexToAddress("0xdef"), }, - CustomGasToken: &CustomGasToken{ - Enabled: false, - Name: "Test", - Symbol: "TEST", + CustomGasToken: CustomGasToken{ + Enabled: false, + Name: "", + Symbol: "", + NativeAssetLiquidityAmount: (*hexutil.Big)(big.NewInt(0)), }, } state := State{ diff --git a/op-deployer/pkg/deployer/state/intent.go b/op-deployer/pkg/deployer/state/intent.go index 8879e5df237..b4edc275a37 100644 --- a/op-deployer/pkg/deployer/state/intent.go +++ b/op-deployer/pkg/deployer/state/intent.go @@ -158,8 +158,7 @@ func (c *Intent) validateStandardValues() error { if len(chain.AdditionalDisputeGames) > 0 { return fmt.Errorf("%w: chainId=%s additionalDisputeGames must be nil", ErrNonStandardValue, chain.ID) } - - if chain.CustomGasToken != nil { + if chain.CustomGasToken.Enabled { return fmt.Errorf("%w: chainId=%s custom gas token must be nil for standard chains", ErrNonStandardValue, chain.ID) } } @@ -303,11 +302,11 @@ func NewIntentCustom(l1ChainId uint64, l2ChainIds []common.Hash) (Intent, error) intent.Chains = append(intent.Chains, &ChainIntent{ ID: l2ChainID, GasLimit: standard.GasLimit, - CustomGasToken: &CustomGasToken{ + CustomGasToken: CustomGasToken{ Enabled: false, Name: "", Symbol: "", - NativeAssetLiquidityAmount: nil, + NativeAssetLiquidityAmount: (*hexutil.Big)(big.NewInt(0)), }, }) } @@ -353,7 +352,12 @@ func NewIntentStandard(l1ChainId uint64, l2ChainIds []common.Hash) (Intent, erro L1ProxyAdminOwner: l1ProxyAdminOwner, L2ProxyAdminOwner: l2ProxyAdminOwner, }, - CustomGasToken: nil, // Standard chains must have nil CustomGasToken + CustomGasToken: CustomGasToken{ + Enabled: false, + Name: "", + Symbol: "", + NativeAssetLiquidityAmount: (*hexutil.Big)(big.NewInt(0)), + }, }) } return intent, nil diff --git a/op-deployer/pkg/deployer/state/intent_test.go b/op-deployer/pkg/deployer/state/intent_test.go index 9507054f575..3fdd975c576 100644 --- a/op-deployer/pkg/deployer/state/intent_test.go +++ b/op-deployer/pkg/deployer/state/intent_test.go @@ -67,11 +67,11 @@ func TestValidateStandardValues(t *testing.T) { { "CustomGasToken", func(intent *Intent) { - intent.Chains[0].CustomGasToken = &CustomGasToken{ - Enabled: false, - Name: "", - Symbol: "", - NativeAssetLiquidityAmount: (*hexutil.Big)(big.NewInt(0)), + intent.Chains[0].CustomGasToken = CustomGasToken{ + Enabled: true, + Name: "Custom Gas Token", + Symbol: "CGT", + NativeAssetLiquidityAmount: (*hexutil.Big)(big.NewInt(1000)), } }, ErrNonStandardValue, @@ -176,7 +176,7 @@ func TestValidateCustomValues(t *testing.T) { { "empty custom gas token name when enabled", func(intent *Intent) { - intent.Chains[0].CustomGasToken = &CustomGasToken{ + intent.Chains[0].CustomGasToken = CustomGasToken{ Enabled: true, Name: "", Symbol: "CGT", @@ -187,7 +187,7 @@ func TestValidateCustomValues(t *testing.T) { { "empty custom gas token symbol when enabled", func(intent *Intent) { - intent.Chains[0].CustomGasToken = &CustomGasToken{ + intent.Chains[0].CustomGasToken = CustomGasToken{ Enabled: true, Name: "Custom Gas Token", Symbol: "", @@ -257,7 +257,7 @@ func setCustomGasToken(intent *Intent) { amount := new(big.Int) amount.SetString("1000000000000000000000", 10) - intent.Chains[0].CustomGasToken = &CustomGasToken{ + intent.Chains[0].CustomGasToken = CustomGasToken{ Enabled: true, Name: "Custom Gas Token", Symbol: "CGT", diff --git a/op-e2e/config/init.go b/op-e2e/config/init.go index 37dcc27da3b..1c105a245aa 100644 --- a/op-e2e/config/init.go +++ b/op-e2e/config/init.go @@ -400,11 +400,11 @@ func defaultIntent(root string, loc *artifacts.Locator, deployer common.Address, Proposer: addrs.Proposer, Challenger: common.HexToAddress("0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65"), }, - CustomGasToken: &state.CustomGasToken{ + CustomGasToken: state.CustomGasToken{ Enabled: false, Name: "", Symbol: "", - NativeAssetLiquidityAmount: nil, + NativeAssetLiquidityAmount: (*hexutil.Big)(big.NewInt(0)), }, AdditionalDisputeGames: []state.AdditionalDisputeGame{ { diff --git a/op-e2e/e2eutils/intentbuilder/builder.go b/op-e2e/e2eutils/intentbuilder/builder.go index 47daff25d82..a3dfca9a144 100644 --- a/op-e2e/e2eutils/intentbuilder/builder.go +++ b/op-e2e/e2eutils/intentbuilder/builder.go @@ -390,7 +390,7 @@ func (c *l2Configurator) WithEIP1559Denominator(value uint64) { } func (c *l2Configurator) WithCustomGasToken(enabled bool, name, symbol string, nativeAssetLiquidityAmount *big.Int) { - c.builder.intent.Chains[c.chainIndex].CustomGasToken = &state.CustomGasToken{ + c.builder.intent.Chains[c.chainIndex].CustomGasToken = state.CustomGasToken{ Enabled: enabled, Name: name, Symbol: symbol, diff --git a/op-e2e/e2eutils/intentbuilder/builder_test.go b/op-e2e/e2eutils/intentbuilder/builder_test.go index 15b50d83f5f..9895f104b2f 100644 --- a/op-e2e/e2eutils/intentbuilder/builder_test.go +++ b/op-e2e/e2eutils/intentbuilder/builder_test.go @@ -163,7 +163,7 @@ func TestBuilder(t *testing.T) { GasLimit: standard.GasLimit, OperatorFeeScalar: 100, OperatorFeeConstant: 200, - CustomGasToken: &state.CustomGasToken{ + CustomGasToken: state.CustomGasToken{ Enabled: false, Name: "", Symbol: "",