Skip to content

Commit 633ad0f

Browse files
authored
Merge pull request #481 from EspressoSystems/tw/timeboost-config
Add `timeboost-config` crate.
2 parents d930435 + 3d58117 commit 633ad0f

Some content is hidden

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

54 files changed

+555
-450
lines changed

Cargo.lock

Lines changed: 70 additions & 15 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ members = [
1212
"tests",
1313
"timeboost",
1414
"timeboost-builder",
15+
"timeboost-config",
1516
"timeboost-contract",
1617
"timeboost-crypto",
1718
"timeboost-proto",
@@ -67,6 +68,7 @@ ethereum_ssz = "0.9.0"
6768
futures = { version = "0.3", default-features = false, features = ["alloc"] }
6869
generic-array = { version = "0.14.7", features = ["serde", "zeroize"] }
6970
http = "1.3.1"
71+
jiff = { version = "0.2", default-features = false, features = ["serde", "std"] }
7072
minicbor = { version = "2.1.1", features = ["full"] }
7173
nohash-hasher = "0.2"
7274
parking_lot = "0.12.3"

justfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,36 +83,42 @@ run *ARGS:
8383
bench *ARGS:
8484
cargo bench --benches {{ARGS}} -- --nocapture
8585

86-
mkconfig NUM_NODES *ARGS:
86+
mkconfig NUM_NODES DATETIME *ARGS:
8787
cargo run --bin mkconfig -- -n {{NUM_NODES}} \
8888
--public-addr "127.0.0.1:8000" \
8989
--internal-addr "127.0.0.1:8003" \
90+
--chain-namespace 10101 \
9091
--parent-rpc-url "http://127.0.0.1:8545" \
9192
--parent-chain-id 31337 \
9293
--parent-ibox-contract "0xa0f3a1a4e2b2bcb7b48c8527c28098f207572ec1" \
9394
--key-manager-contract "0x2bbf15bc655c4cc157b769cfcb1ea9924b9e1a35" \
95+
--timestamp {{DATETIME}} \
9496
--output "test-configs/c0" {{ARGS}}
9597

96-
mkconfig_docker *ARGS:
98+
mkconfig_docker DATETIME *ARGS:
9799
cargo run --bin mkconfig -- -n 5 \
98100
--public-addr "172.20.0.2:8000" \
99101
--internal-addr "172.20.0.2:8003" \
100102
--mode "increment-address" \
103+
--chain-namespace 10101 \
101104
--parent-rpc-url "http://127.0.0.1:8545" \
102105
--parent-chain-id 31337 \
103106
--parent-ibox-contract "0xa0f3a1a4e2b2bcb7b48c8527c28098f207572ec1" \
104107
--key-manager-contract "0x2bbf15bc655c4cc157b769cfcb1ea9924b9e1a35" \
108+
--timestamp {{DATETIME}} \
105109
--output "test-configs/docker" {{ARGS}}
106110

107-
mkconfig_nitro *ARGS:
111+
mkconfig_nitro DATETIME *ARGS:
108112
cargo run --bin mkconfig -- -n 2 \
109113
--public-addr "127.0.0.1:8000" \
110114
--internal-addr "127.0.0.1:8003" \
111115
--nitro-addr "localhost:55000" \
116+
--chain-namespace 412346 \
112117
--parent-rpc-url "http://127.0.0.1:8545" \
113118
--parent-chain-id 1337 \
114119
--parent-ibox-contract "0xa0f3a1a4e2b2bcb7b48c8527c28098f207572ec1" \
115120
--key-manager-contract "0x2bbf15bc655c4cc157b769cfcb1ea9924b9e1a35" \
121+
--timestamp {{DATETIME}} \
116122
--output "test-configs/nitro-ci-committee" {{ARGS}}
117123

118124
verify_blocks *ARGS:

metrics/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ description = "Metrics API types"
44
version.workspace = true
55
edition.workspace = true
66
rust-version.workspace = true
7+
8+
[features]
9+
prometheus = ["dep:parking_lot", "dep:prometheus"]
10+
11+
[dependencies]
12+
parking_lot = { workspace = true, optional = true }
13+
prometheus = { workspace = true, optional = true }

metrics/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
//! - [`Histogram`]: stores multiple float values based for a graph (example usage: CPU %)
1515
//! - text: stores a constant string in the collected metrics
1616
17+
#[cfg(feature = "prometheus")]
18+
pub mod prometheus;
19+
1720
use std::fmt::Debug;
1821

1922
/// The metrics type.

timeboost-utils/src/types/prometheus.rs renamed to metrics/src/prometheus.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{collections::HashMap, sync::Arc};
22

3-
use metrics::{
3+
use crate::{
44
Counter, CounterFamily, Gauge, GaugeFamily, Histogram, HistogramFamily, Metrics, TextFamily,
55
};
66
use parking_lot::RwLock;
@@ -64,7 +64,7 @@ impl TimeboostGauge {
6464
}
6565

6666
#[derive(Debug)]
67-
pub struct PrometheusError(anyhow::Error);
67+
pub struct PrometheusError(Box<dyn std::error::Error + Send + Sync>);
6868

6969
impl std::fmt::Display for PrometheusError {
7070
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
@@ -80,7 +80,7 @@ impl std::error::Error for PrometheusError {
8080

8181
impl From<prometheus::Error> for PrometheusError {
8282
fn from(source: prometheus::Error) -> Self {
83-
Self(anyhow::anyhow!(source))
83+
Self(Box::new(source))
8484
}
8585
}
8686

scripts/run-timeboost-demo

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ tps=1
2424
stamp=
2525
ignore_stamp=false
2626
nitro_enabled=false
27-
namespace=10101
2827
yapper=false
2928

3029
while [[ $# -gt 0 ]]; do
@@ -33,10 +32,6 @@ while [[ $# -gt 0 ]]; do
3332
config_dir="$2"
3433
shift 2
3534
;;
36-
-n|--namespace)
37-
namespace="$2"
38-
shift 2
39-
;;
4035
-l|--late)
4136
late_start=true
4237
shift
@@ -74,9 +69,6 @@ Options:
7469
-l | --late
7570
Delayed startup of first node.
7671
77-
-n | --namespace <NUMBER>
78-
Espresso transactions namespace ID.
79-
8072
-c | --config-dir <PATH>
8173
Use a TOML file for node config (keys and network addresses).
8274
@@ -141,8 +133,7 @@ for f in "$config_dir"/node_*.toml; do
141133
--http-port $((8800 + 10 * $i))
142134
--until $rounds
143135
--stamp "${stamp}-$i.sf"
144-
--watchdog-timeout 120
145-
--namespace $namespace)
136+
--watchdog-timeout 120)
146137

147138
if $ignore_stamp; then
148139
cmd+=(--ignore-stamp)

scripts/runit

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ keyset_file=
1515
tps=1
1616
stamp=
1717
ignore_stamp=false
18-
namespace=10101
1918

2019
while [[ $# -gt 0 ]]; do
2120
case "$1" in
@@ -27,10 +26,6 @@ while [[ $# -gt 0 ]]; do
2726
late_start=true
2827
shift
2928
;;
30-
-n|--namespace)
31-
namespace="$2"
32-
shift 2
33-
;;
3429
-r|--rounds)
3530
rounds="$2"
3631
shift 2
@@ -56,9 +51,6 @@ Options:
5651
-l | --late
5752
Delayed startup of first node.
5853
59-
-n | --namespace <NUMBER>
60-
Espresso transactions namespace ID.
61-
6254
-k | --keyset-file <PATH>
6355
Use a JSON file for node keys.
6456
@@ -100,8 +92,7 @@ for (( i=0; i<$nodes; i++ )); do
10092
--until $rounds
10193
--keyset-file $keyset_file
10294
--stamp "${stamp}-$i.sf"
103-
--watchdog-timeout $rounds
104-
--namespace $namespace)
95+
--watchdog-timeout $rounds)
10596

10697
if $ignore_stamp; then
10798
cmd+=(--ignore-stamp)

0 commit comments

Comments
 (0)