Skip to content

Commit

Permalink
Merge branch 'jamie/v0.9.22' into garandor/nimbus0
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Reif <Garandor@manta.network>
  • Loading branch information
Adam Reif authored and Adam Reif committed Jul 12, 2022
2 parents 47039c7 + 561eb63 commit cfc82fa
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 125 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [\#614](https://github.com/Manta-Network/Manta/pull/614) Remove `OnRuntimeUpgrade` from calamari-runtime.
- [\#619](https://github.com/Manta-Network/Manta/pull/619) Add CI runtime upgrade test for Dolphin and improve test scenario.
- [\#622](https://github.com/Manta-Network/Manta/pull/622) Update parameter path from `sdk` to `manta-parameters`.
- [\#638](https://github.com/Manta-Network/Manta/pull/638) `existence_requirement` argument for `FungibleLedger` trait functions.
- [\#652](https://github.com/Manta-Network/Manta/pull/652) Reduce CI failure rate by switching AWS CI runners from AMD to Intel
- [\#653](https://github.com/Manta-Network/Manta/pull/653) Add concurrency groups for pull request CI builds to reduce CI costs
- [\#657](https://github.com/Manta-Network/Manta/pull/657) retire manta-pc-launch with polkadot-launch.
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

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

8 changes: 7 additions & 1 deletion genesis/calamari-genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
"name": "Calamari Parachain",
"id": "calamari",
"chainType": "Live",
"bootNodes": [],
"bootNodes": [
"/dns/crispy.calamari.systems/tcp/30333/p2p/12D3KooWNE4LBfkYB2B7D4r9vL54YMMGsfAsXdkhWfBw8VHJSEQc",
"/dns/crunchy.calamari.systems/tcp/30333/p2p/12D3KooWL3ELxcoMGA6han3wPQoym5DKbYHqkWkCuqyjaCXpyJTt",
"/dns/hotdog.calamari.systems/tcp/30333/p2p/12D3KooWMHdpUCCS9j8hvNLTV8PeqJ16KaVEjb5PVdYgAQUFUcCG",
"/dns/tasty.calamari.systems/tcp/30333/p2p/12D3KooWGs2hfnRQ3Y2eAoUyWKUL3g7Jmcsf8FpyhVYeNpXeBMSu",
"/dns/tender.calamari.systems/tcp/30333/p2p/12D3KooWNXZeUSEKRPsp1yiDH99qSVawQSWHqG4umPjgHsn1joci"
],
"telemetryEndpoints": [
[
"/dns/api.telemetry.manta.systems/tcp/443/x-parity-wss/%2Fsubmit%2F",
Expand Down
1 change: 0 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ cfg-if = "1.0.0"
clap = { version = "3.1", features = ["derive"] }
codec = { package = 'parity-scale-codec', version = '3.1.2' }
futures = "0.3.21"
hex-literal = "0.3.4"
log = "0.4.16"
serde = { version = "1.0.137", features = ["derive"] }

Expand Down
2 changes: 1 addition & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ pub fn run_with(cli: Cli) -> Result {
Some(Subcommand::Benchmark(cmd)) => {
let runner = cli.create_runner(cmd)?;

// Switch on the concrete benchmark sub-command-
// Switch on the concrete benchmark sub-command
match cmd {
BenchmarkCmd::Pallet(cmd) => {
if cfg!(feature = "runtime-benchmarks") {
Expand Down
16 changes: 8 additions & 8 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use cumulus_relay_chain_inprocess_interface::build_inprocess_relay_chain;
use cumulus_relay_chain_interface::{RelayChainError, RelayChainInterface, RelayChainResult};
use cumulus_relay_chain_rpc_interface::RelayChainRPCInterface;
use jsonrpsee::RpcModule;
use polkadot_service::{CollatorPair, NativeExecutionDispatch};
use polkadot_service::CollatorPair;

use futures::lock::Mutex;
pub use manta_primitives::types::{AccountId, Balance, Block, Hash, Header, Index as Nonce};
Expand All @@ -46,7 +46,7 @@ use sc_consensus::{
import_queue::{BasicQueue, Verifier as VerifierT},
BlockImportParams,
};
use sc_executor::NativeElseWasmExecutor;
use sc_executor::{NativeElseWasmExecutor, NativeExecutionDispatch};
use sc_network::NetworkService;
pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
use sc_service::{Configuration, Error, Role, TFullBackend, TFullClient, TaskManager};
Expand All @@ -69,7 +69,7 @@ use substrate_prometheus_endpoint::Registry;

/// Native Manta Parachain executor instance.
pub struct MantaRuntimeExecutor;
impl sc_executor::NativeExecutionDispatch for MantaRuntimeExecutor {
impl NativeExecutionDispatch for MantaRuntimeExecutor {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;

fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
Expand All @@ -83,7 +83,7 @@ impl sc_executor::NativeExecutionDispatch for MantaRuntimeExecutor {

/// Native Calamari Parachain executor instance.
pub struct CalamariRuntimeExecutor;
impl sc_executor::NativeExecutionDispatch for CalamariRuntimeExecutor {
impl NativeExecutionDispatch for CalamariRuntimeExecutor {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;

fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
Expand All @@ -97,7 +97,7 @@ impl sc_executor::NativeExecutionDispatch for CalamariRuntimeExecutor {

/// Native Dolphin Parachain executor instance.
pub struct DolphinRuntimeExecutor;
impl sc_executor::NativeExecutionDispatch for DolphinRuntimeExecutor {
impl NativeExecutionDispatch for DolphinRuntimeExecutor {
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;

fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
Expand Down Expand Up @@ -267,7 +267,7 @@ where
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
StateBackend: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
Executor: NativeExecutionDispatch + 'static,
FullRpc: Fn(
rpc::FullDeps<Client<RuntimeApi, Executor>, TransactionPool<RuntimeApi, Executor>>,
) -> Result<RpcModule<()>, Error>
Expand Down Expand Up @@ -545,7 +545,7 @@ where
+ sp_block_builder::BlockBuilder<Block>
+ sp_consensus_aura::AuraApi<Block, <<AuraId as AppKey>::Pair as Pair>::Public>,
StateBackend: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
Executor: NativeExecutionDispatch + 'static,
<<AuraId as AppKey>::Pair as Pair>::Signature:
TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec,
{
Expand Down Expand Up @@ -628,7 +628,7 @@ where
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
StateBackend: sp_api::StateBackend<BlakeTwo256>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
Executor: NativeExecutionDispatch + 'static,
<<AuraId as AppKey>::Pair as Pair>::Signature:
TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec,
FullRpc: Fn(
Expand Down
61 changes: 35 additions & 26 deletions pallets/manta-pay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ extern crate alloc;

use alloc::{vec, vec::Vec};
use core::marker::PhantomData;
use frame_support::{transactional, PalletId};
use frame_support::{traits::tokens::ExistenceRequirement, transactional, PalletId};

use manta_accounting::{
asset,
transfer::{
Expand Down Expand Up @@ -218,8 +219,14 @@ pub mod pallet {
sink: T::AccountId,
) -> DispatchResultWithPostInfo {
let origin = ensure_signed(origin)?;
FungibleLedger::<T>::transfer(asset.id, &origin, &sink, asset.value)
.map_err(Error::<T>::from)?;
FungibleLedger::<T>::transfer(
asset.id,
&origin,
&sink,
asset.value,
ExistenceRequirement::KeepAlive,
)
.map_err(Error::<T>::from)?;
Self::deposit_event(Event::Transfer {
asset,
source: origin,
Expand Down Expand Up @@ -353,17 +360,14 @@ pub mod pallet {
/// [`Overflow`](FungibleLedgerError::Overflow) from [`FungibleLedgerError`]
PublicUpdateOverflow,

/// [`Underflow`](FungibleLedgerError::Underflow) from [`FungibleLedgerError`]
PublicUpdateUnderflow,

/// [`Frozen`](FungibleLedgerError::Frozen) from [`FungibleLedgerError`]
PublicUpdateFrozen,
/// [`CannotWithdraw`](FungibleLedgerError::CannotWithdrawMoreThan(Balance)) from [`FungibleLedgerError`]
PublicUpdateCannotWithdraw,

/// [`NoFunds`](FungibleLedgerError::NoFunds) from [`FungibleLedgerError`]
PublicUpdateNoFunds,
/// [`InvalidMint`](FungibleLedgerError::InvalidMint) from [`FungibleLedgerError`]
PublicUpdateInvalidMint,

/// [`WouldDie`](FungibleLedgerError::WouldDie) from [`FungibleLedgerError`]
PublicUpdateWouldDie,
/// [`InvalidBurn`](FungibleLedgerError::InvalidBurn) from [`FungibleLedgerError`]
PublicUpdateInvalidBurn,

/// [`InvalidTransfer`](FungibleLedgerError::InvalidTransfer) from [`FungibleLedgerError`]
PublicUpdateInvalidTransfer,
Expand Down Expand Up @@ -425,12 +429,10 @@ pub mod pallet {
FungibleLedgerError::CannotCreate => Self::PublicUpdateCannotCreate,
FungibleLedgerError::UnknownAsset => Self::PublicUpdateUnknownAsset,
FungibleLedgerError::Overflow => Self::PublicUpdateOverflow,
FungibleLedgerError::Underflow => Self::PublicUpdateUnderflow,
FungibleLedgerError::Frozen => Self::PublicUpdateFrozen,
FungibleLedgerError::NoFunds => Self::PublicUpdateNoFunds,
FungibleLedgerError::WouldDie => Self::PublicUpdateWouldDie,
FungibleLedgerError::InvalidTransfer(_e) => Self::PublicUpdateInvalidTransfer,
_ => Self::InternalLedgerError,
FungibleLedgerError::CannotWithdrawMoreThan(_) => Self::PublicUpdateCannotWithdraw,
FungibleLedgerError::InvalidMint(_) => Self::PublicUpdateInvalidMint,
FungibleLedgerError::InvalidBurn(_) => Self::PublicUpdateInvalidBurn,
FungibleLedgerError::InvalidTransfer(_) => Self::PublicUpdateInvalidTransfer,
}
}
}
Expand Down Expand Up @@ -806,13 +808,18 @@ where
{
sources
.map(move |(account_id, withdraw)| {
FungibleLedger::<T>::can_withdraw(asset_id.0, &account_id, withdraw.0)
.map(|_| WrapPair(account_id.clone(), withdraw))
.map_err(|_| InvalidSourceAccount {
account_id,
asset_id,
withdraw,
})
FungibleLedger::<T>::can_reduce_by_amount(
asset_id.0,
&account_id,
withdraw.0,
ExistenceRequirement::KeepAlive,
)
.map(|_| WrapPair(account_id.clone(), withdraw))
.map_err(|_| InvalidSourceAccount {
account_id,
asset_id,
withdraw,
})
})
.collect()
}
Expand All @@ -830,7 +837,7 @@ where
// pass the data forward.
sinks
.map(move |(account_id, deposit)| {
FungibleLedger::<T>::can_deposit(asset_id.0, &account_id, deposit.0, true)
FungibleLedger::<T>::can_deposit(asset_id.0, &account_id, deposit.0, false)
.map(|_| WrapPair(account_id.clone(), deposit))
.map_err(|_| InvalidSinkAccount {
account_id,
Expand Down Expand Up @@ -906,6 +913,7 @@ where
&account_id,
&Pallet::<T>::account_id(),
withdraw.0,
ExistenceRequirement::KeepAlive,
)?;
}
for WrapPair(account_id, deposit) in sinks {
Expand All @@ -914,6 +922,7 @@ where
&Pallet::<T>::account_id(),
&account_id,
deposit.0,
ExistenceRequirement::KeepAlive,
)?;
}
Ok(())
Expand Down
Loading

0 comments on commit cfc82fa

Please sign in to comment.