-
Notifications
You must be signed in to change notification settings - Fork 629
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
Implement and test AccumulateChanges #468
Conversation
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.
Looks good! Just a couple nits
@AdityaSripal A couple questions about the |
Correct, however the type ABCI expects is We're keeping this in store as a list both because its easier to just stick to the type expected by ABCI, and because go-maps are not marshalled deterministically which will cause app hash divergence |
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.
Nice work! My main concern is iteration over a map as that is non determinstic in go and usually a source of problems
abci "github.com/tendermint/tendermint/abci/types" | ||
) | ||
|
||
func AccumulateChanges(currentChanges, newChanges []abci.ValidatorUpdate) []abci.ValidatorUpdate { |
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.
Maybe this could go in the types package? I think even just a file on the top level could be fine. I'd recommend avoiding utils/utils.go
and go with file naming that is descriptive
Function needs godoc/comments/tests as well
|
||
var out []abci.ValidatorUpdate | ||
|
||
for _, update := range m { |
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.
Is this used in the state machine? Iteration over maps is nondeterministic, seems likely this could result in app hash mismatch
name string | ||
packet channeltypes.Packet | ||
newChanges types.ValidatorSetChangePacketData | ||
expectedPendingChanges types.ValidatorSetChangePacketData |
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.
expectedPendingChanges types.ValidatorSetChangePacketData | |
expPendingChanges types.ValidatorSetChangePacketData |
nit: naming consistency
suite.Require().True(ok) | ||
suite.Require().Equal(&pd, actualPd, "pending changes not equal to packet data after successful packet receive. case: %s", tc.name) | ||
// Sort to avoid dumb inequalities |
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.
Maybe it would be better to require pending changes to always be sorted?
Closed in favor of cosmos/interchain-security#6 |
…github.com/stretchr/testify-1.8.0 build(deps): bump github.com/stretchr/testify from 1.7.5 to 1.8.0
Description
This creates a utility which accumulates validator set changes by updating those validators whose powers have changed. It then uses this utility in the child's OnRecvPacket to update the stored changes instead of overwriting them
closes: https://github.com/cosmos/cosmos-sdk/issues/10123
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes