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