Skip to content

Commit af3fc45

Browse files
committed
Merge branch 'staging' into feat/aggregate-proofs-in-chunks
2 parents 8b7305a + adc5793 commit af3fc45

30 files changed

+718
-559
lines changed

.github/workflows/build-and-test-rust.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
paths:
99
- "batcher/**"
1010
- "aggregation_mode/**"
11-
- ".github/workflows/build-rust.yml"
11+
- ".github/workflows/build-and-test-rust.yml"
1212

1313
jobs:
1414
build:
@@ -20,7 +20,7 @@ jobs:
2020
- name: Set up Rust
2121
uses: actions-rs/toolchain@v1
2222
with:
23-
toolchain: stable
23+
toolchain: 1.86.0
2424
components: rustfmt, clippy
2525
override: true
2626

Makefile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,19 @@ start_proof_aggregator_dev: is_aggregator_set reset_last_aggregated_block ## Sta
178178
start_proof_aggregator: is_aggregator_set reset_last_aggregated_block ## Starts proof aggregator with proving activated
179179
AGGREGATOR=$(AGGREGATOR) cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features prove --bin proof_aggregator -- config-files/config-proof-aggregator.yaml
180180

181+
start_proof_aggregator_dev_ethereum_package: is_aggregator_set reset_last_aggregated_block ## Starts proof aggregator with mock proofs (DEV mode) in ethereum package
182+
AGGREGATOR=$(AGGREGATOR) RISC0_DEV_MODE=1 cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --bin proof_aggregator -- config-files/config-proof-aggregator-mock-ethereum-package.yaml
183+
184+
start_proof_aggregator_ethereum_package: is_aggregator_set reset_last_aggregated_block ## Starts proof aggregator with proving activated in ethereum package
185+
AGGREGATOR=$(AGGREGATOR) cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features prove --bin proof_aggregator -- config-files/config-proof-aggregator-ethereum-package.yaml
186+
181187
start_proof_aggregator_gpu: is_aggregator_set reset_last_aggregated_block ## Starts proof aggregator with proving + GPU acceleration (CUDA)
182188
AGGREGATOR=$(AGGREGATOR) SP1_PROVER=cuda cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features prove,gpu --bin proof_aggregator -- config-files/config-proof-aggregator.yaml
183189

190+
start_proof_aggregator_gpu_ethereum_package: is_aggregator_set reset_last_aggregated_block ## Starts proof aggregator with proving activated in ethereum package
191+
AGGREGATOR=$(AGGREGATOR) SP1_PROVER=cuda cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features prove,gpu --bin proof_aggregator -- config-files/config-proof-aggregator-ethereum-package.yaml
192+
193+
184194
verify_aggregated_proof_sp1_holesky_stage:
185195
@echo "Verifying SP1 in aggregated proofs on holesky..."
186196
@cd batcher/aligned/ && \
@@ -1319,6 +1329,7 @@ ethereum_package_inspect: ## Prints detailed information about the net
13191329

13201330
ethereum_package_rm: ## Stops and removes the ethereum_package environment and used resources
13211331
kurtosis enclave rm aligned -f
1332+
kurtosis engine stop
13221333

13231334
batcher_start_ethereum_package: user_fund_payment_service
13241335
@echo "Starting Batcher..."
@@ -1329,11 +1340,11 @@ aggregator_start_ethereum_package:
13291340
$(MAKE) aggregator_start AGG_CONFIG_FILE=config-files/config-aggregator-ethereum-package.yaml
13301341

13311342
operator_start_ethereum_package:
1332-
$(MAKE) operator_start OPERATOR_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 CONFIG_FILE=config-files/config-operator-1-ethereum-package.yaml
1343+
$(MAKE) operator_start ENVIRONMENT=devnet OPERATOR_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 CONFIG_FILE=config-files/config-operator-1-ethereum-package.yaml
13331344

13341345
operator_register_start_ethereum_package:
1335-
$(MAKE) operator_full_registration OPERATOR_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 CONFIG_FILE=config-files/config-operator-1-ethereum-package.yaml \
1336-
$(MAKE) operator_start OPERATOR_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 CONFIG_FILE=config-files/config-operator-1-ethereum-package.yaml
1346+
$(MAKE) operator_full_registration OPERATOR_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 CONFIG_FILE=config-files/config-operator-1-ethereum-package.yaml
1347+
$(MAKE) operator_start ENVIRONMENT=devnet OPERATOR_ADDRESS=0x70997970C51812dc3A010C7d01b50e0d17dc79C8 CONFIG_FILE=config-files/config-operator-1-ethereum-package.yaml
13371348

13381349

13391350
install_spamoor: ## Instal spamoor to spam transactions

