From 4d7429bc5452b5f15ec1a69deac2441a9f7cde5b Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Tue, 9 Apr 2024 15:48:31 +0100 Subject: [PATCH] trying to fix float number --- Cargo.lock | 48 ++----------------- Cargo.toml | 1 - contracts/cosmwasm/executor/Cargo.toml | 2 +- contracts/cosmwasm/executor/src/contract.rs | 2 +- contracts/cosmwasm/order/Cargo.toml | 1 - crates/cvm-runtime/Cargo.toml | 4 +- crates/cvm/Cargo.toml | 4 +- crates/cvm/src/asset.rs | 2 +- mantis/node/Cargo.lock | 26 ---------- mantis/node/Cargo.toml | 2 +- mantis/node/src/mantis/autopilot.rs | 2 +- mantis/node/src/mantis/blackbox/mod.rs | 4 +- mantis/node/src/mantis/cosmos/client.rs | 5 +- mantis/node/src/mantis/solve.rs | 9 ++-- .../node/src/solver/router/shortest_path.rs | 2 - 15 files changed, 20 insertions(+), 94 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7607a519..261f6da9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -724,7 +724,7 @@ dependencies = [ "cw-storage-plus 1.2.0", "derive_more", "hex", - "num", + "num-traits", "parity-scale-codec", "prost", "prost-build", @@ -770,8 +770,7 @@ dependencies = [ "ibc-core-host-types", "ibc-primitives", "ibc-proto 0.42.2", - "num", - "num-rational 0.4.1 (git+https://github.com/dzmitry-lahoda-forks/num-rational.git?rev=719b4dbe0afd69b98f5875e3bdf936b9df822522)", + "num-rational", "parity-scale-codec", "prost", "prost-build", @@ -832,7 +831,7 @@ dependencies = [ "cw20 1.1.2", "hex", "ibc-apps-more", - "num", + "num-traits", "prost", "schemars", "serde", @@ -880,7 +879,7 @@ dependencies = [ "mantis-cw", "no-panic", "num-integer", - "num-rational 0.4.1 (git+https://github.com/dzmitry-lahoda-forks/num-rational.git?rev=719b4dbe0afd69b98f5875e3bdf936b9df822522)", + "num-rational", "schemars", "serde", "sha2 0.10.8", @@ -2308,7 +2307,7 @@ dependencies = [ "log", "mantis-cw", "ndarray", - "num-rational 0.4.1 (git+https://github.com/dzmitry-lahoda-forks/num-rational.git?rev=719b4dbe0afd69b98f5875e3bdf936b9df822522)", + "num-rational", "num-traits", "petgraph", "prost-types", @@ -2405,20 +2404,6 @@ dependencies = [ "syn 2.0.52", ] -[[package]] -name = "num" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" -dependencies = [ - "num-bigint", - "num-complex", - "num-integer", - "num-iter", - "num-rational 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits", -] - [[package]] name = "num-bigint" version = "0.4.4" @@ -2470,29 +2455,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d03e6c028c5dc5cac6e2dec0efda81fc887605bb3d884578bb6d6bf7514e252" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - -[[package]] -name = "num-rational" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" -dependencies = [ - "autocfg", - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-rational" version = "0.4.1" diff --git a/Cargo.toml b/Cargo.toml index df4fcb01..f5a7994f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -90,7 +90,6 @@ cw-multi-test = {version = "^1.0.0", default-features = false} num-integer = { version = "^0.1.46", default-features = false } num-rational = {git = "https://github.com/dzmitry-lahoda-forks/num-rational.git", rev = "719b4dbe0afd69b98f5875e3bdf936b9df822522", default-features = false} num-traits = { version = "^0.2.18", default-features = false } -num = { version = "^0.4.1", default-features = false } ibc-proto = { version = "^0.42.2", default-features = false } diff --git a/contracts/cosmwasm/executor/Cargo.toml b/contracts/cosmwasm/executor/Cargo.toml index 9f410a5e..7f9011af 100644 --- a/contracts/cosmwasm/executor/Cargo.toml +++ b/contracts/cosmwasm/executor/Cargo.toml @@ -46,7 +46,6 @@ cosmwasm-schema = { workspace = true, optional = true } cw-utils = { workspace = true } cw2 = { workspace = true } cw20 = { workspace = true } -num = { workspace = true } hex = { workspace = true, default-features = false, features = ["alloc"] } schemars = { workspace = true } serde = { workspace = true } @@ -58,6 +57,7 @@ cvm-runtime = { path = "../../../crates/cvm-runtime", features = [ "cosmwasm", "cosmos", ], default-features = false } +num-traits = { workspace = true } cvm-route = { path = "../../../crates/cvm-route", features = [ "cosmwasm", diff --git a/contracts/cosmwasm/executor/src/contract.rs b/contracts/cosmwasm/executor/src/contract.rs index fe32bfce..9ad946b4 100644 --- a/contracts/cosmwasm/executor/src/contract.rs +++ b/contracts/cosmwasm/executor/src/contract.rs @@ -26,7 +26,7 @@ use cvm_runtime::{ use cvm_runtime::{executor::*, shared::CvmAddress}; use cw2::{ensure_from_older_version, set_contract_version}; use cw20::{BalanceResponse, Cw20Contract, Cw20ExecuteMsg, Cw20QueryMsg}; -use num::Zero; +use num_traits::Zero; const CONTRACT_NAME: &str = include_str!("contract_name.txt"); const CONTRACT_VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/contracts/cosmwasm/order/Cargo.toml b/contracts/cosmwasm/order/Cargo.toml index 16d098a0..ff6c0471 100644 --- a/contracts/cosmwasm/order/Cargo.toml +++ b/contracts/cosmwasm/order/Cargo.toml @@ -43,7 +43,6 @@ sha2 = {workspace = true, default-features = false, features = ["std"] } no-panic = { workspace = true } tuples = { workspace = true } num-rational = { workspace = true, default-features = false, features = [ - "num-bigint-std", "serde", ] } diff --git a/crates/cvm-runtime/Cargo.toml b/crates/cvm-runtime/Cargo.toml index a6570073..50554dd6 100644 --- a/crates/cvm-runtime/Cargo.toml +++ b/crates/cvm-runtime/Cargo.toml @@ -19,8 +19,7 @@ ibc-app-transfer-types = { workspace = true, features = [ "parity-scale-codec", ] } ibc-core-host-types = { workspace = true, features = ["serde"] } -num = { workspace = true } -num-rational = { workspace = true } +num-rational = { workspace = true, default-features = false} parity-scale-codec = { workspace = true, optional = true } prost = { workspace = true, features = ["prost-derive"] } scale-info = { workspace = true, features = ["derive"], optional = true } @@ -86,6 +85,5 @@ std = [ "ibc-app-transfer-types/schema", "ibc-core-host-types/schema", "ibc-primitives/schema", - "num/std", "thiserror/std", ] diff --git a/crates/cvm/Cargo.toml b/crates/cvm/Cargo.toml index 9634b59f..908a140a 100644 --- a/crates/cvm/Cargo.toml +++ b/crates/cvm/Cargo.toml @@ -10,16 +10,15 @@ cosmwasm-schema = { workspace = true, optional = true } cosmwasm-std = { workspace = true, no-default-features = true, optional = true} cw-storage-plus = { workspace = true, optional = true} -# num = { workspace = true, optional = false} parity-scale-codec = { workspace = true, optional = true } prost = { workspace = true, features = ["prost-derive"] } scale-info = { workspace = true, features = ["derive"], optional = true } schemars = { workspace = true, optional = true } serde = { workspace = true, features = ["alloc", "derive"] } -num = { workspace = true, default-features = false} hex ={ workspace = true, default-features = false, features = ["serde"]} bech32 = { workspace = true, default-features = false} derive_more = { workspace = true, default-features = false} +num-traits = { workspace = true, default-features = false} [dev-dependencies] serde-json-wasm = { workspace = true, default-features = false } @@ -42,5 +41,4 @@ json-schema = [ ] std = [ - "num/std", ] \ No newline at end of file diff --git a/crates/cvm/src/asset.rs b/crates/cvm/src/asset.rs index 25e2f3e8..01da372c 100644 --- a/crates/cvm/src/asset.rs +++ b/crates/cvm/src/asset.rs @@ -6,7 +6,7 @@ use cw_storage_plus::{Key, Prefixer}; use crate::shared::Displayed; use core::ops::Add; use cosmwasm_std::{Uint128, Uint256}; -use num::Zero; +use num_traits::Zero; use serde::{Deserialize, Serialize}; /// Newtype for CVM assets ID. Must be unique for each asset and must never change. diff --git a/mantis/node/Cargo.lock b/mantis/node/Cargo.lock index 8e05ed27..f850e151 100644 --- a/mantis/node/Cargo.lock +++ b/mantis/node/Cargo.lock @@ -638,7 +638,6 @@ dependencies = [ "cosmwasm-std", "derive_more", "hex", - "num", "prost-build", "schemars", "serde", @@ -1441,30 +1440,6 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" -[[package]] -name = "num" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" -dependencies = [ - "num-complex", - "num-integer", - "num-iter", - "num-rational", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" -dependencies = [ - "autocfg", - "num-integer", - "num-traits", -] - [[package]] name = "num-complex" version = "0.4.4" @@ -1513,7 +1488,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", - "num-bigint", "num-integer", "num-traits", ] diff --git a/mantis/node/Cargo.toml b/mantis/node/Cargo.toml index 564c67eb..87be164c 100644 --- a/mantis/node/Cargo.toml +++ b/mantis/node/Cargo.toml @@ -47,7 +47,7 @@ ndarray ={ workspace = true, features = ["std", "serde"]} env_logger = {workspace = true} cw-multi-test = { workspace = true } petgraph = {workspace = true} -num-rational = {workspace = true, features = ["cosmwasm", "serde", "json-schema"]} +num-rational = {workspace = true, features = ["cosmwasm", "serde", "json-schema"], default-features = false} [dev-dependencies] diff --git a/mantis/node/src/mantis/autopilot.rs b/mantis/node/src/mantis/autopilot.rs index 71465d7e..2984a6bf 100644 --- a/mantis/node/src/mantis/autopilot.rs +++ b/mantis/node/src/mantis/autopilot.rs @@ -11,7 +11,7 @@ use crate::{ use super::cosmos::client::{CosmWasmWriteClient, CosmosChainInfo, CosmosQueryClient, Tip}; pub async fn cleanup( - write_client: &mut CosmWasmWriteClient, + _write_client: &mut CosmWasmWriteClient, _cosmos_query_client: &mut CosmosQueryClient, order_contract: String, signing_key: &cosmrs::crypto::secp256k1::SigningKey, diff --git a/mantis/node/src/mantis/blackbox/mod.rs b/mantis/node/src/mantis/blackbox/mod.rs index 45dd169c..1e26d375 100644 --- a/mantis/node/src/mantis/blackbox/mod.rs +++ b/mantis/node/src/mantis/blackbox/mod.rs @@ -2,7 +2,7 @@ use blackbox_rs::{types::*, Client}; /// Given total amount it, order owners and desired out, produce CVM program from and by requesting route use cvm_runtime::{ outpost::GetConfigResponse, - shared::{CvmAddress, CvmFundsFilter, CvmInstruction, CvmProgram, Displayed}, + shared::{CvmFundsFilter, CvmInstruction, CvmProgram,}, Amount, }; @@ -22,7 +22,7 @@ fn build_next( NextItem::Exchange(exchange) => { let exchange = new_exchange(exchange); current.instructions.push(exchange); - build_next(current, rest, &glt, salt); + build_next(current, rest, glt, salt); } NextItem::Spawn(spawn) => { let mut program = CvmProgram::default(); diff --git a/mantis/node/src/mantis/cosmos/client.rs b/mantis/node/src/mantis/cosmos/client.rs index c6874569..317cd2f5 100644 --- a/mantis/node/src/mantis/cosmos/client.rs +++ b/mantis/node/src/mantis/cosmos/client.rs @@ -105,13 +105,12 @@ pub async fn get_latest_block_and_account_by_key( /// latest chain state pub async fn get_latest_block(rpc: &str) -> cosmrs::tendermint::block::Height { let rpc_client: cosmrs::rpc::HttpClient = cosmrs::rpc::HttpClient::new(rpc).unwrap(); - let status = rpc_client + rpc_client .status() .await .expect("status") .sync_info - .latest_block_height; - status + .latest_block_height } pub async fn sign_and_tx_tendermint( diff --git a/mantis/node/src/mantis/solve.rs b/mantis/node/src/mantis/solve.rs index 6b894df9..11be8f16 100644 --- a/mantis/node/src/mantis/solve.rs +++ b/mantis/node/src/mantis/solve.rs @@ -1,11 +1,10 @@ -use core::num; use cvm_runtime::{ outpost::GetConfigResponse, - shared::{CvmAddress, CvmBalanceFilter, CvmFunds, CvmFundsFilter, CvmInstruction, Displayed}, - Amount, AssetId, Destination, + shared::{CvmAddress, CvmBalanceFilter, CvmFundsFilter, CvmInstruction, Displayed}, + AssetId, Destination, }; -use cw_mantis_order::{CrossChainPart, OrderAmount, OrderItem, OrderSolution, OrderSubMsg}; -use mantis_cw::{DenomPair, OrderCoinPair, OrderSide, OrderedTuple2}; +use cw_mantis_order::{OrderAmount, OrderItem, OrderSolution,}; +use mantis_cw::{DenomPair, OrderCoinPair,}; use num_rational::Ratio; use crate::{ diff --git a/mantis/node/src/solver/router/shortest_path.rs b/mantis/node/src/solver/router/shortest_path.rs index dcec1c5c..4f10509d 100644 --- a/mantis/node/src/solver/router/shortest_path.rs +++ b/mantis/node/src/solver/router/shortest_path.rs @@ -5,9 +5,7 @@ use cvm_route::venue::VenueId; use cvm_runtime::shared::{CvmFundsFilter, CvmInstruction, CvmProgram}; use cvm_runtime::{exchange, AssetId, ExchangeId}; use petgraph::algo::bellman_ford; -use petgraph::dot::{Config, Dot}; use std::collections::BTreeMap; -use std::ops::Deref; // need some how unify with python #[derive(Debug, Clone)]