Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
7c5e216
Created a cache for flatKV.
Mar 5, 2026
4a404ee
checkpoint
Mar 5, 2026
d36e825
incremental progress
Mar 5, 2026
2ccbe62
address feedback
Mar 5, 2026
f412e85
more fixes
Mar 5, 2026
e310037
bugfix
Mar 5, 2026
cf1071c
wire in cache
Mar 5, 2026
11232ff
Merge branch 'main' into cjl/flatkv-cache
Mar 6, 2026
a8c1c75
incremental improvements
Mar 6, 2026
221d114
checkin
Mar 6, 2026
8eca079
Moved where the cache sits
Mar 6, 2026
267feae
bugfix
Mar 6, 2026
50b0be6
Batch update the cache
Mar 6, 2026
2ca00d6
Add batch read to cache
Mar 6, 2026
8f8534a
Add batch get to db interface
Mar 6, 2026
23c0277
integrate batch reads
Mar 6, 2026
02d3ca1
wire in cache
Mar 6, 2026
7ee1b08
Introduce work pool, size caches differently
Mar 6, 2026
20c70c3
bugfix
Mar 6, 2026
b714789
Add unit constants
Mar 9, 2026
cc9d41d
refactor threading utils
Mar 9, 2026
53b2bd8
cleanup
Mar 9, 2026
c10e0cd
Cleanup, fix race condition
Mar 9, 2026
04f40fa
cleanup
Mar 9, 2026
b4e4d2c
cleanup
Mar 9, 2026
e53fefa
use pool
Mar 9, 2026
438fc8d
fix ctx lifecycle
Mar 9, 2026
19a8a19
Merge branch 'main' into cjl/flatkv-cache
Mar 9, 2026
23440f6
rename package
Mar 9, 2026
4ecc8fd
Clean up string copies
Mar 9, 2026
7a315c6
simplify gc
Mar 9, 2026
a3f3907
better error handling
Mar 9, 2026
f255b87
use config to configure cache params
Mar 9, 2026
cf0a73d
Allow flatkv config to be set in tests
Mar 9, 2026
0b34737
tweak config
Mar 10, 2026
452aa4d
incremental progress
Mar 10, 2026
1c804a8
move data dir into config
Mar 10, 2026
663b2ea
fix config file
Mar 10, 2026
bb530b5
cleanup
Mar 10, 2026
04daf75
move pebble metrics to proper location
Mar 10, 2026
354818e
clean up metrics
Mar 10, 2026
b1574ac
updated dashboard
Mar 10, 2026
07e071c
fix histograms
Mar 10, 2026
d090796
threading tests
Mar 10, 2026
dfd92c1
test lru queue
Mar 10, 2026
f751a9b
unit tests for shard
Mar 10, 2026
7b5538e
cache tests
Mar 10, 2026
dc8d0c9
moar unit tests
Mar 10, 2026
e9cc9ca
cleanup
Mar 10, 2026
c7a418c
Merge branch 'main' into cjl/flatkv-cache
Mar 10, 2026
087fd0f
Merge branch 'main' into cjl/flatkv-cache
Mar 10, 2026
eb9bc51
Merge branch 'main' into cjl/flatkv-cache
Mar 11, 2026
cea0ebb
unit test fixes
Mar 11, 2026
e58bec2
fix hash bug
Mar 11, 2026
c3f34b1
fixed path bug
Mar 11, 2026
111459f
Helper files for flatKV cache
Mar 11, 2026
d40395f
add missing struct
Mar 11, 2026
c8e85d2
Merge branch 'main' into cjl/cache-auxilery
Mar 12, 2026
ed7e4b6
made suggested changes
Mar 12, 2026
5c46647
fix tests
Mar 12, 2026
be0d4f5
Merge branch 'main' into cjl/flatkv-cache
Mar 12, 2026
9ff2199
Merge branch 'cjl/cache-auxilery' into cjl/flatkv-cache
Mar 12, 2026
bb2fe7e
Maded suggested change to cache structure
Mar 13, 2026
f4b8326
rename cache -> dbcache to avoid gitignore
Mar 13, 2026
4b2247b
Helper files for the flatKV cache implementation
Mar 13, 2026
36d7328
bugfix
Mar 13, 2026
d759a9b
Merge branch 'cjl/cache-auxilery-2' into cjl/flatkv-cache
Mar 16, 2026
4ba242b
fix merge problems
Mar 16, 2026
e19a998
refactor API
Mar 16, 2026
94ae673
made suggested changes
Mar 16, 2026
ed10a26
made suggested changes
Mar 16, 2026
81dfd46
fix bug
Mar 16, 2026
480839d
Merge branch 'main' into cjl/flatkv-cache
Mar 16, 2026
7835683
Implement a standard cache.
Mar 16, 2026
950197c
cleanup
Mar 16, 2026
cff96ab
Merge branch 'main' into cjl/cache-impl
Mar 17, 2026
003fcc9
made suggested changes
Mar 17, 2026
a208a1b
made suggested change
Mar 17, 2026
157a600
made suggested changes
Mar 17, 2026
b41639f
fix unit test
Mar 17, 2026
fe31475
fix unit test
Mar 17, 2026
0702197
Merge branch 'cjl/cache-impl' into cjl/flatkv-cache
Mar 17, 2026
6d435f5
Merge branch 'main' into cjl/flatkv-cache
Mar 20, 2026
64f8530
fixed merge bugs
Mar 20, 2026
d9c5fc1
fix teardown race
Mar 20, 2026
14593ec
Add logging metric, clean up log files before/after run
Mar 20, 2026
2d88076
fix unit test
Mar 20, 2026
ccad074
fix unit tests
Mar 20, 2026
38ffd35
fix unit test
Mar 20, 2026
f143d30
made suggested changes
Mar 25, 2026
a18fd93
config changes
Mar 25, 2026
34e711d
made suggested changes
Mar 25, 2026
b596f89
Merge branch 'main' into cjl/flatkv-cache
Mar 25, 2026
61d1f4d
rearranged files
Mar 26, 2026
fa351b3
basic data structures
Mar 27, 2026
33378ce
bugfix
Mar 27, 2026
f8d0113
Basic impl and unit tests
Mar 27, 2026
d9c27bc
config
Mar 27, 2026
55c871f
block generator
Mar 27, 2026
d59bfab
created struct for account data
Mar 30, 2026
94ebc9a
added structs
Mar 30, 2026
9a52335
Merge branch 'cjl/flatkv-cache' into cjl/9-byte-metadata
Mar 30, 2026
9dab6ca
incremental progress
Mar 30, 2026
3443a06
cleanup
Mar 30, 2026
a402238
don't ignore errors from batch get
Mar 30, 2026
b18bc4e
Merge branch 'main' into cjl/flatkv-cache
Mar 30, 2026
1a04e5e
Merge branch 'cjl/flatkv-cache' into cjl/9-byte-metadata
Mar 30, 2026
e8bf28a
incremental progress
Mar 30, 2026
73b6d36
cleanup
Mar 30, 2026
fbb3041
cleanup
Mar 30, 2026
cd59319
incremental progress
Mar 30, 2026
8ce84b1
convert code data to new format
Mar 30, 2026
ee30ca9
made suggested changes
Mar 31, 2026
c8fd5ec
Merge branch 'main' into cjl/flatkv-cache
Mar 31, 2026
8094375
Merge branch 'main' into cjl/flatkv-cache
Mar 31, 2026
c2c0552
Merge branch 'cjl/flatkv-cache' into cjl/9-byte-metadata
Mar 31, 2026
51560a3
incremental progress
Mar 31, 2026
faf4871
make suggested change to pool
Apr 1, 2026
2760580
Merge branch 'cjl/flatkv-cache' into cjl/9-byte-metadata
Apr 1, 2026
10172fd
started big refactor
Apr 1, 2026
aa3ef36
incremental progress
Apr 1, 2026
cdc1a7d
incremental progress
Apr 1, 2026
95b392c
fix parsing
Apr 1, 2026
0dfb271
fix store read
Apr 1, 2026
9c8454f
Merge branch 'main' into cjl/flatkv-cache
Apr 1, 2026
872b0a6
fix merge problem
Apr 1, 2026
80487c3
Merge branch 'cjl/flatkv-cache' into cjl/9-byte-metadata
Apr 1, 2026
1aef1c3
bugfixes
Apr 1, 2026
ea8b01e
fix compile issues
Apr 1, 2026
1eccb80
Merge branch 'main' into cjl/9-byte-metadata
Apr 1, 2026
caadeef
lint
Apr 1, 2026
aab88b1
test cleanup
Apr 1, 2026
4618c0a
clean up interface
Apr 1, 2026
2873025
check for bad keys
Apr 1, 2026
a1a46d7
better handling of variable sized data
Apr 1, 2026
8bb29c7
Improve codehash serialization
Apr 1, 2026
2050921
cleanup
Apr 1, 2026
8be4dfa
Merge branch 'main' into cjl/9-byte-metadata
Apr 8, 2026
d9a981d
fix things that broke with merge
Apr 8, 2026
309fb33
revert unecessary changes
Apr 8, 2026
b9e1d2f
fix unit tests
Apr 8, 2026
2b0fdd7
fix unit test
Apr 8, 2026
e80ff1e
Merge branch 'main' into cjl/9-byte-metadata
Kbhat1 Apr 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions sei-db/state_db/bench/wrappers/flatkv_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ func (f *flatKVWrapper) Close() error {
}

