fuel_tx/transaction/validity/
error.rs

1use crate::UtxoId;
2use fuel_types::{
3    AssetId,
4    ContractId,
5    MessageId,
6};
7
8/// The error returned during the checking of the transaction's validity rules.
9#[derive(
10    Debug,
11    Clone,
12    PartialEq,
13    Eq,
14    Hash,
15    derive_more::Display,
16    serde::Serialize,
17    serde::Deserialize,
18)]
19#[non_exhaustive]
20pub enum ValidityError {
21    /// The actual and calculated metadata of the transaction mismatch.
22    TransactionMetadataMismatch,
23    /// Transaction doesn't have spendable input message or coin.
24    NoSpendableInput,
25    InputWitnessIndexBounds {
26        index: usize,
27    },
28    InputPredicateEmpty {
29        index: usize,
30    },
31    InputPredicateLength {
32        index: usize,
33    },
34    InputPredicateDataLength {
35        index: usize,
36    },
37    InputPredicateOwner {
38        index: usize,
39    },
40    InputInvalidSignature {
41        index: usize,
42    },
43    InputContractAssociatedOutputContract {
44        index: usize,
45    },
46    InputMessageDataLength {
47        index: usize,
48    },
49    DuplicateInputUtxoId {
50        utxo_id: UtxoId,
51    },
52    DuplicateMessageInputId {
53        message_id: MessageId,
54    },
55    DuplicateInputContractId {
56        contract_id: ContractId,
57    },
58    OutputContractInputIndex {
59        index: usize,
60    },
61    /// One of inputs' `AssetId` is not base asset id.
62    TransactionInputContainsNonBaseAssetId {
63        index: usize,
64    },
65    /// One of inputs is a `Input::Contract` when it is not allowed.
66    TransactionInputContainsContract {
67        index: usize,
68    },
69    /// One of inputs contains retryable message when it is not allowed.
70    TransactionInputContainsMessageData {
71        index: usize,
72    },
73    /// One of outputs is a `Output::Contract` when it is not allowed.
74    TransactionOutputContainsContract {
75        index: usize,
76    },
77    /// One of outputs is a `Output::Variable` when it is not allowed.
78    TransactionOutputContainsVariable {
79        index: usize,
80    },
81    /// One of `Output::Change` outputs uses a non-base asset id.
82    TransactionChangeChangeUsesNotBaseAsset {
83        index: usize,
84    },
85    TransactionCreateOutputContractCreatedDoesntMatch {
86        index: usize,
87    },
88    TransactionCreateOutputContractCreatedMultiple {
89        index: usize,
90    },
91    TransactionCreateBytecodeLen,
92    TransactionCreateBytecodeWitnessIndex,
93    TransactionCreateStorageSlotMax,
94    TransactionCreateStorageSlotOrder,
95    TransactionScriptLength,
96    TransactionScriptDataLength,
97    /// The output contains a `Output::ContractCreated` which is not allowed.
98    TransactionOutputContainsContractCreated {
99        index: usize,
100    },
101    /// The block height of the checking doesn't match the transaction's block height.
102    /// `Mint` transaction only exists in the scope of the block.
103    TransactionMintIncorrectBlockHeight,
104    /// The `Output.input_index` is not zero.
105    TransactionMintIncorrectOutputIndex,
106    /// The `Output.mint_base_asset` is not base asset.
107    TransactionMintNonBaseAsset,
108    /// The `Upgrade` transaction doesn't have the privileged address as the input
109    /// owner.
110    TransactionUpgradeNoPrivilegedAddress,
111    /// The `Upgrade` transaction's checksum doesn't match the consensus parameters from
112    /// witness.
113    TransactionUpgradeConsensusParametersChecksumMismatch,
114    /// The `Upgrade` transaction's consensus parameters serialization failed.
115    TransactionUpgradeConsensusParametersSerialization,
116    /// The `Upgrade` transaction's consensus parameters deserialization failed.
117    TransactionUpgradeConsensusParametersDeserialization,
118    /// The verification of the bytecode root of the `Upload` transaction failed.
119    TransactionUploadRootVerificationFailed,
120    /// The total number of bytecode subsections in the `Upload` transaction exceeds the
121    /// limit.
122    TransactionUploadTooManyBytecodeSubsections,
123    /// The transaction exceeded the size limit.
124    TransactionSizeLimitExceeded,
125    /// Max gas per tx exceeded
126    TransactionMaxGasExceeded,
127    TransactionWitnessLimitExceeded,
128    TransactionPoliciesAreInvalid,
129    TransactionNoGasPricePolicy,
130    TransactionMaturity,
131    TransactionExpiration,
132    TransactionMaxFeeNotSet,
133    TransactionInputsMax,
134    TransactionOutputsMax,
135    TransactionWitnessesMax,
136    TransactionOutputChangeAssetIdDuplicated(AssetId),
137    TransactionOutputChangeAssetIdNotFound(AssetId),
138    /// This error happens when a transaction attempts to create a coin output for an
139    /// asset type that doesn't exist in the coin inputs.
140    TransactionOutputCoinAssetIdNotFound(AssetId),
141    /// The transaction doesn't provide enough input amount of the native chain asset to
142    /// cover all potential execution fees
143    #[display(
144        "Insufficient fee amount: expected {}, provided {}",
145        expected,
146        provided
147    )]
148    InsufficientFeeAmount {
149        /// The expected amount of fees required to cover the transaction
150        expected: u64,
151        /// The fee amount actually provided for spending
152        provided: u64,
153    },
154    /// The transaction doesn't provide enough input amount of the given asset to cover
155    /// the amounts used in the outputs.
156    #[display(
157        "Insufficient input amount: asset {}, expected {}, provided {}",
158        asset,
159        expected,
160        provided
161    )]
162    InsufficientInputAmount {
163        /// The asset id being spent
164        asset: AssetId,
165        /// The amount expected by a coin output
166        expected: u64,
167        /// The total amount provided by coin inputs
168        provided: u64,
169    },
170    /// The given coins is too large
171    BalanceOverflow,
172    /// The given gas costs is are too large
173    GasCostsCoinsOverflow,
174    /// Serialized input length is too large.
175    SerializedInputTooLarge {
176        index: usize,
177    },
178    /// Serialized output length is too large.
179    SerializedOutputTooLarge {
180        index: usize,
181    },
182    /// Serialized witness length is too large.
183    SerializedWitnessTooLarge {
184        index: usize,
185    },
186    /// The `Create` transaction doesn't contain `Output::ContractCreated`.
187    TransactionOutputDoesntContainContractCreated,
188    /// Blob id of the transaction differs from the data.
189    TransactionBlobIdVerificationFailed,
190}