AgentSecured
Inherits: MessagingBase, IAgentSecured
Base contract for messaging contracts that are secured by the agent manager.
AgentSecured
relies on AgentManager
to provide the following functionality:
- Keep track of agents and their statuses.
- Pass agent-signed statements that were verified by the agent manager.
- These statements are considered valid indefinitely, unless the agent is disputed.
- Disputes are opened and resolved by the agent manager.
AgentSecured
implementation should never use statements signed by agents that are disputed.
State Variables
agentManager
Returns the address of the local AgentManager contract, which is treated as the "source of truth" for agent statuses.
address public immutable agentManager;
inbox
Returns the address of the local Inbox contract, which is treated as the "source of truth" for agent-signed statements.
Inbox passes verified agent statements to IAgentSecured
contract.
address public immutable inbox;
_disputes
mapping(uint32 => DisputeStatus) internal _disputes;
__GAP
gap for upgrade safety
uint256[49] private __GAP;
Functions
onlyAgentManager
modifier onlyAgentManager();
onlyInbox
modifier onlyInbox();
constructor
constructor(string memory version_, uint32 synapseDomain_, address agentManager_, address inbox_)
MessagingBase(version_, synapseDomain_);
openDispute
Local AgentManager should call this function to indicate that a dispute between a Guard and a Notary has been opened.
function openDispute(uint32 guardIndex, uint32 notaryIndex) external onlyAgentManager;
Parameters
Name | Type | Description |
---|---|---|
guardIndex | uint32 | Index of the Guard in the Agent Merkle Tree |
notaryIndex | uint32 | Index of the Notary in the Agent Merkle Tree |
resolveDispute
Local AgentManager should call this function to indicate that a dispute has been resolved due to one of the agents being slashed.
rivalIndex
will be ZERO, if the slashed agent was not in the Dispute.
function resolveDispute(uint32 slashedIndex, uint32 rivalIndex) external onlyAgentManager;
Parameters
Name | Type | Description |
---|---|---|
slashedIndex | uint32 | Index of the slashed agent in the Agent Merkle Tree |
rivalIndex | uint32 | Index of the their Dispute Rival in the Agent Merkle Tree |
agentStatus
Returns (flag, domain, index) for a given agent. See Structures.sol for details.
Will return AgentFlag.Fraudulent for agents that have been proven to commit fraud, but their status is not updated to Slashed yet.
function agentStatus(address agent) external view returns (AgentStatus memory);
Parameters
Name | Type | Description |
---|---|---|
agent | address | Agent address |
Returns
Name | Type | Description |
---|---|---|
<none> | AgentStatus | Status for the given agent: (flag, domain, index). |
getAgent
Returns agent address and their current status for a given agent index.
Will return empty values if agent with given index doesn't exist.
function getAgent(uint256 index) external view returns (address agent, AgentStatus memory status);
Parameters
Name | Type | Description |
---|---|---|
index | uint256 | Agent index in the Agent Merkle Tree |
Returns
Name | Type | Description |
---|---|---|
agent | address | Agent address |
status | AgentStatus | Status for the given agent: (flag, domain, index) |
latestDisputeStatus
Returns (flag, openedAt, resolvedAt) that describes the latest status of the latest dispute for an agent with a given index.
Will return empty values if agent with given index doesn't exist.
function latestDisputeStatus(uint32 agentIndex) external view returns (DisputeStatus memory);
Parameters
Name | Type | Description |
---|---|---|
agentIndex | uint32 | Agent index in the Agent Merkle Tree |
Returns
Name | Type | Description |
---|---|---|
<none> | DisputeStatus | Latest dispute status for the given agent: (flag, openedAt, resolvedAt) |
_agentStatus
Returns status of the given agent: (flag, domain, index).
function _agentStatus(address agent) internal view returns (AgentStatus memory);
_getAgent
Returns agent and their status for a given agent index. Returns zero values for non existing indexes.
function _getAgent(uint256 index) internal view returns (address agent, AgentStatus memory status);
_notaryDisputeExists
Checks if a Dispute exists for the given Notary. This function returns true, if
Notary is in ongoing Dispute, or if Dispute was resolved not in Notary's favor.
In both cases we can't trust Notary's data.
Note: Agent-Secured contracts can trust Notary data only if both _notaryDisputeExists
and
_notaryDisputeTimeout
return false.
function _notaryDisputeExists(uint32 notaryIndex) internal view returns (bool);
_notaryDisputeTimeout
Checks if a Notary recently won a Dispute and is still in the "post-dispute" timeout period.
In this period we still can't trust Notary's data, though we can optimistically assume that
that the data will be correct after the timeout (assuming no new Disputes are opened).
Note: Agent-Secured contracts can trust Notary data only if both _notaryDisputeExists
and
_notaryDisputeTimeout
return false.
function _notaryDisputeTimeout(uint32 notaryIndex) internal view returns (bool);