func (f *flatKVWrapper) Read(key []byte) (data []byte, found bool, err error) {
data, found = f.base.Get(key)
return data, found, nil
return f.base.Get(key)
}

func (f *flatKVWrapper) GetPhaseTimer() *metrics.PhaseTimer {
Expand Down
62 changes: 37 additions & 25 deletions sei-db/state_db/sc/composite/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,28 @@ func (f *failingEVMStore) LoadVersion(int64, bool) (flatkv.Store, error) {
}
func (f *failingEVMStore) ApplyChangeSets([]*proto.NamedChangeSet) error { return nil }
func (f *failingEVMStore) Commit() (int64, error) { return 0, nil }
func (f *failingEVMStore) Get([]byte) ([]byte, bool) { return nil, false }
func (f *failingEVMStore) Has([]byte) bool { return false }
func (f *failingEVMStore) Iterator(_, _ []byte) flatkv.Iterator { return nil }
func (f *failingEVMStore) IteratorByPrefix([]byte) flatkv.Iterator { return nil }
func (f *failingEVMStore) RootHash() []byte { return nil }
func (f *failingEVMStore) Version() int64 { return 0 }
func (f *failingEVMStore) WriteSnapshot(string) error { return nil }
func (f *failingEVMStore) Rollback(int64) error { return nil }
func (f *failingEVMStore) Exporter(int64) (types.Exporter, error) { return nil, nil }
func (f *failingEVMStore) Importer(int64) (types.Importer, error) { return nil, nil }
func (f *failingEVMStore) GetPhaseTimer() *metrics.PhaseTimer { return nil }
func (f *failingEVMStore) CommittedRootHash() []byte { return nil }
func (f *failingEVMStore) Close() error { return nil }
func (f *failingEVMStore) Get([]byte) ([]byte, bool, error) { return nil, false, nil }
func (f *failingEVMStore) GetBlockHeightModified([]byte) (int64, bool, error) {
return -1, false, nil
}
func (f *failingEVMStore) Has([]byte) (bool, error) { return false, nil }
func (f *failingEVMStore) Iterator(_, _ []byte) flatkv.Iterator { return nil }
func (f *failingEVMStore) IteratorByPrefix([]byte) flatkv.Iterator { return nil }
func (f *failingEVMStore) RootHash() []byte { return nil }
func (f *failingEVMStore) Version() int64 { return 0 }
func (f *failingEVMStore) WriteSnapshot(string) error { return nil }
func (f *failingEVMStore) Rollback(int64) error { return nil }
func (f *failingEVMStore) Exporter(int64) (types.Exporter, error) { return nil, nil }
func (f *failingEVMStore) Importer(int64) (types.Importer, error) { return nil, nil }
func (f *failingEVMStore) GetPhaseTimer() *metrics.PhaseTimer { return nil }
func (f *failingEVMStore) CommittedRootHash() []byte { return nil }
func (f *failingEVMStore) Close() error { return nil }

func padLeft32(val ...byte) []byte {
var b [32]byte
copy(b[32-len(val):], val)
return b[:]
}

func TestCompositeStoreBasicOperations(t *testing.T) {
dir := t.TempDir()
Expand Down Expand Up @@ -201,7 +210,7 @@ func TestLatticeHashCommitInfo(t *testing.T) {
Name: EVMStoreName,
Changeset: proto.ChangeSet{
Pairs: []*proto.KVPair{
{Key: evmStorageKey, Value: []byte{round}},
{Key: evmStorageKey, Value: padLeft32(round)},
},
},
},
Expand Down Expand Up @@ -509,7 +518,7 @@ func TestExportImportSplitWrite(t *testing.T) {
slot := flatkv.Slot{0xBB}
storageKey := evm.BuildMemIAVLEVMKey(evm.EVMKeyStorage,
flatkv.StorageKey(addr, slot))
storageVal := []byte{0x42}
storageVal := padLeft32(0x42)

nonceKey := evm.BuildMemIAVLEVMKey(evm.EVMKeyNonce, addr[:])
nonceVal := []byte{0, 0, 0, 0, 0, 0, 0, 10}
Expand Down Expand Up @@ -571,11 +580,13 @@ func TestExportImportSplitWrite(t *testing.T) {

// Verify FlatKV data
require.NotNil(t, dst.evmCommitter)
got, found := dst.evmCommitter.Get(storageKey)
got, found, err := dst.evmCommitter.Get(storageKey)
require.NoError(t, err)
require.True(t, found, "storage key should exist in FlatKV after import")
require.Equal(t, storageVal, got)

got, found = dst.evmCommitter.Get(nonceKey)
got, found, err = dst.evmCommitter.Get(nonceKey)
require.NoError(t, err)
require.True(t, found, "nonce key should exist in FlatKV after import")
require.Equal(t, nonceVal, got)
}
Expand Down Expand Up @@ -699,7 +710,7 @@ func TestReconcileVersionsAfterCrash(t *testing.T) {
Name: EVMStoreName,
Changeset: proto.ChangeSet{
Pairs: []*proto.KVPair{
{Key: storageKey, Value: []byte{i}},
{Key: storageKey, Value: padLeft32(i)},
},
},
},
Expand Down Expand Up @@ -766,7 +777,7 @@ func TestReconcileVersionsThenContinueCommitting(t *testing.T) {
{Key: []byte("bal"), Value: []byte{i}},
}}},
{Name: EVMStoreName, Changeset: proto.ChangeSet{Pairs: []*proto.KVPair{
{Key: storageKey, Value: []byte{i}},
{Key: storageKey, Value: padLeft32(i)},
}}},
}))
_, err = cs.Commit()
Expand Down Expand Up @@ -796,13 +807,13 @@ func TestReconcileVersionsThenContinueCommitting(t *testing.T) {
// Continue committing new blocks on top of the reconciled state.
// Version 3 is re-created with new data (0xA3 instead of 0x03).
for i := byte(0); i < 3; i++ {
v := []byte{0xA0 + i + 3}
v := 0xA0 + i + 3
require.NoError(t, cs2.ApplyChangeSets([]*proto.NamedChangeSet{
{Name: "bank", Changeset: proto.ChangeSet{Pairs: []*proto.KVPair{
{Key: []byte("bal"), Value: v},
{Key: []byte("bal"), Value: []byte{v}},
}}},
{Name: EVMStoreName, Changeset: proto.ChangeSet{Pairs: []*proto.KVPair{
{Key: storageKey, Value: v},
{Key: storageKey, Value: padLeft32(v)},
}}},
}))
ver, err := cs2.Commit()
Expand All @@ -827,9 +838,10 @@ func TestReconcileVersionsThenContinueCommitting(t *testing.T) {
bankStore := cs3.GetChildStoreByName("bank")
require.Equal(t, []byte{0xA5}, bankStore.Get([]byte("bal")))

got, found := cs3.evmCommitter.Get(storageKey)
got, found, err := cs3.evmCommitter.Get(storageKey)
require.NoError(t, err)
require.True(t, found)
require.Equal(t, []byte{0xA5}, got)
require.Equal(t, padLeft32(0xA5), got)
}

func TestReconcileVersionsCosmosAheadByMultiple(t *testing.T) {
Expand Down Expand Up @@ -860,7 +872,7 @@ func TestReconcileVersionsCosmosAheadByMultiple(t *testing.T) {
Name: EVMStoreName,
Changeset: proto.ChangeSet{
Pairs: []*proto.KVPair{
{Key: storageKey, Value: []byte{i}},
{Key: storageKey, Value: padLeft32(i)},
},
},
},
Expand Down
10 changes: 7 additions & 3 deletions sei-db/state_db/sc/flatkv/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ type Store interface {
// Commit persists buffered writes and advances the version.
Commit() (int64, error)

// Get returns the value for the x/evm memiavl key, or (nil, false) if not found.
Get(key []byte) ([]byte, bool)
// Get returns the value for the x/evm memiavl key. If not found, returns (nil, false, nil).
Get(key []byte) (value []byte, found bool, err error)
Copy link
Copy Markdown
Contributor

@yzang2019 yzang2019 Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not big fan of having to return an extra error for each get/has call in this layer, I think if we can avoid, we should not return any error. If there's a database internal error, we can choose to panic out.


// GetBlockHeightModified returns the block height at which the key was last modified.
// If not found, returns (-1, false, nil).
GetBlockHeightModified(key []byte) (int64, bool, error)

// Has reports whether the x/evm memiavl key exists.
Has(key []byte) bool
Has(key []byte) (bool, error)

// Iterator returns an iterator over [start, end) in memiavl key order.
// Pass nil for unbounded.
Expand Down
5 changes: 5 additions & 0 deletions sei-db/state_db/sc/flatkv/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ type Config struct {
// Controls the number of goroutines pre-allocated in the thread pool for miscellaneous operations.
// The number of threads in this pool is equal to MiscThreadsPerCore * runtime.NumCPU() + MiscConstantThreadCount.
MiscConstantThreadCount int

// If true, FlatKV will return an error if it encounters an unsupported key type. Otherwise,
// it will log a warning and continue.
StrictKeyTypeCheck bool
}

// DefaultConfig returns Config with safe default values.
Expand All @@ -120,6 +124,7 @@ func DefaultConfig() *Config {
ReaderPoolQueueSize: 1024,
MiscPoolThreadsPerCore: 4.0,
MiscConstantThreadCount: 0,
StrictKeyTypeCheck: true,
}

cfg.AccountCacheConfig.MaxSize = unit.GB
Expand Down
42 changes: 23 additions & 19 deletions sei-db/state_db/sc/flatkv/crash_recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestCrashRecoveryGlobalMetadataAheadOfDataDBs(t *testing.T) {
addr := addrN(0x02)
for i := 1; i <= 5; i++ {
key := evm.BuildMemIAVLEVMKey(evm.EVMKeyStorage, StorageKey(addr, slotN(byte(i))))
cs := makeChangeSet(key, []byte{byte(i * 11)}, false)
cs := makeChangeSet(key, padLeft32(byte(i*11)), false)
require.NoError(t, s.ApplyChangeSets([]*proto.NamedChangeSet{cs}))
_, err := s.Commit()
require.NoError(t, err)
Expand Down Expand Up @@ -122,9 +122,10 @@ func TestCrashRecoveryGlobalMetadataAheadOfDataDBs(t *testing.T) {

for i := 1; i <= 5; i++ {
key := evm.BuildMemIAVLEVMKey(evm.EVMKeyStorage, StorageKey(addr, slotN(byte(i))))
val, found := s2.Get(key)
val, found, err := s2.Get(key)
require.NoError(t, err)
require.True(t, found, "slot %d should exist after recovery", i)
require.Equal(t, []byte{byte(i * 11)}, val)
require.Equal(t, padLeft32(byte(i*11)), val)
}
}

Expand All @@ -142,7 +143,7 @@ func TestCrashRecoveryWALReplayLargeGap(t *testing.T) {
addr := addrN(0x03)
for i := 1; i <= 20; i++ {
key := evm.BuildMemIAVLEVMKey(evm.EVMKeyStorage, StorageKey(addr, slotN(byte(i))))
cs := makeChangeSet(key, []byte{byte(i)}, false)
cs := makeChangeSet(key, padLeft32(byte(i)), false)
require.NoError(t, s.ApplyChangeSets([]*proto.NamedChangeSet{cs}))
_, err := s.Commit()
require.NoError(t, err)
Expand All @@ -164,9 +165,10 @@ func TestCrashRecoveryWALReplayLargeGap(t *testing.T) {
// All 20 storage slots should be readable.
for i := 1; i <= 20; i++ {
key := evm.BuildMemIAVLEVMKey(evm.EVMKeyStorage, StorageKey(addr, slotN(byte(i))))
val, found := s2.Get(key)
val, found, err := s2.Get(key)
require.NoError(t, err)
require.True(t, found, "slot %d should exist", i)
require.Equal(t, []byte{byte(i)}, val)
require.Equal(t, padLeft32(byte(i)), val)
}
}

Expand All @@ -182,7 +184,7 @@ func TestCrashRecoveryEmptyWALAfterSnapshot(t *testing.T) {

addr := addrN(0x04)
key := evm.BuildMemIAVLEVMKey(evm.EVMKeyStorage, StorageKey(addr, slotN(0x01)))
cs := makeChangeSet(key, []byte{0xAA}, false)
cs := makeChangeSet(key, padLeft32(0xAA), false)
require.NoError(t, s.ApplyChangeSets([]*proto.NamedChangeSet{cs}))
_, err = s.Commit()
require.NoError(t, err)
Expand All @@ -205,12 +207,13 @@ func TestCrashRecoveryEmptyWALAfterSnapshot(t *testing.T) {
require.Equal(t, expectedVersion, s2.Version())
require.Equal(t, expectedHash, s2.RootHash())

val, found := s2.Get(key)
val, found, err := s2.Get(key)
require.NoError(t, err)
require.True(t, found)
require.Equal(t, []byte{0xAA}, val)
require.Equal(t, padLeft32(0xAA), val)

// Can continue committing after recovery from snapshot-only state.
cs2 := makeChangeSet(key, []byte{0xBB}, false)
cs2 := makeChangeSet(key, padLeft32(0xBB), false)
require.NoError(t, s2.ApplyChangeSets([]*proto.NamedChangeSet{cs2}))
v, err := s2.Commit()
require.NoError(t, err)
Expand Down Expand Up @@ -248,7 +251,7 @@ func TestCrashRecoveryCorruptedAccountValueInDB(t *testing.T) {
}
err = s.ApplyChangeSets([]*proto.NamedChangeSet{cs2})
require.Error(t, err, "should fail on corrupted AccountValue")
require.Contains(t, err.Error(), "corrupted AccountValue")
require.Contains(t, err.Error(), "unsupported serialization version")
}

func TestCrashRecoveryCrashAfterWALBeforeDBCommit(t *testing.T) {
Expand All @@ -265,14 +268,14 @@ func TestCrashRecoveryCrashAfterWALBeforeDBCommit(t *testing.T) {
addr := addrN(0x06)
slot := slotN(0x01)
key := evm.BuildMemIAVLEVMKey(evm.EVMKeyStorage, StorageKey(addr, slot))
cs := makeChangeSet(key, []byte{0x11}, false)
cs := makeChangeSet(key, padLeft32(0x11), false)
require.NoError(t, s.ApplyChangeSets([]*proto.NamedChangeSet{cs}))
_, err = s.Commit()
require.NoError(t, err)
hashAfterV1 := s.RootHash()

// Now simulate writing v2 to WAL but "crashing" before DB commit.
cs2 := makeChangeSet(key, []byte{0x22}, false)
cs2 := makeChangeSet(key, padLeft32(0x22), false)
require.NoError(t, s.ApplyChangeSets([]*proto.NamedChangeSet{cs2}))

// Write v2 to WAL manually (like Commit step 1).
Expand All @@ -298,9 +301,10 @@ func TestCrashRecoveryCrashAfterWALBeforeDBCommit(t *testing.T) {
require.Equal(t, int64(2), s2.Version())
require.NotEqual(t, hashAfterV1, s2.RootHash(), "hash should differ after v2 replay")

val, found := s2.Get(key)
val, found, err := s2.Get(key)
require.NoError(t, err)
require.True(t, found)
require.Equal(t, []byte{0x22}, val, "v2 value should be present after catchup")
require.Equal(t, padLeft32(0x22), val, "v2 value should be present after catchup")
verifyLtHashConsistency(t, s2)
}

Expand All @@ -321,7 +325,7 @@ func TestCrashRecoveryLtHashConsistencyAfterAllPaths(t *testing.T) {
noncePair(addr, uint64(i)),
{
Key: evm.BuildMemIAVLEVMKey(evm.EVMKeyStorage, StorageKey(addr, slotN(byte(i)))),
Value: []byte{byte(i)},
Value: padLeft32(byte(i)),
},
}
cs := &proto.NamedChangeSet{
Expand Down Expand Up @@ -381,7 +385,7 @@ func TestCrashRecoveryCorruptLtHashBlobInMetadata(t *testing.T) {

cs := makeChangeSet(
evm.BuildMemIAVLEVMKey(evm.EVMKeyStorage, StorageKey(addrN(0x01), slotN(0x01))),
[]byte{0x11}, false,
padLeft32(0x11), false,
)
require.NoError(t, s.ApplyChangeSets([]*proto.NamedChangeSet{cs}))
_, err = s.Commit()
Expand Down Expand Up @@ -416,7 +420,7 @@ func TestCrashRecoveryCorruptLtHashBlobInPerDBMeta(t *testing.T) {

cs := makeChangeSet(
evm.BuildMemIAVLEVMKey(evm.EVMKeyStorage, StorageKey(addrN(0x02), slotN(0x01))),
[]byte{0x22}, false,
padLeft32(0x22), false,
)
require.NoError(t, s.ApplyChangeSets([]*proto.NamedChangeSet{cs}))
_, err = s.Commit()
Expand Down Expand Up @@ -451,7 +455,7 @@ func TestCrashRecoveryGlobalVersionOverflow(t *testing.T) {

cs := makeChangeSet(
evm.BuildMemIAVLEVMKey(evm.EVMKeyStorage, StorageKey(addrN(0x03), slotN(0x01))),
[]byte{0x33}, false,
padLeft32(0x33), false,
)
require.NoError(t, s.ApplyChangeSets([]*proto.NamedChangeSet{cs}))
_, err = s.Commit()
Expand Down
Loading
Loading