Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion giga/evmonly/flatkv_changeset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ func TestFlatKVChangeSetEncoderPersistsExecutorState(t *testing.T) {
},
})
require.NoError(t, err)
require.NoError(t, store.CommitStateChanges(1, changes))
prior := store.OpenView()
mutations, err := flatkv.MutationsFromChangeSets(changes, 1, prior)
prior.Close()
require.NoError(t, err)
require.NoError(t, store.CommitStateChanges(1, mutations))

view := store.OpenView()
defer view.Close()
Expand Down
6 changes: 5 additions & 1 deletion sei-db/bootstrap/recovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,11 @@ func TestRecoverReplaysForwardFromTheStoreOwnHeight(t *testing.T) {
}
// Block 8 goes to SC under an address the WAL's own block 8 does not carry. It marks the working
// copy: a rebuild from the snapshot replays the WAL's block 8 instead and the address is gone.
require.NoError(t, manager.SC().CommitStateChanges(8, evmBlock(108, 108)))
prior := manager.SC().OpenView()
marked, err := flatkv.MutationsFromChangeSets(evmBlock(108, 108), 8, prior)
prior.Close()
require.NoError(t, err)
require.NoError(t, manager.SC().CommitStateChanges(8, marked))
writeWALOnly(t, manager.StateWAL(), 8, evmBlock(8, 8))
writeWALOnly(t, manager.StateWAL(), 9, evmBlock(9, 9))
writeWALOnly(t, manager.StateWAL(), 10, evmBlock(10, 10))
Expand Down
205 changes: 0 additions & 205 deletions sei-db/db_engine/view/batch_update_test.go

This file was deleted.

54 changes: 1 addition & 53 deletions sei-db/db_engine/view/differential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const (
opSet = iota
opDelete
opBatch
opUpdate
opView
)

Expand Down Expand Up @@ -91,13 +90,6 @@ func runDifferential(t *testing.T, shardCount, maxSize uint64, seedDB bool, seed
muts := randMuts(rng, keys)
require.NoError(t, manager.BatchSet(muts))
model.BatchSet(muts)
case opUpdate:
updated := randUpdateKeys(rng, keys)
require.NoError(t, manager.BatchUpdate(updated, foldUpdater{}))
for _, k := range updated {
prior, _ := model.GetLive([]byte(k))
model.Set([]byte(k), foldedValue(prior))
}
case opView:
if len(opens) >= maxOpen {
releaseOldest()
Expand Down Expand Up @@ -198,57 +190,13 @@ func pickOp(rng *testutil.TestRandom) int {
return opSet
case r < 60:
return opDelete
case r < 70:
return opBatch
case r < 80:
return opUpdate
return opBatch
default:
return opView
}
}

// randUpdateKeys picks the keys for one BatchUpdate, deduplicated because the contract forbids a
// repeated key.
func randUpdateKeys(rng *testutil.TestRandom, keys [][]byte) []string {
n := rng.IntRange(1, 9)
seen := make(map[string]struct{}, n)
picked := make([]string, 0, n)
for i := 0; i < n; i++ {
k := string(pick(rng, keys))
if _, ok := seen[k]; ok {
continue
}
seen[k] = struct{}{}
picked = append(picked, k)
}
return picked
}

// foldUpdater folds through foldedValue, so the oracle can reproduce the same writes from its own
// state rather than carrying a second copy of the manager's logic.
type foldUpdater struct{}

var _ BatchUpdater = foldUpdater{}

func (foldUpdater) NewValueFor(_ string, priorValue []byte) ([]byte, error) {
return foldedValue(priorValue), nil
}

// foldedValue is a pure function of the value a key already held. A key holding nothing gets one, a
// value that has grown past the cap is deleted, and anything else is extended — between them the
// create, modify and delete outcomes a fold can have. Bounded so a long run cannot grow values
// without limit.
func foldedValue(priorValue []byte) []byte {
if priorValue == nil {
return []byte("folded")
}
if len(priorValue) >= 12 {
return nil
}
// Copied rather than appended in place: priorValue aliases the manager's own stored value.
return append(append([]byte{}, priorValue...), '+')
}

func genKeys(rng *testutil.TestRandom, n int) [][]byte {
keys := make([][]byte, n)
keys[0] = []byte{} // include the empty key as an edge case
Expand Down
Loading
Loading