Commit f7e13566 authored by Joshua Gutow's avatar Joshua Gutow Committed by Mark Tyneway

devnet: Use later L2 timestamp for network

parent eb0405cb
......@@ -60,7 +60,7 @@ mkdir -p ./.devnet
if [ ! -f ./.devnet/rollup.json ]; then
GENESIS_TIMESTAMP=$(date +%s | xargs printf "0x%x")
else
GENESIS_TIMESTAMP=$(jq '.genesis.l2_time' < .devnet/rollup.json)
GENESIS_TIMESTAMP=$(jq '.timestamp' < .devnet/genesis-l1.json)
fi
# Regenerate the L1 genesis file if necessary. The existence of the genesis
......
......@@ -52,6 +52,7 @@ task('genesis-l2', 'create a genesis config')
'The file to write the output JSON to',
'genesis.json'
)
.addOptionalParam('l1RpcUrl', 'The L1 RPC URL', 'http://127.0.0.1:8545')
.setAction(async (args, hre) => {
const {
computeStorageSlots,
......@@ -60,6 +61,8 @@ task('genesis-l2', 'create a genesis config')
const { deployConfig } = hre
const l1 = new ethers.providers.StaticJsonRpcProvider(args.l1RpcUrl)
// Use the addresses of the proxies here instead of the implementations
// Be backwards compatible
let ProxyL1CrossDomainMessenger = await hre.deployments.getOrNull(
......@@ -256,6 +259,9 @@ task('genesis-l2', 'create a genesis config')
}
}
const portal = await hre.deployments.get('OptimismPortalProxy')
const l1StartingBlock = await l1.getBlock(portal.receipt.blockHash)
const genesis: OptimismGenesis = {
config: {
chainId: deployConfig.genesisBlockChainid,
......@@ -279,9 +285,7 @@ task('genesis-l2', 'create a genesis config')
},
nonce: '0x1234',
difficulty: '0x1',
timestamp: ethers.BigNumber.from(
deployConfig.startingTimestamp
).toHexString(),
timestamp: ethers.BigNumber.from(l1StartingBlock.timestamp).toHexString(),
gasLimit: deployConfig.genesisBlockGasLimit,
extraData: deployConfig.genesisBlockExtradata,
optimism: {
......
......@@ -21,6 +21,7 @@ task('rollup-config', 'create a genesis config')
const l2Genesis = await l2.getBlock('earliest')
const portal = await hre.deployments.get('OptimismPortalProxy')
const l1StartingBlock = await l1.getBlock(portal.receipt.blockHash)
const config: OpNodeConfig = {
genesis: {
......@@ -32,7 +33,7 @@ task('rollup-config', 'create a genesis config')
hash: l2Genesis.hash,
number: 0,
},
l2_time: deployConfig.startingTimestamp,
l2_time: l1StartingBlock.timestamp,
},
block_time: deployConfig.l2BlockTime,
max_sequencer_drift: deployConfig.maxSequencerDrift,
......
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