Protocol contracts to power the AVS service with registration, challenge creation/resolution, and slashing.
PreconfChallengeManager
is the central contract of the protocol, which inherits ServiceManagerBase
from the EigenLayer middleware for operator registration and deregistrating in communication with the EigenLayer core contracts. Additionally, it implements the logic to freeze/slash an operator (needs to be implemented as it depends on the latest EigenLayer core contracts). Read more about ServiceManagerBase
here.
function initialize(
IPauserRegistry _pauserRegistry,
uint256 _initialPausedStatus,
address _initialOwner,
PreconfChallengeManager _challengeManager
) external initializer
The initialize
function is used to initialize the contract with the following parameters:
_pauserRegistry
: The address of thePauserRegistry
contract._initialPausedStatus
: The initial paused status of the contract._initialOwner
: The initial owner of the contract._challengeManager
: The address of thePreconfChallengeManager
contract.
Effects:
- Initialization of the AVS service contract
Requirements:
- Can only be called once.
function freezeOperator(address operatorAddr) external onlyChallengeManager
Freezes/slashes an operator due to violation of a preconfirmation promise. Needs to be fully implemented.
operatorAddr
: The address of the operator to penalize.
Effects:
- Penalizes the operator by freezing/slashing their stake.
Requirements:
- Can only be called by the
PreconfChallengeManager
contract.
PreconfChallengeManager
is a periphery contract that allows to raise and resolve challenges by integrating with Relic Protocol's Transaction Prover.
function raiseAndResolveChallenge(Preconf calldata preconf, bytes calldata preconfSigned, bytes calldata proof)
external
Allows anyone to raise and resolve a challenge for a signed preconfirmation. The function takes three parameters:
preconf
: the preconfirmation datapreconfSigned
: the preconfirmation data signed by the operator/preconferproof
: the proof that the preconfirmation's transaction hash was not included in the promised block.
Using these parameters, the function verifies the proof with the prover to determine if the preconfirmation promise was violated. If the proof is valid, the contract penalizes the operator by calling the freezeOperator
function from the PreconfServiceManager
contract.
Effects:
- Raises a challenge to penalize an operator.
Requirements:
- Can only be called with valid proof parameters.
Requires Foundry.
To build the contracts:
git clone https://github.com/cairoeth/preconfirmations.git
cd contracts
forge install
forge build
In order to run unit tests, run:
forge test
To check the test coverage, run:
forge coverage
In order to deploy the contracts, you need to set the PRIVATE_KEY
variable in the .env
file, then run the script to deploy on the network (assuming Anvil is running):
forge script script/Preconf.s.sol:DeployPreconf --rpc-url http://127.0.0.1:8545 --broadcast