-
Notifications
You must be signed in to change notification settings - Fork 150
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
Map iteration non determinism in consumer AccumulateChanges #505
Comments
I'm not sure that it's safe to use .String() to get the map key interchain-security/x/ccv/utils/utils.go Lines 19 to 25 in 25b0d01
Maybe it's better to use consensus address here^^
|
Does ABCI require the lists of validator updates return by different nodes in EndBlock to be in the same order?
Would that mean hashing the public key for every update? That sounds like a lot of hashing just for this purpose. |
It seems that the only requirement is that any two nodes return the same list of updates, but not necessarily in the same order. Confirmed by @sergio-mena |
Ahh yeah I forgot that these are never committed to store, because the pending updates are always deleted in endblock. I think it's fine then. |
I still think we should fix this. The fix is very easy. |
Snippet like // The list of tendermint updates should hash the same across all consensus nodes
// that means it is necessary to sort for determinism.
sort.Slice(consumerUpdatesAsList, func(i, j int) bool {
if consumerUpdatesAsList[i].Power > consumerUpdatesAsList[j].Power {
return true
}
return consumerUpdatesAsList[i].PubKey.String() > consumerUpdatesAsList[j].PubKey.String()
}) EDIT: not correct :/ lol |
Problem
AccumulateChanges used to aggregate tendermint updates on the consumer uses non deterministic map iteration to produce a list, and then writes the list to store in one go. I think this could cause a consensus error.
Closing criteria
Fix the nondeterminism.
Problem details
interchain-security/x/ccv/utils/utils.go
Lines 29 to 31 in 25b0d01
interchain-security/x/ccv/consumer/keeper/relay.go
Lines 58 to 59 in 25b0d01
TODOs
The text was updated successfully, but these errors were encountered: