Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
18 changes: 9 additions & 9 deletions packages/contracts-bedrock/.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchm
GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_benchmark() (gas: 5099)
GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158531)
GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7597)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369242)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967382)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564356)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076571)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 467019)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512723)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72618)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_0() (gas: 369350)
GasBenchMark_L1CrossDomainMessenger:test_sendMessage_benchmark_1() (gas: 2967490)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_0() (gas: 564464)
GasBenchMark_L1StandardBridge_Deposit:test_depositERC20_benchmark_1() (gas: 4076679)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_0() (gas: 466998)
GasBenchMark_L1StandardBridge_Deposit:test_depositETH_benchmark_1() (gas: 3512702)
GasBenchMark_L1StandardBridge_Finalize:test_finalizeETHWithdrawal_benchmark() (gas: 72661)
GasBenchMark_L2OutputOracle:test_proposeL2Output_benchmark() (gas: 92973)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68357)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68921)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark() (gas: 68422)
GasBenchMark_OptimismPortal:test_depositTransaction_benchmark_1() (gas: 68986)
GasBenchMark_OptimismPortal:test_proveWithdrawalTransaction_benchmark() (gas: 155610)
21 changes: 12 additions & 9 deletions packages/contracts-bedrock/scripts/deploy/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,15 @@ contract Deploy is Deployer {
}

