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

Add mantapay to manta runtime #1137

Merged
merged 14 commits into from
Jun 5, 2023
1 change: 1 addition & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@ pub fn run_with(cli: Cli) -> Result {
rpc::create_calamari_full,
).await
.map_err(Into::into);
} else if config.chain_spec.is_manta() {
return crate::service::start_dev_nimbus_node::<manta_runtime::RuntimeApi, _>(
config,
rpc::create_manta_full,
).await
.map_err(Into::into);
} else {
return Err("Dev mode not support for current chain".into());
}
Expand Down
54 changes: 0 additions & 54 deletions node/src/rpc/common.rs

This file was deleted.

14 changes: 12 additions & 2 deletions node/src/rpc/manta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with Manta. If not, see <http://www.gnu.org/licenses/>.

//! Calamari RPC Extensions
//! Manta RPC Extensions

use super::*;
use pallet_manta_pay::{
rpc::{Pull, PullApiServer},
runtime::PullLedgerDiffApi,
};
use pallet_manta_sbt::{
rpc::{SBTPull, SBTPullApiServer},
runtime::SBTPullLedgerDiffApi,
};

/// Instantiate all RPC extensions for calamari.
/// Instantiate all RPC extensions for manta.
pub fn create_manta_full<C, P>(deps: FullDeps<C, P>) -> Result<RpcExtension, sc_service::Error>
where
C: ProvideRuntimeApi<Block>
Expand All @@ -35,6 +39,7 @@ where
C::Api: frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BlockBuilder<Block>,
C::Api: PullLedgerDiffApi<Block>,
C::Api: SBTPullLedgerDiffApi<Block>,
P: TransactionPool + Sync + Send + 'static,
{
Expand All @@ -55,6 +60,11 @@ where
.merge(TransactionPayment::new(client.clone()).into_rpc())
.map_err(|e| sc_service::Error::Other(e.to_string()))?;

let manta_pay_rpc: jsonrpsee::RpcModule<Pull<Block, C>> = Pull::new(client.clone()).into_rpc();
module
.merge(manta_pay_rpc)
.map_err(|e| sc_service::Error::Other(e.to_string()))?;

let manta_sbt_rpc: jsonrpsee::RpcModule<SBTPull<Block, C>> = SBTPull::new(client).into_rpc();
module
.merge(manta_sbt_rpc)
Expand Down
2 changes: 0 additions & 2 deletions node/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use std::sync::Arc;

mod calamari;
mod common;
mod dolphin;
mod manta;

pub use self::manta::create_manta_full;
pub use calamari::create_calamari_full;
pub use common::create_common_full;
pub use dolphin::create_dolphin_full;

/// A type representing all RPC extensions.
Expand Down
5 changes: 5 additions & 0 deletions runtime/manta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ manta-collator-selection = { path = '../../pallets/collator-selection', default-
manta-primitives = { path = '../../primitives/manta', default-features = false }
manta-support = { package = "pallet-manta-support", path = "../../pallets/manta-support", default-features = false }
pallet-asset-manager = { path = '../../pallets/asset-manager', default-features = false }
pallet-manta-pay = { path = '../../pallets/manta-pay', default-features = false, features = ["runtime"] }
pallet-manta-sbt = { path = '../../pallets/manta-sbt', default-features = false, features = ["runtime"] }
pallet-parachain-staking = { path = '../../pallets/parachain-staking', default-features = false }
pallet-tx-pause = { path = '../../pallets/tx-pause', default-features = false }
Expand Down Expand Up @@ -144,6 +145,7 @@ runtime-benchmarks = [
'cumulus-pallet-xcmp-queue/runtime-benchmarks',
'orml-xtokens/runtime-benchmarks',
'cumulus-pallet-parachain-system/runtime-benchmarks',
'pallet-manta-pay/runtime-benchmarks',
'pallet-xcm-benchmarks/runtime-benchmarks',
'pallet-manta-sbt/runtime-benchmarks',
]
Expand Down Expand Up @@ -182,6 +184,7 @@ try-runtime = [
'cumulus-pallet-xcmp-queue/try-runtime',
'cumulus-pallet-xcm/try-runtime',
'pallet-asset-manager/try-runtime',
'pallet-manta-pay/try-runtime',
'orml-xtokens/try-runtime',
'pallet-manta-sbt/try-runtime',
]
Expand Down Expand Up @@ -249,6 +252,8 @@ std = [
'pallet-treasury/std',
'pallet-assets/std',
'pallet-asset-manager/std',
'pallet-manta-pay/std',
'manta-support/std',
'orml-traits/std',
'orml-xtokens/std',
'pallet-manta-sbt/std',
Expand Down
10 changes: 9 additions & 1 deletion runtime/manta/src/assets_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use manta_primitives::{
AssetConfig, AssetIdType, AssetLocation, AssetRegistry, AssetRegistryMetadata,
AssetStorageMetadata, BalanceType, LocationType, NativeAndNonNative,
},
constants::{ASSET_MANAGER_PALLET_ID, MANTA_DECIMAL, MANTA_SBT_PALLET_ID},
constants::{ASSET_MANAGER_PALLET_ID, MANTA_DECIMAL, MANTA_PAY_PALLET_ID, MANTA_SBT_PALLET_ID},
types::{AccountId, Balance, MantaAssetId},
};

Expand Down Expand Up @@ -184,9 +184,17 @@ impl pallet_asset_manager::Config for Runtime {
}

parameter_types! {
pub const MantaPayPalletId: PalletId = MANTA_PAY_PALLET_ID;
pub const MantaSbtPalletId: PalletId = MANTA_SBT_PALLET_ID;
}

impl pallet_manta_pay::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_manta_pay::SubstrateWeight<Runtime>;
type AssetConfig = MantaAssetConfig;
type PalletId = MantaPayPalletId;
}

impl pallet_manta_sbt::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type PalletId = MantaSbtPalletId;
Expand Down
21 changes: 20 additions & 1 deletion runtime/manta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use manta_primitives::{
constants::{time::*, RocksDbWeight, STAKING_PALLET_ID, TREASURY_PALLET_ID, WEIGHT_PER_SECOND},
types::{AccountId, Balance, BlockNumber, Hash, Header, Index, Signature},
};
use manta_support::manta_pay::{PullResponse, RawCheckpoint};
use manta_support::manta_pay::{InitialSyncResponse, PullResponse, RawCheckpoint};
pub use pallet_parachain_staking::{InflationInfo, Range};
use pallet_session::ShouldEndSession;
use runtime_common::{
Expand Down Expand Up @@ -261,6 +261,7 @@ impl Contains<RuntimeCall> for MantaFilter {
| RuntimeCall::XTokens(orml_xtokens::Call::transfer {..})
| RuntimeCall::Balances(_)
| RuntimeCall::Preimage(_)
| RuntimeCall::MantaPay(_)
| RuntimeCall::MantaSbt(_)
| RuntimeCall::TransactionPause(_)
| RuntimeCall::AssetManager(pallet_asset_manager::Call::update_outgoing_filtered_assets {..})
Expand Down Expand Up @@ -812,6 +813,7 @@ construct_runtime!(
// Assets management
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>} = 45,
AssetManager: pallet_asset_manager::{Pallet, Call, Storage, Config<T>, Event<T>} = 46,
MantaPay: pallet_manta_pay::{Pallet, Call, Storage, Event<T>} = 47,
MantaSbt: pallet_manta_sbt::{Pallet, Call, Storage, Event<T>} = 49,
}
);
Expand Down Expand Up @@ -883,6 +885,7 @@ mod benches {
[pallet_tx_pause, TransactionPause]
[manta_collator_selection, CollatorSelection]
[pallet_parachain_staking, ParachainStaking]
[pallet_manta_pay, MantaPay]
[pallet_manta_sbt, MantaSbt]
// Nimbus pallets
[pallet_author_inherent, AuthorInherent]
Expand Down Expand Up @@ -1015,6 +1018,22 @@ impl_runtime_apis! {
}
}

impl pallet_manta_pay::runtime::PullLedgerDiffApi<Block> for Runtime {
fn pull_ledger_diff(
checkpoint: RawCheckpoint,
max_receiver: u64,
max_sender: u64
) -> PullResponse {
MantaPay::pull_ledger_diff(checkpoint.into(), max_receiver, max_sender)
}
fn pull_ledger_total_count() -> [u8; 16] {
MantaPay::pull_ledger_total_count()
}
fn initial_pull(checkpoint: RawCheckpoint, max_receiver: u64) -> InitialSyncResponse {
MantaPay::initial_pull(checkpoint.into(), max_receiver)
}
}

impl nimbus_primitives::NimbusApi<Block> for Runtime {
fn can_author(author: NimbusId, relay_parent: u32, parent_header: &<Block as BlockT>::Header) -> bool {
let next_block_number = parent_header.number + 1;
Expand Down
1 change: 1 addition & 0 deletions runtime/manta/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub mod pallet_author_inherent;
pub mod pallet_balances;
pub mod pallet_collective;
pub mod pallet_democracy;
pub mod pallet_manta_pay;
pub mod pallet_manta_sbt;
pub mod pallet_membership;
pub mod pallet_multisig;
Expand Down
Loading