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

feat(zcoin): ARRR WASM implementation #1957

Merged
merged 124 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
9624b52
save dev state — impl get_latest_block
borngraced Jun 9, 2023
74475d4
save dev state — impl insert_block
borngraced Jun 9, 2023
0df0b74
save dev state — impl rewind_to_height
borngraced Jun 9, 2023
82ea381
save dev state — impl with_blocks
borngraced Jun 9, 2023
e143d36
save dev state — impl some unit tests
borngraced Jun 13, 2023
aa890a4
minor changes
borngraced Jun 13, 2023
4187ca9
impl simple unit test for with_blocks
borngraced Jun 19, 2023
ecca8ea
save dev state
borngraced Aug 22, 2023
02af3d5
save dev state — validate_blocks and scan_cached_block porting succes…
borngraced Aug 22, 2023
00b0ec6
Merge remote-tracking branch 'origin/dev' into blockdb_indexeddb_storage
borngraced Aug 22, 2023
af2b1d7
port scan_cached_block and validate_blocks to mm2
borngraced Aug 24, 2023
e039d56
save dev state
borngraced Aug 26, 2023
fbb61ea
save dev state — apply fixes from librustzcash
borngraced Aug 27, 2023
6fc8697
save dev state — refactor wallet db storage module
borngraced Aug 28, 2023
67c30b4
save dev state — fix linting
borngraced Aug 28, 2023
fcce1c6
walletdb — impl block_height_extrema, get_block_hash, get_tx_height
borngraced Aug 29, 2023
67102ef
walletdb — impl get_balance_at, get_memo
borngraced Aug 29, 2023
1dbb508
walletdb — impl get_commitment_tree, get_witnesses
borngraced Aug 29, 2023
7de42b1
refactor zcoin storage error
borngraced Aug 30, 2023
020b47c
walletdb — impl get_nullifiers
borngraced Aug 30, 2023
97a10e9
save dev state
borngraced Aug 30, 2023
0e0915c
save dev state — use BigInt for i64 values
borngraced Aug 31, 2023
cd6ad5f
walletdb — impl select_spendable_notes
borngraced Aug 31, 2023
573b52f
walletdb — save dev state (advance_by_block wip)
borngraced Aug 31, 2023
b3c1347
cleanup for overall impls
borngraced Sep 1, 2023
5c3e589
Merge remote-tracking branch 'origin/dev' into blockdb_indexeddb_storage
borngraced Sep 1, 2023
c25a34a
cleanup for overall impls
borngraced Sep 1, 2023
2da2e2c
fix wasm clippy warnings
borngraced Sep 3, 2023
b80bbc3
walletdb — implemented put_received_note && insert_witness
borngraced Sep 4, 2023
af1e88f
walletdb — implemented prune_witnesses
borngraced Sep 4, 2023
7d434a7
fix unit tests
borngraced Sep 4, 2023
1c4df5d
walletdb — impl update_expired_notes
borngraced Sep 4, 2023
24774ad
walletdb — impl advance_by_block
borngraced Sep 5, 2023
b908555
fix clippy warning
borngraced Sep 5, 2023
23e8bc7
save dev state
borngraced Sep 5, 2023
920ca89
fix review notes and add doc comments
borngraced Sep 5, 2023
4396023
refactor indexeddb TableSignature TABLE_NAME
borngraced Sep 5, 2023
909c1d7
fix failing blockdb tests
borngraced Sep 5, 2023
c4f44bb
fix review notes
borngraced Sep 6, 2023
6f3dade
walletdb — finished WalletWrite and WalletRead implementations for in…
borngraced Sep 6, 2023
0a50ab3
walletdb — cleanup after self review round 1
borngraced Sep 7, 2023
7743f14
Merge remote-tracking branch 'origin/dev' into zcoin_storage
borngraced Sep 7, 2023
8cd1cc3
fix conflicts
borngraced Sep 7, 2023
4d708eb
implement init walletdb for indexedddb
borngraced Sep 7, 2023
5af48d8
fix blockdb unit tests
borngraced Sep 9, 2023
31737e3
save dev state — test_intialize_db_impl
borngraced Sep 12, 2023
f2cab39
save dev state
borngraced Sep 13, 2023
7004e70
impl test_intialize_wallet_db_impl
borngraced Sep 13, 2023
c5dc508
walletdb - implement all init unit tests
borngraced Sep 13, 2023
93cba48
fix fmt warning
borngraced Sep 13, 2023
40d9735
save dev state - implementing test_valid_chain_state
borngraced Sep 13, 2023
34e8940
save dev state
borngraced Sep 14, 2023
60315a3
save dev state - impl test_valid_chain_state
borngraced Sep 14, 2023
a56e802
walletdb - implemented all chain tests!
borngraced Sep 14, 2023
62efac1
fix wasm clippy warning
borngraced Sep 15, 2023
653b4e8
save dev state
borngraced Sep 15, 2023
ead00e0
Merge branch 'zcoin_storage' of github.com:KomodoPlatform/komodo-defi…
borngraced Sep 15, 2023
ccc45df
save dev state
borngraced Sep 16, 2023
641120b
save dev state
borngraced Sep 16, 2023
4d58482
cleanup
borngraced Sep 18, 2023
45aa2f7
minor changes
borngraced Sep 18, 2023
54f6dba
refactor wams mod
borngraced Sep 18, 2023
62aa5fa
save dev state
borngraced Sep 20, 2023
8fbd911
save dev state
borngraced Sep 21, 2023
ad888e7
save dev state
borngraced Sep 24, 2023
55a62a3
minor changes
borngraced Sep 25, 2023
9dd53f1
fix cargo toml
borngraced Sep 25, 2023
eb74f06
minor fix and impl is_tx_imported
borngraced Oct 2, 2023
f7b03d0
Merge remote-tracking branch 'origin/dev' into zcoin_storage
borngraced Oct 2, 2023
e156699
fix merge conflicts
borngraced Oct 2, 2023
14c1c68
fix review notes
borngraced Oct 3, 2023
dc1d7d4
fix review notes
borngraced Oct 4, 2023
230d4d5
fix review notes
borngraced Oct 6, 2023
3b8920f
remove unnecessary clone
borngraced Oct 11, 2023
cf6891b
Merge remote-tracking branch 'origin/dev' into zcoin_storage
borngraced Oct 25, 2023
532d901
use LocalTxProver::from_bytes directly for creating LocalTxProver
borngraced Nov 1, 2023
3c01ae0
update librustzcash crate
borngraced Nov 7, 2023
92e7014
merge branch and fix conflicts
borngraced Nov 7, 2023
8a7cb8c
fix DbInstance trait impl for zcoin storages
borngraced Nov 7, 2023
a207ea8
lock librustzcash crate
borngraced Nov 7, 2023
9ac0af8
fix review notes
borngraced Nov 8, 2023
bbe0461
minor fixes
borngraced Nov 9, 2023
c1ed8cb
fix review notes
borngraced Nov 9, 2023
b52ee2b
open connection in async blocking and fix review notes
borngraced Nov 10, 2023
5382464
fix review notes
borngraced Nov 16, 2023
35b5a81
add comment for walletdb wasm tx tests
borngraced Nov 16, 2023
272f46b
Merge remote-tracking branch 'origin/dev' into zcoin_storage
borngraced Nov 27, 2023
1a64a9c
Merge remote-tracking branch 'origin/dev' into zcoin_storage
borngraced Dec 21, 2023
3d80b3a
feat(zcoin): implement zcoin/pirate transport layer for WASM (#1996)
borngraced Dec 22, 2023
d45246c
Merge remote-tracking branch 'origin/dev' into zcoin_storage
borngraced Dec 22, 2023
e1bc113
fix merge conflicts
borngraced Dec 22, 2023
b2187c9
update walletdb unit tests and delete wagyu-zcash-parameters dep
borngraced Dec 22, 2023
05eeb03
fix clippy
borngraced Dec 22, 2023
c5df161
fix unit tests
borngraced Dec 25, 2023
6d45c03
linting
borngraced Dec 26, 2023
a3a3a34
fix typo/doc comments
borngraced Jan 17, 2024
f80a017
Merge branch 'dev' into zcoin_storage
borngraced Jan 17, 2024
b011fea
fix blocks db deadlock
borngraced Jan 22, 2024
cd8f768
impl construct_block_range_requests o fetch block ranges efficiently
borngraced Jan 23, 2024
96a4544
handle block range requests concurrently
borngraced Jan 25, 2024
8c5e185
update PIRATE_LIGHTWALLETD_URLS for unit test
borngraced Jan 25, 2024
32e991e
make get_block_range_wrapper wasm target only
borngraced Jan 25, 2024
c2354ca
revert test_rewind_to_height_impl
borngraced Jan 25, 2024
caafcf1
improve block_height_extrema and rewind_to_height
borngraced Jan 27, 2024
4c87d69
minor changes _skip_sync_params in ZcoinRpcMode::Light
borngraced Jan 27, 2024
c63316f
add skip_sync_params to sync_params and other minor changes
borngraced Jan 28, 2024
9059326
improve and remove unnecessary cloning from scan_validate_and_update_…
borngraced Jan 29, 2024
f9494fd
Merge branch 'dev' into zcoin_storage
borngraced Jan 29, 2024
3f5ff56
make z_p2sh_spend wasm compatible
borngraced Feb 1, 2024
f28d04d
allow accept_gzip compression for light rpc client
borngraced Feb 5, 2024
beebc6a
improve ZRpcOps impls
borngraced Feb 7, 2024
69ddb50
some changes to deps
borngraced Feb 13, 2024
f4f225c
Merge remote-tracking branch 'origin/dev' into zcoin_storage
borngraced Feb 13, 2024
a336ebc
update test_transport to use assert and cargo lock file
borngraced Feb 13, 2024
21d6cf4
Merge branch 'dev' into zcoin_storage
borngraced Feb 17, 2024
b12f2dd
utilise new cursor api and fix big bug in impl :)
borngraced Feb 18, 2024
982f003
update cursor usage
borngraced Feb 19, 2024
665e80c
Merge remote-tracking branch 'origin/dev' into zcoin_storage
borngraced Feb 20, 2024
403365b
handle rewind to height for blockdb as it's done for walletdb
borngraced Feb 22, 2024
ba79025
Merge remote-tracking branch 'origin/dev' into zcoin_storage
borngraced Feb 22, 2024
3dd4e3c
fix merge conflict and minor changes
borngraced Feb 22, 2024
b28e3fa
make WithdrawTask wasm target
borngraced Feb 22, 2024
5664a64
fix bug in WASM get_spendable_notes to properly scan and create spend…
borngraced Feb 23, 2024
6075733
add features = ["wasm-bindgen"] for rand crate in mm2_bitcoin
borngraced Feb 23, 2024
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
89 changes: 83 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions mm2src/coins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ uuid = { version = "1.2.2", features = ["fast-rng", "serde", "v4"] }
# We don't need the default web3 features at all since we added our own web3 transport using shared HYPER instance.
web3 = { git = "https://github.com/KomodoPlatform/rust-web3", tag = "v0.19.0", default-features = false }
zbase32 = "0.1.2"
zcash_client_backend = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.3.0" }
zcash_primitives = { features = ["transparent-inputs"], git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.3.0" }
zcash_proofs = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.3.0" }
zcash_client_backend = { git = "https://github.com/KomodoPlatform/librustzcash.git", rev = "1901f09" }
zcash_extras = { git = "https://github.com/KomodoPlatform/librustzcash.git", rev = "1901f09" }
zcash_primitives = {features = ["transparent-inputs"], git = "https://github.com/KomodoPlatform/librustzcash.git", rev = "1901f09" }
zcash_proofs = { git = "https://github.com/KomodoPlatform/librustzcash.git", rev = "1901f09" }

[target.'cfg(all(not(target_os = "ios"), not(target_os = "android"), not(target_arch = "wasm32")))'.dependencies]
bincode = { version = "1.3.3", default-features = false, optional = true }
Expand All @@ -118,13 +119,17 @@ spl-token = { version = "3", optional = true }
spl-associated-token-account = { version = "1", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
ff = "0.8"
onur-ozkan marked this conversation as resolved.
Show resolved Hide resolved
jubjub = "0.5.1"
js-sys = { version = "0.3.27" }
mm2_db = { path = "../mm2_db" }
mm2_metamask = { path = "../mm2_metamask" }
mm2_test_helpers = { path = "../mm2_test_helpers" }
time = { version = "0.3" }
wasm-bindgen = "0.2.86"
wasm-bindgen-futures = { version = "0.4.1" }
wasm-bindgen-test = { version = "0.3.2" }
wagyu-zcash-parameters = { version = "0.2" }
web-sys = { version = "0.3.55", features = ["console", "Headers", "Request", "RequestInit", "RequestMode", "Response", "Window"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand All @@ -146,7 +151,7 @@ tokio = { version = "1.20" }
tokio-rustls = { version = "0.23" }
tonic = { version = "0.7", features = ["tls", "tls-webpki-roots", "compression"] }
webpki-roots = { version = "0.22" }
zcash_client_sqlite = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.3.0" }
zcash_client_sqlite = { git = "https://github.com/KomodoPlatform/librustzcash.git", rev = "1901f09" }

[target.'cfg(windows)'.dependencies]
winapi = "0.3"
Expand Down
3 changes: 3 additions & 0 deletions mm2src/coins/eth/eth_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ fn eth_coin_for_test(
eth_coin_from_keypair(coin_type, urls, fallback_swap_contract, key_pair)
}

#[cfg(not(target_arch = "wasm32"))]
fn random_eth_coin_for_test(
coin_type: EthCoinType,
urls: &[&str],
Expand Down Expand Up @@ -809,6 +810,7 @@ fn test_search_for_swap_tx_spend_was_refunded() {
assert_eq!(refund_tx, found_tx);
}

#[cfg(not(target_arch = "wasm32"))]
#[test]
fn test_withdraw_impl_manual_fee() {
let (_ctx, coin) = eth_coin_for_test(EthCoinType::Eth, &["http://dummy.dummy"], None);
Expand Down Expand Up @@ -846,6 +848,7 @@ fn test_withdraw_impl_manual_fee() {
assert_eq!(expected, tx_details.fee_details);
}

#[cfg(not(target_arch = "wasm32"))]
#[test]
fn test_withdraw_impl_fee_details() {
let (_ctx, coin) = eth_coin_for_test(
Expand Down
4 changes: 2 additions & 2 deletions mm2src/coins/hd_wallet_storage/wasm_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ pub struct HDAccountTable {
}

impl TableSignature for HDAccountTable {
fn table_name() -> &'static str { "hd_account" }
const TABLE_NAME: &'static str = "hd_account";

fn on_upgrade_needed(upgrader: &DbUpgrader, old_version: u32, new_version: u32) -> OnUpgradeResult<()> {
if let (0, 1) = (old_version, new_version) {
let table = upgrader.create_table(Self::table_name())?;
let table = upgrader.create_table(Self::TABLE_NAME)?;
table.create_multi_index(WALLET_ID_INDEX, &["coin", "hd_wallet_rmd160"], false)?;
table.create_multi_index(
WALLET_ACCOUNT_ID_INDEX,
Expand Down
1 change: 1 addition & 0 deletions mm2src/coins/lp_coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#![feature(hash_raw_entry)]
#![feature(stmt_expr_attributes)]
#![feature(result_flattening)]
#![feature(let_chains)]
shamardy marked this conversation as resolved.
Show resolved Hide resolved

#[macro_use] extern crate common;
#[macro_use] extern crate gstuff;
Expand Down
12 changes: 6 additions & 6 deletions mm2src/coins/nft/storage/wasm/wasm_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,11 +600,11 @@ impl NftListTable {
}

impl TableSignature for NftListTable {
fn table_name() -> &'static str { "nft_list_cache_table" }
const TABLE_NAME: &'static str = "nft_list_cache_table";

fn on_upgrade_needed(upgrader: &DbUpgrader, old_version: u32, new_version: u32) -> OnUpgradeResult<()> {
if is_initial_upgrade(old_version, new_version) {
let table = upgrader.create_table(Self::table_name())?;
let table = upgrader.create_table(Self::TABLE_NAME)?;
table.create_multi_index(
Self::CHAIN_TOKEN_ADD_TOKEN_ID_INDEX,
&["chain", "token_address", "token_id"],
Expand Down Expand Up @@ -668,11 +668,11 @@ impl NftTransferHistoryTable {
}

impl TableSignature for NftTransferHistoryTable {
fn table_name() -> &'static str { "nft_transfer_history_cache_table" }
const TABLE_NAME: &'static str = "nft_transfer_history_cache_table";

fn on_upgrade_needed(upgrader: &DbUpgrader, old_version: u32, new_version: u32) -> OnUpgradeResult<()> {
if is_initial_upgrade(old_version, new_version) {
let table = upgrader.create_table(Self::table_name())?;
let table = upgrader.create_table(Self::TABLE_NAME)?;
table.create_multi_index(
Self::CHAIN_TOKEN_ADD_TOKEN_ID_INDEX,
&["chain", "token_address", "token_id"],
Expand All @@ -698,11 +698,11 @@ pub(crate) struct LastScannedBlockTable {
}

impl TableSignature for LastScannedBlockTable {
fn table_name() -> &'static str { "last_scanned_block_table" }
const TABLE_NAME: &'static str = "last_scanned_block_table";

fn on_upgrade_needed(upgrader: &DbUpgrader, old_version: u32, new_version: u32) -> OnUpgradeResult<()> {
if is_initial_upgrade(old_version, new_version) {
let table = upgrader.create_table(Self::table_name())?;
let table = upgrader.create_table(Self::TABLE_NAME)?;
table.create_index("chain", true)?;
}
Ok(())
Expand Down
12 changes: 9 additions & 3 deletions mm2src/coins/qrc20/qrc20_tests.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
use super::*;
use crate::utxo::rpc_clients::UnspentInfo;
use crate::{TxFeeDetails, WaitForHTLCTxSpendArgs};
use chain::OutPoint;
use common::{block_on, wait_until_sec, DEX_FEE_ADDR_RAW_PUBKEY};
use crypto::Secp256k1Secret;
use itertools::Itertools;
use mm2_core::mm_ctx::MmCtxBuilder;
use mm2_number::bigdecimal::Zero;
use mocktopus::mocking::{MockResult, Mockable};
use rpc::v1::types::ToTxHash;
use std::convert::TryFrom;
use std::mem::discriminant;

cfg_native!(
use crate::utxo::rpc_clients::UnspentInfo;

use mocktopus::mocking::{MockResult, Mockable};
use chain::OutPoint;
);

const EXPECTED_TX_FEE: i64 = 1000;
const CONTRACT_CALL_GAS_FEE: i64 = (QRC20_GAS_LIMIT_DEFAULT * QRC20_GAS_PRICE_DEFAULT) as i64;
const SWAP_PAYMENT_GAS_FEE: i64 = (QRC20_PAYMENT_GAS_LIMIT * QRC20_GAS_PRICE_DEFAULT) as i64;
Expand Down Expand Up @@ -57,6 +61,7 @@ fn check_tx_fee(coin: &Qrc20Coin, expected_tx_fee: ActualTxFee) {
assert_eq!(actual_tx_fee, expected_tx_fee);
}

#[cfg(not(target_arch = "wasm32"))]
shamardy marked this conversation as resolved.
Show resolved Hide resolved
#[test]
fn test_withdraw_to_p2sh_address_should_fail() {
let priv_key = [
Expand Down Expand Up @@ -88,6 +93,7 @@ fn test_withdraw_to_p2sh_address_should_fail() {
assert_eq!(err, expect);
}

#[cfg(not(target_arch = "wasm32"))]
#[test]
fn test_withdraw_impl_fee_details() {
Qrc20Coin::get_unspent_ordered_list.mock_safe(|coin, _| {
Expand Down
4 changes: 2 additions & 2 deletions mm2src/coins/tx_history_storage/wasm/tx_history_storage_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ pub(crate) struct TxHistoryTableV1 {
}

impl TableSignature for TxHistoryTableV1 {
fn table_name() -> &'static str { "tx_history" }
const TABLE_NAME: &'static str = "tx_history";

fn on_upgrade_needed(upgrader: &DbUpgrader, old_version: u32, new_version: u32) -> OnUpgradeResult<()> {
if let (0, 1) = (old_version, new_version) {
let table = upgrader.create_table(Self::table_name())?;
let table = upgrader.create_table(Self::TABLE_NAME)?;
table.create_index("history_id", true)?;
}

Expand Down
Loading
Loading