From d9ba10bd7c178b3425a0693b10005eb19a2b7cee Mon Sep 17 00:00:00 2001 From: Ratan Kaliani Date: Thu, 3 Oct 2024 12:57:19 -0700 Subject: [PATCH] feat: db path indexed by chain id (#137) * feat: switch db path * add --- docker-compose.yml | 2 +- proposer/op/op_proposer.sh | 2 +- proposer/op/proposer/config.go | 7 ++++++- proposer/op/proposer/flags/flags.go | 4 ++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 75389406..102ff5b8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,4 +21,4 @@ services: depends_on: - op-succinct-server volumes: - - ./db:/usr/local/bin/dbdata/ + - ./db:/usr/local/bin/dbdata diff --git a/proposer/op/op_proposer.sh b/proposer/op/op_proposer.sh index 77eb7c55..2d3b50d6 100644 --- a/proposer/op/op_proposer.sh +++ b/proposer/op/op_proposer.sh @@ -13,7 +13,7 @@ --l1-eth-rpc=${L1_RPC} \ --beacon-rpc=${L1_BEACON_RPC} \ --max-concurrent-proof-requests=${MAX_CONCURRENT_PROOF_REQUESTS:-10} \ - --db-path=${DB_PATH:-/usr/local/bin/dbdata/proofs.db} \ + --db-path=${DB_PATH:-/usr/local/bin/dbdata} \ --op-succinct-server-url=${OP_SUCCINCT_SERVER_URL:-http://op-succinct-server:3000} \ --max-block-range-per-span-proof=${MAX_BLOCK_RANGE_PER_SPAN_PROOF:-20} \ --use-cached-db=${USE_CACHED_DB:-false} diff --git a/proposer/op/proposer/config.go b/proposer/op/proposer/config.go index 6cf996b6..8ad7b1cd 100644 --- a/proposer/op/proposer/config.go +++ b/proposer/op/proposer/config.go @@ -2,7 +2,9 @@ package proposer import ( "errors" + "fmt" "log" + "path/filepath" "time" "github.com/urfave/cli/v2" @@ -142,6 +144,9 @@ func NewConfig(ctx *cli.Context) *CLIConfig { log.Fatal(err) } + dbPath := ctx.String(flags.DbPathFlag.Name) + dbPath = filepath.Join(dbPath, fmt.Sprintf("%d", rollupConfig.L2ChainID.Uint64()), "proofs.db") + return &CLIConfig{ // Required Flags L1EthRpc: ctx.String(flags.L1EthRpcFlag.Name), @@ -164,7 +169,7 @@ func NewConfig(ctx *cli.Context) *CLIConfig { DisputeGameType: uint32(ctx.Uint(flags.DisputeGameTypeFlag.Name)), ActiveSequencerCheckDuration: ctx.Duration(flags.ActiveSequencerCheckDurationFlag.Name), WaitNodeSync: ctx.Bool(flags.WaitNodeSyncFlag.Name), - DbPath: ctx.String(flags.DbPathFlag.Name), + DbPath: dbPath, UseCachedDb: ctx.Bool(flags.UseCachedDbFlag.Name), MaxSpanBatchDeviation: ctx.Uint64(flags.MaxSpanBatchDeviationFlag.Name), MaxBlockRangePerSpanProof: ctx.Uint64(flags.MaxBlockRangePerSpanProofFlag.Name), diff --git a/proposer/op/proposer/flags/flags.go b/proposer/op/proposer/flags/flags.go index 92e45cd9..9a1b48e1 100644 --- a/proposer/op/proposer/flags/flags.go +++ b/proposer/op/proposer/flags/flags.go @@ -92,8 +92,8 @@ var ( } DbPathFlag = &cli.StringFlag{ Name: "db-path", - Usage: "Path to the database used to track OP Succinct proof generation", - Value: "./op-proposer/proofs.db", + Usage: "Path to the database folder used to track OP Succinct proof generation. The DB file is always stored at DbPathFlag/{chain_id}/proofs.db", + Value: "./op-proposer", EnvVars: prefixEnvVars("DB_PATH"), } UseCachedDbFlag = &cli.BoolFlag{