From 67cfcc6b62cf49d3902581eb937e5a395d48979d Mon Sep 17 00:00:00 2001 From: Ganesh Vanahalli Date: Thu, 23 May 2024 14:40:12 -0700 Subject: [PATCH] fix typos and make logs consistent --- cmd/nitro/init.go | 20 ++++++++++---------- execution/gethexec/wasmstorerebuilder.go | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cmd/nitro/init.go b/cmd/nitro/init.go index 1f00e14b46..ea908394e2 100644 --- a/cmd/nitro/init.go +++ b/cmd/nitro/init.go @@ -207,25 +207,25 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo } latestBlock := l2BlockChain.CurrentBlock() if latestBlock.Number.Uint64() <= chainConfig.ArbitrumChainParams.GenesisBlockNum { - // If there is only genesis block or no blocks in the blockchain, set Rebuilding of wasmdb to Done - log.Info("setting rebuilding of wasmdb to done") + // If there is only genesis block or no blocks in the blockchain, set Rebuilding of wasm store to Done + log.Info("setting rebuilding of wasm store to done") if err = gethexec.WriteToKeyValueStore(wasmDb, gethexec.RebuildingPositionKey, gethexec.RebuildingDone); err != nil { - return nil, nil, fmt.Errorf("unable to set rebuilding status of wasmdb to done: %w", err) + return nil, nil, fmt.Errorf("unable to set rebuilding status of wasm store to done: %w", err) } } else { position, err := gethexec.ReadFromKeyValueStore[common.Hash](wasmDb, gethexec.RebuildingPositionKey) if err != nil { - log.Info("unable to get codehash position in rebuilding of wasmdb, its possible it isnt initialized yet, so initializing it and starting rebuilding", "err", err) + log.Info("unable to get codehash position in rebuilding of wasm store, its possible it isnt initialized yet, so initializing it and starting rebuilding", "err", err) if err := gethexec.WriteToKeyValueStore(wasmDb, gethexec.RebuildingPositionKey, common.Hash{}); err != nil { - return nil, nil, fmt.Errorf("unable to set rebuilding status of wasmdb to beginning: %w", err) + return nil, nil, fmt.Errorf("unable to initialize codehash position in rebuilding of wasm store to beginning: %w", err) } } if position != gethexec.RebuildingDone { startBlockHash, err := gethexec.ReadFromKeyValueStore[common.Hash](wasmDb, gethexec.RebuildingStartBlockHashKey) if err != nil { - log.Info("unable to get rebuilding start time of wasmdb so initializing it to current block time", "err", err) + log.Info("unable to get start block hash in rebuilding of wasm store, its possible it isnt initialized yet, so initializing it to latest block hash", "err", err) if err := gethexec.WriteToKeyValueStore(wasmDb, gethexec.RebuildingStartBlockHashKey, latestBlock.Hash()); err != nil { - return nil, nil, fmt.Errorf("unable to set rebuilding status of wasmdb to beginning: %w", err) + return nil, nil, fmt.Errorf("unable to initialize start block hash in rebuilding of wasm store to latest block hash: %w", err) } startBlockHash = latestBlock.Hash() } @@ -272,11 +272,11 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo } chainDb := rawdb.WrapDatabaseWithWasm(chainData, wasmDb, 1) - // Rebuilding wasmdb is not required when just starting out + // Rebuilding wasm store is not required when just starting out err = gethexec.WriteToKeyValueStore(wasmDb, gethexec.RebuildingPositionKey, gethexec.RebuildingDone) - log.Info("setting rebuilding of wasmdb to done") + log.Info("setting codehash position in rebuilding of wasm store to done") if err != nil { - return nil, nil, fmt.Errorf("unable to set rebuilding of wasmdb to done: %w", err) + return nil, nil, fmt.Errorf("unable to set codehash position in rebuilding of wasm store to done: %w", err) } if config.Init.ImportFile != "" { diff --git a/execution/gethexec/wasmstorerebuilder.go b/execution/gethexec/wasmstorerebuilder.go index eca901ffd6..b4affa8bbc 100644 --- a/execution/gethexec/wasmstorerebuilder.go +++ b/execution/gethexec/wasmstorerebuilder.go @@ -18,7 +18,7 @@ import ( "github.com/offchainlabs/nitro/arbos/arbosState" ) -var RebuildingPositionKey []byte = []byte("_rebuildingPosition") // contains the codehash upto where rebuilding of wasm store was last completed +var RebuildingPositionKey []byte = []byte("_rebuildingPosition") // contains the codehash upto which rebuilding of wasm store was last completed. Initialized to common.Hash{} at the start var RebuildingStartBlockHashKey []byte = []byte("_rebuildingStartBlockHash") // contains the block hash of starting block when rebuilding of wasm store first began var RebuildingDone common.Hash = common.BytesToHash([]byte("_done")) // indicates that the rebuilding is done, if RebuildingPositionKey holds this value it implies rebuilding was completed @@ -86,7 +86,7 @@ func RebuildWasmStore(ctx context.Context, wasmStore ethdb.KeyValueStore, l2Bloc code := iter.Value() if state.IsStylusProgram(code) { if err := programs.SaveActiveProgramToWasmStore(stateDb, codeHash, code, latestHeader.Time, l2Blockchain.Config().DebugMode(), rebuildingStartHeader.Time); err != nil { - log.Error("error while rebuilding wasm store, aborting rebuilding", "err", err) + log.Error("error while rebuilding of wasm store, aborting rebuilding", "err", err) return } } @@ -95,7 +95,7 @@ func RebuildWasmStore(ctx context.Context, wasmStore ethdb.KeyValueStore, l2Bloc if count%50 == 0 || ctx.Err() != nil { log.Info("Storing rebuilding status to disk", "codeHash", codeHash) if err := WriteToKeyValueStore(wasmStore, RebuildingPositionKey, codeHash); err != nil { - log.Error("error updating position to wasm store mid way though rebuilding, aborting", "err", err) + log.Error("error updating codehash position in rebuilding of wasm store", "err", err) return } // If outer context is cancelled we should terminate rebuilding @@ -108,7 +108,7 @@ func RebuildWasmStore(ctx context.Context, wasmStore ethdb.KeyValueStore, l2Bloc iter.Release() // Set rebuilding position to done indicating completion if err := WriteToKeyValueStore(wasmStore, RebuildingPositionKey, RebuildingDone); err != nil { - log.Error("error updating rebuilding position to done", "err", err) + log.Error("error updating codehash position in rebuilding of wasm store to done", "err", err) return } log.Info("Rebuilding of wasm store was successful")