Skip to content

Commit a8ea3d3

Browse files
authored
Merge pull request #502 from EspressoSystems/ax/event-stream
feat: event stream trigger NextCommittee
2 parents 450ccfb + d48f068 commit a8ea3d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+860
-241
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ jobs:
141141
run: just run_sailfish_demo
142142
- name: Test with block-maker
143143
run: just test-all
144+
- name: Test dynamic committee change
145+
run: just test-dyn-comm
144146

145147
contracts:
146148
runs-on: ubuntu-latest

Cargo.lock

Lines changed: 59 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ rust-version = "1.85.0"
3131

3232
[workspace.dependencies]
3333
aes-gcm = { version = "0.10.3" }
34-
alloy = { version = "1.0", features = ["default", "arbitrary", "k256", "serde", "rlp", "node-bindings", "getrandom", "signer-mnemonic"] }
34+
alloy = { version = "1.0", features = ["default", "arbitrary", "k256", "serde", "rlp", "node-bindings", "getrandom", "signer-mnemonic", "transport-ws"] }
3535
alloy-chains = "0.2"
3636
# derive feature is not exposed via `alloy`, thus has to explicitly declare here
3737
alloy-rlp = { version = "0.3.12", features = ["derive"] }
@@ -69,6 +69,7 @@ ethereum_ssz = "0.9.0"
6969
futures = { version = "0.3", default-features = false, features = ["alloc"] }
7070
generic-array = { version = "0.14.7", features = ["serde", "zeroize"] }
7171
http = "1.3.1"
72+
itertools = "0.14.0"
7273
jiff = { version = "0.2", default-features = false, features = ["serde", "std"] }
7374
minicbor = { version = "2.1.1", features = ["full"] }
7475
nohash-hasher = "0.2"

justfile

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ update-submodules:
1919
build_release *ARGS:
2020
cargo build --release --workspace --all-targets {{ARGS}}
2121

22+
build_release_until:
23+
cargo build --release --workspace --all-targets --features "until"
24+
2225
build_docker:
2326
docker build . -f ./docker/timeboost.Dockerfile -t timeboost:latest
2427
docker build . -f ./docker/yapper.Dockerfile -t yapper:latest
@@ -103,6 +106,7 @@ mkconfig NUM_NODES DATETIME *ARGS:
103106
--http-api "127.0.0.1:8004" \
104107
--chain-namespace 10101 \
105108
--parent-rpc-url "http://127.0.0.1:8545" \
109+
--parent-ws-url "ws://127.0.0.1:8545" \
106110
--parent-chain-id 31337 \
107111
--parent-ibox-contract "0xa0f3a1a4e2b2bcb7b48c8527c28098f207572ec1" \
108112
--key-manager-contract "0x2bbf15bc655c4cc157b769cfcb1ea9924b9e1a35" \
@@ -118,6 +122,7 @@ mkconfig_docker DATETIME *ARGS:
118122
--mode "increment-address" \
119123
--chain-namespace 10101 \
120124
--parent-rpc-url "http://127.0.0.1:8545" \
125+
--parent-ws-url "ws://127.0.0.1:8545" \
121126
--parent-chain-id 31337 \
122127
--parent-ibox-contract "0xa0f3a1a4e2b2bcb7b48c8527c28098f207572ec1" \
123128
--key-manager-contract "0x2bbf15bc655c4cc157b769cfcb1ea9924b9e1a35" \
@@ -133,6 +138,7 @@ mkconfig_nitro DATETIME *ARGS:
133138
--nitro-addr "localhost:55000" \
134139
--chain-namespace 412346 \
135140
--parent-rpc-url "http://127.0.0.1:8545" \
141+
--parent-ws-url "ws://127.0.0.1:8546" \
136142
--parent-chain-id 1337 \
137143
--parent-ibox-contract "0xa0f3a1a4e2b2bcb7b48c8527c28098f207572ec1" \
138144
--key-manager-contract "0x2bbf15bc655c4cc157b769cfcb1ea9924b9e1a35" \
@@ -179,9 +185,53 @@ test-all: build_release build-test-utils
179185
--run "3:scripts/deploy-test-contract" \
180186
--spawn "4:target/release/block-maker --port 55000 --committee test-configs/local/committee.toml" \
181187
--spawn "4:target/release/yapper --keyset-file test-configs/local/committee.toml" \
182-
--spawn "5:target/release/run-committee --configs test-configs/local/ --committee 0 --timeboost target/release/timeboost" \
188+
--spawn "5:target/release/run-committee --configs test-configs/local/ --committee-id 0 --timeboost target/release/timeboost" \
183189
target/release/block-checker -- \
184190
--config test-configs/local/node_0.toml \
185191
--committee test-configs/local/committee.toml \
186192
--committee-id 0 \
187193
--blocks 1000
194+
195+
test-dyn-comm: build_release_until build-test-utils
196+
env RUST_LOG=sailfish=warn,yapper=error,timeboost=info,info target/release/run \
197+
--verbose \
198+
--timeout 120 \
199+
--spawn "1:anvil --port 8545" \
200+
--run "2:sleep 2" \
201+
--run "3:scripts/deploy-test-contract" \
202+
--spawn "4:target/release/run-committee --configs test-configs/c0/ --committee-id 0 --until 2000" \
203+
--run "5:target/release/mkconfig -n 4 \
204+
--public-addr 127.0.0.1:9000 \
205+
--internal-addr 127.0.0.1:9003 \
206+
--http-api 127.0.0.1:9004 \
207+
--chain-namespace 10101 \
208+
--parent-rpc-url http://127.0.0.1:8545 \
209+
--parent-ws-url ws://127.0.0.1:8545 \
210+
--parent-chain-id 31337 \
211+
--parent-ibox-contract 0xa0f3a1a4e2b2bcb7b48c8527c28098f207572ec1 \
212+
--key-manager-contract 0x2bbf15bc655c4cc157b769cfcb1ea9924b9e1a35 \
213+
--timestamp +16s \
214+
--stamp-dir /tmp \
215+
--output test-configs/c1" \
216+
--run "6:sleep 6" \
217+
--run "7:target/release/register \
218+
-a threshold-enc-key \
219+
-m 'attend year erase basket blind adapt stove broccoli isolate unveil acquire category' \
220+
-u http://localhost:8545 \
221+
-k 0x2bbf15bc655c4cc157b769cfcb1ea9924b9e1a35 \
222+
-c test-configs/c0/committee.toml" \
223+
--run "8:target/release/register \
224+
-a new-committee \
225+
-m 'attend year erase basket blind adapt stove broccoli isolate unveil acquire category' \
226+
-u http://localhost:8545 \
227+
-k 0x2bbf15bc655c4cc157b769cfcb1ea9924b9e1a35 \
228+
-c test-configs/c1/committee.toml" \
229+
--spawn "9:target/release/yapper \
230+
--keyset-file test-configs/c1/committee.toml \
231+
--parent-url http://localhost:8545 \
232+
--key-manager-contract 0x2bbf15bc655c4cc157b769cfcb1ea9924b9e1a35" \
233+
target/release/run-committee -- \
234+
--configs test-configs/c1/ \
235+
--committee-id 1 \
236+
--until 800 \
237+
--required-decrypt-rounds 3 && rm -rf test-configs/c1

