Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
74d7d48
First iteration of client-side commitment calculation working
entropidelic Jun 17, 2024
24af202
Client side verification working
entropidelic Jun 17, 2024
e2f5c7a
Add types module for batcher client
entropidelic Jun 17, 2024
06279e8
Polish code
entropidelic Jun 17, 2024
6cf4031
Refactored some functionality into save_response function
entropidelic Jun 17, 2024
1fcaa05
Remove unused import
entropidelic Jun 17, 2024
7ba86f1
Add comment
entropidelic Jun 17, 2024
06bd9be
Change logs
MauroToscano Jun 18, 2024
fabf809
feat(wip): building sdk of submit()
uri-99 Jun 18, 2024
1be2ee5
fix: add sdk to cargo.toml
uri-99 Jun 19, 2024
e346c76
Merge branch '407-feat-batcher-should-not-return-commitment' into 442…
uri-99 Jun 19, 2024
e1c6de1
feat(wip): test file that uses sdk
uri-99 Jun 19, 2024
e6da4bb
Save work in progress
entropidelic Jun 19, 2024
56541bc
feat(wip): sdk for test example
uri-99 Jun 19, 2024
5e982f8
Finish first iteration of payment system
entropidelic Jun 19, 2024
b2094be
Delete unused functions
entropidelic Jun 19, 2024
5557013
Fix upgrader scripts and tests
entropidelic Jun 20, 2024
5ed3a37
Merge branch 'main' into 412-feat-implement-payment-system
entropidelic Jun 20, 2024
88d2b20
Add config file for aggregator in anvil
entropidelic Jun 20, 2024
46f107a
Add keys files
entropidelic Jun 20, 2024
66a8171
Merge remote-tracking branch 'origin/412-feat-implement-payment-syste…
entropidelic Jun 20, 2024
df7c610
Merge branch 'main' into 412-feat-implement-payment-system
entropidelic Jun 20, 2024
d8c9f9a
feat: submit test by 1, must run twice
uri-99 Jun 20, 2024
7070b39
remove: test.rs file, now running directly on lib.rs
uri-99 Jun 20, 2024
61fe057
fix: update cargo.lock
uri-99 Jun 20, 2024
412f4ef
Update Makefile
entropidelic Jun 20, 2024
2929de3
remove unused import in aligned contract
entropidelic Jun 20, 2024
a720faa
Merge branch 'main' into 412-feat-implement-payment-system
entropidelic Jun 20, 2024
13a3d57
Change initialGasLeft in function
entropidelic Jun 20, 2024
6ea90c7
Use anvil address & keys for aggregator
entropidelic Jun 20, 2024
5cd923a
Remove aggregator funding script
entropidelic Jun 20, 2024
64413a8
fix: solidity test
taturosati Jun 20, 2024
7a543d0
Change position GAP variable of storage to the end of the contract
entropidelic Jun 20, 2024
1bbc17c
Merge remote-tracking branch 'origin/412-feat-implement-payment-syste…
entropidelic Jun 20, 2024
43523af
chore: more initial ether for batcher in devnet
uri-99 Jun 20, 2024
9b12900
fix: createNewTask and withdraw does not need to be payable
JuArce Jun 20, 2024
e67bf0b
Merge remote-tracking branch 'origin/412-feat-implement-payment-syste…
JuArce Jun 20, 2024
5f7d347
fix: reduce size of GAP after storage
uri-99 Jun 20, 2024
a003ba7
remove: delete batcherAddress from alignedlayer.sol since dereferenci…
uri-99 Jun 21, 2024
6d30935
Merge branch 'main' into 442-feat-rust-sdk
NicolasRampoldi Jun 21, 2024
e9dd116
feat: initial version of batcherPayments
uri-99 Jun 21, 2024
5c2d650
feat: first sdk version
NicolasRampoldi Jun 21, 2024
3b7bafb
feat: createNewTask on batcherPayments working
uri-99 Jun 21, 2024
68a58c6
feat: read BatcherPayments config from config file
uri-99 Jun 21, 2024
92ae27c
refactor: separate submit and receive into two functions
NicolasRampoldi Jun 21, 2024
6898240
fix: export receive
NicolasRampoldi Jun 21, 2024
e006dd8
refactor: new version
NicolasRampoldi Jun 21, 2024
1a4f1f0
feat: upgradeable and pausable (missing more tests about this)
uri-99 Jun 21, 2024
2bcd4e8
refactor: submit return type
NicolasRampoldi Jun 24, 2024
5bdc43e
feat: add verify_proof_onchain method
NicolasRampoldi Jun 24, 2024
456c956
fix: change info to debug in logs
NicolasRampoldi Jun 24, 2024
dc75fc7
feat: add first tests version
NicolasRampoldi Jun 24, 2024
d5ec625
docs: add documentation to the functions
NicolasRampoldi Jun 24, 2024
f865a86
refactor: remove unnecessary clones
NicolasRampoldi Jun 24, 2024
34f7bc9
Merge branch 'refs/heads/main' into 442-feat-rust-sdk
NicolasRampoldi Jun 24, 2024
c298cec
refactor: lint
NicolasRampoldi Jun 24, 2024
f6deb0b
feat: add get_verification_key_commitment
NicolasRampoldi Jun 24, 2024
eefcef4
feat: discount value of tx from payers
uri-99 Jun 24, 2024
1cbb17e
remove: batcher withdraw function
uri-99 Jun 24, 2024
e9b7a11
feat: accept batch payment in createNewTask
uri-99 Jun 24, 2024
3d6ea04
Merge branch '412-feat-implement-payment-system' into 460-feat-implem…
uri-99 Jun 24, 2024
aff5660
feat: unhardcode variables in fund batcher
uri-99 Jun 24, 2024
d4d0c1f
feat: batcher has its own ecdsa and config files
uri-99 Jun 24, 2024
931d523
Merge branch 'main' into 412-feat-implement-payment-system
uri-99 Jun 24, 2024
e20e95b
Merge branch '412-feat-implement-payment-system' into 460-feat-implem…
uri-99 Jun 24, 2024
b24e5a5
feat: change submit method of the client to use the sdk
NicolasRampoldi Jun 24, 2024
e3ecf49
feat: add utils
NicolasRampoldi Jun 24, 2024
85f20f3
Merge branch 'main' into 442-feat-rust-sdk
NicolasRampoldi Jun 24, 2024
5a35896
feat: better gas cost numbers
uri-99 Jun 24, 2024
6905e17
feat: add verify_proof_onchain and get_verification_key_commitment to…
NicolasRampoldi Jun 25, 2024
f7fe07d
Merge branch '442-feat-rust-sdk' of github.com:yetanotherco/aligned_l…
NicolasRampoldi Jun 25, 2024
ceee1cf
fix: remove unused import
NicolasRampoldi Jun 25, 2024
b8fc908
feat: error handling
NicolasRampoldi Jun 25, 2024
7f89c1c
feat: add repetitions
NicolasRampoldi Jun 25, 2024
d0a6d27
Merge branch 'main' into 442-feat-rust-sdk
NicolasRampoldi Jun 25, 2024
0a70b35
docs: add example to the sdk and readme
NicolasRampoldi Jun 25, 2024
54cf4df
fix: remove sdk example
NicolasRampoldi Jun 25, 2024
fa6d905
docs: remove usage
NicolasRampoldi Jun 25, 2024
a705786
deps: remove anyhow
NicolasRampoldi Jun 25, 2024
196fd72
Merge branch 'main' into 442-feat-rust-sdk
NicolasRampoldi Jun 25, 2024
8d7e3f5
fix: tests
taturosati Jun 25, 2024
0d31dda
refactor: change drop for scope
NicolasRampoldi Jun 25, 2024
614dec3
fix: removed unused comment
NicolasRampoldi Jun 25, 2024
94a3fe6
Merge branch 'main' into 442-feat-rust-sdk
NicolasRampoldi Jun 25, 2024
0ce17dd
feat: deploy batcher_payments on testnet + polish details
uri-99 Jun 25, 2024
b713c05
Merge branch 'main' into 442-feat-rust-sdk
NicolasRampoldi Jun 25, 2024
8daafb6
feat: verify make batcher payments on etherscan + emit event on Creat…
uri-99 Jun 25, 2024
12f64f3
refactor: UserBalances map name
uri-99 Jun 25, 2024
29123a8
fix: public batchersBalances to internal
uri-99 Jun 25, 2024
f0fb484
Merge branch '412-feat-implement-payment-system' into 460-feat-implem…
uri-99 Jun 25, 2024
247936b
Merge branch 'main' into 442-feat-rust-sdk
NicolasRampoldi Jun 26, 2024
20bd84d
feat: un-hardcode gas cost amounts
uri-99 Jun 26, 2024
a44d195
Merge branch 'refs/heads/main' into 442-feat-rust-sdk
NicolasRampoldi Jun 26, 2024
a26839e
fix: risc0
NicolasRampoldi Jun 26, 2024
ce58ffb
refactor: correct use of UPPER_SNAKE_CASE and camelCase
uri-99 Jun 26, 2024
944cdba
Merge branch 'main' into 460-feat-implement-user-batcher-payment-system
uri-99 Jun 26, 2024
42f2ffe
Merge remote-tracking branch 'origin/main' into 460-feat-implement-us…
uri-99 Jun 26, 2024
65c1633
perf: reduce gas cost inlining internal discountFromPayer
uri-99 Jun 26, 2024
8963194
refactor: PaymentWithdrawn event renamed to FundsWithdrawn
uri-99 Jun 26, 2024
77941c4
docs: new document explaining how a user must fund its batcher
uri-99 Jun 26, 2024
3a867a3
Merge branch 'refs/heads/main' into 442-feat-rust-sdk
NicolasRampoldi Jun 26, 2024
08a47d6
fix: merge conflicts
NicolasRampoldi Jun 26, 2024
e250cba
feat: simplify sdk for user
NicolasRampoldi Jun 27, 2024
fb442a4
Merge branch 'main' into 460-feat-implement-user-batcher-payment-system
entropidelic Jun 27, 2024
fe96a1f
Merge branch 'refs/heads/main' into 442-feat-rust-sdk
NicolasRampoldi Jun 27, 2024
7d348d7
remove: CreatedNewTask event
uri-99 Jun 27, 2024
7597e9b
refactor: renamed BatcherPayments to BatcherPaymentService
uri-99 Jun 27, 2024
3600704
refactor: CREATE_TASK_GAS_PRICE to CREATE_TASK_GAS_COST
uri-99 Jun 27, 2024
bb060e4
refactor: THIS_TX_BASE_GAS_COST and CREATE_TASK_GAS_COST to PAYMENT_S…
uri-99 Jun 27, 2024
1e27003
Merge branch 'main' into 460-feat-implement-user-batcher-payment-system
uri-99 Jun 27, 2024
1e9fb92
fix: merge conflicts
NicolasRampoldi Jun 27, 2024
db2aa23
refactor: change debug logs to info
NicolasRampoldi Jun 27, 2024
ee8acf7
feat: 'owner' config for batcherPaymentService
uri-99 Jun 27, 2024
5235294
fix: readme
NicolasRampoldi Jun 27, 2024
46fa92a
Add interaction to with payments system
entropidelic Jun 27, 2024
49d315b
Merge remote-tracking branch 'origin/460-feat-implement-user-batcher-…
entropidelic Jun 27, 2024
d8b8343
Remove unused types
MauroToscano Jun 27, 2024
83678f1
Remove unused imports
MauroToscano Jun 27, 2024
38955e5
refactor: remove wallet creation from submit
NicolasRampoldi Jun 27, 2024
fa1e262
fix: readme
NicolasRampoldi Jun 27, 2024
a5268a0
fix: info logs
NicolasRampoldi Jun 27, 2024
8b0f95c
Save work in progress
entropidelic Jun 27, 2024
4916d8d
fix: batches in explorer log
NicolasRampoldi Jun 28, 2024
f3f0b7c
fix: error on protocol mismatch
NicolasRampoldi Jun 28, 2024
0c46cac
Fix signature bug:
entropidelic Jun 28, 2024
541e36d
Merge branch 'main' into batcher-interact-with-payment-service
entropidelic Jun 28, 2024
593cb70
fix: remove unused errors
NicolasRampoldi Jun 28, 2024
dcb03e9
Merge branch 'main' into 442-feat-rust-sdk
NicolasRampoldi Jun 28, 2024
b14d48a
Get payment service address from file
entropidelic Jun 28, 2024
840ac94
Polish code
entropidelic Jun 28, 2024
85ae366
feat: add submit_multiple and submit
NicolasRampoldi Jun 28, 2024
aa384a9
Merge branch '442-feat-rust-sdk' of github.com:yetanotherco/aligned_l…
NicolasRampoldi Jun 28, 2024
2815f14
Add script for for funding batcher
entropidelic Jun 28, 2024
0aea9e5
Change script name
entropidelic Jun 28, 2024
da99fff
Change script name
entropidelic Jun 28, 2024
8458f92
Clippy
MauroToscano Jun 28, 2024
cdd7f28
Clippy
MauroToscano Jun 28, 2024
7f2ce7e
Remoe unused crate
entropidelic Jun 28, 2024
9ff219c
Add keystore_path arg to send burst script
entropidelic Jun 28, 2024
4389d34
Merge branch 'refs/heads/batcher-interact-with-payment-service' into …
NicolasRampoldi Jun 28, 2024
eeafbda
fix: cargo.lock
NicolasRampoldi Jun 28, 2024
48c5871
Merge branch 'refs/heads/main' into 442-feat-rust-sdk
NicolasRampoldi Jun 28, 2024
de50d5d
fix: merge conflicts
NicolasRampoldi Jun 28, 2024
6c7e626
Merge branch 'refs/heads/main' into 442-feat-rust-sdk
NicolasRampoldi Jun 28, 2024
eda16ae
fix: merge conflicts
NicolasRampoldi Jun 28, 2024
0a8bba6
Merge branch 'main' into 442-feat-rust-sdk
NicolasRampoldi Jun 28, 2024
5915c43
Merge branch 'main' into 442-feat-rust-sdk
NicolasRampoldi Jun 28, 2024
7c9edcc
Merge branch 'main' into 442-feat-rust-sdk
entropidelic Jul 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 70 additions & 10 deletions batcher/Cargo.lock

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

