Skip to content

feat(cli): use transaction v1 when writing program buffers - #5095

Merged
jamie-osec merged 7 commits into
otter-sec:masterfrom
rute-sophie:txv1
Nov 2, 2026
Merged

jamie-osec merged 7 commits into
otter-sec:masterfrom
rute-sophie:txv1

Conversation

@rute-sophie

@rute-sophie rute-sophie commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR changes the program deployment to use transaction V1 when writing the program buffers and chunks the write instructions in 3 per transaction.
In the future, when anza-xyz/agave#15356 (comment) is solved, we will be able to better use the transaction data.

Tested on devnet: https://explorer.solana.com/tx/jXzxi4C1sUkUcw7cBEnx6buMJoWdzJz3SzzMC6XxbJNRfFwAcs4nFQ3qv9KKUrDQ3mkGm7aptbofWcHY4Nysay2?cluster=devnet

Additional changes

The new send_and_confirm_transactions_in_parallel_v3 doesn't dedup like its predecessor nor it blocks in-place so it required some extra plumbing similar to what was in the send_and_confirm_transactions_in_parallel_blocking_v2 impl.

Using the new compute unit limit and loaded data size limit in transaction v1 headers. Without a valid loaded data size the transaction is discarded.

@vercel

vercel Bot commented Sep 25, 2026

Copy link
Copy Markdown

@rute-sophie is attempting to deploy a commit to the OtterSec Team on Vercel.

A member of the Team first needs to authorize it.

@jamie-osec

Copy link
Copy Markdown
Collaborator

Can you address the failures?

@rute-sophie

Copy link
Copy Markdown
Contributor Author

Hi @jamie-osec , I analysed the test failures and found one blocker plus a rust MSRV that needs some input before further action.

Currently, the most recent version of litesvm = "0.17.0" requires solana-address-lookup-table-interface = "~3.1.0". which is incompatible with solana-account-decoder = "^4.3.0" that is required for the transaction v1. This should be solved once litesvm PR 429 is merged and a new version published.

The template tests are failing due to rust MSVR. It is currently applied in 4 different places on that specific template matrix: ./rust-toolchain.toml, ./Cargo.toml, ./programs/prog_name/Cargo.toml and ./tests/src/Cargo.toml.
The only way for the program to compile and for tests to run on this template setup is to have rust-toolchain.toml and the test crate Cargo.toml specify the rust version as 1.97.1 as required by 4.3.0 solana crates while leaving the workspace and program versions to the current solana's rust fork version.

Is it acceptable to have such a mix of versions (e.g. by defining a SOLANA_MSRV next to the current ANCHOR_MSVR here https://github.com/otter-sec/anchor/blob/anchor-next/cli/src/rust_template.rs#L21 and use it in the right place) or do you suggest a different approach?

@jamie-osec

jamie-osec commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

specify the rust version as 1.97.1 as required by 4.3.0 solana crates

Which crates require this? Upstream still seems to pin 1.89.0 as the MSRV: https://github.com/anza-xyz/solana-sdk/blob/fc89c122394e003d05b52aca81a6fb8ba5a8d306/Cargo.toml#L125

You'll also need to rebase on master, as there were recently a lot of changes to dependencies, introducing 4.3.0 crates to the workspace behind a feature flag.

@gwalen

gwalen commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

hey @jamie-osec
I think the link you shared points to anza-xyz/solana-sdk rather than Agave, so the 1.89.0 there applies to the sdk crates.

The 4.3.0 RPC/client crates come from the anza-xyz/agave, which sets a higher MSRV for its whole workspace.

Agave workspace root 4.3.0, sets rust-version = "1.97.1":
https://github.com/anza-xyz/agave/blob/v4.3.0/Cargo.toml#L147

Each of this crates inherits it with rust-version = { workspace = true }:

These are direct dependencies of anchor-cli and anchor-client

@gwalen

gwalen commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Hi @rute-sophie, I think this PR depends on (and now partially duplicates) #5123, which bumps anchor-next to Agave 4.3 and litesvm 0.17.
#5123 is also waiting on the LiteSVM PR you mentioned: LiteSVM/litesvm#429

@jamie-osec

jamie-osec commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Oh I just noticed you're targeting anchor-next here. CLI development happens in master; please retarget your branch. This will likely produce a lot of conflicts, the anchor-next CLI is very out of date.

We recently updated our toolchains, so we can look into bumping our MSRV to a more recent version.

@rute-sophie

Copy link
Copy Markdown
Contributor Author

@jamie-osec @gwalen So I will first wait for #5123 to be merged, then I will rebase and resume my work

@jamie-osec

Copy link
Copy Markdown
Collaborator

I have closed that PR because it
a) Targets CLI changes to anchor-next, which is incorrect
b) The work to update crates to 4.3 has already been done on master (behind a feature flag)

