-
Notifications
You must be signed in to change notification settings - Fork 35
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
Applied snapshot balances #1280
Conversation
5f83ee5
to
f4bde2e
Compare
2658378 mainnet ok |
984ca1e
to
6ab40a9
Compare
pkg/state/snapshot_generator.go
Outdated
return nil, nil, errors.Errorf("more than one balance diff for the same address in the same block") | ||
} | ||
if len(balanceChange.key) > wavesBalanceKeySize { | ||
err := sg.addAssetBalanceDiffFromTxDiff(balanceChange.balanceDiffs[0], balanceChange.key, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you taking first diff, but not latest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
balanceDiffs struct contains proto.BlockID, it means that while inside a block, there's only one element in this array.
It used to be a diff for multiple blocks, but not anymore. The array should be replaced with a variable, but it would take a bit extra time to refactor code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, for now we can leave it without changes.
I've just submitted a refactoring issue #1297
f8b0ab8 mainnet ok |
58af430
to
f8b0ab8
Compare
// for compatibility with the legacy state hashes | ||
sg.stor.balances.addAssetBalanceChangeLegacySH(address, asset, change.balance) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This trick won't work in the light node mode.
// for compatibility with the legacy state hashes | ||
sg.stor.balances.addWavesBalanceChangeLegacySH(address, change) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this one too
// clean up legacy state hash records with zero diffs | ||
a.stor.balances.filterZeroDiffsSHOut(blockID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's important to do these actions in snapshotApplier
because only this entity (mostly) can change the state in the light node mode.
This reverts commit 12b2a6a. According to the scala node implementation: - Saved block snapshot must not contain initial block snapshot. - Light node can calculate all initial data by its own.
These issues will be fixed in a different PR. |
No description provided.