Replace "coin" with "network"

The Processor's coins folder referred to the networks it could process, as did
its Coin trait. This, and other similar cases throughout the codebase, have now
been corrected.

Also corrects dated documentation for a key pair is confirmed under the
validator-sets pallet.
This commit is contained in:
Luke Parker
2023-07-30 16:11:30 -04:00
parent 2815046b21
commit 9f143a9742
40 changed files with 551 additions and 532 deletions

View File

@@ -88,7 +88,7 @@ pub fn network_rpc(network: NetworkId, ops: &DockerOperations, handle: &str) ->
}
pub fn confirmations(network: NetworkId) -> usize {
use processor::coins::*;
use processor::networks::*;
match network {
NetworkId::Bitcoin => Bitcoin::CONFIRMATIONS,
NetworkId::Ethereum => todo!(),
@@ -313,7 +313,7 @@ impl Wallet {
},
rpc::HttpRpc,
};
use processor::{additional_key, coins::Monero};
use processor::{additional_key, networks::Monero};
let rpc_url = network_rpc(NetworkId::Monero, ops, handle);
let rpc = HttpRpc::new(rpc_url).expect("couldn't connect to the Monero RPC");
@@ -384,23 +384,27 @@ impl Wallet {
}
pub fn address(&self) -> ExternalAddress {
use serai_client::coins;
use serai_client::networks;
match self {
Wallet::Bitcoin { public_key, .. } => {
use bitcoin_serai::bitcoin::{Network, Address};
ExternalAddress::new(
coins::bitcoin::Address(Address::p2pkh(public_key, Network::Regtest)).try_into().unwrap(),
networks::bitcoin::Address(Address::p2pkh(public_key, Network::Regtest))
.try_into()
.unwrap(),
)
.unwrap()
}
Wallet::Monero { view_pair, .. } => {
use monero_serai::wallet::address::{Network, AddressSpec};
ExternalAddress::new(
coins::monero::Address::new(view_pair.address(Network::Mainnet, AddressSpec::Standard))
.unwrap()
.try_into()
.unwrap(),
networks::monero::Address::new(
view_pair.address(Network::Mainnet, AddressSpec::Standard),
)
.unwrap()
.try_into()
.unwrap(),
)
.unwrap()
}

View File

@@ -273,7 +273,7 @@ fn batch_test() {
messages::substrate::CoordinatorMessage::SubstrateBlock {
context: SubstrateContext {
serai_time,
coin_latest_finalized_block: batch.batch.block,
network_latest_finalized_block: batch.batch.block,
},
network,
block: substrate_block_num + u64::from(i),

View File

@@ -80,7 +80,7 @@ pub(crate) async fn key_gen(coordinators: &mut [Coordinator], network: NetworkId
// Send the shares
let mut substrate_key = None;
let mut coin_key = None;
let mut network_key = None;
interact_with_all(
coordinators,
|participant| messages::key_gen::CoordinatorMessage::Shares {
@@ -96,15 +96,15 @@ pub(crate) async fn key_gen(coordinators: &mut [Coordinator], network: NetworkId
messages::key_gen::ProcessorMessage::GeneratedKeyPair {
id: this_id,
substrate_key: this_substrate_key,
coin_key: this_coin_key,
network_key: this_network_key,
} => {
assert_eq!(this_id, id);
if substrate_key.is_none() {
substrate_key = Some(this_substrate_key);
coin_key = Some(this_coin_key.clone());
network_key = Some(this_network_key.clone());
}
assert_eq!(substrate_key.unwrap(), this_substrate_key);
assert_eq!(coin_key.as_ref().unwrap(), &this_coin_key);
assert_eq!(network_key.as_ref().unwrap(), &this_network_key);
}
_ => panic!("processor didn't return GeneratedKeyPair in response to GenerateKey"),
},
@@ -112,15 +112,15 @@ pub(crate) async fn key_gen(coordinators: &mut [Coordinator], network: NetworkId
.await;
// Confirm the key pair
// TODO: Beter document coin_latest_finalized_block's genesis state, and error if a set claims
// TODO: Beter document network_latest_finalized_block's genesis state, and error if a set claims
// [0; 32] was finalized
let context = SubstrateContext {
serai_time: SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs(),
coin_latest_finalized_block: BlockHash([0; 32]),
network_latest_finalized_block: BlockHash([0; 32]),
};
let key_pair =
(PublicKey::from_raw(substrate_key.unwrap()), coin_key.clone().unwrap().try_into().unwrap());
(PublicKey::from_raw(substrate_key.unwrap()), network_key.clone().unwrap().try_into().unwrap());
for coordinator in coordinators {
coordinator

View File

@@ -158,7 +158,7 @@ fn send_test() {
let key_pair = key_gen(&mut coordinators, network).await;
// Now we we have to mine blocks to activate the key
// (the first key is activated when the coin's block time exceeds the Serai time it was
// (the first key is activated when the network's block time exceeds the Serai time it was
// confirmed at)
for _ in 0 .. confirmations(network) {
@@ -209,7 +209,7 @@ fn send_test() {
messages::substrate::CoordinatorMessage::SubstrateBlock {
context: SubstrateContext {
serai_time,
coin_latest_finalized_block: batch.batch.block,
network_latest_finalized_block: batch.batch.block,
},
network,
block: substrate_block_num,