Commit e87ad76d authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

Merge pull request #5711 from ethereum-optimism/fix/deploy-ts-checks-gaslimit

contracts-bedrock: deploy time checks
parents 32294e20 080a72cb
...@@ -2,17 +2,29 @@ import assert from 'assert' ...@@ -2,17 +2,29 @@ import assert from 'assert'
import { DeployFunction } from 'hardhat-deploy/dist/types' import { DeployFunction } from 'hardhat-deploy/dist/types'
import '@eth-optimism/hardhat-deploy-config' import '@eth-optimism/hardhat-deploy-config'
import { ethers } from 'ethers' import { BigNumber } from 'ethers'
import { defaultResourceConfig } from '../src/constants'
import { assertContractVariable, deploy } from '../src/deploy-utils' import { assertContractVariable, deploy } from '../src/deploy-utils'
const uint128Max = ethers.BigNumber.from('0xffffffffffffffffffffffffffffffff')
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
const batcherHash = hre.ethers.utils const batcherHash = hre.ethers.utils
.hexZeroPad(hre.deployConfig.batchSenderAddress, 32) .hexZeroPad(hre.deployConfig.batchSenderAddress, 32)
.toLowerCase() .toLowerCase()
const l2GenesisBlockGasLimit = BigNumber.from(
hre.deployConfig.l2GenesisBlockGasLimit
)
const l2GasLimitLowerBound = BigNumber.from(
defaultResourceConfig.systemTxMaxGas +
defaultResourceConfig.maxResourceLimit
)
if (l2GenesisBlockGasLimit.lt(l2GasLimitLowerBound)) {
throw new Error(
`L2 genesis block gas limit must be at least ${l2GasLimitLowerBound}`
)
}
await deploy({ await deploy({
hre, hre,
name: 'SystemConfig', name: 'SystemConfig',
...@@ -21,16 +33,9 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -21,16 +33,9 @@ const deployFn: DeployFunction = async (hre) => {
hre.deployConfig.gasPriceOracleOverhead, hre.deployConfig.gasPriceOracleOverhead,
hre.deployConfig.gasPriceOracleScalar, hre.deployConfig.gasPriceOracleScalar,
batcherHash, batcherHash,
hre.deployConfig.l2GenesisBlockGasLimit, l2GenesisBlockGasLimit,
hre.deployConfig.p2pSequencerAddress, hre.deployConfig.p2pSequencerAddress,
{ defaultResourceConfig,
maxResourceLimit: 20_000_000,
elasticityMultiplier: 10,
baseFeeMaxChangeDenominator: 8,
systemTxMaxGas: 1_000_000,
minimumBaseFee: ethers.utils.parseUnits('1', 'gwei'),
maximumBaseFee: uint128Max,
},
], ],
postDeployAction: async (contract) => { postDeployAction: async (contract) => {
await assertContractVariable( await assertContractVariable(
...@@ -56,12 +61,30 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -56,12 +61,30 @@ const deployFn: DeployFunction = async (hre) => {
) )
const config = await contract.resourceConfig() const config = await contract.resourceConfig()
assert(config.maxResourceLimit === 20_000_000) assert(config.maxResourceLimit === defaultResourceConfig.maxResourceLimit)
assert(config.elasticityMultiplier === 10) assert(
assert(config.baseFeeMaxChangeDenominator === 8) config.elasticityMultiplier ===
assert(config.systemTxMaxGas === 1_000_000) defaultResourceConfig.elasticityMultiplier
assert(ethers.utils.parseUnits('1', 'gwei').eq(config.minimumBaseFee)) )
assert(config.maximumBaseFee.eq(uint128Max)) assert(
config.baseFeeMaxChangeDenominator ===
defaultResourceConfig.baseFeeMaxChangeDenominator
)
assert(
BigNumber.from(config.systemTxMaxGas).eq(
defaultResourceConfig.systemTxMaxGas
)
)
assert(
BigNumber.from(config.minimumBaseFee).eq(
defaultResourceConfig.minimumBaseFee
)
)
assert(
BigNumber.from(config.maximumBaseFee).eq(
defaultResourceConfig.maximumBaseFee
)
)
}, },
}) })
} }
......
import assert from 'assert' import assert from 'assert'
import { ethers, BigNumber } from 'ethers' import { ethers } from 'ethers'
import { DeployFunction } from 'hardhat-deploy/dist/types' import { DeployFunction } from 'hardhat-deploy/dist/types'
import { awaitCondition } from '@eth-optimism/core-utils' import { awaitCondition } from '@eth-optimism/core-utils'
import '@eth-optimism/hardhat-deploy-config' import '@eth-optimism/hardhat-deploy-config'
...@@ -10,6 +10,7 @@ import { ...@@ -10,6 +10,7 @@ import {
getContractsFromArtifacts, getContractsFromArtifacts,
getDeploymentAddress, getDeploymentAddress,
} from '../src/deploy-utils' } from '../src/deploy-utils'
import { defaultResourceConfig } from '../src/constants'
const deployFn: DeployFunction = async (hre) => { const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts() const { deployer } = await hre.getNamedAccounts()
...@@ -102,16 +103,7 @@ const deployFn: DeployFunction = async (hre) => { ...@@ -102,16 +103,7 @@ const deployFn: DeployFunction = async (hre) => {
unsafeBlockSigner: hre.deployConfig.p2pSequencerAddress, unsafeBlockSigner: hre.deployConfig.p2pSequencerAddress,
// The resource config is not exposed to the end user // The resource config is not exposed to the end user
// to simplify deploy config. It may be introduced in the future. // to simplify deploy config. It may be introduced in the future.
resourceConfig: { resourceConfig: defaultResourceConfig,
maxResourceLimit: 20_000_000,
elasticityMultiplier: 10,
baseFeeMaxChangeDenominator: 8,
minimumBaseFee: ethers.utils.parseUnits('1', 'gwei'),
systemTxMaxGas: 1_000_000,
maximumBaseFee: BigNumber.from(
'0xffffffffffffffffffffffffffffffff'
).toString(),
},
}, },
} }
......
import { ethers } from 'ethers'
/** /**
* Predeploys are Solidity contracts that are injected into the initial L2 state and provide * Predeploys are Solidity contracts that are injected into the initial L2 state and provide
* various useful functions. * various useful functions.
...@@ -26,3 +28,14 @@ export const predeploys = { ...@@ -26,3 +28,14 @@ export const predeploys = {
BaseFeeVault: '0x4200000000000000000000000000000000000019', BaseFeeVault: '0x4200000000000000000000000000000000000019',
L1FeeVault: '0x420000000000000000000000000000000000001a', L1FeeVault: '0x420000000000000000000000000000000000001a',
} }
const uint128Max = ethers.BigNumber.from('0xffffffffffffffffffffffffffffffff')
export const defaultResourceConfig = {
maxResourceLimit: 20_000_000,
elasticityMultiplier: 10,
baseFeeMaxChangeDenominator: 8,
minimumBaseFee: ethers.utils.parseUnits('1', 'gwei'),
systemTxMaxGas: 1_000_000,
maximumBaseFee: uint128Max,
}
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