From 120a7e433f006641a43c23c63e4dda4edba75503 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 10 Jun 2021 23:49:03 +0000 Subject: [PATCH] Warn about InstructionError meta (#17864) (#17878) (cherry picked from commit fa6bdd2d12bac5e8217cb491b60f32aa24b541cc) Co-authored-by: Jack May --- sdk/program/src/instruction.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sdk/program/src/instruction.rs b/sdk/program/src/instruction.rs index a158d1883f..64e493129f 100644 --- a/sdk/program/src/instruction.rs +++ b/sdk/program/src/instruction.rs @@ -9,6 +9,14 @@ use serde::Serialize; use thiserror::Error; /// Reasons the runtime might have rejected an instruction. +/// +/// Instructions errors are included in the bank hashes and therefore are +/// included as part of the transaction results when determining consensus. +/// Because of this, members of this enum must not be removed, but new ones can +/// be added. Also, it is crucial that meta-information if any that comes along +/// with an error be consistent across software versions. For example, it is +/// dangerous to include error strings from 3rd party crates because they could +/// change at any time and changes to them are difficult to detect. #[derive( Serialize, Deserialize, Debug, Error, PartialEq, Eq, Clone, AbiExample, AbiEnumVisitor, )] @@ -197,6 +205,14 @@ pub enum InstructionError { IncorrectAuthority, /// Failed to serialize or deserialize account data + /// + /// Warning: This error should never be emitted by the runtime. + /// + /// This error includes strings from the underlying 3rd party Borsh crate + /// which can be dangerous beause the error strings could change across + /// Borsh versions. Only programs can use this error because they are + /// consistent across Solana software versions. + /// #[error("Failed to serialize or deserialize account data: {0}")] BorshIoError(String),