There shouldn't be any other Anchor-side blockers to this, just make sure to rebase and retarget the PR on master.

@jamie-osec

Copy link
Copy Markdown
Collaborator

@rute-sophie Are you currently working on this?

@rute-sophie

Copy link
Copy Markdown
Contributor Author

Yes, almost done testing. I will update the PR today

@rute-sophie
rute-sophie changed the base branch from anchor-next to master October 7, 2026 00:14
@rute-sophie

Copy link
Copy Markdown
Contributor Author

Hi @jamie-osec, I've updated the PR and retargeted the merge to master.

Took me a while longer as I wanted to preserve the QUIC connection, but the API change to solana-tpu-client-next was too drastic and my initial implementation was not working properly.

Let me know if you want any changes.

Comment thread cli/Cargo.toml Resolved
@jamie-osec

Copy link
Copy Markdown
Collaborator

This doesn't compile on v4 for me:

$ cargo +stable build -p anchor-cli --locked --no-default-features --features solana-v4
[ ... ]
error[E0308]: mismatched types
    --> cli/src/program.rs:2994:38
     |
2994 |             if instructions.len() == instructions_per_transaction {
     |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `u32`

error[E0277]: can't compare `usize` with `u32`
    --> cli/src/program.rs:2994:35
     |
2994 |             if instructions.len() == instructions_per_transaction {
     |                                   ^^ no implementation for `usize == u32`
     |
     = help: the trait `PartialEq<u32>` is not implemented for `usize`
help: `usize` implements trait `PartialEq<Rhs>`
    --> /rustc/48a229ceaefd4985c50990b14116b6d856af0985/library/core/src/cmp.rs:1876:12
     |
     = note: `PartialEq`
    ::: /rustc/48a229ceaefd4985c50990b14116b6d856af0985/library/core/src/cmp.rs:1900:5
     |
     = note: in this macro invocation
     |
    ::: /Users/jamie/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/serde_json-1.0.151/src/value/partial_eq.rs:76:13
     |
  76 |               impl PartialEq<Value> for $ty {
     |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `PartialEq<serde_json::Value>`
...
  97 | / partialeq_numeric! {
  98 | |     eq_i64[i8 i16 i32 i64 isize]
  99 | |     eq_u64[u8 u16 u32 u64 usize]
 100 | |     eq_f32[f32]
 101 | |     eq_f64[f64]
 102 | |     eq_bool[bool]
 103 | | }
     | |_- in this macro invocation
     = note: this error originates in the macro `partial_eq_impl` which comes from the expansion of the macro `partialeq_numeric` (in Nightly builds, run with -Z macro-backtrace for more info)

Comment thread cli/src/program.rs Resolved
Comment thread cli/src/program.rs Resolved
- batch 3 write instructions per transaction with max data size (1232-bpf loader instruction overhead)
- add new transaction v1 compute unit and data loaded size limits
- adopt the new `send_and_confirm_transactions_in_parallel_v3` API from solana_client v4.3
@rute-sophie

Copy link
Copy Markdown
Contributor Author

@jamie-osec rebased and implemented your suggestion. Let me know if you have more suggestions.

Comment thread cli/src/program.rs Resolved
Comment thread cli/Cargo.toml
# anchor-lang/anchor-client and Cargo unifies features across the workspace, so
# it has to follow the same Solana cohort as everything else. See the comment
# block in the root Cargo.toml.
default = ["solana-v3"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that this won't actually be enabled by default. However, I think we should explore potentially making solana-v4 the default for the CLI in the next release.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a followup PR of course

@jamie-osec
jamie-osec merged commit 9b5bddb into otter-sec:master Nov 2, 2026
119 of 122 checks passed
@jamie-osec jamie-osec added this to the v1.2.3 milestone Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants