mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Tweak serai-coordinator-cosign to make it closer to compiling again
Adds `PartialOrd, Ord` derivations to some items in `serai-primitives` so they may be used as keys within `borsh` maps.
This commit is contained in:
@@ -21,7 +21,7 @@ workspace = true
|
|||||||
blake2 = { version = "0.11.0-rc.0", default-features = false, features = ["alloc"] }
|
blake2 = { version = "0.11.0-rc.0", default-features = false, features = ["alloc"] }
|
||||||
|
|
||||||
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
borsh = { version = "1", default-features = false, features = ["std", "derive", "de_strict_order"] }
|
||||||
serai-client = { path = "../../substrate/client", default-features = false, features = ["serai"] }
|
serai-abi = { path = "../../substrate/abi", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
log = { version = "0.4", default-features = false, features = ["std"] }
|
log = { version = "0.4", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
use core::future::Future;
|
use core::future::Future;
|
||||||
use std::{sync::Arc, collections::HashMap};
|
use std::{sync::Arc, collections::HashMap};
|
||||||
|
|
||||||
use serai_client::{
|
use serai_abi::primitives::{
|
||||||
primitives::{SeraiAddress, Amount},
|
balance::Amount, validator_sets::ExternalValidatorSet, address::SeraiAddress,
|
||||||
validator_sets::primitives::ExternalValidatorSet,
|
|
||||||
Serai,
|
|
||||||
};
|
};
|
||||||
|
use serai_client::Serai;
|
||||||
|
|
||||||
use serai_db::*;
|
use serai_db::*;
|
||||||
use serai_task::ContinuallyRan;
|
use serai_task::ContinuallyRan;
|
||||||
|
|||||||
@@ -9,11 +9,16 @@ use blake2::{Digest, Blake2s256};
|
|||||||
|
|
||||||
use borsh::{BorshSerialize, BorshDeserialize};
|
use borsh::{BorshSerialize, BorshDeserialize};
|
||||||
|
|
||||||
use serai_client::{
|
use serai_abi::{
|
||||||
primitives::{ExternalNetworkId, SeraiAddress},
|
primitives::{
|
||||||
validator_sets::primitives::{Session, ExternalValidatorSet, KeyPair},
|
crypto::{Public, KeyPair},
|
||||||
Public, Block, Serai, TemporalSerai,
|
network_id::ExternalNetworkId,
|
||||||
|
validator_sets::{Session, ExternalValidatorSet},
|
||||||
|
address::SeraiAddress,
|
||||||
|
},
|
||||||
|
Block,
|
||||||
};
|
};
|
||||||
|
use serai_client::{Serai, TemporalSerai};
|
||||||
|
|
||||||
use serai_db::*;
|
use serai_db::*;
|
||||||
use serai_task::*;
|
use serai_task::*;
|
||||||
@@ -155,8 +160,8 @@ async fn keys_for_network(
|
|||||||
async fn cosigning_sets(
|
async fn cosigning_sets(
|
||||||
serai: &TemporalSerai<'_>,
|
serai: &TemporalSerai<'_>,
|
||||||
) -> Result<Vec<(ExternalValidatorSet, Public)>, String> {
|
) -> Result<Vec<(ExternalValidatorSet, Public)>, String> {
|
||||||
let mut sets = Vec::with_capacity(serai_client::primitives::EXTERNAL_NETWORKS.len());
|
let mut sets = vec![];
|
||||||
for network in serai_client::primitives::EXTERNAL_NETWORKS {
|
for network in ExternalNetworkId::all() {
|
||||||
let Some((session, keys)) = keys_for_network(serai, network).await? else {
|
let Some((session, keys)) = keys_for_network(serai, network).await? else {
|
||||||
// If this network doesn't have usable keys, move on
|
// If this network doesn't have usable keys, move on
|
||||||
continue;
|
continue;
|
||||||
@@ -282,8 +287,8 @@ impl<D: Db> Cosigning<D> {
|
|||||||
/// If this global session hasn't produced any notable cosigns, this will return the latest
|
/// If this global session hasn't produced any notable cosigns, this will return the latest
|
||||||
/// cosigns for this session.
|
/// cosigns for this session.
|
||||||
pub fn notable_cosigns(getter: &impl Get, global_session: [u8; 32]) -> Vec<SignedCosign> {
|
pub fn notable_cosigns(getter: &impl Get, global_session: [u8; 32]) -> Vec<SignedCosign> {
|
||||||
let mut cosigns = Vec::with_capacity(serai_client::primitives::EXTERNAL_NETWORKS.len());
|
let mut cosigns = vec![];
|
||||||
for network in serai_client::primitives::EXTERNAL_NETWORKS {
|
for network in ExternalNetworkId::all() {
|
||||||
if let Some(cosign) = NetworksLatestCosignedBlock::get(getter, global_session, network) {
|
if let Some(cosign) = NetworksLatestCosignedBlock::get(getter, global_session, network) {
|
||||||
cosigns.push(cosign);
|
cosigns.push(cosign);
|
||||||
}
|
}
|
||||||
@@ -300,7 +305,7 @@ impl<D: Db> Cosigning<D> {
|
|||||||
let mut cosigns = Faults::get(&self.db, faulted).expect("faulted with no faults");
|
let mut cosigns = Faults::get(&self.db, faulted).expect("faulted with no faults");
|
||||||
// Also include all of our recognized-as-honest cosigns in an attempt to induce fault
|
// Also include all of our recognized-as-honest cosigns in an attempt to induce fault
|
||||||
// identification in those who see the faulty cosigns as honest
|
// identification in those who see the faulty cosigns as honest
|
||||||
for network in serai_client::primitives::EXTERNAL_NETWORKS {
|
for network in ExternalNetworkId::all() {
|
||||||
if let Some(cosign) = NetworksLatestCosignedBlock::get(&self.db, faulted, network) {
|
if let Some(cosign) = NetworksLatestCosignedBlock::get(&self.db, faulted, network) {
|
||||||
if cosign.cosign.global_session == faulted {
|
if cosign.cosign.global_session == faulted {
|
||||||
cosigns.push(cosign);
|
cosigns.push(cosign);
|
||||||
@@ -312,8 +317,8 @@ impl<D: Db> Cosigning<D> {
|
|||||||
let Some(global_session) = evaluator::currently_evaluated_global_session(&self.db) else {
|
let Some(global_session) = evaluator::currently_evaluated_global_session(&self.db) else {
|
||||||
return vec![];
|
return vec![];
|
||||||
};
|
};
|
||||||
let mut cosigns = Vec::with_capacity(serai_client::primitives::EXTERNAL_NETWORKS.len());
|
let mut cosigns = vec![];
|
||||||
for network in serai_client::primitives::EXTERNAL_NETWORKS {
|
for network in ExternalNetworkId::all() {
|
||||||
if let Some(cosign) = NetworksLatestCosignedBlock::get(&self.db, global_session, network) {
|
if let Some(cosign) = NetworksLatestCosignedBlock::get(&self.db, global_session, network) {
|
||||||
cosigns.push(cosign);
|
cosigns.push(cosign);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ use borsh::{io, BorshSerialize, BorshDeserialize};
|
|||||||
use crate::coin::{ExternalCoin, Coin};
|
use crate::coin::{ExternalCoin, Coin};
|
||||||
|
|
||||||
/// Identifier for an embedded elliptic curve.
|
/// Identifier for an embedded elliptic curve.
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Debug, Zeroize, BorshSerialize, BorshDeserialize)]
|
#[rustfmt::skip]
|
||||||
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Zeroize)]
|
||||||
|
#[derive(BorshSerialize, BorshDeserialize)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "non_canonical_scale_derivations",
|
feature = "non_canonical_scale_derivations",
|
||||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen, scale::DecodeWithMemTracking)
|
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen, scale::DecodeWithMemTracking)
|
||||||
@@ -20,7 +22,9 @@ pub enum EmbeddedEllipticCurve {
|
|||||||
/// The type used to identify external networks.
|
/// The type used to identify external networks.
|
||||||
///
|
///
|
||||||
/// This type serializes to a subset of `NetworkId`.
|
/// This type serializes to a subset of `NetworkId`.
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Zeroize, BorshSerialize, BorshDeserialize)]
|
#[rustfmt::skip]
|
||||||
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Zeroize)]
|
||||||
|
#[derive(BorshSerialize, BorshDeserialize)]
|
||||||
#[borsh(use_discriminant = true)]
|
#[borsh(use_discriminant = true)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "non_canonical_scale_derivations",
|
feature = "non_canonical_scale_derivations",
|
||||||
@@ -73,7 +77,7 @@ impl ExternalNetworkId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The type used to identify networks.
|
/// The type used to identify networks.
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Zeroize)]
|
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Zeroize)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "non_canonical_scale_derivations",
|
feature = "non_canonical_scale_derivations",
|
||||||
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen, scale::DecodeWithMemTracking)
|
derive(scale::Encode, scale::Decode, scale::MaxEncodedLen, scale::DecodeWithMemTracking)
|
||||||
|
|||||||
Reference in New Issue
Block a user