mirror of
https://github.com/serai-dex/serai.git
synced 2024-11-16 17:07:35 +00:00
Add workspace lints
This commit is contained in:
parent
c40ce00955
commit
ea3af28139
122 changed files with 329 additions and 128 deletions
25
Cargo.toml
25
Cargo.toml
|
@ -96,3 +96,28 @@ lazy_static = { git = "https://github.com/rust-lang-nursery/lazy-static.rs", rev
|
||||||
# subxt *can* pull these off crates.io yet there's no benefit to this
|
# subxt *can* pull these off crates.io yet there's no benefit to this
|
||||||
sp-core-hashing = { git = "https://github.com/serai-dex/substrate" }
|
sp-core-hashing = { git = "https://github.com/serai-dex/substrate" }
|
||||||
sp-std = { git = "https://github.com/serai-dex/substrate" }
|
sp-std = { git = "https://github.com/serai-dex/substrate" }
|
||||||
|
|
||||||
|
[workspace.lints.clippy]
|
||||||
|
unwrap_or_default = "allow"
|
||||||
|
borrow_as_ptr = "deny"
|
||||||
|
cast_lossless = "deny"
|
||||||
|
cast_possible_truncation = "deny"
|
||||||
|
cast_possible_wrap = "deny"
|
||||||
|
cast_precision_loss = "deny"
|
||||||
|
cast_ptr_alignment = "deny"
|
||||||
|
cast_sign_loss = "deny"
|
||||||
|
checked_conversions = "deny"
|
||||||
|
cloned_instead_of_copied = "deny"
|
||||||
|
enum_glob_use = "deny"
|
||||||
|
expl_impl_clone_on_copy = "deny"
|
||||||
|
explicit_into_iter_loop = "deny"
|
||||||
|
explicit_iter_loop = "deny"
|
||||||
|
flat_map_option = "deny"
|
||||||
|
float_cmp = "deny"
|
||||||
|
fn_params_excessive_bools = "deny"
|
||||||
|
ignored_unit_patterns = "deny"
|
||||||
|
implicit_clone = "deny"
|
||||||
|
inefficient_to_string = "deny"
|
||||||
|
invalid_upcast_comparisons = "deny"
|
||||||
|
large_stack_arrays = "deny"
|
||||||
|
linkedlist = "deny"
|
||||||
|
|
|
@ -8,6 +8,13 @@ authors = ["Luke Parker <lukeparker5132@gmail.com>", "Vrx <vrx00@proton.me>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.74"
|
rust-version = "1.74"
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
std-shims = { version = "0.1.1", path = "../../common/std-shims", default-features = false }
|
std-shims = { version = "0.1.1", path = "../../common/std-shims", default-features = false }
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ fn test_algorithm() {
|
||||||
let mut keys = key_gen::<_, Secp256k1>(&mut OsRng);
|
let mut keys = key_gen::<_, Secp256k1>(&mut OsRng);
|
||||||
const MESSAGE: &[u8] = b"Hello, World!";
|
const MESSAGE: &[u8] = b"Hello, World!";
|
||||||
|
|
||||||
for (_, keys) in keys.iter_mut() {
|
for keys in keys.values_mut() {
|
||||||
let (_, offset) = make_even(keys.group_key());
|
let (_, offset) = make_even(keys.group_key());
|
||||||
*keys = keys.offset(Scalar::from(offset));
|
*keys = keys.offset(Scalar::from(offset));
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,7 +355,7 @@ impl SignMachine<Transaction> for TransactionSignMachine {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_cache(
|
fn from_cache(
|
||||||
_: (),
|
(): (),
|
||||||
_: ThresholdKeys<Secp256k1>,
|
_: ThresholdKeys<Secp256k1>,
|
||||||
_: CachedPreprocess,
|
_: CachedPreprocess,
|
||||||
) -> (Self, Self::Preprocess) {
|
) -> (Self, Self::Preprocess) {
|
||||||
|
|
|
@ -82,7 +82,7 @@ async fn send_and_get_output(rpc: &Rpc, scanner: &Scanner, key: ProjectivePoint)
|
||||||
|
|
||||||
fn keys() -> (HashMap<Participant, ThresholdKeys<Secp256k1>>, ProjectivePoint) {
|
fn keys() -> (HashMap<Participant, ThresholdKeys<Secp256k1>>, ProjectivePoint) {
|
||||||
let mut keys = key_gen(&mut OsRng);
|
let mut keys = key_gen(&mut OsRng);
|
||||||
for (_, keys) in keys.iter_mut() {
|
for keys in keys.values_mut() {
|
||||||
*keys = tweak_keys(keys);
|
*keys = tweak_keys(keys);
|
||||||
}
|
}
|
||||||
let key = keys.values().next().unwrap().group_key();
|
let key = keys.values().next().unwrap().group_key();
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.74"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
thiserror = { version = "1", default-features = false }
|
thiserror = { version = "1", default-features = false }
|
||||||
eyre = { version = "0.6", default-features = false }
|
eyre = { version = "0.6", default-features = false }
|
||||||
|
|
|
@ -12,6 +12,9 @@ rust-version = "1.74"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
std-shims = { path = "../../common/std-shims", version = "^0.1.1", default-features = false }
|
std-shims = { path = "../../common/std-shims", version = "^0.1.1", default-features = false }
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ edition = "2021"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
std-shims = { path = "../../../common/std-shims", version = "^0.1.1", default-features = false }
|
std-shims = { path = "../../../common/std-shims", version = "^0.1.1", default-features = false }
|
||||||
|
|
||||||
|
|
|
@ -172,8 +172,8 @@ impl Bulletproofs {
|
||||||
write_scalar(&bp.wip.r_answer.0, w)?;
|
write_scalar(&bp.wip.r_answer.0, w)?;
|
||||||
write_scalar(&bp.wip.s_answer.0, w)?;
|
write_scalar(&bp.wip.s_answer.0, w)?;
|
||||||
write_scalar(&bp.wip.delta_answer.0, w)?;
|
write_scalar(&bp.wip.delta_answer.0, w)?;
|
||||||
specific_write_vec(&bp.wip.L.iter().cloned().map(|L| L.0).collect::<Vec<_>>(), w)?;
|
specific_write_vec(&bp.wip.L.iter().copied().map(|L| L.0).collect::<Vec<_>>(), w)?;
|
||||||
specific_write_vec(&bp.wip.R.iter().cloned().map(|R| R.0).collect::<Vec<_>>(), w)
|
specific_write_vec(&bp.wip.R.iter().copied().map(|R| R.0).collect::<Vec<_>>(), w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ impl ScalarVector {
|
||||||
|
|
||||||
pub(crate) fn add(&self, scalar: impl Borrow<Scalar>) -> Self {
|
pub(crate) fn add(&self, scalar: impl Borrow<Scalar>) -> Self {
|
||||||
let mut res = self.clone();
|
let mut res = self.clone();
|
||||||
for val in res.0.iter_mut() {
|
for val in &mut res.0 {
|
||||||
*val += scalar.borrow();
|
*val += scalar.borrow();
|
||||||
}
|
}
|
||||||
res
|
res
|
||||||
|
@ -40,7 +40,7 @@ impl ScalarVector {
|
||||||
|
|
||||||
pub(crate) fn sub(&self, scalar: impl Borrow<Scalar>) -> Self {
|
pub(crate) fn sub(&self, scalar: impl Borrow<Scalar>) -> Self {
|
||||||
let mut res = self.clone();
|
let mut res = self.clone();
|
||||||
for val in res.0.iter_mut() {
|
for val in &mut res.0 {
|
||||||
*val -= scalar.borrow();
|
*val -= scalar.borrow();
|
||||||
}
|
}
|
||||||
res
|
res
|
||||||
|
@ -48,7 +48,7 @@ impl ScalarVector {
|
||||||
|
|
||||||
pub(crate) fn mul(&self, scalar: impl Borrow<Scalar>) -> Self {
|
pub(crate) fn mul(&self, scalar: impl Borrow<Scalar>) -> Self {
|
||||||
let mut res = self.clone();
|
let mut res = self.clone();
|
||||||
for val in res.0.iter_mut() {
|
for val in &mut res.0 {
|
||||||
*val *= scalar.borrow();
|
*val *= scalar.borrow();
|
||||||
}
|
}
|
||||||
res
|
res
|
||||||
|
|
|
@ -414,7 +414,7 @@ impl WipStatement {
|
||||||
|
|
||||||
let mut multiexp = P_terms;
|
let mut multiexp = P_terms;
|
||||||
multiexp.reserve(4 + (2 * generators.len()));
|
multiexp.reserve(4 + (2 * generators.len()));
|
||||||
for (scalar, _) in multiexp.iter_mut() {
|
for (scalar, _) in &mut multiexp {
|
||||||
*scalar *= neg_e_square;
|
*scalar *= neg_e_square;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ impl HttpRpc {
|
||||||
)?;
|
)?;
|
||||||
Authentication::Authenticated {
|
Authentication::Authenticated {
|
||||||
username: split_userpass[0].to_string(),
|
username: split_userpass[0].to_string(),
|
||||||
password: split_userpass.get(1).unwrap_or(&"").to_string(),
|
password: (*split_userpass.get(1).unwrap_or(&"")).to_string(),
|
||||||
connection: Arc::new(Mutex::new((challenge, client))),
|
connection: Arc::new(Mutex::new((challenge, client))),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,7 +16,7 @@ pub(crate) fn PRECOMPUTED_SCALARS() -> [Scalar; 8] {
|
||||||
*PRECOMPUTED_SCALARS_CELL.get_or_init(|| {
|
*PRECOMPUTED_SCALARS_CELL.get_or_init(|| {
|
||||||
let mut precomputed_scalars = [Scalar::ONE; 8];
|
let mut precomputed_scalars = [Scalar::ONE; 8];
|
||||||
for (i, scalar) in precomputed_scalars.iter_mut().enumerate().skip(1) {
|
for (i, scalar) in precomputed_scalars.iter_mut().enumerate().skip(1) {
|
||||||
*scalar = Scalar::from(((i * 2) + 1) as u8);
|
*scalar = Scalar::from(u8::try_from((i * 2) + 1).unwrap());
|
||||||
}
|
}
|
||||||
precomputed_scalars
|
precomputed_scalars
|
||||||
})
|
})
|
||||||
|
@ -57,7 +57,7 @@ impl UnreducedScalar {
|
||||||
let bits = self.as_bits();
|
let bits = self.as_bits();
|
||||||
let mut naf = [0i8; 256];
|
let mut naf = [0i8; 256];
|
||||||
for (b, bit) in bits.into_iter().enumerate() {
|
for (b, bit) in bits.into_iter().enumerate() {
|
||||||
naf[b] = bit as i8;
|
naf[b] = i8::try_from(bit).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 0 .. 256 {
|
for i in 0 .. 256 {
|
||||||
|
@ -127,8 +127,8 @@ impl UnreducedScalar {
|
||||||
for &numb in self.non_adjacent_form().iter().rev() {
|
for &numb in self.non_adjacent_form().iter().rev() {
|
||||||
recovered += recovered;
|
recovered += recovered;
|
||||||
match numb.cmp(&0) {
|
match numb.cmp(&0) {
|
||||||
Ordering::Greater => recovered += precomputed_scalars[(numb as usize) / 2],
|
Ordering::Greater => recovered += precomputed_scalars[usize::try_from(numb).unwrap() / 2],
|
||||||
Ordering::Less => recovered -= precomputed_scalars[((-numb) as usize) / 2],
|
Ordering::Less => recovered -= precomputed_scalars[usize::try_from(-numb).unwrap() / 2],
|
||||||
Ordering::Equal => (),
|
Ordering::Equal => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ const MATURITY: u64 = 60;
|
||||||
const RECENT_WINDOW: usize = 15;
|
const RECENT_WINDOW: usize = 15;
|
||||||
const BLOCK_TIME: usize = 120;
|
const BLOCK_TIME: usize = 120;
|
||||||
const BLOCKS_PER_YEAR: usize = 365 * 24 * 60 * 60 / BLOCK_TIME;
|
const BLOCKS_PER_YEAR: usize = 365 * 24 * 60 * 60 / BLOCK_TIME;
|
||||||
|
#[allow(clippy::cast_precision_loss)]
|
||||||
const TIP_APPLICATION: f64 = (LOCK_WINDOW * BLOCK_TIME) as f64;
|
const TIP_APPLICATION: f64 = (LOCK_WINDOW * BLOCK_TIME) as f64;
|
||||||
|
|
||||||
// TODO: Resolve safety of this in case a reorg occurs/the network changes
|
// TODO: Resolve safety of this in case a reorg occurs/the network changes
|
||||||
|
@ -76,6 +77,7 @@ async fn select_n<'a, R: RngCore + CryptoRng, RPC: RpcConnection>(
|
||||||
|
|
||||||
// Use a gamma distribution
|
// Use a gamma distribution
|
||||||
let mut age = Gamma::<f64>::new(19.28, 1.0 / 1.61).unwrap().sample(rng).exp();
|
let mut age = Gamma::<f64>::new(19.28, 1.0 / 1.61).unwrap().sample(rng).exp();
|
||||||
|
#[allow(clippy::cast_precision_loss)]
|
||||||
if age > TIP_APPLICATION {
|
if age > TIP_APPLICATION {
|
||||||
age -= TIP_APPLICATION;
|
age -= TIP_APPLICATION;
|
||||||
} else {
|
} else {
|
||||||
|
@ -83,6 +85,7 @@ async fn select_n<'a, R: RngCore + CryptoRng, RPC: RpcConnection>(
|
||||||
age = (rng.next_u64() % u64::try_from(RECENT_WINDOW * BLOCK_TIME).unwrap()) as f64;
|
age = (rng.next_u64() % u64::try_from(RECENT_WINDOW * BLOCK_TIME).unwrap()) as f64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
|
||||||
let o = (age * per_second) as u64;
|
let o = (age * per_second) as u64;
|
||||||
if o < high {
|
if o < high {
|
||||||
let i = distribution.partition_point(|s| *s < (high - 1 - o));
|
let i = distribution.partition_point(|s| *s < (high - 1 - o));
|
||||||
|
@ -193,6 +196,7 @@ impl Decoys {
|
||||||
distribution.truncate(height + 1); // height is inclusive, and 0 is a valid height
|
distribution.truncate(height + 1); // height is inclusive, and 0 is a valid height
|
||||||
|
|
||||||
let high = distribution[distribution.len() - 1];
|
let high = distribution[distribution.len() - 1];
|
||||||
|
#[allow(clippy::cast_precision_loss)]
|
||||||
let per_second = {
|
let per_second = {
|
||||||
let blocks = distribution.len().min(BLOCKS_PER_YEAR);
|
let blocks = distribution.len().min(BLOCKS_PER_YEAR);
|
||||||
let outputs = high - distribution[distribution.len().saturating_sub(blocks + 1)];
|
let outputs = high - distribution[distribution.len().saturating_sub(blocks + 1)];
|
||||||
|
|
|
@ -80,7 +80,7 @@ pub(crate) fn shared_key(
|
||||||
|
|
||||||
// uniqueness ||
|
// uniqueness ||
|
||||||
let shared_key = if let Some(uniqueness) = uniqueness {
|
let shared_key = if let Some(uniqueness) = uniqueness {
|
||||||
[uniqueness.as_ref(), &output_derivation].concat().to_vec()
|
[uniqueness.as_ref(), &output_derivation].concat()
|
||||||
} else {
|
} else {
|
||||||
output_derivation
|
output_derivation
|
||||||
};
|
};
|
||||||
|
|
|
@ -200,7 +200,7 @@ pub(crate) fn seed_to_bytes(words: &str) -> Result<(Language, Zeroizing<[u8; 32]
|
||||||
let mut matched_indices = Zeroizing::new(vec![]);
|
let mut matched_indices = Zeroizing::new(vec![]);
|
||||||
|
|
||||||
// Iterate through all the languages
|
// Iterate through all the languages
|
||||||
'language: for (lang_name, lang) in LANGUAGES().iter() {
|
'language: for (lang_name, lang) in LANGUAGES() {
|
||||||
matched_indices.zeroize();
|
matched_indices.zeroize();
|
||||||
matched_indices.clear();
|
matched_indices.clear();
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ const CLEAR_BITS: usize = (SECRET_SIZE * BITS_PER_BYTE) - SECRET_BITS; // 2
|
||||||
|
|
||||||
// Polyseed calls this CLEAR_MASK and has a very complicated formula for this fundamental
|
// Polyseed calls this CLEAR_MASK and has a very complicated formula for this fundamental
|
||||||
// equivalency
|
// equivalency
|
||||||
|
#[allow(clippy::cast_possible_truncation)]
|
||||||
const LAST_BYTE_SECRET_BITS_MASK: u8 = ((1 << (BITS_PER_BYTE - CLEAR_BITS)) - 1) as u8;
|
const LAST_BYTE_SECRET_BITS_MASK: u8 = ((1 << (BITS_PER_BYTE - CLEAR_BITS)) - 1) as u8;
|
||||||
|
|
||||||
const SECRET_BITS_PER_WORD: usize = 10;
|
const SECRET_BITS_PER_WORD: usize = 10;
|
||||||
|
@ -265,7 +266,7 @@ impl Polyseed {
|
||||||
// Decode the seed into its polynomial coefficients
|
// Decode the seed into its polynomial coefficients
|
||||||
let mut poly = [0; POLYSEED_LENGTH];
|
let mut poly = [0; POLYSEED_LENGTH];
|
||||||
let lang = (|| {
|
let lang = (|| {
|
||||||
'language: for (name, lang) in LANGUAGES().iter() {
|
'language: for (name, lang) in LANGUAGES() {
|
||||||
for (i, word) in seed.split_whitespace().enumerate() {
|
for (i, word) in seed.split_whitespace().enumerate() {
|
||||||
// Find the word's index
|
// Find the word's index
|
||||||
fn check_if_matches<S: AsRef<str>, I: Iterator<Item = S>>(
|
fn check_if_matches<S: AsRef<str>, I: Iterator<Item = S>>(
|
||||||
|
|
|
@ -226,7 +226,11 @@ impl SignMachine<Transaction> for TransactionSignMachine {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_cache(_: (), _: ThresholdKeys<Ed25519>, _: CachedPreprocess) -> (Self, Self::Preprocess) {
|
fn from_cache(
|
||||||
|
(): (),
|
||||||
|
_: ThresholdKeys<Ed25519>,
|
||||||
|
_: CachedPreprocess,
|
||||||
|
) -> (Self, Self::Preprocess) {
|
||||||
unimplemented!(
|
unimplemented!(
|
||||||
"Monero transactions don't support caching their preprocesses due to {}",
|
"Monero transactions don't support caching their preprocesses due to {}",
|
||||||
"being already bound to a specific transaction"
|
"being already bound to a specific transaction"
|
||||||
|
|
|
@ -46,7 +46,7 @@ test!(
|
||||||
builder.add_payment(addr, 5);
|
builder.add_payment(addr, 5);
|
||||||
(builder.build().unwrap(), ())
|
(builder.build().unwrap(), ())
|
||||||
},
|
},
|
||||||
|_, tx: Transaction, mut scanner: Scanner, _| async move {
|
|_, tx: Transaction, mut scanner: Scanner, ()| async move {
|
||||||
let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0);
|
let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0);
|
||||||
assert_eq!(output.commitment().amount, 5);
|
assert_eq!(output.commitment().amount, 5);
|
||||||
},
|
},
|
||||||
|
@ -61,7 +61,7 @@ test!(
|
||||||
builder.add_payment(addr, 2000000000000);
|
builder.add_payment(addr, 2000000000000);
|
||||||
(builder.build().unwrap(), ())
|
(builder.build().unwrap(), ())
|
||||||
},
|
},
|
||||||
|_, tx: Transaction, mut scanner: Scanner, _| async move {
|
|_, tx: Transaction, mut scanner: Scanner, ()| async move {
|
||||||
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
||||||
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
||||||
assert_eq!(outputs[0].commitment().amount, 1000000000000);
|
assert_eq!(outputs[0].commitment().amount, 1000000000000);
|
||||||
|
@ -75,7 +75,7 @@ test!(
|
||||||
builder.add_payment(addr, 6);
|
builder.add_payment(addr, 6);
|
||||||
(builder.build().unwrap(), ())
|
(builder.build().unwrap(), ())
|
||||||
},
|
},
|
||||||
|_, tx: Transaction, mut scanner: Scanner, _| async move {
|
|_, tx: Transaction, mut scanner: Scanner, ()| async move {
|
||||||
let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0);
|
let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0);
|
||||||
assert_eq!(output.commitment().amount, 6);
|
assert_eq!(output.commitment().amount, 6);
|
||||||
},
|
},
|
||||||
|
@ -92,7 +92,7 @@ test!(
|
||||||
builder.add_payment(addr, 1000000000000);
|
builder.add_payment(addr, 1000000000000);
|
||||||
(builder.build().unwrap(), ())
|
(builder.build().unwrap(), ())
|
||||||
},
|
},
|
||||||
|_, tx: Transaction, mut scanner: Scanner, _| async move {
|
|_, tx: Transaction, mut scanner: Scanner, ()| async move {
|
||||||
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
||||||
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
||||||
assert_eq!(outputs[0].commitment().amount, 1000000000000);
|
assert_eq!(outputs[0].commitment().amount, 1000000000000);
|
||||||
|
@ -157,7 +157,7 @@ test!(
|
||||||
builder.add_payment(addr, 2000000000000);
|
builder.add_payment(addr, 2000000000000);
|
||||||
(builder.build().unwrap(), ())
|
(builder.build().unwrap(), ())
|
||||||
},
|
},
|
||||||
|_, tx: Transaction, mut scanner: Scanner, _| async move {
|
|_, tx: Transaction, mut scanner: Scanner, ()| async move {
|
||||||
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
||||||
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
||||||
assert_eq!(outputs[0].commitment().amount, 2000000000000);
|
assert_eq!(outputs[0].commitment().amount, 2000000000000);
|
||||||
|
@ -170,7 +170,7 @@ test!(
|
||||||
builder.add_payment(addr, 2);
|
builder.add_payment(addr, 2);
|
||||||
(builder.build().unwrap(), ())
|
(builder.build().unwrap(), ())
|
||||||
},
|
},
|
||||||
|_, tx: Transaction, mut scanner: Scanner, _| async move {
|
|_, tx: Transaction, mut scanner: Scanner, ()| async move {
|
||||||
let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0);
|
let output = scanner.scan_transaction(&tx).not_locked().swap_remove(0);
|
||||||
assert_eq!(output.commitment().amount, 2);
|
assert_eq!(output.commitment().amount, 2);
|
||||||
},
|
},
|
||||||
|
@ -184,7 +184,7 @@ test!(
|
||||||
builder.add_payment(addr, 1000000000000);
|
builder.add_payment(addr, 1000000000000);
|
||||||
(builder.build().unwrap(), ())
|
(builder.build().unwrap(), ())
|
||||||
},
|
},
|
||||||
|_, tx: Transaction, mut scanner: Scanner, _| async move {
|
|_, tx: Transaction, mut scanner: Scanner, ()| async move {
|
||||||
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
||||||
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
||||||
assert_eq!(outputs[0].commitment().amount, 1000000000000);
|
assert_eq!(outputs[0].commitment().amount, 1000000000000);
|
||||||
|
@ -200,12 +200,12 @@ test!(
|
||||||
}
|
}
|
||||||
(builder.build().unwrap(), ())
|
(builder.build().unwrap(), ())
|
||||||
},
|
},
|
||||||
|_, tx: Transaction, mut scanner: Scanner, _| async move {
|
|_, tx: Transaction, mut scanner: Scanner, ()| async move {
|
||||||
let mut scanned_tx = scanner.scan_transaction(&tx).not_locked();
|
let mut scanned_tx = scanner.scan_transaction(&tx).not_locked();
|
||||||
|
|
||||||
let mut output_amounts = HashSet::new();
|
let mut output_amounts = HashSet::new();
|
||||||
for i in 0 .. 15 {
|
for i in 0 .. 15 {
|
||||||
output_amounts.insert((i + 1) as u64);
|
output_amounts.insert(i + 1);
|
||||||
}
|
}
|
||||||
for _ in 0 .. 15 {
|
for _ in 0 .. 15 {
|
||||||
let output = scanned_tx.swap_remove(0);
|
let output = scanned_tx.swap_remove(0);
|
||||||
|
@ -224,7 +224,7 @@ test!(
|
||||||
builder.add_payment(addr, 1000000000000);
|
builder.add_payment(addr, 1000000000000);
|
||||||
(builder.build().unwrap(), ())
|
(builder.build().unwrap(), ())
|
||||||
},
|
},
|
||||||
|_, tx: Transaction, mut scanner: Scanner, _| async move {
|
|_, tx: Transaction, mut scanner: Scanner, ()| async move {
|
||||||
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
||||||
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
||||||
assert_eq!(outputs[0].commitment().amount, 1000000000000);
|
assert_eq!(outputs[0].commitment().amount, 1000000000000);
|
||||||
|
@ -245,7 +245,7 @@ test!(
|
||||||
|
|
||||||
builder.add_payment(
|
builder.add_payment(
|
||||||
view.address(Network::Mainnet, AddressSpec::Subaddress(subaddress)),
|
view.address(Network::Mainnet, AddressSpec::Subaddress(subaddress)),
|
||||||
(i + 1) as u64,
|
u64::from(i + 1),
|
||||||
);
|
);
|
||||||
subaddresses.push(subaddress);
|
subaddresses.push(subaddress);
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ test!(
|
||||||
|
|
||||||
let mut output_amounts_by_subaddress = HashMap::new();
|
let mut output_amounts_by_subaddress = HashMap::new();
|
||||||
for i in 0 .. 15 {
|
for i in 0 .. 15 {
|
||||||
output_amounts_by_subaddress.insert((i + 1) as u64, state.1[i]);
|
output_amounts_by_subaddress.insert(u64::try_from(i + 1).unwrap(), state.1[i]);
|
||||||
}
|
}
|
||||||
for _ in 0 .. 15 {
|
for _ in 0 .. 15 {
|
||||||
let output = scanned_tx.swap_remove(0);
|
let output = scanned_tx.swap_remove(0);
|
||||||
|
@ -281,7 +281,7 @@ test!(
|
||||||
builder.add_payment(addr, 1000000000000);
|
builder.add_payment(addr, 1000000000000);
|
||||||
(builder.build().unwrap(), ())
|
(builder.build().unwrap(), ())
|
||||||
},
|
},
|
||||||
|_, tx: Transaction, mut scanner: Scanner, _| async move {
|
|_, tx: Transaction, mut scanner: Scanner, ()| async move {
|
||||||
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
||||||
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
||||||
assert_eq!(outputs[0].commitment().amount, 1000000000000);
|
assert_eq!(outputs[0].commitment().amount, 1000000000000);
|
||||||
|
@ -303,7 +303,7 @@ test!(
|
||||||
|
|
||||||
(builder.build().unwrap(), ())
|
(builder.build().unwrap(), ())
|
||||||
},
|
},
|
||||||
|_, tx: Transaction, mut scanner: Scanner, _| async move {
|
|_, tx: Transaction, mut scanner: Scanner, ()| async move {
|
||||||
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
let mut outputs = scanner.scan_transaction(&tx).not_locked();
|
||||||
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
outputs.sort_by(|x, y| x.commitment().amount.cmp(&y.commitment().amount));
|
||||||
assert_eq!(outputs[0].commitment().amount, 10000);
|
assert_eq!(outputs[0].commitment().amount, 10000);
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.65"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
parity-db = { version = "0.4", default-features = false, optional = true }
|
parity-db = { version = "0.4", default-features = false, optional = true }
|
||||||
rocksdb = { version = "0.21", default-features = false, features = ["lz4"], optional = true }
|
rocksdb = { version = "0.21", default-features = false, features = ["lz4"], optional = true }
|
||||||
|
|
3
common/env/Cargo.toml
vendored
3
common/env/Cargo.toml
vendored
|
@ -12,3 +12,6 @@ rust-version = "1.60"
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.64"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Deprecated here means to enable deprecated warnings, not to restore deprecated APIs
|
# Deprecated here means to enable deprecated warnings, not to restore deprecated APIs
|
||||||
hyper = { version = "0.14", default-features = false, features = ["http1", "tcp", "client", "runtime", "backports", "deprecated"] }
|
hyper = { version = "0.14", default-features = false, features = ["http1", "tcp", "client", "runtime", "backports", "deprecated"] }
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.70"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
spin = { version = "0.9", default-features = false, features = ["use_ticket_mutex", "once"] }
|
spin = { version = "0.9", default-features = false, features = ["use_ticket_mutex", "once"] }
|
||||||
hashbrown = { version = "0.14", default-features = false, features = ["ahash", "inline-more"] }
|
hashbrown = { version = "0.14", default-features = false, features = ["ahash", "inline-more"] }
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.60"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
zeroize = { version = "^1.5", default-features = false }
|
zeroize = { version = "^1.5", default-features = false }
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ publish = false
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = { version = "0.1", default-features = false }
|
async-trait = { version = "0.1", default-features = false }
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ impl<D: Db> CosignEvaluator<D> {
|
||||||
// If we haven't gotten the stake data yet, return
|
// If we haven't gotten the stake data yet, return
|
||||||
let Some(stakes) = stakes_lock.as_ref() else { return };
|
let Some(stakes) = stakes_lock.as_ref() else { return };
|
||||||
|
|
||||||
let total_stake = stakes.values().cloned().sum::<u64>();
|
let total_stake = stakes.values().copied().sum::<u64>();
|
||||||
|
|
||||||
let latest_cosigns = self.latest_cosigns.read().await;
|
let latest_cosigns = self.latest_cosigns.read().await;
|
||||||
let mut highest_block = 0;
|
let mut highest_block = 0;
|
||||||
|
@ -319,7 +319,7 @@ impl<D: Db> CosignEvaluator<D> {
|
||||||
tokio::spawn({
|
tokio::spawn({
|
||||||
async move {
|
async move {
|
||||||
loop {
|
loop {
|
||||||
let cosigns = evaluator.latest_cosigns.read().await.values().cloned().collect::<Vec<_>>();
|
let cosigns = evaluator.latest_cosigns.read().await.values().copied().collect::<Vec<_>>();
|
||||||
for cosign in cosigns {
|
for cosign in cosigns {
|
||||||
let mut buf = vec![];
|
let mut buf = vec![];
|
||||||
cosign.serialize(&mut buf).unwrap();
|
cosign.serialize(&mut buf).unwrap();
|
||||||
|
|
|
@ -410,7 +410,7 @@ impl LibP2p {
|
||||||
// If we are sending heartbeats, we should've sent one after 60s of no finalized blocks
|
// If we are sending heartbeats, we should've sent one after 60s of no finalized blocks
|
||||||
// (where a finalized block only occurs due to network activity), meaning this won't be
|
// (where a finalized block only occurs due to network activity), meaning this won't be
|
||||||
// run
|
// run
|
||||||
_ = tokio::time::sleep(Duration::from_secs(80).saturating_sub(time_since_last)) => {
|
() = tokio::time::sleep(Duration::from_secs(80).saturating_sub(time_since_last)) => {
|
||||||
broadcast_raw(
|
broadcast_raw(
|
||||||
&mut swarm,
|
&mut swarm,
|
||||||
&mut time_of_last_p2p_message,
|
&mut time_of_last_p2p_message,
|
||||||
|
|
|
@ -95,7 +95,7 @@ pub async fn run_tributaries(
|
||||||
mut tributaries: Vec<(LocalP2p, Tributary<MemDb, Transaction, LocalP2p>)>,
|
mut tributaries: Vec<(LocalP2p, Tributary<MemDb, Transaction, LocalP2p>)>,
|
||||||
) {
|
) {
|
||||||
loop {
|
loop {
|
||||||
for (p2p, tributary) in tributaries.iter_mut() {
|
for (p2p, tributary) in &mut tributaries {
|
||||||
while let Poll::Ready(msg) = poll!(p2p.receive()) {
|
while let Poll::Ready(msg) = poll!(p2p.receive()) {
|
||||||
match msg.kind {
|
match msg.kind {
|
||||||
P2pMessageKind::Tributary(genesis) => {
|
P2pMessageKind::Tributary(genesis) => {
|
||||||
|
@ -170,7 +170,7 @@ async fn tributary_test() {
|
||||||
// run_tributaries will run them ad infinitum
|
// run_tributaries will run them ad infinitum
|
||||||
let timeout = SystemTime::now() + Duration::from_secs(65);
|
let timeout = SystemTime::now() + Duration::from_secs(65);
|
||||||
while (blocks < 10) && (SystemTime::now().duration_since(timeout).is_err()) {
|
while (blocks < 10) && (SystemTime::now().duration_since(timeout).is_err()) {
|
||||||
for (p2p, tributary) in tributaries.iter_mut() {
|
for (p2p, tributary) in &mut tributaries {
|
||||||
while let Poll::Ready(msg) = poll!(p2p.receive()) {
|
while let Poll::Ready(msg) = poll!(p2p.receive()) {
|
||||||
match msg.kind {
|
match msg.kind {
|
||||||
P2pMessageKind::Tributary(genesis) => {
|
P2pMessageKind::Tributary(genesis) => {
|
||||||
|
@ -196,7 +196,7 @@ async fn tributary_test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle all existing messages
|
// Handle all existing messages
|
||||||
for (p2p, tributary) in tributaries.iter_mut() {
|
for (p2p, tributary) in &mut tributaries {
|
||||||
while let Poll::Ready(msg) = poll!(p2p.receive()) {
|
while let Poll::Ready(msg) = poll!(p2p.receive()) {
|
||||||
match msg.kind {
|
match msg.kind {
|
||||||
P2pMessageKind::Tributary(genesis) => {
|
P2pMessageKind::Tributary(genesis) => {
|
||||||
|
@ -220,7 +220,7 @@ async fn tributary_test() {
|
||||||
}
|
}
|
||||||
assert!(tips.len() <= 2);
|
assert!(tips.len() <= 2);
|
||||||
if tips.len() == 2 {
|
if tips.len() == 2 {
|
||||||
for tip in tips.iter() {
|
for tip in &tips {
|
||||||
// Find a Tributary where this isn't the tip
|
// Find a Tributary where this isn't the tip
|
||||||
for (_, tributary) in &tributaries {
|
for (_, tributary) in &tributaries {
|
||||||
let Some(after) = tributary.reader().block_after(tip) else { continue };
|
let Some(after) = tributary.reader().block_after(tip) else { continue };
|
||||||
|
|
|
@ -337,7 +337,7 @@ async fn dkg_test() {
|
||||||
for (i, tx) in txs.iter().enumerate() {
|
for (i, tx) in txs.iter().enumerate() {
|
||||||
assert_eq!(tributaries[i].1.add_transaction(tx.clone()).await, Ok(true));
|
assert_eq!(tributaries[i].1.add_transaction(tx.clone()).await, Ok(true));
|
||||||
}
|
}
|
||||||
for tx in txs.iter() {
|
for tx in &txs {
|
||||||
wait_for_tx_inclusion(&tributaries[0].1, block_before_tx, tx.hash()).await;
|
wait_for_tx_inclusion(&tributaries[0].1, block_before_tx, tx.hash()).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,14 +127,12 @@ impl ReattemptDb {
|
||||||
.min(3);
|
.min(3);
|
||||||
let upon_block = current_block_number + reattempt_delay;
|
let upon_block = current_block_number + reattempt_delay;
|
||||||
|
|
||||||
#[allow(clippy::unwrap_or_default)]
|
|
||||||
let mut reattempts = Self::get(txn, genesis, upon_block).unwrap_or(vec![]);
|
let mut reattempts = Self::get(txn, genesis, upon_block).unwrap_or(vec![]);
|
||||||
reattempts.push(topic);
|
reattempts.push(topic);
|
||||||
Self::set(txn, genesis, upon_block, &reattempts);
|
Self::set(txn, genesis, upon_block, &reattempts);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take(txn: &mut impl DbTxn, genesis: [u8; 32], block_number: u32) -> Vec<Topic> {
|
pub fn take(txn: &mut impl DbTxn, genesis: [u8; 32], block_number: u32) -> Vec<Topic> {
|
||||||
#[allow(clippy::unwrap_or_default)]
|
|
||||||
let res = Self::get(txn, genesis, block_number).unwrap_or(vec![]);
|
let res = Self::get(txn, genesis, block_number).unwrap_or(vec![]);
|
||||||
if !res.is_empty() {
|
if !res.is_empty() {
|
||||||
Self::del(txn, genesis, block_number);
|
Self::del(txn, genesis, block_number);
|
||||||
|
|
|
@ -314,7 +314,7 @@ impl<
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let Ok(_) = self.check_sign_data_len(&removed, signed.signer, commitments.len()).await
|
let Ok(()) = self.check_sign_data_len(&removed, signed.signer, commitments.len()).await
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
@ -348,7 +348,7 @@ impl<
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let Ok(_) = self.check_sign_data_len(&removed, signed.signer, shares.len()).await else {
|
let Ok(()) = self.check_sign_data_len(&removed, signed.signer, shares.len()).await else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -626,7 +626,7 @@ impl<
|
||||||
despite us not providing that transaction",
|
despite us not providing that transaction",
|
||||||
);
|
);
|
||||||
|
|
||||||
for id in plan_ids.into_iter() {
|
for id in plan_ids {
|
||||||
AttemptDb::recognize_topic(self.txn, genesis, Topic::Sign(id));
|
AttemptDb::recognize_topic(self.txn, genesis, Topic::Sign(id));
|
||||||
self
|
self
|
||||||
.recognized_id
|
.recognized_id
|
||||||
|
@ -650,7 +650,7 @@ impl<
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let signer = data.signed.signer;
|
let signer = data.signed.signer;
|
||||||
let Ok(_) = self.check_sign_data_len(&removed, signer, data.data.len()).await else {
|
let Ok(()) = self.check_sign_data_len(&removed, signer, data.data.len()).await else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let expected_len = match data.label {
|
let expected_len = match data.label {
|
||||||
|
@ -711,7 +711,7 @@ impl<
|
||||||
.await;
|
.await;
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let Ok(_) = self.check_sign_data_len(&removed, data.signed.signer, data.data.len()).await
|
let Ok(()) = self.check_sign_data_len(&removed, data.signed.signer, data.data.len()).await
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
|
@ -39,7 +39,6 @@ pub fn removed_as_of_dkg_attempt(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn latest_removed(getter: &impl Get, genesis: [u8; 32]) -> Vec<<Ristretto as Ciphersuite>::G> {
|
pub fn latest_removed(getter: &impl Get, genesis: [u8; 32]) -> Vec<<Ristretto as Ciphersuite>::G> {
|
||||||
#[allow(clippy::unwrap_or_default)]
|
|
||||||
FatalSlashes::get(getter, genesis)
|
FatalSlashes::get(getter, genesis)
|
||||||
.unwrap_or(vec![])
|
.unwrap_or(vec![])
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -136,7 +136,7 @@ mod impl_pst_for_serai {
|
||||||
signature: Signature,
|
signature: Signature,
|
||||||
) {
|
) {
|
||||||
let tx = SeraiValidatorSets::set_keys(set.network, removed, key_pair, signature);
|
let tx = SeraiValidatorSets::set_keys(set.network, removed, key_pair, signature);
|
||||||
async fn check(serai: SeraiValidatorSets<'_>, set: ValidatorSet, _: ()) -> bool {
|
async fn check(serai: SeraiValidatorSets<'_>, set: ValidatorSet, (): ()) -> bool {
|
||||||
if matches!(serai.keys(set).await, Ok(Some(_))) {
|
if matches!(serai.keys(set).await, Ok(Some(_))) {
|
||||||
log::info!("another coordinator set key pair for {:?}", set);
|
log::info!("another coordinator set key pair for {:?}", set);
|
||||||
return true;
|
return true;
|
||||||
|
@ -293,7 +293,6 @@ impl<
|
||||||
*/
|
*/
|
||||||
match topic {
|
match topic {
|
||||||
Topic::Dkg => {
|
Topic::Dkg => {
|
||||||
#[allow(clippy::unwrap_or_default)]
|
|
||||||
FatalSlashesAsOfDkgAttempt::set(
|
FatalSlashesAsOfDkgAttempt::set(
|
||||||
self.txn,
|
self.txn,
|
||||||
genesis,
|
genesis,
|
||||||
|
|
|
@ -158,7 +158,7 @@ impl<T: DbTxn, C: Encode> SigningProtocol<'_, T, C> {
|
||||||
) -> Result<(AlgorithmSignatureMachine<Ristretto, Schnorrkel>, [u8; 32]), Participant> {
|
) -> Result<(AlgorithmSignatureMachine<Ristretto, Schnorrkel>, [u8; 32]), Participant> {
|
||||||
let machine = self.preprocess_internal(participants).0;
|
let machine = self.preprocess_internal(participants).0;
|
||||||
|
|
||||||
let mut participants = serialized_preprocesses.keys().cloned().collect::<Vec<_>>();
|
let mut participants = serialized_preprocesses.keys().copied().collect::<Vec<_>>();
|
||||||
participants.sort();
|
participants.sort();
|
||||||
let mut preprocesses = HashMap::new();
|
let mut preprocesses = HashMap::new();
|
||||||
for participant in participants {
|
for participant in participants {
|
||||||
|
@ -231,7 +231,7 @@ fn threshold_i_map_to_keys_and_musig_i_map(
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut sorted = vec![];
|
let mut sorted = vec![];
|
||||||
let mut threshold_is = map.keys().cloned().collect::<Vec<_>>();
|
let mut threshold_is = map.keys().copied().collect::<Vec<_>>();
|
||||||
threshold_is.sort();
|
threshold_is.sort();
|
||||||
for threshold_i in threshold_is {
|
for threshold_i in threshold_is {
|
||||||
sorted.push((key_from_threshold_i(threshold_i), map.remove(&threshold_i).unwrap()));
|
sorted.push((key_from_threshold_i(threshold_i), map.remove(&threshold_i).unwrap()));
|
||||||
|
|
|
@ -7,6 +7,13 @@ repository = "https://github.com/serai-dex/serai/tree/develop/coordinator/tribut
|
||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = { version = "0.1", default-features = false }
|
async-trait = { version = "0.1", default-features = false }
|
||||||
thiserror = { version = "1", default-features = false }
|
thiserror = { version = "1", default-features = false }
|
||||||
|
|
|
@ -207,7 +207,7 @@ impl<T: TransactionTrait> Block<T> {
|
||||||
let mut last_tx_order = Order::Provided;
|
let mut last_tx_order = Order::Provided;
|
||||||
let mut included_in_block = HashSet::new();
|
let mut included_in_block = HashSet::new();
|
||||||
let mut txs = Vec::with_capacity(self.transactions.len());
|
let mut txs = Vec::with_capacity(self.transactions.len());
|
||||||
for tx in self.transactions.iter() {
|
for tx in &self.transactions {
|
||||||
let tx_hash = tx.hash();
|
let tx_hash = tx.hash();
|
||||||
txs.push(tx_hash);
|
txs.push(tx_hash);
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ impl<D: Db, T: TransactionTrait> Blockchain<D, T> {
|
||||||
let mut res = Self {
|
let mut res = Self {
|
||||||
db: Some(db.clone()),
|
db: Some(db.clone()),
|
||||||
genesis,
|
genesis,
|
||||||
participants: participants.iter().cloned().collect(),
|
participants: participants.iter().copied().collect(),
|
||||||
|
|
||||||
block_number: 0,
|
block_number: 0,
|
||||||
tip: genesis,
|
tip: genesis,
|
||||||
|
|
|
@ -38,7 +38,6 @@ impl<D: Db, T: TransactionTrait> Mempool<D, T> {
|
||||||
let tx_hash = tx.hash();
|
let tx_hash = tx.hash();
|
||||||
let transaction_key = self.transaction_key(&tx_hash);
|
let transaction_key = self.transaction_key(&tx_hash);
|
||||||
let current_mempool_key = self.current_mempool_key();
|
let current_mempool_key = self.current_mempool_key();
|
||||||
#[allow(clippy::unwrap_or_default)]
|
|
||||||
let mut current_mempool = self.db.get(¤t_mempool_key).unwrap_or(vec![]);
|
let mut current_mempool = self.db.get(¤t_mempool_key).unwrap_or(vec![]);
|
||||||
|
|
||||||
let mut txn = self.db.txn();
|
let mut txn = self.db.txn();
|
||||||
|
@ -182,14 +181,14 @@ impl<D: Db, T: TransactionTrait> Mempool<D, T> {
|
||||||
signer: &<Ristretto as Ciphersuite>::G,
|
signer: &<Ristretto as Ciphersuite>::G,
|
||||||
order: Vec<u8>,
|
order: Vec<u8>,
|
||||||
) -> Option<u32> {
|
) -> Option<u32> {
|
||||||
self.last_nonce_in_mempool.get(&(*signer, order)).cloned().map(|nonce| nonce + 1)
|
self.last_nonce_in_mempool.get(&(*signer, order)).copied().map(|nonce| nonce + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get transactions to include in a block.
|
/// Get transactions to include in a block.
|
||||||
pub(crate) fn block(&mut self) -> Vec<Transaction<T>> {
|
pub(crate) fn block(&mut self) -> Vec<Transaction<T>> {
|
||||||
let mut unsigned = vec![];
|
let mut unsigned = vec![];
|
||||||
let mut signed = vec![];
|
let mut signed = vec![];
|
||||||
for hash in self.txs.keys().cloned().collect::<Vec<_>>() {
|
for hash in self.txs.keys().copied().collect::<Vec<_>>() {
|
||||||
let tx = &self.txs[&hash];
|
let tx = &self.txs[&hash];
|
||||||
|
|
||||||
match tx.kind() {
|
match tx.kind() {
|
||||||
|
@ -222,7 +221,6 @@ impl<D: Db, T: TransactionTrait> Mempool<D, T> {
|
||||||
pub(crate) fn remove(&mut self, tx: &[u8; 32]) {
|
pub(crate) fn remove(&mut self, tx: &[u8; 32]) {
|
||||||
let transaction_key = self.transaction_key(tx);
|
let transaction_key = self.transaction_key(tx);
|
||||||
let current_mempool_key = self.current_mempool_key();
|
let current_mempool_key = self.current_mempool_key();
|
||||||
#[allow(clippy::unwrap_or_default)]
|
|
||||||
let current_mempool = self.db.get(¤t_mempool_key).unwrap_or(vec![]);
|
let current_mempool = self.db.get(¤t_mempool_key).unwrap_or(vec![]);
|
||||||
|
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
|
|
|
@ -136,7 +136,6 @@ impl<D: Db, T: Transaction> ProvidedTransactions<D, T> {
|
||||||
}
|
}
|
||||||
txn.commit();
|
txn.commit();
|
||||||
} else {
|
} else {
|
||||||
#[allow(clippy::unwrap_or_default)]
|
|
||||||
let mut currently_provided = txn.get(¤t_provided_key).unwrap_or(vec![]);
|
let mut currently_provided = txn.get(¤t_provided_key).unwrap_or(vec![]);
|
||||||
currently_provided.extend(tx_hash);
|
currently_provided.extend(tx_hash);
|
||||||
txn.put(current_provided_key, currently_provided);
|
txn.put(current_provided_key, currently_provided);
|
||||||
|
|
|
@ -7,6 +7,13 @@ repository = "https://github.com/serai-dex/serai/tree/develop/coordinator/tender
|
||||||
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
authors = ["Luke Parker <lukeparker5132@gmail.com>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
async-trait = { version = "0.1", default-features = false }
|
async-trait = { version = "0.1", default-features = false }
|
||||||
thiserror = { version = "1", default-features = false }
|
thiserror = { version = "1", default-features = false }
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub mod ext;
|
||||||
use ext::*;
|
use ext::*;
|
||||||
|
|
||||||
pub fn commit_msg(end_time: u64, id: &[u8]) -> Vec<u8> {
|
pub fn commit_msg(end_time: u64, id: &[u8]) -> Vec<u8> {
|
||||||
[&end_time.to_le_bytes(), id].concat().to_vec()
|
[&end_time.to_le_bytes(), id].concat()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Encode, Decode)]
|
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Encode, Decode)]
|
||||||
|
@ -398,7 +398,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
||||||
},
|
},
|
||||||
|
|
||||||
// Handle our messages
|
// Handle our messages
|
||||||
_ = queue_future => {
|
() = queue_future => {
|
||||||
Some((true, self.queue.pop_front().unwrap(), None))
|
Some((true, self.queue.pop_front().unwrap(), None))
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -752,7 +752,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
||||||
if self.block.round().step == Step::Propose {
|
if self.block.round().step == Step::Propose {
|
||||||
// Delay error handling (triggering a slash) until after we vote.
|
// Delay error handling (triggering a slash) until after we vote.
|
||||||
let (valid, err) = match self.network.validate(block).await {
|
let (valid, err) = match self.network.validate(block).await {
|
||||||
Ok(_) => (true, Ok(None)),
|
Ok(()) => (true, Ok(None)),
|
||||||
Err(BlockError::Temporal) => (false, Ok(None)),
|
Err(BlockError::Temporal) => (false, Ok(None)),
|
||||||
Err(BlockError::Fatal) => (false, {
|
Err(BlockError::Fatal) => (false, {
|
||||||
log::warn!(target: "tendermint", "Validator proposed a fatally invalid block");
|
log::warn!(target: "tendermint", "Validator proposed a fatally invalid block");
|
||||||
|
@ -812,7 +812,7 @@ impl<N: Network + 'static> TendermintMachine<N> {
|
||||||
|
|
||||||
if self.block.log.has_consensus(self.block.round().number, Data::Prevote(Some(block.id()))) {
|
if self.block.log.has_consensus(self.block.round().number, Data::Prevote(Some(block.id()))) {
|
||||||
match self.network.validate(block).await {
|
match self.network.validate(block).await {
|
||||||
Ok(_) => (),
|
Ok(()) => (),
|
||||||
// BlockError::Temporal is due to a temporal error we have, yet a supermajority of the
|
// BlockError::Temporal is due to a temporal error we have, yet a supermajority of the
|
||||||
// network does not, Because we do not believe this block to be fatally invalid, and
|
// network does not, Because we do not believe this block to be fatally invalid, and
|
||||||
// because a supermajority deems it valid, accept it.
|
// because a supermajority deems it valid, accept it.
|
||||||
|
|
|
@ -21,9 +21,7 @@ impl<N: Network> MessageLog<N> {
|
||||||
pub(crate) fn log(&mut self, signed: SignedMessageFor<N>) -> Result<bool, TendermintError<N>> {
|
pub(crate) fn log(&mut self, signed: SignedMessageFor<N>) -> Result<bool, TendermintError<N>> {
|
||||||
let msg = &signed.msg;
|
let msg = &signed.msg;
|
||||||
// Clarity, and safety around default != new edge cases
|
// Clarity, and safety around default != new edge cases
|
||||||
#[allow(clippy::unwrap_or_default)]
|
|
||||||
let round = self.log.entry(msg.round).or_insert_with(HashMap::new);
|
let round = self.log.entry(msg.round).or_insert_with(HashMap::new);
|
||||||
#[allow(clippy::unwrap_or_default)]
|
|
||||||
let msgs = round.entry(msg.sender).or_insert_with(HashMap::new);
|
let msgs = round.entry(msg.sender).or_insert_with(HashMap::new);
|
||||||
|
|
||||||
// Handle message replays without issue. It's only multiple messages which is malicious
|
// Handle message replays without issue. It's only multiple messages which is malicious
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.74"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
std-shims = { path = "../../common/std-shims", version = "^0.1.1", default-features = false, optional = true }
|
std-shims = { path = "../../common/std-shims", version = "^0.1.1", default-features = false, optional = true }
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.65"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustversion = "1"
|
rustversion = "1"
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ fn u8_from_bool(bit_ref: &mut bool) -> u8 {
|
||||||
let bit_ref = black_box(bit_ref);
|
let bit_ref = black_box(bit_ref);
|
||||||
|
|
||||||
let mut bit = black_box(*bit_ref);
|
let mut bit = black_box(*bit_ref);
|
||||||
|
#[allow(clippy::cast_lossless)]
|
||||||
let res = black_box(bit as u8);
|
let res = black_box(bit as u8);
|
||||||
bit.zeroize();
|
bit.zeroize();
|
||||||
debug_assert!((res | 1) == 1);
|
debug_assert!((res | 1) == 1);
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.70"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
thiserror = { version = "1", default-features = false, optional = true }
|
thiserror = { version = "1", default-features = false, optional = true }
|
||||||
|
|
||||||
|
|
|
@ -226,7 +226,7 @@ impl<C: Ciphersuite, E: Encryptable> EncryptedMessage<C, E> {
|
||||||
use ciphersuite::group::ff::PrimeField;
|
use ciphersuite::group::ff::PrimeField;
|
||||||
|
|
||||||
let mut repr = <C::F as PrimeField>::Repr::default();
|
let mut repr = <C::F as PrimeField>::Repr::default();
|
||||||
for b in repr.as_mut().iter_mut() {
|
for b in repr.as_mut() {
|
||||||
*b = 255;
|
*b = 255;
|
||||||
}
|
}
|
||||||
// Tries to guarantee the above assumption.
|
// Tries to guarantee the above assumption.
|
||||||
|
|
|
@ -257,7 +257,7 @@ mod lib {
|
||||||
self.params.zeroize();
|
self.params.zeroize();
|
||||||
self.secret_share.zeroize();
|
self.secret_share.zeroize();
|
||||||
self.group_key.zeroize();
|
self.group_key.zeroize();
|
||||||
for (_, share) in self.verification_shares.iter_mut() {
|
for share in self.verification_shares.values_mut() {
|
||||||
share.zeroize();
|
share.zeroize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,10 +410,10 @@ mod lib {
|
||||||
self.group_key.zeroize();
|
self.group_key.zeroize();
|
||||||
self.included.zeroize();
|
self.included.zeroize();
|
||||||
self.secret_share.zeroize();
|
self.secret_share.zeroize();
|
||||||
for (_, share) in self.original_verification_shares.iter_mut() {
|
for share in self.original_verification_shares.values_mut() {
|
||||||
share.zeroize();
|
share.zeroize();
|
||||||
}
|
}
|
||||||
for (_, share) in self.verification_shares.iter_mut() {
|
for share in self.verification_shares.values_mut() {
|
||||||
share.zeroize();
|
share.zeroize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -484,7 +484,7 @@ mod lib {
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut verification_shares = self.verification_shares();
|
let mut verification_shares = self.verification_shares();
|
||||||
for (i, share) in verification_shares.iter_mut() {
|
for (i, share) in &mut verification_shares {
|
||||||
*share *= lagrange::<C::F>(*i, &included);
|
*share *= lagrange::<C::F>(*i, &included);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@ rust-version = "1.73"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustversion = "1"
|
rustversion = "1"
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut s = [(G0::Scalar::ZERO, G1::Scalar::ZERO); RING_LEN];
|
let mut s = [(G0::Scalar::ZERO, G1::Scalar::ZERO); RING_LEN];
|
||||||
for s in s.iter_mut() {
|
for s in &mut s {
|
||||||
*s = (read_scalar(r)?, read_scalar(r)?);
|
*s = (read_scalar(r)?, read_scalar(r)?);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ impl BitSignature {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) const fn bits(&self) -> usize {
|
pub(crate) const fn bits(&self) -> u8 {
|
||||||
match self {
|
match self {
|
||||||
BitSignature::ClassicLinear => 1,
|
BitSignature::ClassicLinear => 1,
|
||||||
BitSignature::ConciseLinear => 2,
|
BitSignature::ConciseLinear => 2,
|
||||||
|
|
|
@ -42,6 +42,7 @@ fn u8_from_bool(bit_ref: &mut bool) -> u8 {
|
||||||
let bit_ref = black_box(bit_ref);
|
let bit_ref = black_box(bit_ref);
|
||||||
|
|
||||||
let mut bit = black_box(*bit_ref);
|
let mut bit = black_box(*bit_ref);
|
||||||
|
#[allow(clippy::cast_lossless)]
|
||||||
let res = black_box(bit as u8);
|
let res = black_box(bit as u8);
|
||||||
bit.zeroize();
|
bit.zeroize();
|
||||||
debug_assert!((res | 1) == 1);
|
debug_assert!((res | 1) == 1);
|
||||||
|
@ -278,7 +279,7 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
let capacity = usize::try_from(G0::Scalar::CAPACITY.min(G1::Scalar::CAPACITY)).unwrap();
|
let capacity = usize::try_from(G0::Scalar::CAPACITY.min(G1::Scalar::CAPACITY)).unwrap();
|
||||||
let bits_per_group = BitSignature::from(SIGNATURE).bits();
|
let bits_per_group = usize::from(BitSignature::from(SIGNATURE).bits());
|
||||||
|
|
||||||
let mut pow_2 = (generators.0.primary, generators.1.primary);
|
let mut pow_2 = (generators.0.primary, generators.1.primary);
|
||||||
|
|
||||||
|
@ -391,7 +392,7 @@ where
|
||||||
generators: (Generators<G0>, Generators<G1>),
|
generators: (Generators<G0>, Generators<G1>),
|
||||||
) -> Result<(G0, G1), DLEqError> {
|
) -> Result<(G0, G1), DLEqError> {
|
||||||
let capacity = usize::try_from(G0::Scalar::CAPACITY.min(G1::Scalar::CAPACITY)).unwrap();
|
let capacity = usize::try_from(G0::Scalar::CAPACITY.min(G1::Scalar::CAPACITY)).unwrap();
|
||||||
let bits_per_group = BitSignature::from(SIGNATURE).bits();
|
let bits_per_group = usize::from(BitSignature::from(SIGNATURE).bits());
|
||||||
let has_remainder = (capacity % bits_per_group) != 0;
|
let has_remainder = (capacity % bits_per_group) != 0;
|
||||||
|
|
||||||
// These shouldn't be possible, as locally created and deserialized proofs should be properly
|
// These shouldn't be possible, as locally created and deserialized proofs should be properly
|
||||||
|
@ -449,7 +450,7 @@ where
|
||||||
#[cfg(feature = "serialize")]
|
#[cfg(feature = "serialize")]
|
||||||
pub fn read<R: Read>(r: &mut R) -> io::Result<Self> {
|
pub fn read<R: Read>(r: &mut R) -> io::Result<Self> {
|
||||||
let capacity = usize::try_from(G0::Scalar::CAPACITY.min(G1::Scalar::CAPACITY)).unwrap();
|
let capacity = usize::try_from(G0::Scalar::CAPACITY.min(G1::Scalar::CAPACITY)).unwrap();
|
||||||
let bits_per_group = BitSignature::from(SIGNATURE).bits();
|
let bits_per_group = usize::from(BitSignature::from(SIGNATURE).bits());
|
||||||
|
|
||||||
let mut bits = Vec::with_capacity(capacity / bits_per_group);
|
let mut bits = Vec::with_capacity(capacity / bits_per_group);
|
||||||
for _ in 0 .. (capacity / bits_per_group) {
|
for _ in 0 .. (capacity / bits_per_group) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub fn scalar_normalize<F0: PrimeFieldBits + Zeroize, F1: PrimeFieldBits>(
|
||||||
let mut skip = bits.len() - usize::try_from(mutual_capacity).unwrap();
|
let mut skip = bits.len() - usize::try_from(mutual_capacity).unwrap();
|
||||||
// Needed to zero out the bits
|
// Needed to zero out the bits
|
||||||
#[allow(unused_assignments)]
|
#[allow(unused_assignments)]
|
||||||
for mut bit in bits.iter_mut() {
|
for mut bit in &mut bits {
|
||||||
if skip > 0 {
|
if skip > 0 {
|
||||||
bit.deref_mut().zeroize();
|
bit.deref_mut().zeroize();
|
||||||
skip -= 1;
|
skip -= 1;
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.65"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustversion = "1"
|
rustversion = "1"
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ pub(crate) fn u8_from_bool(bit_ref: &mut bool) -> u8 {
|
||||||
let bit_ref = black_box(bit_ref);
|
let bit_ref = black_box(bit_ref);
|
||||||
|
|
||||||
let mut bit = black_box(*bit_ref);
|
let mut bit = black_box(*bit_ref);
|
||||||
|
#[allow(clippy::cast_lossless)]
|
||||||
let res = black_box(bit as u8);
|
let res = black_box(bit as u8);
|
||||||
bit.zeroize();
|
bit.zeroize();
|
||||||
debug_assert!((res | 1) == 1);
|
debug_assert!((res | 1) == 1);
|
||||||
|
|
|
@ -214,7 +214,7 @@ impl Sum<Point> for Point {
|
||||||
|
|
||||||
impl<'a> Sum<&'a Point> for Point {
|
impl<'a> Sum<&'a Point> for Point {
|
||||||
fn sum<I: Iterator<Item = &'a Point>>(iter: I) -> Point {
|
fn sum<I: Iterator<Item = &'a Point>>(iter: I) -> Point {
|
||||||
Point::sum(iter.cloned())
|
Point::sum(iter.copied())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.60"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rand_core = "0.6"
|
rand_core = "0.6"
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.74"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
|
|
||||||
|
|
|
@ -184,7 +184,7 @@ impl<C: Curve, T: Sync + Clone + Debug + Transcript, H: Hram<C>> Algorithm<C> fo
|
||||||
&mut self,
|
&mut self,
|
||||||
_: &ThresholdView<C>,
|
_: &ThresholdView<C>,
|
||||||
_: Participant,
|
_: Participant,
|
||||||
_: (),
|
(): (),
|
||||||
) -> Result<(), FrostError> {
|
) -> Result<(), FrostError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,7 +256,7 @@ impl<C: Curve> BindingFactor<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn calculate_binding_factors<T: Clone + Transcript>(&mut self, transcript: &T) {
|
pub(crate) fn calculate_binding_factors<T: Clone + Transcript>(&mut self, transcript: &T) {
|
||||||
for (l, binding) in self.0.iter_mut() {
|
for (l, binding) in &mut self.0 {
|
||||||
let mut transcript = transcript.clone();
|
let mut transcript = transcript.clone();
|
||||||
transcript.append_message(b"participant", C::F::from(u64::from(u16::from(*l))).to_repr());
|
transcript.append_message(b"participant", C::F::from(u64::from(u16::from(*l))).to_repr());
|
||||||
// It *should* be perfectly fine to reuse a binding factor for multiple nonces
|
// It *should* be perfectly fine to reuse a binding factor for multiple nonces
|
||||||
|
|
|
@ -177,7 +177,7 @@ pub fn sign<R: RngCore + CryptoRng, M: PreprocessMachine>(
|
||||||
machines,
|
machines,
|
||||||
|rng, machines| {
|
|rng, machines| {
|
||||||
// Cache and rebuild half of the machines
|
// Cache and rebuild half of the machines
|
||||||
let included = machines.keys().cloned().collect::<Vec<_>>();
|
let included = machines.keys().copied().collect::<Vec<_>>();
|
||||||
for i in included {
|
for i in included {
|
||||||
if (rng.next_u64() % 2) == 0 {
|
if (rng.next_u64() % 2) == 0 {
|
||||||
let cache = machines.remove(&i).unwrap().cache();
|
let cache = machines.remove(&i).unwrap().cache();
|
||||||
|
|
|
@ -82,7 +82,7 @@ impl<C: Curve> Algorithm<C> for MultiNonce<C> {
|
||||||
&mut self,
|
&mut self,
|
||||||
_: &ThresholdView<C>,
|
_: &ThresholdView<C>,
|
||||||
_: Participant,
|
_: Participant,
|
||||||
_: (),
|
(): (),
|
||||||
) -> Result<(), FrostError> {
|
) -> Result<(), FrostError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.70"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustversion = "1"
|
rustversion = "1"
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ fn u8_from_bool(bit_ref: &mut bool) -> u8 {
|
||||||
let bit_ref = black_box(bit_ref);
|
let bit_ref = black_box(bit_ref);
|
||||||
|
|
||||||
let mut bit = black_box(*bit_ref);
|
let mut bit = black_box(*bit_ref);
|
||||||
|
#[allow(clippy::cast_lossless)]
|
||||||
let res = black_box(bit as u8);
|
let res = black_box(bit as u8);
|
||||||
bit.zeroize();
|
bit.zeroize();
|
||||||
debug_assert!((res | 1) == 1);
|
debug_assert!((res | 1) == 1);
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.74"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
std-shims = { path = "../../common/std-shims", version = "^0.1.1", default-features = false }
|
std-shims = { path = "../../common/std-shims", version = "^0.1.1", default-features = false }
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.74"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rand_core = "0.6"
|
rand_core = "0.6"
|
||||||
zeroize = "^1.5"
|
zeroize = "^1.5"
|
||||||
|
|
|
@ -99,7 +99,7 @@ impl Algorithm<Ristretto> for Schnorrkel {
|
||||||
&mut self,
|
&mut self,
|
||||||
_: &ThresholdView<Ristretto>,
|
_: &ThresholdView<Ristretto>,
|
||||||
_: Participant,
|
_: Participant,
|
||||||
_: (),
|
(): (),
|
||||||
) -> Result<(), FrostError> {
|
) -> Result<(), FrostError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.73"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustversion = "1"
|
rustversion = "1"
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,9 @@ publish = false
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Macros
|
# Macros
|
||||||
once_cell = { version = "1", default-features = false }
|
once_cell = { version = "1", default-features = false }
|
||||||
|
|
|
@ -67,10 +67,10 @@ impl MessageQueue {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
async fn send(socket: &mut TcpStream, msg: MessageQueueRequest) -> bool {
|
async fn send(socket: &mut TcpStream, msg: MessageQueueRequest) -> bool {
|
||||||
let msg = borsh::to_vec(&msg).unwrap();
|
let msg = borsh::to_vec(&msg).unwrap();
|
||||||
let Ok(_) = socket.write_all(&u32::try_from(msg.len()).unwrap().to_le_bytes()).await else {
|
let Ok(()) = socket.write_all(&u32::try_from(msg.len()).unwrap().to_le_bytes()).await else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
let Ok(_) = socket.write_all(&msg).await else { return false };
|
let Ok(()) = socket.write_all(&msg).await else { return false };
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,18 +250,18 @@ async fn main() {
|
||||||
msg,
|
msg,
|
||||||
SchnorrSignature::<Ristretto>::read(&mut sig.as_slice()).unwrap(),
|
SchnorrSignature::<Ristretto>::read(&mut sig.as_slice()).unwrap(),
|
||||||
);
|
);
|
||||||
let Ok(_) = socket.write_all(&[1]).await else { break };
|
let Ok(()) = socket.write_all(&[1]).await else { break };
|
||||||
}
|
}
|
||||||
MessageQueueRequest::Next { from, to } => match get_next_message(from, to) {
|
MessageQueueRequest::Next { from, to } => match get_next_message(from, to) {
|
||||||
Some(msg) => {
|
Some(msg) => {
|
||||||
let Ok(_) = socket.write_all(&[1]).await else { break };
|
let Ok(()) = socket.write_all(&[1]).await else { break };
|
||||||
let msg = borsh::to_vec(&msg).unwrap();
|
let msg = borsh::to_vec(&msg).unwrap();
|
||||||
let len = u32::try_from(msg.len()).unwrap();
|
let len = u32::try_from(msg.len()).unwrap();
|
||||||
let Ok(_) = socket.write_all(&len.to_le_bytes()).await else { break };
|
let Ok(()) = socket.write_all(&len.to_le_bytes()).await else { break };
|
||||||
let Ok(_) = socket.write_all(&msg).await else { break };
|
let Ok(()) = socket.write_all(&msg).await else { break };
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let Ok(_) = socket.write_all(&[0]).await else { break };
|
let Ok(()) = socket.write_all(&[0]).await else { break };
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
MessageQueueRequest::Ack { from, to, id, sig } => {
|
MessageQueueRequest::Ack { from, to, id, sig } => {
|
||||||
|
@ -271,7 +271,7 @@ async fn main() {
|
||||||
id,
|
id,
|
||||||
SchnorrSignature::<Ristretto>::read(&mut sig.as_slice()).unwrap(),
|
SchnorrSignature::<Ristretto>::read(&mut sig.as_slice()).unwrap(),
|
||||||
);
|
);
|
||||||
let Ok(_) = socket.write_all(&[1]).await else { break };
|
let Ok(()) = socket.write_all(&[1]).await else { break };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,5 +13,8 @@ publish = false
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
loom = "0.7"
|
loom = "0.7"
|
||||||
|
|
|
@ -13,6 +13,9 @@ publish = false
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# Macros
|
# Macros
|
||||||
async-trait = { version = "0.1", default-features = false }
|
async-trait = { version = "0.1", default-features = false }
|
||||||
|
|
|
@ -13,6 +13,9 @@ publish = false
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["std"] }
|
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["std"] }
|
||||||
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
||||||
|
|
|
@ -234,7 +234,7 @@ impl<D: Db> BatchSigner<D> {
|
||||||
|
|
||||||
let mut parsed = HashMap::new();
|
let mut parsed = HashMap::new();
|
||||||
for l in {
|
for l in {
|
||||||
let mut keys = preprocesses.keys().cloned().collect::<Vec<_>>();
|
let mut keys = preprocesses.keys().copied().collect::<Vec<_>>();
|
||||||
keys.sort();
|
keys.sort();
|
||||||
keys
|
keys
|
||||||
} {
|
} {
|
||||||
|
@ -329,7 +329,7 @@ impl<D: Db> BatchSigner<D> {
|
||||||
|
|
||||||
let mut parsed = HashMap::new();
|
let mut parsed = HashMap::new();
|
||||||
for l in {
|
for l in {
|
||||||
let mut keys = shares.keys().cloned().collect::<Vec<_>>();
|
let mut keys = shares.keys().copied().collect::<Vec<_>>();
|
||||||
keys.sort();
|
keys.sort();
|
||||||
keys
|
keys
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -150,7 +150,7 @@ impl Cosigner {
|
||||||
|
|
||||||
let mut parsed = HashMap::new();
|
let mut parsed = HashMap::new();
|
||||||
for l in {
|
for l in {
|
||||||
let mut keys = preprocesses.keys().cloned().collect::<Vec<_>>();
|
let mut keys = preprocesses.keys().copied().collect::<Vec<_>>();
|
||||||
keys.sort();
|
keys.sort();
|
||||||
keys
|
keys
|
||||||
} {
|
} {
|
||||||
|
@ -241,7 +241,7 @@ impl Cosigner {
|
||||||
|
|
||||||
let mut parsed = HashMap::new();
|
let mut parsed = HashMap::new();
|
||||||
for l in {
|
for l in {
|
||||||
let mut keys = shares.keys().cloned().collect::<Vec<_>>();
|
let mut keys = shares.keys().copied().collect::<Vec<_>>();
|
||||||
keys.sort();
|
keys.sort();
|
||||||
keys
|
keys
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -305,7 +305,7 @@ impl<N: Network, D: Db> KeyGen<N, D> {
|
||||||
|
|
||||||
let mut these_shares: HashMap<_, _> =
|
let mut these_shares: HashMap<_, _> =
|
||||||
substrate_shares.drain().map(|(i, share)| (i, share.serialize())).collect();
|
substrate_shares.drain().map(|(i, share)| (i, share.serialize())).collect();
|
||||||
for (i, share) in these_shares.iter_mut() {
|
for (i, share) in &mut these_shares {
|
||||||
share.extend(network_shares[i].serialize());
|
share.extend(network_shares[i].serialize());
|
||||||
}
|
}
|
||||||
shares.push(these_shares);
|
shares.push(these_shares);
|
||||||
|
|
|
@ -113,7 +113,7 @@ impl ResolvedDb {
|
||||||
let end = i + 32;
|
let end = i + 32;
|
||||||
if signing[start .. end] == plan {
|
if signing[start .. end] == plan {
|
||||||
found = true;
|
found = true;
|
||||||
signing = [&signing[.. start], &signing[end ..]].concat().to_vec();
|
signing = [&signing[.. start], &signing[end ..]].concat();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,12 +198,12 @@ impl<D: Db, N: Network> MultisigManager<D, N> {
|
||||||
(
|
(
|
||||||
MultisigManager {
|
MultisigManager {
|
||||||
scanner,
|
scanner,
|
||||||
existing: current_keys.first().cloned().map(|(activation_block, key)| MultisigViewer {
|
existing: current_keys.first().copied().map(|(activation_block, key)| MultisigViewer {
|
||||||
activation_block,
|
activation_block,
|
||||||
key,
|
key,
|
||||||
scheduler: schedulers.remove(0),
|
scheduler: schedulers.remove(0),
|
||||||
}),
|
}),
|
||||||
new: current_keys.get(1).cloned().map(|(activation_block, key)| MultisigViewer {
|
new: current_keys.get(1).copied().map(|(activation_block, key)| MultisigViewer {
|
||||||
activation_block,
|
activation_block,
|
||||||
key,
|
key,
|
||||||
scheduler: schedulers.remove(0),
|
scheduler: schedulers.remove(0),
|
||||||
|
|
|
@ -484,7 +484,7 @@ impl<N: Network, D: Db> Scanner<N, D> {
|
||||||
let needing_ack = {
|
let needing_ack = {
|
||||||
let scanner_lock = scanner_hold.read().await;
|
let scanner_lock = scanner_hold.read().await;
|
||||||
let scanner = scanner_lock.as_ref().unwrap();
|
let scanner = scanner_lock.as_ref().unwrap();
|
||||||
scanner.need_ack.front().cloned()
|
scanner.need_ack.front().copied()
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(needing_ack) = needing_ack {
|
if let Some(needing_ack) = needing_ack {
|
||||||
|
|
|
@ -197,7 +197,6 @@ impl<N: Network> Scheduler<N> {
|
||||||
|
|
||||||
let mut add_plan = |payments| {
|
let mut add_plan = |payments| {
|
||||||
let amount = payment_amounts(&payments);
|
let amount = payment_amounts(&payments);
|
||||||
#[allow(clippy::unwrap_or_default)]
|
|
||||||
self.queued_plans.entry(amount).or_insert(VecDeque::new()).push_back(payments);
|
self.queued_plans.entry(amount).or_insert(VecDeque::new()).push_back(payments);
|
||||||
amount
|
amount
|
||||||
};
|
};
|
||||||
|
@ -474,7 +473,7 @@ impl<N: Network> Scheduler<N> {
|
||||||
let per_payment = to_amortize / payments_len;
|
let per_payment = to_amortize / payments_len;
|
||||||
let mut overage = to_amortize % payments_len;
|
let mut overage = to_amortize % payments_len;
|
||||||
|
|
||||||
for payment in payments.iter_mut() {
|
for payment in &mut payments {
|
||||||
let to_subtract = per_payment + overage;
|
let to_subtract = per_payment + overage;
|
||||||
// Only subtract the overage once
|
// Only subtract the overage once
|
||||||
overage = 0;
|
overage = 0;
|
||||||
|
@ -499,7 +498,6 @@ impl<N: Network> Scheduler<N> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::unwrap_or_default)]
|
|
||||||
self.plans.entry(actual).or_insert(VecDeque::new()).push_back(payments);
|
self.plans.entry(actual).or_insert(VecDeque::new()).push_back(payments);
|
||||||
|
|
||||||
// TODO2: This shows how ridiculous the serialize function is
|
// TODO2: This shows how ridiculous the serialize function is
|
||||||
|
|
|
@ -383,7 +383,7 @@ impl Bitcoin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fees.sort();
|
fees.sort();
|
||||||
let fee = fees.get(fees.len() / 2).cloned().unwrap_or(0);
|
let fee = fees.get(fees.len() / 2).copied().unwrap_or(0);
|
||||||
|
|
||||||
// The DUST constant documentation notes a relay rule practically enforcing a
|
// The DUST constant documentation notes a relay rule practically enforcing a
|
||||||
// 1000 sat/kilo-vbyte minimum fee.
|
// 1000 sat/kilo-vbyte minimum fee.
|
||||||
|
|
|
@ -285,7 +285,7 @@ impl Monero {
|
||||||
fees.push(tx.rct_signatures.base.fee / u64::try_from(tx.serialize().len()).unwrap());
|
fees.push(tx.rct_signatures.base.fee / u64::try_from(tx.serialize().len()).unwrap());
|
||||||
}
|
}
|
||||||
fees.sort();
|
fees.sort();
|
||||||
let fee = fees.get(fees.len() / 2).cloned().unwrap_or(0);
|
let fee = fees.get(fees.len() / 2).copied().unwrap_or(0);
|
||||||
|
|
||||||
// TODO: Set a sane minimum fee
|
// TODO: Set a sane minimum fee
|
||||||
Ok(Fee { per_weight: fee.max(1500000), mask: 10000 })
|
Ok(Fee { per_weight: fee.max(1500000), mask: 10000 })
|
||||||
|
@ -665,7 +665,7 @@ impl Network for Monero {
|
||||||
|
|
||||||
async fn publish_transaction(&self, tx: &Self::Transaction) -> Result<(), NetworkError> {
|
async fn publish_transaction(&self, tx: &Self::Transaction) -> Result<(), NetworkError> {
|
||||||
match self.rpc.publish_transaction(tx).await {
|
match self.rpc.publish_transaction(tx).await {
|
||||||
Ok(_) => Ok(()),
|
Ok(()) => Ok(()),
|
||||||
Err(RpcError::ConnectionError(e)) => {
|
Err(RpcError::ConnectionError(e)) => {
|
||||||
log::debug!("Monero ConnectionError: {e}");
|
log::debug!("Monero ConnectionError: {e}");
|
||||||
Err(NetworkError::ConnectionError)?
|
Err(NetworkError::ConnectionError)?
|
||||||
|
|
|
@ -469,7 +469,7 @@ impl<N: Network, D: Db> Signer<N, D> {
|
||||||
|
|
||||||
let mut parsed = HashMap::new();
|
let mut parsed = HashMap::new();
|
||||||
for l in {
|
for l in {
|
||||||
let mut keys = preprocesses.keys().cloned().collect::<Vec<_>>();
|
let mut keys = preprocesses.keys().copied().collect::<Vec<_>>();
|
||||||
keys.sort();
|
keys.sort();
|
||||||
keys
|
keys
|
||||||
} {
|
} {
|
||||||
|
@ -549,7 +549,7 @@ impl<N: Network, D: Db> Signer<N, D> {
|
||||||
|
|
||||||
let mut parsed = HashMap::new();
|
let mut parsed = HashMap::new();
|
||||||
for l in {
|
for l in {
|
||||||
let mut keys = shares.keys().cloned().collect::<Vec<_>>();
|
let mut keys = shares.keys().copied().collect::<Vec<_>>();
|
||||||
keys.sort();
|
keys.sort();
|
||||||
keys
|
keys
|
||||||
} {
|
} {
|
||||||
|
|
|
@ -78,7 +78,7 @@ async fn spend<N: Network, D: Db>(
|
||||||
|
|
||||||
pub async fn test_addresses<N: Network>(network: N) {
|
pub async fn test_addresses<N: Network>(network: N) {
|
||||||
let mut keys = frost::tests::key_gen::<_, N::Curve>(&mut OsRng);
|
let mut keys = frost::tests::key_gen::<_, N::Curve>(&mut OsRng);
|
||||||
for (_, keys) in keys.iter_mut() {
|
for keys in keys.values_mut() {
|
||||||
N::tweak_keys(keys);
|
N::tweak_keys(keys);
|
||||||
}
|
}
|
||||||
let key = keys[&Participant::new(1).unwrap()].group_key();
|
let key = keys[&Participant::new(1).unwrap()].group_key();
|
||||||
|
|
|
@ -109,7 +109,7 @@ pub async fn test_no_deadlock_in_multisig_completed<N: Network>(network: N) {
|
||||||
network.get_latest_block_number().await.unwrap() + N::CONFIRMATIONS + i,
|
network.get_latest_block_number().await.unwrap() + N::CONFIRMATIONS + i,
|
||||||
{
|
{
|
||||||
let mut keys = key_gen(&mut OsRng);
|
let mut keys = key_gen(&mut OsRng);
|
||||||
for (_, keys) in keys.iter_mut() {
|
for keys in keys.values_mut() {
|
||||||
N::tweak_keys(keys);
|
N::tweak_keys(keys);
|
||||||
}
|
}
|
||||||
keys[&Participant::new(1).unwrap()].group_key()
|
keys[&Participant::new(1).unwrap()].group_key()
|
||||||
|
|
|
@ -147,7 +147,7 @@ pub async fn sign<N: Network>(
|
||||||
|
|
||||||
pub async fn test_signer<N: Network>(network: N) {
|
pub async fn test_signer<N: Network>(network: N) {
|
||||||
let mut keys = key_gen(&mut OsRng);
|
let mut keys = key_gen(&mut OsRng);
|
||||||
for (_, keys) in keys.iter_mut() {
|
for keys in keys.values_mut() {
|
||||||
N::tweak_keys(keys);
|
N::tweak_keys(keys);
|
||||||
}
|
}
|
||||||
let key = keys[&Participant::new(1).unwrap()].group_key();
|
let key = keys[&Participant::new(1).unwrap()].group_key();
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub async fn test_wallet<N: Network>(network: N) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut keys = key_gen(&mut OsRng);
|
let mut keys = key_gen(&mut OsRng);
|
||||||
for (_, keys) in keys.iter_mut() {
|
for keys in keys.values_mut() {
|
||||||
N::tweak_keys(keys);
|
N::tweak_keys(keys);
|
||||||
}
|
}
|
||||||
let key = keys[&Participant::new(1).unwrap()].group_key();
|
let key = keys[&Participant::new(1).unwrap()].group_key();
|
||||||
|
|
|
@ -12,6 +12,9 @@ rust-version = "1.69"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
scale = { package = "parity-scale-codec", version = "3", features = ["derive"] }
|
scale = { package = "parity-scale-codec", version = "3", features = ["derive"] }
|
||||||
scale-info = { version = "2", features = ["derive"] }
|
scale-info = { version = "2", features = ["derive"] }
|
||||||
|
|
|
@ -13,6 +13,9 @@ rust-version = "1.74"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
zeroize = "^1.5"
|
zeroize = "^1.5"
|
||||||
thiserror = { version = "1", optional = true }
|
thiserror = { version = "1", optional = true }
|
||||||
|
|
|
@ -317,7 +317,6 @@ impl<'a> TemporalSerai<'a> {
|
||||||
if events.is_none() {
|
if events.is_none() {
|
||||||
drop(events);
|
drop(events);
|
||||||
let mut events_write = self.events.write().await;
|
let mut events_write = self.events.write().await;
|
||||||
#[allow(clippy::unwrap_or_default)]
|
|
||||||
if events_write.is_none() {
|
if events_write.is_none() {
|
||||||
*events_write = Some(self.storage("System", "Events", ()).await?.unwrap_or(vec![]));
|
*events_write = Some(self.storage("System", "Events", ()).await?.unwrap_or(vec![]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,9 @@ rustdoc-args = ["--cfg", "docsrs"]
|
||||||
[package.metadata.cargo-machete]
|
[package.metadata.cargo-machete]
|
||||||
ignored = ["scale", "scale-info"]
|
ignored = ["scale", "scale-info"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
|
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] }
|
||||||
scale-info = { version = "2", default-features = false, features = ["derive"] }
|
scale-info = { version = "2", default-features = false, features = ["derive"] }
|
||||||
|
|
|
@ -12,6 +12,7 @@ impl AllowMint for () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::cast_possible_truncation)] // TODO: Investigate why Substrate generates this
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -11,6 +11,9 @@ rust-version = "1.69"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
zeroize = { version = "^1.5", features = ["derive"], optional = true }
|
zeroize = { version = "^1.5", features = ["derive"], optional = true }
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@ rustdoc-args = ["--cfg", "docsrs"]
|
||||||
[package.metadata.cargo-machete]
|
[package.metadata.cargo-machete]
|
||||||
ignored = ["scale", "scale-info"]
|
ignored = ["scale", "scale-info"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
scale = { package = "parity-scale-codec", version = "3.6.1", default-features = false }
|
scale = { package = "parity-scale-codec", version = "3.6.1", default-features = false }
|
||||||
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
|
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
|
||||||
|
|
|
@ -94,6 +94,7 @@ use sp_std::prelude::*;
|
||||||
pub use types::*;
|
pub use types::*;
|
||||||
pub use weights::WeightInfo;
|
pub use weights::WeightInfo;
|
||||||
|
|
||||||
|
#[allow(clippy::cast_possible_truncation)] // TODO: Investigate why Substrate generates this
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -751,7 +752,7 @@ pub mod pallet {
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
let path_len = path.len() as u32;
|
let path_len = u32::try_from(path.len()).unwrap();
|
||||||
#[allow(clippy::explicit_counter_loop)]
|
#[allow(clippy::explicit_counter_loop)]
|
||||||
for coins_pair in path.windows(2) {
|
for coins_pair in path.windows(2) {
|
||||||
if let [coin1, coin2] = coins_pair {
|
if let [coin1, coin2] = coins_pair {
|
||||||
|
|
|
@ -15,6 +15,9 @@ rustdoc-args = ["--cfg", "docsrs"]
|
||||||
[package.metadata.cargo-machete]
|
[package.metadata.cargo-machete]
|
||||||
ignored = ["scale", "scale-info"]
|
ignored = ["scale", "scale-info"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "max-encoded-len"] }
|
scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive", "max-encoded-len"] }
|
||||||
scale-info = { version = "2", default-features = false, features = ["derive"] }
|
scale-info = { version = "2", default-features = false, features = ["derive"] }
|
||||||
|
|
|
@ -9,6 +9,7 @@ use serai_primitives::{BlockHash, NetworkId};
|
||||||
pub use in_instructions_primitives as primitives;
|
pub use in_instructions_primitives as primitives;
|
||||||
use primitives::*;
|
use primitives::*;
|
||||||
|
|
||||||
|
#[allow(clippy::cast_possible_truncation)] // TODO: Investigate why Substrate generates this
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use sp_std::vec;
|
use sp_std::vec;
|
||||||
|
|
|
@ -11,6 +11,9 @@ rust-version = "1.69"
|
||||||
all-features = true
|
all-features = true
|
||||||
rustdoc-args = ["--cfg", "docsrs"]
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
zeroize = { version = "^1.5", features = ["derive"], optional = true }
|
zeroize = { version = "^1.5", features = ["derive"], optional = true }
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,13 @@ edition = "2021"
|
||||||
publish = false
|
publish = false
|
||||||
rust-version = "1.74"
|
rust-version = "1.74"
|
||||||
|
|
||||||
|
[package.metadata.docs.rs]
|
||||||
|
all-features = true
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "serai-node"
|
name = "serai-node"
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue