Destination

Git Source

Inherits: ExecutionHub, DestinationEvents, InterfaceDestination

Destination contract is used for receiving messages from other chains. It relies on Notary-signed statements to get the truthful states of the remote chains. These states are then used to verify the validity of the messages sent from the remote chains. Destination is responsible for the following:

  • Accepting the Attestations from the local Inbox contract.
  • Using these Attestations to execute the messages (see parent ExecutionHub).
  • Passing the Agent Merkle Roots from the Attestations to the local LightManager contract, if deployed on a non-Synapse chain.
  • Keeping track of the remote domains GasData submitted by Notaries, that could be later consumed by the local GasOracle contract.

State Variables

_nextAgentRoot

Invariant: this is either current LightManager root, or the pending root to be passed to LightManager once its optimistic period is over.

bytes32 internal _nextAgentRoot;

destStatus

Returns status of Destination contract as far as snapshot/agent roots are concerned

DestinationStatus public destStatus;

lastAttestationNonce

Returns the nonce of the last attestation submitted by a Notary with a given agent index.

Will return zero if the Notary hasn't submitted any attestations yet.

mapping(uint32 => uint32) public lastAttestationNonce;

_storedAttestations

Stored lookup data for all accepted Notary Attestations

StoredAttData[] internal _storedAttestations;

_storedGasData

Remote domains GasData submitted by Notaries

mapping(uint32 => StoredGasData) internal _storedGasData;

Functions

constructor

constructor(uint32 synapseDomain_, address agentManager_, address inbox_)
    AgentSecured("0.0.3", synapseDomain_, agentManager_, inbox_);

initialize

Initializes Destination contract:

  • msg.sender is set as contract owner
function initialize(bytes32 agentRoot) external initializer;

acceptAttestation

Accepts an attestation, which local AgentManager verified to have been signed by an active Notary for this chain.

Attestation is created whenever a Notary-signed snapshot is saved in Summit on Synapse Chain.

  • Saved Attestation could be later used to prove the inclusion of message in the Origin Merkle Tree.
  • Messages coming from chains included in the Attestation's snapshot could be proven.
  • Proof only exists for messages that were sent prior to when the Attestation's snapshot was taken.

Will revert if any of these is true:

  • Called by anyone other than local AgentManager.
  • Attestation payload is not properly formatted.
  • Attestation signer is in Dispute.
  • Attestation's snapshot root has been previously submitted. Note: agentRoot and snapGas have been verified by the local AgentManager.
function acceptAttestation(
    uint32 notaryIndex,
    uint256 sigIndex,
    bytes memory attPayload,
    bytes32 agentRoot,
    ChainGas[] memory snapGas
) external onlyInbox returns (bool wasAccepted);

Parameters

NameTypeDescription
notaryIndexuint32Index of Attestation Notary in Agent Merkle Tree
sigIndexuint256Index of stored Notary signature
attPayloadbytesRaw payload with Attestation data
agentRootbytes32Agent Merkle Root from the Attestation
snapGasChainGas[]Gas data for each chain in the Attestation's snapshot

Returns

NameTypeDescription
wasAcceptedboolWhether the Attestation was accepted

passAgentRoot

Attempts to pass a quarantined Agent Merkle Root to a local Light Manager.

Will do nothing, if root optimistic period is not over.

function passAgentRoot() public returns (bool rootPending);

Returns

NameTypeDescription
rootPendingboolWhether there is a pending agent merkle root left

attestationsAmount

Returns the total amount of Notaries attestations that have been accepted.

function attestationsAmount() external view returns (uint256);

getAttestation

Returns a Notary-signed attestation with a given index.

Index refers to the list of all attestations accepted by this contract.

Attestations are created on Synapse Chain whenever a Notary-signed snapshot is accepted by Summit. Will return an empty signature if this contract is deployed on Synapse Chain.

function getAttestation(uint256 index) external view returns (bytes memory attPayload, bytes memory attSignature);

Parameters

NameTypeDescription
indexuint256Attestation index

Returns

NameTypeDescription
attPayloadbytesRaw payload with Attestation data
attSignaturebytesNotary signature for the reported attestation

getGasData

Returns the gas data for a given chain from the latest accepted attestation with that chain.

Will return empty values if there is no data for the domain, or if the notary who provided the data is in dispute.

function getGasData(uint32 domain) external view returns (GasData gasData, uint256 dataMaturity);

Parameters

NameTypeDescription
domainuint32Domain for the chain

Returns

NameTypeDescription
gasDataGasDataGas data for the chain
dataMaturityuint256Gas data age in seconds

nextAgentRoot

Returns Agent Merkle Root to be passed to LightManager once its optimistic period is over.

function nextAgentRoot() external view returns (bytes32);

_saveAgentRoot

Saves Agent Merkle Root from the accepted attestation, if there is no pending root to be passed to LightManager. Returns the updated "last snapshot root / last agent root" status struct.

function _saveAgentRoot(bool rootPending, bytes32 agentRoot, uint32 notaryIndex)
    internal
    returns (DestinationStatus memory status);

_saveGasData

Saves updated values from the snapshot's gas data list.

function _saveGasData(ChainGas[] memory snapGas, uint32 notaryIndex) internal;

Structs

StoredAttData

struct StoredAttData {
    bytes32 agentRoot;
    bytes32 dataHash;
}

StoredGasData

struct StoredGasData {
    GasData gasData;
    uint32 notaryIndex;
    uint40 submittedAt;
}