Skip to content

Commit

Permalink
Realloc instructions (#20)
Browse files Browse the repository at this point in the history
* also standardizes on epoch over ncn_epoch in instructions

notes to self
* can remove restaking_config from some accounts
* need to update ncn_epoch->epoch variable name in a few places still
  • Loading branch information
ebatsell authored Dec 17, 2024
1 parent 6a7cba3 commit 9b15dda
Show file tree
Hide file tree
Showing 96 changed files with 5,082 additions and 1,003 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ jobs:
name: jito_tip_router_program.so
path: integration_tests/tests/fixtures/
- uses: taiki-e/install-action@nextest
# Test the non-BPF tests and the BPF tests separately
- run: cargo nextest run --all-features -E 'not test(bpf)'
- run: cargo nextest run --all-features -E 'test(bpf)'
- run: cargo nextest run --all-features
env:
SBF_OUT_DIR: ${{ github.workspace }}/integration_tests/tests/fixtures

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ node_modules
# Debugging
program_errors.json
test_errors.output
tests.output
tests.output
integration_tests/tests/fixtures/jito_tip_router_program.so
4 changes: 2 additions & 2 deletions clients/js/jito_tip_router/accounts/weightTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function getWeightTableEncoder(): Encoder<WeightTableArgs> {
['slotCreated', getU64Encoder()],
['bump', getU8Encoder()],
['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })],
['table', getArrayEncoder(getWeightEntryEncoder(), { size: 32 })],
['table', getArrayEncoder(getWeightEntryEncoder(), { size: 64 })],
]);
}

