IStateHub

Git Source

Functions

isValidState

Check that a given state is valid: matches the historical state of Origin contract. Note: any Agent including an invalid state in their snapshot will be slashed upon providing the snapshot and agent signature for it to Origin contract.

*Will revert if any of these is true:

  • State payload is not properly formatted.*
function isValidState(bytes memory statePayload) external view returns (bool isValid);

Parameters

NameTypeDescription
statePayloadbytesRaw payload with state data

Returns

NameTypeDescription
isValidboolWhether the provided state is valid

statesAmount

Returns the amount of saved states so far.

This includes the initial state of "empty Origin Merkle Tree".

function statesAmount() external view returns (uint256);

suggestLatestState

Suggest the data (state after latest sent message) to sign for an Agent. Note: signing the suggested state data will will never lead to slashing of the actor, assuming they have confirmed that the block, which number is included in the data, is not subject to reorganization (which is different for every observed chain).

function suggestLatestState() external view returns (bytes memory statePayload);

Returns

NameTypeDescription
statePayloadbytesRaw payload with the latest state data

suggestState

Given the historical nonce, suggest the state data to sign for an Agent. Note: signing the suggested state data will will never lead to slashing of the actor, assuming they have confirmed that the block, which number is included in the data, is not subject to reorganization (which is different for every observed chain).

function suggestState(uint32 nonce) external view returns (bytes memory statePayload);

Parameters

NameTypeDescription
nonceuint32Historical nonce to form a state

Returns

NameTypeDescription
statePayloadbytesRaw payload with historical state data