Skip to content

Commit

Permalink
cw fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Aug 27, 2023
1 parent 938cfbc commit ee4f738
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 78 deletions.
1 change: 0 additions & 1 deletion DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
16 changes: 9 additions & 7 deletions code/parachain/frame/cosmwasm/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,21 @@ impl<T: Config> Pallet<T> {
}
}

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 {
Expand Down
9 changes: 4 additions & 5 deletions code/parachain/frame/cosmwasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -1299,13 +1299,12 @@ impl<T: Config> Pallet<T> {
from: &AccountIdOf<T>,
to: &AccountIdOf<T>,
funds: &[Coin],
keep_alive: bool,
) -> Result<(), Error<T>> {
// Move funds to contract.
preservation: Preservation,
) -> Result<(), Error<T>> {
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::<T>::TransferFailed)?;
}
Ok(())
Expand Down
5 changes: 3 additions & 2 deletions code/parachain/frame/cosmwasm/src/runtimes/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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::<T>::do_transfer(from, to.as_ref(), funds, false)?;
Pallet::<T>::do_transfer(from, to.as_ref(), funds, Preservation::Expendable)?;
Ok(())
}

Expand Down Expand Up @@ -654,7 +655,7 @@ impl<'a, T: Config + Send + Sync> VMBase for CosmwasmVM<'a, T> {
to: &Self::Address,
funds: &[Coin],
) -> Result<(), Self::Error> {
Pallet::<T>::do_transfer(from.as_ref(), to.as_ref(), funds, false)?;
Pallet::<T>::do_transfer(from.as_ref(), to.as_ref(), funds, Preservation::Expendable)?;
Ok(())
}
}
Expand Down
7 changes: 0 additions & 7 deletions docs/docs/pallets/bonded-finance.md

This file was deleted.

56 changes: 0 additions & 56 deletions rfcs/0013-redesign-assets-id-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ee4f738

Please sign in to comment.