mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Merge branch 'develop' into next
This is an initial resolution of conflicts which does not work.
This commit is contained in:
@@ -21,7 +21,7 @@ use ciphersuite::{
|
||||
use embedwards25519::Embedwards25519;
|
||||
use secq256k1::Secq256k1;
|
||||
|
||||
use serai_client::primitives::NetworkId;
|
||||
use serai_client::primitives::ExternalNetworkId;
|
||||
|
||||
use messages::{
|
||||
coordinator::{SubstrateSignableId, SubstrateSignId, cosign_block_msg},
|
||||
@@ -110,7 +110,7 @@ pub struct Handles {
|
||||
}
|
||||
|
||||
pub struct Processor {
|
||||
network: NetworkId,
|
||||
network: ExternalNetworkId,
|
||||
|
||||
serai_rpc: String,
|
||||
#[allow(unused)]
|
||||
@@ -136,7 +136,7 @@ impl Drop for Processor {
|
||||
impl Processor {
|
||||
pub async fn new(
|
||||
name: &'static str,
|
||||
network: NetworkId,
|
||||
network: ExternalNetworkId,
|
||||
ops: &DockerOperations,
|
||||
handles: Handles,
|
||||
processor_key: <Ristretto as Ciphersuite>::F,
|
||||
|
||||
@@ -16,7 +16,7 @@ use dkg::Participant;
|
||||
use scale::Encode;
|
||||
|
||||
use serai_client::{
|
||||
primitives::{NetworkId, BlockHash, Signature},
|
||||
primitives::{BlockHash, Signature},
|
||||
in_instructions::{
|
||||
primitives::{Batch, SignedBatch, batch_message},
|
||||
InInstructionsEvent,
|
||||
@@ -274,7 +274,7 @@ async fn batch_test() {
|
||||
Session(0),
|
||||
&substrate_key,
|
||||
Batch {
|
||||
network: NetworkId::Bitcoin,
|
||||
network: ExternalNetworkId::Bitcoin,
|
||||
id: 0,
|
||||
block: BlockHash([0x22; 32]),
|
||||
instructions: vec![],
|
||||
|
||||
@@ -10,9 +10,8 @@ use ciphersuite::{
|
||||
use dkg::Participant;
|
||||
|
||||
use serai_client::{
|
||||
primitives::NetworkId,
|
||||
validator_sets::primitives::{ExternalValidatorSet, KeyPair, Session},
|
||||
Public,
|
||||
validator_sets::primitives::{Session, ValidatorSet, KeyPair},
|
||||
};
|
||||
use messages::CoordinatorMessage;
|
||||
|
||||
@@ -25,7 +24,7 @@ pub async fn key_gen<C: Ciphersuite>(
|
||||
let coordinators = processors.len();
|
||||
let mut participant_is = vec![];
|
||||
|
||||
let set = ValidatorSet { session, network: NetworkId::Bitcoin };
|
||||
let set = ExternalValidatorSet { session, network: ExternalNetworkId::Bitcoin };
|
||||
|
||||
// This is distinct from the result of evrf_public_keys for each processor, as there'll have some
|
||||
// ordering algorithm on-chain which won't match our ordering
|
||||
|
||||
@@ -108,7 +108,7 @@ pub(crate) async fn new_test(test_body: impl TestBody, fast_epoch: bool) {
|
||||
handles.insert(name, handle);
|
||||
}
|
||||
|
||||
let processor_key = message_queue_keys[&NetworkId::Bitcoin];
|
||||
let processor_key = message_queue_keys[&ExternalNetworkId::Bitcoin];
|
||||
|
||||
coordinators.push((
|
||||
Handles {
|
||||
@@ -200,7 +200,7 @@ pub(crate) async fn new_test(test_body: impl TestBody, fast_epoch: bool) {
|
||||
let mut processors: Vec<Processor> = vec![];
|
||||
for (i, (handles, key)) in coordinators.iter().enumerate() {
|
||||
processors.push(
|
||||
Processor::new(name(i), NetworkId::Bitcoin, &outer_ops, handles.clone(), *key).await,
|
||||
Processor::new(name(i), ExternalNetworkId::Bitcoin, &outer_ops, handles.clone(), *key).await,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ async fn set_rotation_test() {
|
||||
1,
|
||||
)
|
||||
.await;
|
||||
allocate_stake(&serai, network, amount, &pair5, 2).await;
|
||||
allocate_stake(&serai, network.into(), amount, &pair5, 2).await;
|
||||
|
||||
// genesis keygen
|
||||
let _ = key_gen::<Secp256k1>(&mut processors, Session(0)).await;
|
||||
@@ -188,12 +188,14 @@ async fn set_rotation_test() {
|
||||
}
|
||||
|
||||
// wait until next session to see the effect on coordinator
|
||||
wait_till_session_1(&serai, network).await;
|
||||
wait_till_session_1(&serai, network.into()).await;
|
||||
|
||||
// Ensure the new validator was included in the new set
|
||||
assert_eq!(
|
||||
most_recent_new_set_event(&serai, network).await,
|
||||
ValidatorSetsEvent::NewSet { set: ValidatorSet { session: Session(1), network } },
|
||||
most_recent_new_set_event(&serai, network.into()).await,
|
||||
ValidatorSetsEvent::NewSet {
|
||||
set: ValidatorSet { session: Session(1), network: network.into() }
|
||||
},
|
||||
);
|
||||
|
||||
// add the last participant & do the keygen
|
||||
|
||||
@@ -10,18 +10,17 @@ use ciphersuite::Secp256k1;
|
||||
use dkg::Participant;
|
||||
|
||||
use serai_client::{
|
||||
PairTrait,
|
||||
primitives::{
|
||||
NetworkId, Coin, Amount, Balance, BlockHash, SeraiAddress, ExternalAddress,
|
||||
insecure_pair_from_name,
|
||||
},
|
||||
coins::{
|
||||
primitives::{OutInstruction, OutInstructionWithBalance},
|
||||
CoinsEvent,
|
||||
},
|
||||
in_instructions::primitives::{InInstruction, InInstructionWithBalance, Batch},
|
||||
in_instructions::primitives::{Batch, InInstruction, InInstructionWithBalance},
|
||||
primitives::{
|
||||
insecure_pair_from_name, Amount, Balance, BlockHash, Coin, ExternalAddress, ExternalBalance,
|
||||
ExternalCoin, SeraiAddress,
|
||||
},
|
||||
validator_sets::primitives::Session,
|
||||
SeraiCoins,
|
||||
PairTrait, SeraiCoins,
|
||||
};
|
||||
use messages::{coordinator::PlanMeta, sign::SignId, SubstrateContext, CoordinatorMessage};
|
||||
|
||||
@@ -202,7 +201,7 @@ async fn sign_test() {
|
||||
|
||||
#[allow(clippy::inconsistent_digit_grouping)]
|
||||
let amount = Amount(1_000_000_00);
|
||||
let balance = Balance { coin: Coin::Bitcoin, amount };
|
||||
let balance = ExternalBalance { coin: ExternalCoin::Bitcoin, amount };
|
||||
|
||||
let coin_block = BlockHash([0x33; 32]);
|
||||
let block_included_in = batch(
|
||||
@@ -211,7 +210,7 @@ async fn sign_test() {
|
||||
Session(0),
|
||||
&substrate_key,
|
||||
Batch {
|
||||
network: NetworkId::Bitcoin,
|
||||
network: balance.coin.network(),
|
||||
id: 0,
|
||||
block: coin_block,
|
||||
instructions: vec![InInstructionWithBalance {
|
||||
@@ -236,10 +235,13 @@ async fn sign_test() {
|
||||
// Verify the mint occurred as expected
|
||||
assert_eq!(
|
||||
serai.mint_events().await.unwrap(),
|
||||
vec![CoinsEvent::Mint { to: serai_addr, balance }]
|
||||
vec![CoinsEvent::Mint { to: serai_addr, balance: balance.into() }]
|
||||
);
|
||||
assert_eq!(serai.coin_supply(ExternalCoin::Bitcoin.into()).await.unwrap(), amount);
|
||||
assert_eq!(
|
||||
serai.coin_balance(ExternalCoin::Bitcoin.into(), serai_addr).await.unwrap(),
|
||||
amount
|
||||
);
|
||||
assert_eq!(serai.coin_supply(Coin::Bitcoin).await.unwrap(), amount);
|
||||
assert_eq!(serai.coin_balance(Coin::Bitcoin, serai_addr).await.unwrap(), amount);
|
||||
}
|
||||
|
||||
// Trigger a burn
|
||||
@@ -295,8 +297,11 @@ async fn sign_test() {
|
||||
let last_serai_block_hash = last_serai_block.hash();
|
||||
let serai = serai.as_of(last_serai_block_hash);
|
||||
let serai = serai.coins();
|
||||
assert_eq!(serai.coin_supply(Coin::Bitcoin).await.unwrap(), Amount(0));
|
||||
assert_eq!(serai.coin_balance(Coin::Bitcoin, serai_addr).await.unwrap(), Amount(0));
|
||||
assert_eq!(serai.coin_supply(ExternalCoin::Bitcoin.into()).await.unwrap(), Amount(0));
|
||||
assert_eq!(
|
||||
serai.coin_balance(ExternalCoin::Bitcoin.into(), serai_addr).await.unwrap(),
|
||||
Amount(0)
|
||||
);
|
||||
|
||||
let mut plan_id = [0; 32];
|
||||
OsRng.fill_bytes(&mut plan_id);
|
||||
|
||||
@@ -9,12 +9,13 @@ use rand_core::{RngCore, OsRng};
|
||||
use scale::Encode;
|
||||
|
||||
use serai_client::{
|
||||
primitives::{
|
||||
NetworkId, Coin, Amount, Balance, SeraiAddress, ExternalAddress, insecure_pair_from_name,
|
||||
},
|
||||
validator_sets::primitives::{Session, ValidatorSet},
|
||||
in_instructions::primitives::Shorthand,
|
||||
coins::primitives::{OutInstruction, OutInstructionWithBalance},
|
||||
in_instructions::primitives::Shorthand,
|
||||
primitives::{
|
||||
insecure_pair_from_name, Amount, Balance, Coin, ExternalAddress, ExternalBalance, ExternalCoin,
|
||||
SeraiAddress,
|
||||
},
|
||||
validator_sets::primitives::{ExternalValidatorSet, Session},
|
||||
PairTrait, SeraiCoins,
|
||||
};
|
||||
|
||||
@@ -199,7 +200,7 @@ async fn mint_and_burn_test() {
|
||||
.await
|
||||
.unwrap()
|
||||
.validator_sets()
|
||||
.keys(ValidatorSet { network, session: Session(0) })
|
||||
.keys(ExternalValidatorSet { network, session: Session(0) })
|
||||
.await
|
||||
.unwrap()
|
||||
{
|
||||
@@ -224,7 +225,10 @@ async fn mint_and_burn_test() {
|
||||
}
|
||||
};
|
||||
|
||||
(key_pair(false, NetworkId::Bitcoin).await, key_pair(true, NetworkId::Monero).await)
|
||||
(
|
||||
key_pair(false, ExternalNetworkId::Bitcoin).await,
|
||||
key_pair(true, ExternalNetworkId::Monero).await,
|
||||
)
|
||||
};
|
||||
|
||||
// Because the initial keys only become active when the network's time matches the Serai
|
||||
@@ -439,8 +443,8 @@ async fn mint_and_burn_test() {
|
||||
);
|
||||
}
|
||||
};
|
||||
wait_for_batch(false, NetworkId::Bitcoin).await;
|
||||
wait_for_batch(true, NetworkId::Monero).await;
|
||||
wait_for_batch(false, ExternalNetworkId::Bitcoin).await;
|
||||
wait_for_batch(true, ExternalNetworkId::Monero).await;
|
||||
}
|
||||
|
||||
// TODO: Verify the mints
|
||||
@@ -511,7 +515,7 @@ async fn mint_and_burn_test() {
|
||||
#[allow(clippy::inconsistent_digit_grouping)]
|
||||
burn(
|
||||
0,
|
||||
Coin::Bitcoin,
|
||||
ExternalCoin::Bitcoin,
|
||||
1_000_000_00,
|
||||
ExternalAddress::new(
|
||||
serai_client::networks::bitcoin::Address::new(bitcoin_addr.clone()).unwrap().into(),
|
||||
@@ -522,7 +526,7 @@ async fn mint_and_burn_test() {
|
||||
|
||||
burn(
|
||||
1,
|
||||
Coin::Monero,
|
||||
ExternalCoin::Monero,
|
||||
1_000_000_000_000,
|
||||
ExternalAddress::new(
|
||||
serai_client::networks::monero::Address::new(monero_addr).unwrap().into(),
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{sync::OnceLock, collections::HashMap};
|
||||
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use serai_client::primitives::NetworkId;
|
||||
use serai_client::primitives::ExternalNetworkId;
|
||||
|
||||
use dockertest::{
|
||||
LogAction, LogPolicy, LogSource, LogOptions, StartPolicy, TestBodySpecification,
|
||||
@@ -56,24 +56,24 @@ pub(crate) async fn new_test(test_body: impl TestBody) {
|
||||
|
||||
let (coord_key, message_queue_keys, message_queue_composition) = message_queue_instance();
|
||||
|
||||
let (bitcoin_composition, bitcoin_port) = network_instance(NetworkId::Bitcoin);
|
||||
let (bitcoin_composition, bitcoin_port) = network_instance(ExternalNetworkId::Bitcoin);
|
||||
let mut bitcoin_processor_composition = processor_instance(
|
||||
name,
|
||||
NetworkId::Bitcoin,
|
||||
ExternalNetworkId::Bitcoin,
|
||||
bitcoin_port,
|
||||
message_queue_keys[&NetworkId::Bitcoin],
|
||||
message_queue_keys[&ExternalNetworkId::Bitcoin],
|
||||
)
|
||||
.0;
|
||||
assert_eq!(bitcoin_processor_composition.len(), 1);
|
||||
let bitcoin_processor_composition = bitcoin_processor_composition.swap_remove(0);
|
||||
|
||||
let (monero_composition, monero_port) = network_instance(NetworkId::Monero);
|
||||
let (monero_composition, monero_port) = network_instance(ExternalNetworkId::Monero);
|
||||
let mut monero_processor_composition = processor_instance(
|
||||
name,
|
||||
NetworkId::Monero,
|
||||
ExternalNetworkId::Monero,
|
||||
monero_port,
|
||||
message_queue_keys[&NetworkId::Monero],
|
||||
)
|
||||
ExternalNetworkId
|
||||
.0;
|
||||
assert_eq!(monero_processor_composition.len(), 1);
|
||||
let monero_processor_composition = monero_processor_composition.swap_remove(0);
|
||||
|
||||
@@ -7,23 +7,25 @@ use ciphersuite::{
|
||||
Ciphersuite, Ristretto,
|
||||
};
|
||||
|
||||
use serai_primitives::NetworkId;
|
||||
use serai_primitives::{ExternalNetworkId, EXTERNAL_NETWORKS};
|
||||
|
||||
use dockertest::{
|
||||
PullPolicy, Image, LogAction, LogPolicy, LogSource, LogOptions, TestBodySpecification,
|
||||
};
|
||||
|
||||
pub type MessageQueuePrivateKey = <Ristretto as Ciphersuite>::F;
|
||||
pub fn instance(
|
||||
) -> (MessageQueuePrivateKey, HashMap<NetworkId, MessageQueuePrivateKey>, TestBodySpecification) {
|
||||
pub fn instance() -> (
|
||||
MessageQueuePrivateKey,
|
||||
HashMap<ExternalNetworkId, MessageQueuePrivateKey>,
|
||||
TestBodySpecification,
|
||||
) {
|
||||
serai_docker_tests::build("message-queue".to_string());
|
||||
|
||||
let coord_key = <Ristretto as Ciphersuite>::F::random(&mut OsRng);
|
||||
let priv_keys = HashMap::from([
|
||||
(NetworkId::Bitcoin, <Ristretto as Ciphersuite>::F::random(&mut OsRng)),
|
||||
(NetworkId::Ethereum, <Ristretto as Ciphersuite>::F::random(&mut OsRng)),
|
||||
(NetworkId::Monero, <Ristretto as Ciphersuite>::F::random(&mut OsRng)),
|
||||
]);
|
||||
let priv_keys = EXTERNAL_NETWORKS
|
||||
.into_iter()
|
||||
.map(|n| (n, <Ristretto as Ciphersuite>::F::random(&mut OsRng)))
|
||||
.collect::<HashMap<_, _>>();
|
||||
|
||||
let composition = TestBodySpecification::with_image(
|
||||
Image::with_repository("serai-dev-message-queue").pull_policy(PullPolicy::Never),
|
||||
@@ -38,15 +40,15 @@ pub fn instance(
|
||||
("COORDINATOR_KEY".to_string(), hex::encode((Ristretto::generator() * coord_key).to_bytes())),
|
||||
(
|
||||
"BITCOIN_KEY".to_string(),
|
||||
hex::encode((Ristretto::generator() * priv_keys[&NetworkId::Bitcoin]).to_bytes()),
|
||||
hex::encode((Ristretto::generator() * priv_keys[&ExternalNetworkId::Bitcoin]).to_bytes()),
|
||||
),
|
||||
(
|
||||
"ETHEREUM_KEY".to_string(),
|
||||
hex::encode((Ristretto::generator() * priv_keys[&NetworkId::Ethereum]).to_bytes()),
|
||||
hex::encode((Ristretto::generator() * priv_keys[&ExternalNetworkId::Ethereum]).to_bytes()),
|
||||
),
|
||||
(
|
||||
"MONERO_KEY".to_string(),
|
||||
hex::encode((Ristretto::generator() * priv_keys[&NetworkId::Monero]).to_bytes()),
|
||||
hex::encode((Ristretto::generator() * priv_keys[&ExternalNetworkId::Monero]).to_bytes()),
|
||||
),
|
||||
("DB_PATH".to_string(), "./message-queue-db".to_string()),
|
||||
("RUST_LOG".to_string(), "serai_message_queue=trace,".to_string()),
|
||||
@@ -85,7 +87,7 @@ fn basic_functionality() {
|
||||
.queue(
|
||||
Metadata {
|
||||
from: Service::Coordinator,
|
||||
to: Service::Processor(NetworkId::Bitcoin),
|
||||
to: Service::Processor(ExternalNetworkId::Bitcoin),
|
||||
intent: b"intent".to_vec(),
|
||||
},
|
||||
b"Hello, World!".to_vec(),
|
||||
@@ -99,7 +101,7 @@ fn basic_functionality() {
|
||||
.queue(
|
||||
Metadata {
|
||||
from: Service::Coordinator,
|
||||
to: Service::Processor(NetworkId::Bitcoin),
|
||||
to: Service::Processor(ExternalNetworkId::Bitcoin),
|
||||
intent: b"intent 2".to_vec(),
|
||||
},
|
||||
b"Hello, World, again!".to_vec(),
|
||||
@@ -110,9 +112,9 @@ fn basic_functionality() {
|
||||
|
||||
// Successfully get it
|
||||
let bitcoin = MessageQueue::new(
|
||||
Service::Processor(NetworkId::Bitcoin),
|
||||
Service::Processor(ExternalNetworkId::Bitcoin),
|
||||
rpc.clone(),
|
||||
Zeroizing::new(priv_keys[&NetworkId::Bitcoin]),
|
||||
Zeroizing::new(priv_keys[&ExternalNetworkId::Bitcoin]),
|
||||
);
|
||||
let msg = bitcoin.next(Service::Coordinator).await;
|
||||
assert_eq!(msg.from, Service::Coordinator);
|
||||
@@ -142,7 +144,7 @@ fn basic_functionality() {
|
||||
.queue(
|
||||
Metadata {
|
||||
from: Service::Coordinator,
|
||||
to: Service::Processor(NetworkId::Monero),
|
||||
to: Service::Processor(ExternalNetworkId::Monero),
|
||||
// Intents should be per-from-to, making this valid
|
||||
intent: b"intent".to_vec(),
|
||||
},
|
||||
@@ -152,9 +154,9 @@ fn basic_functionality() {
|
||||
.unwrap();
|
||||
|
||||
let monero = MessageQueue::new(
|
||||
Service::Processor(NetworkId::Monero),
|
||||
Service::Processor(ExternalNetworkId::Monero),
|
||||
rpc,
|
||||
Zeroizing::new(priv_keys[&NetworkId::Monero]),
|
||||
Zeroizing::new(priv_keys[&ExternalNetworkId::Monero]),
|
||||
);
|
||||
assert_eq!(monero.next(Service::Coordinator).await.id, 0);
|
||||
monero.ack(Service::Coordinator, 0).await;
|
||||
|
||||
@@ -42,4 +42,4 @@ dkg = { path = "../../crypto/dkg", default-features = false }
|
||||
|
||||
bitcoin-serai = { path = "../../networks/bitcoin", default-features = false, features = ["hazmat"] }
|
||||
|
||||
monero-wallet-util = { path = "../../networks/monero/wallet/util", default-features = false, features = ["compile-time-generators"] }
|
||||
monero-wallet = { path = "../../networks/monero/wallet", default-features = false, features = ["compile-time-generators"] }
|
||||
|
||||
@@ -27,4 +27,4 @@ pub use frost_schnorrkel;
|
||||
|
||||
pub use bitcoin_serai;
|
||||
|
||||
pub use monero_wallet_util;
|
||||
pub use monero_wallet;
|
||||
|
||||
@@ -10,7 +10,7 @@ use ciphersuite::{
|
||||
};
|
||||
use dkg::evrf::*;
|
||||
|
||||
use serai_client::primitives::{NetworkId, insecure_arbitrary_key_from_name};
|
||||
use serai_client::primitives::{ExternalNetworkId, insecure_arbitrary_key_from_name};
|
||||
use messages::{ProcessorMessage, CoordinatorMessage};
|
||||
use serai_message_queue::{Service, Metadata, client::MessageQueue};
|
||||
|
||||
@@ -36,7 +36,7 @@ pub struct EvrfPublicKeys {
|
||||
|
||||
pub fn processor_instance(
|
||||
name: &str,
|
||||
network: NetworkId,
|
||||
network: ExternalNetworkId,
|
||||
port: u32,
|
||||
message_queue_key: <Ristretto as Ciphersuite>::F,
|
||||
) -> (Vec<TestBodySpecification>, EvrfPublicKeys) {
|
||||
@@ -65,10 +65,9 @@ pub fn processor_instance(
|
||||
};
|
||||
|
||||
let network_str = match network {
|
||||
NetworkId::Serai => panic!("starting a processor for Serai"),
|
||||
NetworkId::Bitcoin => "bitcoin",
|
||||
NetworkId::Ethereum => "ethereum",
|
||||
NetworkId::Monero => "monero",
|
||||
ExternalNetworkId::Bitcoin => "bitcoin",
|
||||
ExternalNetworkId::Ethereum => "ethereum",
|
||||
ExternalNetworkId::Monero => "monero",
|
||||
};
|
||||
let image = format!("{network_str}-processor");
|
||||
serai_docker_tests::build(image.clone());
|
||||
@@ -90,7 +89,7 @@ pub fn processor_instance(
|
||||
.into(),
|
||||
)];
|
||||
|
||||
if network == NetworkId::Ethereum {
|
||||
if network == ExternalNetworkId::Ethereum {
|
||||
serai_docker_tests::build("ethereum-relayer".to_string());
|
||||
res.push(
|
||||
TestBodySpecification::with_image(
|
||||
@@ -119,7 +118,7 @@ pub struct ProcessorKeys {
|
||||
pub type Handles = (String, String, String, String);
|
||||
pub fn processor_stack(
|
||||
name: &str,
|
||||
network: NetworkId,
|
||||
network: ExternalNetworkId,
|
||||
network_hostname_override: Option<String>,
|
||||
) -> (Handles, ProcessorKeys, Vec<TestBodySpecification>) {
|
||||
let (network_composition, network_rpc_port) = network_instance(network);
|
||||
@@ -145,10 +144,9 @@ pub fn processor_stack(
|
||||
for (name, composition) in [
|
||||
Some((
|
||||
match network {
|
||||
NetworkId::Serai => unreachable!(),
|
||||
NetworkId::Bitcoin => "bitcoin",
|
||||
NetworkId::Ethereum => "ethereum",
|
||||
NetworkId::Monero => "monero",
|
||||
ExternalNetworkId::Bitcoin => "bitcoin",
|
||||
ExternalNetworkId::Ethereum => "ethereum",
|
||||
ExternalNetworkId::Monero => "monero",
|
||||
},
|
||||
network_composition,
|
||||
)),
|
||||
@@ -200,7 +198,7 @@ pub fn processor_stack(
|
||||
}
|
||||
|
||||
pub struct Coordinator {
|
||||
network: NetworkId,
|
||||
network: ExternalNetworkId,
|
||||
|
||||
network_handle: String,
|
||||
#[allow(unused)]
|
||||
@@ -218,7 +216,7 @@ pub struct Coordinator {
|
||||
|
||||
impl Coordinator {
|
||||
pub fn new(
|
||||
network: NetworkId,
|
||||
network: ExternalNetworkId,
|
||||
ops: &DockerOperations,
|
||||
handles: Handles,
|
||||
keys: ProcessorKeys,
|
||||
@@ -256,7 +254,7 @@ impl Coordinator {
|
||||
let mut iters = 0;
|
||||
while iters < 60 {
|
||||
match network {
|
||||
NetworkId::Bitcoin => {
|
||||
ExternalNetworkId::Bitcoin => {
|
||||
use bitcoin_serai::rpc::Rpc;
|
||||
|
||||
// Bitcoin's Rpc::new will test the connection
|
||||
@@ -264,7 +262,7 @@ impl Coordinator {
|
||||
break;
|
||||
}
|
||||
}
|
||||
NetworkId::Ethereum => {
|
||||
ExternalNetworkId::Ethereum => {
|
||||
use std::sync::Arc;
|
||||
use ethereum_serai::{
|
||||
alloy::{
|
||||
@@ -293,7 +291,7 @@ impl Coordinator {
|
||||
provider
|
||||
.raw_request::<_, ()>(
|
||||
"anvil_setBalance".into(),
|
||||
[signer.to_string(), (tx.gas_limit * tx.gas_price).to_string()],
|
||||
[signer.to_string(), (u128::from(tx.gas_limit) * tx.gas_price).to_string()],
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
@@ -313,7 +311,7 @@ impl Coordinator {
|
||||
break;
|
||||
}
|
||||
}
|
||||
NetworkId::Monero => {
|
||||
ExternalNetworkId::Monero => {
|
||||
use monero_simple_request_rpc::SimpleRequestRpc;
|
||||
use monero_wallet::rpc::Rpc;
|
||||
|
||||
@@ -327,7 +325,6 @@ impl Coordinator {
|
||||
break;
|
||||
}
|
||||
}
|
||||
NetworkId::Serai => panic!("processor is booting with external network of Serai"),
|
||||
}
|
||||
|
||||
println!("external network RPC has yet to boot, waiting 1 sec, attempt {iters}");
|
||||
@@ -385,7 +382,7 @@ impl Coordinator {
|
||||
pub async fn add_block(&self, ops: &DockerOperations) -> ([u8; 32], Vec<u8>) {
|
||||
let rpc_url = network_rpc(self.network, ops, &self.network_handle);
|
||||
match self.network {
|
||||
NetworkId::Bitcoin => {
|
||||
ExternalNetworkId::Bitcoin => {
|
||||
use bitcoin_serai::{
|
||||
bitcoin::{consensus::Encodable, network::Network, Script, Address},
|
||||
rpc::Rpc,
|
||||
@@ -408,7 +405,7 @@ impl Coordinator {
|
||||
block.consensus_encode(&mut block_buf).unwrap();
|
||||
(hash, block_buf)
|
||||
}
|
||||
NetworkId::Ethereum => {
|
||||
ExternalNetworkId::Ethereum => {
|
||||
use ethereum_serai::alloy::{
|
||||
simple_request_transport::SimpleRequest,
|
||||
rpc_types::{BlockTransactionsKind, BlockNumberOrTag},
|
||||
@@ -445,7 +442,7 @@ impl Coordinator {
|
||||
.into_bytes();
|
||||
(hash.into(), state)
|
||||
}
|
||||
NetworkId::Monero => {
|
||||
ExternalNetworkId::Monero => {
|
||||
use curve25519_dalek::{constants::ED25519_BASEPOINT_POINT, scalar::Scalar};
|
||||
use monero_simple_request_rpc::SimpleRequestRpc;
|
||||
use monero_wallet::{rpc::Rpc, address::Network, ViewPair};
|
||||
@@ -463,14 +460,13 @@ impl Coordinator {
|
||||
let hash = rpc.get_block_hash(rpc.get_height().await.unwrap() - 1).await.unwrap();
|
||||
(hash, rpc.get_block(hash).await.unwrap().serialize())
|
||||
}
|
||||
NetworkId::Serai => panic!("processor tests adding block to Serai"),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn sync(&self, ops: &DockerOperations, others: &[Coordinator]) {
|
||||
let rpc_url = network_rpc(self.network, ops, &self.network_handle);
|
||||
match self.network {
|
||||
NetworkId::Bitcoin => {
|
||||
ExternalNetworkId::Bitcoin => {
|
||||
use bitcoin_serai::{bitcoin::consensus::Encodable, rpc::Rpc};
|
||||
|
||||
let rpc = Rpc::new(rpc_url).await.expect("couldn't connect to the Bitcoin RPC");
|
||||
@@ -500,7 +496,7 @@ impl Coordinator {
|
||||
}
|
||||
}
|
||||
}
|
||||
NetworkId::Ethereum => {
|
||||
ExternalNetworkId::Ethereum => {
|
||||
use ethereum_serai::alloy::{
|
||||
simple_request_transport::SimpleRequest,
|
||||
rpc_types::{BlockTransactionsKind, BlockNumberOrTag},
|
||||
@@ -551,7 +547,7 @@ impl Coordinator {
|
||||
//assert_eq!(expected_number, new_number);
|
||||
}
|
||||
}
|
||||
NetworkId::Monero => {
|
||||
ExternalNetworkId::Monero => {
|
||||
use monero_simple_request_rpc::SimpleRequestRpc;
|
||||
use monero_wallet::rpc::Rpc;
|
||||
|
||||
@@ -582,14 +578,13 @@ impl Coordinator {
|
||||
}
|
||||
}
|
||||
}
|
||||
NetworkId::Serai => panic!("processors tests syncing Serai nodes"),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn publish_transaction(&self, ops: &DockerOperations, tx: &[u8]) {
|
||||
let rpc_url = network_rpc(self.network, ops, &self.network_handle);
|
||||
match self.network {
|
||||
NetworkId::Bitcoin => {
|
||||
ExternalNetworkId::Bitcoin => {
|
||||
use bitcoin_serai::{
|
||||
bitcoin::{consensus::Decodable, Transaction},
|
||||
rpc::Rpc,
|
||||
@@ -599,7 +594,7 @@ impl Coordinator {
|
||||
Rpc::new(rpc_url).await.expect("couldn't connect to the coordinator's Bitcoin RPC");
|
||||
rpc.send_raw_transaction(&Transaction::consensus_decode(&mut &*tx).unwrap()).await.unwrap();
|
||||
}
|
||||
NetworkId::Ethereum => {
|
||||
ExternalNetworkId::Ethereum => {
|
||||
use ethereum_serai::alloy::{
|
||||
simple_request_transport::SimpleRequest,
|
||||
rpc_client::ClientBuilder,
|
||||
@@ -612,7 +607,7 @@ impl Coordinator {
|
||||
);
|
||||
let _ = provider.send_raw_transaction(tx).await.unwrap();
|
||||
}
|
||||
NetworkId::Monero => {
|
||||
ExternalNetworkId::Monero => {
|
||||
use monero_simple_request_rpc::SimpleRequestRpc;
|
||||
use monero_wallet::{transaction::Transaction, rpc::Rpc};
|
||||
|
||||
@@ -621,15 +616,15 @@ impl Coordinator {
|
||||
.expect("couldn't connect to the coordinator's Monero RPC");
|
||||
rpc.publish_transaction(&Transaction::read(&mut &*tx).unwrap()).await.unwrap();
|
||||
}
|
||||
NetworkId::Serai => panic!("processor tests broadcasting block to Serai"),
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn publish_eventuality_completion(&self, ops: &DockerOperations, tx: &[u8]) {
|
||||
match self.network {
|
||||
NetworkId::Bitcoin | NetworkId::Monero => self.publish_transaction(ops, tx).await,
|
||||
NetworkId::Ethereum => (),
|
||||
NetworkId::Serai => panic!("processor tests broadcasting block to Serai"),
|
||||
ExternalNetworkId::Bitcoin | ExternalNetworkId::Monero => {
|
||||
self.publish_transaction(ops, tx).await
|
||||
}
|
||||
ExternalNetworkId::Ethereum => (),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -640,7 +635,7 @@ impl Coordinator {
|
||||
) -> Option<Vec<u8>> {
|
||||
let rpc_url = network_rpc(self.network, ops, &self.network_handle);
|
||||
match self.network {
|
||||
NetworkId::Bitcoin => {
|
||||
ExternalNetworkId::Bitcoin => {
|
||||
use bitcoin_serai::{bitcoin::consensus::Encodable, rpc::Rpc};
|
||||
|
||||
let rpc =
|
||||
@@ -662,7 +657,7 @@ impl Coordinator {
|
||||
None
|
||||
}
|
||||
}
|
||||
NetworkId::Ethereum => {
|
||||
ExternalNetworkId::Ethereum => {
|
||||
/*
|
||||
let provider = RootProvider::<_, Ethereum>::new(
|
||||
ClientBuilder::default().transport(SimpleRequest::new(rpc_url.clone()), true),
|
||||
@@ -712,7 +707,7 @@ impl Coordinator {
|
||||
|
||||
None
|
||||
}
|
||||
NetworkId::Monero => {
|
||||
ExternalNetworkId::Monero => {
|
||||
use monero_simple_request_rpc::SimpleRequestRpc;
|
||||
use monero_wallet::rpc::Rpc;
|
||||
|
||||
@@ -727,7 +722,6 @@ impl Coordinator {
|
||||
None
|
||||
}
|
||||
}
|
||||
NetworkId::Serai => panic!("processor tests broadcasting block to Serai"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ use rand_core::{RngCore, OsRng};
|
||||
use scale::Encode;
|
||||
|
||||
use serai_client::{
|
||||
primitives::{Amount, NetworkId, Coin, Balance, ExternalAddress},
|
||||
validator_sets::primitives::ExternalKey,
|
||||
in_instructions::primitives::{InInstruction, RefundableInInstruction, Shorthand},
|
||||
primitives::{Amount, ExternalAddress, ExternalBalance, ExternalCoin, ExternalNetworkId},
|
||||
validator_sets::primitives::ExternalKey,
|
||||
};
|
||||
|
||||
use dockertest::{PullPolicy, Image, StartPolicy, TestBodySpecification, DockerOperations};
|
||||
@@ -52,37 +52,32 @@ pub fn monero_instance() -> (TestBodySpecification, u32) {
|
||||
(composition, XMR_PORT)
|
||||
}
|
||||
|
||||
pub fn network_instance(network: NetworkId) -> (TestBodySpecification, u32) {
|
||||
pub fn network_instance(network: ExternalNetworkId) -> (TestBodySpecification, u32) {
|
||||
match network {
|
||||
NetworkId::Bitcoin => bitcoin_instance(),
|
||||
NetworkId::Ethereum => ethereum_instance(),
|
||||
NetworkId::Monero => monero_instance(),
|
||||
NetworkId::Serai => {
|
||||
panic!("Serai is not a valid network to spawn an instance of for a processor")
|
||||
}
|
||||
ExternalNetworkId::Bitcoin => bitcoin_instance(),
|
||||
ExternalNetworkId::Ethereum => ethereum_instance(),
|
||||
ExternalNetworkId::Monero => monero_instance(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn network_rpc(network: NetworkId, ops: &DockerOperations, handle: &str) -> String {
|
||||
pub fn network_rpc(network: ExternalNetworkId, ops: &DockerOperations, handle: &str) -> String {
|
||||
let (ip, port) = ops
|
||||
.handle(handle)
|
||||
.host_port(match network {
|
||||
NetworkId::Bitcoin => BTC_PORT,
|
||||
NetworkId::Ethereum => ETH_PORT,
|
||||
NetworkId::Monero => XMR_PORT,
|
||||
NetworkId::Serai => panic!("getting port for external network yet it was Serai"),
|
||||
ExternalNetworkId::Bitcoin => BTC_PORT,
|
||||
ExternalNetworkId::Ethereum => ETH_PORT,
|
||||
ExternalNetworkId::Monero => XMR_PORT,
|
||||
})
|
||||
.unwrap();
|
||||
format!("http://{RPC_USER}:{RPC_PASS}@{ip}:{port}")
|
||||
}
|
||||
|
||||
pub fn confirmations(network: NetworkId) -> usize {
|
||||
pub fn confirmations(network: ExternalNetworkId) -> usize {
|
||||
use processor::networks::*;
|
||||
match network {
|
||||
NetworkId::Bitcoin => Bitcoin::CONFIRMATIONS,
|
||||
NetworkId::Ethereum => Ethereum::<serai_db::MemDb>::CONFIRMATIONS,
|
||||
NetworkId::Monero => Monero::CONFIRMATIONS,
|
||||
NetworkId::Serai => panic!("getting confirmations required for Serai"),
|
||||
ExternalNetworkId::Bitcoin => Bitcoin::CONFIRMATIONS,
|
||||
ExternalNetworkId::Ethereum => Ethereum::<serai_db::MemDb>::CONFIRMATIONS,
|
||||
ExternalNetworkId::Monero => Monero::CONFIRMATIONS,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,11 +103,11 @@ pub enum Wallet {
|
||||
|
||||
// TODO: Merge these functions with the processor's tests, which offers very similar functionality
|
||||
impl Wallet {
|
||||
pub async fn new(network: NetworkId, ops: &DockerOperations, handle: String) -> Wallet {
|
||||
pub async fn new(network: ExternalNetworkId, ops: &DockerOperations, handle: String) -> Wallet {
|
||||
let rpc_url = network_rpc(network, ops, &handle);
|
||||
|
||||
match network {
|
||||
NetworkId::Bitcoin => {
|
||||
ExternalNetworkId::Bitcoin => {
|
||||
use bitcoin_serai::{
|
||||
bitcoin::{
|
||||
secp256k1::{SECP256K1, SecretKey},
|
||||
@@ -153,7 +148,7 @@ impl Wallet {
|
||||
Wallet::Bitcoin { private_key, public_key, input_tx: funds }
|
||||
}
|
||||
|
||||
NetworkId::Ethereum => {
|
||||
ExternalNetworkId::Ethereum => {
|
||||
use ciphersuite::{group::ff::Field, Secp256k1};
|
||||
use ethereum_serai::alloy::{
|
||||
primitives::{U256, Address},
|
||||
@@ -185,7 +180,7 @@ impl Wallet {
|
||||
Wallet::Ethereum { rpc_url: rpc_url.clone(), key, nonce: 0 }
|
||||
}
|
||||
|
||||
NetworkId::Monero => {
|
||||
ExternalNetworkId::Monero => {
|
||||
use curve25519_dalek::{constants::ED25519_BASEPOINT_POINT, scalar::Scalar};
|
||||
use monero_simple_request_rpc::SimpleRequestRpc;
|
||||
use monero_wallet::{rpc::Rpc, address::Network, ViewPair};
|
||||
@@ -210,7 +205,6 @@ impl Wallet {
|
||||
last_tx: (height, block.miner_transaction.hash()),
|
||||
}
|
||||
}
|
||||
NetworkId::Serai => panic!("creating a wallet for for Serai"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +213,7 @@ impl Wallet {
|
||||
ops: &DockerOperations,
|
||||
to: &ExternalKey,
|
||||
instruction: Option<InInstruction>,
|
||||
) -> (Vec<u8>, Balance) {
|
||||
) -> (Vec<u8>, ExternalBalance) {
|
||||
match self {
|
||||
Wallet::Bitcoin { private_key, public_key, ref mut input_tx } => {
|
||||
use bitcoin_serai::bitcoin::{
|
||||
@@ -298,14 +292,14 @@ impl Wallet {
|
||||
let mut buf = vec![];
|
||||
tx.consensus_encode(&mut buf).unwrap();
|
||||
*input_tx = tx;
|
||||
(buf, Balance { coin: Coin::Bitcoin, amount: Amount(AMOUNT) })
|
||||
(buf, ExternalBalance { coin: ExternalCoin::Bitcoin, amount: Amount(AMOUNT) })
|
||||
}
|
||||
|
||||
Wallet::Ethereum { rpc_url, key, ref mut nonce } => {
|
||||
use std::sync::Arc;
|
||||
use ethereum_serai::{
|
||||
alloy::{
|
||||
primitives::{U256, Signature, TxKind},
|
||||
primitives::{U256, Parity, Signature, TxKind},
|
||||
sol_types::SolCall,
|
||||
simple_request_transport::SimpleRequest,
|
||||
consensus::{TxLegacy, SignableTransaction},
|
||||
@@ -349,13 +343,13 @@ impl Wallet {
|
||||
provider
|
||||
.raw_request::<_, ()>(
|
||||
"anvil_setBalance".into(),
|
||||
[signer.to_string(), (tx.gas_limit * tx.gas_price).to_string()],
|
||||
[signer.to_string(), (u128::from(tx.gas_limit) * tx.gas_price).to_string()],
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let mut bytes = vec![];
|
||||
tx.encode_with_signature_fields(&Signature::from(sig), &mut bytes);
|
||||
tx.encode_with_signature_fields(&sig, &mut bytes);
|
||||
let _ = provider.send_raw_transaction(&bytes).await.unwrap();
|
||||
|
||||
provider.raw_request::<_, ()>("anvil_mine".into(), [96]).await.unwrap();
|
||||
@@ -370,7 +364,7 @@ impl Wallet {
|
||||
chain_id: None,
|
||||
nonce: *nonce,
|
||||
gas_price: 1_000_000_000u128,
|
||||
gas_limit: 200_000u128,
|
||||
gas_limit: 200_000,
|
||||
to: TxKind::Call(router_addr.into()),
|
||||
// 1 ETH
|
||||
value: one_eth,
|
||||
@@ -395,12 +389,16 @@ impl Wallet {
|
||||
.unwrap();
|
||||
|
||||
let mut bytes = vec![];
|
||||
tx.encode_with_signature_fields(&Signature::from(sig), &mut bytes);
|
||||
let parity = Parity::NonEip155(Parity::from(sig.1).y_parity());
|
||||
tx.encode_with_signature_fields(&Signature::from(sig).with_parity(parity), &mut bytes);
|
||||
|
||||
// We drop the bottom 10 decimals
|
||||
(
|
||||
bytes,
|
||||
Balance { coin: Coin::Ether, amount: Amount(u64::try_from(eight_decimals).unwrap()) },
|
||||
ExternalBalance {
|
||||
coin: ExternalCoin::Ether,
|
||||
amount: Amount(u64::try_from(eight_decimals).unwrap()),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -417,7 +415,7 @@ impl Wallet {
|
||||
};
|
||||
use processor::{additional_key, networks::Monero};
|
||||
|
||||
let rpc_url = network_rpc(NetworkId::Monero, ops, handle);
|
||||
let rpc_url = network_rpc(ExternalNetworkId::Monero, ops, handle);
|
||||
let rpc = SimpleRequestRpc::new(rpc_url).await.expect("couldn't connect to the Monero RPC");
|
||||
|
||||
// Prepare inputs
|
||||
@@ -485,7 +483,7 @@ impl Wallet {
|
||||
last_tx.0 = current_height;
|
||||
last_tx.1 = tx.hash();
|
||||
|
||||
(tx.serialize(), Balance { coin: Coin::Monero, amount: Amount(AMOUNT) })
|
||||
(tx.serialize(), ExternalBalance { coin: ExternalCoin::Monero, amount: Amount(AMOUNT) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,11 +10,12 @@ use dkg::{Participant, tests::clone_without};
|
||||
use messages::{coordinator::*, SubstrateContext};
|
||||
|
||||
use serai_client::{
|
||||
primitives::{
|
||||
BlockHash, Amount, Balance, crypto::RuntimePublic, PublicKey, SeraiAddress, NetworkId,
|
||||
},
|
||||
in_instructions::primitives::{
|
||||
InInstruction, InInstructionWithBalance, Batch, SignedBatch, batch_message,
|
||||
batch_message, Batch, InInstruction, InInstructionWithBalance, SignedBatch,
|
||||
},
|
||||
primitives::{
|
||||
crypto::RuntimePublic, Amount, BlockHash, ExternalBalance, ExternalNetworkId, PublicKey,
|
||||
SeraiAddress, EXTERNAL_NETWORKS,
|
||||
},
|
||||
validator_sets::primitives::Session,
|
||||
};
|
||||
@@ -191,7 +192,7 @@ pub(crate) async fn substrate_block(
|
||||
|
||||
#[test]
|
||||
fn batch_test() {
|
||||
for network in [NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero] {
|
||||
for network in EXTERNAL_NETWORKS {
|
||||
let (coordinators, test) = new_test(network);
|
||||
|
||||
test.run(|ops| async move {
|
||||
@@ -257,15 +258,14 @@ fn batch_test() {
|
||||
instructions: if let Some(instruction) = &instruction {
|
||||
vec![InInstructionWithBalance {
|
||||
instruction: instruction.clone(),
|
||||
balance: Balance {
|
||||
balance: ExternalBalance {
|
||||
coin: balance_sent.coin,
|
||||
amount: Amount(
|
||||
balance_sent.amount.0 -
|
||||
(2 * match network {
|
||||
NetworkId::Bitcoin => Bitcoin::COST_TO_AGGREGATE,
|
||||
NetworkId::Ethereum => Ethereum::<MemDb>::COST_TO_AGGREGATE,
|
||||
NetworkId::Monero => Monero::COST_TO_AGGREGATE,
|
||||
NetworkId::Serai => panic!("minted for Serai?"),
|
||||
ExternalNetworkId::Bitcoin => Bitcoin::COST_TO_AGGREGATE,
|
||||
ExternalNetworkId::Ethereum => Ethereum::<MemDb>::COST_TO_AGGREGATE,
|
||||
ExternalNetworkId::Monero => Monero::COST_TO_AGGREGATE,
|
||||
}),
|
||||
),
|
||||
},
|
||||
@@ -324,7 +324,9 @@ fn batch_test() {
|
||||
},
|
||||
)
|
||||
.await;
|
||||
if instruction.is_some() || (instruction.is_none() && (network == NetworkId::Monero)) {
|
||||
if instruction.is_some() ||
|
||||
(instruction.is_none() && (network == ExternalNetworkId::Monero))
|
||||
{
|
||||
assert!(plans.is_empty());
|
||||
} else {
|
||||
// If no instruction was used, and the processor csn presume the origin, it'd have
|
||||
@@ -337,7 +339,7 @@ fn batch_test() {
|
||||
// With the latter InInstruction not existing, we should've triggered a refund if the origin
|
||||
// was detectable
|
||||
// Check this is trying to sign a Plan
|
||||
if network != NetworkId::Monero {
|
||||
if network != ExternalNetworkId::Monero {
|
||||
let mut refund_id = None;
|
||||
for coordinator in &mut coordinators {
|
||||
match coordinator.recv_message().await {
|
||||
|
||||
@@ -3,8 +3,8 @@ use std::time::SystemTime;
|
||||
use dkg::Participant;
|
||||
|
||||
use serai_client::{
|
||||
primitives::{NetworkId, BlockHash, PublicKey},
|
||||
validator_sets::primitives::{Session, KeyPair},
|
||||
primitives::{BlockHash, PublicKey, EXTERNAL_NETWORKS},
|
||||
validator_sets::primitives::{KeyPair, Session},
|
||||
};
|
||||
|
||||
use messages::{SubstrateContext, CoordinatorMessage, ProcessorMessage};
|
||||
@@ -122,7 +122,7 @@ pub(crate) async fn key_gen(coordinators: &mut [Coordinator]) -> KeyPair {
|
||||
|
||||
#[test]
|
||||
fn key_gen_test() {
|
||||
for network in [NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero] {
|
||||
for network in EXTERNAL_NETWORKS {
|
||||
let (coordinators, test) = new_test(network);
|
||||
|
||||
test.run(|ops| async move {
|
||||
|
||||
@@ -15,7 +15,7 @@ mod send;
|
||||
pub(crate) const COORDINATORS: usize = 4;
|
||||
pub(crate) const THRESHOLD: usize = ((COORDINATORS * 2) / 3) + 1;
|
||||
|
||||
fn new_test(network: NetworkId) -> (Vec<(Handles, ProcessorKeys)>, DockerTest) {
|
||||
fn new_test(network: ExternalNetworkId) -> (Vec<(Handles, ProcessorKeys)>, DockerTest) {
|
||||
let mut coordinators = vec![];
|
||||
let mut test = DockerTest::new().with_network(dockertest::Network::Isolated);
|
||||
let mut eth_handle = None;
|
||||
@@ -26,7 +26,7 @@ fn new_test(network: NetworkId) -> (Vec<(Handles, ProcessorKeys)>, DockerTest) {
|
||||
processor_stack(&i.to_string(), network, eth_handle.clone());
|
||||
// TODO: Remove this once https://github.com/foundry-rs/foundry/issues/7955
|
||||
// This has all processors share an Ethereum node until we can sync controlled nodes
|
||||
if network == NetworkId::Ethereum {
|
||||
if network == ExternalNetworkId::Ethereum {
|
||||
eth_handle = eth_handle.or_else(|| Some(handles.0.clone()));
|
||||
}
|
||||
coordinators.push((handles, keys));
|
||||
|
||||
@@ -10,9 +10,9 @@ use dkg::{Participant, tests::clone_without};
|
||||
use messages::{sign::SignId, SubstrateContext};
|
||||
|
||||
use serai_client::{
|
||||
primitives::{BlockHash, NetworkId, Amount, Balance, SeraiAddress},
|
||||
coins::primitives::{OutInstruction, OutInstructionWithBalance},
|
||||
in_instructions::primitives::{InInstruction, InInstructionWithBalance, Batch},
|
||||
in_instructions::primitives::{Batch, InInstruction, InInstructionWithBalance},
|
||||
primitives::{Amount, BlockHash, ExternalBalance, SeraiAddress, EXTERNAL_NETWORKS},
|
||||
validator_sets::primitives::Session,
|
||||
};
|
||||
|
||||
@@ -149,7 +149,7 @@ pub(crate) async fn sign_tx(
|
||||
|
||||
#[test]
|
||||
fn send_test() {
|
||||
for network in [NetworkId::Bitcoin, NetworkId::Ethereum, NetworkId::Monero] {
|
||||
for network in EXTERNAL_NETWORKS {
|
||||
let (coordinators, test) = new_test(network);
|
||||
|
||||
test.run(|ops| async move {
|
||||
@@ -204,10 +204,9 @@ fn send_test() {
|
||||
let amount_minted = Amount(
|
||||
balance_sent.amount.0 -
|
||||
(2 * match network {
|
||||
NetworkId::Bitcoin => Bitcoin::COST_TO_AGGREGATE,
|
||||
NetworkId::Ethereum => Ethereum::<MemDb>::COST_TO_AGGREGATE,
|
||||
NetworkId::Monero => Monero::COST_TO_AGGREGATE,
|
||||
NetworkId::Serai => panic!("minted for Serai?"),
|
||||
ExternalNetworkId::Bitcoin => Bitcoin::COST_TO_AGGREGATE,
|
||||
ExternalNetworkId::Ethereum => Ethereum::<MemDb>::COST_TO_AGGREGATE,
|
||||
ExternalNetworkId::Monero => Monero::COST_TO_AGGREGATE,
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -217,7 +216,7 @@ fn send_test() {
|
||||
block: BlockHash(block_with_tx.unwrap()),
|
||||
instructions: vec![InInstructionWithBalance {
|
||||
instruction,
|
||||
balance: Balance { coin: balance_sent.coin, amount: amount_minted },
|
||||
balance: ExternalBalance { coin: balance_sent.coin, amount: amount_minted },
|
||||
}],
|
||||
};
|
||||
|
||||
@@ -247,7 +246,7 @@ fn send_test() {
|
||||
block: substrate_block_num,
|
||||
burns: vec![OutInstructionWithBalance {
|
||||
instruction: OutInstruction { address: wallet.address() },
|
||||
balance: Balance { coin: balance_sent.coin, amount: amount_minted },
|
||||
balance: ExternalBalance { coin: balance_sent.coin, amount: amount_minted },
|
||||
}],
|
||||
batches: vec![batch.batch.id],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user