diff --git a/Dockerfile b/Dockerfile index bf1d96d68a..df8c4a2a85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -204,7 +204,7 @@ COPY ./scripts/download-machine.sh . #RUN ./download-machine.sh consensus-v11 0xf4389b835497a910d7ba3ebfb77aa93da985634f3c052de1290360635be40c4a #RUN ./download-machine.sh consensus-v11.1 0x68e4fe5023f792d4ef584796c84d710303a5e12ea02d6e37e2b5e9c4332507c4 #RUN ./download-machine.sh consensus-v20 0x8b104a2e80ac6165dc58b9048de12f301d70b02a0ab51396c22b4b4b802a16a4 -RUN ./download-machine.sh consensus-v30 0xb0de9cb89e4d944ae6023a3b62276e54804c242fd8c4c2d8e6cc4450f5fa8b1b +RUN ./download-machine.sh consensus-v30 0xb0de9cb89e4d944ae6023a3b62276e54804c242fd8c4c2d8e6cc4450f5fa8b1b && true FROM golang:1.21.10-bookworm as node-builder WORKDIR /workspace diff --git a/arbnode/node.go b/arbnode/node.go index 4ef0e03258..a83558a4e4 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -669,7 +669,9 @@ func createNodeImpl( if err := wallet.Initialize(ctx); err != nil { return nil, err } - stakerAddr = dp.Sender() + if dp != nil { + stakerAddr = dp.Sender() + } whitelisted, err := stakerObj.IsWhitelisted(ctx) if err != nil { return nil, err diff --git a/cmd/nitro/init.go b/cmd/nitro/init.go index 6d6436776d..360b40cd40 100644 --- a/cmd/nitro/init.go +++ b/cmd/nitro/init.go @@ -15,6 +15,8 @@ import ( "net/http" "net/url" "os" + "path" + "path/filepath" "runtime" "strings" "sync" @@ -316,6 +318,14 @@ func validateBlockChain(blockChain *core.BlockChain, chainConfig *params.ChainCo return nil } +func dirExists(path string) bool { + info, err := os.Stat(path) + if os.IsNotExist(err) { + return false + } + return info.IsDir() +} + func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeConfig, chainId *big.Int, cacheConfig *core.CacheConfig, persistentConfig *conf.PersistentConfig, l1Client arbutil.L1Interface, rollupAddrs chaininfo.RollupAddresses, tracer core.BlockchainLogger) (ethdb.Database, *core.BlockChain, error) { if !config.Init.Force { if readOnlyDb, err := stack.OpenDatabaseWithFreezerWithExtraOptions("l2chaindata", 0, 0, "", "l2chaindata/", true, persistentConfig.Pebble.ExtraOptions("l2chaindata")); err == nil { @@ -389,6 +399,36 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo } } + // Check if database was misplaced in parent dir + const errorFmt = "database was not found in %s, but it was found in %s (have you placed the database in the wrong directory?)" + parentDir := filepath.Dir(stack.InstanceDir()) + if dirExists(path.Join(parentDir, "l2chaindata")) { + return nil, nil, fmt.Errorf(errorFmt, stack.InstanceDir(), parentDir) + } + grandParentDir := filepath.Dir(parentDir) + if dirExists(path.Join(grandParentDir, "l2chaindata")) { + return nil, nil, fmt.Errorf(errorFmt, stack.InstanceDir(), grandParentDir) + } + + // Check if database directory is empty + entries, err := os.ReadDir(stack.InstanceDir()) + if err != nil { + return nil, nil, fmt.Errorf("failed to open database dir %s: %w", stack.InstanceDir(), err) + } + unexpectedFiles := []string{} + for _, entry := range entries { + if entry.Name() != "LOCK" { + unexpectedFiles = append(unexpectedFiles, entry.Name()) + } + } + if len(unexpectedFiles) > 0 { + if config.Init.Force { + return nil, nil, fmt.Errorf("trying to overwrite old database directory '%s' (delete the database directory and try again)", stack.InstanceDir()) + } + firstThreeFilenames := strings.Join(unexpectedFiles[:min(len(unexpectedFiles), 3)], ", ") + return nil, nil, fmt.Errorf("found %d unexpected files in database directory, including: %s", len(unexpectedFiles), firstThreeFilenames) + } + if err := setLatestSnapshotUrl(ctx, &config.Init, config.Chain.Name); err != nil { return nil, nil, err } diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index c0d0c75512..c4d9af0ebd 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -492,6 +492,7 @@ func mainImpl() int { deferFuncs = append(deferFuncs, func() { closeDb(arbDb, "arbDb") }) if err != nil { log.Error("failed to open database", "err", err) + log.Error("database is corrupt; delete it and try again", "database-directory", stack.InstanceDir()) return 1 } diff --git a/go-ethereum b/go-ethereum index 6b0438179f..db856b8e86 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 6b0438179f772ba7e0d2dd89b4a708449827c586 +Subproject commit db856b8e8657fd45866e89483360e187c6d7e54b