Skip to content

Commit

Permalink
Remove config options for DB options
Browse files Browse the repository at this point in the history
Kept in a separate commit to make potential adding them back easier.
  • Loading branch information
palango committed Jun 11, 2024
1 parent 9de9c2d commit 0da7f68
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions op-chain-ops/cmd/celo-migrate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,6 @@ var (
Usage: "Path to the Celo database, not including the `celo/chaindata` part",
Required: true,
}
dbCacheFlag = &cli.IntFlag{
Name: "db-cache",
Usage: "LevelDB cache size in mb",
Value: 1024,
}
dbHandlesFlag = &cli.IntFlag{
Name: "db-handles",
Usage: "LevelDB number of handles",
Value: 60,
}
dryRunFlag = &cli.BoolFlag{
Name: "dry-run",
Usage: "Dry run the upgrade by not committing the database",
Expand All @@ -86,8 +76,6 @@ var (
l2AllocsFlag,
outfileRollupConfigFlag,
dbPathFlag,
dbCacheFlag,
dbHandlesFlag,
dryRunFlag,
}

Expand Down Expand Up @@ -116,8 +104,6 @@ func main() {
l2AllocsPath := ctx.Path("l2-allocs")
outfileRollupConfig := ctx.Path("outfile.rollup-config")
dbPath := ctx.String("db-path")
dbCache := ctx.Int("db-cache")
dbHandles := ctx.Int("db-handles")
dryRun := ctx.Bool("dry-run")

// Read deployment configuration
Expand Down Expand Up @@ -192,7 +178,7 @@ func main() {
}

// Write changes to state to actual state database
cel2Header, err := ApplyMigrationChangesToDB(l2Genesis, dbPath, dbCache, dbHandles, !dryRun)
cel2Header, err := ApplyMigrationChangesToDB(l2Genesis, dbPath, !dryRun)
if err != nil {
return err
}
Expand Down Expand Up @@ -221,9 +207,9 @@ func main() {
log.Info("Finished migration successfully!")
}

func ApplyMigrationChangesToDB(genesis *core.Genesis, dbPath string, dbCache int, dbHandles int, commit bool) (*types.Header, error) {
log.Info("Opening celo database", "dbCache", dbCache, "dbHandles", dbHandles, "dbPath", dbPath)
ldb, err := openCeloDb(dbPath, dbCache, dbHandles)
func ApplyMigrationChangesToDB(genesis *core.Genesis, dbPath string, commit bool) (*types.Header, error) {
log.Info("Opening Celo database", "dbPath", dbPath)
ldb, err := openCeloDb(dbPath)
if err != nil {
return nil, fmt.Errorf("cannot open DB: %w", err)
}
Expand Down Expand Up @@ -410,7 +396,7 @@ func ApplyMigrationChangesToDB(genesis *core.Genesis, dbPath string, dbCache int
}

// Opens a Celo database, stored in the `celo` subfolder
func openCeloDb(path string, cache int, handles int) (ethdb.Database, error) {
func openCeloDb(path string) (ethdb.Database, error) {
if _, err := os.Stat(path); errors.Is(err, os.ErrNotExist) {
return nil, err
}
Expand All @@ -422,8 +408,8 @@ func openCeloDb(path string, cache int, handles int) (ethdb.Database, error) {
Directory: chaindataPath,
AncientsDirectory: ancientPath,
Namespace: "",
Cache: cache,
Handles: handles,
Cache: 1024,
Handles: 60,
ReadOnly: false,
})
if err != nil {
Expand Down

0 comments on commit 0da7f68

Please sign in to comment.