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
20 changes: 15 additions & 5 deletions .github/workflows/docker-build-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
branches:
- 'master'
- 'celo*'
push:
branches:
- 'master'
- 'celo*'
workflow_dispatch:

jobs:
Expand All @@ -21,11 +25,15 @@ jobs:

build-cel2-migration-tool:
runs-on: ubuntu-latest
env:
GIT_COMMIT: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
needs: detect-files-changed
if: |
contains(needs.detect-files-changed.outputs.files-changed, 'go.sum') ||
contains(needs.detect-files-changed.outputs.files-changed, 'op-chain-ops/cmd/celo-migrate') ||
contains(needs.detect-files-changed.outputs.files-changed, 'op-chain-ops/Dockerfile')
contains(needs.detect-files-changed.outputs.files-changed, 'op-chain-ops/Dockerfile') ||
contains(needs.detect-files-changed.outputs.files-changed, '.github/workflows/docker-build-scan.yaml') ||
github.event_name == 'workflow_dispatch'
permissions:
contents: read
id-token: write
Expand All @@ -43,7 +51,7 @@ jobs:
with:
platforms: linux/amd64
registry: us-west1-docker.pkg.dev/devopsre/dev-images/cel2-migration-tool
tags: ${{ github.sha }}
tags: ${{ env.GIT_COMMIT }}
context: ./
dockerfile: ./op-chain-ops/Dockerfile
push: true
Expand All @@ -59,15 +67,17 @@ jobs:
contains(needs.detect-files-changed.outputs.files-changed, 'op-node/') ||
contains(needs.detect-files-changed.outputs.files-changed, 'op-batcher/') ||
contains(needs.detect-files-changed.outputs.files-changed, 'op-proposer/') ||
contains(needs.detect-files-changed.outputs.files-changed, 'op-service/')
contains(needs.detect-files-changed.outputs.files-changed, 'op-service/') ||
contains(needs.detect-files-changed.outputs.files-changed, '.github/workflows/docker-build-scan.yaml') ||
github.event_name == 'workflow_dispatch'
permissions:
contents: read
id-token: write
security-events: write
env:
GIT_COMMIT: ${{ github.sha }}
GIT_COMMIT: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
GIT_DATE: ${{ github.event.head_commit.timestamp }}
IMAGE_TAGS: ${{ github.sha }},latest
IMAGE_TAGS: ${{ (github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/celo')) && 'latest,' || '') }}${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
REGISTRY: us-west1-docker.pkg.dev
REPOSITORY: blockchaintestsglobaltestnet/dev-images
steps:
Expand Down
9 changes: 8 additions & 1 deletion op-chain-ops/cmd/celo-migrate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ var (
Usage: "Path to write the rollup config JSON file, to be provided to op-node with the 'rollup.config' flag",
Required: true,
}
migrationBlockTimeFlag = &cli.Uint64Flag{
Name: "migration-block-time",
Usage: "Specifies a unix timestamp to use for the migration block. If not provided, the current time will be used.",
}
oldDBPathFlag = &cli.PathFlag{
Name: "old-db",
Usage: "Path to the old Celo chaindata dir, can be found at '<datadir>/celo/chaindata'",
Expand Down Expand Up @@ -104,6 +108,7 @@ var (
l1RPCFlag,
l2AllocsFlag,
outfileRollupConfigFlag,
migrationBlockTimeFlag,
}
// Ignore onlyAncients flag and duplicate newDBPathFlag for full migration
fullMigrationFlags = append(blockMigrationFlags[1:], stateMigrationFlags[1:]...)
Expand All @@ -127,6 +132,7 @@ type stateMigrationOptions struct {
l2AllocsPath string
outfileRollupConfig string
newDBPath string
migrationBlockTime uint64
}

func parseBlockMigrationOptions(ctx *cli.Context) blockMigrationOptions {
Expand All @@ -150,6 +156,7 @@ func parseStateMigrationOptions(ctx *cli.Context) stateMigrationOptions {
l1RPC: ctx.String(l1RPCFlag.Name),
l2AllocsPath: ctx.Path(l2AllocsFlag.Name),
outfileRollupConfig: ctx.Path(outfileRollupConfigFlag.Name),
migrationBlockTime: ctx.Uint64(migrationBlockTimeFlag.Name),
}
}

Expand Down Expand Up @@ -337,7 +344,7 @@ func runStateMigration(opts stateMigrationOptions) error {
}

// Write changes to state to actual state database
cel2Header, err := applyStateMigrationChanges(config, l2Genesis, opts.newDBPath)
cel2Header, err := applyStateMigrationChanges(config, l2Genesis, opts.newDBPath, opts.migrationBlockTime)
if err != nil {
return err
}
Expand Down
9 changes: 7 additions & 2 deletions op-chain-ops/cmd/celo-migrate/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"math/big"
"os"
"time"

"github.com/ethereum-optimism/optimism/op-chain-ops/genesis"
"github.com/ethereum-optimism/optimism/op-service/predeploys"
Expand Down Expand Up @@ -50,7 +51,7 @@ var (
}
)

func applyStateMigrationChanges(config *genesis.DeployConfig, genesis *core.Genesis, dbPath string) (*types.Header, error) {
func applyStateMigrationChanges(config *genesis.DeployConfig, genesis *core.Genesis, dbPath string, migrationBlockTime uint64) (*types.Header, error) {
log.Info("Opening Celo database", "dbPath", dbPath)

ldb, err := openDB(dbPath)
Expand Down Expand Up @@ -119,6 +120,10 @@ func applyStateMigrationChanges(config *genesis.DeployConfig, genesis *core.Gene
baseFee = header.BaseFee
}

if migrationBlockTime == 0 {
migrationBlockTime = uint64(time.Now().Unix())
}

// Create the header for the Cel2 transition block.
cel2Header := &types.Header{
ParentHash: header.Hash(),
Expand All @@ -132,7 +137,7 @@ func applyStateMigrationChanges(config *genesis.DeployConfig, genesis *core.Gene
Number: migrationBlock,
GasLimit: header.GasLimit,
GasUsed: 0,
Time: header.Time + 5,
Time: migrationBlockTime,
Extra: []byte("CeL2 migration"),
MixDigest: common.Hash{},
Nonce: types.BlockNonce{},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ config=$(cat << EOL
"respectedGameType": 0,

"usePlasma": $USE_PLASMA,
"daCommitmentType": "KeccakCommitment",
"daChallengeWindow": 160,
"daResolveWindow": 160,
"daCommitmentType": "GenericCommitment",
"daChallengeWindow": 3600,
"daResolveWindow": 3600,
"daBondSize": 1000000,
"daResolverRefundPercentage": 0
}
Expand All @@ -133,3 +133,4 @@ EOL

# Write the config file
echo "$config" > deploy-config/$DEPLOYMENT_CONTEXT.json
echo "Created file deploy-config/$DEPLOYMENT_CONTEXT.json successfully."