Skip to content

Commit 6292726

Browse files
committed
[broken] forcing payer_signer to be close_account_refund_recipient
1 parent b970874 commit 6292726

File tree

5 files changed

+14
-63
lines changed

5 files changed

+14
-63
lines changed

solana/modules/matching-engine-testing/tests/shimful/fast_market_order_shim.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub async fn initialize_fast_market_order_shimful(
6161
let payer_signer = config
6262
.payer_signer
6363
.clone()
64-
.unwrap_or_else(|| testing_context.testing_actors.payer_signer.clone());
64+
.unwrap_or_else(|| testing_context.testing_actors.solvers[0].keypair().clone());
6565
let guardian_signature_info = create_guardian_signatures(
6666
testing_context,
6767
test_context,
@@ -77,7 +77,7 @@ pub async fn initialize_fast_market_order_shimful(
7777
&[
7878
FastMarketOrderState::SEED_PREFIX,
7979
&fast_market_order.digest().as_ref(),
80-
&fast_market_order.close_account_refund_recipient.as_ref(),
80+
&payer_signer.pubkey().as_ref(),
8181
],
8282
program_id,
8383
);
@@ -157,7 +157,7 @@ pub fn initialize_fast_market_order_shimful_instruction(
157157
&[
158158
FastMarketOrderState::SEED_PREFIX,
159159
&fast_market_order.digest().as_ref(),
160-
&fast_market_order.close_account_refund_recipient.as_ref(),
160+
&payer_signer.pubkey().as_ref(),
161161
],
162162
program_id,
163163
)

solana/modules/matching-engine-testing/tests/test_scenarios/create_and_close_fast_market_order.rs

Lines changed: 1 addition & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -114,47 +114,6 @@ pub async fn test_close_fast_market_order_fallback() {
114114
.await;
115115
}
116116

117-
/// Test that the close fast market order account works correctly for the fallback instruction
118-
#[tokio::test]
119-
pub async fn test_close_fast_market_order_fallback_with_custom_refund_recipient() {
120-
let vaa_args = vec![VaaArgs {
121-
post_vaa: false,
122-
..VaaArgs::default()
123-
}];
124-
let (testing_context, mut test_context) = setup_environment(
125-
ShimMode::VerifyAndPostSignature,
126-
TransferDirection::FromArbitrumToEthereum,
127-
Some(vaa_args),
128-
)
129-
.await;
130-
let solver_1 = &testing_context.testing_actors.solvers[1].clone();
131-
let solver_1_balance_before = solver_1.get_lamport_balance(&mut test_context).await;
132-
let testing_engine = TestingEngine::new(testing_context).await;
133-
let instruction_triggers = vec![
134-
InstructionTrigger::InitializeProgram(InitializeInstructionConfig::default()),
135-
InstructionTrigger::CreateCctpRouterEndpoints(
136-
CreateCctpRouterEndpointsInstructionConfig::default(),
137-
),
138-
InstructionTrigger::InitializeFastMarketOrderShim(
139-
InitializeFastMarketOrderShimInstructionConfig {
140-
close_account_refund_recipient: Some(solver_1.pubkey()),
141-
..InitializeFastMarketOrderShimInstructionConfig::default()
142-
},
143-
),
144-
InstructionTrigger::CloseFastMarketOrderShim(CloseFastMarketOrderShimInstructionConfig {
145-
close_account_refund_recipient_keypair: Some(solver_1.keypair()),
146-
..CloseFastMarketOrderShimInstructionConfig::default()
147-
}),
148-
];
149-
testing_engine
150-
.execute(&mut test_context, instruction_triggers, None)
151-
.await;
152-
let solver_1_balance_after = solver_1.get_lamport_balance(&mut test_context).await;
153-
assert!(
154-
solver_1_balance_after > solver_1_balance_before,
155-
"Solver 1 balance after is not greater than balance before"
156-
);
157-
}
158117

159118
/*
160119
Sad path tests Section
@@ -332,7 +291,6 @@ pub async fn test_multiple_fast_market_orders_can_be_opened_and_closed_by_differ
332291
)
333292
.await;
334293
let solver_1 = testing_context.testing_actors.solvers[1].clone();
335-
let solver_2 = testing_context.testing_actors.solvers[2].clone();
336294
let testing_engine = TestingEngine::new(testing_context).await;
337295
let instruction_triggers = vec![
338296
InstructionTrigger::InitializeProgram(InitializeInstructionConfig::default()),
@@ -357,6 +315,7 @@ pub async fn test_multiple_fast_market_orders_can_be_opened_and_closed_by_differ
357315
let instruction_triggers_1 = vec![InstructionTrigger::InitializeFastMarketOrderShim(
358316
InitializeFastMarketOrderShimInstructionConfig {
359317
fast_market_order_id: 1,
318+
payer_signer: Some(solver_1.keypair()),
360319
close_account_refund_recipient: Some(solver_1.pubkey()),
361320
..InitializeFastMarketOrderShimInstructionConfig::default()
362321
},
@@ -377,13 +336,6 @@ pub async fn test_multiple_fast_market_orders_can_be_opened_and_closed_by_differ
377336
fast_market_order_address: Some(fast_market_order_0_pubkey),
378337
..CloseFastMarketOrderShimInstructionConfig::default()
379338
}),
380-
InstructionTrigger::InitializeFastMarketOrderShim(
381-
InitializeFastMarketOrderShimInstructionConfig {
382-
fast_market_order_id: 2,
383-
close_account_refund_recipient: Some(solver_2.pubkey()),
384-
..InitializeFastMarketOrderShimInstructionConfig::default()
385-
},
386-
),
387339
];
388340
let current_state = testing_engine
389341
.execute(
@@ -398,12 +350,6 @@ pub async fn test_multiple_fast_market_orders_can_be_opened_and_closed_by_differ
398350
.fast_market_order_address;
399351
let instruction_triggers_3 = vec![
400352
InstructionTrigger::CloseFastMarketOrderShim(CloseFastMarketOrderShimInstructionConfig {
401-
close_account_refund_recipient_keypair: Some(solver_2.keypair()),
402-
fast_market_order_address: Some(fast_market_order_2_pubkey),
403-
..CloseFastMarketOrderShimInstructionConfig::default()
404-
}),
405-
InstructionTrigger::CloseFastMarketOrderShim(CloseFastMarketOrderShimInstructionConfig {
406-
close_account_refund_recipient_keypair: Some(solver_1.keypair()),
407353
fast_market_order_address: Some(fast_market_order_1_pubkey),
408354
..CloseFastMarketOrderShimInstructionConfig::default()
409355
}),

solana/programs/matching-engine/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub enum MatchingEngineError {
9292

9393
InvalidVerifyVaaShimProgram = 0x600,
9494

95-
// Fallback matching engine errors
95+
// V2 matching engine errors
9696
AccountAlreadyInitialized = 0x700,
9797
AccountNotWritable = 0x702,
9898
BorshDeserializationError = 0x704,

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ pub(super) fn process(
115115
// fast market order account.
116116
let payer_info = &accounts[0];
117117

118+
require_keys_eq!(
119+
*payer_info.key,
120+
fast_market_order.close_account_refund_recipient,
121+
MatchingEngineError::MismatchingCloseAccountRefundRecipient
122+
);
123+
118124
// These accounts will be used by the Verify VAA shim program.
119125
let from_endpoint = super::helpers::try_live_endpoint_account(&accounts[1], "from_endpoint")
120126
.map_err(|e: Error| e.with_account_name("from_endpoint"))?;
@@ -143,7 +149,7 @@ pub(super) fn process(
143149
&[
144150
FastMarketOrder::SEED_PREFIX,
145151
&fast_market_order_vaa_digest.as_ref(),
146-
fast_market_order.close_account_refund_recipient.as_ref(),
152+
payer_info.key.as_ref(),
147153
],
148154
&ID,
149155
);
@@ -162,8 +168,7 @@ pub(super) fn process(
162168
&[&[
163169
FastMarketOrder::SEED_PREFIX,
164170
&fast_market_order_vaa_digest.as_ref(),
165-
// TODO: Replace with payer_info.key.
166-
fast_market_order.close_account_refund_recipient.as_ref(),
171+
payer_info.key.as_ref(),
167172
&[fast_market_order_bump],
168173
]],
169174
)?;

solana/programs/matching-engine/src/state/fast_market_order.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub struct FastMarketOrderParams {
6464
pub max_fee: u64,
6565
pub init_auction_fee: u64,
6666
pub redeemer_message: [u8; 512],
67-
pub close_account_refund_recipient: Pubkey,
67+
pub close_account_refund_recipient: Pubkey, // Same as the payer
6868
pub vaa_sequence: u64,
6969
pub vaa_timestamp: u32,
7070
pub vaa_emitter_chain: u16,

0 commit comments

Comments
 (0)