Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
75d34a5
Revamp salp with derivated account
yrong Aug 23, 2021
d48e675
Fix:reserve ksm before confirm
yrong Aug 23, 2021
68cf89e
Revamp with derivated proxy
yrong Aug 24, 2021
7def6f2
Salp rpc integration
yrong Aug 24, 2021
9254f2b
Merge branch 'develop' into salp-with-rpc
yrong Aug 25, 2021
bffc013
Revamp for confirm service
yrong Aug 26, 2021
9dee883
:ambulance: ($RUNTIME) Change SalpTransactionType
AllenPocketGamer Aug 27, 2021
58768d7
merge develop
ark930 Aug 27, 2021
11f2d3e
fix: 🐛 fix ConfirmMuitiSigAccount
yooml Aug 28, 2021
3eeee05
Add some nonce to amount as workround
yrong Aug 28, 2021
b1a8266
Increase contribute weight to cover the nonce
yrong Aug 28, 2021
a8fad47
Revamp for confirm service
yrong Aug 30, 2021
db2c10c
Merge branch 'salp-with-rpc-v0.9.8' into salp-with-rpc
yrong Aug 30, 2021
fc05684
Revamp transfer fee
yrong Aug 31, 2021
095b5c9
Companion with v0.9.9
yrong Aug 31, 2021
5825c47
:bug: ($PALLET) Replace from +-*/ to saturating_*
AllenPocketGamer Aug 31, 2021
786c72c
Refact per discussion
yrong Aug 31, 2021
6e4b171
Merge branch 'salp-with-rpc-v0.9.8' of https://github.com/bifrost-fin…
yrong Aug 31, 2021
b557a09
fix test
yrong Aug 31, 2021
f9c4775
fix test
yrong Aug 31, 2021
26fa8af
Merge branch 'salp-with-rpc' of https://github.com/bifrost-finance/bi…
yrong Aug 31, 2021
0d8f562
Merge branch 'salp-with-rpc-v0.9.8' into salp-with-rpc
yrong Aug 31, 2021
6adc138
Refact&Clean
yrong Aug 31, 2021
f4870ce
Fix build
yrong Aug 31, 2021
8915cd0
Refact&Clean&Fix tests
yrong Aug 31, 2021
c94c15b
:bug: ($PALLET) Fix bug & Fix tests & Fix mock
AllenPocketGamer Aug 31, 2021
9d12741
Integrate salp into bifrost runtime
yrong Aug 31, 2021
db16e05
Merge branch 'salp-with-rpc' of https://github.com/bifrost-finance/bi…
yrong Aug 31, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions node/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,6 @@ pub type ParaId = u32;

/// The measurement type for counting lease periods (generally the same as `BlockNumber`).
pub type LeasePeriod = BlockNumber;

/// Index used for the child trie
pub type TrieIndex = u32;
13 changes: 12 additions & 1 deletion node/primitives/src/xcm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,26 @@ impl From<XcmBaseWeight> for u64 {
}
}

/// represent the xcmp transact type
/// represent the transact type
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode)]
pub enum ParachainTransactType {
Xcm = 0,
Proxy = 1,
}

/// represent the proxy type
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode)]
pub enum ParachainTransactProxyType {
Primary = 0,
Derived = 1,
}

/// represent the derived proxy account type
#[repr(u16)]
pub enum ParachainDerivedProxyAccountType {
Salp = 0,
Staking = 1,
}

/// Xcm Message Id
pub type MessageId = [u8; 32];
2 changes: 2 additions & 0 deletions node/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "pol
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9" }
bifrost-flexible-fee-rpc = { path = "../../pallets/flexible-fee/rpc" }
bifrost-flexible-fee-rpc-runtime-api = { path = "../../pallets/flexible-fee/rpc/runtime-api" }
bifrost-salp-rpc-api = { path = "../../pallets/salp/rpc" }
bifrost-salp-rpc-runtime-api = { path = "../../pallets/salp/rpc/runtime-api" }
zenlink-protocol-rpc = "*"
zenlink-protocol-runtime-api = "*"
10 changes: 7 additions & 3 deletions node/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ use std::sync::Arc;

