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
2 changes: 1 addition & 1 deletion .codespell/.codespellrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[codespell]
skip = .git,node_modules,yarn.lock,Cargo.lock,./typescript/helloworld,./rust/main/config,./rust/sealevel/environments/mainnet3/chain-config.json
skip = .git,node_modules,yarn.lock,Cargo.lock,./typescript/helloworld,./rust/main/config,./rust/sealevel/environments/mainnet3/chain-config.json,package-lock.json,StdStorage.t.sol
count =
quiet-level = 3
ignore-words = ./.codespell/ignore.txt
7 changes: 6 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ name: rust
on:
# Triggers the workflow on pushes to main branch
push:
branches: [main]
branches:
- main
- feat/kas-bridge
# Triggers on pull requests
pull_request:
branches:
Expand Down Expand Up @@ -134,3 +136,6 @@ jobs:
- name: Check WASM for hyperlane-core
run: cargo check --release -p hyperlane-core --features=strum,test-utils --target wasm32-unknown-unknown
working-directory: ./rust/main
- name: Check Dymension Kaspa workspace
run: cargo check --release --all-features --all-targets
working-directory: ./dymension/libs/kaspa/
13 changes: 2 additions & 11 deletions dymension/libs/kaspa/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
[workspace]
resolver = "2" # Enables new feature resolver, good practice for new workspaces
version = "0.1.0"
publish = false
# TODO: docs, edition, homepage, license

