From 3e12fd6faaabf76c5e6c6aec01f396742d6f4a55 Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Wed, 10 Jul 2024 18:26:42 -0300 Subject: [PATCH] init: fix loading db with custom ancient path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In a previous commit, we added a check to verify whether the database directory was empty before initializing it. This check highlighted a bug where an existing database wasn’t being loaded properly when the persistent.ancient flag was set. Before the empty check, the code worked because the database was reinitialized instead of just being loaded. --- cmd/nitro/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/nitro/init.go b/cmd/nitro/init.go index 97678a7d23..ea48ec8784 100644 --- a/cmd/nitro/init.go +++ b/cmd/nitro/init.go @@ -408,7 +408,7 @@ func isLeveldbNotExistError(err error) bool { 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) (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 { + if readOnlyDb, err := stack.OpenDatabaseWithFreezerWithExtraOptions("l2chaindata", 0, 0, config.Persistent.Ancient, "l2chaindata/", true, persistentConfig.Pebble.ExtraOptions("l2chaindata")); err == nil { if chainConfig := gethexec.TryReadStoredChainConfig(readOnlyDb); chainConfig != nil { readOnlyDb.Close() if !arbmath.BigEquals(chainConfig.ChainID, chainId) {