Skip to content

Commit

Permalink
Fix manual seal (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
hqwangningbo authored Aug 1, 2024
1 parent 3f569ff commit e712a90
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 171 deletions.
5 changes: 4 additions & 1 deletion node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Box::new(service::chain_spec::bifrost_polkadot::local_testnet_config()),
#[cfg(any(feature = "with-bifrost-polkadot-runtime", feature = "with-bifrost-runtime"))]
"bifrost-paseo" => Box::new(service::chain_spec::bifrost_polkadot::paseo_config()),
#[cfg(any(feature = "with-bifrost-polkadot-runtime", feature = "with-bifrost-runtime"))]
"bifrost-polkadot-dev" => Box::new(service::chain_spec::bifrost_polkadot::dev_config()),
path => {
let path = std::path::PathBuf::from(path);
if path.to_str().map(|s| s.contains("bifrost-polkadot")) == Some(true) {
Expand Down Expand Up @@ -193,7 +195,7 @@ macro_rules! with_runtime_or_err {

#[cfg(not(any(feature = "with-bifrost-kusama-runtime",feature = "with-bifrost-runtime")))]
return Err(service::BIFROST_KUSAMA_RUNTIME_NOT_AVAILABLE.into());
} else if $chain_spec.is_bifrost_polkadot() {
} else if $chain_spec.is_bifrost_polkadot() || $chain_spec.is_dev() {
#[cfg(any(feature = "with-bifrost-polkadot-runtime", feature = "with-bifrost-runtime"))]
#[allow(unused_imports)]
use service::collator_polkadot::{bifrost_polkadot_runtime::{Block, RuntimeApi}, start_node,new_partial};
Expand Down Expand Up @@ -449,6 +451,7 @@ pub fn run() -> Result<()> {
info!("Parachain id: {:?}", id);
info!("Parachain Account: {}", parachain_account);
info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
info!("Is dev modle: {}", if config.chain_spec.is_dev() { "yes" } else { "no" });

with_runtime_or_err!(config.chain_spec, {
{
Expand Down
109 changes: 109 additions & 0 deletions node/service/src/chain_spec/bifrost_polkadot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,115 @@ pub fn local_testnet_config() -> ChainSpec {
.build()
}

pub fn dev_config() -> ChainSpec {
let endowed_accounts = vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
whitelisted_caller(), // Benchmarking whitelist_account
account("bechmarking_account_1", 0, 0),
];
let balances = endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT())).collect();
let tokens = endowed_accounts
.iter()
.flat_map(|x| {
vec![
(x.clone(), DOT, ENDOWMENT() * 4_000_000),
(x.clone(), WETH, ENDOWMENT() * 4_000_000),
]
})
.collect();
let council_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let technical_committee_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let oracle_membership = vec![get_account_id_from_seed::<sr25519::Public>("Alice")];
let salp_multisig: AccountId =
hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into();
let currency = vec![
(
BNC,
10_000_000_000,
Some((String::from("Bifrost Native Coin"), String::from("BNC"), 12u8)),
),
(DOT, 1_000_000, Some((String::from("Polkadot DOT"), String::from("DOT"), 10u8))),
(
GLMR,
1_000_000_000_000,
Some((String::from("Moonbeam Native Token"), String::from("GLMR"), 18u8)),
),
(DOT_U, 1_000, Some((String::from("Tether USD"), String::from("USDT"), 6u8))),
(ASTR, 10_000_000_000_000_000, Some((String::from("Astar"), String::from("ASTR"), 18u8))),
(
FIL,
1_000_000_000_000,
Some((String::from("Filecoin Network Token"), String::from("FIL"), 18u8)),
),
(USDC, 1_000, Some((String::from("USD Coin"), String::from("USDC"), 6u8))),
(IBTC, 100, Some((String::from("interBTC"), String::from("IBTC"), 8u8))),
(INTR, 10_000_000, Some((String::from("Interlay"), String::from("INTR"), 10u8))),
(
MANTA,
10_000_000_000_000,
Some((String::from("Manta Network"), String::from("MANTA"), 18u8)),
),
(
BNCS,
10_000_000_000,
Some((String::from("bncs-20 inscription token BNCS"), String::from("BNCS"), 12u8)),
),
(PINK, 100_000_000, Some((String::from("PINK"), String::from("PINK"), 10u8))),
(DED, 1, Some((String::from("DED"), String::from("DED"), 10u8))),
(PEN, 100_000_000, Some((String::from("Pendulum"), String::from("PEN"), 12u8))),
(WETH, 100_000_000, Some((String::from("SnowBridge WETH"), String::from("SWETH"), 18u8))),
];
let vcurrency = vec![VSToken2(DOT_TOKEN_ID), VToken(TokenSymbol::BNC), VToken2(DOT_TOKEN_ID)];

let mut evm_accounts = BTreeMap::new();
evm_accounts.insert(
// H160 address of CI test runner account
H160::from_str("6be02d1d3665660d22ff9624b7be0551ee1ac91b")
.expect("internal H160 is valid; qed"),
fp_evm::GenesisAccount {
balance: U256::from(1_000_000_000_000_000_000_000_000u128),
code: Default::default(),
nonce: Default::default(),
storage: Default::default(),
},
);

ChainSpec::builder(
bifrost_polkadot_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
RelayExtensions { relay_chain: "polkadot".into(), para_id: PARA_ID, evm_since: 1 },
)
.with_name("Bifrost Polkadot Dev Testnet")
.with_id("dev")
.with_chain_type(ChainType::Development)
.with_genesis_config_patch(bifrost_polkadot_genesis(
vec![
(
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_from_seed::<AuraId>("Alice"),
),
(get_account_id_from_seed::<sr25519::Public>("Bob"), get_from_seed::<AuraId>("Bob")),
],
balances,
vec![],
PARA_ID.into(),
tokens,
council_membership,
technical_committee_membership,
salp_multisig,
(currency, vcurrency, vec![]),
oracle_membership,
evm_accounts,
))
.with_properties(bifrost_polkadot_properties())
.with_protocol_id(DEFAULT_PROTOCOL_ID)
.build()
}

pub fn paseo_config() -> ChainSpec {
let invulnerables: Vec<(AccountId, AuraId)> = vec![
(
Expand Down
26 changes: 15 additions & 11 deletions node/service/src/collator_polkadot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use cumulus_client_consensus_aura::collators::basic::{
use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport;
use cumulus_client_consensus_proposer::Proposer;

use crate::{chain_spec, eth};
use crate::{chain_spec, eth, IdentifyVariant};
use bifrost_primitives::Block;
use cumulus_client_service::{
build_network, build_relay_chain_interface, prepare_node_config, start_relay_chain_tasks,
Expand Down Expand Up @@ -557,14 +557,18 @@ pub async fn start_node<Net: NetworkBackend<Block, Hash>>(
para_id: ParaId,
hwbench: Option<sc_sysinfo::HwBench>,
) -> sc_service::error::Result<(TaskManager, Arc<FullClient>)> {
start_node_impl::<Net>(
parachain_config,
polkadot_config,
eth_config,
collator_options,
CollatorSybilResistance::Resistant,
para_id,
hwbench,
)
.await
if parachain_config.chain_spec.is_dev() {
crate::dev::start_node::<Net>(parachain_config, eth_config).await
} else {
start_node_impl::<Net>(
parachain_config,
polkadot_config,
eth_config,
collator_options,
CollatorSybilResistance::Resistant,
para_id,
hwbench,
)
.await
}
}
Loading

0 comments on commit e712a90

Please sign in to comment.