use bifrost_flexible_fee_rpc::{FeeRpcApi, FlexibleFeeStruct};
use bifrost_flexible_fee_rpc_runtime_api::FlexibleFeeRuntimeApi as FeeRuntimeApi;
use node_primitives::{AccountId, Balance, Block};
use bifrost_salp_rpc_api::{SalpRpcApi, SalpRpcWrapper};
use bifrost_salp_rpc_runtime_api::SalpRuntimeApi;
use node_primitives::{AccountId, Balance, Block, ParaId};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
pub use sc_rpc_api::DenyUnsafe;
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
Expand Down Expand Up @@ -70,10 +73,9 @@ where
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: FeeRuntimeApi<Block, AccountId>,
C::Api: ZenlinkProtocolRuntimeApi<Block, AccountId>,
C::Api: SalpRuntimeApi<Block, ParaId, AccountId, Balance>,
P: TransactionPool + 'static,
{
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};

let FullDeps { client, .. } = deps;

let mut io = RpcExtension::default();
Expand All @@ -84,5 +86,7 @@ where

io.extend_with(ZenlinkProtocolApi::to_delegate(ZenlinkProtocol::new(client.clone())));

io.extend_with(SalpRpcApi::to_delegate(SalpRpcWrapper::new(client.clone())));

Ok(io)
}
2 changes: 2 additions & 0 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ zenlink-protocol-runtime-api = "*"

# Bifrost rpc
bifrost-flexible-fee-rpc-runtime-api = { path = "../../pallets/flexible-fee/rpc/runtime-api" }
bifrost-salp-rpc-runtime-api = { path = "../../pallets/salp/rpc/runtime-api" }


[features]
default = [ "std" ]
Expand Down
15 changes: 11 additions & 4 deletions node/service/src/chain_spec/bifrost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ use std::{
};

use bifrost_runtime::{
constants::currency::DOLLARS, AccountId, AuraId, Balance, BalancesConfig, BlockNumber,
CollatorSelectionConfig, CouncilConfig, DemocracyConfig, GenesisConfig, IndicesConfig,
ParachainInfoConfig, SessionConfig, SudoConfig, SystemConfig, TechnicalCommitteeConfig,
VestingConfig, WASM_BINARY,
constants::currency::DOLLARS, AccountId, AuraId, Balance, BalancesConfig, BancorConfig,
BlockNumber, CollatorSelectionConfig, CouncilConfig, DemocracyConfig, GenesisConfig,
IndicesConfig, ParachainInfoConfig, SessionConfig, SudoConfig, SystemConfig,
TechnicalCommitteeConfig, VestingConfig, WASM_BINARY,
};
use cumulus_primitives_core::ParaId;
use hex_literal::hex;
use node_primitives::{CurrencyId, TokenSymbol};
use sc_service::ChainType;
use sc_telemetry::TelemetryEndpoints;
use serde::de::DeserializeOwned;
Expand Down Expand Up @@ -92,6 +93,12 @@ pub fn bifrost_genesis(
aura_ext: Default::default(),
parachain_system: Default::default(),
vesting: VestingConfig { vesting: vestings },
bancor: BancorConfig {
bancor_pools: vec![
(CurrencyId::Token(TokenSymbol::DOT), 10_000 * DOLLARS),
(CurrencyId::Token(TokenSymbol::KSM), 1_000_000 * DOLLARS),
],
},
}
}

Expand Down
4 changes: 3 additions & 1 deletion node/service/src/collator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use std::sync::Arc;

