Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1,921 changes: 1,828 additions & 93 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions chain-signatures/crypto/src/kdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub enum Chain {
Ethereum,
Solana,
Bitcoin,
Hydration,
}

impl Chain {
Expand All @@ -28,6 +29,7 @@ impl Chain {
Chain::Ethereum => "0x1",
Chain::Solana => "0x800001f5",
Chain::Bitcoin => "bip122:000000000019d6689c085ae165831e93",
Chain::Hydration => "polkadot:2034",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2034 is not a CAIP-2 identifier, it's a ParaId that identifies it inside of Polkadot network.
CAIP 2 is using the genesis hash. OS it should be polkadot:afdc188f45c71dacbaa0b62e16a91f72.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is matching the id that galacticcouncil/hydration-node#1275 sets in the tests.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we need to change it there @esaminu and fix here

}
}

Expand All @@ -37,6 +39,7 @@ impl Chain {
Chain::Ethereum => "eip155:1",
Chain::Solana => "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
Chain::Bitcoin => "bip122:000000000019d6689c085ae165831e93",
Chain::Hydration => "polkadot:2034",
}
}
}
Expand Down Expand Up @@ -90,6 +93,11 @@ pub fn derive_epsilon_sol(key_version: u32, sender: &str, path: &str) -> Scalar
keccak(derivation_path.as_bytes())
}

pub fn derive_epsilon_hydration(key_version: u32, sender: &str, path: &str) -> Scalar {
let derivation_path = derivation_path(key_version, Chain::Hydration, sender, path);
keccak(derivation_path.as_bytes())
}

pub fn derive_key(public_key: PublicKey, epsilon: Scalar) -> PublicKey {
(<Secp256k1 as CurveArithmetic>::ProjectivePoint::GENERATOR * epsilon + public_key).to_affine()
}
Expand Down
8 changes: 7 additions & 1 deletion chain-signatures/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ opentelemetry-appender-tracing = "0.29.1"
alloy-signer-local = "1.0.38"
alloy-sol-types = "1.4.1"
helios = { git = "https://github.com/a16z/helios", rev = "e1f9a50f73d7af6f6ae4acf2b663d04aab6adb19" }

ed25519-zebra = { version = "4.1", default-features = false, features = ["alloc"] }
subxt = { version = "0.44", default-features = false, features = ["jsonrpsee","native","unstable-light-client"] }
sp-core = { version = "38.1", default-features = false, features = ["std"] }
sp-runtime = { version = "44.0.0", default-features = false, features = ["std"] }
sp-trie = { version = "41.1.0", default-features = false, features = ["std"] }
sp-state-machine = { version = "0.48", default-features = false, features = ["std"] }
subxt-signer = "0.44"

