The GatewayCheckpoint contract is a core component for managing gateway-related state and historical data. It allows administrators and schedulers to create and update checkpoints for gateways, enabling operations such as staking, unstaking, and compute unit tracking.
Key Features
Gateway Checkpoint Management:
Supports the creation of scheduler and operation checkpoints for gateways.
Tracks gateway states by epoch for accurate reporting and auditing.
Role-Based Access Control:
Admins and schedulers can update scheduler checkpoints.
Gateway staking contracts can update operation checkpoints.
Event-Driven Architecture:
Emits events for every checkpoint update, facilitating off-chain integration and monitoring.
Contract Roles
Access Control
The contract uses OpenZeppelin's AccessControl to enforce role-based access.
DEFAULT_ADMIN_ROLE:
Can manage scheduler checkpoints.
Assigned to the deploying address by default.
SCHEDULER_ROLE:
Can update scheduler checkpoints.
Modifiers
onlyAdminOrScheduler: Restricts function calls to accounts with DEFAULT_ADMIN_ROLE or SCHEDULER_ROLE.
onlyStaking: Restricts function calls to the address of the GatewayStaking contract.
Data Structures
GatewaySchedulerCheckpoint
Represents a scheduler checkpoint for a gateway in a specific epoch.
epoch: The epoch of the checkpoint.
gatewayIds: Array of gateway IDs included in the checkpoint.
computeUnits: Array of compute units for each gateway.
isFinalized: Boolean indicating whether the checkpoint is set.
GatewayOperationCheckpoint
Represents an operation checkpoint for a gateway in a specific epoch.
id: Gateway ID.
epoch: Epoch of the operation.
amount: Amount involved in the operation.
totalPoolBalanceAfterOperation: Pool balance after the operation.