Skip to content

Commit ec459b0

Browse files
committed
fix: add new execution error to keep backward compatibility
1 parent ab76d2e commit ec459b0

File tree

1 file changed

+64
-30
lines changed

1 file changed

+64
-30
lines changed

crates/iota-rust-sdk/src/types/execution_status.rs

Lines changed: 64 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ pub enum ExecutionError {
156156
InputObjectDeleted,
157157

158158
/// Certificate is cancelled due to congestion on shared objects
159-
ExecutionCancelledDueToSharedObjectCongestion {
160-
congested_objects: Vec<ObjectId>,
161-
suggested_gas_price: u64,
162-
},
159+
// NOTE: this error is obsolete but kept for backward compatibility;
160+
// instead, use `ExecutionCancelledDueToSharedObjectCongestionV1`, which
161+
// includes gas price feedback for transactions cancelled due to congestion
162+
ExecutionCancelledDueToSharedObjectCongestion { congested_objects: Vec<ObjectId> },
163163

164164
/// Address is denied for this coin type
165165
AddressDeniedForCoin { address: Address, coin_type: String },
@@ -170,6 +170,16 @@ pub enum ExecutionError {
170170
/// Certificate is cancelled because randomness could not be generated this
171171
/// epoch
172172
ExecutionCancelledDueToRandomnessUnavailable,
173+
174+
/// Certificate is cancelled due to congestion on shared objects.
175+
/// Except congested shared objects, this error also contains gas
176+
/// price feedback: the lowest gas price of a non-cancelled transaction
177+
/// (that operates on at least one of these congested objects)
178+
/// in the same consensus commit round
179+
ExecutionCancelledDueToSharedObjectCongestionV1 {
180+
congested_objects: Vec<ObjectId>,
181+
lowest_gas_price_of_non_cancelled_transaction: u64,
182+
},
173183
}
174184

175185
#[derive(Eq, PartialEq, Clone, Debug)]
@@ -461,7 +471,6 @@ mod serialization {
461471
InputObjectDeleted,
462472
ExecutionCancelledDueToSharedObjectCongestion {
463473
congested_objects: Vec<ObjectId>,
464-
suggested_gas_price: u64,
465474
},
466475

467476
AddressDeniedForCoin {
@@ -474,6 +483,11 @@ mod serialization {
474483
},
475484

476485
ExecutionCancelledDueToRandomnessUnavailable,
486+
487+
ExecutionCancelledDueToSharedObjectCongestionV1 {
488+
congested_objects: Vec<ObjectId>,
489+
lowest_gas_price_of_non_cancelled_transaction: u64,
490+
},
477491
}
478492

479493
#[derive(serde_derive::Serialize, serde_derive::Deserialize)]
@@ -545,7 +559,6 @@ mod serialization {
545559
InputObjectDeleted,
546560
ExecutionCancelledDueToSharedObjectCongestion {
547561
congested_objects: Vec<ObjectId>,
548-
suggested_gas_price: u64,
549562
},
550563

551564
AddressDeniedForCoin {
@@ -558,6 +571,11 @@ mod serialization {
558571
},
559572

560573
ExecutionCancelledDueToRandomnessUnavailable,
574+
575+
ExecutionCancelledDueToSharedObjectCongestionV1 {
576+
congested_objects: Vec<ObjectId>,
577+
lowest_gas_price_of_non_cancelled_transaction: u64,
578+
},
561579
}
562580

563581
impl Serialize for ExecutionError {
@@ -662,13 +680,11 @@ mod serialization {
662680
ReadableExecutionError::SharedObjectOperationNotAllowed
663681
}
664682
Self::InputObjectDeleted => ReadableExecutionError::InputObjectDeleted,
665-
Self::ExecutionCancelledDueToSharedObjectCongestion {
666-
congested_objects,
667-
suggested_gas_price,
668-
} => ReadableExecutionError::ExecutionCancelledDueToSharedObjectCongestion {
669-
congested_objects,
670-
suggested_gas_price,
671-
},
683+
Self::ExecutionCancelledDueToSharedObjectCongestion { congested_objects } => {
684+
ReadableExecutionError::ExecutionCancelledDueToSharedObjectCongestion {
685+
congested_objects,
686+
}
687+
}
672688
Self::AddressDeniedForCoin { address, coin_type } => {
673689
ReadableExecutionError::AddressDeniedForCoin { address, coin_type }
674690
}
@@ -678,6 +694,13 @@ mod serialization {
678694
Self::ExecutionCancelledDueToRandomnessUnavailable => {
679695
ReadableExecutionError::ExecutionCancelledDueToRandomnessUnavailable
680696
}
697+
Self::ExecutionCancelledDueToSharedObjectCongestionV1 {
698+
congested_objects,
699+
lowest_gas_price_of_non_cancelled_transaction,
700+
} => ReadableExecutionError::ExecutionCancelledDueToSharedObjectCongestionV1 {
701+
congested_objects,
702+
lowest_gas_price_of_non_cancelled_transaction,
703+
},
681704
};
682705
readable.serialize(serializer)
683706
} else {
@@ -773,13 +796,11 @@ mod serialization {
773796
BinaryExecutionError::SharedObjectOperationNotAllowed
774797
}
775798
Self::InputObjectDeleted => BinaryExecutionError::InputObjectDeleted,
776-
Self::ExecutionCancelledDueToSharedObjectCongestion {
777-
congested_objects,
778-
suggested_gas_price,
779-
} => BinaryExecutionError::ExecutionCancelledDueToSharedObjectCongestion {
780-
congested_objects,
781-
suggested_gas_price,
782-
},
799+
Self::ExecutionCancelledDueToSharedObjectCongestion { congested_objects } => {
800+
BinaryExecutionError::ExecutionCancelledDueToSharedObjectCongestion {
801+
congested_objects,
802+
}
803+
}
783804
Self::AddressDeniedForCoin { address, coin_type } => {
784805
BinaryExecutionError::AddressDeniedForCoin { address, coin_type }
785806
}
@@ -789,6 +810,13 @@ mod serialization {
789810
Self::ExecutionCancelledDueToRandomnessUnavailable => {
790811
BinaryExecutionError::ExecutionCancelledDueToRandomnessUnavailable
791812
}
813+
Self::ExecutionCancelledDueToSharedObjectCongestionV1 {
814+
congested_objects,
815+
lowest_gas_price_of_non_cancelled_transaction,
816+
} => BinaryExecutionError::ExecutionCancelledDueToSharedObjectCongestionV1 {
817+
congested_objects,
818+
lowest_gas_price_of_non_cancelled_transaction,
819+
},
792820
};
793821
binary.serialize(serializer)
794822
}
@@ -899,11 +927,7 @@ mod serialization {
899927
ReadableExecutionError::InputObjectDeleted => Self::InputObjectDeleted,
900928
ReadableExecutionError::ExecutionCancelledDueToSharedObjectCongestion {
901929
congested_objects,
902-
suggested_gas_price,
903-
} => Self::ExecutionCancelledDueToSharedObjectCongestion {
904-
congested_objects,
905-
suggested_gas_price,
906-
},
930+
} => Self::ExecutionCancelledDueToSharedObjectCongestion { congested_objects },
907931
ReadableExecutionError::AddressDeniedForCoin { address, coin_type } => {
908932
Self::AddressDeniedForCoin { address, coin_type }
909933
}
@@ -913,6 +937,13 @@ mod serialization {
913937
ReadableExecutionError::ExecutionCancelledDueToRandomnessUnavailable => {
914938
Self::ExecutionCancelledDueToRandomnessUnavailable
915939
}
940+
ReadableExecutionError::ExecutionCancelledDueToSharedObjectCongestionV1 {
941+
congested_objects,
942+
lowest_gas_price_of_non_cancelled_transaction,
943+
} => Self::ExecutionCancelledDueToSharedObjectCongestionV1 {
944+
congested_objects,
945+
lowest_gas_price_of_non_cancelled_transaction,
946+
},
916947
})
917948
} else {
918949
BinaryExecutionError::deserialize(deserializer).map(|binary| match binary {
@@ -1009,11 +1040,7 @@ mod serialization {
10091040
BinaryExecutionError::InputObjectDeleted => Self::InputObjectDeleted,
10101041
BinaryExecutionError::ExecutionCancelledDueToSharedObjectCongestion {
10111042
congested_objects,
1012-
suggested_gas_price,
1013-
} => Self::ExecutionCancelledDueToSharedObjectCongestion {
1014-
congested_objects,
1015-
suggested_gas_price,
1016-
},
1043+
} => Self::ExecutionCancelledDueToSharedObjectCongestion { congested_objects },
10171044
BinaryExecutionError::AddressDeniedForCoin { address, coin_type } => {
10181045
Self::AddressDeniedForCoin { address, coin_type }
10191046
}
@@ -1023,6 +1050,13 @@ mod serialization {
10231050
BinaryExecutionError::ExecutionCancelledDueToRandomnessUnavailable => {
10241051
Self::ExecutionCancelledDueToRandomnessUnavailable
10251052
}
1053+
BinaryExecutionError::ExecutionCancelledDueToSharedObjectCongestionV1 {
1054+
congested_objects,
1055+
lowest_gas_price_of_non_cancelled_transaction,
1056+
} => Self::ExecutionCancelledDueToSharedObjectCongestionV1 {
1057+
congested_objects,
1058+
lowest_gas_price_of_non_cancelled_transaction,
1059+
},
10261060
})
10271061
}
10281062
}

0 commit comments

Comments
 (0)