Skip to content
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
4 changes: 2 additions & 2 deletions op-deployer/pkg/deployer/integration_test/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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: "",
Expand Down
5 changes: 3 additions & 2 deletions op-deployer/pkg/deployer/pipeline/l2genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions op-deployer/pkg/deployer/state/chain_intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down Expand Up @@ -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)
}
Expand All @@ -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()
}

Expand Down
10 changes: 6 additions & 4 deletions op-deployer/pkg/deployer/state/deploy_config_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package state

import (
"math/big"
"testing"

"github.com/ethereum-optimism/optimism/op-chain-ops/addresses"
Expand Down Expand Up @@ -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{
Expand Down
14 changes: 9 additions & 5 deletions op-deployer/pkg/deployer/state/intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)),
},
})
}
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions op-deployer/pkg/deployer/state/intent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand All @@ -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: "",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions op-e2e/config/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
{
Expand Down
2 changes: 1 addition & 1 deletion op-e2e/e2eutils/intentbuilder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion op-e2e/e2eutils/intentbuilder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "",
Expand Down