Skip to content

Commit

Permalink
Merge tag 'v3.0.2' into release/v3.x-fh
Browse files Browse the repository at this point in the history
Arbitrum Nitro v3.0.2
  • Loading branch information
sduchesneau committed Jun 18, 2024
2 parents 549ae25 + 9efbc16 commit ee40e81
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 40 additions & 0 deletions cmd/nitro/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"net/http"
"net/url"
"os"
"path"
"path/filepath"
"runtime"
"strings"
"sync"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion go-ethereum

0 comments on commit ee40e81

Please sign in to comment.