Do not use it in Production, testnet only.
PoC Mangata AVS implementation
You will need foundry to run local testnet. You will need Rust toolchain to build avs-finalizer binary. And golang toolchain with zap-pretty to run the aggregator.
curl -L https://foundry.paradigm.xyz | bash
foundryup
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
go install github.com/maoueh/zap-pretty@latest
This simple session illustrates the basic flow of the AVS. The makefile commands are hardcoded for a single avs-finalizer. For more avs-finalizers you would need to modify setup script to distribute mock ERC20 tokens and deposit into AVS per avs-finalizer. See 0_AnvilSetup.s.sol script for more info.
Init submodules and update deps,
git submodule init
git submodule update
Start anvil in a separate terminal:
make start-anvil-chain-with-el-and-avs-deployed
The above command starts a local anvil chain from a saved state with eigenlayer and mangata-avs contracts already deployed (but no avs-finalizer registered).
Then start the aggregator:
make start-avs-aggregator
And lately, the avs-finalizer,
make start-avs-finalizer
The architecture of the AVS contains:
- Eigenlayer core contracts
- AVS contracts
- ServiceManager which will eventually contain slashing logic but for M2 is just a placeholder.
- TaskManager which contains task creation and task response logic.
- Set of registry contracts to manage avs-finalizers opted in to this avs
- Task Generator
- in a real world scenario, this could be a separate entity, but for this simple demo, the aggregator also acts as the task generator
- Aggregator
- aggregates BLS signatures from avs-finalizers and posts the aggregated response to the task manager
- For this simple demo, the aggregator is not an avs-finalizer, and thus does not need to register with eigenlayer or the AVS contract. It's IP address is simply hardcoded into the finalizers' config.
- Finalizers
- Execute a block sent to the task manager by the task generator, sign it, and send it to the aggregator
-
A task generator (in our case, same as the aggregator) publishes tasks once every regular interval (say 10 blocks, you are free to set your own interval) to the Mangata contract's createNewTask function. Each task specifies an integer
blockNumber
for which it wants the currently opted-in finalizers to execute it.createNewTask
also takesquorumNumbers
andquorumThresholdPercentage
which requests that each listed quorum (we only use quorumNumber 0) needs to reach at least thresholdPercentage of finalizer signatures. -
A registry contract is deployed that allows any eigenlayer finalizer with at least 1 delegated mockerc20 token to opt-in to this AVS and also de-register from this AVS.
-
[Finalizer] The finalizers who are currently opted-in with the AVS need to read the task number from the Task contract, execute the block, sign on that computed result (over the BN254 curve) and send their taskResponse and signature to the aggregator.
-
[Aggregator] The aggregator collects the signatures from the finalizers and aggregates them using BLS aggregation. If any response passes the quorumThresholdPercentage set by the task generator when posting the task, the aggregator posts the aggregated response to the Task contract.
-
If a response was sent within the response window, we enter the [Dispute resolution] period.
- Not yet implemented
Every AVS node implementation is required to abide by the Eigenlayer AVS Node Specification. We suggest reading through the whole spec, including the keys management section, but the hard requirements are currently only to:
- implement the AVS Node API
- implement the eigen prometheus metrics
Work in progress for the current implementation of Finalizer.
AVS Registry contracts have a stale view of finalizer shares in the delegation manager contract. In order to update their stake table, they need to periodically call the StakeRegistry.updateStakes() function. We are currently using internal script to get finalizer adresses and call the contract manually.
See the integration tests README for more details.
- Ensure you have Docker Compose installed
- Run
docker compose up -d
command from the root of the repository