Skip to content

Commit

Permalink
recordingKV uses separate wasmDB
Browse files Browse the repository at this point in the history
  • Loading branch information
tsahee committed May 10, 2024
1 parent e9b2c95 commit f891743
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions arbitrum/recordingdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ var (
type RecordingKV struct {
inner *trie.Database
diskDb ethdb.KeyValueStore
wasmDb ethdb.KeyValueStore
readDbEntries map[common.Hash][]byte
enableBypass bool
}

func newRecordingKV(inner *trie.Database, diskDb ethdb.KeyValueStore, wasmDb ethdb.KeyValueStore) *RecordingKV {
return &RecordingKV{inner, diskDb, wasmDb, make(map[common.Hash][]byte), false}
func newRecordingKV(inner *trie.Database, diskDb ethdb.KeyValueStore) *RecordingKV {
return &RecordingKV{inner, diskDb, make(map[common.Hash][]byte), false}
}

func (db *RecordingKV) Has(key []byte) (bool, error) {
Expand All @@ -56,12 +55,6 @@ func (db *RecordingKV) Get(key []byte) ([]byte, error) {
// Retrieving code
copy(hash[:], key[len(rawdb.CodePrefix):])
res, err = db.diskDb.Get(key)
} else if ok, _ := rawdb.IsActivatedAsmKey(key); ok {
// Arbitrum: the asm is non-consensus
return db.wasmDb.Get(key)
} else if ok, _ := rawdb.IsActivatedModuleKey(key); ok {
// Arbitrum: the module is non-consensus (only its hash is)
return db.wasmDb.Get(key)
} else {
err = fmt.Errorf("recording KV attempted to access non-hash key %v", hex.EncodeToString(key))
}
Expand Down Expand Up @@ -274,9 +267,9 @@ func (r *RecordingDatabase) PrepareRecording(ctx context.Context, lastBlockHeade
}
finalDereference := lastBlockHeader // dereference in case of error
defer func() { r.Dereference(finalDereference) }()
recordingKeyValue := newRecordingKV(r.db.TrieDB(), r.db.DiskDB(), r.db.WasmStore())
recordingKeyValue := newRecordingKV(r.db.TrieDB(), r.db.DiskDB())

recordingStateDatabase := state.NewDatabase(rawdb.NewDatabase(recordingKeyValue))
recordingStateDatabase := state.NewDatabase(rawdb.WrapDatabaseWithWasm(rawdb.NewDatabase(recordingKeyValue), r.db.WasmStore()))
var prevRoot common.Hash
if lastBlockHeader != nil {
prevRoot = lastBlockHeader.Root
Expand Down

0 comments on commit f891743

Please sign in to comment.