Skip to content

Commit 184a5eb

Browse files
[NONEVM-3352] [L4] Wrong or colliding error codes (#507)
* ref: facility name, id and error codes * feat: normalize exit codes for ownable and merkle multi proof * feat: normalize exit codes for ocr * fix: remove redundant errors * small fixes * ref: align opcodes in Utils
1 parent 1189180 commit 184a5eb

File tree

73 files changed

+1235
-583
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1235
-583
lines changed

contracts/contracts/ccip/ccipsend_executor/contract.tolk

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import "../fee_quoter/types"
1111
import "@stdlib/gas-payments"
1212

1313
const CONTRACT_VERSION = "1.6.0";
14-
const FACILITY_NAME = "com.chainlink.ton.ccip.CCIPSendExecutor";
1514

1615
fun onInternalMessage(in: InMessage) {
1716
val msg = lazy CCIPSendExecutor_InMessage.fromSlice(in.body);
@@ -153,11 +152,11 @@ fun CCIPSendExecutor<T>.exitWithError(self, error: uint256) {
153152
}
154153

155154
get fun typeAndVersion(): (slice, slice) {
156-
return ("com.chainlink.ton.ccip.CCIPSendExecutor", CONTRACT_VERSION);
155+
return (CCIPSendExecutor_FACILITY_NAME, CONTRACT_VERSION);
157156
}
158157

159158
get fun facilityId(): uint16 {
160-
return getFacilityId(stringCrc32("com.chainlink.ton.ccip.CCIPSendExecutor"));
159+
return CCIPSendExecutor_FACILITY_ID;
161160
}
162161

163162
get fun errorCode(local: uint16): uint16 {

contracts/contracts/ccip/ccipsend_executor/errors.tolk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import "types"
2+
13
enum CCIPSendExecutor_Error {
2-
StateNotExpected = 43600 // Facility ID * 100
4+
StateNotExpected = CCIPSendExecutor_FACILITY_ID * 100
35
Unauthorized
46
InsufficientFunds
57
InsufficientFee

contracts/contracts/ccip/ccipsend_executor/types.tolk

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import "../onramp/messages.tolk";
2-
import "../../deployable/types"
3-
import "../../lib/deployable/namespace"
2+
3+
const CCIPSendExecutor_FACILITY_NAME = "com.chainlink.ton.ccip.CCIPSendExecutor";
4+
// getFacilityId(stringCrc32(CCIPSendExecutor_FACILITY_NAME));
5+
const CCIPSendExecutor_FACILITY_ID = 436;
46

57
type CCIPSendExecutor_ID = uint224
68

contracts/contracts/ccip/fee_quoter/contract.tolk

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import "../../lib/funding/withdrawable"
1616
import "../../lib/versioning/upgradeable"
1717

1818
const CONTRACT_VERSION = "1.6.0";
19-
const FACILITY_NAME = "com.chainlink.ton.ccip.FeeQuoter";
2019
const RESERVE = ton("1"); // TODO: set correct value
2120

2221
fun onInternalMessage(in: InMessage) {
@@ -252,7 +251,7 @@ fun calculateValidatedFee(msg: Router_CCIPSend): Fee {
252251
8 => {
253252
throw FeeQuoter_Error.MsgDataTooLarge;
254253
}
255-
ERROR_INVALID_DATA => {
254+
Utils_Error.InvalidData as int => {
256255
throw FeeQuoter_Error.InvalidMsgData;
257256
}
258257
else => {
@@ -644,11 +643,11 @@ get fun pendingOwner(): address? {
644643
}
645644

646645
get fun typeAndVersion(): (slice, slice) {
647-
return ("com.chainlink.ton.ccip.FeeQuoter", CONTRACT_VERSION);
646+
return (FeeQuoter_FACILITY_NAME, CONTRACT_VERSION);
648647
}
649648

650649
get fun facilityId(): uint16 {
651-
return getFacilityId(stringCrc32("com.chainlink.ton.ccip.FeeQuoter"));
650+
return FeeQuoter_FACILITY_ID;
652651
}
653652

654653
get fun errorCode(local: uint16): uint16 {

contracts/contracts/ccip/fee_quoter/errors.tolk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import "types"
2+
13
enum FeeQuoter_Error {
2-
UnsupportedChainFamilySelector = 24800 // Facility ID * 100
4+
UnsupportedChainFamilySelector = FeeQuoter_FACILITY_ID * 100
35
GasLimitTooHigh
46
ExtraArgOutOfOrderExecutionMustBeTrue
57
InvalidExtraArgsData

contracts/contracts/ccip/fee_quoter/types.tolk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import "../../lib/utils"
22

3+
const FeeQuoter_FACILITY_NAME = "com.chainlink.ton.ccip.FeeQuoter";
4+
// getFacilityId(stringCrc32(FeeQuoter_FACILITY_NAME));
5+
const FeeQuoter_FACILITY_ID = 248;
6+
37
struct TimestampedPrice {
48
value: uint224;
59
timestamp: uint32;

contracts/contracts/ccip/merkle_root/contract.tolk

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import "../../deployable/types.tolk"
88
import "../receive_executor/storage"
99
import "../router/storage"
1010
import "../../lib/funding/withdrawable"
11+
import "types"
1112

1213
// MerkleRoot contract
1314
// Root is commited on Commit Reports and the existence of this contract is used to validate Execute Reports
@@ -108,11 +109,11 @@ fun onInitExecute(mutate st: MerkleRoot_Storage, msg: MerkleRoot_Validate) {
108109
}
109110

110111
get fun typeAndVersion(): (slice, slice) {
111-
return ("com.chainlink.ton.ccip.MerkleRoot", CONTRACT_VERSION);
112+
return (MerkleRoot_FACILITY_NAME, CONTRACT_VERSION);
112113
}
113114

114115
get fun facilityId(): uint16 {
115-
return getFacilityId(stringCrc32("com.chainlink.ton.ccip.MerkleRoot"));
116+
return MerkleRoot_FACILITY_ID;
116117
}
117118

118119
get fun errorCode(local: uint16): uint16 {

contracts/contracts/ccip/merkle_root/errors.tolk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import "types"
2+
13
enum MerkleRoot_Error {
2-
AlreadyExecuted = 47900 // Facility ID * 100
4+
AlreadyExecuted = MerkleRoot_FACILITY_ID * 100
35
NotOwner
46
ManualExecutionNotYetEnabled
57
SkippedAlreadyExecutedMessage
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const MerkleRoot_FACILITY_NAME = "com.chainlink.ton.ccip.MerkleRoot";
2+
// getFacilityId(stringCrc32(MerkleRoot_FACILITY_NAME));
3+
const MerkleRoot_FACILITY_ID = 479;

contracts/contracts/ccip/offramp/contract.tolk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,11 +863,11 @@ get fun pendingOwner(): address? {
863863
}
864864

865865
get fun typeAndVersion(): (slice, slice) {
866-
return ("com.chainlink.ton.ccip.OffRamp", CONTRACT_VERSION);
866+
return (OffRamp_FACILITY_NAME, CONTRACT_VERSION);
867867
}
868868

869869
get fun facilityId(): uint16 {
870-
return getFacilityId(stringCrc32("com.chainlink.ton.ccip.OffRamp"));
870+
return OffRamp_FACILITY_ID;
871871
}
872872

873873
get fun errorCode(local: uint16): uint16 {

0 commit comments

Comments
 (0)