Skip to content

Commit d930435

Browse files
alxionglukeiannuccitwittner
authored
update node config and sourcing public keys from contract (#469)
* propose a new node config design * refactor!: new NodeConfig, remove KeysetConfig * update 5 node config * ci_local tests passing * remove test-configs/*.json * introduce register binary for manager * update demo scripts and CI * add separate docker configss, update dockerfile * fix ci * update test-configs' readme * newer os to get newer glibc * try fix ci * fix sailfish demo * fix docker * fix yapper * use cargo fmt instead of just in build.rs * remove unused run-local-integration * robust keymanager contract address from non-default manager wallet * clean up crypto's SerdeAs, remove unused to_bytes, try_from_str etc * rename config_path to config * reorg config * update all test-config files * minor fix * fix ci Co-authored-by: Luke Iannucci <[email protected]> * rename net.sailfish to net.public Co-authored-by: Toralf Wittner <[email protected]> * add rationale to Blackbox * fix typos * improve mkconfig usage, avoid shell hack * fix missing port adjustment for nitro * correct inbox contract addr in configs * replace Blackbox with Bs58Bincode<T>, structurize parent_chain, centralize offset const, builder for ChainConfig Co-authored-by: Toralf Wittner <[email protected]> * update test-configs * fix all test errs * remove Bs58Bincode altogether, use serde(transparent) Co-authored-by: Toralf Wittner <[email protected]> * remove unnecessary NodeEncodedKeypairConfig * fix test err * update port magic * maybe fix ci --------- Co-authored-by: Luke Iannucci <[email protected]> Co-authored-by: Toralf Wittner <[email protected]>
1 parent 1deb25a commit d930435

Some content is hidden

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

66 files changed

+1391
-1582
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ jobs:
134134
- name: Install Foundry
135135
uses: foundry-rs/foundry-toolchain@v1
136136
- name: Run tests
137-
run: just run_demo -s /tmp/stamp --ignore-stamp --yapper -k test-configs/local-5.json
137+
run: just run_demo -s /tmp/stamp --ignore-stamp --yapper -c test-configs/c0
138138
- name: Run tests with late-start node
139-
run: just run_demo -l -s /tmp/stamp --ignore-stamp --yapper -k test-configs/local-5.json
139+
run: just run_demo -l -s /tmp/stamp --ignore-stamp --yapper -c test-configs/c0
140140
- name: Run sailfish demo
141141
run: just run_sailfish_demo
142142

@@ -195,7 +195,7 @@ jobs:
195195
--init &
196196
cd ..
197197
- name: Run test timeboost with nitro sequencer
198-
run: just run_demo -s /tmp/stamp --ignore-stamp -k test-configs/local-2.json --rounds 10000 --yapper --nitro
198+
run: just run_demo -s /tmp/stamp --ignore-stamp -c test-configs/nitro-ci-committee --rounds 10000 --yapper --nitro
199199
- name: Verify sequencer blocks
200200
run: |
201201
RUST_LOG=info just verify_blocks

Cargo.lock

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

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,6 @@ Run in docker
7878
just run_integration
7979
```
8080

81-
Run locally
82-
```shell
83-
just run_integration_local
84-
```
85-
8681
### Accessing Metrics
8782

8883
Metrics are exposed on port 8000 + `i` for each node. Once the nodes are up and running, you
@@ -120,4 +115,4 @@ just test-contracts
120115

121116
[noise]: https://noiseprotocol.org/
122117
[sailfish]: https://eprint.iacr.org/2024/472.pdf
123-
[timeboost]: https://github.com/OffchainLabs/decentralized-timeboost-spec
118+
[timeboost]: https://github.com/OffchainLabs/decentralized-timeboost-spec

cliquenet/src/addr.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ impl Address {
3939
self
4040
}
4141

42+
pub fn with_offset(mut self, o: u16) -> Self {
43+
match self {
44+
Self::Inet(ip, p) => self = Self::Inet(ip, p + o),
45+
Self::Name(hn, p) => self = Self::Name(hn, p + o),
46+
}
47+
self
48+
}
49+
4250
pub fn is_ip(&self) -> bool {
4351
matches!(self, Self::Inet(..))
4452
}

docker-compose.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ services:
44
command:
55
[
66
"/app/timeboost",
7-
"--id", "0",
7+
"--committee-id", "0",
88
"--http-port", "8800",
9-
"--keyset-file", "docker.json",
9+
"--config", "docker/node_0.toml",
1010
"--stamp", "/tmp/timeboost.stamp",
1111
"--namespace", "10101",
1212
]
@@ -31,9 +31,9 @@ services:
3131
command:
3232
[
3333
"/app/timeboost",
34-
"--id", "1",
34+
"--committee-id", "0",
3535
"--http-port", "8800",
36-
"--keyset-file", "docker.json",
36+
"--config", "docker/node_1.toml",
3737
"--stamp", "/tmp/timeboost.stamp",
3838
"--namespace", "10101",
3939
]
@@ -58,9 +58,9 @@ services:
5858
command:
5959
[
6060
"/app/timeboost",
61-
"--id", "2",
61+
"--committee-id", "0",
6262
"--http-port", "8800",
63-
"--keyset-file", "docker.json",
63+
"--config", "docker/node_2.toml",
6464
"--stamp", "/tmp/timeboost.stamp",
6565
"--namespace", "10101",
6666
]
@@ -85,9 +85,9 @@ services:
8585
command:
8686
[
8787
"/app/timeboost",
88-
"--id", "3",
88+
"--committee-id", "0",
8989
"--http-port", "8800",
90-
"--keyset-file", "docker.json",
90+
"--config", "docker/node_3.toml",
9191
"--stamp", "/tmp/timeboost.stamp",
9292
"--namespace", "10101",
9393
]
@@ -112,9 +112,10 @@ services:
112112
command:
113113
[
114114
"/app/timeboost",
115-
"--id", "4",
115+
"--committee-id", "0",
116116
"--http-port", "8800",
117117
"--keyset-file", "docker.json",
118+
"--config", "docker/node_4.toml",
118119
"--stamp", "/tmp/timeboost.stamp",
119120
"--namespace", "10101",
120121
]
@@ -150,7 +151,7 @@ services:
150151
"--tps",
151152
"1",
152153
"--keyset-file",
153-
"docker.json",
154+
"committee.json",
154155
]
155156
networks:
156157
timeboost:

docker/timeboost.Dockerfile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
# Builder stage
2-
FROM rust:bullseye AS builder
2+
FROM rust:bookworm AS builder
3+
SHELL ["/bin/bash", "-c"]
34

45
WORKDIR /app
56

67
COPY . .
78
RUN apt update && apt-get install -y protobuf-compiler libssl-dev
9+
RUN curl -L https://foundry.paradigm.xyz | bash && /root/.foundry/bin/foundryup
10+
ENV PATH="/root/.foundry/bin:${PATH}"
11+
RUN forge --version
12+
RUN rustup component add rustfmt --toolchain nightly
13+
814
RUN cargo build --release --bin timeboost
915

1016
# Non-root app container stage
@@ -19,7 +25,7 @@ RUN groupadd -r appgroup && useradd -r -g appgroup timeboostuser
1925

2026
# Copy binary
2127
COPY --from=builder /app/target/release/timeboost .
22-
COPY --from=builder /app/test-configs .
28+
COPY --from=builder /app/test-configs/docker .
2329

2430
# Set ownership of application files and make binary executable
2531
RUN chown -R timeboostuser:appgroup /app && chmod +x /app/timeboost

docker/yapper.Dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
# Builder stage
2-
FROM rust:bullseye AS builder
2+
FROM rust:bookworm AS builder
33

44
WORKDIR /app
55

66
COPY . .
77
RUN apt update && apt-get install -y protobuf-compiler
8+
RUN curl -L https://foundry.paradigm.xyz | bash && /root/.foundry/bin/foundryup
9+
ENV PATH="/root/.foundry/bin:${PATH}"
10+
RUN forge --version
11+
RUN rustup component add rustfmt --toolchain nightly
812
RUN cargo build --release --bin yapper
913

1014
# Non-root app container stage
@@ -19,7 +23,7 @@ RUN groupadd -r appgroup && useradd -r -g appgroup yapperuser
1923

2024
# Copy binary and just
2125
COPY --from=builder /app/target/release/yapper .
22-
COPY --from=builder /app/test-configs .
26+
COPY --from=builder /app/test-configs/docker .
2327

2428
# Set ownership of application files and make binary executable
2529
RUN chown -R yapperuser:appgroup /app && chmod +x /app/yapper
@@ -34,4 +38,4 @@ USER yapperuser
3438
ENV RUST_LOG=info
3539

3640
# Run the timeboost binary
37-
CMD ["/app/yapper"]
41+
CMD ["/app/yapper"]

justfile

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ fix:
4848
cargo fix --allow-dirty --allow-staged
4949

5050
ci_local:
51-
just build && just lint && just test_ci --release && just run_demo && just run_sailfish_demo && just build_docker
51+
just build && just lint && just test_ci --release && \
52+
just run_demo -s /tmp/stamp --ignore-stamp --yapper -c test-configs/c0 && \
53+
just run_sailfish_demo && just build_docker
5254

5355
bacon: clippy check fmt
5456

@@ -69,9 +71,6 @@ run_monitoring:
6971
stop_monitoring:
7072
docker compose -f docker-compose.metrics.yml down
7173

72-
run_integration_local *ARGS:
73-
./scripts/run-local-integration {{ARGS}}
74-
7574
run_demo *ARGS:
7675
./scripts/run-timeboost-demo {{ARGS}}
7776

@@ -84,33 +83,37 @@ run *ARGS:
8483
bench *ARGS:
8584
cargo bench --benches {{ARGS}} -- --nocapture
8685

87-
mkconfig_local NUM_NODES *ARGS:
88-
just mkconfig_local_full {{NUM_NODES}} "https://theserversroom.com/ethereum/54cmzzhcj1o/" 1 "0x4dbd4fc535ac27206064b68ffcf827b0a60bab3f" {{ARGS}}
89-
90-
mkconfig_local_full NUM_NODES RPC_URL PARENT_CHAIN_ID PARENT_INBOX_ADDRESS *ARGS:
91-
cargo run --bin mkconfig -- -n {{NUM_NODES}} \
92-
--sailfish-base-addr "127.0.0.1:8000" \
93-
--decrypt-base-addr "127.0.0.1:10000" \
94-
--certifier-base-addr "127.0.0.1:11000" \
95-
--internal-base-addr "127.0.0.1:5000" \
96-
--parent-rpc-url {{RPC_URL}} \
97-
--parent-chain-id {{PARENT_CHAIN_ID}} \
98-
--parent-ibox-contr-addr {{PARENT_INBOX_ADDRESS}} \
99-
--mode "increment-port" {{ARGS}} | jq
100-
101-
mkconfig_docker NUM_NODES *ARGS:
102-
just mkconfig_docker_full {{NUM_NODES}} "https://theserversroom.com/ethereum/54cmzzhcj1o/" 1 "0x4dbd4fc535ac27206064b68ffcf827b0a60bab3f" {{ARGS}}
103-
104-
mkconfig_docker_full NUM_NODES RPC_URL PARENT_CHAIN_ID PARENT_INBOX_ADDRESS *ARGS:
86+
mkconfig NUM_NODES *ARGS:
10587
cargo run --bin mkconfig -- -n {{NUM_NODES}} \
106-
--sailfish-base-addr "172.20.0.2:8000" \
107-
--decrypt-base-addr "172.20.0.2:8001" \
108-
--certifier-base-addr "172.20.0.2:8002" \
109-
--internal-base-addr "172.20.0.2:5000" \
110-
--parent-rpc-url {{RPC_URL}} \
111-
--parent-chain-id {{PARENT_CHAIN_ID}} \
112-
--parent-ibox-contr-addr {{PARENT_INBOX_ADDRESS}} \
113-
--mode "increment-address" {{ARGS}} | jq
88+
--public-addr "127.0.0.1:8000" \
89+
--internal-addr "127.0.0.1:8003" \
90+
--parent-rpc-url "http://127.0.0.1:8545" \
91+
--parent-chain-id 31337 \
92+
--parent-ibox-contract "0xa0f3a1a4e2b2bcb7b48c8527c28098f207572ec1" \
93+
--key-manager-contract "0x2bbf15bc655c4cc157b769cfcb1ea9924b9e1a35" \
94+
--output "test-configs/c0" {{ARGS}}
95+
96+
mkconfig_docker *ARGS:
97+
cargo run --bin mkconfig -- -n 5 \
98+
--public-addr "172.20.0.2:8000" \
99+
--internal-addr "172.20.0.2:8003" \
100+
--mode "increment-address" \
101+
--parent-rpc-url "http://127.0.0.1:8545" \
102+
--parent-chain-id 31337 \
103+
--parent-ibox-contract "0xa0f3a1a4e2b2bcb7b48c8527c28098f207572ec1" \
104+
--key-manager-contract "0x2bbf15bc655c4cc157b769cfcb1ea9924b9e1a35" \
105+
--output "test-configs/docker" {{ARGS}}
106+
107+
mkconfig_nitro *ARGS:
108+
cargo run --bin mkconfig -- -n 2 \
109+
--public-addr "127.0.0.1:8000" \
110+
--internal-addr "127.0.0.1:8003" \
111+
--nitro-addr "localhost:55000" \
112+
--parent-rpc-url "http://127.0.0.1:8545" \
113+
--parent-chain-id 1337 \
114+
--parent-ibox-contract "0xa0f3a1a4e2b2bcb7b48c8527c28098f207572ec1" \
115+
--key-manager-contract "0x2bbf15bc655c4cc157b769cfcb1ea9924b9e1a35" \
116+
--output "test-configs/nitro-ci-committee" {{ARGS}}
114117

115118
verify_blocks *ARGS:
116119
cargo run --release --bin block-verifier --features bin {{ARGS}}
@@ -135,5 +138,5 @@ test-individually:
135138
cargo nextest run --no-tests=pass -p $pkg || exit 1; \
136139
done
137140

138-
test-contract-deploy:
139-
./scripts/test-contract-deploy
141+
test-contract-deploy *ARGS:
142+
./scripts/test-contract-deploy {{ARGS}}

multisig/src/committee.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::fmt;
2-
use std::num::NonZeroUsize;
1+
use std::num::{NonZeroUsize, ParseIntError};
2+
use std::{fmt, str::FromStr};
33

44
use std::sync::Arc;
55

@@ -135,6 +135,15 @@ impl fmt::Display for CommitteeId {
135135
}
136136
}
137137

138+
impl FromStr for CommitteeId {
139+
type Err = ParseIntError;
140+
141+
fn from_str(s: &str) -> Result<Self, Self::Err> {
142+
let v = s.parse::<u64>()?;
143+
Ok(Self(v))
144+
}
145+
}
146+
138147
impl Committable for CommitteeId {
139148
fn commit(&self) -> Commitment<Self> {
140149
RawCommitmentBuilder::new("CommitteeId")

scripts/README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
11
# Scripts
22

33
These scripts are used to run the integration tests locally and do other tasks which require lots of steps.
4-
5-
## run-local-integration
6-
7-
This script runs a local integration test with 5 nodes. It can be run in either debug or release mode. To run in release mode, pass the `release` argument to the script, pass nothing to run in debug mode.
8-
9-
```bash
10-
./scripts/run-local-integration [release]
11-
```

0 commit comments

Comments
 (0)