From ee4f738d59a2b811a9fa10ece563e52d188370cf Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Sun, 27 Aug 2023 12:33:56 +0100 Subject: [PATCH] cw fixes --- DEPENDENCIES.md | 1 - code/parachain/frame/cosmwasm/src/crypto.rs | 16 +++--- code/parachain/frame/cosmwasm/src/lib.rs | 9 ++- .../frame/cosmwasm/src/runtimes/vm.rs | 5 +- docs/docs/pallets/bonded-finance.md | 7 --- rfcs/0013-redesign-assets-id-system.md | 56 ------------------- 6 files changed, 16 insertions(+), 78 deletions(-) delete mode 100644 docs/docs/pallets/bonded-finance.md diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md index b30872f6fd0..a728caed624 100644 --- a/DEPENDENCIES.md +++ b/DEPENDENCIES.md @@ -5,7 +5,6 @@ For 2, if you are unsure of the legal implications, contact our general council Exact version of dependencies are more welcomed than wildcards(*). -We pin to a `commit`, not a branch for git dependencies. Forks with PRs to upstream are welcomed, forks without PRs to upstream are not. Other things are checked by CI jobs or decided per case. \ No newline at end of file diff --git a/code/parachain/frame/cosmwasm/src/crypto.rs b/code/parachain/frame/cosmwasm/src/crypto.rs index 0c5b9aa2842..318d786472b 100644 --- a/code/parachain/frame/cosmwasm/src/crypto.rs +++ b/code/parachain/frame/cosmwasm/src/crypto.rs @@ -102,19 +102,21 @@ impl Pallet { } } - sp_io::crypto::start_batch_verify(); + //sp_io::crypto::start_batch_verify(); for (signature, message, public_key) in verify_items { // This is very unlikely to fail. Because this only fails if the verification task // cannot be spawned internally. Note that the actual verification is only done when // `finish_batch_verify` is called. - if !sp_io::crypto::ed25519_batch_verify(&signature, message, &public_key) { - let _ = sp_io::crypto::finish_batch_verify(); - return false - } + return false; + // sp_io::Crypto::start_batch_verify(&mut self) + // if !sp_io::crypto::ed25519_batch_verify(&signature, message, &public_key) { + // let _ = sp_io::crypto::finish_batch_verify(); + // return false + // } } - - sp_io::crypto::finish_batch_verify() + return true; + //sp_io::crypto::finish_batch_verify() } pub(crate) fn do_ed25519_verify(message: &[u8], signature: &[u8], public_key: &[u8]) -> bool { diff --git a/code/parachain/frame/cosmwasm/src/lib.rs b/code/parachain/frame/cosmwasm/src/lib.rs index b7285f2ba29..191223fde31 100644 --- a/code/parachain/frame/cosmwasm/src/lib.rs +++ b/code/parachain/frame/cosmwasm/src/lib.rs @@ -104,7 +104,7 @@ use frame_support::{ storage::child::ChildInfo, traits::{ fungibles::{Inspect as FungiblesInspect, Mutate as FungiblesMutate}, - Get, ReservableCurrency, UnixTime, + Get, ReservableCurrency, UnixTime, tokens::Preservation, }, ReversibleStorageHasher, StorageHasher, }; @@ -1299,13 +1299,12 @@ impl Pallet { from: &AccountIdOf, to: &AccountIdOf, funds: &[Coin], - keep_alive: bool, - ) -> Result<(), Error> { - // Move funds to contract. + preservation: Preservation, + ) -> Result<(), Error> { for Coin { denom, amount } in funds { let asset = Self::cosmwasm_asset_to_native_asset(denom.clone())?; let amount = amount.u128().saturated_into(); - T::Assets::transfer(asset, from, to, amount, keep_alive) + T::Assets::transfer(asset, from, to, amount, preservation) .map_err(|_| Error::::TransferFailed)?; } Ok(()) diff --git a/code/parachain/frame/cosmwasm/src/runtimes/vm.rs b/code/parachain/frame/cosmwasm/src/runtimes/vm.rs index b0a98629f38..2161b2bcc94 100644 --- a/code/parachain/frame/cosmwasm/src/runtimes/vm.rs +++ b/code/parachain/frame/cosmwasm/src/runtimes/vm.rs @@ -4,6 +4,7 @@ use crate::{ }; use alloc::{borrow::ToOwned, string::String}; use composable_traits::cosmwasm::CosmwasmSubstrateError; +use frame_support::traits::tokens::Preservation; use core::marker::{Send, Sync}; use cosmwasm_std::{CodeInfoResponse, Coin, ContractInfoResponse, Empty, Env, MessageInfo}; use cosmwasm_vm::{ @@ -413,7 +414,7 @@ impl<'a, T: Config + Send + Sync> VMBase for CosmwasmVM<'a, T> { fn transfer(&mut self, to: &Self::Address, funds: &[Coin]) -> Result<(), Self::Error> { log::debug!(target: "runtime::contracts", "transfer: {:#?}", funds); let from = self.contract_address.as_ref(); - Pallet::::do_transfer(from, to.as_ref(), funds, false)?; + Pallet::::do_transfer(from, to.as_ref(), funds, Preservation::Expendable)?; Ok(()) } @@ -654,7 +655,7 @@ impl<'a, T: Config + Send + Sync> VMBase for CosmwasmVM<'a, T> { to: &Self::Address, funds: &[Coin], ) -> Result<(), Self::Error> { - Pallet::::do_transfer(from.as_ref(), to.as_ref(), funds, false)?; + Pallet::::do_transfer(from.as_ref(), to.as_ref(), funds, Preservation::Expendable)?; Ok(()) } } diff --git a/docs/docs/pallets/bonded-finance.md b/docs/docs/pallets/bonded-finance.md deleted file mode 100644 index 1502dc69a25..00000000000 --- a/docs/docs/pallets/bonded-finance.md +++ /dev/null @@ -1,7 +0,0 @@ -# Bonded Finance - -*A pallet providing means of submitting and maintaining bond offers.* - ---- - -{{#include ../../../code/parachain/frame/bonded-finance/README.md:5:}} diff --git a/rfcs/0013-redesign-assets-id-system.md b/rfcs/0013-redesign-assets-id-system.md index ad02d763dfa..160b9868b9d 100644 --- a/rfcs/0013-redesign-assets-id-system.md +++ b/rfcs/0013-redesign-assets-id-system.md @@ -158,62 +158,6 @@ assets. To enable this, instead of only passing a multi-location, we switch to an enum of either multi-location or local ID. -## Create Assets Transactor Router (Assets Manager) - -Assets Manager will be a migration of the current pallet-assets that we created -to route between pallet-balances and orml-tokens. The primary difference being -that assets-transactor-router will also need to handle routing between our two instances -of orml-tokens as well as pallet-balances. - -As stated in the design, we can depend on information provided by Assets -Registry to route between our two instances of pallet-assets. - -**Dependency Graph of the New Assets System:** - -```mermaid -classDiagram - AssetsTransactorRouter <|-- AssetsRegistry - AssetsTransactorRouter <|-- Balances - AssetsTransactorRouter <|-- LocalAssetsTransactor - AssetsTransactorRouter <|-- ForeignAssetsTransactor - AssetsTransactorRouter : frame_support.traits.tokens.fungible.* - AssetsTransactorRouter : .. .currency.* - AssetsTransactorRouter : .. .fungibles.* - AssetsTransactorRouter : orml_traits.currency.MultiCurrency* - class AssetsRegistry{ - composable_traits.assets.AssetTypeInspect - .. .AssetRatioInspect - .. .MutateMetadata - .. .InspectRegistryMetadata - composable_traits.xcm.assets.RemoteAssetRegistryMutate - .. RemoteAssetRegistryInspect - } - class Balances{ - frame_support.traits.tokens.currency.* - .. .fungible.* - } - class LocalAssetsTransactor{ - orml_traits.currency.MultiCurrency* - frame_support.traits.tokens.fungibles.* - } - class ForeignAssetsTransactor{ - orml_traits.currency.MultiCurrency* - frame_support.traits.tokens.fungibles.* - } -``` - -**Steps:** - -* Rename our `pallet-assets` to `pallet-assets-transactor-router` - -* Add routes for both instances to existing functions - -* Expose the `metadata::Inspect` and `InspectMetadata` traits from the manager - -* Use a call filter to block calls into the individual instances of -pallet-assets - -* Provide assets-transactor-router as the XCM Asset Transactor ### Asset ID Creation