Skip to content

epoch-rewards: remove assertion inside distribute#629

Open
mjain-jump wants to merge 1 commit intoanza-xyz:masterfrom
mjain-jump:manik-master
Open

epoch-rewards: remove assertion inside distribute#629
mjain-jump wants to merge 1 commit intoanza-xyz:masterfrom
mjain-jump:manik-master

Conversation

@mjain-jump
Copy link
Contributor

When fuzzing FD + Agave at the block level, ensuring that this assertion doesn't trigger is incredibly difficult. Within the fuzzer itself, it involves parsing through all vote / stake accounts / delegations, recomputing partitions for epoch rewards, calculating the total distributed amount, and parsing the epoch rewards sysvar to make sure the total_rewards field is properly bounded. It is a lot easier to simply remove this assertion, or handling it in a more graceful manner.

@github-actions
Copy link
Contributor

If this PR represents a change to the sysvar layout, please open a follow-up PR to update the JavaScript client @solana/sysvars (example)
Thank you for keeping the JavaScript clients in sync with the Rust clients.

Copy link
Contributor

@buffalojoec buffalojoec left a comment

Choose a reason for hiding this comment

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

Can't we do debug_assert! instead?

impl EpochRewards {
pub fn distribute(&mut self, amount: u64) {
let new_distributed_rewards = self.distributed_rewards.saturating_add(amount);
assert!(new_distributed_rewards <= self.total_rewards);
Copy link
Contributor

Choose a reason for hiding this comment

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

@joncinque is this one of those "if there's ever an issue with the lamport accounting, halt the chain as a last resort rather than create an LoF scenario"?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We were discussing this briefly -- there's only one callsite for this function, so we could hoist the checks into agave to make sure or have this return an error, but I think that would just move the panic up higher into the runtime eventually.

Would that work for the fuzzer @mjain-jump ?

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.

3 participants