use bifrost_flexible_fee_rpc_runtime_api::FlexibleFeeRuntimeApi as FeeRuntimeApi;
use bifrost_salp_rpc_runtime_api::SalpRuntimeApi;
use cumulus_client_consensus_aura::{
build_aura_consensus, BuildAuraConsensusParams, SlotProportion,
};
Expand All @@ -28,7 +29,7 @@ use cumulus_client_service::{
prepare_node_config, start_collator, start_full_node, StartCollatorParams, StartFullNodeParams,
};
use cumulus_primitives_core::ParaId;
use node_primitives::AccountId;
use node_primitives::{AccountId, Balance, ParaId as BifrostParaId};
use sc_client_api::ExecutorProvider;
use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor;
Expand Down Expand Up @@ -335,6 +336,7 @@ where
>,
RuntimeApi::RuntimeApi: FeeRuntimeApi<Block, AccountId>,
RuntimeApi::RuntimeApi: ZenlinkProtocolRuntimeApi<Block, AccountId>,
RuntimeApi::RuntimeApi: SalpRuntimeApi<Block, BifrostParaId, AccountId, Balance>,
Executor: sc_executor::NativeExecutionDispatch + 'static,
RB: Fn(
Arc<TFullClient<Block, RuntimeApi, Executor>>,
Expand Down
5 changes: 3 additions & 2 deletions node/service/src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn new_partial(
FullClient,
FullBackend,
FullSelectChain,
sp_consensus::DefaultImportQueue<Block, FullClient>,
sc_consensus::DefaultImportQueue<Block, FullClient>,
sc_transaction_pool::FullPool<Block, FullClient>,
(
sc_finality_grandpa::GrandpaBlockImport<
Expand Down Expand Up @@ -202,6 +202,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
import_queue,
on_demand: None,
block_announce_validator_builder: None,
warp_sync: None,
})?;

if config.offchain_worker.enabled {
Expand All @@ -226,7 +227,7 @@ pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError>
keystore: keystore_container.sync_keystore(),
task_manager: &mut task_manager,
transaction_pool: transaction_pool.clone(),
rpc_extensions_builder: Box::new(|_, _| ()),
rpc_extensions_builder: Box::new(|_, _| Ok(())),
on_demand: None,
remote_blockchain: None,
backend,
Expand Down
11 changes: 7 additions & 4 deletions node/service/src/manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ use std::sync::Arc;

pub use dev_runtime;
use futures::StreamExt;
use jsonrpc_core::IoHandler;
use node_rpc::{self, RpcExtension};
use sc_consensus::LongestChain;
pub use sc_executor::NativeExecutor;
use sc_rpc::Metadata;
use sc_service::{error::Error as ServiceError, Configuration, PartialComponents, TaskManager};
use sc_telemetry::TelemetryWorker;

Expand All @@ -43,7 +45,7 @@ pub fn new_partial(
FullClient,
FullBackend,
FullSelectChain,
sp_consensus::DefaultImportQueue<Block, FullClient>,
sc_consensus::DefaultImportQueue<Block, FullClient>,
sc_transaction_pool::FullPool<Block, FullClient>,
(),
>,
Expand Down Expand Up @@ -120,6 +122,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
import_queue,
on_demand: None,
block_announce_validator_builder: None,
warp_sync: None,
})?;

if config.offchain_worker.enabled {
Expand Down Expand Up @@ -158,7 +161,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
block_import: client.clone(),
env: proposer_factory,
client: client.clone(),
pool,
pool: transaction_pool.clone(),
commands_stream,
select_chain,
consensus_data_provider: None,
Expand All @@ -179,8 +182,8 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
let client = client.clone();
let transaction_pool = transaction_pool.clone();

Box::new(move |_deny_unsafe, _| -> node_rpc::RpcExtension {
return RpcExtension::default();
Box::new(move |_deny_unsafe, _| -> Result<IoHandler<Metadata>, _> {
return Ok(RpcExtension::default());
})
};

Expand Down
2 changes: 2 additions & 0 deletions pallets/salp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ frame-support = { git = "https://github.com/paritytech/substrate", branch = "pol
frame-system = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9", default-features = false, optional = true }
sp-std = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9", default-features = false }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9", default-features = false }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9", default-features = false }
sp-arithmetic = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9", default-features = false }
xcm = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.9", default-features = false }
Expand Down Expand Up @@ -43,6 +44,7 @@ std = [
"frame-support/std",
"frame-system/std",
"sp-std/std",
"sp-io/std",
"sp-runtime/std",
"sp-arithmetic/std",
"orml-traits/std",
Expand Down
17 changes: 17 additions & 0 deletions pallets/salp/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "bifrost-salp-rpc-api"
version = "0.8.0"
authors = ["Ron Yang <yrong1997@gmail.com>"]
edition = "2018"

[dependencies]
serde = { version = "1.0.124", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
jsonrpc-core = "15.1.0"
jsonrpc-core-client = "15.1.0"
jsonrpc-derive = "15.1.0"
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9" }
node-primitives = { path = "../../../node/primitives", default-features = false }
bifrost-salp-rpc-runtime-api = { path = "./runtime-api" }
16 changes: 16 additions & 0 deletions pallets/salp/rpc/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "bifrost-salp-rpc-runtime-api"
version = "0.8.0"
authors = ["Ron Yang<yrong1997@gmail.com>"]
edition = "2018"

[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9", default-features = false }

[features]
default = ["std"]
std = [
"codec/std",
"sp-api/std",
]
35 changes: 35 additions & 0 deletions pallets/salp/rpc/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// This file is part of Bifrost.

// Copyright (C) 2019-2021 Liebi Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]

use codec::Codec;
use sp_api::decl_runtime_apis;

decl_runtime_apis! {
pub trait SalpRuntimeApi<ParaId,AccountId, Balance> where
ParaId: Codec,
AccountId: Codec,
Balance: Codec,
{
fn get_contribution(
index: ParaId,
who: AccountId
) -> Balance;
}
}
Loading