Warn about InstructionError meta (#17864)

This commit is contained in:
Jack May 2021-06-10 15:13:56 -07:00 committed by GitHub
parent d272468a14
commit fa6bdd2d12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -9,6 +9,14 @@ use serde::Serialize;
use thiserror::Error; use thiserror::Error;
/// Reasons the runtime might have rejected an instruction. /// 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( #[derive(
Serialize, Deserialize, Debug, Error, PartialEq, Eq, Clone, AbiExample, AbiEnumVisitor, Serialize, Deserialize, Debug, Error, PartialEq, Eq, Clone, AbiExample, AbiEnumVisitor,
)] )]
@ -197,6 +205,14 @@ pub enum InstructionError {
IncorrectAuthority, IncorrectAuthority,
/// Failed to serialize or deserialize account data /// 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}")] #[error("Failed to serialize or deserialize account data: {0}")]
BorshIoError(String), BorshIoError(String),