Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/local-integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ jobs:

echo "Starting router in background..."
# Source environment and run router in background
nohup cargo run -p counter-router --release -- --key-file config/router_orchestrator.json --port 3000 > router.log 2>&1 &
nohup cargo run -p counter-router --release -- --key-file config/router_key.json --port 3000 > router.log 2>&1 &
echo $! > router.pid

# Wait for router to start
Expand Down
3 changes: 0 additions & 3 deletions config/orchestrator.json

This file was deleted.

File renamed without changes.
File renamed without changes.
22 changes: 11 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ services:
volumes:
- ./config/.nodes/operator_keys/testacc1.private.bls.key.json:/app/key.json:ro
- ./config/.nodes:/app/.nodes:ro
- ./config/public_orchestrator.json:/app/public_orchestrator.json:ro
- ./config/public_router.json:/app/public_router.json:ro
- node-1-data:/app/data
command:
[
"--key-file",
"/app/key.json",
"--port",
"3001",
"--orchestrator",
"/app/public_orchestrator.json",
"--router",
"/app/public_router.json",
]
ports:
- "3001:3001"
Expand All @@ -91,16 +91,16 @@ services:
volumes:
- ./config/.nodes/operator_keys/testacc2.private.bls.key.json:/app/key.json:ro
- ./config/.nodes:/app/.nodes:ro
- ./config/public_orchestrator.json:/app/public_orchestrator.json:ro
- ./config/public_router.json:/app/public_router.json:ro
- node-2-data:/app/data
command:
[
"--key-file",
"/app/key.json",
"--port",
"3002",
"--orchestrator",
"/app/public_orchestrator.json",
"--router",
"/app/public_router.json",
]
ports:
- "3002:3002"
Expand All @@ -127,16 +127,16 @@ services:
volumes:
- ./config/.nodes/operator_keys/testacc3.private.bls.key.json:/app/key.json:ro
- ./config/.nodes:/app/.nodes:ro
- ./config/public_orchestrator.json:/app/public_orchestrator.json:ro
- ./config/public_router.json:/app/public_router.json:ro
- node-3-data:/app/data
command:
[
"--key-file",
"/app/key.json",
"--port",
"3003",
"--orchestrator",
"/app/public_orchestrator.json",
"--router",
"/app/public_router.json",
]
ports:
- "3003:3003"
Expand Down Expand Up @@ -167,9 +167,9 @@ services:
- STORAGE_DIR=/app/data
volumes:
- ./config/.nodes:/app/.nodes:ro
- ./config/router_orchestrator.json:/app/router_orchestrator.json:ro
- ./config/router_key.json:/app/router_key.json:ro
- router-data:/app/data
command: ["--key-file", "/app/router_orchestrator.json", "--port", "3000"]
command: ["--key-file", "/app/router_key.json", "--port", "3000"]
ports:
- "4000:3000"
- "8080:8080"
Expand Down
8 changes: 0 additions & 8 deletions example.env
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ FUNDED_KEY= # Required for TESTNET mode, should have testnet ETH
# =============================================================================
TEST_ACCOUNTS=3

# =============================================================================
# Contributor Key Files
# =============================================================================
# These will be generated by the Docker setup
CONTRIBUTOR_1_KEYFILE="config/.nodes/operator_keys/testacc1.private.bls.key.json"
CONTRIBUTOR_2_KEYFILE="config/.nodes/operator_keys/testacc2.private.bls.key.json"
CONTRIBUTOR_3_KEYFILE="config/.nodes/operator_keys/testacc3.private.bls.key.json"

