Skip to content

Commit 9f76086

Browse files
uri-99glpecileNicolasRampoldiJuArce
authored
docs: add components to gitbook (#569)
Co-authored-by: Gian <58370608+glpecile@users.noreply.github.com> Co-authored-by: Nicolas Rampoldi <58613770+NicolasRampoldi@users.noreply.github.com> Co-authored-by: Julian Arce <52429267+JuArce@users.noreply.github.com>
1 parent a8b3a25 commit 9f76086

17 files changed

Lines changed: 197 additions & 127 deletions

docs/SUMMARY.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,22 @@
1111
## Architecture
1212

1313
* [Supported Verifiers](architecture/0_supported_verifiers.md)
14-
* [Fast mode](architecture/1_fast_mode.md)
1514
* [Aggregation mode](architecture/2_aggregation_mode.md)
16-
17-
<!-- * Components
18-
* [User](./architecture/entities/user.md)
19-
* [Operator](./architecture/entities/operator.md)
20-
* [Aggregator](./architecture/entities/aggregator.md)
21-
* [Batcher](./architecture/entities/batcher.md)
22-
* [Payment Service](./architecture/entities/payment_service.md) -->
23-
24-
* [Smart contracts](architecture/3_smart_contracts.md)
15+
* [Fast mode](architecture/1_fast_mode.md)
16+
* [Batcher](./architecture/components/1_batcher.md)
17+
* [Payment Service Contract](./architecture/components/2_payment_service_contract.md)
18+
* [Service Manager Contract](./architecture/components/3_service_manager_contract.md)
19+
* [Operator](./architecture/components/4_operator.md)
20+
* [Aggregator](./architecture/components/5_aggregator.md)
21+
* [Explorer](./architecture/components/6_explorer.md)
2522

2623
## Guides
2724

2825
* [Submitting proofs](guides/0_submitting_proofs.md)
2926
* [SDK](guides/1_SDK.md)
3027
* [Using Aligned on your app](guides/2_using_aligned_on_your_app.md)
3128
* [Generating proofs for Aligned](guides/3_generating_proofs.md)
29+
* [Contract Addresses](architecture/4_contract_addresses.md)
3230
* [Generating & submitting proofs of Rust code with ZKRust](guides/0_5_using_zkrust.md)
3331

3432
<!-- * [Setup Aligned](developer_guides/2_setup_aligned.md) -->
@@ -39,7 +37,7 @@
3937

4038
## Useful links
4139

42-
* [All the proof aggregation solutions will use RISC-V zkvms](https://blog.alignedlayer.com/all-the-proof-aggregation-solutions-will-use-risc-v-zkvms/)
40+
* [All the proof aggregation solutions will use RISC-V zkvms](https://mirror.xyz/0x7794D1c55568270A81D8Bf39e1bcE96BEaC10901/5JfikCrjdHsyqGCpqvbakrA8DZHIgj0d90i9tVOTink)
4341
* [Manifesto](https://mirror.xyz/0x7794D1c55568270A81D8Bf39e1bcE96BEaC10901/rOya8TwZvj_8kTpjDPVwTuNc1UcS0VLUr1t2nhCxYj8)
4442

4543
## Contacts

docs/architecture/3_smart_contracts.md

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Batcher
2+
3+
The Batcher receives proofs from different Users, bundles them in a batch of proofs, builds a Merkle Root from these, uploads the batch to a data service (like an S3 bucket), and submits this information to the [Aligned Service Manager](./3_service_manager_contract.md).
4+
5+
6+
To ensure that the User is sure that their proof was included in a batch, the Batcher will send each User the Merkle Proof (or Merkle Path). With this, the User can rebuild the Merkle Root starting from their proof, thus verifying it was actually included in the batch.
7+
8+
Also, to avoid unnecessary proof submissions, the Batcher performs a preliminary verification of the submitted proofs, to minimize the submission of false proofs in a batch.
9+
10+
However, each proof has a cost of verification, so each batch must contain some sort of payment for it to be verified. To handle the payment for each batch, the Batcher submits the batch through its [Batcher Payment Service](./2_payment_service_contract.md).
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Payment Service
2+
3+
The Payment Service handles User's payments to fund the verification of their proofs.
4+
5+
To be able to use the batcher, a user must fund its transactions. For this, there is a simple Batcher Payment System.
6+
7+
The Batcher has an associated Batcher Payments smart contract, which is in charge of receiving user's payments, and it guarantees that it can only spend these funds to send users' proofs to Aligned.
8+
9+
Users must first deposit into this contract, via a normal transfer to its address, where the Batcher Payment System will update the User's balance.
10+
11+
Then, users can send proofs to the Batcher, the Batcher will preemptively check if the user has funds for this, and once the whole batch is assembled, the Batcher will call its smart contract with the data it has received from the users.
12+
13+
The smart contract will then discount the corresponding amount of funds from each of the senders' balances, and create a new Batch in [Aligned Service Manager](./3_service_manager_contract.md), sending with it the corresponding amount of tokens for the batch verification to be paid to the [Aggregator](./5_aggregator.md).
14+
15+
Users can then withdraw extra funds deposited to the Batcher Payments smart contract, or leave them to fund future proofs.
16+
17+
This way, the Batcher can only use User funds to pay for the verification of the User's proofs.
18+
19+
## Details of the contract
20+
21+
### API
22+
23+
#### Receive funds
24+
25+
```solidity
26+
receive() external payable
27+
```
28+
29+
This function will be called every time a User transfers funds to the smart contract. It will not only receive the funds, but it will also register internally how much the User deposited, to keep track of each User's funds separately.
30+
31+
32+
#### Create New Task
33+
34+
```solidity
35+
function createNewTask(
36+
bytes32 batchMerkleRoot,
37+
string calldata batchDataPointer,
38+
address[] calldata proofSubmitters,
39+
uint256 gasForAggregator,
40+
uint256 gasPerProof
41+
) external onlyBatcher
42+
```
43+
44+
This function will be executed only by the Batcher, when it has a batch to post to Aligned. It contains all the information needed to post the batch in [Aligned Service Manager](./3_service_manager_contract.md) (`batchMerkleRoot` and `batchDataPointer`), plus an array containing which are the `proofSubmitters`, so as to discount `gasPerProof` from these, and also the `gasForAggregator`, declaring how much will need to go pay for the response of the batch.
45+
46+
#### Withdraw
47+
48+
```solidity
49+
function withdraw(uint256 amount) external
50+
```
51+
52+
This function can be called by any User, to freely withdraw any amount of their available balance from the contract.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Aligned Service Manager Contract
2+
3+
The Aligned Service Manager handles the reception of new batches to Aligned, keeps their status on-chain, and receives their response.
4+
5+
It is a smart contract which receives all new batches, with their Merkle Root and a pointer to where the batch is currently stored. When received, this manager will emit an Event for the [Operators](./4_operator.md) to know when there is a new batch to verify.
6+
7+
Then, when receiving a response from the [Aggregator](./5_aggregator.md), with Operator's aggregated BLS signatures, the Aligned Service Manager checks the BLS signature to verify the Operators were in fact those who processed the batch and its responded status.
8+
9+
Once verified, it will emit another Event, for anyone interested (for example, the [Explorer](./6_explorer.md)) to know that the batch was verified by the operators. This batch is now verified and Users can know their proofs inside the batch were proven and verified leveraging Ethereum's security.
10+
11+
## Details of the contract
12+
13+
Besides the base [EigenLayer middleware contracts](https://github.com/Layr-Labs/eigenlayer-middleware/tree/mainnet/src), the core contract for Aligned is [AlignedLayerServiceManager](../../contracts/src/core/AlignedLayerServiceManager.sol). It is in charge of creating new batch verification tasks, storing batches state and verifying operator responses.
14+
15+
### API
16+
17+
#### Create new task
18+
19+
```solidity
20+
function createNewTask(
21+
bytes32 batchMerkleRoot,
22+
string calldata batchDataPointer
23+
) external payable
24+
```
25+
26+
This method is called to create a new batch verification task that will broadcast an event to all operators, signaling that there are new proofs awaiting verification.
27+
28+
* `batchMerkleRoot` is a 256 bit hash corresponding to the Merkle Root of the proofs batch to be verified by operators.
29+
* `batchDataPointer` is a string representing a link to some specific data storage location. This is used by operators to download the entire batch of proofs.
30+
31+
#### Respond to task
32+
33+
```solidity
34+
function respondToTask(
35+
bytes32 batchMerkleRoot,
36+
NonSignerStakesAndSignature memory nonSignerStakesAndSignature
37+
) external
38+
```
39+
40+
This method is used by the Aggregator once the quorum for a particular task has been reached. Its main purpose is to verify the aggregated signature of the operators for the given task, and also that the quorum was reached. After verifying, an event is emitted signaling to any consumer that the batch has reached soft finality.
41+
42+
* `batchMerkleRoot` is a 256 bit hash representing the Merkle Root of the batch that has been verified and signed by operators.
43+
* `nonSignerStakesAndSignature` is a struct provided by EigenLayer middleware with information about operators' signatures, stakes and quorum for the given task.
44+
45+
### Verify batch inclusion
46+
47+
```solidity
48+
function verifyBatchInclusion(
49+
bytes32 proofCommitment,
50+
bytes32 pubInputCommitment,
51+
bytes32 provingSystemAuxDataCommitment,
52+
bytes20 proofGeneratorAddr,
53+
bytes32 batchMerkleRoot,
54+
bytes memory merkleProof,
55+
uint256 verificationDataBatchIndex
56+
) external view returns (bool)
57+
```
58+
59+
A method used for consumers to check that their proof was verified in Aligned. It checks if the batch where the proof was included was verified and if the proof was included in the batch when verifying the Merkle path.
60+
61+
* `proofCommitment`, `pubInputCommitment`, `provingSystemAuxDataCommitment`, `proofGeneratorAddr` are the commitments to the verification data sent to the batcher.
62+
* `batchMerkleRoot` is a 256 bit hash representing the batch Merkle Root the proof was included in.
63+
* `merkleProof` is the Merkle path from the hashed leaf built from the verification data commitments to the root.
64+
* `verificationDataBatchIndex` is the index of the proof in the batch where it was included.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Operator
2+
3+
The Operators verify the ZK Proofs and are the Eigenlayer restakers. They also insert financial security into the system, and leverage Ethereum's security for any AVS they take part in (e.g. Aligned).
4+
5+
Operators read [Aligned Service Manager](./3_service_manager_contract.md)'s new batch events. These have the necessary information to verify a batch, its Merkle Root, and its data pointer.
6+
7+
With the data pointer, they will download the actual proofs they will need to verify. The first thing they do after this, is verify that the downloaded proofs actually compute the expected Merkle Root. If not, they will regard the batch as corrupted and will not verify it. This avoids malicious [Batchers](./1_batcher.md) from uploading proofs that are different from what [Users](0_user.md) uploaded.
8+
9+
After verifying the Merkle Root of the batch, thus verifying that the downloaded batch matches the one intended to be submitted, the Operator must now verify each one of its proofs. This is done by executing the appropriate verification programs integrated with Aligned.
10+
11+
After verifying the whole batch, Operators sign their response (either true or false depending on whether the batch was completely verified or not) with a BLS signature, and send it to the [Aggregator](./5_aggregator.md).
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Aggregator
2+
3+
The Aggregator collects [Operator](./4_operator.md)'s BLS Signatures.
4+
5+
When the quorum of responses is reached, the Aggregator will submit a Task Response with the aggregated signatures back to the [Aligned Service Manager](./3_service_manager_contract.md).
6+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Explorer
2+
3+
{% embed url="https://explorer.alignedlayer.com" %}
4+
5+
The Explorer keeps track of [Aligned Service Manager](./3_service_manager_contract.md).
6+
7+
It has an internal state of previous batches, actively listens for new batches and their responses. The Explorer then displays this information for Users to visualize the submitted batches, their states and more useful information in real time.
8+
9+
In the landing page we can see information such as how many [Operators](./4_operator.md) are currently registered and running, how many Batches and how many total Proofs have been verified.
10+
11+
![](../../images/explorer-landing-page.png)
12+
13+
From here, we can search for a specific batch by its Merkle Root, we can directly jump to any one of the last 5 submitted batches, and we can easily go to the `Latest Batches` page, where we can navigate through the various pages of batches of proofs submitted to aligned, ordered by latest submission, and easily check their on-chain status, timestamp, and block number.
14+
15+
![](../../images/explorer-latest-batches.png)
16+
17+
From there we can also click any individual batch Merkle Root to view its details.
18+
19+
From here we can visualize:
20+
21+
- the whole `Merkle Root`
22+
- `Amount of Proofs` in the batch
23+
- Ethereum's `Submission Block Number`, linked to etherscan
24+
- `Submission Transaction Hash`, linked to etherscan
25+
- `Submission Timestamp` of the batch
26+
- `Status`, either `Pending` or `Verified`
27+
- Ethereum's `Response Block Number`, linked to etherscan
28+
- `Response Transaction Hash`, linked to etherscan
29+
- `Response Timestamp` of the batch
30+
31+
![](../../images/explorer-batch-details.png)
32+

docs/architecture/entities/aggregator.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/architecture/entities/batcher.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)