ReceiptLib
Receipt structure represents a Notary statement that a certain message has been executed in ExecutionHub
.
- It is possible to prove the correctness of the tips payload using the message hash, therefore tips are not included in the receipt.
- Receipt is signed by a Notary and submitted to
Summit
in order to initiate the tips distribution for an executed message. - If a message execution fails the first time, the
finalExecutor
field will be set to zero address. In this case, when the message is finally executed successfully, thefinalExecutor
field will be updated. Both receipts will be considered valid.
Memory layout of Receipt fields
Position | Field | Type | Bytes | Description |
---|---|---|---|---|
[000..004) | origin | uint32 | 4 | Domain where message originated |
[004..008) | destination | uint32 | 4 | Domain where message was executed |
[008..040) | messageHash | bytes32 | 32 | Hash of the message |
[040..072) | snapshotRoot | bytes32 | 32 | Snapshot root used for proving the message |
[072..073) | stateIndex | uint8 | 1 | Index of state used for the snapshot proof |
[073..093) | attNotary | address | 20 | Notary who posted attestation with snapshot root |
[093..113) | firstExecutor | address | 20 | Executor who performed first valid execution |
[113..133) | finalExecutor | address | 20 | Executor who successfully executed the message |
State Variables
OFFSET_ORIGIN
The variables below are not supposed to be used outside of the library directly.
uint256 private constant OFFSET_ORIGIN = 0;
OFFSET_DESTINATION
uint256 private constant OFFSET_DESTINATION = 4;
OFFSET_MESSAGE_HASH
uint256 private constant OFFSET_MESSAGE_HASH = 8;
OFFSET_SNAPSHOT_ROOT
uint256 private constant OFFSET_SNAPSHOT_ROOT = 40;
OFFSET_STATE_INDEX
uint256 private constant OFFSET_STATE_INDEX = 72;
OFFSET_ATT_NOTARY
uint256 private constant OFFSET_ATT_NOTARY = 73;
OFFSET_FIRST_EXECUTOR
uint256 private constant OFFSET_FIRST_EXECUTOR = 93;
OFFSET_FINAL_EXECUTOR
uint256 private constant OFFSET_FINAL_EXECUTOR = 113;
Functions
formatReceipt
Returns a formatted Receipt payload with provided fields.
function formatReceipt(
uint32 origin_,
uint32 destination_,
bytes32 messageHash_,
bytes32 snapshotRoot_,
uint8 stateIndex_,
address attNotary_,
address firstExecutor_,
address finalExecutor_
) internal pure returns (bytes memory);
Parameters
Name | Type | Description |
---|---|---|
origin_ | uint32 | Domain where message originated |
destination_ | uint32 | Domain where message was executed |
messageHash_ | bytes32 | Hash of the message |
snapshotRoot_ | bytes32 | Snapshot root used for proving the message |
stateIndex_ | uint8 | Index of state used for the snapshot proof |
attNotary_ | address | Notary who posted attestation with snapshot root |
firstExecutor_ | address | Executor who performed first valid execution attempt |
finalExecutor_ | address | Executor who successfully executed the message |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes | Formatted receipt |
castToReceipt
Returns a Receipt view over the given payload.
Will revert if the payload is not a receipt.
function castToReceipt(bytes memory payload) internal pure returns (Receipt);
castToReceipt
Casts a memory view to a Receipt view.
Will revert if the memory view is not over a receipt.
function castToReceipt(MemView memView) internal pure returns (Receipt);
isReceipt
Checks that a payload is a formatted Receipt.
function isReceipt(MemView memView) internal pure returns (bool);
hashValid
Returns the hash of an Receipt, that could be later signed by a Notary to signal that the receipt is valid.
function hashValid(Receipt receipt) internal pure returns (bytes32);
hashInvalid
Returns the hash of a Receipt, that could be later signed by a Guard to signal that the receipt is invalid.
function hashInvalid(Receipt receipt) internal pure returns (bytes32);
unwrap
Convenience shortcut for unwrapping a view.
function unwrap(Receipt receipt) internal pure returns (MemView);
equals
Compares two Receipt structures.
function equals(Receipt a, Receipt b) internal pure returns (bool);
origin
Returns receipt's origin field
function origin(Receipt receipt) internal pure returns (uint32);
destination
Returns receipt's destination field
function destination(Receipt receipt) internal pure returns (uint32);
messageHash
Returns receipt's "message hash" field
function messageHash(Receipt receipt) internal pure returns (bytes32);
snapshotRoot
Returns receipt's "snapshot root" field
function snapshotRoot(Receipt receipt) internal pure returns (bytes32);
stateIndex
Returns receipt's "state index" field
function stateIndex(Receipt receipt) internal pure returns (uint8);
attNotary
Returns receipt's "attestation notary" field
function attNotary(Receipt receipt) internal pure returns (address);
firstExecutor
Returns receipt's "first executor" field
function firstExecutor(Receipt receipt) internal pure returns (address);
finalExecutor
Returns receipt's "final executor" field
function finalExecutor(Receipt receipt) internal pure returns (address);