Skip to content

Commit

Permalink
Merge #3821
Browse files Browse the repository at this point in the history
3821: remove RegisterIDToKey & RegisterValuesToValues from execution state r=pattyshack a=pattyshack

they've been replaced by RegisterEntriesToKeysValues

Co-authored-by: Patrick Lee <patrick.lee@dapperlabs.com>
  • Loading branch information
bors[bot] and pattyshack authored Jan 17, 2023
2 parents 99337f3 + c6723d9 commit b0f6598
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 35 deletions.
16 changes: 0 additions & 16 deletions engine/execution/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,6 @@ func makeQuery(commitment flow.StateCommitment, ids []flow.RegisterID) (*ledger.
return ledger.NewQuery(ledger.State(commitment), keys)
}

func RegisterIDSToKeys(ids []flow.RegisterID) []ledger.Key {
keys := make([]ledger.Key, len(ids))
for i, id := range ids {
keys[i] = RegisterIDToKey(id)
}
return keys
}

func RegisterValuesToValues(values []flow.RegisterValue) []ledger.Value {
vals := make([]ledger.Value, len(values))
for i, value := range values {
vals[i] = value
}
return vals
}

func RegisterEntriesToKeysValues(
entries flow.RegisterEntries,
) (
Expand Down
6 changes: 5 additions & 1 deletion ledger/partial/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ func TestProofsForEmptyRegisters(t *testing.T) {
require.NoError(t, err)

allRegisters := view.Interactions().AllRegisters()
allKeys := executionState.RegisterIDSToKeys(allRegisters)
allKeys := make([]ledger.Key, len(allRegisters))
for i, id := range allRegisters {
allKeys[i] = executionState.RegisterIDToKey(id)
}

newState := updated.State()

proofQuery, err := ledger.NewQuery(newState, allKeys)
Expand Down
38 changes: 20 additions & 18 deletions module/chunks/chunkVerifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,16 @@ func GetBaselineVerifiableChunk(t *testing.T, script string, system bool) *verif
value2 := []byte{'b'}
UpdatedValue2 := []byte{'B'}

ids := make([]flow.RegisterID, 0)
values := make([]flow.RegisterValue, 0)
ids = append(ids, id1, id2)
values = append(values, value1, value2)
entries := flow.RegisterEntries{
{
Key: id1,
Value: value1,
},
{
Key: id2,
Value: value2,
},
}

var verifiableChunkData verification.VerifiableChunkData

Expand All @@ -258,12 +264,8 @@ func GetBaselineVerifiableChunk(t *testing.T, script string, system bool) *verif
<-compactor.Done()
}()

keys := executionState.RegisterIDSToKeys(ids)
update, err := ledger.NewUpdate(
f.InitialState(),
keys,
executionState.RegisterValuesToValues(values),
)
keys, values := executionState.RegisterEntriesToKeysValues(entries)
update, err := ledger.NewUpdate(f.InitialState(), keys, values)

require.NoError(t, err)

Expand All @@ -276,15 +278,15 @@ func GetBaselineVerifiableChunk(t *testing.T, script string, system bool) *verif
proof, err := f.Prove(query)
require.NoError(t, err)

ids = []flow.RegisterID{id2}
values = [][]byte{UpdatedValue2}
entries = flow.RegisterEntries{
{
Key: id2,
Value: UpdatedValue2,
},
}

keys = executionState.RegisterIDSToKeys(ids)
update, err = ledger.NewUpdate(
startState,
keys,
executionState.RegisterValuesToValues(values),
)
keys, values = executionState.RegisterEntriesToKeysValues(entries)
update, err = ledger.NewUpdate(startState, keys, values)
require.NoError(t, err)

endState, _, err := f.Set(update)
Expand Down

0 comments on commit b0f6598

Please sign in to comment.