mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Move serai-client off serai-runtime, MIT licensing it
Uses a full-fledged serai-abi to do so. Removes use of UncheckedExtrinsic as a pointlessly (for us) length-prefixed block with a more complicated signing algorithm than advantageous. In the future, we should considering consolidating the various primitives crates. I'm not convinced we benefit from one primitives crate per pallet.
This commit is contained in:
@@ -151,7 +151,7 @@ impl<D: Db> CosignEvaluator<D> {
|
||||
// included the set_keys and one didn't
|
||||
// Because set_keys will force a cosign, it will force detection of distinct blocks
|
||||
// re: set_keys using keys prior to set_keys (assumed amenable to all)
|
||||
let serai = self.serai.as_of(block.header().parent_hash.into());
|
||||
let serai = self.serai.as_of(block.header.parent_hash.into());
|
||||
|
||||
let Some(set_with_keys) = set_with_keys_fn(&serai, cosign.network).await? else {
|
||||
return Ok(());
|
||||
|
||||
@@ -464,7 +464,7 @@ async fn handle_new_blocks<D: Db, Pro: Processors>(
|
||||
// Get the keys as of the prior block
|
||||
// That means if this block is setting new keys (which won't lock in until we process this
|
||||
// block), we won't freeze up waiting for the yet-to-be-processed keys to sign this block
|
||||
let serai = serai.as_of(actual_block.header().parent_hash.into());
|
||||
let serai = serai.as_of(actual_block.header.parent_hash.into());
|
||||
|
||||
has_no_cosigners = Some(actual_block.clone());
|
||||
|
||||
@@ -583,7 +583,7 @@ pub async fn scan_task<D: Db, Pro: Processors>(
|
||||
loop {
|
||||
match serai.latest_finalized_block().await {
|
||||
Ok(latest) => {
|
||||
if latest.header().number >= next_substrate_block {
|
||||
if latest.header.number >= next_substrate_block {
|
||||
return latest;
|
||||
} else {
|
||||
sleep(Duration::from_secs(3)).await;
|
||||
|
||||
@@ -4,8 +4,6 @@ use std::collections::HashMap;
|
||||
use zeroize::Zeroizing;
|
||||
use rand_core::{RngCore, OsRng};
|
||||
|
||||
use scale::Decode;
|
||||
|
||||
use ciphersuite::{group::GroupEncoding, Ciphersuite, Ristretto};
|
||||
use frost::Participant;
|
||||
|
||||
@@ -340,27 +338,10 @@ async fn dkg_test() {
|
||||
let spec = spec.clone();
|
||||
let key_pair = key_pair.clone();
|
||||
async move {
|
||||
// Version, Pallet, Call, Network, Key Pair, Signature
|
||||
let expected_len = 1 + 1 + 1 + 1 + 32 + 1 + key_pair.1.len() + 64;
|
||||
// It's length prefixed
|
||||
assert_eq!(tx.len(), 2 + expected_len);
|
||||
let expected_len = u16::try_from(expected_len).unwrap();
|
||||
|
||||
// Check the encoded length
|
||||
// This is the compact encoding from SCALE, specifically the two-byte length encoding case
|
||||
let bottom_six = expected_len & 0b111111;
|
||||
let upper_eight = expected_len >> 6;
|
||||
assert_eq!(u8::try_from((bottom_six << 2) | 1).unwrap(), tx[0]);
|
||||
assert_eq!(u8::try_from(upper_eight).unwrap(), tx[1]);
|
||||
|
||||
// Version
|
||||
assert_eq!(tx[2], 4);
|
||||
|
||||
// Call
|
||||
let tx = serai_client::runtime::RuntimeCall::decode(&mut &tx[3 ..]).unwrap();
|
||||
match tx {
|
||||
serai_client::runtime::RuntimeCall::ValidatorSets(
|
||||
serai_client::runtime::validator_sets::Call::set_keys {
|
||||
assert_eq!(tx.signature, None);
|
||||
match tx.call {
|
||||
serai_client::abi::Call::ValidatorSets(
|
||||
serai_client::abi::validator_sets::Call::set_keys {
|
||||
network,
|
||||
key_pair: set_key_pair,
|
||||
signature,
|
||||
|
||||
@@ -19,7 +19,7 @@ use frost::{
|
||||
use frost_schnorrkel::Schnorrkel;
|
||||
|
||||
use serai_client::{
|
||||
Public,
|
||||
Public, SeraiAddress,
|
||||
validator_sets::primitives::{musig_context, remove_participant_message},
|
||||
};
|
||||
|
||||
@@ -190,7 +190,7 @@ impl DkgRemoval {
|
||||
preprocesses: HashMap<Participant, Vec<u8>>,
|
||||
removed: [u8; 32],
|
||||
mut shares: HashMap<Participant, Vec<u8>>,
|
||||
) -> Result<(Vec<Public>, [u8; 64]), Participant> {
|
||||
) -> Result<(Vec<SeraiAddress>, [u8; 64]), Participant> {
|
||||
// TODO: Remove this ugly blob
|
||||
let shares = {
|
||||
let mut shares_participants = shares.keys().cloned().collect::<Vec<_>>();
|
||||
@@ -213,7 +213,7 @@ impl DkgRemoval {
|
||||
new_shares
|
||||
};
|
||||
|
||||
let mut signers = shares.keys().cloned().map(Public).collect::<Vec<_>>();
|
||||
let mut signers = shares.keys().cloned().map(SeraiAddress).collect::<Vec<_>>();
|
||||
signers.sort();
|
||||
|
||||
let machine = Self::share_internal(spec, key, attempt, preprocesses, removed)
|
||||
|
||||
@@ -10,7 +10,7 @@ use frost::dkg::Participant;
|
||||
|
||||
use scale::{Encode, Decode};
|
||||
use serai_client::{
|
||||
Public, Signature,
|
||||
Public, SeraiAddress, Signature,
|
||||
validator_sets::primitives::{ValidatorSet, KeyPair},
|
||||
SeraiValidatorSets,
|
||||
};
|
||||
@@ -174,7 +174,7 @@ pub(crate) async fn handle_application_tx<
|
||||
D: Db,
|
||||
Pro: Processors,
|
||||
FPst: Future<Output = ()>,
|
||||
PST: Clone + Fn(ValidatorSet, PstTxType, Vec<u8>) -> FPst,
|
||||
PST: Clone + Fn(ValidatorSet, PstTxType, serai_client::Transaction) -> FPst,
|
||||
FPtt: Future<Output = ()>,
|
||||
PTT: Clone + Fn(Transaction) -> FPtt,
|
||||
FRid: Future<Output = ()>,
|
||||
@@ -734,7 +734,7 @@ pub(crate) async fn handle_application_tx<
|
||||
|
||||
let tx = serai_client::SeraiValidatorSets::remove_participant(
|
||||
spec.set().network,
|
||||
Public(data.plan),
|
||||
SeraiAddress(data.plan),
|
||||
signers,
|
||||
Signature(signature),
|
||||
);
|
||||
|
||||
@@ -55,7 +55,7 @@ async fn handle_block<
|
||||
D: Db,
|
||||
Pro: Processors,
|
||||
FPst: Future<Output = ()>,
|
||||
PST: Clone + Fn(ValidatorSet, PstTxType, Vec<u8>) -> FPst,
|
||||
PST: Clone + Fn(ValidatorSet, PstTxType, serai_client::Transaction) -> FPst,
|
||||
FPtt: Future<Output = ()>,
|
||||
PTT: Clone + Fn(Transaction) -> FPtt,
|
||||
FRid: Future<Output = ()>,
|
||||
@@ -148,7 +148,7 @@ pub(crate) async fn handle_new_blocks<
|
||||
D: Db,
|
||||
Pro: Processors,
|
||||
FPst: Future<Output = ()>,
|
||||
PST: Clone + Fn(ValidatorSet, PstTxType, Vec<u8>) -> FPst,
|
||||
PST: Clone + Fn(ValidatorSet, PstTxType, serai_client::Transaction) -> FPst,
|
||||
FPtt: Future<Output = ()>,
|
||||
PTT: Clone + Fn(Transaction) -> FPtt,
|
||||
FRid: Future<Output = ()>,
|
||||
|
||||
Reference in New Issue
Block a user