sui_sdk_types/
execution_status.rs

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