Skip to content

Conversation

@avichalp
Copy link
Collaborator

This pull request updates ValidatorRewarder contract and related scripts and tests. The changes focus on improving the accuracy of reward calculations.

In the earlier implementation we mistakenly assumed that every bottom-up checkpoint will always be 600 blocks (checkpoint period). This assumption is wrong. Bottom up checkpoints in IPC can be shorter than the checkpoint period. Sometimes when the max number of messages are added the checkpoint is sent immediately.

These changes reads the actual number of blocks in the checkpoint and use that number for reward calculation. For instance, if any checkpoint contains only 300 blocks then the rewards claimed by the validator should be: 100 * validator's share.

closes: #100

avichalp added 6 commits April 8, 2025 16:03
Signed-off-by: avichalp <[email protected]>
Signed-off-by: avichalp <[email protected]>
Signed-off-by: avichalp <[email protected]>
Signed-off-by: avichalp <[email protected]>

event ActiveStateChange(bool active, address account);
event SubnetUpdated(SubnetID subnet, uint256 checkpointPeriod);
event SubnetUpdated(SubnetID subnet);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Stop storing checkpointPeriod, we will fetch the number of blocks in a checkpoint on the fly

/// @dev Ensures the checkpoint height is a multiple of the checkpoint period
function validateCheckpointHeight(uint64 claimedCheckpointHeight) internal view returns (bool) {
return claimedCheckpointHeight > 0 && claimedCheckpointHeight % checkpointPeriod == 0;
/// @notice Gets the number of blocks in a checkpoint from the subnet actor
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Calls the subnetActorGetter to fetch the number of blocks in the checkpoint.

}

/// @notice A bottom-up checkpoint type.
struct BottomUpCheckpoint {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addition data types copied over from IPC contracts to call subnetGetterActor

@avichalp avichalp marked this pull request as ready for review April 11, 2025 21:58
@avichalp avichalp merged commit fcd7530 into main Apr 15, 2025
7 checks passed
@avichalp avichalp deleted the avichalp/rewarder-update branch April 15, 2025 03:35
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.

Fix validator rewards share

3 participants