Skip to content

Commit

Permalink
fix typos and make logs consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshvanahalli committed May 23, 2024
1 parent 89dfbea commit 67cfcc6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
20 changes: 10 additions & 10 deletions cmd/nitro/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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 != "" {
Expand Down
8 changes: 4 additions & 4 deletions execution/gethexec/wasmstorerebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
}
}
Expand All @@ -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
Expand All @@ -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")
Expand Down

0 comments on commit 67cfcc6

Please sign in to comment.