-
Notifications
You must be signed in to change notification settings - Fork 31
fix: Priority fee copy and scoring logic #134
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
Conversation
| epoch, | ||
| priority_fee_commission: commission, | ||
| priority_fee_tips, | ||
| merkle_root_upload_authority, |
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.
This was wrong.
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.
great catch
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.
for the record: this bug existed for the case where the copy_priority_fee_distribution ix is called on a validator as the first instruction before any other validator history ixs are called and there existed no entry yet for this validator
| ], | ||
| bump, | ||
| seeds::program = config.priority_fee_distribution_program.key(), | ||
| owner = config.priority_fee_distribution_program.key() |
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.
I do think this check is redundant (bc we can the seeds and seeds::program constraints). So should we update the docstring above? It's specifically talking about the owner check.
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.
Good call-out. The big logic change here is that now we actually do want to allow a non-existent (still owned by system program) account to be passed in but it must abide by the PDA constraints. I will make sure this is reflected.
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.
Oh even better. Did not quite catch that. Nice work.
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.
Was copying a non-existent account possible before? I think it wouldn't have been because of the owner constraint
| } | ||
|
|
||
| /// Boolean representing if fields required for scoring have been set | ||
| pub fn can_score(&self) -> bool { |
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.
Should we rename this method to is_finalized?
I do think we should lean into this concept of "finalizing" a validator history entry. If there is outstanding/missing data, is it okay that the steward can score without it?
The following PR will require the CopyStakeInfo instruction to run during the current epoch. While this CopyPriorityFeeDistribution is required to run after the current epoch. This means that history accounts will always be partially updated, up until being finalized.
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.
There's a few other requirements for finalization, kind of baked into the StewardState::compute_score fn like the vote credits being updated in the current epoch and cluster history being updated
Open to putting those all in one method but we should keep scoring logic on the Steward side since validator history is supposed to be just the data store
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.
Dropping this function as discussed offline. The process of "skipping" an epoch while scoring will look different and impact score rather than instruction success/failure.
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.
I jive with this ^
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.
I would actually name it something a little more verbose, has_copied_priority_fees()
In this case can_score() seems to vague, and is_finalized() is closer, but its meaning is lost.
programs/validator-history/src/instructions/copy_priority_fee_distribution.rs
Show resolved
Hide resolved
tests/tests/validator_history/test_copy_priority_fee_distribution.rs
Outdated
Show resolved
Hide resolved
programs/validator-history/src/instructions/copy_priority_fee_distribution.rs
Show resolved
Hide resolved
coachchucksol
left a comment
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.
This all seems to hit what we need!
- Cannot call copy on N epoch
- Cannot overwrite data once its been written
- Added the DNE
- Cannot score without a valid MRUA
Just a couple of comments
programs/validator-history/src/instructions/copy_priority_fee_distribution.rs
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| /// Boolean representing if fields required for scoring have been set | ||
| pub fn can_score(&self) -> bool { |
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.
I jive with this ^
| } | ||
|
|
||
| /// Boolean representing if fields required for scoring have been set | ||
| pub fn can_score(&self) -> bool { |
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.
I would actually name it something a little more verbose, has_copied_priority_fees()
In this case can_score() seems to vague, and is_finalized() is closer, but its meaning is lost.
coachchucksol
left a comment
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.
Another thought
programs/validator-history/src/instructions/copy_priority_fee_distribution.rs
Outdated
Show resolved
Hide resolved
coachchucksol
left a comment
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.
A couple more things
| let distribution_account = PriorityFeeDistributionAccount::try_deserialize(&mut pdfa_data) | ||
| .unwrap_or(PriorityFeeDistributionAccount { | ||
| validator_vote_account: Pubkey::default(), | ||
| merkle_root_upload_authority: Pubkey::default(), |
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.
nit: Set as DNE_AUTHORITY not Pubkey::default(),
| &[ | ||
| MerkleRootUploadAuthority::TipRouter, | ||
| MerkleRootUploadAuthority::TipRouter, | ||
| MerkleRootUploadAuthority::TipRouter, |
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.
Any test cases with MerkleRootUploadAuthority::Other?
Problem
Current copy_priority_fee_distribution_account and compute_score instruction handlers don't consider all edge cases considering their permissionless nature.
Solution
IMPORTANT
This diff has been modified to have priority fee related score defaulted to 1.0. The intended logic has been commented out until the time of priority fee scoring launch.