Skip to content

Commit

Permalink
GetTimeouts with proofs
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege committed Aug 6, 2024
1 parent a8c4783 commit 2253389
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
44 changes: 22 additions & 22 deletions interfaces/Message.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ struct GetResponseMessage {
struct GetTimeoutMessage {
// requests which have timed-out
GetRequest[] timeouts;
}

struct PostTimeout {
PostRequest request;
// the height of the state machine proof
StateMachineHeight height;
// non-membership proof of the requests
bytes[] proof;
}

struct PostRequestTimeoutMessage {
Expand Down Expand Up @@ -147,8 +147,8 @@ struct PostResponseMessage {

library Message {
/**
* @dev Calculates the absolute timeout value for a PostRequest
*/
* @dev Calculates the absolute timeout value for a PostRequest
*/
function timeout(PostRequest memory req) internal pure returns (uint64) {
if (req.timeoutTimestamp == 0) {
return type(uint64).max;
Expand All @@ -158,8 +158,8 @@ library Message {
}

/**
* @dev Calculates the absolute timeout value for a GetRequest
*/
* @dev Calculates the absolute timeout value for a GetRequest
*/
function timeout(GetRequest memory req) internal pure returns (uint64) {
if (req.timeoutTimestamp == 0) {
return type(uint64).max;
Expand All @@ -169,8 +169,8 @@ library Message {
}

/**
* @dev Calculates the absolute timeout value for a PostResponse
*/
* @dev Calculates the absolute timeout value for a PostResponse
*/
function timeout(PostResponse memory res) internal pure returns (uint64) {
if (res.timeoutTimestamp == 0) {
return type(uint64).max;
Expand All @@ -180,15 +180,15 @@ library Message {
}

/**
* @dev Encode the given post request for commitment
*/
* @dev Encode the given post request for commitment
*/
function encode(PostRequest memory req) internal pure returns (bytes memory) {
return abi.encodePacked(req.source, req.dest, req.nonce, req.timeoutTimestamp, req.from, req.to, req.body);
}

/**
* @dev Encode the given get request for commitment
*/
* @dev Encode the given get request for commitment
*/
function encode(GetRequest memory req) internal pure returns (bytes memory) {
bytes memory keysEncoding = bytes("");
uint256 len = req.keys.length;
Expand All @@ -209,29 +209,29 @@ library Message {
}

/**
* @dev Returns the commitment for the given post response
*/
* @dev Returns the commitment for the given post response
*/
function hash(PostResponse memory res) internal pure returns (bytes32) {
return keccak256(bytes.concat(encode(res.request), abi.encodePacked(res.response, res.timeoutTimestamp)));
}

/**
* @dev Returns the commitment for the given post request
*/
* @dev Returns the commitment for the given post request
*/
function hash(PostRequest memory req) internal pure returns (bytes32) {
return keccak256(encode(req));
}

/**
* @dev Returns the commitment for the given get request
*/
* @dev Returns the commitment for the given get request
*/
function hash(GetRequest memory req) internal pure returns (bytes32) {
return keccak256(encode(req));
}

/**
* @dev Returns the commitment for the given get response
*/
* @dev Returns the commitment for the given get response
*/
function hash(GetResponse memory res) internal pure returns (bytes32) {
bytes memory response = bytes("");
uint256 len = res.values.length;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@polytope-labs/ismp-solidity",
"version": "0.3.8",
"version": "0.4.0",
"description": "Hyperbridge Solidity SDK for the Interoperable state machine protocol",
"author": "Polytope Labs <[email protected]>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -33,4 +33,4 @@
"prettier": "^3.3.3",
"prettier-plugin-solidity": "^1.3.1"
}
}
}

0 comments on commit 2253389

Please sign in to comment.