Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 851-add-max-limit-eth…
Browse files Browse the repository at this point in the history
…-in-payment-from-batcher-to-aggregator-make-the-respond-to-ask-only-callable-by-one-agg
  • Loading branch information
uri-99 committed Sep 3, 2024
2 parents 23b36ae + d5c0dc0 commit 974f13e
Show file tree
Hide file tree
Showing 40 changed files with 1,150 additions and 637 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,13 @@ If you want to run an operator, check our [Operator Guide](./docs/operator_guide
## Aligned Infrastructure Guide
If you are developing on Aligned, or want to run your own devnet, check our [setup Aligned guide](docs/guides/6_setup_aligned.md).
If you are developing on Aligned, or want to run your own devnet, check our [setup Aligned guide](docs/3_guides/6_setup_aligned.md).
## Submitting Proofs to Aligned
For submitting proofs generated by your own project to the network via CLI, see the documentation on [submitting proofs to Aligned](docs/guides/0_submitting_proofs.md).
For submitting proofs generated by your own project to the network via CLI, see the documentation on [submitting proofs to Aligned](docs/3_guides/0_submitting_proofs.md).
## Integrating Aligned into your Project
If you are developing applications using Aligned, we offer a [Rust-SDK](docs/guides/1_SDK.md) for submitting proofs directly to the network within your applications.
If you are developing applications using Aligned, we offer a [Rust-SDK](docs/3_guides/1_SDK_how_to.md) for submitting proofs directly to the network within your applications.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
"deploymentBlock": 0
},
"permissions": {
"alignedLayerAggregator": "0x15d34aaf54267db7d7c367839aaf71a00a2c6a65",
"alignedLayerChurner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"alignedLayerEjector": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"alignedLayerOwner": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"alignedLayerUpgrader": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
"pauserRegistry": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"alignedLayerAggregator": "0x15d34aaf54267db7d7c367839aaf71a00a2c6a65"
"pauserRegistry": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"addresses": {
"alignedLayerProxyAdmin": "0x3eb924d928c138898FC089328f840105969bD6a0",
"alignedLayerServiceManager": "0x58F280BeBE9B34c9939C3C39e0890C81f163B623",
"alignedLayerServiceManagerImplementation": "0x1d1D5F13dd25A57fc1Cb36382FeD5398B333d41A",
"alignedLayerServiceManagerImplementation": "0xFc572B73e61B376957BFe88fE577709b1624c6B9",
"blsApkRegistry": "0xD0A725d82649f9e4155D7A60B638Fe33b3F25e3b",
"blsApkRegistryImplementation": "0xB05BB98a966F58aDAB8dF58350b77fF2131A3b87",
"indexRegistry": "0x4A7DE0a9fBBAa4fF0270d31852B363592F68B81F",
Expand All @@ -14,7 +14,7 @@
"stakeRegistry": "0x51462D5511563A0F97Bb3Ce5475E1c3905b83F4b",
"stakeRegistryImplementation": "0xd1555Be14931C061E06D3CE1D1Daadc1B3c6F8c7",
"batcherPaymentService": "0x815aeCA64a974297942D2Bbf034ABEe22a38A003",
"batcherPaymentServiceImplementation": "0xa1E835Edc8c3c2284293eE96F1498BD3f88934ab"
"batcherPaymentServiceImplementation": "0x89ebb109f390aed920dC2B2e920743EBA1811013"
},
"chainInfo": {
"chainId": 17000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"addresses": {
"alignedLayerProxyAdmin": "0x7262d34478f8fB496a8feDfa0fdaBD1a0401d6cD",
"alignedLayerServiceManager": "0x9C5231FC88059C086Ea95712d105A2026048c39B",
"alignedLayerServiceManagerImplementation": "0x58DFadE33c13cC728f3960BeF0CC50DF751b97F5",
"alignedLayerServiceManagerImplementation": "0x4a2040959a12e170EACeF03B2E692d57e652b20C",
"blsApkRegistry": "0xEe1b6Dc663F17eC69987b6D56255a7282b358a09",
"blsApkRegistryImplementation": "0x875f22C55D5363f7d1d1d63420298E89DcdB7bdF",
"indexRegistry": "0xF12b82A933381391fE0e9a0270111f90FB10a810",
Expand All @@ -14,7 +14,7 @@
"stakeRegistry": "0x1b0C9b87b094d821911500F91914B1A1D2856F14",
"stakeRegistryImplementation": "0x52A9e264b98fe2d53805937Bc094a981E7eB6BeE",
"batcherPaymentService": "0x7577Ec4ccC1E6C529162ec8019A49C13F6DAd98b",
"batcherPaymentServiceImplementation": "0x8BD8a8a49F44115Be48735c8661F59B1cb20946e"
"batcherPaymentServiceImplementation": "0x0874cf293B81b367ab99A7884B98d6616C295cB6"
},
"chainInfo": {
"chainId": 17000,
Expand Down

Large diffs are not rendered by default.

34 changes: 30 additions & 4 deletions contracts/src/core/AlignedLayerServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ contract AlignedLayerServiceManager is
);
}

if (batchersBalances[msg.sender] <= 0) {
if (batchersBalances[msg.sender] == 0) {
revert BatcherBalanceIsEmpty(msg.sender);
}

Expand Down Expand Up @@ -122,7 +122,7 @@ contract AlignedLayerServiceManager is
revert BatchAlreadyResponded(batchIdentifierHash);
}

if (batchersBalances[senderAddress] <= 0) {
if (batchersBalances[senderAddress] == 0) {
revert BatcherHasNoBalance(senderAddress);
}

Expand Down Expand Up @@ -219,13 +219,39 @@ contract AlignedLayerServiceManager is
alignedAggregator = _alignedAggregator;
}

function withdraw(uint256 amount) external {
if (batchersBalances[msg.sender] < amount) {
revert InsufficientFunds(
msg.sender,
amount,
batchersBalances[msg.sender]
);
}

batchersBalances[msg.sender] -= amount;
emit BatcherBalanceUpdated(msg.sender, batchersBalances[msg.sender]);

payable(msg.sender).transfer(amount);
}

function balanceOf(address account) public view returns (uint256) {
return batchersBalances[account];
}

function depositToBatcher(address account) external payable {
_depositToBatcher(account, msg.value);
}

function _depositToBatcher(address account, uint256 amount) internal {
if (amount == 0) {
revert InvalidDepositAmount(amount);
}
batchersBalances[account] += amount;
emit BatcherBalanceUpdated(account, batchersBalances[account]);
}

receive() external payable {
batchersBalances[msg.sender] += msg.value;
emit BatcherBalanceUpdated(msg.sender, batchersBalances[msg.sender]);
_depositToBatcher(msg.sender, msg.value);
}

function checkPublicInput(
Expand Down
16 changes: 8 additions & 8 deletions contracts/src/core/BatcherPaymentService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ contract BatcherPaymentService is
}

// STORAGE
address public batcherWallet;

IAlignedLayerServiceManager public alignedLayerServiceManager;

address public batcherWallet;

// map to user data
mapping(address => UserInfo) public userData;

Expand Down Expand Up @@ -117,11 +117,11 @@ contract BatcherPaymentService is
uint256 feeForAggregator = gasForAggregator * tx.gasprice;
uint256 feePerProof = gasPerProof * tx.gasprice;

if (leavesQty <= 0) {
if (leavesQty == 0) {
revert NoLeavesSubmitted();
}

if (signaturesQty <= 0) {
if (signaturesQty == 0) {
revert NoProofSubmitterSignatures();
}

Expand All @@ -133,11 +133,11 @@ contract BatcherPaymentService is
revert LeavesNotPowerOfTwo(leavesQty);
}

if (feeForAggregator <= 0) {
if (feeForAggregator == 0) {
revert NoGasForAggregator();
}

if (feePerProof <= 0) {
if (feePerProof == 0) {
revert NoGasPerProof();
}

Expand Down Expand Up @@ -170,7 +170,7 @@ contract BatcherPaymentService is
}

function unlock() external whenNotPaused {
if (userData[msg.sender].balance <= 0) {
if (userData[msg.sender].balance == 0) {
revert UserHasNoFundsToUnlock(msg.sender);
}

Expand All @@ -179,7 +179,7 @@ contract BatcherPaymentService is
}

function lock() external whenNotPaused {
if (userData[msg.sender].balance <= 0) {
if (userData[msg.sender].balance == 0) {
revert UserHasNoFundsToLock(msg.sender);
}
userData[msg.sender].unlockBlock = 0;
Expand Down
3 changes: 2 additions & 1 deletion contracts/src/core/IAlignedLayerServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ interface IAlignedLayerServiceManager {
uint256 available
); // 5c54305e
error InvalidQuorumThreshold(uint256 signedStake, uint256 requiredStake); // a61eb88a
error SenderIsNotAggregator(address sender, address alignedAggregator); // 0x2cbe4195
error SenderIsNotAggregator(address sender, address alignedAggregator); // 2cbe4195
error InvalidDepositAmount(uint256 amount); // 412ed242

function createNewTask(
bytes32 batchMerkleRoot,
Expand Down
4 changes: 4 additions & 0 deletions docs/1_introduction/0_about_aligned.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Aligned is a decentralized network that verifies Zero-Knowledge/validity proofs and posts the results to Ethereum. It is designed to provide high throughput, cheap proof verification with low latency.

{% hint style="info" %}
If you are unfamiliar with ZK and why this is useful, see [Why ZK and Aligned?](./5_why_zk.md)
{% endhint %}

## Mission

Our mission is to accelerate Ethereum's roadmap and the adoption of verifiable computation by enabling fast and economical verification of ZK and validity proofs.
Expand Down
43 changes: 43 additions & 0 deletions docs/1_introduction/5_why_zk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Why ZK and how can Aligned help you?

The following is an introduction to zero-knowledge/validity proofs to understand their utility and impact and why they may help you solve problems you can encounter when building your application. Before jumping on the explanation, we give some definitions:

- Validity/integrity proofs: These are cryptographic proofs that allow you to check that a computation was carried out correctly, without having to re-run it entirely.
- Zero-knowledge proofs: These are cryptographic that allow you to prove the validity of a statement, without revealing sensitive data.

The two terms are sometimes grouped under ZK, though depending on the use case, you may need it to be zero-knowledge or not. Validity proofs are widely used by ZK-rollups (though not rigorously zero-knowledge), while Schnorr signatures are an example of the second (basically, they let you show to others that you have a secret key, without leaking it).

In blockchains, we need to coordinate between different parties that do not trust each other. How can we agree on whether something has happened? The logical construction involves independently re-executing transactions and reaching consensus. However, the number of transactions we can process is limited by the weakest devices in the network, acting as bottlenecks. Moreover, adding more hardware does not make the system faster (as in web2), only more robust. ZK allows the situation to scale, allowing the system to process more transactions with the same guarantees. ZK proofs allow you to verify a computation much faster than re-execution: we can use more powerful machines to run the transactions and generate the cryptographic proof, and the rest of the network verifies the proof. If the proof is valid, it is the same as if all the nodes had re-executed the transactions, but with less computational effort. More concretely, a ZK-rollup can generate a proof that it processed 10,000 transactions correctly, and submit to Ethereum the proof with the state diff (or other information necessary to update the state), and Ethereum can check very quickly that all those transactions were correct! ZK is also useful whenever you need to show the integrity of some computation, for example, that an image you published in the newspaper is the result of enlarging an image from a real camera. You can generate the proof and then use Ethereum as a settlement layer, in charge of performing the verification of your proofs, though there is a problem: it can be expensive, and you have limited throughput. This is where Aligned comes in.

Aligned offers you two different products to reduce your costs and increase throughput: fast mode and the proof aggregation service. Once you know that you want to use ZK for your product and Ethereum, Aligned fits perfectly. Whether to use fast mode or proof aggregation depends on your needs:

- Fast mode: a decentralized network of verifiers that checks the proofs, signs messages stating the correctness of the proof and when a threshold is met, publishes the signature to Ethereum. Once Ethereum checks the signature, the state of the proofs is changed to verified, and you can use the result as always. It has very high throughput, reduces costs significantly (depending on the number of proofs that are sent) and has low latency.
- Proof aggregation service: performs recursive proof aggregation of several ZK proofs. The final proof is sent to Ethereum, and if verified, it implied the validity of your proof. It has higher latency and lower throughput than the fast mode, but achieves the full security of Ethereum.

How can you write ZK applications and generate proofs?
There are many different technologies and libraries to build ZK applications.
Until recently, it was fairly complicated, since you needed some background of math and write circuits
(you can think of it as coding in assembly).
Luckily,
there are several ZK virtual machines (zkVM)
that allow you to generate proofs of code written in a higher level language,
such as Rust.
You write your code and run it on top of the zkVM, and you get a proof of its correct execution.
To simplify things, we have [zkRust](../3_guides/5_using_zkrust.md),
where you can run your code and send the proof directly to Aligned!

## Projects or ideas using ZK

The list below contains examples or projects using ZK. It is meant to illustrate some use cases, but it is not meant to be exhaustive.

- Rollups
- On-chain gaming
- ZK Machine Learning (zKML)
- ZK-TLS
- Bridges
- Oracles
- Data processors
- Voting
- ZK-Email
- Identity protocols
- IoT
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [Example - ZKquiz](1_introduction/2_zkquiz.md)
* [Use cases](1_introduction/3_use_cases.md)
* [FAQ](1_introduction/4_faq.md)
* [Why ZK and Aligned?](1_introduction/5_why_zk.md)

## Architecture

Expand Down
15 changes: 13 additions & 2 deletions docs/operator_guides/0_running_an_operator.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Register as an Aligned operator in testnet

> **CURRENT VERSION:**
> Aligned Operator [v0.4.0](https://github.com/yetanotherco/aligned_layer/releases/tag/v0.4.0)
> Aligned Operator [v0.5.2](https://github.com/yetanotherco/aligned_layer/releases/tag/v0.5.2)
> **IMPORTANT:**
> You must be [whitelisted](https://docs.google.com/forms/d/e/1FAIpQLSdH9sgfTz4v33lAvwj6BvYJGAeIshQia3FXz36PFfF-WQAWEQ/viewform) to become an Aligned operator.
Expand Down Expand Up @@ -41,7 +41,7 @@ Minimum hardware requirements:
To start with, clone the Aligned repository and move inside it

```bash
git clone https://github.com/yetanotherco/aligned_layer.git --branch v0.4.0
git clone https://github.com/yetanotherco/aligned_layer.git --branch v0.5.2
cd aligned_layer
```

Expand Down Expand Up @@ -107,6 +107,17 @@ Update the following placeholders in `./config-files/config-operator.yaml`:
`"<ecdsa_key_store_location_path>"` and `"<bls_key_store_location_path>"` are the paths to your keys generated with the EigenLayer CLI, `"<operator_address>"` and `"<earnings_receiver_address>"` can be found in the `operator.yaml` file created in the EigenLayer registration process.
The keys are stored by default in the `~/.eigenlayer/operator_keys/` directory, so for example `<ecdsa_key_store_location_path>` could be `/path/to/home/.eigenlayer/operator_keys/some_key.ecdsa.key.json` and for `<bls_key_store_location_path>` it could be `/path/to/home/.eigenlayer/operator_keys/some_key.bls.key.json`.

The default configuration uses the public nodes RPC, but we suggest you use your own nodes for better performance and reliability.
Also, from v0.5.2 there is a fallback mechanism to have two RPCs, so you can add a second RPC for redundancy.

```yaml
eth_rpc_url: "https://ethereum-holesky-rpc.publicnode.com"
eth_rpc_url_fallback: "https://ethereum-holesky-rpc.publicnode.com"
eth_ws_url: "wss://ethereum-holesky-rpc.publicnode.com"
eth_ws_url_fallback: "wss://ethereum-holesky-rpc.publicnode.com"
```
## Step 4 - Deposit Strategy Tokens
We are using [WETH](https://holesky.eigenlayer.xyz/restake/WETH) as the strategy token.
Expand Down
4 changes: 4 additions & 0 deletions examples/validating-public-input/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ docs/

# Dotenv file
.env

risc_zero/fibonacci_proof_generator/risc_zero_fibonacci.proof
risc_zero/fibonacci_proof_generator/risc_zero_fibonacci.pub
risc_zero/fibonacci_proof_generator/risc_zero_fibonacci_id.bin
52 changes: 51 additions & 1 deletion examples/validating-public-input/aligned-integration/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 974f13e

Please sign in to comment.