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

tendermint: GetEvents: return events in order #5117

Merged
merged 1 commit into from Jan 5, 2023
Merged

Conversation

mitjat
Copy link
Contributor

@mitjat mitjat commented Jan 5, 2023

Currently consensus events (e.g. in various GetEvents RPCs) are returned in the following order:

  • BeginBlock
  • EndBlock
  • DeliverTx

This PR switches all GetEvents RPCs to the more natural order:

  • BeginBlock
  • DeliverTx
  • EndBlock

The motivation comes from oasis-indexer, where processing events in the order they were returned before this PR can lead to violated assumptions (e.g. "no account can ever have negative balance").

Comment on lines -421 to +426
tmEvents := append(results.BeginBlockEvents, results.EndBlockEvents...)
tmEvents := results.BeginBlockEvents
for _, txResults := range results.TxsResults {
tmEvents = append(tmEvents, txResults.Events...)
}
tmEvents = append(tmEvents, results.EndBlockEvents...)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks unrelated, but might as well change this too, for consistency.
This covers all the occurrences of EndBlockEvents in the codebase.

@codecov
Copy link

codecov bot commented Jan 5, 2023

Codecov Report

Merging #5117 (6423bfd) into master (613c026) will increase coverage by 0.22%.
The diff coverage is 58.33%.

❗ Current head 6423bfd differs from pull request most recent head 07c003e. Consider uploading reports for the commit 07c003e to get more accurate results

@@            Coverage Diff             @@
##           master    #5117      +/-   ##
==========================================
+ Coverage   66.85%   67.07%   +0.22%     
==========================================
  Files         497      497              
  Lines       53159    53160       +1     
==========================================
+ Hits        35540    35658     +118     
+ Misses      13280    13186      -94     
+ Partials     4339     4316      -23     
Impacted Files Coverage Δ
go/consensus/tendermint/governance/governance.go 63.76% <50.00%> (ø)
go/consensus/tendermint/registry/registry.go 66.66% <50.00%> (ø)
go/consensus/tendermint/staking/staking.go 61.13% <50.00%> (ø)
go/common/sgx/ias/avr.go 41.93% <66.66%> (ø)
go/consensus/tendermint/roothash/roothash.go 67.01% <66.66%> (+0.06%) ⬆️
go/scheduler/api/api.go 53.26% <0.00%> (-6.53%) ⬇️
go/common/cbor/codec.go 78.37% <0.00%> (-5.41%) ⬇️
go/p2p/rpc/client.go 79.73% <0.00%> (-3.53%) ⬇️
go/governance/api/api.go 75.20% <0.00%> (-3.31%) ⬇️
go/runtime/host/multi/multi.go 75.00% <0.00%> (-2.21%) ⬇️
... and 30 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@mitjat mitjat marked this pull request as ready for review January 5, 2023 09:54
@@ -0,0 +1,4 @@
go/tendermint: Change order of events returned from GetEvents()
Copy link
Member

@ptrus ptrus Jan 5, 2023

Choose a reason for hiding this comment

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

I guess under a strict definition this could be considered a breaking change as it modifies the order in API responses. However, this is not a consensus breaking change (no consensus issues in case some nodes apply this change) and could be considered a bugfix. That would be useful if we want to backport this to 22.2.x branch (iirc the release process forbids breaking changes in point releases).

Since oasis-indexer relies on this change, I would recommend backporting this to stable/22.2.x and making a new release, as otherwise the nodes used by the indexer would need a custom-built version of oasis-node.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

I meanwhile already fixed the indexer so it does some heuristic reordering of events. So it does not depend on this change. I was hoping that once this PR goes in, I could remove the reordering on the indexer side, but I guess we'll also have to process archive data from Cobalt sooner or later, and I'm not sure it's worth backporting this change all the way there.

Still, it's nice to have flexibility. Good to know this is not consensus-breaking. Relabeling as bugfix.

@mitjat mitjat enabled auto-merge January 5, 2023 21:01
@mitjat mitjat merged commit dc9d303 into master Jan 5, 2023
@mitjat mitjat deleted the mitjat/getevents-order branch January 5, 2023 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants