Commit 2b4851f3 authored by Mark Tyneway's avatar Mark Tyneway

op-chain-ops: better logging in migrate script

Add some additional loglines for sanity checking in the migration
script. Checks for the L1 chain id and logs some info about the
database config before opening it. Also add some context for error
messages that should never happnen in practice.
parent 12e782df
...@@ -164,8 +164,14 @@ func main() { ...@@ -164,8 +164,14 @@ func main() {
l1RpcURL := ctx.String("l1-rpc-url") l1RpcURL := ctx.String("l1-rpc-url")
l1Client, err := ethclient.Dial(l1RpcURL) l1Client, err := ethclient.Dial(l1RpcURL)
if err != nil { if err != nil {
return err return fmt.Errorf("cannot dial L1 client: %w", err)
}
chainId, err := l1Client.ChainID(context.Background())
if err != nil {
return fmt.Errorf("failed to get L1 ChainID: %w", err)
} }
log.Info("L1 ChainID", "chainId", chainId)
var block *types.Block var block *types.Block
tag := config.L1StartingBlockTag tag := config.L1StartingBlockTag
...@@ -181,14 +187,16 @@ func main() { ...@@ -181,14 +187,16 @@ func main() {
return fmt.Errorf("invalid l1StartingBlockTag in deploy config: %v", tag) return fmt.Errorf("invalid l1StartingBlockTag in deploy config: %v", tag)
} }
if err != nil { if err != nil {
return err return fmt.Errorf("cannot fetch L1 starting block tag: %w", err)
} }
dbCache := ctx.Int("db-cache") dbCache := ctx.Int("db-cache")
dbHandles := ctx.Int("db-handles") dbHandles := ctx.Int("db-handles")
ldb, err := db.Open(ctx.String("db-path"), dbCache, dbHandles) dbPath := ctx.String("db-path")
log.Info("Opening database", "dbCache", dbCache, "dbHandles", dbHandles, "dbPath", dbPath)
ldb, err := db.Open(dbPath, dbCache, dbHandles)
if err != nil { if err != nil {
return err return fmt.Errorf("cannot open DB: %w", err)
} }
// Read the required deployment addresses from disk if required // Read the required deployment addresses from disk if required
...@@ -217,7 +225,7 @@ func main() { ...@@ -217,7 +225,7 @@ func main() {
return err return err
} }
postLDB, err := db.Open(ctx.String("db-path"), dbCache, dbHandles) postLDB, err := db.Open(dbPath, dbCache, dbHandles)
if err != nil { if err != nil {
return err return err
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment