Skip to content
Closed
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
30 changes: 30 additions & 0 deletions cel2-migration-test/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export DEPLOYMENT_CONTEXT=cel2-migration
export IMPL_SALT=$(openssl rand -hex 32)

export L1_RPC_URL="http://localhost:8545"
export L1_RPC_KIND=debug_geth

export L2_RPC_URL="http://localhost:9545"

export GS_ADMIN_ADDRESS="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
export GS_ADMIN_PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"

export GS_BATCHER_ADDRESS="0x70997970C51812dc3A010C7d01b50e0d17dc79C8"
export GS_BATCHER_PRIVATE_KEY="0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"

export GS_PROPOSER_ADDRESS="0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC"
export GS_PROPOSER_PRIVATE_KEY="0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a"

export GS_SEQUENCER_ADDRESS="0x90F79bf6EB2c4f870365E785982E1f101E93b906"
export GS_SEQUENCER_PRIVATE_KEY="0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6"

export DG_TYPE=0
export PROPOSAL_INTERVAL="10s"

if [ -f "config/deployment-l1.json" ]; then
# TODO(pl): FInd out why we cannot set both
# export L2OO_ADDRESS=$(cat config/deployment-l1.json | jq -r .L2OutputOracleProxy)
export DGF_ADDRESS=$(cat config/deployment-l1.json | jq -r .DisputeGameFactoryProxy)
fi


9 changes: 9 additions & 0 deletions cel2-migration-test/Dockerfile.l1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM ethereum/client-go:v1.13.11

RUN apk add --no-cache jq bash

COPY entrypoint-l1.sh /entrypoint.sh

VOLUME ["/db"]

ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
11 changes: 11 additions & 0 deletions cel2-migration-test/Dockerfile.l2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# TODO: build arm64 images
# This currently requires op-geth from https://github.com/celo-org/op-geth/tree/alecps/piersy/data-migration
Copy link

Choose a reason for hiding this comment

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

We might want to update this to piersy/minimal-data-migration

FROM --platform=linux/amd64 us-west1-docker.pkg.dev/blockchaintestsglobaltestnet/dev-images/op-geth:3d6a0e48e00137e581ee064db9cafa8300598771

RUN apk add --no-cache jq

COPY entrypoint-l2.sh /entrypoint.sh

# VOLUME ["/db"]

ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
82 changes: 82 additions & 0 deletions cel2-migration-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Migration testing setup

This directory contains files for running a local L2 with the purpose of testing
the migration. Most services are run via docker compose, but there are some
scripts that need to be run manually (right now).

In general services can be started by `docker compose up <service_name>`. If you
want to start in a detached mode, add `-d` to the command. Logs can be watched
with `docker compose logs <service_name>`. Add `-f` to follow them.

All commands are expected to be run from inside this directory.

## Walkthrough

1. **Start the L1**

The L1 is a `geth` client running with the clique consensus engine in the
`l1` service. Is uses the genesis file at `genesis-l1.json` to initialize the
chain and fund important accounts that will be used in later steps.

Start the L1 by running `docker compose up l1`. This will initialize the
chain, the data dir is `data/l1`.

1. **Deploy the OP L1 contracts**

Now it is necessary to deploy the L1 contracts. This is done by the
`deploy-l1-contracts.sh` script.

Start the script `./deploy-l1-contracts.sh`. This creates a config file
(`config/config.json`) and a file containing L1 addresses
(`deployment-l1.json`).

Running the script overwrites prior deployments. If it fails without a
readable error message, it might be caused by re-using an old salt. In this
case you can create a new one with `direnv allow`.

1. **Setup Celo datadir and run migration**

First we need to build the migration tool.

```sh
cd ../op-chain-ops # Assuming you're in cel2-migration-test
make celo-migrate
```

Now it possible to setup the migration of a Celo datadir. Copy the datadir
of the node you want into `data/l2` and name it `source`. This directory
will not be touched in the migration process.

**Important**: Then update the `config/config.json` file under the
`l2ChainID` field with the chain id of the celo chain.

Run the migration by executing `./migrate-state.sh`. It should finish with
the message "Finished migration successfully!" and a new directory `migrated`
in `data/l2`. Additionally two files will have been created:

- `config/rollup-config.json` is the config required by `op-node`.
- `config/op-state-log.json` is purely informational and contains all state
that was written into the migrated state database.

1. **Run `op-geth` on migrated state**

Start `op-geth` with `docker compose up l2`.

Make sure this prints the correct chain id and *Optimism* as the consensus
engine. Additionally, the merge should be configured and the *Cel2* hardfork
enabled.

The execution client is now running and waiting for command from the
consensus client, `op-node`.

1. **Run `op-node` on migrated state**

Finally, we can start `op-node`: `docker compose up op-node`.

This should show logs indicating that blocks are created on both the `l2` and
`op-node` services.

1. **Run `op-batcher` and `op-proposer`**

Run `docker compose up op-batcher op-proposer`. If this fails with unset
environment variables, reload the `.envrc` file with `direnv allow`.
112 changes: 112 additions & 0 deletions cel2-migration-test/config/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/usr/bin/env bash

