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

fix: update genesis build source code for cc3 node #481

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ substrate-test-runtime-client = { git = "https://github.com/paritytech/polkadot
substrate-wasm-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" }
generate-bags = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" }
xcm = { package = "staging-xcm", git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407" }
sp-genesis-builder = { git = "https://github.com/paritytech/polkadot-sdk", branch = "stable2407", default-features = false }

# Frontier Client
fc-api = { git = "https://github.com/paritytech/frontier", rev = "80c768f688d86bfb350753f3e2aebc9d89037727" }
Expand Down
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ build = "build.rs"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
serde_json = { workspace = true }
async-trait = { workspace = true }
clap = { workspace = true }
futures = { workspace = true }
Expand Down
6 changes: 6 additions & 0 deletions node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
};

use hex_literal::hex;
use sc_service::NoExtension;

Check warning on line 7 in node/src/chain_spec.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testing-ci

unused import: `sc_service::NoExtension`

Check warning on line 7 in node/src/chain_spec.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testing-devnet

unused import: `sc_service::NoExtension`
use serde::{Deserialize, Serialize};
// Substrate
use sc_chain_spec::{ChainSpecBuilder, ChainType, Properties};

Check warning on line 10 in node/src/chain_spec.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testnet

unused import: `ChainSpecBuilder`

Check warning on line 10 in node/src/chain_spec.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-devnet

unused import: `ChainSpecBuilder`

Check warning on line 10 in node/src/chain_spec.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testing-ci

unused import: `ChainSpecBuilder`

Check warning on line 10 in node/src/chain_spec.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testing-devnet

unused import: `ChainSpecBuilder`
use sp_consensus_babe::AuthorityId as BabeId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
#[allow(unused_imports)]
Expand Down Expand Up @@ -151,10 +151,13 @@
SS58Prefix::get() as u64,
);

let config_json = serde_json::to_value(&rgc).expect("Could not build genesis config.");

return ChainSpec::builder(wasm_binary, None)
.with_name("Development")
.with_id("dev")
.with_chain_type(ChainType::Development)
.with_genesis_config(config_json)
.with_properties(properties())
.build();

Expand Down Expand Up @@ -243,10 +246,13 @@
SS58Prefix::get() as u64,
);

let config_json = serde_json::to_value(&rgc).expect("Could not build genesis config.");

return ChainSpec::builder(wasm_binary, None)
.with_name("Local Testnet")
.with_id("local_testnet")
.with_chain_type(ChainType::Local)
.with_genesis_config(config_json)
.with_properties(properties())
.build();