aggregation_mode/aggregation_programs/risc0/src/lib.rs

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,26 @@ impl IsMerkleTreeBackend for Risc0ImageIdAndPubInputs {
4040
leaf.commitment()
4141
}
4242

43+
/// Computes a commutative Keccak256 hash, ensuring H(a, b) == H(b, a).
44+
///
45+
/// See: https://docs.openzeppelin.com/contracts/5.x/api/utils#Hashes
46+
///
47+
/// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/Hashes.sol#L17-L19
48+
///
49+
/// Compliant with OpenZeppelin's `processProofCalldata` function from MerkleProof.sol.
50+
///
51+
/// See: https://docs.openzeppelin.com/contracts/5.x/api/utils#MerkleProof
52+
///
53+
/// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol#L114-L128
4354
fn hash_new_parent(child_1: &Self::Node, child_2: &Self::Node) -> Self::Node {
4455
let mut hasher = Keccak::v256();
45-
hasher.update(child_1);
46-
hasher.update(child_2);
47-
56+
if child_1 < child_2 {
57+
hasher.update(child_1);
58+
hasher.update(child_2);
59+
} else {
60+
hasher.update(child_2);
61+
hasher.update(child_1);
62+
}
4863
let mut hash = [0u8; 32];
4964
hasher.finalize(&mut hash);
5065
hash
@@ -62,10 +77,26 @@ impl IsMerkleTreeBackend for Hash32 {
6277
leaf.0
6378
}
6479

80+
/// Computes a commutative Keccak256 hash, ensuring H(a, b) == H(b, a).
81+
///
82+
/// See: https://docs.openzeppelin.com/contracts/5.x/api/utils#Hashes
83+
///
84+
/// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/Hashes.sol#L17-L19
85+
///
86+
/// Compliant with OpenZeppelin's `processProofCalldata` function from MerkleProof.sol.
87+
///
88+
/// See: https://docs.openzeppelin.com/contracts/5.x/api/utils#MerkleProof
89+
///
90+
/// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol#L114-L128
6591
fn hash_new_parent(child_1: &Self::Node, child_2: &Self::Node) -> Self::Node {
6692
let mut hasher = Keccak::v256();
67-
hasher.update(child_1);
68-
hasher.update(child_2);
93+
if child_1 < child_2 {
94+
hasher.update(child_1);
95+
hasher.update(child_2);
96+
} else {
97+
hasher.update(child_2);
98+
hasher.update(child_1);
99+
}
69100
let mut hash = [0u8; 32];
70101
hasher.finalize(&mut hash);
71102
hash

aggregation_mode/aggregation_programs/risc0/src/root_aggregator_main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ use risc0_zkvm::guest::env;
77
risc0_zkvm::guest::entry!(main);
88

99
// Generated with `make agg_mode_write_program_ids` and copied from program_ids.json
10-
pub const CHUNK_AGGREGATOR_PROGRAM_IMAGE_ID: [u8; 32] = [200, 155, 105, 236, 200, 48, 124, 101, 178, 175, 101, 213, 67, 76, 52, 119, 110, 9, 50, 215, 92, 126, 5, 172, 211, 193, 88, 83, 150, 62, 51, 74];
10+
pub const CHUNK_AGGREGATOR_PROGRAM_IMAGE_ID: [u8; 32] = [
11+
222, 122, 103, 148, 14, 219, 83, 212, 30, 154, 147, 196, 219, 133, 93, 22, 63, 149, 190, 190,
12+
242, 50, 62, 145, 18, 8, 121, 25, 107, 58, 184, 66,
13+
];
1114

1215
fn main() {
1316
let input = env::read::<RootAggregatorInput>();

aggregation_mode/aggregation_programs/sp1/src/lib.rs

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,26 @@ impl IsMerkleTreeBackend for SP1VkAndPubInputs {
3737
leaf.commitment()
3838
}
3939

40+
/// Computes a commutative Keccak256 hash, ensuring H(a, b) == H(b, a).
41+
///
42+
/// See: https://docs.openzeppelin.com/contracts/5.x/api/utils#Hashes
43+
///
44+
/// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/Hashes.sol#L17-L19
45+
///
46+
/// Compliant with OpenZeppelin's `processProofCalldata` function from MerkleProof.sol.
47+
///
48+
/// See: https://docs.openzeppelin.com/contracts/5.x/api/utils#MerkleProof
49+
///
50+
/// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol#L114-L128
4051
fn hash_new_parent(child_1: &Self::Node, child_2: &Self::Node) -> Self::Node {
4152
let mut hasher = Keccak256::new();
42-
hasher.update(child_1);
43-
hasher.update(child_2);
53+
if child_1 < child_2 {
54+
hasher.update(child_1);
55+
hasher.update(child_2);
56+
} else {
57+
hasher.update(child_2);
58+
hasher.update(child_1);
59+
}
4460
hasher.finalize().into()
4561
}
4662
}
@@ -56,10 +72,26 @@ impl IsMerkleTreeBackend for Hash32 {
5672
leaf.0
5773
}
5874

75+
/// Computes a commutative Keccak256 hash, ensuring H(a, b) == H(b, a).
76+
///
77+
/// See: https://docs.openzeppelin.com/contracts/5.x/api/utils#Hashes
78+
///
79+
/// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/Hashes.sol#L17-L19
80+
///
81+
/// Compliant with OpenZeppelin's `processProofCalldata` function from MerkleProof.sol.
82+
///
83+
/// See: https://docs.openzeppelin.com/contracts/5.x/api/utils#MerkleProof
84+
///
85+
/// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol#L114-L128
5986
fn hash_new_parent(child_1: &Self::Node, child_2: &Self::Node) -> Self::Node {
6087
let mut hasher = Keccak256::new();
61-
hasher.update(child_1);
62-
hasher.update(child_2);
88+
if child_1 < child_2 {
89+
hasher.update(child_1);
90+
hasher.update(child_2);
91+
} else {
92+
hasher.update(child_2);
93+
hasher.update(child_1);
94+
}
6395
hasher.finalize().into()
6496
}
6597
}

aggregation_mode/aggregation_programs/sp1/src/root_aggregator_main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use sha2::{Digest, Sha256};
66
use sp1_aggregation_program::{Hash32, RootAggregatorInput};
77

88
// Generated with `make agg_mode_write_program_ids` and copied from program_ids.json
9-
pub const CHUNK_AGGREGATOR_PROGRAM_VK_HASH: [u32; 8] = [899813587, 1068831252, 2000190855, 1210454658, 1057127892, 56287617, 1572193608, 1379769886];
9+
pub const CHUNK_AGGREGATOR_PROGRAM_VK_HASH: [u32; 8] = [
10+
1040333920, 1542570412, 411443120, 206151865, 190370181, 1775934843, 1568897572, 1219192306,
11+
];
1012

1113
pub fn main() {
1214
let input = sp1_zkvm::io::read::<RootAggregatorInput>();

aggregation_mode/programs_ids.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"risc0_chunk_aggregator_image_id": "0xc89b69ecc8307c65b2af65d5434c34776e0932d75c7e05acd3c15853963e334a",
3-
"risc0_chunk_aggregator_image_id_bytes": "[200, 155, 105, 236, 200, 48, 124, 101, 178, 175, 101, 213, 67, 76, 52, 119, 110, 9, 50, 215, 92, 126, 5, 172, 211, 193, 88, 83, 150, 62, 51, 74]",
4-
"risc0_root_aggregator_image_id": "0x3452ff90f5fa471705fd6a213d7cf126c372658ef759271ce687ef1161cceb8a",
5-
"sp1_chunk_aggregator_vk_hash": "0x006b4421a6fed44853b9c3ec3c82612827e04fba80d6b8606edae2a4523d9e1e",
6-
"sp1_chunk_aggregator_vk_hash_words": "[899813587, 1068831252, 2000190855, 1210454658, 1057127892, 56287617, 1572193608, 1379769886]",
7-
"sp1_root_aggregator_vk_hash": "0x004b2cdc6c24f614ac3a66886a6bd96e0b2a6e0e1151b6251c8ba0ec4e8f19d1"
2+
"risc0_chunk_aggregator_image_id": "0xde7a67940edb53d41e9a93c4db855d163f95bebef2323e91120879196b3ab842",
3+
"risc0_chunk_aggregator_image_id_bytes": "[222, 122, 103, 148, 14, 219, 83, 212, 30, 154, 147, 196, 219, 133, 93, 22, 63, 149, 190, 190, 242, 50, 62, 145, 18, 8, 121, 25, 107, 58, 184, 66]",
4+
"risc0_root_aggregator_image_id": "0x850737352f63a706cd79b3f128ff7f466e607bbacd7dd94bc4a7e76db6160068",
5+
"sp1_chunk_aggregator_vk_hash": "0x007c0478c16fc706b0c430fd80c49a0b916b1a30ba76a75eeec1bd1248ab65f2",
6+
"sp1_chunk_aggregator_vk_hash_words": "[1040333920, 1542570412, 411443120, 206151865, 190370181, 1775934843, 1568897572, 1219192306]",
7+
"sp1_root_aggregator_vk_hash": "0x00c262f809acf5799f2a158bad858de8a19b3e756f46df818ff8139789147938"
88
}

aggregation_mode/src/aggregators/mod.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,26 @@ impl IsMerkleTreeBackend for AlignedProof {
204204
leaf.commitment()
205205
}
206206

207+
/// Computes a commutative Keccak256 hash, ensuring H(a, b) == H(b, a).
208+
///
209+
/// See: https://docs.openzeppelin.com/contracts/5.x/api/utils#Hashes
210+
///
211+
/// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/Hashes.sol#L17-L19
212+
///
213+
/// Compliant with OpenZeppelin's `processProofCalldata` function from MerkleProof.sol.
214+
///
215+
/// See: https://docs.openzeppelin.com/contracts/5.x/api/utils#MerkleProof
216+
///
217+
/// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol#L114-L128
207218
fn hash_new_parent(child_1: &Self::Node, child_2: &Self::Node) -> Self::Node {
208219
let mut hasher = Keccak256::new();
209-
hasher.update(child_1);
210-
hasher.update(child_2);
220+
if child_1 < child_2 {
221+
hasher.update(child_1);
222+
hasher.update(child_2);
223+
} else {
224+
hasher.update(child_2);
225+
hasher.update(child_1);
226+
}
211227
hasher.finalize().into()
212228
}
213229
}