# workspace dependencies
alloy.workspace = true
Expand Down
92 changes: 49 additions & 43 deletions chain-signatures/node/src/backlog/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ mod tests {
fn create_test_tx(id: u8, status: PendingRequestStatus) -> BidirectionalTx {
BidirectionalTx {
id: BidirectionalTxId(B256::from([id; 32])),
sender: Pubkey::new_unique(),
sender: [0u8; 32],
serialized_transaction: vec![1, 2, 3],
source_chain: Chain::Solana,
target_chain: Chain::Ethereum,
Expand Down Expand Up @@ -781,62 +781,68 @@ mod tests {
Chain::Ethereum,
sign_id_eth,
BacklogTransaction::Bidirectional(tx_eth.clone()),
SignRequestType::SignBidirectional(SignBidirectionalEvent {
sender: Default::default(),
serialized_transaction: vec![],
dest: "ethereum".to_string(),
caip2_id: "eip155:1".to_string(),
key_version: 0,
deposit: 0,
path: "".to_string(),
algo: "".to_string(),
params: "".to_string(),
program_id,
output_deserialization_schema: vec![],
respond_serialization_schema: vec![],
}),
SignRequestType::SignBidirectional(
crate::indexer_common::SignBidirectionalEvent::Solana(SignBidirectionalEvent {
sender: Default::default(),
serialized_transaction: vec![],
dest: "ethereum".to_string(),
caip2_id: "eip155:1".to_string(),
key_version: 0,
deposit: 0,
path: "".to_string(),
algo: "".to_string(),
params: "".to_string(),
program_id,
output_deserialization_schema: vec![],
respond_serialization_schema: vec![],
}),
),
)
.await;
backlog
.insert(
Chain::Solana,
sign_id_sol,
BacklogTransaction::Bidirectional(tx_sol.clone()),
SignRequestType::SignBidirectional(SignBidirectionalEvent {
sender: Default::default(),
serialized_transaction: vec![],
dest: "solana".to_string(),
caip2_id: "solana:5eykt4UsFY6PZFX8nTM1".to_string(),
key_version: 0,
deposit: 0,
path: "".to_string(),
algo: "".to_string(),
params: "".to_string(),
program_id,
output_deserialization_schema: vec![],
respond_serialization_schema: vec![],
}),
SignRequestType::SignBidirectional(
crate::indexer_common::SignBidirectionalEvent::Solana(SignBidirectionalEvent {
sender: Default::default(),
serialized_transaction: vec![],
dest: "solana".to_string(),
caip2_id: "solana:5eykt4UsFY6PZFX8nTM1".to_string(),
key_version: 0,
deposit: 0,
path: "".to_string(),
algo: "".to_string(),
params: "".to_string(),
program_id,
output_deserialization_schema: vec![],
respond_serialization_schema: vec![],
}),
),
)
.await;
backlog
.insert(
Chain::NEAR,
sign_id_near,
BacklogTransaction::Bidirectional(tx_near.clone()),
SignRequestType::SignBidirectional(SignBidirectionalEvent {
sender: Default::default(),
serialized_transaction: vec![],
dest: "near".to_string(),
caip2_id: "near:mainnet".to_string(),
key_version: 0,
deposit: 0,
path: "".to_string(),
algo: "".to_string(),
params: "".to_string(),
program_id,
output_deserialization_schema: vec![],
respond_serialization_schema: vec![],
}),
SignRequestType::SignBidirectional(
crate::indexer_common::SignBidirectionalEvent::Solana(SignBidirectionalEvent {
sender: Default::default(),
serialized_transaction: vec![],
dest: "near".to_string(),
caip2_id: "near:mainnet".to_string(),
key_version: 0,
deposit: 0,
path: "".to_string(),
algo: "".to_string(),
params: "".to_string(),
program_id,
output_deserialization_schema: vec![],
respond_serialization_schema: vec![],
}),
),
)
.await;

Expand Down
21 changes: 19 additions & 2 deletions chain-signatures/node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::rpc::{ContractStateWatcher, NearClient, RpcExecutor};
use crate::storage::app_data_storage;
use crate::storage::checkpoint_storage::CheckpointStorage;
use crate::storage::triple_storage::TriplePair;
use crate::{indexer, indexer_eth, indexer_sol, logs, mesh, storage, web};
use crate::{indexer, indexer_eth, indexer_hydration, indexer_sol, logs, mesh, storage, web};

use clap::Parser;
use deadpool_redis::Runtime;
Expand Down Expand Up @@ -64,6 +64,9 @@ pub enum Cli {
/// Solana Indexer options
#[clap(flatten)]
sol: indexer_sol::SolArgs,
/// Hydration Indexer options
#[clap(flatten)]
hydration: indexer_hydration::HydrationArgs,
/// NEAR requests options
#[clap(flatten)]
indexer_options: indexer::Options,
Expand Down Expand Up @@ -106,6 +109,7 @@ impl Cli {
sign_sk,
eth,
sol,
hydration,
indexer_options,
my_address,
storage_options,
Expand Down Expand Up @@ -152,6 +156,7 @@ impl Cli {

args.extend(eth.into_str_args());
args.extend(sol.into_str_args());
args.extend(hydration.into_str_args());
args.extend(indexer_options.into_str_args());
args.extend(storage_options.into_str_args());
args.extend(log_options.into_str_args());
Expand All @@ -175,6 +180,7 @@ pub async fn run(cmd: Cli) -> anyhow::Result<()> {
sign_sk,
eth,
sol,
hydration,
indexer_options,
my_address,
storage_options,
Expand Down Expand Up @@ -264,11 +270,13 @@ pub async fn run(cmd: Cli) -> anyhow::Result<()> {

let eth = eth.into_config();
let sol = sol.into_config();
let hydration = hydration.into_config();
let network = NetworkConfig { cipher_sk, sign_sk };
let near_client =
NearClient::new(&near_rpc, &my_address, &network, &mpc_contract_id, signer);

let (rpc_channel, rpc) = RpcExecutor::new(&near_client, &eth, &sol, backlog.clone());
let (rpc_channel, rpc) =
RpcExecutor::new(&near_client, &eth, &sol, &hydration, backlog.clone()).await;

let (sync_channel, sync) = SyncTask::new(
&client,
Expand Down Expand Up @@ -370,6 +378,15 @@ pub async fn run(cmd: Cli) -> anyhow::Result<()> {

tokio::spawn(indexer_sol::run(
sol,
sign_tx.clone(),
account_id.clone(),
backlog.clone(),
contract_watcher.clone(),
mesh_state.clone(),
client.clone(),
));
tokio::spawn(indexer_hydration::run(
hydration,
sign_tx,
account_id,
backlog,
Expand Down
Loading
Loading