Skip to content

Commit 1651ab4

Browse files
committed
Handle post-merge conflicts.
1 parent 2d25530 commit 1651ab4

File tree

4 files changed

+44
-36
lines changed

4 files changed

+44
-36
lines changed

Cargo.lock

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

tests/src/tests/timeboost.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ use cliquenet::{Address, AddressableCommittee};
1515
use metrics::NoMetrics;
1616
use multisig::Keypair;
1717
use multisig::{Committee, x25519};
18-
use sailfish_types::UNKNOWN_COMMITTEE_ID;
18+
use parking_lot::Mutex;
19+
use sailfish_types::{RoundNumber, UNKNOWN_COMMITTEE_ID};
1920
use test_utils::ports::alloc_ports;
2021
use timeboost::builder::CertifierConfig;
2122
use timeboost::config::{ChainConfig, ParentChain};

tests/src/tests/timeboost/timeboost_handover.rs

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
use alloy::eips::BlockNumberOrTag;
2-
use cliquenet::{Address, AddressableCommittee};
3-
use multisig::{Certificate, Committee, CommitteeId, Keypair, x25519};
4-
use sailfish::types::{ConsensusTime, Timestamp};
51
use std::cmp::min;
62
use std::collections::HashMap;
73
use std::iter::{once, repeat_with};
84
use std::net::Ipv4Addr;
95
use std::num::NonZeroUsize;
106
use std::sync::Arc;
11-
use timeboost::builder::CertifierConfig;
7+
8+
use alloy::eips::BlockNumberOrTag;
9+
use cliquenet::{Address, AddressableCommittee};
10+
use multisig::{Certificate, Committee, CommitteeId, Keypair, x25519};
11+
use sailfish::types::{ConsensusTime, RoundNumber, Timestamp};
12+
use timeboost::builder::Certifier;
1213
use timeboost::config::{CERTIFIER_PORT_OFFSET, ChainConfig, DECRYPTER_PORT_OFFSET, ParentChain};
1314
use timeboost::crypto::prelude::DkgDecKey;
1415
use timeboost::sequencer::{Output, SequencerConfig};
@@ -285,7 +286,7 @@ async fn run_handover(
285286
}
286287