Expand All @@ -81,7 +81,7 @@ export function getWeightTableDecoder(): Decoder<WeightTable> {
['slotCreated', getU64Decoder()],
['bump', getU8Decoder()],
['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })],
['table', getArrayDecoder(getWeightEntryDecoder(), { size: 32 })],
['table', getArrayDecoder(getWeightEntryDecoder(), { size: 64 })],
]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import {
combineCodec,
getOptionDecoder,
getOptionEncoder,
getStructDecoder,
getStructEncoder,
getU64Decoder,
Expand All @@ -25,8 +23,6 @@ import {
type IInstruction,
type IInstructionWithAccounts,
type IInstructionWithData,
type Option,
type OptionOrNullable,
type ReadonlyAccount,
type WritableAccount,
} from '@solana/web3.js';
Expand Down Expand Up @@ -79,20 +75,20 @@ export type DistributeBaseNcnRewardRouteInstruction<
export type DistributeBaseNcnRewardRouteInstructionData = {
discriminator: number;
ncnFeeGroup: number;
firstSlotOfNcnEpoch: Option<bigint>;
epoch: bigint;
};

export type DistributeBaseNcnRewardRouteInstructionDataArgs = {
ncnFeeGroup: number;
firstSlotOfNcnEpoch: OptionOrNullable<number | bigint>;
epoch: number | bigint;
};

export function getDistributeBaseNcnRewardRouteInstructionDataEncoder(): Encoder<DistributeBaseNcnRewardRouteInstructionDataArgs> {
return transformEncoder(
getStructEncoder([
['discriminator', getU8Encoder()],
['ncnFeeGroup', getU8Encoder()],
['firstSlotOfNcnEpoch', getOptionEncoder(getU64Encoder())],
['epoch', getU64Encoder()],
]),
(value) => ({
...value,
Expand All @@ -105,7 +101,7 @@ export function getDistributeBaseNcnRewardRouteInstructionDataDecoder(): Decoder
return getStructDecoder([
['discriminator', getU8Decoder()],
['ncnFeeGroup', getU8Decoder()],
['firstSlotOfNcnEpoch', getOptionDecoder(getU64Decoder())],
['epoch', getU64Decoder()],
]);
}

Expand Down Expand Up @@ -136,7 +132,7 @@ export type DistributeBaseNcnRewardRouteInput<
ncnRewardRouter: Address<TAccountNcnRewardRouter>;
restakingProgram: Address<TAccountRestakingProgram>;
ncnFeeGroup: DistributeBaseNcnRewardRouteInstructionDataArgs['ncnFeeGroup'];
firstSlotOfNcnEpoch: DistributeBaseNcnRewardRouteInstructionDataArgs['firstSlotOfNcnEpoch'];
epoch: DistributeBaseNcnRewardRouteInstructionDataArgs['epoch'];
};

export function getDistributeBaseNcnRewardRouteInstruction<
Expand Down
14 changes: 5 additions & 9 deletions clients/js/jito_tip_router/instructions/distributeBaseRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import {
combineCodec,
getOptionDecoder,
getOptionEncoder,
getStructDecoder,
getStructEncoder,
getU64Decoder,
Expand All @@ -25,8 +23,6 @@ import {
type IInstruction,
type IInstructionWithAccounts,
type IInstructionWithData,
type Option,
type OptionOrNullable,
type ReadonlyAccount,
type WritableAccount,
} from '@solana/web3.js';
Expand Down Expand Up @@ -75,20 +71,20 @@ export type DistributeBaseRewardsInstruction<
export type DistributeBaseRewardsInstructionData = {
discriminator: number;
baseFeeGroup: number;
firstSlotOfNcnEpoch: Option<bigint>;
epoch: bigint;
};

export type DistributeBaseRewardsInstructionDataArgs = {
baseFeeGroup: number;
firstSlotOfNcnEpoch: OptionOrNullable<number | bigint>;
epoch: number | bigint;
};

export function getDistributeBaseRewardsInstructionDataEncoder(): Encoder<DistributeBaseRewardsInstructionDataArgs> {
return transformEncoder(
getStructEncoder([
['discriminator', getU8Encoder()],
['baseFeeGroup', getU8Encoder()],
['firstSlotOfNcnEpoch', getOptionEncoder(getU64Encoder())],
['epoch', getU64Encoder()],
]),
(value) => ({
...value,
Expand All @@ -101,7 +97,7 @@ export function getDistributeBaseRewardsInstructionDataDecoder(): Decoder<Distri
return getStructDecoder([
['discriminator', getU8Decoder()],
['baseFeeGroup', getU8Decoder()],
['firstSlotOfNcnEpoch', getOptionDecoder(getU64Decoder())],
['epoch', getU64Decoder()],
]);
}

Expand Down Expand Up @@ -130,7 +126,7 @@ export type DistributeBaseRewardsInput<
baseFeeWallet: Address<TAccountBaseFeeWallet>;
restakingProgram: Address<TAccountRestakingProgram>;
baseFeeGroup: DistributeBaseRewardsInstructionDataArgs['baseFeeGroup'];
firstSlotOfNcnEpoch: DistributeBaseRewardsInstructionDataArgs['firstSlotOfNcnEpoch'];
epoch: DistributeBaseRewardsInstructionDataArgs['epoch'];
};

export function getDistributeBaseRewardsInstruction<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import {
combineCodec,
getOptionDecoder,
getOptionEncoder,
getStructDecoder,
getStructEncoder,
getU64Decoder,
Expand All @@ -25,8 +23,6 @@ import {
type IInstruction,
type IInstructionWithAccounts,
type IInstructionWithData,
type Option,
type OptionOrNullable,
type ReadonlyAccount,
type WritableAccount,
} from '@solana/web3.js';
Expand Down Expand Up @@ -75,20 +71,20 @@ export type DistributeNcnOperatorRewardsInstruction<
export type DistributeNcnOperatorRewardsInstructionData = {
discriminator: number;
ncnFeeGroup: number;
firstSlotOfNcnEpoch: Option<bigint>;
epoch: bigint;
};

export type DistributeNcnOperatorRewardsInstructionDataArgs = {
ncnFeeGroup: number;
firstSlotOfNcnEpoch: OptionOrNullable<number | bigint>;
epoch: number | bigint;
};

export function getDistributeNcnOperatorRewardsInstructionDataEncoder(): Encoder<DistributeNcnOperatorRewardsInstructionDataArgs> {
return transformEncoder(
getStructEncoder([
['discriminator', getU8Encoder()],
['ncnFeeGroup', getU8Encoder()],
['firstSlotOfNcnEpoch', getOptionEncoder(getU64Encoder())],
['epoch', getU64Encoder()],
]),
(value) => ({
...value,
Expand All @@ -101,7 +97,7 @@ export function getDistributeNcnOperatorRewardsInstructionDataDecoder(): Decoder
return getStructDecoder([
['discriminator', getU8Decoder()],
['ncnFeeGroup', getU8Decoder()],
['firstSlotOfNcnEpoch', getOptionDecoder(getU64Decoder())],
['epoch', getU64Decoder()],
]);
}

Expand Down Expand Up @@ -130,7 +126,7 @@ export type DistributeNcnOperatorRewardsInput<
ncnRewardRouter: Address<TAccountNcnRewardRouter>;
restakingProgram: Address<TAccountRestakingProgram>;
ncnFeeGroup: DistributeNcnOperatorRewardsInstructionDataArgs['ncnFeeGroup'];
firstSlotOfNcnEpoch: DistributeNcnOperatorRewardsInstructionDataArgs['firstSlotOfNcnEpoch'];
epoch: DistributeNcnOperatorRewardsInstructionDataArgs['epoch'];
};

export function getDistributeNcnOperatorRewardsInstruction<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import {
combineCodec,
getOptionDecoder,
getOptionEncoder,
getStructDecoder,
getStructEncoder,
getU64Decoder,
Expand All @@ -25,8 +23,6 @@ import {
type IInstruction,
type IInstructionWithAccounts,
type IInstructionWithData,
type Option,
type OptionOrNullable,
type ReadonlyAccount,
type WritableAccount,
} from '@solana/web3.js';
Expand Down Expand Up @@ -75,20 +71,20 @@ export type DistributeNcnVaultRewardsInstruction<
export type DistributeNcnVaultRewardsInstructionData = {
discriminator: number;
ncnFeeGroup: number;
firstSlotOfNcnEpoch: Option<bigint>;
epoch: bigint;
};

export type DistributeNcnVaultRewardsInstructionDataArgs = {
ncnFeeGroup: number;
firstSlotOfNcnEpoch: OptionOrNullable<number | bigint>;
epoch: number | bigint;
};

export function getDistributeNcnVaultRewardsInstructionDataEncoder(): Encoder<DistributeNcnVaultRewardsInstructionDataArgs> {
return transformEncoder(
getStructEncoder([
['discriminator', getU8Encoder()],
['ncnFeeGroup', getU8Encoder()],
['firstSlotOfNcnEpoch', getOptionEncoder(getU64Encoder())],
['epoch', getU64Encoder()],
]),
(value) => ({
...value,
Expand All @@ -101,7 +97,7 @@ export function getDistributeNcnVaultRewardsInstructionDataDecoder(): Decoder<Di
return getStructDecoder([
['discriminator', getU8Decoder()],
['ncnFeeGroup', getU8Decoder()],
['firstSlotOfNcnEpoch', getOptionDecoder(getU64Decoder())],
['epoch', getU64Decoder()],
]);
}

Expand Down Expand Up @@ -130,7 +126,7 @@ export type DistributeNcnVaultRewardsInput<
vault: Address<TAccountVault>;
ncnRewardRouter: Address<TAccountNcnRewardRouter>;
ncnFeeGroup: DistributeNcnVaultRewardsInstructionDataArgs['ncnFeeGroup'];
firstSlotOfNcnEpoch: DistributeNcnVaultRewardsInstructionDataArgs['firstSlotOfNcnEpoch'];
epoch: DistributeNcnVaultRewardsInstructionDataArgs['epoch'];
};

export function getDistributeNcnVaultRewardsInstruction<
Expand Down
4 changes: 4 additions & 0 deletions clients/js/jito_tip_router/instructions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export * from './initializeNcnRewardRouter';
export * from './initializeOperatorSnapshot';
export * from './initializeTrackedMints';
export * from './initializeWeightTable';
export * from './reallocBallotBox';
export * from './reallocBaseRewardRouter';
export * from './reallocOperatorSnapshot';
export * from './reallocWeightTable';
export * from './registerMint';
export * from './routeBaseRewards';
export * from './routeNcnRewards';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import {
combineCodec,
getOptionDecoder,
getOptionEncoder,
getStructDecoder,
getStructEncoder,
getU64Decoder,
Expand All @@ -26,8 +24,6 @@ import {
type IInstruction,
type IInstructionWithAccounts,
type IInstructionWithData,
type Option,
type OptionOrNullable,
type ReadonlyAccount,
type TransactionSigner,
type WritableAccount,
Expand Down Expand Up @@ -80,18 +76,18 @@ export type InitializeBaseRewardRouterInstruction<

export type InitializeBaseRewardRouterInstructionData = {
discriminator: number;
firstSlotOfNcnEpoch: Option<bigint>;
epoch: bigint;
};

export type InitializeBaseRewardRouterInstructionDataArgs = {
firstSlotOfNcnEpoch: OptionOrNullable<number | bigint>;
epoch: number | bigint;
};

export function getInitializeBaseRewardRouterInstructionDataEncoder(): Encoder<InitializeBaseRewardRouterInstructionDataArgs> {
return transformEncoder(
getStructEncoder([
['discriminator', getU8Encoder()],
['firstSlotOfNcnEpoch', getOptionEncoder(getU64Encoder())],
['epoch', getU64Encoder()],
]),
(value) => ({
...value,
Expand All @@ -103,7 +99,7 @@ export function getInitializeBaseRewardRouterInstructionDataEncoder(): Encoder<I
export function getInitializeBaseRewardRouterInstructionDataDecoder(): Decoder<InitializeBaseRewardRouterInstructionData> {
return getStructDecoder([
['discriminator', getU8Decoder()],
['firstSlotOfNcnEpoch', getOptionDecoder(getU64Decoder())],
['epoch', getU64Decoder()],
]);
}

Expand Down Expand Up @@ -131,7 +127,7 @@ export type InitializeBaseRewardRouterInput<
payer: TransactionSigner<TAccountPayer>;
restakingProgram: Address<TAccountRestakingProgram>;
systemProgram?: Address<TAccountSystemProgram>;
firstSlotOfNcnEpoch: InitializeBaseRewardRouterInstructionDataArgs['firstSlotOfNcnEpoch'];
epoch: InitializeBaseRewardRouterInstructionDataArgs['epoch'];
};

export function getInitializeBaseRewardRouterInstruction<
Expand Down
Loading

0 comments on commit 9b15dda

Please sign in to comment.