Skip to content

Commit 60e2970

Browse files
committed
only add stable version to CI
1 parent ff084d1 commit 60e2970

23 files changed

+128
-486
lines changed

Diff for: .github/workflows/prod.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
rust: [stable, beta, nightly]
19+
rust: [stable]
2020

2121
steps:
2222
- uses: actions/checkout@v2

Diff for: rustfmt.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
use_small_heuristics = "Max"
2-
imports_granularity = "Crate"
2+

Diff for: src/cli.rs

+6-25
Original file line numberDiff line numberDiff line change
@@ -146,47 +146,28 @@ impl Cli {
146146
pub async fn run(self) -> anyhow::Result<()> {
147147
init_log(self.verbose)?;
148148
match self.commands {
149-
Commands::GenerateKeypair {
150-
folder,
151-
id,
152-
scheme,
153-
address,
154-
tls_disable,
155-
} => {
149+
Commands::GenerateKeypair { folder, id, scheme, address, tls_disable } => {
156150
// - Default boolean value is true, omitting '--tls_disable' leads to tls_disable:true
157151
// - We want to keep CLI in sync with golang implementation
158152
// - From here tls:true means tls enabled, this can probably be done more elegantly
159153
let tls = !tls_disable;
160154
crate::core::schemes::gen_keypair(scheme, &folder, tls, id, address)?
161155
}
162-
Commands::Start {
163-
folder,
164-
id,
165-
private_listen,
166-
control,
167-
} => control::start(&folder, id, &control, private_listen).await?,
156+
Commands::Start { folder, id, private_listen, control } => {
157+
control::start(&folder, id, &control, private_listen).await?
158+
}
168159

169160
Commands::Stop { control, id } => control::stop(&control, id.as_ref()).await?,
170161

171162
Commands::Show(show) => match show {
172163
Show::Public { control, id } => control::public_key_request(&control, id).await?,
173164
},
174165
Commands::Util(util) => match util {
175-
Util::Check {
176-
tls_disable,
177-
id,
178-
addresses,
179-
} => todo!(),
166+
Util::Check { tls_disable, id, addresses } => todo!(),
180167
Util::ListSchemes { control } => control::list_schemes(&control).await?,
181168
Util::PoolInfo { control } => control::pool_info(&control).await?,
182169
},
183-
Commands::Share {
184-
control,
185-
leader,
186-
id,
187-
tls_disable,
188-
connect,
189-
} => {
170+
Commands::Share { control, leader, id, tls_disable, connect } => {
190171
// - Default boolean value is true, omitting '--tls_disable' leads to tls_disable:true
191172
// - We want to keep CLI in sync with golang implementation
192173
// - From here tls:true means tls enabled, this can probably be done more elegantly

Diff for: src/core/beacon.rs

+5-23
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,7 @@ impl<S: Scheme> Beacon<S> {
125125
) -> Self {
126126
let span = info_span!("", id = format!("{private_listen}.{id}"));
127127

128-
Self(Arc::new(InnerNode {
129-
beacon_id: id.clone(),
130-
fs,
131-
keypair,
132-
pool,
133-
span,
134-
}))
128+
Self(Arc::new(InnerNode { beacon_id: id.clone(), fs, keypair, pool, span }))
135129
}
136130

137131
pub fn start(self, mut rx: Receiver<BeaconCmd>) {
@@ -299,18 +293,11 @@ impl<S: Scheme> Beacon<S> {
299293
secret: &[u8],
300294
) -> Result<DkgConfig<S>> {
301295
if secret != p.secret_proof {
302-
bail!(
303-
"secret_proof is not valid, beacon_id: {}",
304-
self.beacon_id.as_str()
305-
);
296+
bail!("secret_proof is not valid, beacon_id: {}", self.beacon_id.as_str());
306297
}
307298

308299
if p.new_group.scheme_id != S::ID {
309-
bail!(
310-
"invalid scheme, expected: {}, received: {}",
311-
S::ID,
312-
p.new_group.scheme_id,
313-
);
300+
bail!("invalid scheme, expected: {}, received: {}", S::ID, p.new_group.scheme_id,);
314301
}
315302
let leader_key = Affine::deserialize(leader_key)?;
316303

@@ -321,10 +308,7 @@ impl<S: Scheme> Beacon<S> {
321308
}
322309
let group: Group<S> = p.new_group.try_into()?;
323310
let Some(dkg_index) = group.find_index(self.keypair.public()) else {
324-
bail!(
325-
"local node {} is not found in group_file",
326-
self.keypair.public().address()
327-
)
311+
bail!("local node {} is not found in group_file", self.keypair.public().address())
328312
};
329313

330314
Ok(DkgConfig::new(leader_key, group, p.dkg_timeout, dkg_index))
@@ -333,9 +317,7 @@ impl<S: Scheme> Beacon<S> {
333317

334318
impl From<String> for BeaconID {
335319
fn from(value: String) -> Self {
336-
Self {
337-
inner: value.into(),
338-
}
320+
Self { inner: value.into() }
339321
}
340322
}
341323

Diff for: src/core/chain.rs

+3-15
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,7 @@ impl<S: Scheme> ChainHandler<S> {
118118

119119
async fn add_partial(&mut self, p: PartialBeaconPacket) -> Result<()> {
120120
let sig_sh = SigShare::deserialize(&p.partial_sig)?;
121-
if self
122-
.sigs_buf
123-
.iter()
124-
.any(|stored| stored.index() == sig_sh.index())
125-
{
121+
if self.sigs_buf.iter().any(|stored| stored.index() == sig_sh.index()) {
126122
debug!(parent: self.node.span(), "ignoring dublicated partial, index: {}, round: {}", sig_sh.index(), p.round);
127123
return Ok(());
128124
}
@@ -135,11 +131,7 @@ impl<S: Scheme> ChainHandler<S> {
135131
let msg = S::Beacon::digest(&p.previous_signature, p.round);
136132
let key = &self.share.public().eval(sig_sh.index()).v;
137133
if S::bls_verify(key, sig_sh.value(), &msg).is_err() {
138-
bail!(
139-
"invalid bls signarure, index: {}, round: {}",
140-
sig_sh.index(),
141-
p.round
142-
);
134+
bail!("invalid bls signarure, index: {}, round: {}", sig_sh.index(), p.round);
143135
}
144136

145137
debug!(parent: self.node.span(), "Added valid partial, index: {}, round: {}, last_stored.round: {}", sig_sh.index(), p.round, self.last_stored.round);
@@ -183,11 +175,7 @@ impl<S: Scheme> ChainHandler<S> {
183175
metadata: From::from(&self.node.beacon_id),
184176
};
185177

186-
if !self
187-
.sigs_buf
188-
.iter()
189-
.any(|stored| stored.index() == our_partial.index())
190-
{
178+
if !self.sigs_buf.iter().any(|stored| stored.index() == our_partial.index()) {
191179
self.try_recover(our_partial, &msg);
192180
}
193181
let _ = self.node.pool.send(PoolCmd::Partial(packet)).await;

Diff for: src/core/daemon.rs

+4-17
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,7 @@ impl Daemon {
5454
let pool = Pool::start(false, logger.register_pool());
5555
let beacons = MultiBeacon::new(beacon_id, base_folder, &private_listen, pool.clone())?;
5656
let (stop_daemon, _) = tokio::sync::broadcast::channel::<()>(1);
57-
let daemon = Self {
58-
beacons,
59-
stop_daemon,
60-
logger,
61-
private_listen,
62-
pool,
63-
};
57+
let daemon = Self { beacons, stop_daemon, logger, private_listen, pool };
6458

6559
Ok(Arc::new(daemon))
6660
}
@@ -127,9 +121,7 @@ impl Daemon {
127121
.await
128122
.map_err(|e| Status::invalid_argument(e.to_string()))?;
129123

130-
callback
131-
.await
132-
.map_or_else(|_| Err(Status::internal(INTERNAL_ERR)), Ok)
124+
callback.await.map_or_else(|_| Err(Status::internal(INTERNAL_ERR)), Ok)
133125
}
134126

135127
pub async fn broadcast_dkg_bundle(&self, bundle: Bundle, id: &str) -> Result<(), Status> {
@@ -166,14 +158,9 @@ impl Daemon {
166158

167159
pub async fn pool_status(&self) -> Result<String, Status> {
168160
let (sender, callback) = oneshot::channel();
169-
self.pool
170-
.send(PoolCmd::Status(sender))
171-
.await
172-
.map_err(|e| Status::from_error(e.into()))?;
161+
self.pool.send(PoolCmd::Status(sender)).await.map_err(|e| Status::from_error(e.into()))?;
173162

174-
callback
175-
.await
176-
.map_or_else(|_| Err(Status::internal(INTERNAL_ERR)), Ok)
163+
callback.await.map_or_else(|_| Err(Status::internal(INTERNAL_ERR)), Ok)
177164
}
178165
}
179166

0 commit comments

Comments
 (0)