# This script is used to generate the getting-started.json configuration file
# used in the Getting Started quickstart guide on the docs site. Avoids the
# need to have the getting-started.json committed to the repo since it's an
# invalid JSON file when not filled in, which is annoying.

reqenv() {
if [ -z "${!1}" ]; then
echo "Error: environment variable '$1' is undefined"
exit 1
fi
}

# Check required environment variables
reqenv "GS_ADMIN_ADDRESS"
reqenv "GS_BATCHER_ADDRESS"
reqenv "GS_PROPOSER_ADDRESS"
reqenv "GS_SEQUENCER_ADDRESS"
reqenv "L1_RPC_URL"

# Get the finalized block timestamp and hash
block=$(cast block --rpc-url "$L1_RPC_URL")
timestamp=$(echo "$block" | awk '/timestamp/ { print $2 }')
blockhash=$(echo "$block" | awk '/hash/ { print $2 }')

# Generate the config file
config=$(cat << EOL
{
"l1StartingBlockTag": "$blockhash",

"l1ChainID": 900,
"l2ChainID": 949000,
"l2BlockTime": 2,
"l1BlockTime": 12,

"maxSequencerDrift": 600,
"sequencerWindowSize": 3600,
"channelTimeout": 300,

"p2pSequencerAddress": "$GS_SEQUENCER_ADDRESS",
"batchInboxAddress": "0xff00000000000000000000000000000000042069",
"batchSenderAddress": "$GS_BATCHER_ADDRESS",

"l2OutputOracleSubmissionInterval": 120,
"l2OutputOracleStartingBlockNumber": 0,
"l2OutputOracleStartingTimestamp": $timestamp,

"l2OutputOracleProposer": "$GS_PROPOSER_ADDRESS",
"l2OutputOracleChallenger": "$GS_ADMIN_ADDRESS",

"finalizationPeriodSeconds": 12,

"proxyAdminOwner": "$GS_ADMIN_ADDRESS",
"baseFeeVaultRecipient": "$GS_ADMIN_ADDRESS",
"l1FeeVaultRecipient": "$GS_ADMIN_ADDRESS",
"sequencerFeeVaultRecipient": "$GS_ADMIN_ADDRESS",
"finalSystemOwner": "$GS_ADMIN_ADDRESS",
"superchainConfigGuardian": "$GS_ADMIN_ADDRESS",

"baseFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
"l1FeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
"sequencerFeeVaultMinimumWithdrawalAmount": "0x8ac7230489e80000",
"baseFeeVaultWithdrawalNetwork": 0,
"l1FeeVaultWithdrawalNetwork": 0,
"sequencerFeeVaultWithdrawalNetwork": 0,

"gasPriceOracleOverhead": 2100,
"gasPriceOracleScalar": 1000000,

"enableGovernance": false,
"governanceTokenSymbol": "OP",
"governanceTokenName": "Optimism",
"governanceTokenOwner": "$GS_ADMIN_ADDRESS",

"l2GenesisBlockGasLimit": "0x1c9c380",
"l2GenesisBlockBaseFeePerGas": "0x3b9aca00",
"l2GenesisRegolithTimeOffset": "0x0",

"eip1559Denominator": 50,
"eip1559DenominatorCanyon": 250,
"eip1559Elasticity": 6,

"l2GenesisDeltaTimeOffset": null,
"l2GenesisCanyonTimeOffset": "0x0",

"systemConfigStartBlock": 0,

"requiredProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",
"recommendedProtocolVersion": "0x0000000000000000000000000000000000000000000000000000000000000000",

"faultGameAbsolutePrestate": "0x03c7ae758795765c6664a5d39bf63841c71ff191e9189522bad8ebff5d4eca98",
"faultGameMaxDepth": 44,
"faultGameMaxDuration": 1200,
"faultGameGenesisBlock": 0,
"faultGameGenesisOutputRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
"faultGameSplitDepth": 14,

"preimageOracleMinProposalSize": 1800000,
"preimageOracleChallengePeriod": 86400,
"preimageOracleCancunActivationTimestamp": 0,

"proofMaturityDelaySeconds": 12,
"disputeGameFinalityDelaySeconds": 6,
"respectedGameType": 0,
"useFaultProofs": false
}
EOL
)

# Write the config file
echo "$config" > config/config.json
21 changes: 21 additions & 0 deletions cel2-migration-test/deploy-l1-contracts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
set -o errexit # abort on nonzero exitstatus
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes

# Create config file
./config/config.sh
cp config/config.json ../packages/contracts-bedrock/deploy-config/${DEPLOYMENT_CONTEXT}.json

# Deploy CREATE2 contract
codesize=$(cast codesize 0x4e59b44847b379578588920cA78FbF26c0B4956C --rpc-url $L1_RPC_URL)
if [[ $codesize =~ 0 ]]; then
cast publish --rpc-url $L1_RPC_URL 0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222
fi

# Deploy OP contracts
pushd ../packages/contracts-bedrock
forge script scripts/Deploy.s.sol:Deploy --private-key $GS_ADMIN_PRIVATE_KEY --broadcast --rpc-url $L1_RPC_URL
popd

# Copy deployment information
cp ../packages/contracts-bedrock/deployments/${DEPLOYMENT_CONTEXT}/.deploy config/deployment-l1.json
Loading