IProxyAdmin proxyAdmin = IProxyAdmin(payable(mustGetAddress("ProxyAdmin")));
ISystemConfig.Addresses memory addresses = ISystemConfig.Addresses({
l1CrossDomainMessenger: mustGetAddress("L1CrossDomainMessengerProxy"),
l1ERC721Bridge: mustGetAddress("L1ERC721BridgeProxy"),
l1StandardBridge: mustGetAddress("L1StandardBridgeProxy"),
disputeGameFactory: mustGetAddress("DisputeGameFactoryProxy"),
optimismPortal: mustGetAddress("OptimismPortalProxy"),
optimismMintableERC20Factory: mustGetAddress("OptimismMintableERC20FactoryProxy"),
gasPayingToken: customGasTokenAddress
});
proxyAdmin.upgradeAndCall({
_proxy: payable(systemConfigProxy),
_implementation: systemConfig,
Expand All @@ -1091,18 +1100,12 @@ contract Deploy is Deployer {
cfg.blobbasefeeScalar(),
batcherHash,
uint64(cfg.l2GenesisBlockGasLimit()),
uint32(cfg.eip1559Denominator()),
uint32(cfg.eip1559Elasticity()),
cfg.p2pSequencerAddress(),
Constants.DEFAULT_RESOURCE_CONFIG(),
cfg.batchInboxAddress(),
ISystemConfig.Addresses({

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stack too deep.

l1CrossDomainMessenger: mustGetAddress("L1CrossDomainMessengerProxy"),
l1ERC721Bridge: mustGetAddress("L1ERC721BridgeProxy"),
l1StandardBridge: mustGetAddress("L1StandardBridgeProxy"),
disputeGameFactory: mustGetAddress("DisputeGameFactoryProxy"),
optimismPortal: mustGetAddress("OptimismPortalProxy"),
optimismMintableERC20Factory: mustGetAddress("OptimismMintableERC20FactoryProxy"),
gasPayingToken: customGasTokenAddress
})
addresses
)
)
});
Expand Down
54 changes: 54 additions & 0 deletions packages/contracts-bedrock/snapshots/abi/SystemConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,32 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "eip1559Denominator",
"outputs": [
{
"internalType": "uint32",
"name": "",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "eip1559Elasticity",
"outputs": [
{
"internalType": "uint32",
"name": "",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gasLimit",
Expand Down Expand Up @@ -283,6 +309,16 @@
"name": "_gasLimit",
"type": "uint64"
},
{
"internalType": "uint32",
"name": "_eip1559Denominator",
"type": "uint32"
},
{
"internalType": "uint32",
"name": "_eip1559Elasticity",
"type": "uint32"
},
{
"internalType": "address",
"name": "_unsafeBlockSigner",
Expand Down Expand Up @@ -586,6 +622,24 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint32",
"name": "_denominator",
"type": "uint32"
},
{
"internalType": "uint32",
"name": "_elasticity",
"type": "uint32"
}
],
"name": "setEIP1559Params",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,32 @@
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "eip1559Denominator",
"outputs": [
{
"internalType": "uint32",
"name": "",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "eip1559Elasticity",
"outputs": [
{
"internalType": "uint32",
"name": "",
"type": "uint32"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "gasLimit",
Expand Down Expand Up @@ -304,6 +330,16 @@
"name": "_gasLimit",
"type": "uint64"
},
{
"internalType": "uint32",
"name": "_eip1559Denominator",
"type": "uint32"
},
{
"internalType": "uint32",
"name": "_eip1559Elasticity",
"type": "uint32"
},
{
"internalType": "address",
"name": "_unsafeBlockSigner",
Expand Down Expand Up @@ -431,6 +467,16 @@
"name": "_gasLimit",
"type": "uint64"
},
{
"internalType": "uint32",
"name": "_eip1559Denominator",
"type": "uint32"
},
{
"internalType": "uint32",
"name": "_eip1559Elasticity",
"type": "uint32"
},
{
"internalType": "address",
"name": "_unsafeBlockSigner",
Expand Down Expand Up @@ -747,6 +793,24 @@
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint32",
"name": "_denominator",
"type": "uint32"
},
{
"internalType": "uint32",
"name": "_elasticity",
"type": "uint32"
}
],
"name": "setEIP1559Params",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,19 @@
"offset": 0,
"slot": "105",
"type": "struct IResourceMetering.ResourceConfig"
},
{
"bytes": "4",
"label": "eip1559Denominator",
"offset": 0,
"slot": "106",
"type": "uint32"
},
{
"bytes": "4",
"label": "eip1559Elasticity",
"offset": 4,
"slot": "106",
"type": "uint32"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,19 @@
"offset": 0,
"slot": "105",
"type": "struct IResourceMetering.ResourceConfig"
},
{
"bytes": "4",
"label": "eip1559Denominator",
"offset": 0,
"slot": "106",
"type": "uint32"
},
{
"bytes": "4",
"label": "eip1559Elasticity",
"offset": 4,
"slot": "106",
"type": "uint32"
}
]
53 changes: 42 additions & 11 deletions packages/contracts-bedrock/src/L1/SystemConfig.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {
/// @custom:value GAS_LIMIT Represents an update to gas limit on L2.
/// @custom:value UNSAFE_BLOCK_SIGNER Represents an update to the signer key for unsafe
/// block distrubution.
/// @custom:value EIP_1559_PARAMS Represents an update to the EIP-1559 parameters.
enum UpdateType {
BATCHER,
GAS_CONFIG,
GAS_LIMIT,
UNSAFE_BLOCK_SIGNER
UNSAFE_BLOCK_SIGNER,
EIP_1559_PARAMS
}

/// @notice Struct representing the addresses of L1 system contracts. These should be the
Expand Down Expand Up @@ -123,6 +125,12 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {
/// Set as internal with a getter so that the struct is returned instead of a tuple.
IResourceMetering.ResourceConfig internal _resourceConfig;

/// @notice The EIP-1559 base fee max change denominator.
uint32 public eip1559Denominator;

/// @notice The elasticity multiplier for the EIP-1559 market.
uint32 public eip1559Elasticity;

/// @notice Emitted when configuration is updated.
/// @param version SystemConfig version.
/// @param updateType Type of update.
Expand All @@ -148,6 +156,8 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {
_blobbasefeeScalar: 0,
_batcherHash: bytes32(0),
_gasLimit: 1,
_eip1559Denominator: 1,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We agreed on not modifying the initializer with inputs to reduce the integration pains with OP Stack Chain Manager. We agreed on emitting default canyon values, if the storage slots are set to 0 (first time the contract is initalized) rather than having input arguments. This will sync the L1 state with the L2 view of the state. The dependency that is introduced is that chains will need to update to a newer release of op-node BEFORE we do the contract upgrade. We will add a getter/setter for the values, which can be atomically called during the same batch the new implementation is set in the proxy. cc @roberto-bayardo for context. Probably easier to just start on a fresh branch

_eip1559Elasticity: 1,
_unsafeBlockSigner: address(0),
_config: IResourceMetering.ResourceConfig({
maxResourceLimit: 1,
Expand All @@ -172,22 +182,26 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {

/// @notice Initializer.
/// The resource config must be set before the require check.
/// @param _owner Initial owner of the contract.
/// @param _basefeeScalar Initial basefee scalar value.
/// @param _blobbasefeeScalar Initial blobbasefee scalar value.
/// @param _batcherHash Initial batcher hash.
/// @param _gasLimit Initial gas limit.
/// @param _unsafeBlockSigner Initial unsafe block signer address.
/// @param _config Initial ResourceConfig.
/// @param _batchInbox Batch inbox address. An identifier for the op-node to find
/// canonical data.
/// @param _addresses Set of L1 contract addresses. These should be the proxies.
/// @param _owner Initial owner of the contract.
/// @param _basefeeScalar Initial basefee scalar value.
/// @param _blobbasefeeScalar Initial blobbasefee scalar value.
/// @param _batcherHash Initial batcher hash.
/// @param _gasLimit Initial gas limit.
/// @param _eip1559Denominator Initial EIP-1559 base fee max change denominator.
/// @param _eip1559Elasticity Initial EIP-1559 elasticity multiplier.
/// @param _unsafeBlockSigner Initial unsafe block signer address.
/// @param _config Initial ResourceConfig.
/// @param _batchInbox Batch inbox address. An identifier for the op-node to find
/// canonical data.
/// @param _addresses Set of L1 contract addresses. These should be the proxies.
function initialize(
address _owner,
uint32 _basefeeScalar,
uint32 _blobbasefeeScalar,
bytes32 _batcherHash,
uint64 _gasLimit,
uint32 _eip1559Denominator,
uint32 _eip1559Elasticity,
address _unsafeBlockSigner,
IResourceMetering.ResourceConfig memory _config,
address _batchInbox,
Expand All @@ -203,6 +217,7 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {
_setBatcherHash(_batcherHash);
_setGasConfigEcotone({ _basefeeScalar: _basefeeScalar, _blobbasefeeScalar: _blobbasefeeScalar });
_setGasLimit(_gasLimit);
_setEIP1559Params(_eip1559Denominator, _eip1559Elasticity);

Storage.setAddress(UNSAFE_BLOCK_SIGNER_SLOT, _unsafeBlockSigner);
Storage.setAddress(BATCH_INBOX_SLOT, _batchInbox);
Expand Down Expand Up @@ -420,6 +435,22 @@ contract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {
emit ConfigUpdate(VERSION, UpdateType.GAS_LIMIT, data);
}

/// @notice Updates the EIP-1559 parameters of the chain. Can only be called by the owner.
/// @param _denominator EIP-1559 base fee max change denominator.
/// @param _elasticity EIP-1559 elasticity multiplier.
function setEIP1559Params(uint32 _denominator, uint32 _elasticity) external onlyOwner {
_setEIP1559Params(_denominator, _elasticity);
}

/// @notice Internal function for updating the EIP-1559 parameters.
function _setEIP1559Params(uint32 _denominator, uint32 _elasticity) internal {
eip1559Denominator = _denominator;
eip1559Elasticity = _elasticity;

bytes memory data = abi.encode(uint64(uint64(_denominator) << 32 | uint64(_elasticity)));
Comment thread
clabby marked this conversation as resolved.
Outdated
emit ConfigUpdate(VERSION, UpdateType.EIP_1559_PARAMS, data);
}

/// @notice Sets the start block in a backwards compatible way. Proxies
/// that were initialized before the startBlock existed in storage
/// can have their start block set by a user provided override.
Expand Down
Loading