Expand Down
4 changes: 3 additions & 1 deletion node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ impl SubstrateCli for Cli {
let ret = match id {
"dev" => {
let enable_manual_seal = self.sealing.map(|_| true);
Box::new(chain_spec::development_config(enable_manual_seal))
let x = Box::new(chain_spec::development_config(enable_manual_seal));
// panic!("eeeeeee");
x
}
"devnet" => Box::new(chain_spec::devnet_config()?),
"testnet" => Box::new(chain_spec::testnet_config()?),
Expand Down
1 change: 1 addition & 0 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ scale-info = { workspace = true }
smallvec = "1.13.2"

# Substrate
sp-genesis-builder = { workspace = true }
sp-api = { workspace = true }
sp-block-builder = { workspace = true }
sp-consensus-babe = { workspace = true }
Expand Down
18 changes: 18 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
crypto::{ByteArray, KeyTypeId},
OpaqueMetadata, H160, H256, U256,
};
use frame_support::{
genesis_builder_helper::{build_state, get_preset},
// traits::VariantCountOf,
};
use sp_runtime::{
generic, impl_opaque_keys,
traits::{
Expand Down Expand Up @@ -50,7 +54,7 @@
use pallet_grandpa::{
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
};
use pallet_transaction_payment::{ConstFeeMultiplier, CurrencyAdapter};

Check warning on line 57 in runtime/src/lib.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testnet

use of deprecated struct `pallet_transaction_payment::CurrencyAdapter`: Please use the fungible trait and FungibleAdapter. This struct will be removed some time after March 2024.

Check warning on line 57 in runtime/src/lib.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-devnet

use of deprecated struct `pallet_transaction_payment::CurrencyAdapter`: Please use the fungible trait and FungibleAdapter. This struct will be removed some time after March 2024.

Check warning on line 57 in runtime/src/lib.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testing-ci

use of deprecated struct `pallet_transaction_payment::CurrencyAdapter`: Please use the fungible trait and FungibleAdapter. This struct will be removed some time after March 2024.

Check warning on line 57 in runtime/src/lib.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testing-devnet

use of deprecated struct `pallet_transaction_payment::CurrencyAdapter`: Please use the fungible trait and FungibleAdapter. This struct will be removed some time after March 2024.
// Frontier
use fp_evm::weight_per_gas;
use fp_rpc::TransactionStatus;
Expand All @@ -73,7 +77,7 @@
pub use pallet_staking::StakerStatus;
pub use pallet_timestamp::Call as TimestampCall;
use pallet_transaction_payment::Multiplier;
use ethereum::TransactionV2;

Check warning on line 80 in runtime/src/lib.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testnet

unused import: `ethereum::TransactionV2`

Check warning on line 80 in runtime/src/lib.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-devnet

unused import: `ethereum::TransactionV2`

mod precompiles;
use precompiles::FrontierPrecompiles;
Expand Down Expand Up @@ -372,7 +376,7 @@

impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;

Check warning on line 379 in runtime/src/lib.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testnet

use of deprecated struct `pallet_transaction_payment::CurrencyAdapter`: Please use the fungible trait and FungibleAdapter. This struct will be removed some time after March 2024.

Check warning on line 379 in runtime/src/lib.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-devnet

use of deprecated struct `pallet_transaction_payment::CurrencyAdapter`: Please use the fungible trait and FungibleAdapter. This struct will be removed some time after March 2024.

Check warning on line 379 in runtime/src/lib.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testing-ci

use of deprecated struct `pallet_transaction_payment::CurrencyAdapter`: Please use the fungible trait and FungibleAdapter. This struct will be removed some time after March 2024.

Check warning on line 379 in runtime/src/lib.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testing-devnet

use of deprecated struct `pallet_transaction_payment::CurrencyAdapter`: Please use the fungible trait and FungibleAdapter. This struct will be removed some time after March 2024.
type OperationalFeeMultiplier = ConstU8<1u8>;
type WeightToFee = WeightToCtcFee<Runtime>;
type LengthToFee = ConstantMultiplier<u128, ConstU128<1_500_000_000u128>>;
Expand Down Expand Up @@ -1264,7 +1268,7 @@

impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {

fn initialize_pending_block(header: &<Block as BlockT>::Header){

Check warning on line 1271 in runtime/src/lib.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testnet

unused variable: `header`

Check warning on line 1271 in runtime/src/lib.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-devnet

unused variable: `header`

Check warning on line 1271 in runtime/src/lib.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testing-ci

unused variable: `header`

Check warning on line 1271 in runtime/src/lib.rs

View workflow job for this annotation

GitHub Actions / build-creditcoin-node-for-testing-devnet

unused variable: `header`
//todo
todo!()
//new method arrived
Expand Down Expand Up @@ -1678,6 +1682,20 @@
}
}

impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
build_state::<RuntimeGenesisConfig>(config)
}

fn get_preset(id: &Option<sp_genesis_builder::PresetId>) -> Option<Vec<u8>> {
get_preset::<RuntimeGenesisConfig>(id, |_| None)
}

fn preset_names() -> Vec<sp_genesis_builder::PresetId> {
vec![]
}
}

}

#[cfg(test)]
Expand Down
Loading