solana-cli: read v1 transactions in shreds payments - #4304
Conversation
A payer who funds with a v1 transaction currently fails the whole listing with error -32015.
There was a problem hiding this comment.
🔵 Needs a closer look
The new instruction account filter has a string comparison bug and the amount conversion can overflow and produce incorrect negative values.
Pull request overview
This PR updates the offchain doublezero-solana shreds payments command so it can parse funding events from Solana v1 transactions by requesting transaction version 1 and reading JsonParsed instruction data.
Changes:
- Request
JsonParsedtransactions and setmax_supported_transaction_versionto1when fetching transactions for escrow signatures. - Add a
payment_eventshelper that extracts funding events from partially decodedJsonParsedinstructions. - Add unit tests for v1
JsonParsedfund parsing, plus addbs58as a dependency and document the behavior change in the changelog.
File summaries
| File | Description |
|---|---|
| offchain/crates/solana-cli/src/command/shreds/payments.rs | Switch transaction fetch config, add payment_events parser, and add unit tests for v1 JsonParsed bodies. |
| offchain/crates/solana-cli/CHANGELOG.md | Document the shreds payments v1 + JsonParsed behavior change. |
| offchain/crates/solana-cli/Cargo.toml | Add bs58 dependency for base58 instruction data decode/encode. |
Review details
Suppressed comments (2)
offchain/crates/solana-cli/src/command/shreds/payments.rs:123
- Issue
The escrow filter compares a newly allocated string to*account, which moves a value out of a reference and can fail to compile.
Context
The command scans many instructions per transaction, so the current nested loop also allocates one string per escrow key for every account entry.
Proposed Fix
Build a set of escrow key strings once per transaction and use contains to test each instruction account.
.expect("discriminator serialization");
let config = RpcProgramAccountsConfig {
filters: Some(vec![
RpcFilterType::Memcmp(Memcmp::new_raw_bytes(0, escrow_disc_bytes)),
RpcFilterType::Memcmp(Memcmp::new_raw_bytes(
offchain/crates/solana-cli/src/command/shreds/payments.rs:133
- Issue
The code casts au64amount toi64withas, so large values can wrap and become negative.
Context
A v1 fund instruction can encode an amount above i64::MAX, which makes the running balance incorrect.
Proposed Fix
Convert the amount with i64::try_from and skip the event when the value does not fit.
encoding: Some(UiAccountEncoding::Base64),
..Default::default()
},
..Default::default()
};
- Files reviewed: 4/5 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Summary
doublezero-solana shreds paymentsasks the Solana node for version 1 when it fetches a landed fund.Testing
doublezero-solana shreds payments --device-code <code> --client-ip <ip>.