Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 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
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2038,7 +2038,8 @@ workflows:
dev_features: <<matrix.dev_features>>
matrix:
parameters:
dev_features: ["main", "OPTIMISM_PORTAL_INTEROP"]
dev_features:
["main", "OPTIMISM_PORTAL_INTEROP", "CUSTOM_GAS_TOKEN"]
# need this requires to ensure that all FFI JSONs exist
requires:
- contracts-bedrock-build
Expand Down
1 change: 0 additions & 1 deletion op-chain-ops/interopgen/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ func DeployL2ToL1(l1Host *script.Host, superCfg *SuperchainConfig, superDeployme
AllowCustomDisputeParameters: true,
OperatorFeeScalar: cfg.GasPriceOracleOperatorFeeScalar,
OperatorFeeConstant: cfg.GasPriceOracleOperatorFeeConstant,
UseCustomGasToken: cfg.UseCustomGasToken,
})
if err != nil {
return nil, fmt.Errorf("failed to deploy L2 OP chain: %w", err)
Expand Down
17 changes: 15 additions & 2 deletions op-deployer/pkg/deployer/integration_test/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,20 @@ func TestEndToEndApply(t *testing.T) {

t.Run("with custom gas token", func(t *testing.T) {
intent, st := newIntent(t, l1ChainID, dk, l2ChainID1, loc, loc)

// 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",
NativeAssetLiquidityAmount: (*hexutil.Big)(amount),
}
// CGT config for OPCM
intent.GlobalDeployOverrides = map[string]interface{}{
"devFeatureBitmap": common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000010"),
}

require.NoError(t, deployer.ApplyPipeline(ctx, deployer.ApplyPipelineOpts{
DeploymentTarget: deployer.DeploymentTargetLive,
Expand Down Expand Up @@ -279,6 +285,13 @@ func TestEndToEndApply(t *testing.T) {
err = fn.DecodeReturns(res, &response)
require.NoError(t, err)
require.Equal(t, true, response)

// Check that the native asset liquidity predeploy has the configured amount in L2 genesis
nativeAssetLiquidityAddr := common.HexToAddress("0x4200000000000000000000000000000000000029")
l2Genesis := st.Chains[0].Allocs.Data.Accounts
account, exists := l2Genesis[nativeAssetLiquidityAddr]
require.True(t, exists, "Native asset liquidity predeploy should exist in L2 genesis")
require.Equal(t, amount, account.Balance, "Native asset liquidity predeploy should have the configured balance")
})
}

Expand Down Expand Up @@ -753,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
1 change: 0 additions & 1 deletion op-deployer/pkg/deployer/opcm/opchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type DeployOPChainInput struct {
DisputeClockExtension uint64
DisputeMaxClockDuration uint64
AllowCustomDisputeParameters bool
UseCustomGasToken bool

OperatorFeeScalar uint32
OperatorFeeConstant uint64
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
1 change: 0 additions & 1 deletion op-deployer/pkg/deployer/pipeline/opchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ func makeDCI(intent *state.Intent, thisIntent *state.ChainIntent, chainID common
DisputeClockExtension: proofParams.DisputeClockExtension, // 3 hours (input in seconds)
DisputeMaxClockDuration: proofParams.DisputeMaxClockDuration, // 3.5 days (input in seconds)
AllowCustomDisputeParameters: proofParams.DangerouslyAllowCustomDisputeParameters,
UseCustomGasToken: thisIntent.CustomGasToken != nil && thisIntent.CustomGasToken.Enabled,
OperatorFeeScalar: thisIntent.OperatorFeeScalar,
OperatorFeeConstant: thisIntent.OperatorFeeConstant,
}, nil
Expand Down
10 changes: 5 additions & 5 deletions op-deployer/pkg/deployer/state/chain_intent.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ type L2DevGenesisParams struct {

type CustomGasToken struct {
Enabled bool `json:"enabled" toml:"enabled"`
Name string `json:"name" toml:"name"`
Symbol string `json:"symbol" toml:"symbol"`
Name string `json:"name,omitempty" toml:"name,omitempty"`
Symbol string `json:"symbol,omitempty" toml:"symbol,omitempty"`
NativeAssetLiquidityAmount *hexutil.Big `json:"nativeAssetLiquidityAmount,omitempty" toml:"nativeAssetLiquidityAmount,omitempty"`
}

Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ interface IOPContractsManager {
uint32 basefeeScalar;
uint32 blobBasefeeScalar;
uint256 l2ChainId;
bool useCustomGasToken;
// The correct type is OutputRoot memory but OP Deployer does not yet support structs.
bytes startingAnchorRoot;
// The salt mixer is used as part of making the resulting salt unique.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,8 @@ interface IOptimismPortal2 is IProxyAdminOwnedBase {
external;
function finalizedWithdrawals(bytes32) external view returns (bool);
function guardian() external view returns (address);
function initialize(
ISystemConfig _systemConfig,
IAnchorStateRegistry _anchorStateRegistry
)
external;
function initialize(ISystemConfig _systemConfig, IAnchorStateRegistry _anchorStateRegistry) external;
function initVersion() external view returns (uint8);
function isCustomGasToken() external view returns (bool);
function l2Sender() external view returns (address);
function minimumGasLimit(uint64 _byteCount) external pure returns (uint64);
function numProofSubmitters(bytes32 _withdrawalHash) external view returns (uint256);
Expand Down
6 changes: 6 additions & 0 deletions packages/contracts-bedrock/scripts/L2Genesis.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ contract L2Genesis is Script {
if (_input.fundDevAccounts) {
fundDevAccounts();
}

vm.stopPrank();
vm.deal(deployer, 0);
vm.resetNonce(deployer);
Expand Down Expand Up @@ -600,6 +601,11 @@ contract L2Genesis is Script {
function setNativeAssetLiquidity(Input memory _input) internal {
_setImplementationCode(Predeploys.NATIVE_ASSET_LIQUIDITY);

require(
_input.nativeAssetLiquidityAmount <= type(uint248).max,
"L2Genesis: native asset liquidity amount must be less than or equal to type(uint248).max"
);

// Pre-fund the liquidity contract with the specified amount
vm.deal(Predeploys.NATIVE_ASSET_LIQUIDITY, _input.nativeAssetLiquidityAmount);
}
Expand Down
1 change: 0 additions & 1 deletion packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ contract Deploy is Deployer {
basefeeScalar: cfg.basefeeScalar(),
blobBasefeeScalar: cfg.blobbasefeeScalar(),
l2ChainId: cfg.l2ChainID(),
useCustomGasToken: cfg.useCustomGasToken(),
startingAnchorRoot: abi.encode(
Proposal({ root: Hash.wrap(cfg.faultGameGenesisOutputRoot()), l2SequenceNumber: cfg.faultGameGenesisBlock() })
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ contract DeployConfig is Script {
useCustomGasToken = _readOr(_json, "$.useCustomGasToken", false);
gasPayingTokenName = _readOr(_json, "$.gasPayingTokenName", "");
gasPayingTokenSymbol = _readOr(_json, "$.gasPayingTokenSymbol", "");
nativeAssetLiquidityAmount = _readOr(_json, "$.nativeAssetLiquidityAmount", type(uint248).max);
nativeAssetLiquidityAmount = _readOr(_json, "$.nativeAssetLiquidityAmount", 0);

enableGovernance = _readOr(_json, "$.enableGovernance", false);
systemConfigStartBlock = stdJson.readUint(_json, "$.systemConfigStartBlock");
Expand Down Expand Up @@ -238,6 +238,11 @@ contract DeployConfig is Script {
useCustomGasToken = _useCustomGasToken;
}

/// @notice Allow the `nativeAssetLiquidityAmount` config to be overridden in testing environments
function setNativeAssetLiquidityAmount(uint256 _nativeAssetLiquidityAmount) public {
nativeAssetLiquidityAmount = _nativeAssetLiquidityAmount;
}

/// @notice Allow the `baseFeeVaultWithdrawalNetwork` config to be overridden in testing environments
function setBaseFeeVaultWithdrawalNetwork(uint256 _baseFeeVaultWithdrawalNetwork) public {
baseFeeVaultWithdrawalNetwork = _baseFeeVaultWithdrawalNetwork;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ contract DeployOPChainInput is BaseDeployIO {
Duration internal _disputeClockExtension;
Duration internal _disputeMaxClockDuration;
bool internal _allowCustomDisputeParameters;
bool internal _useCustomGasToken;

uint32 internal _operatorFeeScalar;
uint64 internal _operatorFeeConstant;
Expand Down Expand Up @@ -118,8 +117,6 @@ contract DeployOPChainInput is BaseDeployIO {
function set(bytes4 _sel, bool _value) public {
if (_sel == this.allowCustomDisputeParameters.selector) {
_allowCustomDisputeParameters = _value;
} else if (_sel == this.useCustomGasToken.selector) {
_useCustomGasToken = _value;
} else {
revert("DeployOPChainInput: unknown selector");
}
Expand Down Expand Up @@ -171,10 +168,6 @@ contract DeployOPChainInput is BaseDeployIO {
return _l2ChainId;
}

function useCustomGasToken() public view returns (bool) {
return _useCustomGasToken;
}

function startingAnchorRoot() public pure returns (bytes memory) {
// WARNING: For now always hardcode the starting permissioned game anchor root to 0xdead,
// and we do not set anything for the permissioned game. This is because we currently only
Expand Down Expand Up @@ -394,8 +387,7 @@ contract DeployOPChain is Script {
disputeMaxGameDepth: _doi.disputeMaxGameDepth(),
disputeSplitDepth: _doi.disputeSplitDepth(),
disputeClockExtension: _doi.disputeClockExtension(),
disputeMaxClockDuration: _doi.disputeMaxClockDuration(),
useCustomGasToken: _doi.useCustomGasToken()
disputeMaxClockDuration: _doi.disputeMaxClockDuration()
});

vm.broadcast(msg.sender);
Expand Down
5 changes: 5 additions & 0 deletions packages/contracts-bedrock/scripts/libraries/Config.sol
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,9 @@ library Config {
function devFeatureInterop() internal view returns (bool) {
return vm.envOr("DEV_FEATURE__OPTIMISM_PORTAL_INTEROP", false);
}

/// @notice Returns true if the development feature custom gas token is enabled.
function devFeatureCustomGasToken() internal view returns (bool) {
return vm.envOr("DEV_FEATURE__CUSTOM_GAS_TOKEN", false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,6 @@
"name": "l2ChainId",
"type": "uint256"
},
{
"internalType": "bool",
"name": "useCustomGasToken",
"type": "bool"
},
{
"internalType": "bytes",
"name": "startingAnchorRoot",
Expand Down
Loading