Skip to content

Commit

Permalink
Merge pull request #2229 from OffchainLabs/nit-2413-fix-database-metr…
Browse files Browse the repository at this point in the history
…ics-namespaces

use metrics namespaces when opening databases
  • Loading branch information
magicxyyz authored Apr 18, 2024
2 parents 368a320 + 67c77ac commit f8d40ac
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions cmd/nitro/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ func validateBlockChain(blockChain *core.BlockChain, chainConfig *params.ChainCo

func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeConfig, chainId *big.Int, cacheConfig *core.CacheConfig, l1Client arbutil.L1Interface, rollupAddrs chaininfo.RollupAddresses) (ethdb.Database, *core.BlockChain, error) {
if !config.Init.Force {
if readOnlyDb, err := stack.OpenDatabaseWithFreezer("l2chaindata", 0, 0, "", "", true); err == nil {
if readOnlyDb, err := stack.OpenDatabaseWithFreezer("l2chaindata", 0, 0, "", "l2chaindata/", true); err == nil {
if chainConfig := gethexec.TryReadStoredChainConfig(readOnlyDb); chainConfig != nil {
readOnlyDb.Close()
if !arbmath.BigEquals(chainConfig.ChainID, chainId) {
return nil, nil, fmt.Errorf("database has chain ID %v but config has chain ID %v (are you sure this database is for the right chain?)", chainConfig.ChainID, chainId)
}
chainDb, err := stack.OpenDatabaseWithFreezer("l2chaindata", config.Execution.Caching.DatabaseCache, config.Persistent.Handles, config.Persistent.Ancient, "", false)
chainDb, err := stack.OpenDatabaseWithFreezer("l2chaindata", config.Execution.Caching.DatabaseCache, config.Persistent.Handles, config.Persistent.Ancient, "l2chaindata/", false)
if err != nil {
return chainDb, nil, err
}
Expand Down Expand Up @@ -219,7 +219,7 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo

var initDataReader statetransfer.InitDataReader = nil

chainDb, err := stack.OpenDatabaseWithFreezer("l2chaindata", config.Execution.Caching.DatabaseCache, config.Persistent.Handles, config.Persistent.Ancient, "", false)
chainDb, err := stack.OpenDatabaseWithFreezer("l2chaindata", config.Execution.Caching.DatabaseCache, config.Persistent.Handles, config.Persistent.Ancient, "l2chaindata/", false)
if err != nil {
return chainDb, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func mainImpl() int {
return 1
}

arbDb, err := stack.OpenDatabase("arbitrumdata", 0, 0, "", false)
arbDb, err := stack.OpenDatabase("arbitrumdata", 0, 0, "arbitrumdata/", false)
deferFuncs = append(deferFuncs, func() { closeDb(arbDb, "arbDb") })
if err != nil {
log.Error("failed to open database", "err", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/pruning/pruning.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func findImportantRoots(ctx context.Context, chainDb ethdb.Database, stack *node
if chainConfig == nil {
return nil, errors.New("database doesn't have a chain config (was this node initialized?)")
}
arbDb, err := stack.OpenDatabase("arbitrumdata", 0, 0, "", true)
arbDb, err := stack.OpenDatabase("arbitrumdata", 0, 0, "arbitrumdata/", true)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion execution/gethexec/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func CreateExecutionNode(
var classicOutbox *ClassicOutboxRetriever

if l2BlockChain.Config().ArbitrumChainParams.GenesisBlockNum > 0 {
classicMsgDb, err := stack.OpenDatabase("classic-msg", 0, 0, "", true)
classicMsgDb, err := stack.OpenDatabase("classic-msg", 0, 0, "classicmsg/", true)
if err != nil {
log.Warn("Classic Msg Database not found", "err", err)
classicOutbox = nil
Expand Down
8 changes: 4 additions & 4 deletions system_tests/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,9 @@ func createL2BlockChainWithStackConfig(
stack, err = node.New(stackConfig)
Require(t, err)

chainDb, err := stack.OpenDatabase("chaindb", 0, 0, "", false)
chainDb, err := stack.OpenDatabase("l2chaindata", 0, 0, "l2chaindata/", false)
Require(t, err)
arbDb, err := stack.OpenDatabase("arbitrumdata", 0, 0, "", false)
arbDb, err := stack.OpenDatabase("arbitrumdata", 0, 0, "arbitrumdata/", false)
Require(t, err)

initReader := statetransfer.NewMemoryInitDataReader(&l2info.ArbInitData)
Expand Down Expand Up @@ -922,9 +922,9 @@ func Create2ndNodeWithConfig(
l2stack, err := node.New(stackConfig)
Require(t, err)

l2chainDb, err := l2stack.OpenDatabase("chaindb", 0, 0, "", false)
l2chainDb, err := l2stack.OpenDatabase("l2chaindata", 0, 0, "l2chaindata/", false)
Require(t, err)
l2arbDb, err := l2stack.OpenDatabase("arbitrumdata", 0, 0, "", false)
l2arbDb, err := l2stack.OpenDatabase("arbitrumdata", 0, 0, "arbitrumdata/", false)
Require(t, err)
initReader := statetransfer.NewMemoryInitDataReader(l2InitData)

Expand Down
4 changes: 2 additions & 2 deletions system_tests/das_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ func TestDASRekey(t *testing.T) {
l2stackA, err := node.New(stackConfig)
Require(t, err)

l2chainDb, err := l2stackA.OpenDatabase("chaindb", 0, 0, "", false)
l2chainDb, err := l2stackA.OpenDatabase("l2chaindata", 0, 0, "l2chaindata/", false)
Require(t, err)

l2arbDb, err := l2stackA.OpenDatabase("arbitrumdata", 0, 0, "", false)
l2arbDb, err := l2stackA.OpenDatabase("arbitrumdata", 0, 0, "arbitrumdata/", false)
Require(t, err)

l2blockchain, err := gethexec.GetBlockChain(l2chainDb, nil, chainConfig, gethexec.ConfigDefaultTest().TxLookupLimit)
Expand Down
2 changes: 1 addition & 1 deletion system_tests/pruning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestPruning(t *testing.T) {
stack, err := node.New(builder.l2StackConfig)
Require(t, err)
defer stack.Close()
chainDb, err := stack.OpenDatabase("chaindb", 0, 0, "", false)
chainDb, err := stack.OpenDatabase("l2chaindata", 0, 0, "l2chaindata/", false)
Require(t, err)
defer chainDb.Close()
chainDbEntriesBeforePruning := countStateEntries(chainDb)
Expand Down
2 changes: 1 addition & 1 deletion system_tests/staterecovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestRectreateMissingStates(t *testing.T) {
stack, err := node.New(builder.l2StackConfig)
Require(t, err)
defer stack.Close()
chainDb, err := stack.OpenDatabase("chaindb", 0, 0, "", false)
chainDb, err := stack.OpenDatabase("l2chaindata", 0, 0, "l2chaindata/", false)
Require(t, err)
defer chainDb.Close()
cacheConfig := gethexec.DefaultCacheConfigFor(stack, &gethexec.DefaultCachingConfig)
Expand Down

0 comments on commit f8d40ac

Please sign in to comment.