-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01dd215
commit 89dd619
Showing
11 changed files
with
687 additions
and
604 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 |
---|---|---|
|
@@ -13,4 +13,6 @@ broadcast/ | |
target/ | ||
.cargo/ | ||
.idea | ||
.vscode/ | ||
.vscode/ | ||
|
||
node_modules/ |
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,5 @@ | ||
{ | ||
"printWidth": 120, | ||
"tabWidth": 4, | ||
"useTabs": 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 |
---|---|---|
|
@@ -4,39 +4,44 @@ pragma solidity 0.8.17; | |
// The state commiment identifies a commiment to some intermediate state in the state machine. | ||
// This contains some metadata about the state machine like it's own timestamp at the time of this commitment. | ||
struct StateCommitment { | ||
// This timestamp is useful for handling request timeouts. | ||
uint256 timestamp; | ||
// Overlay trie commitment to all ismp requests & response. | ||
bytes32 overlayRoot; | ||
// State trie commitment at the given block height | ||
bytes32 stateRoot; | ||
// This timestamp is useful for handling request timeouts. | ||
uint256 timestamp; | ||
// Overlay trie commitment to all ismp requests & response. | ||
bytes32 overlayRoot; | ||
// State trie commitment at the given block height | ||
bytes32 stateRoot; | ||
} | ||
|
||
// Identifies some state machine height. We allow for a state machine identifier here | ||
// as some consensus clients may track multiple, concurrent state machines. | ||
struct StateMachineHeight { | ||
// the state machine identifier | ||
uint256 stateMachineId; | ||
// height of this state machine | ||
uint256 height; | ||
// the state machine identifier | ||
uint256 stateMachineId; | ||
// height of this state machine | ||
uint256 height; | ||
} | ||
|
||
// An intermediate state in the series of state transitions undergone by a given state machine. | ||
struct IntermediateState { | ||
// the state machine identifier | ||
uint256 stateMachineId; | ||
// height of this state machine | ||
uint256 height; | ||
// state commitment | ||
StateCommitment commitment; | ||
// the state machine identifier | ||
uint256 stateMachineId; | ||
// height of this state machine | ||
uint256 height; | ||
// state commitment | ||
StateCommitment commitment; | ||
} | ||
|
||
// The consensus client interface responsible for the verification of consensus datagrams. | ||
// It's internals is opaque to the ISMP framework allowing it to evolve as needed. | ||
/** | ||
* @title The Ismp ConsensusClient | ||
* @author Polytope Labs ([email protected]) | ||
* | ||
* @notice The consensus client interface responsible for the verification of consensus datagrams. | ||
* It's internals are opaque to the ISMP framework allowing it to evolve as needed. | ||
*/ | ||
interface IConsensusClient { | ||
/// Verify the consensus proof and return the new trusted consensus state and any intermediate states finalized | ||
/// by this consensus proof. | ||
function verifyConsensus(bytes memory trustedState, bytes memory proof) | ||
external | ||
returns (bytes memory, IntermediateState memory); | ||
// @dev Given some opaque consensus proof, produce the new consensus state and newly finalized intermediate states. | ||
function verifyConsensus( | ||
bytes memory trustedState, | ||
bytes memory proof | ||
) external returns (bytes memory, IntermediateState memory); | ||
} |
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 |
---|---|---|
|
@@ -6,69 +6,74 @@ import {PostRequest} from "./Message.sol"; | |
|
||
// @notice An object for dispatching post requests to the Hyperbridge | ||
struct DispatchPost { | ||
// bytes representation of the destination state machine | ||
bytes dest; | ||
// the destination module | ||
bytes to; | ||
// the request body | ||
bytes body; | ||
// timeout for this request in seconds | ||
uint64 timeout; | ||
// the amount put up to be paid to the relayer, | ||
// this is charged in `IIsmpHost.feeToken` to `msg.sender` | ||
uint256 fee; | ||
// who pays for this request? | ||
address payer; | ||
// bytes representation of the destination state machine | ||
bytes dest; | ||
// the destination module | ||
bytes to; | ||
// the request body | ||
bytes body; | ||
// timeout for this request in seconds | ||
uint64 timeout; | ||
// the amount put up to be paid to the relayer, | ||
// this is charged in `IIsmpHost.feeToken` to `msg.sender` | ||
uint256 fee; | ||
// who pays for this request? | ||
address payer; | ||
} | ||
|
||
// @notice An object for dispatching get requests to the Hyperbridge | ||
struct DispatchGet { | ||
// bytes representation of the destination state machine | ||
bytes dest; | ||
// height at which to read the state machine | ||
uint64 height; | ||
// storage keys to read | ||
bytes[] keys; | ||
// timeout for this request in seconds | ||
uint64 timeout; | ||
// Hyperbridge protocol fees for processing this request. | ||
uint256 fee; | ||
// bytes representation of the destination state machine | ||
bytes dest; | ||
// height at which to read the state machine | ||
uint64 height; | ||
// storage keys to read | ||
bytes[] keys; | ||
// timeout for this request in seconds | ||
uint64 timeout; | ||
// Hyperbridge protocol fees for processing this request. | ||
uint256 fee; | ||
} | ||
|
||
struct DispatchPostResponse { | ||
// The request that initiated this response | ||
PostRequest request; | ||
// bytes for post response | ||
bytes response; | ||
// timeout for this response in seconds | ||
uint64 timeout; | ||
// the amount put up to be paid to the relayer, | ||
// this is charged in `IIsmpHost.feeToken` to `msg.sender` | ||
uint256 fee; | ||
// who pays for this request? | ||
address payer; | ||
// The request that initiated this response | ||
PostRequest request; | ||
// bytes for post response | ||
bytes response; | ||
// timeout for this response in seconds | ||
uint64 timeout; | ||
// the amount put up to be paid to the relayer, | ||
// this is charged in `IIsmpHost.feeToken` to `msg.sender` | ||
uint256 fee; | ||
// who pays for this request? | ||
address payer; | ||
} | ||
|
||
// The core ISMP API, IIsmpModules use this interface to send outgoing get/post requests & responses | ||
/* | ||
* @title The Ismp Dispatcher | ||
* @author Polytope Labs ([email protected]) | ||
* | ||
* @notice The IHandler interface serves as the entry point for ISMP datagrams, i.e consensus, requests & response messages. | ||
*/ | ||
interface IDispatcher { | ||
/** | ||
* @dev Dispatch a post request to the ISMP router. | ||
* @param request - post request | ||
* @return commitment - the request commitment | ||
*/ | ||
function dispatch(DispatchPost memory request) external returns (bytes32 commitment); | ||
/** | ||
* @dev Dispatch a post request to the ISMP router. | ||
* @param request - post request | ||
* @return commitment - the request commitment | ||
*/ | ||
function dispatch(DispatchPost memory request) external returns (bytes32 commitment); | ||
|
||
/** | ||
* @dev Dispatch a GET request to the ISMP router. | ||
* @param request - get request | ||
* @return commitment - the request commitment | ||
*/ | ||
function dispatch(DispatchGet memory request) external returns (bytes32 commitment); | ||
/** | ||
* @dev Dispatch a GET request to the ISMP router. | ||
* @param request - get request | ||
* @return commitment - the request commitment | ||
*/ | ||
function dispatch(DispatchGet memory request) external returns (bytes32 commitment); | ||
|
||
/** | ||
* @dev Provide a response to a previously received request. | ||
* @param response - post response | ||
* @return commitment - the request commitment | ||
*/ | ||
function dispatch(DispatchPostResponse memory response) external returns (bytes32 commitment); | ||
/** | ||
* @dev Provide a response to a previously received request. | ||
* @param response - post response | ||
* @return commitment - the request commitment | ||
*/ | ||
function dispatch(DispatchPostResponse memory response) external returns (bytes32 commitment); | ||
} |
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 |
---|---|---|
|
@@ -2,67 +2,61 @@ | |
pragma solidity 0.8.17; | ||
|
||
import {IIsmpHost} from "./IIsmpHost.sol"; | ||
import { | ||
PostRequestMessage, | ||
PostResponseMessage, | ||
GetResponseMessage, | ||
PostRequestTimeoutMessage, | ||
PostResponseTimeoutMessage, | ||
GetTimeoutMessage | ||
} from "./Message.sol"; | ||
import {PostRequestMessage, PostResponseMessage, GetResponseMessage, PostRequestTimeoutMessage, PostResponseTimeoutMessage, GetTimeoutMessage} from "./Message.sol"; | ||
|
||
/* | ||
The IHandler interface serves as the entry point for ISMP datagrams, i.e consensus, requests & response messages. | ||
The handler is decoupled from the IsmpHost as it allows for easy upgrading through the cross-chain governor contract. | ||
This way more efficient cryptographic schemes can be employed without cumbersome contract migrations. | ||
* @title The Ismp Handler | ||
* @author Polytope Labs ([email protected]) | ||
* | ||
* @notice The IHandler interface serves as the entry point for ISMP datagrams, i.e consensus, requests & response messages. | ||
*/ | ||
interface IHandler { | ||
/** | ||
* @dev Handle an incoming consensus message. This uses the IConsensusClient contract registered on the host to perform the consensus message verification. | ||
* @param host - Ismp host | ||
* @param proof - consensus proof | ||
*/ | ||
function handleConsensus(IIsmpHost host, bytes memory proof) external; | ||
|
||
/** | ||
* @dev Handles incoming POST requests, check request proofs, message delay and timeouts, then dispatch POST requests to the apropriate contracts. | ||
* @param host - Ismp host | ||
* @param request - batch post requests | ||
*/ | ||
function handlePostRequests(IIsmpHost host, PostRequestMessage memory request) external; | ||
|
||
/** | ||
* @dev Handles incoming POST responses, check response proofs, message delay and timeouts, then dispatch POST responses to the apropriate contracts. | ||
* @param host - Ismp host | ||
* @param response - batch post responses | ||
*/ | ||
function handlePostResponses(IIsmpHost host, PostResponseMessage memory response) external; | ||
|
||
/** | ||
* @dev check response proofs, message delay and timeouts, then dispatch get responses to modules | ||
* @param host - Ismp host | ||
* @param message - batch get responses | ||
*/ | ||
function handleGetResponses(IIsmpHost host, GetResponseMessage memory message) external; | ||
|
||
/** | ||
* @dev check timeout proofs then dispatch to modules | ||
* @param host - Ismp host | ||
* @param message - batch post request timeouts | ||
*/ | ||
function handlePostRequestTimeouts(IIsmpHost host, PostRequestTimeoutMessage memory message) external; | ||
|
||
/** | ||
* @dev check timeout proofs then dispatch to modules | ||
* @param host - Ismp host | ||
* @param message - batch post response timeouts | ||
*/ | ||
function handlePostResponseTimeouts(IIsmpHost host, PostResponseTimeoutMessage memory message) external; | ||
|
||
/** | ||
* @dev dispatch to modules | ||
* @param host - Ismp host | ||
* @param message - batch get request timeouts | ||
*/ | ||
function handleGetRequestTimeouts(IIsmpHost host, GetTimeoutMessage memory message) external; | ||
/** | ||
* @dev Handle an incoming consensus message. This uses the IConsensusClient contract registered on the host to perform the consensus message verification. | ||
* @param host - Ismp host | ||
* @param proof - consensus proof | ||
*/ | ||
function handleConsensus(IIsmpHost host, bytes memory proof) external; | ||
|
||
/** | ||
* @dev Handles incoming POST requests, check request proofs, message delay and timeouts, then dispatch POST requests to the apropriate contracts. | ||
* @param host - Ismp host | ||
* @param request - batch post requests | ||
*/ | ||
function handlePostRequests(IIsmpHost host, PostRequestMessage memory request) external; | ||
|
||
/** | ||
* @dev Handles incoming POST responses, check response proofs, message delay and timeouts, then dispatch POST responses to the apropriate contracts. | ||
* @param host - Ismp host | ||
* @param response - batch post responses | ||
*/ | ||
function handlePostResponses(IIsmpHost host, PostResponseMessage memory response) external; | ||
|
||
/** | ||
* @dev check response proofs, message delay and timeouts, then dispatch get responses to modules | ||
* @param host - Ismp host | ||
* @param message - batch get responses | ||
*/ | ||
function handleGetResponses(IIsmpHost host, GetResponseMessage memory message) external; | ||
|
||
/** | ||
* @dev check timeout proofs then dispatch to modules | ||
* @param host - Ismp host | ||
* @param message - batch post request timeouts | ||
*/ | ||
function handlePostRequestTimeouts(IIsmpHost host, PostRequestTimeoutMessage memory message) external; | ||
|
||
/** | ||
* @dev check timeout proofs then dispatch to modules | ||
* @param host - Ismp host | ||
* @param message - batch post response timeouts | ||
*/ | ||
function handlePostResponseTimeouts(IIsmpHost host, PostResponseTimeoutMessage memory message) external; | ||
|
||
/** | ||
* @dev dispatch to modules | ||
* @param host - Ismp host | ||
* @param message - batch get request timeouts | ||
*/ | ||
function handleGetRequestTimeouts(IIsmpHost host, GetTimeoutMessage memory message) external; | ||
} |
Oops, something went wrong.