Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 6 additions & 6 deletions ops-bedrock/devnet-up.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ function wait_up {
mkdir -p ./.devnet

if [ ! -f ./.devnet/rollup.json ]; then
GENESIS_TIMESTAMP=$(date +%s | xargs printf "0x%x")
L1_GENESIS_TIMESTAMP=$(date +%s | xargs printf "0x%x")
else
GENESIS_TIMESTAMP=$(jq '.timestamp' < .devnet/genesis-l1.json)
L1_GENESIS_TIMESTAMP=$(jq '.timestamp' < .devnet/genesis-l1.json)
fi

# Regenerate the L1 genesis file if necessary. The existence of the genesis
Expand All @@ -69,7 +69,7 @@ if [ ! -f ./.devnet/genesis-l1.json ]; then
echo "Regenerating L1 genesis."
(
cd $CONTRACTS_BEDROCK
L2OO_STARTING_BLOCK_TIMESTAMP=$GENESIS_TIMESTAMP npx hardhat genesis-l1 \
L1_GENESIS_TIMESTAMP=$L1_GENESIS_TIMESTAMP npx hardhat genesis-l1 \
--outfile genesis-l1.json
mv genesis-l1.json ../../.devnet/genesis-l1.json
)
Expand All @@ -89,7 +89,7 @@ if [ ! -d $CONTRACTS_BEDROCK/deployments/$NETWORK ]; then
(
echo "Deploying contracts."
cd $CONTRACTS_BEDROCK
L2OO_STARTING_BLOCK_TIMESTAMP=$GENESIS_TIMESTAMP yarn hardhat --network $NETWORK deploy
L1_GENESIS_TIMESTAMP=$L1_GENESIS_TIMESTAMP yarn hardhat --network $NETWORK deploy
)
else
echo "Contracts already deployed, skipping."
Expand All @@ -99,7 +99,7 @@ if [ ! -f ./.devnet/genesis-l2.json ]; then
(
echo "Creating L2 genesis file."
cd $CONTRACTS_BEDROCK
L2OO_STARTING_BLOCK_TIMESTAMP=$GENESIS_TIMESTAMP npx hardhat --network $NETWORK genesis-l2
L1_GENESIS_TIMESTAMP=$L1_GENESIS_TIMESTAMP npx hardhat --network $NETWORK genesis-l2
mv genesis.json ../../.devnet/genesis-l2.json
echo "Created L2 genesis."
)
Expand All @@ -120,7 +120,7 @@ if [ ! -f ./.devnet/rollup.json ]; then
(
echo "Building rollup config..."
cd $CONTRACTS_BEDROCK
L2OO_STARTING_BLOCK_TIMESTAMP=$GENESIS_TIMESTAMP npx hardhat --network $NETWORK rollup-config
L1_GENESIS_TIMESTAMP=$L1_GENESIS_TIMESTAMP npx hardhat --network $NETWORK rollup-config
mv rollup.json ../../.devnet/rollup.json
)
else
Expand Down
9 changes: 5 additions & 4 deletions packages/contracts-bedrock/deploy-config/devnetL1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@ import { ethers } from 'ethers'

const { env } = process

const startingTimestamp =
typeof env.L2OO_STARTING_BLOCK_TIMESTAMP === 'string'
? ethers.BigNumber.from(env.L2OO_STARTING_BLOCK_TIMESTAMP).toNumber()
const l1GenesisTimestamp =
typeof env.L1_GENESIS_TIMESTAMP === 'string'
? ethers.BigNumber.from(env.L1_GENESIS_TIMESTAMP).toNumber()
: Math.floor(Date.now() / 1000)

const config = {
submissionInterval: 6,
genesisOutput: ethers.constants.HashZero,
historicalBlocks: 0,
l1StartingBlockTag: 'earliest',
startingBlockNumber: 0,
l2BlockTime: 2,

startingTimestamp,
l1GenesisTimestamp,
sequencerAddress: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8',

l2CrossDomainMessengerOwner: ethers.constants.AddressZero,
Expand Down
5 changes: 3 additions & 2 deletions packages/contracts-bedrock/deploy-config/goerli.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { ethers } from 'ethers'

const sequencerAddress = '0x6c23a0dcdfc44b7a57bed148de598895e398d984'
const startingTimestamp = 1658777882
const l1StartingBlockTag =
'0xafce66a0a2446856112e4069b275ad32b1f4a607888f9c4c59eddf9be81f8670'

const config = {
submissionInterval: 6,
genesisOutput: ethers.constants.HashZero,
historicalBlocks: 0,
startingBlockNumber: 0,
l2BlockTime: 2,
startingTimestamp,
l1StartingBlockTag,
sequencerAddress,

l2CrossDomainMessengerOwner: ethers.constants.AddressZero,
Expand Down
9 changes: 5 additions & 4 deletions packages/contracts-bedrock/deploy-config/hardhat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ import { ethers } from 'ethers'

const { env } = process

const startingTimestamp =
typeof env.L2OO_STARTING_BLOCK_TIMESTAMP === 'string'
? ethers.BigNumber.from(env.L2OO_STARTING_BLOCK_TIMESTAMP).toNumber()
const l1GenesisTimestamp =
typeof env.L1_GENESIS_TIMESTAMP === 'string'
? ethers.BigNumber.from(env.L1_GENESIS_TIMESTAMP).toNumber()
: Math.floor(Date.now() / 1000)

const config = {
submissionInterval: 6,
genesisOutput: ethers.constants.HashZero,
historicalBlocks: 0,
startingBlockNumber: 0,
l1StartingBlockTag: 'earliest',
l2BlockTime: 2,
startingTimestamp,
l1GenesisTimestamp,
sequencerAddress: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8',
maxSequencerDrift: 10,
sequencerWindowSize: 4,
Expand Down
15 changes: 6 additions & 9 deletions packages/contracts-bedrock/deploy/000-L2OutputOracle.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()
const { deployConfig } = hre

if (
typeof deployConfig.startingTimestamp !== 'number' ||
isNaN(deployConfig.startingTimestamp)
) {
throw new Error(
'Cannot deploy L2OutputOracle without specifying a valid startingTimestamp.'
)
const l1 = hre.ethers.getDefaultProvider()
const l1StartingBlock = await l1.getBlock(deployConfig.l1StartingBlockTag)
if (l1StartingBlock === null) {
throw new Error(`Cannot fetch block tag ${deployConfig.l1StartingBlockTag}`)
}

await deploy('L2OutputOracleProxy', {
Expand All @@ -34,7 +31,7 @@ const deployFn: DeployFunction = async (hre) => {
deployConfig.genesisOutput,
deployConfig.historicalBlocks,
deployConfig.startingBlockNumber,
deployConfig.startingTimestamp,
l1StartingBlock.timestamp,
deployConfig.l2BlockTime,
deployConfig.sequencerAddress,
deployConfig.outputOracleOwner,
Expand Down Expand Up @@ -84,7 +81,7 @@ const deployFn: DeployFunction = async (hre) => {
}

const startingTimestamp = await L2OutputOracle.STARTING_TIMESTAMP()
if (!startingTimestamp.eq(BigNumber.from(deployConfig.startingTimestamp))) {
if (!startingTimestamp.eq(BigNumber.from(l1StartingBlock.timestamp))) {
throw new Error('starting timestamp misconfigured')
}
const l2BlockTime = await L2OutputOracle.L2_BLOCK_TIME()
Expand Down
9 changes: 3 additions & 6 deletions packages/contracts-bedrock/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,15 @@ const config: HardhatUserConfig = {
historicalBlocks: {
type: 'number',
},
startingBlockNumber: {
type: 'number',
},
startingTimestamp: {
type: 'number',
},
sequencerAddress: {
type: 'address',
},
outputOracleOwner: {
type: 'address',
},
l1StartingBlockTag: {
type: 'string',
},
},
external: {
contracts: [
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts-bedrock/tasks/genesis-l1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ task('genesis-l1', 'create a genesis config')
}
}

const timestamp = hre.deployConfig.startingTimestamp
const timestamp = hre.deployConfig.l1GenesisTimestamp
if (timestamp === undefined) {
throw new Error('Must configure starting block timestamp')
}
Expand Down
8 changes: 6 additions & 2 deletions packages/contracts-bedrock/tasks/genesis-l2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,12 @@ task('genesis-l2', 'create a genesis config')
}
}

const portal = await hre.deployments.get('OptimismPortalProxy')
const l1StartingBlock = await l1.getBlock(portal.receipt.blockHash)
const l1StartingBlock = await l1.getBlock(deployConfig.l1StartingBlockTag)
if (l1StartingBlock === null) {
throw new Error(
`Cannot fetch block tag ${deployConfig.l1StartingBlockTag}`
)
}

if (l1StartingBlock === null) {
console.log(`Unable to fetch L1 starting timestamp`)
Expand Down
11 changes: 8 additions & 3 deletions packages/contracts-bedrock/tasks/rollup-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ 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 l1StartingBlock = await l1.getBlock(deployConfig.l1StartingBlockTag)
if (l1StartingBlock === null) {
throw new Error(
`Cannot fetch block tag ${deployConfig.l1StartingBlockTag}`
)
}

const config: OpNodeConfig = {
genesis: {
l1: {
hash: portal.receipt.blockHash,
number: portal.receipt.blockNumber,
hash: l1StartingBlock.hash,
number: l1StartingBlock.number,
},
l2: {
hash: l2Genesis.hash,
Expand Down
4 changes: 1 addition & 3 deletions packages/contracts-bedrock/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@
"rootDir": "./src",
"outDir": "./dist"
},
"include": [
"src/**/*"
]
"include": ["src/**/*"]
}