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

Catchpoints: Enrich catchpoint generation and status with KV metadata #4808

Merged
merged 32 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6af364f
always process KvMods to add OldData to mods when building StateDeltas
cce Nov 16, 2022
df4dc56
remove guard clause
cce Nov 16, 2022
d4a9408
Merge remote-tracking branch 'origin/master' into fix-kvmods-deltas
cce Nov 16, 2022
de58702
Test that old data is populated by roundCowState.deltas()
jannotti Nov 16, 2022
f3d88dd
Merge pull request #11 from jannotti/fix-kvmods-deltas-test
cce Nov 16, 2022
f3b226c
Add KVs count to catchpoint generation
michaeldiamant Nov 16, 2022
a8e6cfa
Try to wire in support for counting accounts vs KVs
michaeldiamant Nov 16, 2022
28969e9
squash box changes that become no-ops
jannotti Nov 16, 2022
06555df
Plumb kv stats back to status endpoint
michaeldiamant Nov 17, 2022
07ee088
Plumb kv stats back through goal
michaeldiamant Nov 17, 2022
7e206f5
Merge pull request #12 from jannotti/squash-optimization
cce Nov 17, 2022
277dc19
Fix codegen_verification failure notification condition
michaeldiamant Nov 17, 2022
de8d3d7
Make minimal changes to make the build pass
michaeldiamant Nov 17, 2022
1bf1861
Fix reviewdog lint error
michaeldiamant Nov 17, 2022
aeb4f19
Make HashKind an explicit concept
michaeldiamant Nov 17, 2022
166d941
Fix lint errors
michaeldiamant Nov 17, 2022
4c4dba0
Fix msgp generation
michaeldiamant Nov 17, 2022
7e1f45c
Merge remote-tracking branch 'cce/fix-kvmods-deltas' into kvs_catchpo…
michaeldiamant Nov 17, 2022
d27d3a4
Remove extraneous assignments
michaeldiamant Nov 17, 2022
85e25e9
Fix counting logic
michaeldiamant Nov 17, 2022
c5e14df
Emit KVs count during catchpointdump file
michaeldiamant Nov 17, 2022
c480d17
Merge branch 'master' into kvs_catchpoint_stats
michaeldiamant Nov 17, 2022
e41f3ec
Add a test defending against hashing breaking changes
michaeldiamant Nov 18, 2022
465b954
Confirm expected hash kind
michaeldiamant Nov 18, 2022
015199a
Reverse argument ordering to match prior convention
michaeldiamant Nov 18, 2022
beff392
Make hashKind members private
michaeldiamant Nov 18, 2022
168026a
Merge branch 'master' into kvs_catchpoint_stats
michaeldiamant Nov 18, 2022
9d685c8
Merge branch 'master' into kvs_catchpoint_stats
michaeldiamant Nov 18, 2022
351f9be
Make hashKindEncodingIndex private
michaeldiamant Nov 18, 2022
c9a8b11
Fix comment spacing per code review
michaeldiamant Nov 18, 2022
5fd5770
Shorten method name per code review
michaeldiamant Nov 18, 2022
56b4a54
Pass resourcesData as pointer because it's a large struct
michaeldiamant Nov 18, 2022
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
Prev Previous commit
Pass resourcesData as pointer because it's a large struct
  • Loading branch information