# =============================================================================
# Service Configuration
# =============================================================================
Expand Down
51 changes: 25 additions & 26 deletions examples/counter/node/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct KeyConfig {
}
#[derive(Debug, Serialize, Deserialize)]
#[allow(non_snake_case)]
struct OrchestratorConfig {
struct RouterConfig {
g2_x1: String,
g2_x2: String,
g2_y1: String,
Expand All @@ -77,10 +77,9 @@ fn load_key_from_file(path: &str) -> String {
config.privateKey
}

fn load_orchestrator_config(path: &str) -> OrchestratorConfig {
fn load_router_config(path: &str) -> RouterConfig {
let contents = fs::read_to_string(path).expect("Could not read key file");
let config: OrchestratorConfig =
serde_json::from_str(&contents).expect("Could not parse key file");
let config: RouterConfig = serde_json::from_str(&contents).expect("Could not parse key file");
config
}

Expand Down Expand Up @@ -109,11 +108,11 @@ fn configure_identity(matches: &clap::ArgMatches) -> (Bn254, u16) {
(signer, port)
}

fn configure_orchestrator(matches: &clap::ArgMatches) -> OrchestratorConfig {
let orchestrator_file = matches
.get_one::<String>("orchestrator")
.expect("No orchestrator addr");
load_orchestrator_config(orchestrator_file)
fn configure_router(matches: &clap::ArgMatches) -> RouterConfig {
let router_file = matches
.get_one::<String>("router")
.expect("No router connection file provided");
load_router_config(router_file)
}

async fn get_operator_states() -> Result<Vec<QuorumInfo>, Box<dyn std::error::Error>> {
Expand Down Expand Up @@ -153,22 +152,22 @@ pub fn main() {
.help("Port to run the service on"),
)
.arg(
Arg::new("orchestrator")
.long("orchestrator")
Arg::new("router")
.long("router")
.required(false)
.help("Path to orchestrator key file"),
.help("Path to the router's public connection file"),
)
.get_matches();

// Configure my identity
let (signer, port) = configure_identity(&matches);
let orchestrator_config = configure_orchestrator(&matches);
let router_config = configure_router(&matches);

// Start runtime
runner.start(|context: tokio::Context| async move {
let mut recipients: Vec<(PublicKey, Address)> = Vec::new();
// Scoped to avoid configuring two loggers
let orchestrator_pub_key;
let router_pub_key;
let quorum_infos;
{
eigen_logging::init_logger(LogLevel::Debug);
Expand Down Expand Up @@ -199,35 +198,35 @@ pub fn main() {
recipients.push((verifier, Address::from(socket_addr)));
}
Err(_) => {
panic!("Contributor address not well-formed: {socket}");
panic!("Operator address not well-formed: {socket}");
}
}
}
}
}
}
orchestrator_pub_key = PublicKey::create_from_g2_coordinates(
&orchestrator_config.g2_x1,
&orchestrator_config.g2_x2,
&orchestrator_config.g2_y1,
&orchestrator_config.g2_y2,
router_pub_key = PublicKey::create_from_g2_coordinates(
&router_config.g2_x1,
&router_config.g2_x2,
&router_config.g2_y1,
&router_config.g2_y2,
)
.unwrap();

let orchestrator_addr = orchestrator_config
let router_addr = router_config
.address
.parse::<IpAddr>()
.unwrap_or(IpAddr::V4(Ipv4Addr::LOCALHOST));

let local_addr = SocketAddr::new(
orchestrator_addr,
orchestrator_config
router_addr,
router_config
.port
.parse::<u16>()
.expect("Port not well-formed"),
);

recipients.push((orchestrator_pub_key.clone(), Address::from(local_addr)));
recipients.push((router_pub_key.clone(), Address::from(local_addr)));
}

tracing::info!(storage_dir = %storage_dir.display(), "engine journal storage directory");
Expand Down Expand Up @@ -260,7 +259,7 @@ pub fn main() {
// both sides resolve a duplicate to the same G1 key.
let operators = &quorum_infos[0].operators;
if operators.is_empty() {
panic!("Please provide at least one contributor");
panic!("Please provide at least one operator");
}
let key_map: Map<PublicKey, G1PublicKey> =
Map::from_iter_dedup(operators.iter().map(|operator| {
Expand Down Expand Up @@ -329,7 +328,7 @@ pub fn main() {
// are authorized on the channel but must not assign heights).
{
let task_book_mailbox = task_book_mailbox.clone();
let router_key = orchestrator_pub_key.clone();
let router_key = router_pub_key.clone();
let engine_tip = Arc::clone(&engine_tip);
let min_report_interval = rebroadcast_interval();
context.child("directives").spawn(move |_| async move {
Expand Down
12 changes: 6 additions & 6 deletions examples/counter/router/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub fn main() {
let runner = tokio::Runner::new(runtime_cfg);

// Parse arguments
let matches = Command::new("orchestrator")
let matches = Command::new("router")
.about("generate and verify BN254 Multi-Signatures")
.arg(
Arg::new("bootstrappers")
Expand Down Expand Up @@ -198,9 +198,9 @@ pub fn main() {
}
}
// Authorize ourselves too (nodes dial the router from
// public_orchestrator.json; this entry is never dialed by us).
let orchestrator_verifier = signer.public_key();
recipients.push((orchestrator_verifier, Address::from(my_addr)));
// public_router.json; this entry is never dialed by us).
let router_verifier = signer.public_key();
recipients.push((router_verifier, Address::from(my_addr)));
}
let subscriber = tracing_subscriber::fmt()
.with_max_level(tracing::Level::DEBUG)
Expand All @@ -221,12 +221,12 @@ pub fn main() {
// different G1 keys cannot misalign the two sides' participant indices.
let operators = &quorum_infos[0].operators;
if operators.is_empty() {
panic!("Please provide at least one contributor");
panic!("Please provide at least one operator");
}
let key_map: Map<PublicKey, G1PublicKey> =
Map::from_iter_dedup(operators.iter().map(|operator| {
let keys = operator.pub_keys.as_ref().expect("operator has BLS keys");
tracing::info!(key = ?keys.g2_pub_key, "registered contributor");
tracing::info!(key = ?keys.g2_pub_key, "registered operator");
(keys.g2_pub_key.clone(), keys.g1_pub_key.clone())
}));
let participants: Set<PublicKey> = Set::from_iter_dedup(key_map.iter().cloned());
Expand Down
6 changes: 3 additions & 3 deletions node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ full task-flow and quorum model.

### Router Connection File

A node locates the router via a JSON file passed to `--orchestrator` carrying
the router's public identity and socket address:
A node locates the router via a JSON file passed to `--router` carrying the
router's public identity and socket address:

```json
{
Expand Down Expand Up @@ -61,7 +61,7 @@ the router's public identity and socket address:
### Running

```bash
cargo run --release -- --key-file operator1.bls.key.json --port 3001 --orchestrator public_orchestrator.json
cargo run --release -- --key-file operator1.bls.key.json --port 3001 --router public_router.json
```

Run one process per operator, each with its own `--key-file` and `--port`.
6 changes: 3 additions & 3 deletions router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ Contract addresses are loaded from the deployment JSON file.
### Running

```bash
cargo run -p counter-router --release -- --key-file router_orchestrator.json --port 3000
cargo run -p counter-router --release -- --key-file router_key.json --port 3000
```

`--key-file` is the router's own BLS private key (`{"privateKey": "..."}`).
`--bootstrappers` optionally takes a comma-separated list of additional peer
addresses. Nodes locate the router via a separate file carrying its public
identity and socket address (`{g2_x1, g2_x2, g2_y1, g2_y2, address, port}`,
conventionally named `public_orchestrator.json`), passed to each node's
`--orchestrator` flag.
conventionally named `public_router.json`), passed to each node's `--router`
flag.

### Docker

Expand Down
10 changes: 5 additions & 5 deletions router/src/submitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,16 +298,16 @@ where
// precomputed pubkey hash.
let mut operators: Vec<Option<Address>> = Vec::with_capacity(participating.len());
let mut misses: Vec<(usize, PublicKey, FixedBytes<32>)> = Vec::new();
for (index, (contributor, g1_pubkey)) in participating
for (index, (operator, g1_pubkey)) in participating
.iter()
.zip(participating_g1.iter())
.enumerate()
{
match self.operator_cache.get(contributor) {
match self.operator_cache.get(operator) {
Some(address) => operators.push(Some(*address)),
None => {
operators.push(None);
misses.push((index, contributor.clone(), pubkey_hash(g1_pubkey)?));
misses.push((index, operator.clone(), pubkey_hash(g1_pubkey)?));
}
}
}
Expand All @@ -332,11 +332,11 @@ where
let resolved =
futures::future::join_all(calls.iter().map(|call| call.call().into_future())).await;

for ((index, contributor, _), result) in misses.into_iter().zip(resolved) {
for ((index, operator, _), result) in misses.into_iter().zip(resolved) {
let address = result.map_err(|e| {
anyhow::anyhow!("Failed to get operator from pubkey hash: {}", e)
})?;
self.operator_cache.insert(contributor, address);
self.operator_cache.insert(operator, address);
operators[index] = Some(address);
}
}
Expand Down
Loading
Loading