multisig/src/committee.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::num::{NonZeroUsize, ParseIntError};
2+
use std::ops::{Add, Sub};
23
use std::{fmt, str::FromStr};
34

45
use std::sync::Arc;
@@ -107,6 +108,7 @@ impl Committee {
107108
#[derive(
108109
Debug,
109110
Copy,
111+
Default,
110112
Clone,
111113
PartialEq,
112114
Eq,
@@ -163,3 +165,19 @@ impl Committable for CommitteeId {
163165
.finalize()
164166
}
165167
}
168+
169+
impl Add<u64> for CommitteeId {
170+
type Output = Self;
171+
172+
fn add(self, rhs: u64) -> Self::Output {
173+
Self(self.0 + rhs)
174+
}
175+
}
176+
177+
impl Sub<u64> for CommitteeId {
178+
type Output = Self;
179+
180+
fn sub(self, rhs: u64) -> Self::Output {
181+
Self(self.0 - rhs)
182+
}
183+
}

scripts/deploy-test-contract

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ km_addr=$(sed -nr 's/^key_manager.*=.*"(.+)"/\1/p' "$DEPLOYMENT_FILE")
2222

2323
# Update the contract
2424
env RUST_LOG=info cargo run --release --bin register -- \
25+
-a new-committee \
2526
-m "$MANAGER_MNEMONIC" \
2627
-i "$MANAGER_ACCOUNT_INDEX" \
2728
-u "$URL" \

scripts/run-timeboost-demo

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ i=0
116116
for f in "$config_dir"/node_*.toml; do
117117
cmd=(target/release/timeboost
118118
--committee-id 0
119-
--committee "$config_dir/committee.toml"
120119
--config "$f"
121120
--until $rounds
122121
--watchdog-timeout 120)

scripts/test-contract-deploy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ km_addr=$(sed -nr 's/^key_manager.*=.*"(.+)"/\1/p' "$DEPLOYMENT_FILE")
8484

8585
# Update the contract
8686
committee_config="test-configs/$COMMITTEE_PATH/committee.toml"
87-
RUST_LOG=info cargo run --release --bin register -- -m "$MANAGER_MNEMONIC" -i "$MANAGER_ACCOUNT_INDEX" -u "$URL" -k "$km_addr" -c "$committee_config"
87+
RUST_LOG=info cargo run --release --bin register -- -a new-committee -m "$MANAGER_MNEMONIC" -i "$MANAGER_ACCOUNT_INDEX" -u "$URL" -k "$km_addr" -c "$committee_config"
8888

8989
# Finally, clean up the temporary deployment file
9090
rm -f "$DEPLOYMENT_FILE"

test-configs/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ To generate configs for all nodes in a new committee:
2626

2727
``` sh
2828
# see mkconfig.rs Args or `mkconfig --help` for more options
29-
just mkconfig 5 2025-01-09T02:00:00Z --seed 42
30-
just mkconfig 13 2025-01-09T02:00:00Z --nitro-addr "localhost:55000"
29+
just mkconfig 5 2025-09-01T02:00:00Z --seed 42
30+
just mkconfig 13 2025-09-01T02:00:00Z --nitro-addr "localhost:55000"
3131

3232
# recipe for docker env is fixed at 5 nodes
33-
just mkconfig_docker 2025-01-09T02:00:00Z --seed 42
33+
just mkconfig_docker 2025-09-01T02:00:00Z --seed 42
3434

3535
# recipe for nitro CI test, fixed at 2 nodes with nitro chain config
36-
just mkconfig_nitro 2025-01-09T02:00:00Z --seed 42
36+
just mkconfig_nitro 2025-09-01T02:00:00Z --seed 42
3737
```
3838

3939
### On test wallet mnemonic

0 commit comments

Comments
 (0)