Gateway

The Ethereum gateway is the connection between client and the relayer. Gateway implements the below given interface.

Gateway does two things mainly it accepts the tasks for preExecution for which it does payload hash verification and then logs out the new task for relayer to pick up and after the private computation it accepts the task for postExecution procedure where it does payload hash verification, result signature verification, packet signature verification and then call back the client with computed result for the task and logs out the task details. Initialize and updateRoute are periphary functions in which you can initialize a master verification address for the contract and then check the validity of the (route -> verification address) map for updateRoute and this map is to be stored onchain for postExecution validity checks.

Gateway Interface:

interface IGateway {
    /// @notice Initialize the verification address
    /// @param _masterVerificationAddress The verification input address
    function initialize(address _masterVerificationAddress) external;
    
    /// @notice Updating the route
    /// @param _route                 Route name
    /// @param _verificationAddress   Address corresponding to the route
    /// @param _signature             Signed hashed inputs(_route + _verificationAddress)
    function updateRoute(string memory _route, address _verificationAddress, bytes memory _signature) external;
    
    /// @notice Pre-Execution
    /// @param _task                  Task struct
    /// @param _info                  ExecutionInfo struct
    function preExecution(Task memory _task, ExecutionInfo memory _info) external;
    
    /// @notice Post-Execution
    /// @param _taskId                Task Id of the executed message
    /// @param _sourceNetwork         Source network of the message
    /// @param _info                  PostExecutionInfo struct
    function postExecution(uint256 _taskId, string memory _sourceNetwork, PostExecutionInfo memory _info) external;
}

Data Structs:

struct Task {
        address callback_address;
        bytes4 callback_selector;
        address user_address;
        string source_network;
        string routing_info;
        bytes32 payload_hash;
        bool completed;
}

struct ExecutionInfo {
        bytes user_key;
        string routing_code_hash;
        string handle;
        bytes12 nonce;
        bytes payload;
        bytes payload_signature;
}

struct PostExecutionInfo {
        bytes32 payload_hash;
        bytes result;
        bytes32 result_hash;
        bytes result_signature;
        bytes32 packet_hash;
        bytes packet_signature;
}

Last updated