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

go: Add consensus transaction prioritization #4911

Merged
merged 1 commit into from
Sep 14, 2022

Conversation

abukosek
Copy link
Contributor

@abukosek abukosek commented Aug 29, 2022

This PR adds support for consensus transaction prioritization using the V1 tendermint mempool implementation.

Here are the base priorities for our consensus apps:

consensus/tendermint/apps/beacon/api.go:		AppPriority int64 = 100000
consensus/tendermint/apps/keymanager/api.go:		AppPriority int64 = 50000
consensus/tendermint/apps/registry/api.go:		AppPriority int64 = 50000
consensus/tendermint/apps/governance/api.go:		AppPriority int64 = 25000
consensus/tendermint/apps/roothash/api.go:		AppPriority int64 = 15000
consensus/tendermint/apps/staking/api.go:		AppPriority int64 = 1000
consensus/tendermint/apps/scheduler/api.go:		AppPriority int64 = 0
consensus/tendermint/apps/supplementarysanity/api.go:	AppPriority int64 = 0

The reason why the scheduler and supplementarysanity have a priority of 0 is that they have no transactions.
Node registrations have a slightly higher priority of 60000 instead of the base 50000 used for other registry transactions.

I also experimented a bit with bumping various priorities based on the transaction contents -- e.g. roothash executor commits and proposer timeouts based on runtime stake, but I don't think it's worth the extra complexity.
I suggest we first try the basic version as implemented in this PR and we can always add the extra priority fudging later, once we're sure this works as intended.

In case of errors, the returned priority is 0, which I think makes most sense, so people won't be able to submit faulty transactions to fill up the high-priority part of the queue.

@codecov
Copy link

codecov bot commented Aug 29, 2022

Codecov Report

Merging #4911 (34729a1) into master (06012a8) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

❗ Current head 34729a1 differs from pull request most recent head b844f58. Consider uploading reports for the commit b844f58 to get more accurate results

@@            Coverage Diff             @@
##           master    #4911      +/-   ##
==========================================
- Coverage   66.64%   66.61%   -0.03%     
==========================================
  Files         464      464              
  Lines       51204    51218      +14     
==========================================
- Hits        34127    34121       -6     
- Misses      12891    12904      +13     
- Partials     4186     4193       +7     
Impacted Files Coverage Δ
go/common/version/version.go 80.26% <ø> (ø)
go/consensus/tendermint/apps/roothash/api.go 100.00% <ø> (ø)
go/consensus/tendermint/abci/mux.go 58.43% <100.00%> (+0.06%) ⬆️
go/consensus/tendermint/api/context.go 88.95% <100.00%> (+0.31%) ⬆️
go/consensus/tendermint/apps/beacon/beacon.go 70.96% <100.00%> (+0.47%) ⬆️
...consensus/tendermint/apps/governance/governance.go 62.50% <100.00%> (-0.54%) ⬇️
...consensus/tendermint/apps/keymanager/keymanager.go 63.24% <100.00%> (+0.19%) ⬆️
go/consensus/tendermint/apps/registry/registry.go 61.94% <100.00%> (+0.57%) ⬆️
go/consensus/tendermint/apps/roothash/roothash.go 73.34% <100.00%> (+0.05%) ⬆️
go/consensus/tendermint/apps/staking/staking.go 57.14% <100.00%> (+0.23%) ⬆️
... and 29 more

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

@abukosek abukosek force-pushed the andrej/feature/tx-prioritization branch 4 times, most recently from dd9d1d4 to 3964c45 Compare September 5, 2022 10:20
@abukosek abukosek marked this pull request as ready for review September 5, 2022 11:44
Copy link
Member

@kostko kostko 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 have some tests that these priorities work correctly?

It would probably be better if these priorities would be emitted similar to how gas stuff is done. E.g. there being some SetPriority in the context that one could query via GetPriority during CheckTx. Then priority could be configured as part of the regular execution flow instead of introducing another method.

@abukosek abukosek force-pushed the andrej/feature/tx-prioritization branch 7 times, most recently from d357e81 to c9e49b7 Compare September 12, 2022 13:08
go/consensus/tendermint/abci/mux.go Outdated Show resolved Hide resolved
go/consensus/tendermint/api/context.go Outdated Show resolved Hide resolved
go/consensus/tendermint/apps/governance/governance.go Outdated Show resolved Hide resolved
go/consensus/tendermint/full/full.go Show resolved Hide resolved
@abukosek abukosek force-pushed the andrej/feature/tx-prioritization branch from c9e49b7 to 34729a1 Compare September 13, 2022 13:10
@@ -82,6 +82,8 @@ type Context struct { // nolint: maligned
blockCtx *BlockContext
initialHeight int64

priority int64
Copy link
Member

@kostko kostko Sep 14, 2022

Choose a reason for hiding this comment

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

Could be moved up into the group where the data, events and gasAccountant are.

@abukosek abukosek force-pushed the andrej/feature/tx-prioritization branch from 34729a1 to 68bbdf0 Compare September 14, 2022 08:39
@abukosek abukosek force-pushed the andrej/feature/tx-prioritization branch from 68bbdf0 to b844f58 Compare September 14, 2022 08:41
@abukosek abukosek merged commit bfdd187 into master Sep 14, 2022
@abukosek abukosek deleted the andrej/feature/tx-prioritization branch September 14, 2022 09:23
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

2 participants