mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
2
.github/nightly-version
vendored
2
.github/nightly-version
vendored
@@ -1 +1 @@
|
|||||||
nightly-2024-07-01
|
nightly-2025-01-01
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use crate::{Client, Error};
|
|||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Response<'a>(pub(crate) hyper::Response<Incoming>, pub(crate) &'a Client);
|
pub struct Response<'a>(pub(crate) hyper::Response<Incoming>, pub(crate) &'a Client);
|
||||||
impl<'a> Response<'a> {
|
impl Response<'_> {
|
||||||
pub fn status(&self) -> StatusCode {
|
pub fn status(&self) -> StatusCode {
|
||||||
self.0.status()
|
self.0.status()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ struct ScanBlock<'a, TD: Db, TDT: DbTxn, P: P2p> {
|
|||||||
total_weight: u16,
|
total_weight: u16,
|
||||||
validator_weights: &'a HashMap<SeraiAddress, u16>,
|
validator_weights: &'a HashMap<SeraiAddress, u16>,
|
||||||
}
|
}
|
||||||
impl<'a, TD: Db, TDT: DbTxn, P: P2p> ScanBlock<'a, TD, TDT, P> {
|
impl<TD: Db, TDT: DbTxn, P: P2p> ScanBlock<'_, TD, TDT, P> {
|
||||||
fn potentially_start_cosign(&mut self) {
|
fn potentially_start_cosign(&mut self) {
|
||||||
// Don't start a new cosigning instance if we're actively running one
|
// Don't start a new cosigning instance if we're actively running one
|
||||||
if TributaryDb::actively_cosigning(self.tributary_txn, self.set.set).is_some() {
|
if TributaryDb::actively_cosigning(self.tributary_txn, self.set.set).is_some() {
|
||||||
@@ -173,7 +173,7 @@ impl<'a, TD: Db, TDT: DbTxn, P: P2p> ScanBlock<'a, TD, TDT, P> {
|
|||||||
self.set.set,
|
self.set.set,
|
||||||
messages::coordinator::CoordinatorMessage::CosignSubstrateBlock {
|
messages::coordinator::CoordinatorMessage::CosignSubstrateBlock {
|
||||||
session: self.set.set.session,
|
session: self.set.set.session,
|
||||||
intent,
|
cosign: intent.into_cosign(self.set.set.network),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ impl Neg for FieldElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Neg for &'a FieldElement {
|
impl Neg for &FieldElement {
|
||||||
type Output = FieldElement;
|
type Output = FieldElement;
|
||||||
fn neg(self) -> Self::Output {
|
fn neg(self) -> Self::Output {
|
||||||
(*self).neg()
|
(*self).neg()
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ pub(crate) fn challenge<T: Transcript, F: PrimeField>(transcript: &mut T) -> F {
|
|||||||
// Get a wide amount of bytes to safely reduce without bias
|
// Get a wide amount of bytes to safely reduce without bias
|
||||||
// In most cases, <=1.5x bytes is enough. 2x is still standard and there's some theoretical
|
// In most cases, <=1.5x bytes is enough. 2x is still standard and there's some theoretical
|
||||||
// groups which may technically require more than 1.5x bytes for this to work as intended
|
// groups which may technically require more than 1.5x bytes for this to work as intended
|
||||||
let target_bytes = ((usize::try_from(F::NUM_BITS).unwrap() + 7) / 8) * 2;
|
let target_bytes = usize::try_from(F::NUM_BITS).unwrap().div_ceil(8) * 2;
|
||||||
let mut challenge_bytes = transcript.challenge(b"challenge");
|
let mut challenge_bytes = transcript.challenge(b"challenge");
|
||||||
let challenge_bytes_len = challenge_bytes.as_ref().len();
|
let challenge_bytes_len = challenge_bytes.as_ref().len();
|
||||||
// If the challenge is 32 bytes, and we need 64, we need two challenges
|
// If the challenge is 32 bytes, and we need 64, we need two challenges
|
||||||
let needed_challenges = (target_bytes + (challenge_bytes_len - 1)) / challenge_bytes_len;
|
let needed_challenges = target_bytes.div_ceil(challenge_bytes_len);
|
||||||
|
|
||||||
// The following algorithm should be equivalent to a wide reduction of the challenges,
|
// The following algorithm should be equivalent to a wide reduction of the challenges,
|
||||||
// interpreted as concatenated, big-endian byte string
|
// interpreted as concatenated, big-endian byte string
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ pub struct ArithmeticCircuitStatement<'a, C: Ciphersuite> {
|
|||||||
V: PointVector<C>,
|
V: PointVector<C>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, C: Ciphersuite> Zeroize for ArithmeticCircuitStatement<'a, C> {
|
impl<C: Ciphersuite> Zeroize for ArithmeticCircuitStatement<'_, C> {
|
||||||
fn zeroize(&mut self) {
|
fn zeroize(&mut self) {
|
||||||
self.constraints.zeroize();
|
self.constraints.zeroize();
|
||||||
self.C.zeroize();
|
self.C.zeroize();
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ impl<C: Ciphersuite> Generators<C> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, C: Ciphersuite> ProofGenerators<'a, C> {
|
impl<C: Ciphersuite> ProofGenerators<'_, C> {
|
||||||
pub(crate) fn len(&self) -> usize {
|
pub(crate) fn len(&self) -> usize {
|
||||||
self.g_bold.len()
|
self.g_bold.len()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,14 +203,15 @@ pub trait SignMachine<S>: Send + Sync + Sized {
|
|||||||
/// SignatureMachine this SignMachine turns into.
|
/// SignatureMachine this SignMachine turns into.
|
||||||
type SignatureMachine: SignatureMachine<S, SignatureShare = Self::SignatureShare>;
|
type SignatureMachine: SignatureMachine<S, SignatureShare = Self::SignatureShare>;
|
||||||
|
|
||||||
/// Cache this preprocess for usage later. This cached preprocess MUST only be used once. Reuse
|
/// Cache this preprocess for usage later.
|
||||||
/// of it enables recovery of your private key share. Third-party recovery of a cached preprocess
|
///
|
||||||
/// also enables recovery of your private key share, so this MUST be treated with the same
|
/// This cached preprocess MUST only be used once. Reuse of it enables recovery of your private
|
||||||
/// security as your private key share.
|
/// key share. Third-party recovery of a cached preprocess also enables recovery of your private
|
||||||
|
/// key share, so this MUST be treated with the same security as your private key share.
|
||||||
fn cache(self) -> CachedPreprocess;
|
fn cache(self) -> CachedPreprocess;
|
||||||
|
|
||||||
/// Create a sign machine from a cached preprocess.
|
/// Create a sign machine from a cached preprocess.
|
||||||
|
///
|
||||||
/// After this, the preprocess must be deleted so it's never reused. Any reuse will presumably
|
/// After this, the preprocess must be deleted so it's never reused. Any reuse will presumably
|
||||||
/// cause the signer to leak their secret share.
|
/// cause the signer to leak their secret share.
|
||||||
fn from_cache(
|
fn from_cache(
|
||||||
@@ -219,11 +220,14 @@ pub trait SignMachine<S>: Send + Sync + Sized {
|
|||||||
cache: CachedPreprocess,
|
cache: CachedPreprocess,
|
||||||
) -> (Self, Self::Preprocess);
|
) -> (Self, Self::Preprocess);
|
||||||
|
|
||||||
/// Read a Preprocess message. Despite taking self, this does not save the preprocess.
|
/// Read a Preprocess message.
|
||||||
/// It must be externally cached and passed into sign.
|
///
|
||||||
|
/// Despite taking self, this does not save the preprocess. It must be externally cached and
|
||||||
|
/// passed into sign.
|
||||||
fn read_preprocess<R: Read>(&self, reader: &mut R) -> io::Result<Self::Preprocess>;
|
fn read_preprocess<R: Read>(&self, reader: &mut R) -> io::Result<Self::Preprocess>;
|
||||||
|
|
||||||
/// Sign a message.
|
/// Sign a message.
|
||||||
|
///
|
||||||
/// Takes in the participants' preprocess messages. Returns the signature share to be broadcast
|
/// Takes in the participants' preprocess messages. Returns the signature share to be broadcast
|
||||||
/// to all participants, over an authenticated channel. The parties who participate here will
|
/// to all participants, over an authenticated channel. The parties who participate here will
|
||||||
/// become the signing set for this session.
|
/// become the signing set for this session.
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ pub(crate) fn prep_bits<G: Group<Scalar: PrimeFieldBits>>(
|
|||||||
for pair in pairs {
|
for pair in pairs {
|
||||||
let p = groupings.len();
|
let p = groupings.len();
|
||||||
let mut bits = pair.0.to_le_bits();
|
let mut bits = pair.0.to_le_bits();
|
||||||
groupings.push(vec![0; (bits.len() + (w_usize - 1)) / w_usize]);
|
groupings.push(vec![0; bits.len().div_ceil(w_usize)]);
|
||||||
|
|
||||||
for (i, mut bit) in bits.iter_mut().enumerate() {
|
for (i, mut bit) in bits.iter_mut().enumerate() {
|
||||||
let mut bit = u8_from_bool(&mut bit);
|
let mut bit = u8_from_bool(&mut bit);
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ pub trait TransactionPlanner<S: ScannerFeed, A>: 'static + Send + Sync {
|
|||||||
///
|
///
|
||||||
/// Returns `None` if the fee exceeded the inputs, or `Some` otherwise.
|
/// Returns `None` if the fee exceeded the inputs, or `Some` otherwise.
|
||||||
// TODO: Enum for Change of None, Some, Mandatory
|
// TODO: Enum for Change of None, Some, Mandatory
|
||||||
|
#[allow(clippy::type_complexity)]
|
||||||
fn plan_transaction_with_fee_amortization(
|
fn plan_transaction_with_fee_amortization(
|
||||||
&self,
|
&self,
|
||||||
operating_costs: &mut u64,
|
operating_costs: &mut u64,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ pub type CoinsEvent = serai_abi::coins::Event;
|
|||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct SeraiCoins<'a>(pub(crate) &'a TemporalSerai<'a>);
|
pub struct SeraiCoins<'a>(pub(crate) &'a TemporalSerai<'a>);
|
||||||
impl<'a> SeraiCoins<'a> {
|
impl SeraiCoins<'_> {
|
||||||
pub async fn mint_events(&self) -> Result<Vec<CoinsEvent>, SeraiError> {
|
pub async fn mint_events(&self) -> Result<Vec<CoinsEvent>, SeraiError> {
|
||||||
self
|
self
|
||||||
.0
|
.0
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const PALLET: &str = "Dex";
|
|||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct SeraiDex<'a>(pub(crate) &'a TemporalSerai<'a>);
|
pub struct SeraiDex<'a>(pub(crate) &'a TemporalSerai<'a>);
|
||||||
impl<'a> SeraiDex<'a> {
|
impl SeraiDex<'_> {
|
||||||
pub async fn events(&self) -> Result<Vec<DexEvent>, SeraiError> {
|
pub async fn events(&self) -> Result<Vec<DexEvent>, SeraiError> {
|
||||||
self
|
self
|
||||||
.0
|
.0
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const PALLET: &str = "GenesisLiquidity";
|
|||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct SeraiGenesisLiquidity<'a>(pub(crate) &'a TemporalSerai<'a>);
|
pub struct SeraiGenesisLiquidity<'a>(pub(crate) &'a TemporalSerai<'a>);
|
||||||
impl<'a> SeraiGenesisLiquidity<'a> {
|
impl SeraiGenesisLiquidity<'_> {
|
||||||
pub async fn events(&self) -> Result<Vec<GenesisLiquidityEvent>, SeraiError> {
|
pub async fn events(&self) -> Result<Vec<GenesisLiquidityEvent>, SeraiError> {
|
||||||
self
|
self
|
||||||
.0
|
.0
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const PALLET: &str = "InInstructions";
|
|||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct SeraiInInstructions<'a>(pub(crate) &'a TemporalSerai<'a>);
|
pub struct SeraiInInstructions<'a>(pub(crate) &'a TemporalSerai<'a>);
|
||||||
impl<'a> SeraiInInstructions<'a> {
|
impl SeraiInInstructions<'_> {
|
||||||
pub async fn last_batch_for_network(
|
pub async fn last_batch_for_network(
|
||||||
&self,
|
&self,
|
||||||
network: NetworkId,
|
network: NetworkId,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const PALLET: &str = "LiquidityTokens";
|
|||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct SeraiLiquidityTokens<'a>(pub(crate) &'a TemporalSerai<'a>);
|
pub struct SeraiLiquidityTokens<'a>(pub(crate) &'a TemporalSerai<'a>);
|
||||||
impl<'a> SeraiLiquidityTokens<'a> {
|
impl SeraiLiquidityTokens<'_> {
|
||||||
pub async fn token_supply(&self, coin: Coin) -> Result<Amount, SeraiError> {
|
pub async fn token_supply(&self, coin: Coin) -> Result<Amount, SeraiError> {
|
||||||
Ok(self.0.storage(PALLET, "Supply", coin).await?.unwrap_or(Amount(0)))
|
Ok(self.0.storage(PALLET, "Supply", coin).await?.unwrap_or(Amount(0)))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ pub struct TemporalSerai<'a> {
|
|||||||
block: [u8; 32],
|
block: [u8; 32],
|
||||||
events: RwLock<Option<EventsInBlock>>,
|
events: RwLock<Option<EventsInBlock>>,
|
||||||
}
|
}
|
||||||
impl<'a> Clone for TemporalSerai<'a> {
|
impl Clone for TemporalSerai<'_> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Self { serai: self.serai, block: self.block, events: RwLock::new(None) }
|
Self { serai: self.serai, block: self.block, events: RwLock::new(None) }
|
||||||
}
|
}
|
||||||
@@ -319,7 +319,7 @@ impl Serai {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> TemporalSerai<'a> {
|
impl TemporalSerai<'_> {
|
||||||
async fn events<E>(
|
async fn events<E>(
|
||||||
&self,
|
&self,
|
||||||
filter_map: impl Fn(&Event) -> Option<E>,
|
filter_map: impl Fn(&Event) -> Option<E>,
|
||||||
@@ -389,27 +389,27 @@ impl<'a> TemporalSerai<'a> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn coins(&'a self) -> SeraiCoins<'a> {
|
pub fn coins(&self) -> SeraiCoins<'_> {
|
||||||
SeraiCoins(self)
|
SeraiCoins(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dex(&'a self) -> SeraiDex<'a> {
|
pub fn dex(&self) -> SeraiDex<'_> {
|
||||||
SeraiDex(self)
|
SeraiDex(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn in_instructions(&'a self) -> SeraiInInstructions<'a> {
|
pub fn in_instructions(&self) -> SeraiInInstructions<'_> {
|
||||||
SeraiInInstructions(self)
|
SeraiInInstructions(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn validator_sets(&'a self) -> SeraiValidatorSets<'a> {
|
pub fn validator_sets(&self) -> SeraiValidatorSets<'_> {
|
||||||
SeraiValidatorSets(self)
|
SeraiValidatorSets(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn genesis_liquidity(&'a self) -> SeraiGenesisLiquidity {
|
pub fn genesis_liquidity(&self) -> SeraiGenesisLiquidity {
|
||||||
SeraiGenesisLiquidity(self)
|
SeraiGenesisLiquidity(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn liquidity_tokens(&'a self) -> SeraiLiquidityTokens {
|
pub fn liquidity_tokens(&self) -> SeraiLiquidityTokens {
|
||||||
SeraiLiquidityTokens(self)
|
SeraiLiquidityTokens(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub type ValidatorSetsEvent = serai_abi::validator_sets::Event;
|
|||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct SeraiValidatorSets<'a>(pub(crate) &'a TemporalSerai<'a>);
|
pub struct SeraiValidatorSets<'a>(pub(crate) &'a TemporalSerai<'a>);
|
||||||
impl<'a> SeraiValidatorSets<'a> {
|
impl SeraiValidatorSets<'_> {
|
||||||
pub async fn new_set_events(&self) -> Result<Vec<ValidatorSetsEvent>, SeraiError> {
|
pub async fn new_set_events(&self) -> Result<Vec<ValidatorSetsEvent>, SeraiError> {
|
||||||
self
|
self
|
||||||
.0
|
.0
|
||||||
|
|||||||
Reference in New Issue
Block a user