287288
/// Create sequencer configs.
288-
fn mk_configs(
289+
async fn mk_configs(
289290
id: CommitteeId,
290291
prev: &[(DecryptionKeyCell, SequencerConfig, CertifierConfig)],
291292
keep: usize,
@@ -313,30 +314,30 @@ fn mk_configs(
313314
.chain(repeat_with(DkgDecKey::generate).take(add.get()))
314315
.collect::<Vec<_>>();
315316

316-
let sf_addrs = prev
317+
let mut sf_addrs = prev
317318
.iter()
318319
.take(keep)
319320
.map(|c| c.1.sailfish_address().clone())
320-
.chain(
321-
repeat_with(|| {
322-
loop {
323-
if let Some(port) = portpicker::pick_unused_port() {
324-
break Address::from((Ipv4Addr::LOCALHOST, port));
325-
}
326-
}
327-
})
328-
.take(add.get()),
329-
)
330321
.collect::<Vec<_>>();
331322

323+
sf_addrs.extend(
324+
alloc_ports(add.get() as u16)
325+
.await
326+
.unwrap()
327+
.into_iter()
328+
.map(|p| Address::from((Ipv4Addr::LOCALHOST, p))),
329+
);
330+
332331
let de_addrs = sf_addrs
333332
.iter()
334-
.map(|addr| Address::from((Ipv4Addr::LOCALHOST, addr.port() + CERTIFIER_PORT_OFFSET)))
333+
.cloned()
334+
.map(|addr| addr.with_offset(DECRYPTER_PORT_OFFSET))
335335
.collect::<Vec<_>>();
336336

337337
let cert_addrs = sf_addrs
338338
.iter()
339-
.map(|addr| Address::from((Ipv4Addr::LOCALHOST, addr.port() + DECRYPTER_PORT_OFFSET)))
339+
.cloned()
340+
.map(|addr| addr.with_offset(CERTIFIER_PORT_OFFSET))
340341
.collect::<Vec<_>>();
341342

342343
let committee = Committee::new(
@@ -482,28 +483,30 @@ impl TestConfig {
482483
self
483484
}
484485

485-
fn build(self) -> Vec<(DecryptionKeyCell, SequencerConfig, CertifierConfig)> {
486+
async fn build(self) -> Vec<(DecryptionKeyCell, SequencerConfig, CertifierConfig)> {
486487
mk_configs(
487488
self.committee_id,
488489
&self.prev_configs,
489490
self.keep,
490491
self.add,
491492
self.set_prev,
492493
)
494+
.await
493495
}
494496
}
495497

496498
#[tokio::test]
497499
async fn handover_0_to_5() {
498500
init_logging();
499501

500-
let c1 = TestConfig::new(0).build();
502+
let c1 = TestConfig::new(0).build().await;
501503
let c2 = TestConfig::new(1)
502504
.with_prev_configs(&c1)
503505
.keep_nodes(0)
504506
.add_nodes(NonZeroUsize::new(5).unwrap())
505507
.set_previous_committee(true)
506-
.build();
508+
.build()
509+
.await;
507510

508511
run_handover(c1, c2).await;
509512
}
@@ -512,13 +515,14 @@ async fn handover_0_to_5() {
512515
async fn handover_1_to_4() {
513516
init_logging();
514517

515-
let c1 = TestConfig::new(0).build();
518+
let c1 = TestConfig::new(0).build().await;
516519
let c2 = TestConfig::new(1)
517520
.with_prev_configs(&c1)
518521
.keep_nodes(1)
519522
.add_nodes(NonZeroUsize::new(4).unwrap())
520523
.set_previous_committee(true)
521-
.build();
524+
.build()
525+
.await;
522526

523527
run_handover(c1, c2).await;
524528
}
@@ -527,13 +531,14 @@ async fn handover_1_to_4() {
527531
async fn handover_2_to_3() {
528532
init_logging();
529533

530-
let c1 = TestConfig::new(0).build();
534+
let c1 = TestConfig::new(0).build().await;
531535
let c2 = TestConfig::new(1)
532536
.with_prev_configs(&c1)
533537
.keep_nodes(2)
534538
.add_nodes(NonZeroUsize::new(3).unwrap())
535539
.set_previous_committee(true)
536-
.build();
540+
.build()
541+
.await;
537542

538543
run_handover(c1, c2).await;
539544
}
@@ -542,39 +547,42 @@ async fn handover_2_to_3() {
542547
async fn handover_3_to_2() {
543548
init_logging();
544549

545-
let c1 = TestConfig::new(0).build();
550+
let c1 = TestConfig::new(0).build().await;
546551
let c2 = TestConfig::new(1)
547552
.with_prev_configs(&c1)
548553
.keep_nodes(3)
549554
.add_nodes(NonZeroUsize::new(2).unwrap())
550555
.set_previous_committee(true)
551-
.build();
556+
.build()
557+
.await;
552558
run_handover(c1, c2).await;
553559
}
554560

555561
#[tokio::test]
556562
async fn handover_4_to_1() {
557563
init_logging();
558564

559-
let c1 = TestConfig::new(0).build();
565+
let c1 = TestConfig::new(0).build().await;
560566
let c2 = TestConfig::new(1)
561567
.with_prev_configs(&c1)
562568
.keep_nodes(4)
563569
.add_nodes(NonZeroUsize::new(1).unwrap())
564570
.set_previous_committee(true)
565-
.build();
571+
.build()
572+
.await;
566573
run_handover(c1, c2).await;
567574
}
568575

569576
#[tokio::test]
570577
async fn handover_3_to_5() {
571578
init_logging();
572-
let c1 = TestConfig::new(0).build();
579+
let c1 = TestConfig::new(0).build().await;
573580
let c2 = TestConfig::new(1)
574581
.with_prev_configs(&c1)
575582
.keep_nodes(3)
576583
.add_nodes(NonZeroUsize::new(5).unwrap())
577584
.set_previous_committee(true)
578-
.build();
585+
.build()
586+
.await;
579587
run_handover(c1, c2).await;
580588
}

timeboost-config/src/node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use multisig::x25519;
88
use serde::{Deserialize, Serialize};
99
use timeboost_crypto::prelude::{DkgDecKey, DkgEncKey};
1010

11-
pub const DECRYPTER_PORT_OFFSET: u16 = 1;
12-
pub const CERTIFIER_PORT_OFFSET: u16 = 2;
11+
pub const DECRYPTER_PORT_OFFSET: u16 = 100;
12+
pub const CERTIFIER_PORT_OFFSET: u16 = 200;
1313

1414
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
1515
pub struct NodeConfig {

0 commit comments

Comments
 (0)