sui_sdk_types/
execution_status.rs

1use super::Address;
2use super::Digest;
3use super::Identifier;
4
5/// The status of an executed Transaction
6///
7/// # BCS
8///
9/// The BCS serialized form for this type is defined by the following ABNF:
10///
11/// ```text
12/// execution-status = success / failure
13/// success = %x00
14/// failure = %x01 execution-error (option u64)
15/// ```
16#[derive(Eq, PartialEq, Clone, Debug)]
17#[cfg_attr(
18    feature = "serde",
19    derive(serde_derive::Serialize, serde_derive::Deserialize)
20)]
21#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
22pub enum ExecutionStatus {
23    /// The Transaction successfully executed.
24    Success,
25
26    /// The Transaction didn't execute successfully.
27    ///
28    /// Failed transactions are still committed to the blockchain but any intended effects are
29    /// rolled back to prior to this transaction executing with the caveat that gas objects are
30    /// still smashed and gas usage is still charged.
31    Failure {
32        /// The error encountered during execution.
33        error: ExecutionError,
34        /// The command, if any, during which the error occurred.
35        #[cfg_attr(feature = "proptest", map(|x: Option<u16>| x.map(Into::into)))]
36        command: Option<u64>,
37    },
38}
39
40/// An error that can occur during the execution of a transaction
41///
42/// # BCS
43///
44/// The BCS serialized form for this type is defined by the following ABNF:
45///
46/// ```text
47/// execution-error =  insufficient-gas
48///                 =/ invalid-gas-object
49///                 =/ invariant-violation
50///                 =/ feature-not-yet-supported
51///                 =/ object-too-big
52///                 =/ package-too-big
53///                 =/ circular-object-ownership
54///                 =/ insufficient-coin-balance
55///                 =/ coin-balance-overflow
56///                 =/ publish-error-non-zero-address
57///                 =/ sui-move-verification-error
58///                 =/ move-primitive-runtime-error
59///                 =/ move-abort
60///                 =/ vm-verification-or-deserialization-error
61///                 =/ vm-invariant-violation
62///                 =/ function-not-found
63///                 =/ arity-mismatch
64///                 =/ type-arity-mismatch
65///                 =/ non-entry-function-invoked
66///                 =/ command-argument-error
67///                 =/ type-argument-error
68///                 =/ unused-value-without-drop
69///                 =/ invalid-public-function-return-type
70///                 =/ invalid-transfer-object
71///                 =/ effects-too-large
72///                 =/ publish-upgrade-missing-dependency
73///                 =/ publish-upgrade-dependency-downgrade
74///                 =/ package-upgrade-error
75///                 =/ written-objects-too-large
76///                 =/ certificate-denied
77///                 =/ sui-move-verification-timedout
78///                 =/ shared-object-operation-not-allowed
79///                 =/ input-object-deleted
80///                 =/ execution-canceled-due-to-shared-object-congestion
81///                 =/ address-denied-for-coin
82///                 =/ coin-type-global-pause
83///                 =/ execution-canceled-due-to-randomness-unavailable
84///
85/// insufficient-gas                                    = %x00
86/// invalid-gas-object                                  = %x01
87/// invariant-violation                                 = %x02
88/// feature-not-yet-supported                           = %x03
89/// object-too-big                                      = %x04 u64 u64
90/// package-too-big                                     = %x05 u64 u64
91/// circular-object-ownership                           = %x06 address
92/// insufficient-coin-balance                           = %x07
93/// coin-balance-overflow                               = %x08
94/// publish-error-non-zero-address                      = %x09
95/// sui-move-verification-error                         = %x0a
96/// move-primitive-runtime-error                        = %x0b (option move-location)
97/// move-abort                                          = %x0c move-location u64
98/// vm-verification-or-deserialization-error            = %x0d
99/// vm-invariant-violation                              = %x0e
100/// function-not-found                                  = %x0f
101/// arity-mismatch                                      = %x10
102/// type-arity-mismatch                                 = %x11
103/// non-entry-function-invoked                          = %x12
104/// command-argument-error                              = %x13 u16 command-argument-error
105/// type-argument-error                                 = %x14 u16 type-argument-error
106/// unused-value-without-drop                           = %x15 u16 u16
107/// invalid-public-function-return-type                 = %x16 u16
108/// invalid-transfer-object                             = %x17
109/// effects-too-large                                   = %x18 u64 u64
110/// publish-upgrade-missing-dependency                  = %x19
111/// publish-upgrade-dependency-downgrade                = %x1a
112/// package-upgrade-error                               = %x1b package-upgrade-error
113/// written-objects-too-large                           = %x1c u64 u64
114/// certificate-denied                                  = %x1d
115/// sui-move-verification-timedout                      = %x1e
116/// shared-object-operation-not-allowed                 = %x1f
117/// input-object-deleted                                = %x20
118/// execution-canceled-due-to-shared-object-congestion = %x21 (vector address)
119/// address-denied-for-coin                             = %x22 address string
120/// coin-type-global-pause                              = %x23 string
121/// execution-canceled-due-to-randomness-unavailable   = %x24
122/// ```
123#[derive(Eq, PartialEq, Clone, Debug)]
124#[cfg_attr(
125    feature = "serde",
126    derive(serde_derive::Serialize, serde_derive::Deserialize)
127)]
128#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
129pub enum ExecutionError {
130    //
131    // General transaction errors
132    //
133    /// Insufficient Gas
134    InsufficientGas,
135    /// Invalid Gas Object.
136    InvalidGasObject,
137    /// Invariant Violation
138    InvariantViolation,
139    /// Attempted to used feature that is not supported yet
140    FeatureNotYetSupported,
141    /// Move object is larger than the maximum allowed size
142    ObjectTooBig {
143        object_size: u64,
144        max_object_size: u64,
145    },
146    /// Package is larger than the maximum allowed size
147    PackageTooBig {
148        object_size: u64,
149        max_object_size: u64,
150    },
151    /// Circular Object Ownership
152    CircularObjectOwnership { object: Address },
153
154    //
155    // Coin errors
156    //
157    /// Insufficient coin balance for requested operation
158    InsufficientCoinBalance,
159    /// Coin balance overflowed an u64
160    CoinBalanceOverflow,
161
162    //
163    // Publish/Upgrade errors
164    //
165    /// Publish Error, Non-zero Address.
166    /// The modules in the package must have their self-addresses set to zero.
167    PublishErrorNonZeroAddress,
168
169    /// Sui Move Bytecode Verification Error.
170    SuiMoveVerificationError,
171
172    //
173    // MoveVm Errors
174    //
175    /// Error from a non-abort instruction.
176    /// Possible causes:
177    ///     Arithmetic error, stack overflow, max value depth, etc."
178    MovePrimitiveRuntimeError { location: Option<MoveLocation> },
179    /// Move runtime abort
180    MoveAbort { location: MoveLocation, code: u64 },
181    /// Bytecode verification error.
182    VmVerificationOrDeserializationError,
183    /// MoveVm invariant violation
184    VmInvariantViolation,
185
186    //
187    // Programmable Transaction Errors
188    //
189    /// Function not found
190    FunctionNotFound,
191    /// Arity mismatch for Move function.
192    /// The number of arguments does not match the number of parameters
193    ArityMismatch,
194    /// Type arity mismatch for Move function.
195    /// Mismatch between the number of actual versus expected type arguments.
196    TypeArityMismatch,
197    /// Non Entry Function Invoked. Move Call must start with an entry function.
198    NonEntryFunctionInvoked,
199    /// Invalid command argument
200    CommandArgumentError {
201        argument: u16,
202        kind: CommandArgumentError,
203    },
204    /// Type argument error
205    TypeArgumentError {
206        /// Index of the problematic type argument
207        type_argument: u16,
208        kind: TypeArgumentError,
209    },
210    /// Unused result without the drop ability.
211    UnusedValueWithoutDrop { result: u16, subresult: u16 },
212    /// Invalid public Move function signature.
213    /// Unsupported return type for return value
214    InvalidPublicFunctionReturnType { index: u16 },
215    /// Invalid Transfer Object, object does not have public transfer.
216    InvalidTransferObject,
217
218    //
219    // Post-execution errors
220    //
221    /// Effects from the transaction are too large
222    EffectsTooLarge { current_size: u64, max_size: u64 },
223
224    /// Publish or Upgrade is missing dependency
225    PublishUpgradeMissingDependency,
226
227    /// Publish or Upgrade dependency downgrade.
228    ///
229    /// Indirect (transitive) dependency of published or upgraded package has been assigned an
230    /// on-chain version that is less than the version required by one of the package's
231    /// transitive dependencies.
232    PublishUpgradeDependencyDowngrade,
233
234    /// Invalid package upgrade
235    PackageUpgradeError { kind: PackageUpgradeError },
236
237    /// Indicates the transaction tried to write objects too large to storage
238    WrittenObjectsTooLarge {
239        object_size: u64,
240        max_object_size: u64,
241    },
242
243    /// Certificate is on the deny list
244    CertificateDenied,
245
246    /// Sui Move Bytecode verification timed out.
247    SuiMoveVerificationTimedout,
248
249    /// The requested shared object operation is not allowed
250    SharedObjectOperationNotAllowed,
251
252    /// Requested shared object has been deleted
253    InputObjectDeleted,
254
255    /// Certificate is canceled due to congestion on shared objects
256    ExecutionCanceledDueToSharedObjectCongestion {
257        #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))]
258        congested_objects: Vec<Address>,
259    },
260
261    /// Address is denied for this coin type
262    AddressDeniedForCoin { address: Address, coin_type: String },
263
264    /// Coin type is globally paused for use
265    CoinTypeGlobalPause { coin_type: String },
266
267    /// Certificate is canceled because randomness could not be generated this epoch
268    ExecutionCanceledDueToRandomnessUnavailable,
269
270    /// Move vector element (passed to MakeMoveVec) with size {value_size} is larger \
271    /// than the maximum size {max_scaled_size}. Note that this maximum is scaled based on the \
272    /// type of the vector element.
273    MoveVectorElemTooBig {
274        value_size: u64,
275        max_scaled_size: u64,
276    },
277
278    /// Move value (possibly an upgrade ticket or a dev-inspect value) with size {value_size} \
279    /// is larger than the maximum size  {max_scaled_size}. Note that this maximum is scaled based \
280    /// on the type of the value.
281    MoveRawValueTooBig {
282        value_size: u64,
283        max_scaled_size: u64,
284    },
285
286    /// A valid linkage was unable to be determined for the transaction or one of its commands.
287    InvalidLinkage,
288}
289
290/// Location in move bytecode where an error occurred
291///
292/// # BCS
293///
294/// The BCS serialized form for this type is defined by the following ABNF:
295///
296/// ```text
297/// move-location = address identifier u16 u16 (option identifier)
298/// ```
299#[derive(Eq, PartialEq, Clone, Debug)]
300#[cfg_attr(
301    feature = "serde",
302    derive(serde_derive::Serialize, serde_derive::Deserialize)
303)]
304#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
305pub struct MoveLocation {
306    /// The package id
307    pub package: Address,
308
309    /// The module name
310    pub module: Identifier,
311
312    /// The function index
313    pub function: u16,
314
315    /// Index into the code stream for a jump. The offset is relative to the beginning of
316    /// the instruction stream.
317    pub instruction: u16,
318
319    /// The name of the function if available
320    pub function_name: Option<Identifier>,
321}
322
323/// An error with an argument to a command
324///
325/// # BCS
326///
327/// The BCS serialized form for this type is defined by the following ABNF:
328///
329/// ```text
330/// command-argument-error =  type-mismatch
331///                        =/ invalid-bcs-bytes
332///                        =/ invalid-usage-of-pure-argument
333///                        =/ invalid-argument-to-private-entry-function
334///                        =/ index-out-of-bounds
335///                        =/ secondary-index-out-of-bound
336///                        =/ invalid-result-arity
337///                        =/ invalid-gas-coin-usage
338///                        =/ invalid-value-usage
339///                        =/ invalid-object-by-value
340///                        =/ invalid-object-by-mut-ref
341///                        =/ shared-object-operation-not-allowed
342///
343/// type-mismatch                               = %x00
344/// invalid-bcs-bytes                           = %x01
345/// invalid-usage-of-pure-argument              = %x02
346/// invalid-argument-to-private-entry-function  = %x03
347/// index-out-of-bounds                         = %x04 u16
348/// secondary-index-out-of-bound                = %x05 u16 u16
349/// invalid-result-arity                        = %x06 u16
350/// invalid-gas-coin-usage                      = %x07
351/// invalid-value-usage                         = %x08
352/// invalid-object-by-value                     = %x09
353/// invalid-object-by-mut-ref                   = %x0a
354/// shared-object-operation-not-allowed         = %x0b
355/// ```
356#[derive(Eq, PartialEq, Clone, Debug)]
357#[cfg_attr(
358    feature = "serde",
359    derive(serde_derive::Serialize, serde_derive::Deserialize)
360)]
361#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
362pub enum CommandArgumentError {
363    /// The type of the value does not match the expected type
364    TypeMismatch,
365
366    /// The argument cannot be deserialized into a value of the specified type
367    InvalidBcsBytes,
368
369    /// The argument cannot be instantiated from raw bytes
370    InvalidUsageOfPureArgument,
371
372    /// Invalid argument to private entry function.
373    /// Private entry functions cannot take arguments from other Move functions.
374    InvalidArgumentToPrivateEntryFunction,
375
376    /// Out of bounds access to input or results
377    IndexOutOfBounds { index: u16 },
378
379    /// Out of bounds access to subresult
380    SecondaryIndexOutOfBounds { result: u16, subresult: u16 },
381
382    /// Invalid usage of result.
383    /// Expected a single result but found either no return value or multiple.
384    InvalidResultArity { result: u16 },
385
386    /// Invalid usage of Gas coin.
387    /// The Gas coin can only be used by-value with a TransferObjects command.
388    InvalidGasCoinUsage,
389
390    /// Invalid usage of move value.
391    //     Mutably borrowed values require unique usage.
392    //     Immutably borrowed values cannot be taken or borrowed mutably.
393    //     Taken values cannot be used again.
394    InvalidValueUsage,
395
396    /// Immutable objects cannot be passed by-value.
397    InvalidObjectByValue,
398
399    /// Immutable objects cannot be passed by mutable reference, &mut.
400    InvalidObjectByMutRef,
401
402    /// Shared object operations such a wrapping, freezing, or converting to owned are not
403    /// allowed.
404    SharedObjectOperationNotAllowed,
405
406    /// Invalid argument arity. Expected a single argument but found a result that expanded to
407    /// multiple arguments.
408    InvalidArgumentArity,
409}
410
411/// An error with a upgrading a package
412///
413/// # BCS
414///
415/// The BCS serialized form for this type is defined by the following ABNF:
416///
417/// ```text
418/// package-upgrade-error = unable-to-fetch-package /
419///                         not-a-package           /
420///                         incompatible-upgrade    /
421///                         digest-does-not-match   /
422///                         unknown-upgrade-policy  /
423///                         package-id-does-not-match
424///
425/// unable-to-fetch-package     = %x00 address
426/// not-a-package               = %x01 address
427/// incompatible-upgrade        = %x02
428/// digest-does-not-match       = %x03 digest
429/// unknown-upgrade-policy      = %x04 u8
430/// package-id-does-not-match   = %x05 address address
431/// ```
432#[derive(Eq, PartialEq, Clone, Debug)]
433#[cfg_attr(
434    feature = "serde",
435    derive(serde_derive::Serialize, serde_derive::Deserialize)
436)]
437#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
438pub enum PackageUpgradeError {
439    /// Unable to fetch package
440    UnableToFetchPackage { package_id: Address },
441
442    /// Object is not a package
443    NotAPackage { object_id: Address },
444
445    /// Package upgrade is incompatible with previous version
446    IncompatibleUpgrade,
447
448    /// Digest in upgrade ticket and computed digest differ
449    DigestDoesNotMatch { digest: Digest },
450
451    /// Upgrade policy is not valid
452    UnknownUpgradePolicy { policy: u8 },
453
454    /// PackageId does not matach PackageId in upgrade ticket
455    PackageIdDoesNotMatch {
456        package_id: Address,
457        ticket_id: Address,
458    },
459}
460
461/// An error with a type argument
462///
463/// # BCS
464///
465/// The BCS serialized form for this type is defined by the following ABNF:
466///
467/// ```text
468/// type-argument-error = type-not-found / constraint-not-satisfied
469/// type-not-found = %x00
470/// constraint-not-satisfied = %x01
471/// ```
472#[derive(Eq, PartialEq, Clone, Copy, Debug)]
473#[cfg_attr(
474    feature = "serde",
475    derive(serde_derive::Serialize, serde_derive::Deserialize)
476)]
477#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
478pub enum TypeArgumentError {
479    /// A type was not found in the module specified
480    TypeNotFound,
481
482    /// A type provided did not match the specified constraint
483    ConstraintNotSatisfied,
484}