Skip to main content

StakingManager

What is StakingManager?

StakingManager handles the interface between Olla and the Aztec rollup. It stakes Aztec tokens as attesters, tracks their on-chain state, harvests sequencer rewards, and manages the exit process when funds need to be unstaked.

It maintains a registry of all attesters the protocol has deposited, grouped by status: Queued (waiting for rollup activation), Active (validating), or Exiting (withdrawal initiated).

Key responsibilities:

  • Depositing Aztec tokens into the rollup as new attesters.
  • Tracking attester balances and detecting slashing via delta updates.
  • Harvesting sequencer rewards into the RewardsAccumulator.
  • Initiating and finalizing attester exits.
  • Provisioning attester keys from the StakingProviderRegistry.

StakingManager is upgradeable via UUPS proxy.

Attester lifecycle

Key provisioned → Queued → Active → Exiting → Finalized (removed)
  1. Queued: OllaCore calls stake(), which provisions a key from the registry and deposits into the rollup's entry queue.
  2. Active: After the rollup flushes its entry queue, refreshAttesterState() promotes the attester.
  3. Exiting: When funds need to be unstaked, unstake() initiates a withdrawal on the rollup.
  4. Finalized: refreshAttesterState() detects the exit is complete, claims the funds, and removes the attester.

Slashing detection

refreshAttesterState() compares each attester's on-chain balance against the protocol's last known balance. Any decrease without an exit is recorded as slashing. The slashing delta is reported to OllaCore during updateAccounting(), which adjusts the exchange rate.

Methods

Permissionless

refreshAttesterState()

Sync attester states with the rollup. Detects slashing, promotes queued attesters, and finalizes exits.

function refreshAttesterState(address[] calldata attesters) external

purgeFailedQueueEntry()

Clean up an attester that failed rollup activation (invalid BLS proof, duplicate key).

function purgeFailedQueueEntry(address attester) external

Core-only

Called by OllaCore during rebalance.

stake()

Deposit Aztec into the rollup as a new attester.

function stake(uint256 amount) external returns (uint256 stakedAmount)

unstake()

Initiate withdrawal for the given amount.

function unstake(uint256 amount) external returns (uint256 unstakedAmount)

harvestRewards()

Claim sequencer rewards into RewardsAccumulator.

function harvestRewards() external returns (uint256 harvested)

getUnstakedFunds()

Sweep completed exits back to OllaCore.

function getUnstakedFunds() external returns (uint256 received, uint256 exitAmount)

getSlashingDelta()

Report cumulative slashing since last accounting.

function getSlashingDelta() external view returns (uint256 slashingDelta)

getClaimableRewards()

Report unclaimed rewards balance.

function getClaimableRewards() external view returns (uint256 claimableRewards)

View methods

totalStaked()

Total Aztec currently staked on the rollup.

function totalStaked() external view returns (uint256 stakedTotal)

pendingUnstakes()

Total Aztec in the process of being withdrawn.

function pendingUnstakes() external view returns (uint256 pendingUnstakeAmount)

canStake()

Whether the protocol can stake more (keys available and amount meets threshold).

function canStake(uint256 amount) external view returns (bool)

getStakingState()

Full snapshot: staked, pending unstakes, queued/active/exiting counts.

function getStakingState() external view returns (StakingState memory state)

getProviderConfig()

Current staking provider configuration.

function getProviderConfig() external view returns (ProviderConfig memory)

getActivatedAttesterCount()

Number of active attesters on the rollup.

function getActivatedAttesterCount() external view returns (uint256)

getPendingUnstakeCount()

Number of attesters currently exiting.

function getPendingUnstakeCount() external view returns (uint256)

hasFinalizedUnstakes()

Whether any exits have completed and are ready to claim.

function hasFinalizedUnstakes() external view returns (bool)

Events

event StakedWithProvider(address indexed attester, uint256 indexed amount)

New attester deposited into the rollup.

event UnstakeInitiated(address indexed attester, uint256 indexed amount)

Withdrawal initiated for an attester.

event UnstakeFinalized(address indexed attester, uint256 indexed amount)

Attester exit completed and funds claimed.

event RewardsHarvested(uint256 indexed amount)

Sequencer rewards claimed from the rollup.

event RewardsHarvestFailed(bytes reason)

Reward claim failed (logged, not reverted).

event AttesterStateRefreshed(address indexed attester, uint256 indexed oldBalance, uint256 indexed newBalance)

Attester state synced with rollup.

event AttesterRemoved(address indexed attester)

Attester fully exited and removed from tracking.

event FailedQueueEntryPurged(address indexed attester, uint256 indexed recoveredAmount)

Failed queue entry cleaned up.

event UnstakedFundsClaimed(uint256 indexed amount)

Completed exit funds swept to OllaCore.