batcher/aligned-sdk/src/sdk/aggregation.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,26 @@ impl IsMerkleTreeBackend for Hash32 {
7070
leaf.0
7171
}
7272

73+
/// Computes a commutative Keccak256 hash, ensuring H(a, b) == H(b, a).
74+
///
75+
/// See: https://docs.openzeppelin.com/contracts/5.x/api/utils#Hashes
76+
///
77+
/// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/Hashes.sol#L17-L19
78+
///
79+
/// Compliant with OpenZeppelin's `processProofCalldata` function from MerkleProof.sol.
80+
///
81+
/// See: https://docs.openzeppelin.com/contracts/5.x/api/utils#MerkleProof
82+
///
83+
/// Source: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol#L114-L128
7384
fn hash_new_parent(child_1: &Self::Node, child_2: &Self::Node) -> Self::Node {
7485
let mut hasher = Keccak256::new();
75-
hasher.update(child_1);
76-
hasher.update(child_2);
86+
if child_1 < child_2 {
87+
hasher.update(child_1);
88+
hasher.update(child_2);
89+
} else {
90+
hasher.update(child_2);
91+
hasher.update(child_1);
92+
}
7793
hasher.finalize().into()
7894
}
7995
}

config-files/config-aggregator-ethereum-package.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ environment: "production"
44
aligned_layer_deployment_config_file_path: "./contracts/script/output/devnet/alignedlayer_deployment_output.json"
55
eigen_layer_deployment_config_file_path: "./contracts/script/output/devnet/eigenlayer_deployment_output.json"
66
eth_rpc_url: "http://localhost:8545"
7-
eth_rpc_url_fallback: "http://localhost:8550"
7+
eth_rpc_url_fallback: "http://localhost:8552"
88
eth_ws_url: "ws://localhost:8546"
9-
eth_ws_url_fallback: "ws://localhost:8551"
9+
eth_ws_url_fallback: "ws://localhost:8553"
1010
eigen_metrics_ip_port_address: "localhost:9090"
1111

