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

Adds rewards calculation for sporks #365

Merged
merged 2 commits into from
Apr 27, 2023
Merged

Conversation

joshuahannan
Copy link
Member

@joshuahannan joshuahannan commented Apr 24, 2023

During a spork, the FlowEpoch.heartbeat.resetEpoch() method is called after the spork is complete.
If automatic rewards are enabled, the reward breakdown for the current epoch needs to be calculated and rewards for the next epoch need to be calculated.
This PR adds calculateAndSetRewards() to the resetEpoch() method so this is done properly and automatic rewards can be paid after a spork.

The creation of new epoch metadata has also been moved to before the start of the new epoch in order to have valid epoch metadata for the rewards calculations to modify. This is why it now creates an EpochMetadata with counter + 1

This also removes the rewards parameter from resetEpoch() because it is not used any more

Copy link
Contributor

@satyamakgec satyamakgec left a comment

Choose a reason for hiding this comment

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

LGTM

contracts/epochs/FlowEpoch.cdc Outdated Show resolved Hide resolved
contracts/epochs/FlowEpoch.cdc Show resolved Hide resolved
lib/go/test/flow_epoch_test.go Outdated Show resolved Hide resolved
false,
)

// Verifies that the rewards from the previous epoch does not include the new epoch's amount
Copy link
Member

Choose a reason for hiding this comment

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

When we spork, the rewards for the epoch pre-spork will be paid out when the resetEpoch transaction is submitted. Currently this is the next day, on Thursday. It would be ideal if this multisig could be moved to Wednesday, so there isn't a 1-day delay in reward payouts, once this is enabled. cc @vishalchangrani

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, it would be nice to reset on the same day as the spork

transactions/epoch/admin/reset_epoch.cdc Show resolved Hide resolved
@joshuahannan joshuahannan merged commit 3198bb0 into master Apr 27, 2023
@joshuahannan joshuahannan deleted the reset-epoch-calculate branch April 27, 2023 17:51
jordanschalm added a commit to onflow/flow-go that referenced this pull request Apr 27, 2023
In onflow/flow-core-contracts#365, we removed
the payout argument from the resetEpoch transaction and function. Here,
we update the CLI tool which generates arguments for this transaction
accordingly.
bors bot added a commit to onflow/flow-go that referenced this pull request May 1, 2023
4286: Remove payout flag, arg from resetEpoch cmd r=jordanschalm a=jordanschalm

In onflow/flow-core-contracts#365, we removed the payout argument from the resetEpoch transaction and function. Here, we update the CLI tool which generates arguments for this transaction accordingly.

Co-authored-by: Jordan Schalm <[email protected]>
KshitijChaudhary666 added a commit to onflow/flips that referenced this pull request Jun 6, 2023
KshitijChaudhary666 added a commit to onflow/flips that referenced this pull request Jun 6, 2023
dsainati1 pushed a commit to onflow/flips that referenced this pull request Jul 11, 2023
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