From 2dd2132e74124448702851504d45e42d82eb28dd Mon Sep 17 00:00:00 2001 From: Christian Krueger Date: Tue, 26 Nov 2024 14:21:07 -0600 Subject: [PATCH] tests passing --- .../accounts/epochRewardRouter.ts | 4 +- clients/js/jito_tip_router/types/fees.ts | 4 +- .../types/rewardStakeWeight.ts | 25 +----- .../js/jito_tip_router/types/stakeWeight.ts | 13 +-- .../generated/accounts/epoch_reward_router.rs | 2 +- .../src/generated/types/fees.rs | 2 +- .../generated/types/reward_stake_weight.rs | 2 - .../src/generated/types/stake_weight.rs | 4 +- core/src/epoch_reward_router.rs | 4 +- core/src/fees.rs | 6 +- core/src/ncn_fee_group.rs | 82 +++++++++---------- core/src/stake_weight.rs | 12 +-- idl/jito_tip_router.json | 24 +----- .../tests/fixtures/tip_router_client.rs | 4 + program/src/initialize_operator_snapshot.rs | 1 + 15 files changed, 73 insertions(+), 116 deletions(-) diff --git a/clients/js/jito_tip_router/accounts/epochRewardRouter.ts b/clients/js/jito_tip_router/accounts/epochRewardRouter.ts index c642f6df..56a28d6e 100644 --- a/clients/js/jito_tip_router/accounts/epochRewardRouter.ts +++ b/clients/js/jito_tip_router/accounts/epochRewardRouter.ts @@ -83,7 +83,7 @@ export function getEpochRewardRouterEncoder(): Encoder { ['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })], [ 'ncnRewardBuckets', - getArrayEncoder(getRewardBucketEncoder(), { size: 16 }), + getArrayEncoder(getRewardBucketEncoder(), { size: 8 }), ], ['rewardRoutes', getArrayEncoder(getRewardRoutesEncoder(), { size: 32 })], ]); @@ -101,7 +101,7 @@ export function getEpochRewardRouterDecoder(): Decoder { ['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })], [ 'ncnRewardBuckets', - getArrayDecoder(getRewardBucketDecoder(), { size: 16 }), + getArrayDecoder(getRewardBucketDecoder(), { size: 8 }), ], ['rewardRoutes', getArrayDecoder(getRewardRoutesDecoder(), { size: 32 })], ]); diff --git a/clients/js/jito_tip_router/types/fees.ts b/clients/js/jito_tip_router/types/fees.ts index ae4529a8..8fc9da70 100644 --- a/clients/js/jito_tip_router/types/fees.ts +++ b/clients/js/jito_tip_router/types/fees.ts @@ -49,7 +49,7 @@ export function getFeesEncoder(): Encoder { ['blockEngineFeeBps', getU64Encoder()], ['daoFeeBps', getU64Encoder()], ['reserved', getArrayEncoder(getU8Encoder(), { size: 128 })], - ['ncnFeeGroupsBps', getArrayEncoder(getNcnFeeEncoder(), { size: 16 })], + ['ncnFeeGroupsBps', getArrayEncoder(getNcnFeeEncoder(), { size: 8 })], ]); } @@ -59,7 +59,7 @@ export function getFeesDecoder(): Decoder { ['blockEngineFeeBps', getU64Decoder()], ['daoFeeBps', getU64Decoder()], ['reserved', getArrayDecoder(getU8Decoder(), { size: 128 })], - ['ncnFeeGroupsBps', getArrayDecoder(getNcnFeeDecoder(), { size: 16 })], + ['ncnFeeGroupsBps', getArrayDecoder(getNcnFeeDecoder(), { size: 8 })], ]); } diff --git a/clients/js/jito_tip_router/types/rewardStakeWeight.ts b/clients/js/jito_tip_router/types/rewardStakeWeight.ts index 160f1042..1e32a4f5 100644 --- a/clients/js/jito_tip_router/types/rewardStakeWeight.ts +++ b/clients/js/jito_tip_router/types/rewardStakeWeight.ts @@ -8,10 +8,6 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, getStructDecoder, getStructEncoder, getU128Decoder, @@ -19,31 +15,18 @@ import { type Codec, type Decoder, type Encoder, - type ReadonlyUint8Array, } from '@solana/web3.js'; -export type RewardStakeWeight = { - rewardStakeWeight: bigint; - reserved: ReadonlyUint8Array; -}; +export type RewardStakeWeight = { rewardStakeWeight: bigint }; -export type RewardStakeWeightArgs = { - rewardStakeWeight: number | bigint; - reserved: ReadonlyUint8Array; -}; +export type RewardStakeWeightArgs = { rewardStakeWeight: number | bigint }; export function getRewardStakeWeightEncoder(): Encoder { - return getStructEncoder([ - ['rewardStakeWeight', getU128Encoder()], - ['reserved', fixEncoderSize(getBytesEncoder(), 64)], - ]); + return getStructEncoder([['rewardStakeWeight', getU128Encoder()]]); } export function getRewardStakeWeightDecoder(): Decoder { - return getStructDecoder([ - ['rewardStakeWeight', getU128Decoder()], - ['reserved', fixDecoderSize(getBytesDecoder(), 64)], - ]); + return getStructDecoder([['rewardStakeWeight', getU128Decoder()]]); } export function getRewardStakeWeightCodec(): Codec< diff --git a/clients/js/jito_tip_router/types/stakeWeight.ts b/clients/js/jito_tip_router/types/stakeWeight.ts index 0c5e2935..7c83d59f 100644 --- a/clients/js/jito_tip_router/types/stakeWeight.ts +++ b/clients/js/jito_tip_router/types/stakeWeight.ts @@ -8,12 +8,8 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, getArrayDecoder, getArrayEncoder, - getBytesDecoder, - getBytesEncoder, getStructDecoder, getStructEncoder, getU128Decoder, @@ -21,7 +17,6 @@ import { type Codec, type Decoder, type Encoder, - type ReadonlyUint8Array, } from '@solana/web3.js'; import { getRewardStakeWeightDecoder, @@ -33,13 +28,11 @@ import { export type StakeWeight = { stakeWeight: bigint; rewardStakeWeights: Array; - reserved: ReadonlyUint8Array; }; export type StakeWeightArgs = { stakeWeight: number | bigint; rewardStakeWeights: Array; - reserved: ReadonlyUint8Array; }; export function getStakeWeightEncoder(): Encoder { @@ -47,9 +40,8 @@ export function getStakeWeightEncoder(): Encoder { ['stakeWeight', getU128Encoder()], [ 'rewardStakeWeights', - getArrayEncoder(getRewardStakeWeightEncoder(), { size: 16 }), + getArrayEncoder(getRewardStakeWeightEncoder(), { size: 8 }), ], - ['reserved', fixEncoderSize(getBytesEncoder(), 64)], ]); } @@ -58,9 +50,8 @@ export function getStakeWeightDecoder(): Decoder { ['stakeWeight', getU128Decoder()], [ 'rewardStakeWeights', - getArrayDecoder(getRewardStakeWeightDecoder(), { size: 16 }), + getArrayDecoder(getRewardStakeWeightDecoder(), { size: 8 }), ], - ['reserved', fixDecoderSize(getBytesDecoder(), 64)], ]); } diff --git a/clients/rust/jito_tip_router/src/generated/accounts/epoch_reward_router.rs b/clients/rust/jito_tip_router/src/generated/accounts/epoch_reward_router.rs index d09629ee..04b564d2 100644 --- a/clients/rust/jito_tip_router/src/generated/accounts/epoch_reward_router.rs +++ b/clients/rust/jito_tip_router/src/generated/accounts/epoch_reward_router.rs @@ -25,7 +25,7 @@ pub struct EpochRewardRouter { pub doa_rewards: u64, #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] pub reserved: [u8; 128], - pub ncn_reward_buckets: [RewardBucket; 16], + pub ncn_reward_buckets: [RewardBucket; 8], pub reward_routes: [RewardRoutes; 32], } diff --git a/clients/rust/jito_tip_router/src/generated/types/fees.rs b/clients/rust/jito_tip_router/src/generated/types/fees.rs index 86331c34..2947f4ee 100644 --- a/clients/rust/jito_tip_router/src/generated/types/fees.rs +++ b/clients/rust/jito_tip_router/src/generated/types/fees.rs @@ -16,5 +16,5 @@ pub struct Fees { pub dao_fee_bps: u64, #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] pub reserved: [u8; 128], - pub ncn_fee_groups_bps: [NcnFee; 16], + pub ncn_fee_groups_bps: [NcnFee; 8], } diff --git a/clients/rust/jito_tip_router/src/generated/types/reward_stake_weight.rs b/clients/rust/jito_tip_router/src/generated/types/reward_stake_weight.rs index 2dd41fd9..e40d60c5 100644 --- a/clients/rust/jito_tip_router/src/generated/types/reward_stake_weight.rs +++ b/clients/rust/jito_tip_router/src/generated/types/reward_stake_weight.rs @@ -10,6 +10,4 @@ use borsh::{BorshDeserialize, BorshSerialize}; #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct RewardStakeWeight { pub reward_stake_weight: u128, - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub reserved: [u8; 64], } diff --git a/clients/rust/jito_tip_router/src/generated/types/stake_weight.rs b/clients/rust/jito_tip_router/src/generated/types/stake_weight.rs index a274273d..a473343d 100644 --- a/clients/rust/jito_tip_router/src/generated/types/stake_weight.rs +++ b/clients/rust/jito_tip_router/src/generated/types/stake_weight.rs @@ -12,7 +12,5 @@ use crate::generated::types::RewardStakeWeight; #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct StakeWeight { pub stake_weight: u128, - pub reward_stake_weights: [RewardStakeWeight; 16], - #[cfg_attr(feature = "serde", serde(with = "serde_with::As::"))] - pub reserved: [u8; 64], + pub reward_stake_weights: [RewardStakeWeight; 8], } diff --git a/core/src/epoch_reward_router.rs b/core/src/epoch_reward_router.rs index 965bdbf0..504cc8c8 100644 --- a/core/src/epoch_reward_router.rs +++ b/core/src/epoch_reward_router.rs @@ -99,7 +99,7 @@ pub struct EpochRewardRouter { reserved: [u8; 128], - ncn_reward_buckets: [RewardBucket; 16], + ncn_reward_buckets: [RewardBucket; 8], //TODO change to 256 reward_routes: [RewardRoutes; 32], @@ -437,7 +437,7 @@ impl EpochRewardRouter { Ok(()) } - pub const fn ncn_reward_buckets(&self) -> &[RewardBucket; 16] { + pub const fn ncn_reward_buckets(&self) -> &[RewardBucket; 8] { &self.ncn_reward_buckets } diff --git a/core/src/fees.rs b/core/src/fees.rs index 1cec1bcb..abbaa15c 100644 --- a/core/src/fees.rs +++ b/core/src/fees.rs @@ -272,7 +272,7 @@ pub struct Fees { block_engine_fee_bps: PodU64, dao_fee_bps: PodU64, reserved: [u8; 128], - ncn_fee_groups_bps: [NcnFee; 16], + ncn_fee_groups_bps: [NcnFee; 8], } impl Fees { @@ -474,7 +474,7 @@ mod tests { .fee_1 .ncn_fee_bps(NcnFeeGroup::default()) .unwrap(), - 0 + DEFAULT_NCN_FEE ); assert_eq!(fee_config.fee_2.activation_epoch(), STARTING_EPOCH); @@ -485,7 +485,7 @@ mod tests { .fee_2 .ncn_fee_bps(NcnFeeGroup::default()) .unwrap(), - 0 + DEFAULT_NCN_FEE ); let new_fees = Fees::new(500, 600, 700, 10).unwrap(); diff --git a/core/src/ncn_fee_group.rs b/core/src/ncn_fee_group.rs index 983f7d16..9e8eb682 100644 --- a/core/src/ncn_fee_group.rs +++ b/core/src/ncn_fee_group.rs @@ -14,14 +14,14 @@ pub enum NcnFeeGroupType { Reserved5 = 0x5, Reserved6 = 0x6, Reserved7 = 0x7, - Reserved8 = 0x8, - Reserved9 = 0x9, - ReservedA = 0xA, - ReservedB = 0xB, - ReservedC = 0xC, - ReservedD = 0xD, - ReservedE = 0xE, - ReservedF = 0xF, + // Reserved8 = 0x8, + // Reserved9 = 0x9, + // ReservedA = 0xA, + // ReservedB = 0xB, + // ReservedC = 0xC, + // ReservedD = 0xD, + // ReservedE = 0xE, + // ReservedF = 0xF, } #[derive(Debug, Clone, Copy, Zeroable, ShankType, Pod)] @@ -39,7 +39,7 @@ impl Default for NcnFeeGroup { } impl NcnFeeGroup { - pub const FEE_GROUP_COUNT: usize = 16; + pub const FEE_GROUP_COUNT: usize = 8; pub const fn new(group: NcnFeeGroupType) -> Self { // So compiler will yell at us if we miss a group @@ -52,14 +52,14 @@ impl NcnFeeGroup { NcnFeeGroupType::Reserved5 => Self { group: group as u8 }, NcnFeeGroupType::Reserved6 => Self { group: group as u8 }, NcnFeeGroupType::Reserved7 => Self { group: group as u8 }, - NcnFeeGroupType::Reserved8 => Self { group: group as u8 }, - NcnFeeGroupType::Reserved9 => Self { group: group as u8 }, - NcnFeeGroupType::ReservedA => Self { group: group as u8 }, - NcnFeeGroupType::ReservedB => Self { group: group as u8 }, - NcnFeeGroupType::ReservedC => Self { group: group as u8 }, - NcnFeeGroupType::ReservedD => Self { group: group as u8 }, - NcnFeeGroupType::ReservedE => Self { group: group as u8 }, - NcnFeeGroupType::ReservedF => Self { group: group as u8 }, + // NcnFeeGroupType::Reserved8 => Self { group: group as u8 }, + // NcnFeeGroupType::Reserved9 => Self { group: group as u8 }, + // NcnFeeGroupType::ReservedA => Self { group: group as u8 }, + // NcnFeeGroupType::ReservedB => Self { group: group as u8 }, + // NcnFeeGroupType::ReservedC => Self { group: group as u8 }, + // NcnFeeGroupType::ReservedD => Self { group: group as u8 }, + // NcnFeeGroupType::ReservedE => Self { group: group as u8 }, + // NcnFeeGroupType::ReservedF => Self { group: group as u8 }, } } @@ -73,14 +73,14 @@ impl NcnFeeGroup { 0x5 => Ok(Self::new(NcnFeeGroupType::Reserved5)), 0x6 => Ok(Self::new(NcnFeeGroupType::Reserved6)), 0x7 => Ok(Self::new(NcnFeeGroupType::Reserved7)), - 0x8 => Ok(Self::new(NcnFeeGroupType::Reserved8)), - 0x9 => Ok(Self::new(NcnFeeGroupType::Reserved9)), - 0xA => Ok(Self::new(NcnFeeGroupType::ReservedA)), - 0xB => Ok(Self::new(NcnFeeGroupType::ReservedB)), - 0xC => Ok(Self::new(NcnFeeGroupType::ReservedC)), - 0xD => Ok(Self::new(NcnFeeGroupType::ReservedD)), - 0xE => Ok(Self::new(NcnFeeGroupType::ReservedE)), - 0xF => Ok(Self::new(NcnFeeGroupType::ReservedF)), + // 0x8 => Ok(Self::new(NcnFeeGroupType::Reserved8)), + // 0x9 => Ok(Self::new(NcnFeeGroupType::Reserved9)), + // 0xA => Ok(Self::new(NcnFeeGroupType::ReservedA)), + // 0xB => Ok(Self::new(NcnFeeGroupType::ReservedB)), + // 0xC => Ok(Self::new(NcnFeeGroupType::ReservedC)), + // 0xD => Ok(Self::new(NcnFeeGroupType::ReservedD)), + // 0xE => Ok(Self::new(NcnFeeGroupType::ReservedE)), + // 0xF => Ok(Self::new(NcnFeeGroupType::ReservedF)), _ => Err(TipRouterError::InvalidNcnFeeGroup), } } @@ -95,14 +95,14 @@ impl NcnFeeGroup { 0x5 => Ok(NcnFeeGroupType::Reserved5), 0x6 => Ok(NcnFeeGroupType::Reserved6), 0x7 => Ok(NcnFeeGroupType::Reserved7), - 0x8 => Ok(NcnFeeGroupType::Reserved8), - 0x9 => Ok(NcnFeeGroupType::Reserved9), - 0xA => Ok(NcnFeeGroupType::ReservedA), - 0xB => Ok(NcnFeeGroupType::ReservedB), - 0xC => Ok(NcnFeeGroupType::ReservedC), - 0xD => Ok(NcnFeeGroupType::ReservedD), - 0xE => Ok(NcnFeeGroupType::ReservedE), - 0xF => Ok(NcnFeeGroupType::ReservedF), + // 0x8 => Ok(NcnFeeGroupType::Reserved8), + // 0x9 => Ok(NcnFeeGroupType::Reserved9), + // 0xA => Ok(NcnFeeGroupType::ReservedA), + // 0xB => Ok(NcnFeeGroupType::ReservedB), + // 0xC => Ok(NcnFeeGroupType::ReservedC), + // 0xD => Ok(NcnFeeGroupType::ReservedD), + // 0xE => Ok(NcnFeeGroupType::ReservedE), + // 0xF => Ok(NcnFeeGroupType::ReservedF), _ => Err(TipRouterError::InvalidNcnFeeGroup), } } @@ -122,14 +122,14 @@ impl NcnFeeGroup { Self::new(NcnFeeGroupType::Reserved5), Self::new(NcnFeeGroupType::Reserved6), Self::new(NcnFeeGroupType::Reserved7), - Self::new(NcnFeeGroupType::Reserved8), - Self::new(NcnFeeGroupType::Reserved9), - Self::new(NcnFeeGroupType::ReservedA), - Self::new(NcnFeeGroupType::ReservedB), - Self::new(NcnFeeGroupType::ReservedC), - Self::new(NcnFeeGroupType::ReservedD), - Self::new(NcnFeeGroupType::ReservedE), - Self::new(NcnFeeGroupType::ReservedF), + // Self::new(NcnFeeGroupType::Reserved8), + // Self::new(NcnFeeGroupType::Reserved9), + // Self::new(NcnFeeGroupType::ReservedA), + // Self::new(NcnFeeGroupType::ReservedB), + // Self::new(NcnFeeGroupType::ReservedC), + // Self::new(NcnFeeGroupType::ReservedD), + // Self::new(NcnFeeGroupType::ReservedE), + // Self::new(NcnFeeGroupType::ReservedF), ] } } diff --git a/core/src/stake_weight.rs b/core/src/stake_weight.rs index d425b318..f9824a76 100644 --- a/core/src/stake_weight.rs +++ b/core/src/stake_weight.rs @@ -8,9 +8,9 @@ use crate::{error::TipRouterError, ncn_fee_group::NcnFeeGroup}; #[repr(C)] pub struct StakeWeight { stake_weight: PodU128, - reward_stake_weights: [RewardStakeWeight; 16], + reward_stake_weights: [RewardStakeWeight; 8], // Reserves - reserved: [u8; 64], + // reserved: [u8; 64], } impl Default for StakeWeight { @@ -18,7 +18,7 @@ impl Default for StakeWeight { Self { stake_weight: PodU128::from(0), reward_stake_weights: [RewardStakeWeight::default(); NcnFeeGroup::FEE_GROUP_COUNT], - reserved: [0; 64], + // reserved: [0; 64], } } } @@ -75,14 +75,14 @@ impl StakeWeight { #[repr(C)] pub struct RewardStakeWeight { reward_stake_weight: PodU128, - reserved: [u8; 64], + // reserved: [u8; 64], } impl Default for RewardStakeWeight { fn default() -> Self { Self { reward_stake_weight: PodU128::from(0), - reserved: [0; 64], + // reserved: [0; 64], } } } @@ -91,7 +91,7 @@ impl RewardStakeWeight { pub fn new(reward_stake_weight: u128) -> Self { Self { reward_stake_weight: PodU128::from(reward_stake_weight), - reserved: [0; 64], + // reserved: [0; 64], } } diff --git a/idl/jito_tip_router.json b/idl/jito_tip_router.json index 399c9f5c..3925165b 100644 --- a/idl/jito_tip_router.json +++ b/idl/jito_tip_router.json @@ -713,7 +713,7 @@ { "defined": "RewardBucket" }, - 16 + 8 ] } }, @@ -1372,7 +1372,7 @@ { "defined": "NcnFee" }, - 16 + 8 ] } } @@ -1432,16 +1432,7 @@ { "defined": "RewardStakeWeight" }, - 16 - ] - } - }, - { - "name": "reserved", - "type": { - "array": [ - "u8", - 64 + 8 ] } } @@ -1458,15 +1449,6 @@ "type": { "defined": "PodU128" } - }, - { - "name": "reserved", - "type": { - "array": [ - "u8", - 64 - ] - } } ] } diff --git a/integration_tests/tests/fixtures/tip_router_client.rs b/integration_tests/tests/fixtures/tip_router_client.rs index c4dea87a..d2f60a2f 100644 --- a/integration_tests/tests/fixtures/tip_router_client.rs +++ b/integration_tests/tests/fixtures/tip_router_client.rs @@ -650,6 +650,9 @@ impl TipRouterClient { let weight_table = WeightTable::find_program_address(&jito_tip_router_program::id(), &ncn, ncn_epoch).0; + let tracked_mints = + TrackedMints::find_program_address(&jito_tip_router_program::id(), &ncn).0; + let ix = SnapshotVaultOperatorDelegationBuilder::new() .ncn_config(config_pda) .restaking_config(restaking_config) @@ -660,6 +663,7 @@ impl TipRouterClient { .ncn_vault_ticket(ncn_vault_ticket) .vault_operator_delegation(vault_operator_delegation) .weight_table(weight_table) + .tracked_mints(tracked_mints) .epoch_snapshot(epoch_snapshot) .operator_snapshot(operator_snapshot) .vault_program(jito_vault_program::id()) diff --git a/program/src/initialize_operator_snapshot.rs b/program/src/initialize_operator_snapshot.rs index d4a0be5a..e45ac32b 100644 --- a/program/src/initialize_operator_snapshot.rs +++ b/program/src/initialize_operator_snapshot.rs @@ -72,6 +72,7 @@ pub fn process_initialize_operator_snapshot( ncn.key, ncn_epoch ); + create_account( payer, operator_snapshot,