You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @dev routeUpdateClient returns the LC contract address and the calldata to the receiving function of the client message.
63
66
* Light client contract may encode a client message as other encoding scheme(e.g. ethereum ABI)
67
+
* WARNING: If the caller is an EOA like a relayer, the caller must validate the return values with the allow list of the contract functions before calling the LC contract with the data.
68
+
* This validation is always required because even if the caller trusts the IBC contract, a malicious RPC provider can return arbitrary data to the caller.
69
+
* Check ADR-001 for details.
64
70
*/
65
71
function routeUpdateClient(MsgUpdateClient calldatamsg_)
Copy file name to clipboardExpand all lines: contracts/core/02-client/IBCClientLib.sol
+25-7Lines changed: 25 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -4,24 +4,29 @@ pragma solidity ^0.8.20;
4
4
libraryIBCClientLib {
5
5
/**
6
6
* @dev validateClientType validates the client type
7
-
* - clientType must be non-empty
8
-
* - clientType must be in the form of `^[a-z][a-z0-9-]*[a-z0-9]$`
7
+
* - clientType must be non-empty
8
+
* - clientType must be between 7 and 62 characters long
9
+
* - This is because the length of the client ID is 9-64 characters long in the ICS-24, and the client ID is composed of the client type and the counter suffix (minimum 2 characters long).
10
+
* - clientType must be in the form of `^[a-z][a-z0-9-]*[a-z0-9]$`
9
11
*/
10
12
function validateClientType(bytesmemoryclientTypeBytes) internalpurereturns (bool) {
11
-
uint256byteLength= clientTypeBytes.length;
12
-
if (byteLength==0) {
13
+
uint256bytesLength= clientTypeBytes.length;
14
+
if (bytesLength==0) {
13
15
returnfalse;
14
16
}
15
-
for (uint256 i =0; i < byteLength; i++) {
17
+
if (bytesLength <7|| bytesLength >62) {
18
+
returnfalse;
19
+
}
20
+
for (uint256 i =0; i < bytesLength; i++) {
16
21
uint256 c =uint256(uint8(clientTypeBytes[i]));
17
22
if (0x61<= c && c <=0x7a) {
18
23
// a-z
19
24
continue;
20
25
} elseif (c ==0x2d) {
21
26
// hyphen cannot be the first or last character
22
27
unchecked {
23
-
// SAFETY: `byteLength` is greater than 0
24
-
if (i ==0|| i ==byteLength-1) {
28
+
// SAFETY: `bytesLength` is greater than 0
29
+
if (i ==0|| i ==bytesLength-1) {
25
30
returnfalse;
26
31
}
27
32
}
@@ -35,4 +40,17 @@ library IBCClientLib {
35
40
}
36
41
returntrue;
37
42
}
43
+
44
+
/**
45
+
* @dev validateClientId validates the client ID
46
+
* NOTE: The client ID must be composed of the client type is validated by `validateClientType` and the counter suffix.
47
+
* - clientId must be between 9 and 64 characters long
48
+
*/
49
+
function validateClientId(bytesmemoryclientIdBytes) internalpurereturns (bool) {
0 commit comments