Repository navigation
[EASY] Decode custom program error codes back into SettlementError - #160
Merged
Merged
Conversation
squadgazzz
marked this pull request as ready for review
September 18, 2026 12:21
PeterHackz
pushed a commit
to nexroute/services
that referenced
this pull request
Sep 22, 2026
…rotocol#4940) # Description A settlement that fails simulation or submission surfaces as `InstructionError(2, Custom(16))`, and whoever reads it opens the interface crate to learn that 16 means `OrderExpired`. cowprotocol/solana-programs#160 added the reverse conversion, so the failed-simulation and failed-submission errors now carry the decoded `SettlementError` inside them, and the settle task's single failure log prints it, for example `settlement simulation failed: ..., settlement error Some(OrderExpired)`. The simulation's own log line keeps only the raw program logs, which removed a duplicate: previously every simulation failure logged twice, once with the details and once from the settle task. Only the settlement program's own instruction is decoded: a foreign instruction (a Jupiter route step, for example) fails with its own custom codes, and a code newer than the interface crate decodes to nothing. The interface crate is patched to the merged commit until the next release, the patch section carries the pointer. The wire error body the autopilot receives keeps its static per-kind description. # Changes - `FailedToSubmit` and `SimulationFailed` carry the decoded `SettlementError` when the failing instruction belongs to the settlement program, and the settle failure log prints it - Simulation failures log once, the simulation line keeps only the program logs - `cow-settlement-interface` patched to the commit with the decoding until it releases # How to test New unit tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The conversions only went one way: a consumer reading a simulation result or transaction meta gets
InstructionError(index, Custom(16))and has to open this file to learn it meansOrderExpired. This adds the reverse,TryFrom<u32> for SettlementError, so the services driver can log the variant name next to raw errors. An unknown code (a newer program than the consumer's interface crate) comes back unchanged in theErr. A test round-trips the whole contiguous discriminant range so a new variant cannot silently miss the mapping.