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/// =/ consensus-object-operation-not-allowed
79/// =/ input-object-deleted
80/// =/ execution-canceled-due-to-consensus-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/// consensus-object-operation-not-allowed = %x1f
117/// input-object-deleted = %x20
118/// execution-canceled-due-to-consensus-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))]
129#[non_exhaustive]
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: Address },
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 consensus object operation is not allowed
251 ConsensusObjectOperationNotAllowed,
252
253 /// Requested consensus object has been deleted
254 InputObjectDeleted,
255
256 /// Certificate is canceled due to congestion on consensus objects
257 ExecutionCanceledDueToConsensusObjectCongestion {
258 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))]
259 congested_objects: Vec<Address>,
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 = address 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: Address,
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/// =/ consensus-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/// consensus-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))]
363#[non_exhaustive]
364pub enum CommandArgumentError {
365 /// The type of the value does not match the expected type
366 TypeMismatch,
367
368 /// The argument cannot be deserialized into a value of the specified type
369 InvalidBcsBytes,
370
371 /// The argument cannot be instantiated from raw bytes
372 InvalidUsageOfPureArgument,
373
374 /// Invalid argument to private entry function.
375 /// Private entry functions cannot take arguments from other Move functions.
376 InvalidArgumentToPrivateEntryFunction,
377
378 /// Out of bounds access to input or results
379 IndexOutOfBounds { index: u16 },
380
381 /// Out of bounds access to subresult
382 SecondaryIndexOutOfBounds { result: u16, subresult: u16 },
383
384 /// Invalid usage of result.
385 /// Expected a single result but found either no return value or multiple.
386 InvalidResultArity { result: u16 },
387
388 /// Invalid usage of Gas coin.
389 /// The Gas coin can only be used by-value with a TransferObjects command.
390 InvalidGasCoinUsage,
391
392 /// Invalid usage of move value.
393 // Mutably borrowed values require unique usage.
394 // Immutably borrowed values cannot be taken or borrowed mutably.
395 // Taken values cannot be used again.
396 InvalidValueUsage,
397
398 /// Immutable objects cannot be passed by-value.
399 InvalidObjectByValue,
400
401 /// Immutable objects cannot be passed by mutable reference, &mut.
402 InvalidObjectByMutRef,
403
404 /// consensus object operations such a wrapping, freezing, or converting to owned are not
405 /// allowed.
406 ConsensusObjectOperationNotAllowed,
407
408 /// Invalid argument arity. Expected a single argument but found a result that expanded to
409 /// multiple arguments.
410 InvalidArgumentArity,
411}
412
413/// An error with a upgrading a package
414///
415/// # BCS
416///
417/// The BCS serialized form for this type is defined by the following ABNF:
418///
419/// ```text
420/// package-upgrade-error = unable-to-fetch-package /
421/// not-a-package /
422/// incompatible-upgrade /
423/// digest-does-not-match /
424/// unknown-upgrade-policy /
425/// package-id-does-not-match
426///
427/// unable-to-fetch-package = %x00 address
428/// not-a-package = %x01 address
429/// incompatible-upgrade = %x02
430/// digest-does-not-match = %x03 digest
431/// unknown-upgrade-policy = %x04 u8
432/// package-id-does-not-match = %x05 address address
433/// ```
434#[derive(Eq, PartialEq, Clone, Debug)]
435#[cfg_attr(
436 feature = "serde",
437 derive(serde_derive::Serialize, serde_derive::Deserialize)
438)]
439#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
440#[non_exhaustive]
441pub enum PackageUpgradeError {
442 /// Unable to fetch package
443 UnableToFetchPackage { package_id: Address },
444
445 /// Object is not a package
446 NotAPackage { object_id: Address },
447
448 /// Package upgrade is incompatible with previous version
449 IncompatibleUpgrade,
450
451 /// Digest in upgrade ticket and computed digest differ
452 DigestDoesNotMatch { digest: Digest },
453
454 /// Upgrade policy is not valid
455 UnknownUpgradePolicy { policy: u8 },
456
457 /// PackageId does not matach PackageId in upgrade ticket
458 PackageIdDoesNotMatch {
459 package_id: Address,
460 ticket_id: Address,
461 },
462}
463
464/// An error with a type argument
465///
466/// # BCS
467///
468/// The BCS serialized form for this type is defined by the following ABNF:
469///
470/// ```text
471/// type-argument-error = type-not-found / constraint-not-satisfied
472/// type-not-found = %x00
473/// constraint-not-satisfied = %x01
474/// ```
475#[derive(Eq, PartialEq, Clone, Copy, Debug)]
476#[cfg_attr(
477 feature = "serde",
478 derive(serde_derive::Serialize, serde_derive::Deserialize)
479)]
480#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
481#[non_exhaustive]
482pub enum TypeArgumentError {
483 /// A type was not found in the module specified
484 TypeNotFound,
485
486 /// A type provided did not match the specified constraint
487 ConstraintNotSatisfied,
488}