-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Separate vote cost #33230
Separate vote cost #33230
Conversation
7ff981d
to
31b949c
Compare
Codecov Report
@@ Coverage Diff @@
## master #33230 +/- ##
=======================================
Coverage 81.9% 81.9%
=======================================
Files 798 798
Lines 216579 216647 +68
=======================================
+ Hits 177481 177540 +59
- Misses 39098 39107 +9 |
61d2d15
to
1d12230
Compare
cost-model/src/transaction_cost.rs
Outdated
/// can be simpler, calculation quicker. | ||
#[derive(Debug)] | ||
pub enum TransactionCost { | ||
Vote { writable_accounts: Vec<Pubkey> }, |
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.
We know upfront that we will only have 1 or 2 of these writable accounts.
Given the size of the other variant, it's probably better to use a size + array[2] here: { num: usize, writable_accounts: [Pubkey; 2] }
.
That way we can avoid an allocation entirely.
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.
after #33269 , I am leaning to just give simple_vote a static cost, no need to track vote's writable accounts, their size etc.
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.
Possible that we'd go over account-CU limits if non-vote txs can write to the vote-accounts, right?
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.
right, the whole non-vote tx's cu will be apply to the vote account in that scenario, just follow the usual logic. I bet there are some guards to prevent vote embedded in non-vote transaction. Will dig it between tasks ;)
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.
So looks like it is always allowed to have vote ix included in normal transaction, where the vote shall be processed as usual. So the scenario you mentioned above is possible.
As for SimpleVote to use Vec<Pubkey>
or array of two, imo, using vec is fine for current code since cost-model creates a vec of pubkey for writable accounts, then move to TransactionCost.
(Later when making TransactionCost as part of transaction meta, we can get ride of copying pubkey part, instead just holding write account's index.)
cost-model/src/transaction_cost.rs
Outdated
|
||
pub fn account_data_size(&self) -> u64 { | ||
match self { | ||
Self::Vote { .. } => 0, |
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.
probably we want comments here. The actual size is not 0 for loaded accounts. It's I think we just don't want t include the costs for votes
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.
once decided to give simple vote a static cost, maybe of this can be refactored away.
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.
simple vote tx has 8 cu
for loaded_accounts_data_size_cost
, which is different form this account_data_size
that tracks allocating accounts size (eg CreateAccount, Allocate space etc)
…ote transaction, not necessary for vote in general
6226f41
to
634228f
Compare
Problem
Usage cost of simple-vote transaction is static (#33269), due to restrictions of being a "simple vote transaction".
Assigning a static usage cost to simple-vote, instead of going to calculation that applies to normal transaction, would simplify code. Also preparing for enhancing normal transaction's usage cost categorization and calculation, without having to worry about accidentally changing vote's cost. Another side benefit is to slightly improve vote cost calculation performance.
Summary of Changes
enum
cost type forVote
andTransaction
.Fixes #