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

cow: always process KvMods to add OldData to mods when building StateDeltas #4804

Merged
merged 7 commits into from
Nov 18, 2022

Conversation

cce
Copy link
Contributor

@cce cce commented Nov 16, 2022

Summary

Through debugging we noticed OldData was not set when it should be. Later we realized that roundCowState.deltas() was not always adding OldData to KvMods, and the early exit on empty sdeltas was the culprit.

Test Plan

Existing tests should pass, maybe we should have new tests for this kind of thing.

Copy link
Contributor

@jannotti jannotti left a comment

Choose a reason for hiding this comment

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

Can we remove this entire early exit / guard clause? I don't see any point in exiting early. If those values are len == 0, the for loops should (not) run just as quickly.

@algorandskiy
Copy link
Contributor

+1 to remove, empty blocks are rare :)
Need a unit test for this, and a MT-related test for this.

@cce
Copy link
Contributor Author

cce commented Nov 16, 2022

Removed the guard clause

@codecov
Copy link

codecov bot commented Nov 16, 2022

Codecov Report

Merging #4804 (7e206f5) into master (23890a8) will decrease coverage by 0.02%.
The diff coverage is 71.42%.

@@            Coverage Diff             @@
##           master    #4804      +/-   ##
==========================================
- Coverage   54.68%   54.66%   -0.03%     
==========================================
  Files         414      414              
  Lines       53550    53552       +2     
==========================================
- Hits        29286    29273      -13     
- Misses      21836    21851      +15     
  Partials     2428     2428              
Impacted Files Coverage Δ
ledger/catchpointtracker.go 60.59% <ø> (ø)
ledger/internal/cow.go 64.28% <ø> (-0.63%) ⬇️
ledger/accountdb.go 72.51% <71.42%> (-0.04%) ⬇️
network/wsPeer.go 66.50% <0.00%> (-2.43%) ⬇️
agreement/cryptoVerifier.go 67.60% <0.00%> (-2.12%) ⬇️
agreement/proposalManager.go 96.07% <0.00%> (-1.97%) ⬇️
catchup/service.go 68.14% <0.00%> (-1.24%) ⬇️
catchup/peerSelector.go 98.95% <0.00%> (-1.05%) ⬇️
network/wsNetwork.go 65.34% <0.00%> (ø)
ledger/acctupdates.go 69.75% <0.00%> (+0.24%) ⬆️
... and 2 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

kvMods[name] = ledgercore.KvValueDelta{Data: nil}
// needs an old data, else optimized away.
// if oldData = "" there is the best chance of a bug, so we use that
kvMods[name] = ledgercore.KvValueDelta{Data: nil, OldData: []byte("")}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
kvMods[name] = ledgercore.KvValueDelta{Data: nil, OldData: []byte("")}
kvMods[name] = ledgercore.KvValueDelta{Data: nil, OldData: []byte{}}

Copy link
Contributor

@michaeldiamant michaeldiamant left a comment

Choose a reason for hiding this comment

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

As intended, I confirmed the added tests fail in master while passing in the PR.

@cce Thanks again for your efforts to isolate + find the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants