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

Adding additional logging when overflow occurs in calculate_stake_rew… #3783

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

roryharr
Copy link

Problem

Currently unwrap is used during calculate_stake_rewards, this lead to a lack of logging when an overflow occurs.

It might be better to take an action other than panic!, but it matches the current code and it's not clear to me what other action should be taken.

Summary of Changes

Additional logs during overflow calculations during calculate_stake_rewards
No change of functionality, validated through new unit tests.

Fixes #

Copy link

mergify bot commented Nov 25, 2024

The Firedancer team maintains a line-for-line reimplementation of the
native programs, and until native programs are moved to BPF, those
implementations must exactly match their Agave counterparts.
If this PR represents a change to a native program implementation (not
tests), please include a reviewer from the Firedancer team. And please
keep refactors to a minimum.

Copy link

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! If you want logging with unwrap(), rather than adding all of the match statements, it's more idiomatic to use expect(&format!("My formatted message with {variable}")): https://doc.rust-lang.org/std/option/enum.Option.html#method.expect

How about making that change?

Comment on lines +633 to +634
// assume stake.stake() is right
// bootstrap means fully-vested stake at epoch 0

Choose a reason for hiding this comment

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

Is this comment intentional?

Comment on lines +628 to +630
#[test]
#[should_panic]
fn test_overflow_on_umul_calculate_rewards() {

Choose a reason for hiding this comment

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

Rather than creating two separate tests, how about parametrizing the stake passed to new_stake and using the test_case crate to combine the two tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants