AdminV2

Git Source

Inherits: AccessControlEnumerable, IAdminV2, IAdminV2Errors

Provides administrative functions and controls for managing the FastBridgeV2 contract, including access control and configuration settings.

State Variables

NATIVE_GAS_TOKEN

The address reserved for the native gas token (ETH on Ethereum and most L2s, AVAX on Avalanche, etc.).

address public constant NATIVE_GAS_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

QUOTER_ROLE

The role identifier for the Quoter API's off-chain authentication.

Only addresses with this role can post FastBridge quotes to the API.

bytes32 public constant QUOTER_ROLE = keccak256("QUOTER_ROLE");

GUARD_ROLE

The role identifier for the Guard's on-chain authentication in FastBridge.

Only addresses with this role can dispute submitted relay proofs during the dispute period.

bytes32 public constant GUARD_ROLE = keccak256("GUARD_ROLE");

CANCELER_ROLE

The role identifier for the Canceler's on-chain authentication in FastBridge.

Only addresses with this role can cancel a FastBridge transaction without the cancel delay.

bytes32 public constant CANCELER_ROLE = keccak256("CANCELER_ROLE");

GOVERNOR_ROLE

The role identifier for the Governor's on-chain administrative authority.

Only addresses with this role can perform administrative tasks within the contract.

bytes32 public constant GOVERNOR_ROLE = keccak256("GOVERNOR_ROLE");

FEE_BPS

The denominator for fee rates, representing 100%.

uint256 public constant FEE_BPS = 1e6;

FEE_RATE_MAX

The maximum protocol fee rate: 1% of the origin amount.

uint256 public constant FEE_RATE_MAX = 0.01e6;

MIN_CANCEL_DELAY

The minimum cancel delay that can be set by the governor.

uint256 public constant MIN_CANCEL_DELAY = 1 hours;

DEFAULT_CANCEL_DELAY

The default cancel delay set during contract deployment.

uint256 public constant DEFAULT_CANCEL_DELAY = 1 days;

MIN_DISPUTE_PENALTY_TIME

The minimum dispute penalty time that can be set by the governor.

uint256 public constant MIN_DISPUTE_PENALTY_TIME = 1 minutes;

DEFAULT_DISPUTE_PENALTY_TIME

The default dispute penalty time set during contract deployment.

uint256 public constant DEFAULT_DISPUTE_PENALTY_TIME = 30 minutes;

protocolFeeRate

The protocol fee rate taken on the origin amount deposited in the origin chain.

uint256 public protocolFeeRate;

protocolFees

The accumulated protocol fee amounts.

mapping(address => uint256) public protocolFees;

cancelDelay

The delay period after which a transaction can be permissionlessly cancelled.

uint256 public cancelDelay;

deployBlock

The block number at which the contract was deployed.

This used to be immutable in V1, but was adjusted to be mutable in V2 for chains like Arbitrum that implement the block.number as the underlying L1 block number rather than the chain's native block number. This is exposed for conveniece for off-chain indexers that need to know the deployment block.

uint256 public deployBlock;

disputePenaltyTime

The timeout period that is used to temporarily disactivate a disputed prover.

uint256 public disputePenaltyTime;

_allProvers

A list of all provers ever added to the contract. Can hold up to 2^16-1 provers.

address[] private _allProvers;

_proverInfos

A mapping of provers to their information: id and activeFromTimestamp.

mapping(address => ProverInfo) private _proverInfos;

chainGasAmount

This variable is deprecated and should not be used.

Use ZapNative V2 requests instead.

uint256 public immutable chainGasAmount = 0;

Functions

constructor

constructor(address defaultAdmin);

addProver

Allows the role admin to add a new prover to the contract.

function addProver(address prover) external onlyRole(DEFAULT_ADMIN_ROLE);

removeProver

Allows the role admin to remove a prover from the contract.

function removeProver(address prover) external onlyRole(DEFAULT_ADMIN_ROLE);

setCancelDelay

Allows the governor to set the cancel delay. The cancel delay is the time period after the transaction deadline during which a transaction can be permissionlessly cancelled if it hasn't been proven by any Relayer.

function setCancelDelay(uint256 newCancelDelay) external onlyRole(GOVERNOR_ROLE);

setDeployBlock

Allows the default admin to set the deploy block.

This is only relevant for chains like Arbitrum that implement the block.number as the underlying L1 block number rather than the chain's native block number.

function setDeployBlock(uint256 blockNumber) external onlyRole(DEFAULT_ADMIN_ROLE);

setDisputePenaltyTime

Allows the governor to set the dispute penalty time. The dispute penalty time is the time period used to temporarily deactivate a prover if its proof is disputed: prover will be inactive for the dispute penalty time after the dispute is submitted.

function setDisputePenaltyTime(uint256 newDisputePenaltyTime) external onlyRole(GOVERNOR_ROLE);

setProtocolFeeRate

Allows the governor to set the protocol fee rate. The protocol fee is taken from the origin amount and is only applied to completed and claimed transactions.

The protocol fee is abstracted away from the relayers; they always operate using the amounts after fees. The origin amount they see in the emitted log is what they get credited with.

function setProtocolFeeRate(uint256 newFeeRate) external onlyRole(GOVERNOR_ROLE);

sweepProtocolFees

Allows the governor to withdraw the accumulated protocol fees from the contract.

function sweepProtocolFees(address token, address recipient) external onlyRole(GOVERNOR_ROLE);

getProvers

Returns the list of the active provers.

function getProvers() external view returns (address[] memory provers);

getProverInfo

Returns the information about the prover with the provided address.

function getProverInfo(address prover) external view returns (uint16 proverID, uint256 activeFromTimestamp);

Returns

NameTypeDescription
proverIDuint16The ID of the prover if it has been added before, or zero otherwise.
activeFromTimestampuint256The timestamp when the prover becomes active, or zero if the prover isn't active.

getProverInfoByID

Returns the information about the prover with the provided ID.

function getProverInfoByID(uint16 proverID) external view returns (address prover, uint256 activeFromTimestamp);

Returns

NameTypeDescription
proveraddressThe address of the prover with the provided ID, or zero the ID does not exist.
activeFromTimestampuint256The timestamp when the prover becomes active, or zero if the prover isn't active.

getActiveProverID

Returns the ID of the active prover, or zero if the prover is not currently active.

function getActiveProverID(address prover) public view returns (uint16);

_applyDisputePenaltyTime

Internal logic to apply the dispute penalty time to a given prover. Will make the prover inactive for disputePenaltyTime seconds. No-op if the prover ID does not exist or prover is already inactive.

function _applyDisputePenaltyTime(uint16 proverID) internal;

_setCancelDelay

Internal logic to set the cancel delay. Security checks are performed outside of this function.

This function is marked as private to prevent child contracts from calling it directly.

function _setCancelDelay(uint256 newCancelDelay) private;

_setDeployBlock

Internal logic to set the deploy block. Security checks are performed outside of this function.

This function is marked as private to prevent child contracts from calling it directly.

function _setDeployBlock(uint256 blockNumber) private;

_setDisputePenaltyTime

Internal logic to set the dispute penalty time. Security checks are performed outside of this function.

This function is marked as private to prevent child contracts from calling it directly.

function _setDisputePenaltyTime(uint256 newDisputePenaltyTime) private;

Structs

ProverInfo

Struct for storing information about a prover.

struct ProverInfo {
    uint16 id;
    uint240 activeFromTimestamp;
}