Skip to content

Commit 38eb457

Browse files
martinsander00bgm-malbeclabs
authored andcommitted
Remove the fund-seat instruction from the Solana SDK (malbeclabs/doublezero-offchain#416)
Closes malbeclabs/infra#2410. ## Summary - The Solana SDK no longer builds a fund-seat instruction. - `doublezero-solana shreds payments` still reads leftover fund transactions so escrow history stays intact. - Close and withdraw stay so a holder can pull unused USDC.
1 parent 69dc788 commit 38eb457

4 files changed

Lines changed: 19 additions & 84 deletions

File tree

offchain/crates/solana-cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
- `shreds payments`: keep reading leftover fund-seat transactions after the SDK drops that instruction (malbeclabs/infra#2411)
1011
- `shreds pay`: remove the command. `shreds withdraw`, `list`, `payments`, and `price` stay (malbeclabs/infra#2410)
1112
- `shreds`: collapse `pay`'s `SLOT_DURATION_SECS` and `prepare-offchain-message`'s `SLOT_DURATION_MS` into one `NOMINAL_SLOT_DURATION` at 350ms, matching mainnet-beta from epoch 1020 (2026-08-21). Deliberately cluster-independent, because a `~` prefixed estimate and a deadline slot the CLI and operator must both compute want reproducibility over accuracy. `--valid-for 1h` now resolves to 10,285 slots rather than 9,000, and the epoch-remaining estimates shrink by an eighth. Testnet runs at 200ms, so its estimates stay wrong in the other direction, and SIMD-0525 will need one more bump here (malbeclabs/infra#2317)
1213
- `shreds validator-client-rewards`: read the `ValidatorClientRewards` account through the SDK's zero-copy mirror instead of the hand-written byte-offset parser. Every subcommand now requires at least 184 bytes of account data rather than 116

offchain/crates/solana-cli/src/command/shreds/payments.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ impl std::fmt::Display for EventType {
8383
}
8484
}
8585

86+
const LEGACY_FUND_PAYMENT_ESCROW_USDC: [u8; 8] = [111, 6, 96, 2, 121, 92, 68, 147];
87+
88+
fn parse_legacy_fund_payment_escrow_usdc(data: &[u8]) -> Option<u64> {
89+
if data.len() < 16 || data[..8] != LEGACY_FUND_PAYMENT_ESCROW_USDC {
90+
return None;
91+
}
92+
Some(u64::from_le_bytes(data[8..16].try_into().ok()?))
93+
}
94+
8695
impl PaymentsCommand {
8796
pub async fn execute(
8897
self,
@@ -194,14 +203,16 @@ impl PaymentsCommand {
194203
continue;
195204
}
196205

206+
if let Some(amount) = parse_legacy_fund_payment_escrow_usdc(&ix.data) {
207+
events.push(PaymentEvent {
208+
event_type: EventType::Funded,
209+
amount_micro: amount as i64,
210+
block_time: tx_response.block_time,
211+
});
212+
continue;
213+
}
214+
197215
match ShredSubscriptionInstructionData::try_from_slice(&ix.data) {
198-
Ok(ShredSubscriptionInstructionData::FundPaymentEscrowUsdc(amount)) => {
199-
events.push(PaymentEvent {
200-
event_type: EventType::Funded,
201-
amount_micro: amount as i64,
202-
block_time: tx_response.block_time,
203-
});
204-
}
205216
// TODO: ClosePaymentEscrow (withdrawal) — the actual
206217
// refunded amount is in the tx log message "Withdrew {}
207218
// USDC from payment escrow to refund account". Parse that

offchain/crates/solana-sdk/src/shred_subscription/instruction/account.rs

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -366,71 +366,6 @@ impl From<CheckCliVersionAccounts> for Vec<AccountMeta> {
366366
}
367367
}
368368

369-
/// Accounts for the `FundPaymentEscrowUsdc` instruction (10 accounts).
370-
#[derive(Debug, Clone, PartialEq, Eq)]
371-
pub struct FundPaymentEscrowUsdcAccounts {
372-
pub program_config_key: Pubkey,
373-
pub execution_controller_key: Pubkey,
374-
pub metro_history_key: Pubkey,
375-
pub device_history_key: Pubkey,
376-
pub client_seat_key: Pubkey,
377-
pub payment_escrow_key: Pubkey,
378-
pub device_history_usdc_token_account_key: Pubkey,
379-
pub source_usdc_token_account_key: Pubkey,
380-
pub transfer_authority_key: Pubkey,
381-
}
382-
383-
impl FundPaymentEscrowUsdcAccounts {
384-
pub fn new(
385-
exchange_key: &Pubkey,
386-
device_key: &Pubkey,
387-
client_ip_bits: u32,
388-
withdraw_authority_key: &Pubkey,
389-
usdc_mint_key: &Pubkey,
390-
source_usdc_token_account_key: &Pubkey,
391-
transfer_authority_key: &Pubkey,
392-
) -> Self {
393-
let client_seat_key = state::find_client_seat_address(device_key, client_ip_bits).0;
394-
let device_history_key = state::find_device_history_address(device_key).0;
395-
Self {
396-
program_config_key: state::find_program_config_address().0,
397-
execution_controller_key: state::find_execution_controller_address().0,
398-
metro_history_key: state::find_metro_history_address(exchange_key).0,
399-
device_history_key,
400-
client_seat_key,
401-
payment_escrow_key: state::find_payment_escrow_address(
402-
&client_seat_key,
403-
withdraw_authority_key,
404-
)
405-
.0,
406-
device_history_usdc_token_account_key: state::find_token_pda_address(
407-
&device_history_key,
408-
usdc_mint_key,
409-
)
410-
.0,
411-
source_usdc_token_account_key: *source_usdc_token_account_key,
412-
transfer_authority_key: *transfer_authority_key,
413-
}
414-
}
415-
}
416-
417-
impl From<FundPaymentEscrowUsdcAccounts> for Vec<AccountMeta> {
418-
fn from(accounts: FundPaymentEscrowUsdcAccounts) -> Self {
419-
vec![
420-
AccountMeta::new_readonly(accounts.program_config_key, false),
421-
AccountMeta::new(accounts.execution_controller_key, false),
422-
AccountMeta::new_readonly(accounts.metro_history_key, false),
423-
AccountMeta::new_readonly(accounts.device_history_key, false),
424-
AccountMeta::new(accounts.client_seat_key, false),
425-
AccountMeta::new(accounts.payment_escrow_key, false),
426-
AccountMeta::new(accounts.device_history_usdc_token_account_key, false),
427-
AccountMeta::new(accounts.source_usdc_token_account_key, false),
428-
AccountMeta::new_readonly(accounts.transfer_authority_key, true),
429-
AccountMeta::new_readonly(spl_token_interface::ID, false),
430-
]
431-
}
432-
}
433-
434369
/// Accounts for the `InitializeClaimHolding` instruction (6 accounts).
435370
#[derive(Debug, Clone, PartialEq, Eq)]
436371
pub struct InitializeClaimHoldingAccounts {

offchain/crates/solana-sdk/src/shred_subscription/instruction/mod.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ pub enum ShredSubscriptionInstructionData {
3434
InitializePaymentEscrow,
3535
/// Close a payment escrow and refund any remaining USDC.
3636
ClosePaymentEscrow,
37-
/// Fund a payment escrow with USDC.
38-
FundPaymentEscrowUsdc(u64),
3937
/// Request instant allocation for a funded seat (skips auction settlement).
4038
RequestInstantSeatAllocation,
4139
/// Request instant seat withdrawal.
@@ -88,8 +86,6 @@ impl ShredSubscriptionInstructionData {
8886
Discriminator::new_sha2(b"dz::ix::initialize_payment_escrow");
8987
pub const CLOSE_PAYMENT_ESCROW: Discriminator<DISCRIMINATOR_LEN> =
9088
Discriminator::new_sha2(b"dz::ix::close_payment_escrow");
91-
pub const FUND_PAYMENT_ESCROW_USDC: Discriminator<DISCRIMINATOR_LEN> =
92-
Discriminator::new_sha2(b"dz::ix::fund_payment_escrow_usdc");
9389
pub const REQUEST_INSTANT_SEAT_ALLOCATION: Discriminator<DISCRIMINATOR_LEN> =
9490
Discriminator::new_sha2(b"dz::ix::request_instant_seat_allocation");
9591
pub const REQUEST_INSTANT_SEAT_WITHDRAWAL: Discriminator<DISCRIMINATOR_LEN> =
@@ -121,10 +117,6 @@ impl BorshSerialize for ShredSubscriptionInstructionData {
121117
}
122118
Self::InitializePaymentEscrow => Self::INITIALIZE_PAYMENT_ESCROW.serialize(writer),
123119
Self::ClosePaymentEscrow => Self::CLOSE_PAYMENT_ESCROW.serialize(writer),
124-
Self::FundPaymentEscrowUsdc(amount) => {
125-
Self::FUND_PAYMENT_ESCROW_USDC.serialize(writer)?;
126-
amount.serialize(writer)
127-
}
128120
Self::RequestInstantSeatAllocation => {
129121
Self::REQUEST_INSTANT_SEAT_ALLOCATION.serialize(writer)
130122
}
@@ -189,10 +181,6 @@ impl BorshDeserialize for ShredSubscriptionInstructionData {
189181
}
190182
Self::INITIALIZE_PAYMENT_ESCROW => Ok(Self::InitializePaymentEscrow),
191183
Self::CLOSE_PAYMENT_ESCROW => Ok(Self::ClosePaymentEscrow),
192-
Self::FUND_PAYMENT_ESCROW_USDC => {
193-
let amount = u64::deserialize_reader(reader)?;
194-
Ok(Self::FundPaymentEscrowUsdc(amount))
195-
}
196184
Self::REQUEST_INSTANT_SEAT_ALLOCATION => Ok(Self::RequestInstantSeatAllocation),
197185
Self::REQUEST_INSTANT_SEAT_WITHDRAWAL => Ok(Self::RequestInstantSeatWithdrawal),
198186
Self::REQUEST_PRORATED_INSTANT_SEAT_WITHDRAWAL => {

0 commit comments

Comments
 (0)