members = [
Expand All @@ -23,39 +21,32 @@ kaspa-txscript = { git = "https://github.com/dymensionxyz/rusty-kaspa", rev = "a
kaspa-wallet-pskt = { git = "https://github.com/dymensionxyz/rusty-kaspa", rev = "a443c3f" }
kaspa-wrpc-client = { git = "https://github.com/dymensionxyz/rusty-kaspa", rev = "a443c3f" }
kaspa-addresses = { git = "https://github.com/dymensionxyz/rusty-kaspa", rev = "a443c3f" }
kaspa-bip32 = { git = "https://github.com/dymensionxyz/rusty-kaspa", rev = "a443c3f" }
kaspa-wallet-core = { git = "https://github.com/dymensionxyz/rusty-kaspa", rev = "a443c3f" }
kaspa-wallet-keys = { git = "https://github.com/dymensionxyz/rusty-kaspa", rev = "a443c3f" }
kaspa-rpc-core = { git = "https://github.com/dymensionxyz/rusty-kaspa", rev = "a443c3f" }
kaspa-core = { git = "https://github.com/dymensionxyz/rusty-kaspa", rev = "a443c3f" }
kaspa-grpc-client = { git = "https://github.com/dymensionxyz/rusty-kaspa", rev = "a443c3f" }
kaspa-notify = { git = "https://github.com/dymensionxyz/rusty-kaspa", rev = "a443c3f" }
kaspa-hashes = { git = "https://github.com/dymensionxyz/rusty-kaspa", rev = "a443c3f" }


api-rs = { path = "../api", package = "openapi" }

secp256k1 = { version = "0.29.0", features = ["global-context", "rand-std", "serde"] }
serde_json = "1.0.107"
tokio = { version = "1.36", features = ["full"] }
clap = "4.5.39"
log = "0.4.20"
faster-hex = "0.9.0"
bip39 = "2.1.0"
workflow-core = { version = "0.18.0" }
tracing = { version = "0.1" }
tracing-error = "0.2"
tracing-futures = "0.2"
tracing-subscriber = { version = "0.3", default-features = false }
tracing-test = "0.2.2"
# reqwest = "0.11"
reqwest = { version = "0.12", default-features = false, features = ["json", "multipart"] } # had to use 0.12 to be compatible with open ai generation
bytes = "1"
reqwest-middleware = "0.4"
hex = "0.4.3"

# HYPERLANE
axum = "0.8.4"
url = "2.3"
eyre = "=0.6.8"

# HYPERLANE
hyperlane-cosmos-rs = { package = "hyperlane-cosmos-dymension-rs", git = "https://github.com/dymensionxyz/hyperlane-cosmos-rs", rev = "d7fcf4b" }
12 changes: 6 additions & 6 deletions dymension/libs/kaspa/demo/multisig/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ async fn load_wallet(args: &Args, url: Option<&str>) -> Result<EasyKaspaWallet>
"184.190.99.128",
"157.90.201.188",
] {
for pre in vec!["", "http://", "https://", "ws://", "wss://"] {
for suf in vec!["", ":16210", ":17210"] {
for pre in ["", "http://", "https://", "ws://", "wss://"] {
for suf in ["", ":16210", ":17210"] {
let full_url: String = match url {
Some(url) => url.to_string(),
None => format!("{}{}{}", pre, u, suf),
None => format!("{pre}{u}{suf}"),
};
let w = EasyKaspaWallet::try_new(EasyKaspaWalletArgs {
wallet_secret: args.wallet_secret.as_ref().unwrap().clone(),
Expand All @@ -113,8 +113,8 @@ async fn load_wallet(args: &Args, url: Option<&str>) -> Result<EasyKaspaWallet>
})
.await;
if w.is_ok() {
println!("Connected to wallet at {}", full_url);
return Ok(w.unwrap());
println!("Connected to wallet at {full_url}");
return w;
}
}
}
Expand Down Expand Up @@ -239,6 +239,6 @@ async fn demo() -> Result<()> {
#[tokio::main]
async fn main() {
if let Err(e) = demo().await {
eprintln!("Error: {}", e);
eprintln!("Error: {e}");
}
}
16 changes: 9 additions & 7 deletions dymension/libs/kaspa/demo/relayer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,23 @@ use x::deposit::{demo, DemoArgs};
async fn main() {
let args = Args::parse();

let mut demo_args = DemoArgs::default();
demo_args.payload = args.payload;
demo_args.only_deposit = args.only_deposit;
demo_args.wallet_secret = args.wallet_secret.unwrap_or("".to_string());
let amt = args.amount.unwrap_or(DEPOSIT_AMOUNT);

let escrow_address = if let Some(e) = args.escrow_address {
Address::try_from(e).unwrap()
} else {
Address::try_from(ESCROW_ADDRESS).unwrap()
};

demo_args.amt = amt;
demo_args.escrow_address = escrow_address;
let demo_args = DemoArgs {
amt,
escrow_address,
payload: args.payload,
only_deposit: args.only_deposit,
wallet_secret: args.wallet_secret.unwrap_or("".to_string()),
};

if let Err(e) = demo(demo_args).await {
eprintln!("Error: {}", e);
eprintln!("Error: {e}");
}
}
4 changes: 2 additions & 2 deletions dymension/libs/kaspa/demo/relayer/src/x/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ impl Args {
.get_one::<String>("rpcserver")
.cloned()
.unwrap_or("localhost:16210".to_owned()),
only_deposit: only_deposit,
only_deposit,
payload: m.get_one::<String>("payload").cloned(),
escrow_address: m.get_one::<String>("escrow-address").cloned(),
amount: amount,
amount,
}
}
}
6 changes: 3 additions & 3 deletions dymension/libs/kaspa/demo/user/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ async fn run(cli: Cli) {
match cli.command {
Commands::Recipient(args) => {
let converted = x::addr::hl_recipient(&args.address);
println!("{}", converted);
println!("{converted}",);
}
Commands::Deposit(args) => {
let res = x::deposit::do_deposit(args.to_deposit_args()).await;
if let Err(e) = res {
eprintln!("Error: {}", e);
eprintln!("Error: {e}");
}
}
Commands::Escrow(args) => {
Expand All @@ -25,7 +25,7 @@ async fn run(cli: Cli) {
.map(|s| s.trim())
.collect::<Vec<_>>();
let e = x::escrow::get_escrow_address(pub_keys, args.required_signatures);
println!("Escrow address: {}", e);
println!("Escrow address: {e}");
}
Commands::Validator(args) => {
let mut infos = vec![];
Expand Down
2 changes: 1 addition & 1 deletion dymension/libs/kaspa/demo/user/src/sim/demo.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use super::sim::Params;
use super::util::{as_kas, SOMPI_PER_KAS};
use rand::Rng;
use rand_distr::Distribution;
use std::time::Duration;

#[allow(dead_code)]
pub fn do_demo_params() {
demo_params(Params {
time_limit: Duration::from_secs(60),
Expand Down
13 changes: 0 additions & 13 deletions dymension/libs/kaspa/demo/user/src/sim/key_cosmos.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
use super::stats::RoundTripStats;
use corelib::user::deposit::deposit_with_payload;
use corelib::user::payload::make_deposit_payload_easy;
use corelib::wallet::EasyKaspaWallet;
use cosmrs::crypto::secp256k1::SigningKey;
use eyre::Result;
use hyperlane_core::AccountAddressType;
use hyperlane_core::H256;
use hyperlane_cosmos_native::signers::Signer;
use hyperlane_cosmos_native::GrpcProvider as CosmosGrpcClient;
use k256::ecdsa::SigningKey as K256SigningKey;
use kaspa_addresses::Address;
use kaspa_consensus_core::tx::TransactionId;
use rand_core::OsRng;
use std::str::FromStr;
use std::sync::Arc;
use tokio::sync::mpsc;

pub struct EasyHubKey {
k: K256SigningKey,
Expand Down
2 changes: 0 additions & 2 deletions dymension/libs/kaspa/demo/user/src/sim/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ mod round_trip;
mod sim;
mod stats;
mod util;
pub use demo::do_demo_params;
pub use round_trip::TaskArgs;
pub use sim::*;
30 changes: 8 additions & 22 deletions dymension/libs/kaspa/demo/user/src/sim/round_trip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@ use super::stats::RoundTripStats;
use corelib::user::deposit::deposit_with_payload;
use corelib::user::payload::make_deposit_payload_easy;
use corelib::wallet::EasyKaspaWallet;
use cosmrs::crypto::secp256k1::SigningKey;
use eyre::Result;
use hyperlane_core::AccountAddressType;
use hyperlane_core::H256;
use hyperlane_cosmos_native::signers::Signer;
use hyperlane_cosmos_native::GrpcProvider as CosmosGrpcClient;
use k256::ecdsa::SigningKey as K256SigningKey;
use kaspa_addresses::Address;
use kaspa_consensus_core::tx::TransactionId;
use rand_core::OsRng;
use std::str::FromStr;
use std::sync::Arc;
use tokio::sync::mpsc;

Expand All @@ -40,33 +33,26 @@ Stages

Measure the time gaps, and record failures
*/
pub async fn do_round_trip(
res: Arc<TaskResources>,
value: u64,
tx: mpsc::Sender<RoundTripStats>,
task_id: u64,
) {
let mut rt = RoundTrip::new(res, value);
rt.deposit().await;
rt.await_hub_credit().await;
rt.withdraw().await;
rt.await_kaspa_credit().await;
pub async fn do_round_trip(res: Arc<TaskResources>, tx: mpsc::Sender<RoundTripStats>) {
let mut rt = RoundTrip::new(res);
let _ = rt.deposit().await;
let _ = rt.await_hub_credit().await;
let _ = rt.withdraw().await;
let _ = rt.await_kaspa_credit().await;
tx.send(rt.stats).await.unwrap();
}

struct RoundTrip {
res: Arc<TaskResources>,
value: u64,
stats: RoundTripStats,
hub_key: EasyHubKey,
}

impl RoundTrip {
pub fn new(res: Arc<TaskResources>, value: u64) -> Self {
pub fn new(res: Arc<TaskResources>) -> Self {
let hub_k = EasyHubKey::new();
Self {
res,
value,
stats: RoundTripStats::new(),
hub_key: hub_k,
}
Expand All @@ -86,7 +72,7 @@ impl RoundTrip {
amt,
&self.hub_key.signer(),
);
let tx_id = deposit_with_payload(&w.wallet, &s, a, amt, payload).await?;
let tx_id = deposit_with_payload(&w.wallet, s, a, amt, payload).await?;
self.stats.kaspa_deposit_tx_id = tx_id;
Ok(tx_id)
}
Expand Down
13 changes: 3 additions & 10 deletions dymension/libs/kaspa/demo/user/src/sim/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@ use super::round_trip::TaskArgs;
use super::round_trip::TaskResources;
use super::stats::render_stats;
use super::util::as_kas;
use corelib::wallet::get_wallet;
use crate::x::args::{SimulateTrafficCli, WalletCli};
use corelib::wallet::EasyKaspaWallet;
use corelib::wallet::{EasyKaspaWalletArgs, Network};
use eyre::Result;
use hyperlane_cosmos_native::GrpcProvider as CosmosGrpcClient;
use kaspa_consensus_core::network::NetworkId;
use kaspa_wallet_keys::secret::Secret;
use rand_distr::{Distribution, Exp};
use std::str::FromStr;
use std::sync::Arc;
use std::time::{Duration, Instant};
use tokio::sync::mpsc;

use crate::x::args::{SimulateTrafficCli, WalletCli};
use corelib::wallet::{EasyKaspaWalletArgs, Network};
use tracing::info;

pub struct Params {
Expand Down Expand Up @@ -122,9 +116,8 @@ impl TrafficSim {
let nominal_value = self.params.distr_value().sample(&mut rng) as u64;
let tx_clone = stats_tx.clone();
let r = self.resources.clone();
let task_id = total_ops;
tokio::spawn(async move {
do_round_trip(r, nominal_value, tx_clone, task_id).await;
do_round_trip(r, tx_clone).await;
});
total_spend += nominal_value;
total_ops += 1;
Expand Down
2 changes: 1 addition & 1 deletion dymension/libs/kaspa/demo/user/src/sim/stats.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use kaspa_consensus_core::tx::TransactionId;

pub fn render_stats(stats: Vec<RoundTripStats>, total_spend: u64, total_ops: u64) {
pub fn render_stats(stats: Vec<RoundTripStats>, _: u64, _: u64) {
for s in stats {
println!("kaspa_deposit_tx_id: {}", s.kaspa_deposit_tx_id);
}
Expand Down
2 changes: 1 addition & 1 deletion dymension/libs/kaspa/demo/user/src/x/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub fn hl_recipient(kaspa_addr: &str) -> String {
let addr = Address::try_from(kaspa_addr).unwrap();
let bz = addr.payload.as_slice();
let bz_hex = hex::encode(bz);
let s = format!("0x{}", bz_hex);
let s = format!("0x{bz_hex}");
s
}

Expand Down
3 changes: 0 additions & 3 deletions dymension/libs/kaspa/demo/user/src/x/args.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
use super::deposit::DepositArgs;
use crate::sim::{Params, SimulateTrafficArgs, TaskArgs};
use clap::{Args, Parser, Subcommand};
use hyperlane_core::H256;
use kaspa_addresses::Address;
use kaspa_consensus_core::network::NetworkId;
use std::str::FromStr;
use std::time::Duration;

#[derive(Parser, Debug)]
#[command(
Expand Down
5 changes: 2 additions & 3 deletions dymension/libs/kaspa/demo/user/src/x/escrow.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use corelib::escrow::generate_escrow_priv_key;
use corelib::escrow::EscrowPublic;
use corelib::escrow::{generate_escrow_priv_key, Escrow};
use corelib::KaspaSecpKeypair;
use kaspa_addresses::Prefix;
use secp256k1::PublicKey;
use serde::{Deserialize, Serialize};
use serde::Serialize;
use std::str::FromStr;
use validator::signer::get_ethereum_style_signer;

Expand Down
2 changes: 2 additions & 0 deletions dymension/libs/kaspa/lib/api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![allow(unused_imports)]
#![allow(non_snake_case)]
#![allow(clippy::all)] // disable clippy for codegen
#![allow(clippy::too_many_arguments)]

extern crate reqwest;
Expand Down
Loading