Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Re-arrange Chains traits for better composability #3912

Merged
merged 7 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::{anyhow, bail, Context, Result};
use async_trait::async_trait;
use cf_chains::{
address::EncodedAddress,
eth::{to_ethereum_address, Address as EthereumAddress},
evm::{to_ethereum_address, Address as EthereumAddress},
CcmChannelMetadata, ForeignChain,
};
use cf_primitives::{AccountRole, Asset, BasisPoints, ChannelId};
Expand Down
10 changes: 5 additions & 5 deletions engine/multisig/src/crypto/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use super::{
// solely use "CryptoScheme" as generic parameter instead.
pub use super::secp256k1::{Point, Scalar};
use anyhow::Context;
use cf_chains::{eth::ParityBit, Chain, ChainCrypto, Ethereum};
use cf_chains::{evm::ParityBit, Chain, ChainCrypto, Ethereum};
use num_bigint::BigUint;
use secp256k1::constants::CURVE_ORDER;
use serde::{Deserialize, Serialize};
Expand All @@ -23,7 +23,7 @@ pub struct EthSchnorrSignature {
pub r: secp256k1::PublicKey,
}

impl From<EthSchnorrSignature> for cf_chains::eth::SchnorrVerificationComponents {
impl From<EthSchnorrSignature> for cf_chains::evm::SchnorrVerificationComponents {
fn from(cfe_sig: EthSchnorrSignature) -> Self {
Self { s: cfe_sig.s, k_times_g_address: pubkey_to_eth_addr(cfe_sig.r) }
}
Expand Down Expand Up @@ -71,7 +71,7 @@ impl ChainSigning for EthSigning {
impl CryptoScheme for EvmCryptoScheme {
type Point = Point;
type Signature = EthSchnorrSignature;
type PublicKey = cf_chains::eth::AggKey;
type PublicKey = cf_chains::evm::AggKey;
type SigningPayload = SigningPayload;
const CRYPTO_TAG: CryptoTag = CryptoTag::Evm;
const NAME: &'static str = "Evm Crypto";
Expand All @@ -86,7 +86,7 @@ impl CryptoScheme for EvmCryptoScheme {
nonce_commitment: Self::Point,
payload: &Self::SigningPayload,
) -> Scalar {
use cf_chains::eth::AggKey;
use cf_chains::evm::AggKey;

let e = AggKey::from_pubkey_compressed(pubkey.get_element().serialize())
.message_challenge(&payload.0, &pubkey_to_eth_addr(nonce_commitment.get_element()));
Expand Down Expand Up @@ -132,7 +132,7 @@ impl CryptoScheme for EvmCryptoScheme {
}

fn pubkey_from_point(pubkey_point: &Self::Point) -> Self::PublicKey {
cf_chains::eth::AggKey {
cf_chains::evm::AggKey {
pub_key_x: pubkey_point.x_bytes(),
pub_key_y_parity: if pubkey_point.is_even_y() {
ParityBit::Even
Expand Down
2 changes: 1 addition & 1 deletion engine/multisig/src/crypto/key_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl CanonicalEncoding for cf_chains::dot::PolkadotPublicKey {
}
}

impl CanonicalEncoding for cf_chains::eth::AggKey {
impl CanonicalEncoding for cf_chains::evm::AggKey {
fn encode_key(&self) -> Vec<u8> {
self.to_pubkey_compressed().to_vec()
}
Expand Down
2 changes: 1 addition & 1 deletion engine/src/eth/broadcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ where
pub async fn send(
&self,
// This is from the SC.
unsigned_tx: cf_chains::eth::Transaction,
unsigned_tx: cf_chains::evm::Transaction,
) -> Result<TxHash> {
async move {
let mut transaction_request = Eip1559TransactionRequest {
Expand Down
2 changes: 1 addition & 1 deletion engine/src/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub use self::{
muxer::{ProtocolVersion, VersionedCeremonyMessage, CURRENT_PROTOCOL_VERSION},
};
use anyhow::Context;
use cf_chains::{btc::BitcoinCrypto, dot::PolkadotCrypto, eth::EvmCrypto, ChainCrypto};
use cf_chains::{btc::BitcoinCrypto, dot::PolkadotCrypto, evm::EvmCrypto, ChainCrypto};
use cf_primitives::AccountId;
use futures::{Future, FutureExt};
use multisig::p2p::OutgoingMultisigStageMessages;
Expand Down
2 changes: 1 addition & 1 deletion engine/src/p2p/muxer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{anyhow, Result};
use cf_chains::{btc::BitcoinCrypto, dot::PolkadotCrypto, eth::EvmCrypto};
use cf_chains::{btc::BitcoinCrypto, dot::PolkadotCrypto, evm::EvmCrypto};
use futures::Future;
use state_chain_runtime::AccountId;
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use cf_chains::{
btc::BitcoinCrypto,
dot::{PolkadotCrypto, PolkadotPublicKey},
eth::EvmCrypto,
evm::EvmCrypto,
ChainCrypto,
};
use multisig::{
Expand Down
2 changes: 1 addition & 1 deletion engine/src/state_chain_observer/sc_observer/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
state_chain_observer::client::{extrinsic_api, StreamCache},
};
use cf_chains::{
eth::{SchnorrVerificationComponents, Transaction},
evm::{SchnorrVerificationComponents, Transaction},
Chain, ChainCrypto,
};
use cf_primitives::{AccountRole, GENESIS_EPOCH};
Expand Down
4 changes: 2 additions & 2 deletions engine/src/witness/eth/key_manager.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

use cf_chains::eth::{EvmCrypto, SchnorrVerificationComponents, TransactionFee};
use cf_chains::evm::{EvmCrypto, SchnorrVerificationComponents, TransactionFee};
use ethers::{
prelude::abigen,
types::{Bloom, TransactionReceipt},
Expand Down Expand Up @@ -108,7 +108,7 @@ impl<Inner: ChunkedByVault> ChunkedByVaultBuilder<Inner> {
<Inner::Chain as PalletInstanceAlias>::Instance,
>::vault_key_rotated_externally {
new_public_key:
cf_chains::eth::AggKey::from_pubkey_compressed(
cf_chains::evm::AggKey::from_pubkey_compressed(
new_agg_key.serialize(),
),
block_number: header.index,
Expand Down
2 changes: 1 addition & 1 deletion state-chain/cf-integration-tests/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::threshold_signing::{
BtcKeyComponents, BtcThresholdSigner, DotKeyComponents, DotThresholdSigner, EthKeyComponents,
EthThresholdSigner, KeyUtils, ThresholdSigner,
};
use cf_chains::{dot::PolkadotSignature, eth::SchnorrVerificationComponents, Chain, ChainCrypto};
use cf_chains::{dot::PolkadotSignature, evm::SchnorrVerificationComponents, Chain, ChainCrypto};

use cf_primitives::{AccountRole, CeremonyId, EpochIndex, FlipBalance, TxId, GENESIS_EPOCH};
use cf_traits::{AccountRoleRegistry, EpochInfo};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use arrayref::array_ref;
use cf_chains::{
btc,
dot::{EncodedPolkadotPayload, PolkadotPair, PolkadotPublicKey, PolkadotSignature},
eth::{to_ethereum_address, AggKey, SchnorrVerificationComponents},
evm::{to_ethereum_address, AggKey, SchnorrVerificationComponents},
};
use cf_primitives::{EpochIndex, GENESIS_EPOCH};
use libsecp256k1::{PublicKey, SecretKey};
Expand Down
2 changes: 1 addition & 1 deletion state-chain/chains/src/benchmarking_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::address::EncodedAddress;
#[cfg(feature = "runtime-benchmarks")]
use crate::address::ForeignChainAddress;
#[cfg(feature = "runtime-benchmarks")]
use crate::eth::EthereumFetchId;
use crate::evm::EthereumFetchId;

/// Ensure type specifies a value to be used for benchmarking purposes.
pub trait BenchmarkValue {
Expand Down
Loading
Loading