-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #234 from hyperledger-labs/refactor-handler
Refactoring to merge handler into each feature implementation Signed-off-by: Jun Kimura <jun.kimura@datachain.jp>
- Loading branch information
Showing
57 changed files
with
1,883 additions
and
1,824 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
IBCTest:testBenchmarkCreateMockClient() (gas: 216645) | ||
IBCTest:testBenchmarkRecvPacket() (gas: 153912) | ||
IBCTest:testBenchmarkSendPacket() (gas: 89919) | ||
IBCTest:testBenchmarkUpdateMockClient() (gas: 129946) | ||
IBCTest:testToUint128((uint64,uint64)) (runs: 256, μ: 1013, ~: 1013) | ||
TestICS02:testCreateClient() (gas: 20419568) | ||
TestICS02:testInvalidCreateClient() (gas: 20267951) | ||
TestICS02:testInvalidUpdateClient() (gas: 20272833) | ||
TestICS02:testRegisterClient() (gas: 19902791) | ||
TestICS02:testRegisterClientDuplicatedClientType() (gas: 19884771) | ||
TestICS02:testRegisterClientInvalidClientType() (gas: 19873570) | ||
TestICS02:testUpdateClient() (gas: 20415107) | ||
TestICS03Handshake:testConnOpenAck() (gas: 1642938) | ||
TestICS03Handshake:testConnOpenConfirm() (gas: 1781624) | ||
TestICS03Handshake:testConnOpenInit() (gas: 1319897) | ||
TestICS03Handshake:testConnOpenTry() (gas: 2148987) | ||
TestICS03Handshake:testInvalidConnOpenAck() (gas: 2031709) | ||
TestICS03Handshake:testInvalidConnOpenConfirm() (gas: 2037872) | ||
TestICS03Handshake:testInvalidConnOpenInit() (gas: 693724) | ||
TestICS03Handshake:testInvalidConnOpenTry() (gas: 2156100) | ||
TestICS03Version:testCopyVersions() (gas: 560316) | ||
TestICS03Version:testFindSupportedVersion() (gas: 19986) | ||
TestICS03Version:testIsSupportedVersion() (gas: 8317) | ||
TestICS03Version:testPickVersion() (gas: 27093) | ||
TestICS03Version:testVerifyProposedVersion() (gas: 12368) | ||
TestICS03Version:testVerifySupportedFeature() (gas: 4441) | ||
TestICS04Handshake:testChanOpenAck() (gas: 3081103) | ||
TestICS04Handshake:testChanOpenConfirm() (gas: 3272966) | ||
TestICS04Handshake:testChanOpenInit() (gas: 2337459) | ||
TestICS04Handshake:testChanOpenTry() (gas: 2840835) | ||
TestICS04Handshake:testInvalidChanOpenAck() (gas: 2175906) | ||
TestICS04Handshake:testInvalidChanOpenConfirm() (gas: 2234633) | ||
TestICS04Handshake:testInvalidChanOpenInit() (gas: 1333705) | ||
TestICS04Handshake:testInvalidChanOpenTry() (gas: 1411715) | ||
TestICS04Packet:testInvalidSendPacket() (gas: 2301656) | ||
TestICS04Packet:testSendPacket() (gas: 2486762) | ||
TestICS20:testAddressToHex(address) (runs: 256, μ: 23716, ~: 23858) | ||
TestICS20:testHexToAddress(string) (runs: 256, μ: 4817, ~: 4829) | ||
TestICS20:testIsEscapedString() (gas: 49914) | ||
TestICS20:testMarshaling() (gas: 150062) | ||
TestICS20:testParseAmount(uint256) (runs: 256, μ: 27191, ~: 21814) | ||
IBCTest:testBenchmarkCreateMockClient() (gas: 211711) | ||
IBCTest:testBenchmarkRecvPacket() (gas: 140015) | ||
IBCTest:testBenchmarkSendPacket() (gas: 86064) | ||
IBCTest:testBenchmarkUpdateMockClient() (gas: 126678) | ||
IBCTest:testToUint128((uint64,uint64)) (runs: 256, μ: 917, ~: 917) | ||
TestICS02:testCreateClient() (gas: 23422491) | ||
TestICS02:testInvalidCreateClient() (gas: 23270044) | ||
TestICS02:testInvalidUpdateClient() (gas: 23273913) | ||
TestICS02:testRegisterClient() (gas: 22894201) | ||
TestICS02:testRegisterClientDuplicatedClientType() (gas: 22876251) | ||
TestICS02:testRegisterClientInvalidClientType() (gas: 22861044) | ||
TestICS02:testUpdateClient() (gas: 23417285) | ||
TestICS03Handshake:testConnOpenAck() (gas: 1594072) | ||
TestICS03Handshake:testConnOpenConfirm() (gas: 1728943) | ||
TestICS03Handshake:testConnOpenInit() (gas: 1287196) | ||
TestICS03Handshake:testConnOpenTry() (gas: 2088127) | ||
TestICS03Handshake:testInvalidConnOpenAck() (gas: 1953639) | ||
TestICS03Handshake:testInvalidConnOpenConfirm() (gas: 1974862) | ||
TestICS03Handshake:testInvalidConnOpenInit() (gas: 672171) | ||
TestICS03Handshake:testInvalidConnOpenTry() (gas: 2093785) | ||
TestICS03Version:testCopyVersions() (gas: 560134) | ||
TestICS03Version:testFindSupportedVersion() (gas: 19740) | ||
TestICS03Version:testIsSupportedVersion() (gas: 8272) | ||
TestICS03Version:testPickVersion() (gas: 26823) | ||
TestICS03Version:testVerifyProposedVersion() (gas: 12185) | ||
TestICS03Version:testVerifySupportedFeature() (gas: 4357) | ||
TestICS04Handshake:testChanOpenAck() (gas: 2989540) | ||
TestICS04Handshake:testChanOpenConfirm() (gas: 3172516) | ||
TestICS04Handshake:testChanOpenInit() (gas: 2276564) | ||
TestICS04Handshake:testChanOpenTry() (gas: 2760444) | ||
TestICS04Handshake:testInvalidChanOpenAck() (gas: 2117646) | ||
TestICS04Handshake:testInvalidChanOpenConfirm() (gas: 2176812) | ||
TestICS04Handshake:testInvalidChanOpenInit() (gas: 1281923) | ||
TestICS04Handshake:testInvalidChanOpenTry() (gas: 1356309) | ||
TestICS04Packet:testInvalidSendPacket() (gas: 2319493) | ||
TestICS04Packet:testSendPacket() (gas: 2377298) | ||
TestICS20:testAddressToHex(address) (runs: 256, μ: 22708, ~: 22824) | ||
TestICS20:testHexToAddress(string) (runs: 256, μ: 4776, ~: 4734) | ||
TestICS20:testIsEscapedString() (gas: 48979) | ||
TestICS20:testMarshaling() (gas: 148145) | ||
TestICS20:testParseAmount(uint256) (runs: 256, μ: 27065, ~: 21653) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.9; | ||
|
||
library IBCClientLib { | ||
/** | ||
* @dev validateClientType validates the client type | ||
* - clientType must be non-empty | ||
* - clientType must be in the form of `^[a-z][a-z0-9-]*[a-z0-9]$` | ||
*/ | ||
function validateClientType(bytes memory clientTypeBytes) internal pure returns (bool) { | ||
if (clientTypeBytes.length == 0) { | ||
return false; | ||
} | ||
unchecked { | ||
for (uint256 i = 0; i < clientTypeBytes.length; i++) { | ||
uint256 c = uint256(uint8(clientTypeBytes[i])); | ||
if (0x61 <= c && c <= 0x7a) { | ||
// a-z | ||
continue; | ||
} else if (c == 0x2d) { | ||
// hyphen cannot be the first or last character | ||
if (i == 0 || i == clientTypeBytes.length - 1) { | ||
return false; | ||
} | ||
continue; | ||
} else if (0x30 <= c && c <= 0x39) { | ||
// 0-9 | ||
continue; | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity ^0.8.9; | ||
|
||
import "./ILightClient.sol"; | ||
import "../25-handler/IBCMsgs.sol"; | ||
|
||
interface IIBCClient { | ||
/** | ||
* @dev registerClient registers a new client type into the client registry | ||
*/ | ||
function registerClient(string calldata clientType, ILightClient client) external; | ||
struct MsgCreateClient { | ||
string clientType; | ||
bytes clientStateBytes; | ||
bytes consensusStateBytes; | ||
} | ||
|
||
struct MsgUpdateClient { | ||
string clientId; | ||
bytes clientMessage; | ||
} | ||
|
||
event GeneratedClientIdentifier(string); | ||
|
||
/** | ||
* @dev createClient creates a new client state and populates it with a given consensus state | ||
*/ | ||
function createClient(IBCMsgs.MsgCreateClient calldata msg_) external returns (string memory clientId); | ||
function createClient(MsgCreateClient calldata msg_) external returns (string memory clientId); | ||
|
||
/** | ||
* @dev updateClient updates the consensus state and the state root from a provided header | ||
*/ | ||
function updateClient(IBCMsgs.MsgUpdateClient calldata msg_) external; | ||
function updateClient(MsgUpdateClient calldata msg_) external; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.