michaeldiamant committed Nov 18, 2022
commit 56b4a54868b913bfec8ec6a9803e2d156dafebf8
4 changes: 2 additions & 2 deletions ledger/accountdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ func prepareNormalizedBalancesV6(bals []encodedBalanceRecordV6, proto config.Con
if err != nil {
return nil, err
}
normalizedAccountBalances[i].accountHashes[curHashIdx], err = resourcesHashBuilderV6(resData, balance.Address, basics.CreatableIndex(cidx), resData.UpdateRound, res)
normalizedAccountBalances[i].accountHashes[curHashIdx], err = resourcesHashBuilderV6(&resData, balance.Address, basics.CreatableIndex(cidx), resData.UpdateRound, res)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -4822,7 +4822,7 @@ func (iterator *orderedAccountsIter) Next(ctx context.Context) (acct []accountAd

resCb := func(addr basics.Address, cidx basics.CreatableIndex, resData *resourcesData, encodedResourceData []byte, lastResource bool) error {
if resData != nil {
hash, err := resourcesHashBuilderV6(*resData, addr, cidx, resData.UpdateRound, encodedResourceData)
hash, err := resourcesHashBuilderV6(resData, addr, cidx, resData.UpdateRound, encodedResourceData)
if err != nil {
return err
}
Expand Down
8 changes: 4 additions & 4 deletions ledger/catchpointtracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ func (ct *catchpointTracker) accountsUpdateBalances(accountsDeltas compactAccoun
resDelta := resourcesDeltas.getByIdx(i)
addr := resDelta.address
if !resDelta.oldResource.data.IsEmpty() {
deleteHash, err := resourcesHashBuilderV6(resDelta.oldResource.data, addr, resDelta.oldResource.aidx, resDelta.oldResource.data.UpdateRound, protocol.Encode(&resDelta.oldResource.data))
deleteHash, err := resourcesHashBuilderV6(&resDelta.oldResource.data, addr, resDelta.oldResource.aidx, resDelta.oldResource.data.UpdateRound, protocol.Encode(&resDelta.oldResource.data))
if err != nil {
return err
}
Expand All @@ -987,7 +987,7 @@ func (ct *catchpointTracker) accountsUpdateBalances(accountsDeltas compactAccoun
}

if !resDelta.newResource.IsEmpty() {
addHash, err := resourcesHashBuilderV6(resDelta.newResource, addr, resDelta.oldResource.aidx, resDelta.newResource.UpdateRound, protocol.Encode(&resDelta.newResource))
addHash, err := resourcesHashBuilderV6(&resDelta.newResource, addr, resDelta.oldResource.aidx, resDelta.newResource.UpdateRound, protocol.Encode(&resDelta.newResource))
if err != nil {
return err
}
Expand Down Expand Up @@ -1462,7 +1462,7 @@ const (
// encoded.
const hashKindEncodingIndex = 4

func rdGetCreatableHashKind(rd resourcesData, a basics.Address, ci basics.CreatableIndex) (hashKind, error) {
func rdGetCreatableHashKind(rd *resourcesData, a basics.Address, ci basics.CreatableIndex) (hashKind, error) {
if rd.IsAsset() {
return assetHK, nil
} else if rd.IsApp() {
Expand All @@ -1472,7 +1472,7 @@ func rdGetCreatableHashKind(rd resourcesData, a basics.Address, ci basics.Creata
}

// resourcesHashBuilderV6 calculates the hash key used for the trie by combining the creatable's resource data and its index
func resourcesHashBuilderV6(rd resourcesData, addr basics.Address, cidx basics.CreatableIndex, updateRound uint64, encodedResourceData []byte) ([]byte, error) {
func resourcesHashBuilderV6(rd *resourcesData, addr basics.Address, cidx basics.CreatableIndex, updateRound uint64, encodedResourceData []byte) ([]byte, error) {
hk, err := rdGetCreatableHashKind(rd, addr, cidx)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions ledger/catchpointtracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ func TestHashContract(t *testing.T) {
Manager: a,
}

bytes, err := resourcesHashBuilderV6(r, a, 7, 1024, protocol.Encode(&r))
bytes, err := resourcesHashBuilderV6(&r, a, 7, 1024, protocol.Encode(&r))
require.NoError(t, err)
return bytes
},
Expand All @@ -1437,7 +1437,7 @@ func TestHashContract(t *testing.T) {
GlobalStateSchemaNumUint: 2,
}

bytes, err := resourcesHashBuilderV6(r, a, 7, 1024, protocol.Encode(&r))
bytes, err := resourcesHashBuilderV6(&r, a, 7, 1024, protocol.Encode(&r))
require.NoError(t, err)
return bytes
},
Expand Down