Skip to content

Commit 0c4dd70

Browse files
committed
solana: clean up settle auction none
1 parent 09ce66a commit 0c4dd70

File tree

7 files changed

+161
-195
lines changed

7 files changed

+161
-195
lines changed

solana/programs/matching-engine/src/fallback/processor/close_fast_market_order.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ impl CloseFastMarketOrder<'_> {
4242
}
4343
}
4444

45-
pub fn process(accounts: &[AccountInfo]) -> Result<()> {
45+
#[inline(never)]
46+
pub(super) fn process(accounts: &[AccountInfo]) -> Result<()> {
4647
super::helpers::require_min_account_infos_len(accounts, NUM_ACCOUNTS)?;
4748

4849
// We need to check the refund recipient account against what we know as the

solana/programs/matching-engine/src/fallback/processor/execute_order.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ impl ExecuteOrderCctpShim<'_> {
188188
}
189189
}
190190

191+
#[inline(never)]
191192
pub(super) fn process(accounts: &[AccountInfo]) -> Result<()> {
192193
// This saves stack space whereas having that in the body does not
193194
super::helpers::require_min_account_infos_len(accounts, NUM_ACCOUNTS)?;

solana/programs/matching-engine/src/fallback/processor/initialize_fast_market_order.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ impl InitializeFastMarketOrder<'_> {
9595
}
9696
}
9797

98+
#[inline(never)]
9899
pub(super) fn process(
99100
accounts: &[AccountInfo],
100101
data: &InitializeFastMarketOrderData,

solana/programs/matching-engine/src/fallback/processor/place_initial_offer.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ impl PlaceInitialOfferCctpShim<'_> {
112112
}
113113
}
114114

115-
pub fn process(accounts: &[AccountInfo], data: &PlaceInitialOfferCctpShimData) -> Result<()> {
115+
#[inline(never)]
116+
pub(super) fn process(
117+
accounts: &[AccountInfo],
118+
data: &PlaceInitialOfferCctpShimData,
119+
) -> Result<()> {
116120
// Check all accounts are valid
117121
super::helpers::require_min_account_infos_len(accounts, NUM_ACCOUNTS)?;
118122

solana/programs/matching-engine/src/fallback/processor/prepare_order_response.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ impl<'ix> PrepareOrderResponseCctpShim<'ix> {
154154
}
155155
}
156156

157-
pub fn prepare_order_response_cctp_shim(
157+
#[inline(never)]
158+
pub(super) fn process(
158159
accounts: &[AccountInfo],
159160
data: PrepareOrderResponseCctpShimData,
160161
) -> Result<()> {

solana/programs/matching-engine/src/fallback/processor/process_instruction.rs

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ use crate::ID;
55

66
use super::initialize_fast_market_order::InitializeFastMarketOrderData;
77
use super::place_initial_offer::PlaceInitialOfferCctpShimData;
8-
use super::prepare_order_response::{
9-
prepare_order_response_cctp_shim, PrepareOrderResponseCctpShimData,
10-
};
11-
use super::settle_auction_none_cctp::SettleAuctionNoneCctpShimData;
8+
use super::prepare_order_response::PrepareOrderResponseCctpShimData;
129

1310
const SELECTOR_SIZE: usize = 8;
1411

@@ -34,7 +31,7 @@ pub enum FallbackMatchingEngineInstruction<'ix> {
3431
PlaceInitialOfferCctpShim(&'ix PlaceInitialOfferCctpShimData),
3532
ExecuteOrderCctpShim,
3633
PrepareOrderResponseCctpShim(PrepareOrderResponseCctpShimData),
37-
SettleAuctionNoneCctpShim(&'ix SettleAuctionNoneCctpShimData),
34+
SettleAuctionNoneCctpShim,
3835
}
3936

4037
pub fn process_instruction(
@@ -63,10 +60,10 @@ pub fn process_instruction(
6360
super::execute_order::process(accounts)
6461
}
6562
FallbackMatchingEngineInstruction::PrepareOrderResponseCctpShim(data) => {
66-
prepare_order_response_cctp_shim(accounts, data)
63+
super::prepare_order_response::process(accounts, data)
6764
}
68-
FallbackMatchingEngineInstruction::SettleAuctionNoneCctpShim(data) => {
69-
super::settle_auction_none_cctp::process(accounts, data)
65+
FallbackMatchingEngineInstruction::SettleAuctionNoneCctpShim => {
66+
super::settle_auction_none_cctp::process(accounts)
7067
}
7168
}
7269
}
@@ -100,9 +97,7 @@ impl<'ix> FallbackMatchingEngineInstruction<'ix> {
10097
.map(Self::PrepareOrderResponseCctpShim)
10198
}
10299
FallbackMatchingEngineInstruction::SETTLE_AUCTION_NONE_CCTP_SHIM_SELECTOR => {
103-
bytemuck::try_from_bytes(&instruction_data[SELECTOR_SIZE..])
104-
.ok()
105-
.map(Self::SettleAuctionNoneCctpShim)
100+
Some(Self::SettleAuctionNoneCctpShim)
106101
}
107102
_ => None,
108103
}
@@ -156,18 +151,8 @@ impl FallbackMatchingEngineInstruction<'_> {
156151

157152
out
158153
}
159-
FallbackMatchingEngineInstruction::SettleAuctionNoneCctpShim(data) => {
160-
let mut out = Vec::with_capacity(
161-
SELECTOR_SIZE
162-
.saturating_add(std::mem::size_of::<SettleAuctionNoneCctpShimData>()),
163-
);
164-
165-
out.extend_from_slice(
166-
&FallbackMatchingEngineInstruction::SETTLE_AUCTION_NONE_CCTP_SHIM_SELECTOR,
167-
);
168-
out.extend_from_slice(bytemuck::bytes_of(*data));
169-
170-
out
154+
FallbackMatchingEngineInstruction::SettleAuctionNoneCctpShim => {
155+
FallbackMatchingEngineInstruction::SETTLE_AUCTION_NONE_CCTP_SHIM_SELECTOR.to_vec()
171156
}
172157
}
173158
}

0 commit comments

Comments
 (0)