1212
## ECDSA Configurations
@@ -27,9 +27,9 @@ aggregator:
2727
enable_metrics: true
2828
metrics_ip_port_address: localhost:9091
2929
telemetry_ip_port_address: localhost:4001
30-
garbage_collector_period: 2m #The period of the GC process. Suggested value for Prod: '168h' (7 days)
31-
garbage_collector_tasks_age: 20 #The age of tasks that will be removed by the GC, in blocks. Suggested value for prod: '216000' (30 days)
32-
garbage_collector_tasks_interval: 10 #The interval of queried blocks to get an old batch. Suggested value for prod: '900' (3 hours)
30+
garbage_collector_period: 30m #The period of the GC process. Suggested value for Prod: '168h' (7 days)
31+
garbage_collector_tasks_age: 300 #The age of tasks that will be removed by the GC, in blocks. Suggested value for prod: '216000' (30 days)
32+
garbage_collector_tasks_interval: 300 #The interval of queried blocks to get an old batch. Suggested value for prod: '900' (3 hours)
3333
bls_service_task_timeout: 168h # The timeout of bls aggregation service tasks. Suggested value for prod '168h' (7 days)
3434
gas_base_bump_percentage: 10 # How much to bump gas price when responding to task. Suggested value 10%
3535
gas_bump_incremental_percentage: 2 # An extra percentage to bump every retry i*2 when responding to task. Suggested value 2%

0 commit comments

Comments
 (0)