Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove RegisterIDToKey & RegisterValuesToValues from execution state #3821

Merged
merged 1 commit into from
Jan 17, 2023
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
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