Skip to content

Commit

Permalink
BUG: Fixed interruption in route_base_rewards (#35)
Browse files Browse the repository at this point in the history
There was an issue in the BaseRewardRouter where if max_iterations was
hit, it would not carry over the `rewards_to_process` meaning when the
instruction ran again, it would go off of the new pre-routed value.

Say we had 10 operators and 5 max_iterations with 10_000 rewards to
split:

```
op0: 1000
op1: 1000
op2: 1000
op3: 1000
- Iterations Hit -
op4: 600
op5: 600
op6: 600
op7: 600
op8: 600
op9: 600
```

The fix was to save the `last_rewards_to_process` like we do in
route_ncn_rewards;
  • Loading branch information
coachchucksol authored Dec 30, 2024
1 parent 25f43df commit 984cd00
Show file tree
Hide file tree
Showing 5 changed files with 500 additions and 10 deletions.
4 changes: 4 additions & 0 deletions clients/js/jito_tip_router/accounts/baseRewardRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export type BaseRewardRouter = {
reserved: Array<number>;
lastNcnGroupIndex: number;
lastVoteIndex: number;
lastRewardsToProcess: bigint;
baseFeeGroupRewards: Array<BaseRewardRouterRewards>;
ncnFeeGroupRewards: Array<BaseRewardRouterRewards>;
ncnFeeGroupRewardRoutes: Array<NcnRewardRoute>;
Expand All @@ -76,6 +77,7 @@ export type BaseRewardRouterArgs = {
reserved: Array<number>;
lastNcnGroupIndex: number;
lastVoteIndex: number;
lastRewardsToProcess: number | bigint;
baseFeeGroupRewards: Array<BaseRewardRouterRewardsArgs>;
ncnFeeGroupRewards: Array<BaseRewardRouterRewardsArgs>;
ncnFeeGroupRewardRoutes: Array<NcnRewardRouteArgs>;
Expand All @@ -94,6 +96,7 @@ export function getBaseRewardRouterEncoder(): Encoder<BaseRewardRouterArgs> {
['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })],
['lastNcnGroupIndex', getU8Encoder()],
['lastVoteIndex', getU16Encoder()],
['lastRewardsToProcess', getU64Encoder()],
[
'baseFeeGroupRewards',
getArrayEncoder(getBaseRewardRouterRewardsEncoder(), { size: 8 }),
Expand Down Expand Up @@ -122,6 +125,7 @@ export function getBaseRewardRouterDecoder(): Decoder<BaseRewardRouter> {
['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })],
['lastNcnGroupIndex', getU8Decoder()],
['lastVoteIndex', getU16Decoder()],
['lastRewardsToProcess', getU64Decoder()],
[
'baseFeeGroupRewards',
getArrayDecoder(getBaseRewardRouterRewardsDecoder(), { size: 8 }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub struct BaseRewardRouter {
pub reserved: [u8; 128],
pub last_ncn_group_index: u8,
pub last_vote_index: u16,
pub last_rewards_to_process: u64,
pub base_fee_group_rewards: [BaseRewardRouterRewards; 8],
pub ncn_fee_group_rewards: [BaseRewardRouterRewards; 8],
#[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))]
Expand Down
Loading

0 comments on commit 984cd00

Please sign in to comment.