This document provides an overview of the TemporalGovernor
smart contract written in Solidity.
-
Safe Math Operations: The contract leverages the OpenZeppelin
SafeCast
library to perform safe casting operations. -
Pause Functionality: The contract uses the
Pausable
contract from OpenZeppelin to add pausing mechanisms. This allows certain functionalities of the contract to be paused and unpaused. -
Owner Permissions: The contract inherits from OpenZeppelin's
Ownable
contract which restricts certain functions to be executable only by the contract owner. -
Wormhole Bridge Reference: The contract holds an immutable reference to the Wormhole bridge. Wormhole is a cross-chain communication protocol.
-
Proposal Delay and Permissionless Unpause Time: The contract keeps track of the time a proposal must wait before being processed and the time until this contract can be unpaused without permission.
-
Trusted Senders: The contract maintains a mapping of chain ids to trusted senders to validate incoming requests.
-
Queued Transactions: The contract also maintains a mapping of message hashes to
ProposalInfo
objects. This mechanism is in place to prevent transaction replay and enforce time limits.
-
Wormhole Bridge: An immutable reference to the Wormhole bridge contract.
-
Proposal Delay: An immutable variable which keeps the amount of time a proposal must wait before it can be processed.
-
Permissionless Unpause Time: An immutable variable which defines the amount of time until the contract can be unpaused without any permission.
-
Last Pause Time: The contract maintains a timestamp of when it was last paused.
-
Guardian Pause Allowed: A Boolean variable indicating whether or not the guardian can pause the contract. It starts as true and then is set to false when the guardian pauses.
-
Trusted Senders: A mapping from chain id to a trusted sender (in bytes32 format). This mapping is used to validate incoming requests.
-
Queued Transactions: A mapping from message hashes to
ProposalInfo
objects. This mapping is used to ensure transactions aren't processed more than once, and that time restrictions are enforced.
The contract provides various functionalities:
-
Managing trusted senders: The contract maintains a list of trusted senders and provides a function to update this list.
-
Proposal queueing and execution: Proposals can be queued and later executed.
-
Pausing and unpausing: The contract can be paused and unpaused. After a certain delay, it can be unpaused without any permission (permissionless unpause).
-
Guardian management: The contract allows for a guardian who can pause the contract. This ability can be granted, revoked, and its status can be toggled. The guardian's ability to pause is revoked when the contract is paused.
-
Emergency actions: In case of an emergency, the contract provides a fast-track mechanism for proposals to be executed only when the contract is paused. A proposal cannot be fast tracked when the contract is unpaused.
-
Helper functions: There are several private helper functions used internally by the contract for queueing proposals, executing proposals, and performing payload sanity checks.