Skip to content

transaction-status-client-types: Fix deserializer for SDKv2#8625

Merged
joncinque merged 1 commit intoanza-xyz:masterfrom
joncinque:ixerr-deserializer
Oct 29, 2025
Merged

transaction-status-client-types: Fix deserializer for SDKv2#8625
joncinque merged 1 commit intoanza-xyz:masterfrom
joncinque:ixerr-deserializer

Conversation

@joncinque
Copy link
Copy Markdown

@joncinque joncinque commented Oct 22, 2025

Problem

The InstructionError deserializer within UiTransactionError fails to deserialize errors from SDKv2 because BorshIoError changed from being a newtype with string to a unit enum variant.

Summary of changes

If deserialization fails, check to see if it's an old BorshIoError, and change to the new variation if so.

Also includes a test using the old and new SDKs.

Closes #8582 Fixes #8536

Note: the backport will be the exact same thing for v3.0, but v2.3 will change the logic to check for a string BorshIoError and replace it with {"BorshIoError": ""}, and will involve bringing in sdk v3 for the test.

cc @BriungRi

@mergify
Copy link
Copy Markdown

mergify Bot commented Oct 22, 2025

Backports to the stable branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule.

@mergify
Copy link
Copy Markdown

mergify Bot commented Oct 22, 2025

Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.2%. Comparing base (bac25c1) to head (7ad91b1).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##           master    #8625     +/-   ##
=========================================
- Coverage    83.2%    83.2%   -0.1%     
=========================================
  Files         859      859             
  Lines      373629   373646     +17     
=========================================
- Hits       311006   310996     -10     
- Misses      62623    62650     +27     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joncinque
Copy link
Copy Markdown
Author

The Cargo.lock changes in this PR are a bit obnoxious because we're bringing in multiple packages of the same name. I could also change the test to just use json values to avoid pulling in multiple versions of the same dependency.

@t-nelson what do you think? Is it too much to backport if there's a big Cargo.lock change?

@joncinque
Copy link
Copy Markdown
Author

We'll also need to backport #6435 to v2.3 so that v2.3 can deserialize blocks produced by v3.0, mostly while RPCs and clients upgrade.

@fanatid
Copy link
Copy Markdown

fanatid commented Oct 23, 2025

Why don't fix ser/deser in solana-sdk repo for TransactionError?

Comment thread Cargo.lock Outdated
Comment on lines +11585 to +11691
"solana-instruction",
"solana-instruction 2.3.0",
"solana-instruction 3.0.0",
"solana-message",
"solana-pubkey",
"solana-pubkey 3.0.0",
"solana-reward-info",
"solana-signature",
"solana-transaction",
"solana-transaction-context",
"solana-transaction-error",
"solana-transaction-error 2.2.1",
"solana-transaction-error 3.0.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

these are the only real changes right? rest is just addition of their dep entries and the version added to existing entries for all?

i can probably be fine with this. will give @bw-solana and @sakridge a chance to chime in tho

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yep that's exactly right. I'm totally fine with inlining the JSON representation of the v2 error though to avoid all this

t-nelson
t-nelson previously approved these changes Oct 23, 2025
@fanatid
Copy link
Copy Markdown

fanatid commented Oct 24, 2025

I created PR that should allow to InstructionError process both old and new format for BorshIoError: anza-xyz/solana-sdk#404

If you don't want to use custom Visitor created with macros then probably would be better to check type of value (Object vs String) instead of error based logic.

@joncinque
Copy link
Copy Markdown
Author

If you don't want to use custom Visitor created with macros then probably would be better to check type of value (Object vs String) instead of error based logic.

Thanks for the call-out, done!

I also removed the old dependencies, I think they were going to just be a huge hassle in the long-run, and will make a backport to v3 easier.

@joncinque joncinque requested a review from t-nelson October 27, 2025 23:42
// This checks compatibility across SDK versions where BorshIoError is
// a unit variant in v3 and newtype variant in v2.
let old_error =
to_value(serde_json::json!({"InstructionError": [0, {"BorshIoError": "Unknown"}]}))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

won't this lend to breakage should we wind up with a typo here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I take your point that we don't get a compile-error from a misspelling here, which we would for InstructionError::BorshIoError. On the flip-side, if the test starts failing because we made a typo, that means the test is doing its job, right?

We'd only get a false positive if we change this string, the one on line 316, but not the one on line 317. While that's possible, I'd argue that it's very unlikely. What do you think?

@joncinque joncinque removed the v2.3 label Oct 29, 2025
@joncinque
Copy link
Copy Markdown
Author

I removed the v2.3 label -- we'll fix the issue at the SDK level for v2 with anza-xyz/solana-sdk#410

For master and v3, I'd like to land this PR, which will avoid bringing std back into instruction-error

#### Problem

The InstructionError deserializer within UiTransactionError fails to
deserialize errors from SDKv2 because `BorshIoError` changed from being
a newtype with string to a unit enum variant.

#### Summary of changes

If deserialization fails, check to see if it's an old `BorshIoError`,
and change to the new variation if so.

Also include a test using the old and new error formats.
@joncinque joncinque added this pull request to the merge queue Oct 29, 2025
Merged via the queue into anza-xyz:master with commit ed4cbad Oct 29, 2025
44 checks passed
@joncinque joncinque deleted the ixerr-deserializer branch October 29, 2025 17:45
mergify Bot pushed a commit that referenced this pull request Oct 29, 2025
#### Problem

The InstructionError deserializer within UiTransactionError fails to
deserialize errors from SDKv2 because `BorshIoError` changed from being
a newtype with string to a unit enum variant.

#### Summary of changes

If deserialization fails, check to see if it's an old `BorshIoError`,
and change to the new variation if so.

Also include a test using the old and new error formats.

Co-authored-by: Brian Li <brnli7@gmail.com>
(cherry picked from commit ed4cbad)
joncinque added a commit that referenced this pull request Oct 29, 2025
…ckport of #8625) (#8759)

transaction-status-client-types: Fix deserializer for SDKv2 (#8625)

#### Problem

The InstructionError deserializer within UiTransactionError fails to
deserialize errors from SDKv2 because `BorshIoError` changed from being
a newtype with string to a unit enum variant.

#### Summary of changes

If deserialization fails, check to see if it's an old `BorshIoError`,
and change to the new variation if so.

Also include a test using the old and new error formats.


(cherry picked from commit ed4cbad)

Co-authored-by: Jon C <me@jonc.dev>
Co-authored-by: Brian Li <brnli7@gmail.com>
rustopian pushed a commit to rustopian/agave that referenced this pull request Nov 20, 2025
…#8625)

#### Problem

The InstructionError deserializer within UiTransactionError fails to
deserialize errors from SDKv2 because `BorshIoError` changed from being
a newtype with string to a unit enum variant.

#### Summary of changes

If deserialization fails, check to see if it's an old `BorshIoError`,
and change to the new variation if so.

Also include a test using the old and new error formats.

Co-authored-by: Brian Li <brnli7@gmail.com>
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.

Unable to fetch block with sdk client version 2

5 participants