2 changes: 1 addition & 1 deletion batcher/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
members = [
"aligned-batcher",
"aligned-batcher-lib",
"aligned-sdk",
"aligned"
]
resolver = "2"
1 change: 0 additions & 1 deletion batcher/aligned-batcher-lib/src/lib.rs

This file was deleted.

2 changes: 1 addition & 1 deletion batcher/aligned-batcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ halo2_backend = { git = "https://github.com/yetanotherco/yet-another-halo2-fork.
halo2_proofs = { git = "https://github.com/yetanotherco/yet-another-halo2-fork.git", branch = "feat/serde_constraint_system" }
lazy_static = "1.4.0"
bincode = "1.3.3"
aligned-batcher-lib = { path = "../aligned-batcher-lib"}
aligned-sdk = { path = "../aligned-sdk"}
2 changes: 1 addition & 1 deletion batcher/aligned-batcher/src/gnark/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use aligned_batcher_lib::types::ProvingSystemId;
use aligned_sdk::types::ProvingSystemId;

#[derive(Copy, Clone, Debug)]
#[repr(C)]
Expand Down
23 changes: 11 additions & 12 deletions batcher/aligned-batcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ use std::net::SocketAddr;
use std::sync::Arc;
use std::time::Duration;

use crate::eth::BatchVerifiedEventStream;
use aligned_sdk::types::{
BatchInclusionData, ClientMessage, VerificationCommitmentBatch, VerificationData,
VerificationDataCommitment,
};
use aws_sdk_s3::client::Client as S3Client;
use eth::{BatchVerifiedFilter, BatcherPaymentService};
use ethers::prelude::{Middleware, Provider};
use ethers::providers::Ws;
use ethers::types::{Address, U256};
Expand All @@ -20,18 +26,11 @@ use tokio_tungstenite::tungstenite::error::ProtocolError;
use tokio_tungstenite::tungstenite::protocol::{frame::coding::CloseCode, CloseFrame};
use tokio_tungstenite::tungstenite::{Error, Message};
use tokio_tungstenite::WebSocketStream;

use aligned_batcher_lib::types::{
BatchInclusionData, ClientMessage, VerificationCommitmentBatch, VerificationData,
VerificationDataCommitment,
};
use eth::{BatchVerifiedFilter, BatcherPaymentService};
use types::batch_queue::BatchQueue;
use types::errors::BatcherError;

use crate::config::{ConfigFromYaml, ContractDeploymentOutput, NonPayingConfig};
use crate::eth::AlignedLayerServiceManager;
use crate::eth::BatchVerifiedEventStream;

mod config;
mod eth;
Expand All @@ -45,8 +44,6 @@ mod zk_utils;

const S3_BUCKET_NAME: &str = "storage.alignedlayer.com";

const PROTOCOL_VERSION: u16 = 0;

pub struct Batcher {
s3_client: S3Client,
eth_ws_provider: Provider<Ws>,
Expand All @@ -59,7 +56,6 @@ pub struct Batcher {
max_batch_size: usize,
last_uploaded_batch_block: Mutex<u64>,
pre_verification_is_enabled: bool,
protocol_version: u16,
non_paying_config: Option<NonPayingConfig>,
}

Expand Down Expand Up @@ -121,7 +117,6 @@ impl Batcher {
max_batch_size: config.batcher.max_batch_size,
last_uploaded_batch_block: Mutex::new(last_uploaded_batch_block),
pre_verification_is_enabled: config.batcher.pre_verification_is_enabled,
protocol_version: PROTOCOL_VERSION,
non_paying_config: config.batcher.non_paying,
}
}
Expand Down Expand Up @@ -172,7 +167,11 @@ impl Batcher {
let outgoing = Arc::new(RwLock::new(outgoing));

// Send the protocol version to the client
let protocol_version_msg = Message::binary(self.protocol_version.to_be_bytes().to_vec());
let protocol_version_msg = Message::binary(
aligned_sdk::sdk::CURRENT_PROTOCOL_VERSION
.to_be_bytes()
.to_vec(),
);

outgoing
.write()
Expand Down
2 changes: 1 addition & 1 deletion batcher/aligned-batcher/src/types/batch_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use futures_util::stream::SplitSink;
use tokio::{net::TcpStream, sync::RwLock};
use tokio_tungstenite::{tungstenite::Message, WebSocketStream};

use aligned_batcher_lib::types::{VerificationData, VerificationDataCommitment};
use aligned_sdk::types::{VerificationData, VerificationDataCommitment};

pub(crate) type BatchQueueEntry = (
VerificationData,
Expand Down
2 changes: 1 addition & 1 deletion batcher/aligned-batcher/src/zk_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::halo2::ipa::verify_halo2_ipa;
use crate::halo2::kzg::verify_halo2_kzg;
use crate::risc_zero::verify_risc_zero_proof;
use crate::sp1::verify_sp1_proof;
use aligned_batcher_lib::types::{ProvingSystemId, VerificationData};
use aligned_sdk::types::{ProvingSystemId, VerificationData};
use log::{debug, warn};

pub(crate) fn verify(verification_data: &VerificationData) -> bool {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
[package]
name = "aligned-batcher-lib"
name = "aligned-sdk"
version = "0.1.0"
edition = "2021"

[dependencies]
ethers = { tag = "v2.0.15-fix-reconnections", features = ["ws", "rustls"], git = "https://github.com/yetanotherco/ethers-rs.git" }
anyhow = "1.0.83"
log = { version = "0.4.21"}
serde_json = "1.0.117"
tokio-tungstenite = { version = "0.23.1", features = ["native-tls"] }
futures-util = "0.3.30"
tokio = { version = "1.37.0", features = ["io-std", "time", "macros", "rt", "rt-multi-thread", "sync"] }
lambdaworks-crypto = { version = "0.7.0", features = ["serde"] }
serde = { version = "1.0.201", features = ["derive"] }
sha3 = { version = "0.10.8"}
lambdaworks-crypto = { version = "0.7.0", features = ["serde"] }
url = "2.5.0"
hex = "0.4.3"
serde_json = "1.0.117"
92 changes: 92 additions & 0 deletions batcher/aligned-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# Aligned Verification SDK

The Aligned Verification SDK facilitates the submission and verification of proofs through the Aligned batcher and checks the inclusion of these verified proofs on-chain. This README provides an overview of the SDK, its installation, usage, and API details.

## Table of Contents
- [Aligned Verification SDK](#aligned-verification-sdk)
- [Table of Contents](#table-of-contents)
- [Installation](#installation)
- [API Reference](#api-reference)

## Installation

To use this SDK in your Rust project, add the following to your `Cargo.toml`:

```toml
[dependencies]
aligned-sdk = { git = "https://github.com/yetanotherco/aligned_layer" }
```

## API Reference

### submit

Submits a proof to the batcher to be verified and returns an aligned verification data struct.

#### Arguments

- `batcher_addr` - The address of the batcher to which the proof will be submitted.
- `verification_data` - The verification data for the proof.
- `wallet` - The wallet used to sign the proof.

#### Returns

- `Result<Option<AlignedVerificationData>>, SubmitError>` - An aligned verification data or an error.

#### Errors

- `MissingParameter` if the verification data vector is empty.
- `SerdeError` if there is an error serializing the verification data.
- `ConnectionError` if there is an error sending the message to the websocket.

### submit_multiple

Submits mulitple proofs to the batcher to be verified and returns an aligned verification data array.

#### Arguments

- `batcher_addr` - The address of the batcher to which the proof will be submitted.
- `verification_data` - A verification data array.
- `wallet` - The wallet used to sign the proof.

#### Returns

- `Result<Option<Vec<AlignedVerificationData>>>, SubmitError>` - An aligned verification data array or an error.

#### Errors

- `MissingParameter` if the verification data vector is empty.
- `SerdeError` if there is an error serializing the verification data.
- `ConnectionError` if there is an error sending the message to the websocket.

### verify_proof_onchain

Checks if the proof has been verified with Aligned and is included in the batch on-chain.

#### Arguments

- `aligned_verification_data` - The aligned verification data obtained when submitting the proofs.
- `chain` - The chain on which the verification will be done.
- `eth_rpc_url` - The URL of the Ethereum RPC node.

#### Returns

- `Result<bool, VerificationError>` - A boolean indicating whether the proof was verified on-chain and is included in the batch or an error.

#### Errors

- `EthError` if there is an error creating the rpc provider.
- `ParsingError` if there is an error parsing the address of the contract.
- `EthError` if there is an error verifying the proof on-chain.

### get_verification_key_commitment

Generates a keccak256 hash commitment of the verification key.

#### Arguments

- `content` - A byte slice of the verification key.

#### Returns

- `[u8; 32]` - A 32-byte array representing the keccak256 hash of the verification key.
1 change: 1 addition & 0 deletions batcher/aligned-sdk/abi/AlignedLayerServiceManager.json

Large diffs are not rendered by default.

Loading