Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Custom error decoder #3783

Merged
merged 5 commits into from
Apr 25, 2019

Conversation

CriesofCarrots
Copy link
Contributor

Problem

The solana-sdk offers an easy way to encode custom program instruction errors (into InstructionError::CustomError(<u32>)), but no easy way to decode them.

Summary of Changes

Add DecodeError trait to solana-sdk
Impl DecodeError for relevant solana native programs
Plumb through wallet to log and return decoded custom errors

FYI, @rob-solana

@CriesofCarrots CriesofCarrots requested a review from mvines April 15, 2019 19:14
@CriesofCarrots
Copy link
Contributor Author

There's a clippy error in the num_derive crate (rust-num/num-derive#20). Because it's in a proc macro, it can't be narrowly ignored. There's a fix coming in clippy (rust-lang/rust-clippy#3932), but it hasn't landed yet, and it doesn't look like it's in Rust-1.34 clippy either.
... hence the ugly, module-level ignores.
On pr merge, will file issue to track and improve.

@codecov
Copy link

codecov bot commented Apr 15, 2019

Codecov Report

Merging #3783 into master will decrease coverage by 0.1%.
The diff coverage is 39.5%.

@@           Coverage Diff            @@
##           master   #3783     +/-   ##
========================================
- Coverage    77.6%   77.5%   -0.2%     
========================================
  Files         162     164      +2     
  Lines       27737   27806     +69     
========================================
+ Hits        21533   21552     +19     
- Misses       6204    6254     +50

Copy link
Contributor

@mvines mvines left a comment

Choose a reason for hiding this comment

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

oops, I didn't see this review request until now. looks great

@CriesofCarrots CriesofCarrots force-pushed the custom-err-decoder branch 2 times, most recently from f0c3e3d to f9f2706 Compare April 25, 2019 17:05
@CriesofCarrots
Copy link
Contributor Author

There's a clippy error in the num_derive crate (rust-num/num-derive#20). Because it's in a proc macro, it can't be narrowly ignored. There's a fix coming in clippy (rust-lang/rust-clippy#3932), but it hasn't landed yet, and it doesn't look like it's in Rust-1.34 clippy either.
... hence the ugly, module-level ignores.
On pr merge, will file issue to track and improve.

Update: num_derive is fixed, woot! Rebased and removed the ugly clippy fix :)

@CriesofCarrots CriesofCarrots added the automerge Merge this Pull Request automatically once CI passes label Apr 25, 2019
@solana-grimes solana-grimes merged commit 5a79676 into solana-labs:master Apr 25, 2019
@CriesofCarrots CriesofCarrots deleted the custom-err-decoder branch April 25, 2019 17:42
ryoqun pushed a commit to ryoqun/solana that referenced this pull request Dec 4, 2024
solana-labs#3783)

* Adding additional logging when overflow occurs in calculate_stake_rewards
No change in functional behavior

* Updated code to use expects statements, and test case macros based on review feedback

* Resolving Performance Degredation by removing formatted output
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants