Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Fixes (#179)
Browse files Browse the repository at this point in the history
* Fix

* Bump to fix

* Fix genesis

* Fix build spec

* Test env
  • Loading branch information
AurevoirXavier authored Jan 5, 2023
1 parent 702cdea commit 511c26e
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 40 deletions.
6 changes: 4 additions & 2 deletions node/src/chain_spec/crab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ pub fn genesis_config() -> ChainSpec {
parachain_info: ParachainInfoConfig { parachain_id: 2105.into() },

// Monetary stuff.
balances: Default::default(),
balances: BalancesConfig {
balances: vec![(array_bytes::hex_n_into_unchecked(ALITH), UNIT)],
},
transaction_payment: Default::default(),
assets: AssetsConfig {
assets: vec![(AssetIds::CKton as _, ROOT, true, 1)],
Expand All @@ -167,7 +169,7 @@ pub fn genesis_config() -> ChainSpec {
now: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(),
elapsed_time: 0,
collator_count: 3,
collators: Vec::new(),
collators: vec![(array_bytes::hex_n_into_unchecked(ALITH), UNIT)],
},
session: SessionConfig {
keys: vec![(
Expand Down
6 changes: 4 additions & 2 deletions node/src/chain_spec/darwinia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ pub fn genesis_config() -> ChainSpec {
parachain_info: ParachainInfoConfig { parachain_id: 2046.into() },

// Monetary stuff.
balances: Default::default(),
balances: BalancesConfig {
balances: vec![(array_bytes::hex_n_into_unchecked(ALITH), UNIT)],
},
transaction_payment: Default::default(),
assets: AssetsConfig {
assets: vec![(AssetIds::Kton as _, ROOT, true, 1)],
Expand All @@ -167,7 +169,7 @@ pub fn genesis_config() -> ChainSpec {
now: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(),
elapsed_time: 0,
collator_count: 3,
collators: Vec::new(),
collators: vec![(array_bytes::hex_n_into_unchecked(ALITH), UNIT)],
},
session: SessionConfig {
keys: vec![(
Expand Down
6 changes: 4 additions & 2 deletions node/src/chain_spec/pangolin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ pub fn genesis_config() -> ChainSpec {
parachain_info: ParachainInfoConfig { parachain_id: 2105.into() },

// Monetary stuff.
balances: Default::default(),
balances: BalancesConfig {
balances: vec![(array_bytes::hex_n_into_unchecked(ALITH), UNIT)],
},
transaction_payment: Default::default(),
assets: AssetsConfig {
assets: vec![(AssetIds::PKton as _, ROOT, true, 1)],
Expand All @@ -167,7 +169,7 @@ pub fn genesis_config() -> ChainSpec {
now: SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(),
elapsed_time: 0,
collator_count: 3,
collators: Vec::new(),
collators: vec![(array_bytes::hex_n_into_unchecked(ALITH), UNIT)],
},
session: SessionConfig {
keys: vec![(
Expand Down
62 changes: 31 additions & 31 deletions tool/state-processor/Cargo.lock

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

2 changes: 1 addition & 1 deletion tool/state-processor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn main() -> Result<()> {

// <Processor<Darwinia>>::new()?.process()?;
// <Processor<Crab>>::new()?.process()?;
<Processor<Pangolin>>::new()?.process()?;
<Processor<Pangolin>>::new()?.test().process()?;

Ok(())
}
13 changes: 13 additions & 0 deletions tool/state-processor/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use fxhash::FxHashMap;
use once_cell::sync::Lazy;
use parity_scale_codec::{Decode, Encode};
use serde::de::DeserializeOwned;
use serde_json::Value;
// hack-ink
use subspector::ChainSpec;

Expand All @@ -26,6 +27,7 @@ pub struct Processor<S> {
pub para_state: State<()>,
pub shell_state: State<()>,
pub shell_chain_spec: ChainSpec,
pub test: bool,
}
impl<S> Processor<S>
where
Expand All @@ -45,9 +47,16 @@ where
_runtime: Default::default(),
},
shell_chain_spec,
test: false,
})
}

pub fn test(mut self) -> Self {
self.test = true;

self
}

pub fn process(mut self) -> Result<()> {
self.solo_state.get_value(b"System", b"Number", "", &mut *NOW.write().unwrap());

Expand All @@ -71,6 +80,10 @@ where

mem::swap(&mut self.shell_state.map, &mut self.shell_chain_spec.genesis.raw.top);

if self.test {
self.shell_chain_spec.extensions["relay_chain"] = Value::String("rococo-local".into());
}

let mut f = File::create(format!("data/{}-processed.json", S::NAME))?;
let v = serde_json::to_vec(&self.shell_chain_spec)?;

Expand Down
17 changes: 15 additions & 2 deletions tool/state-processor/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// std
use std::{
fs::File,
path::Path,
process::{Command, Stdio},
};
// crates.io
Expand Down Expand Up @@ -68,8 +69,20 @@ pub fn is_evm_address(address: &[u8]) -> bool {
}

pub fn build_spec(chain: &str) -> Result<()> {
Command::new("../../target/release/darwinia")
.args(["build-spec", "--chain", &format!("{chain}-genesis")])
let mut path = "../../target/release/darwinia";

if !Path::new(path).is_file() {
path = "../../target/x86_64-unknown-linux-gnu/release/darwinia";
}

Command::new(path)
.args([
"build-spec",
"--raw",
"--disable-default-bootnode",
"--chain",
&format!("{chain}-genesis"),
])
.stdout(Stdio::from(File::create(format!("data/{chain}-shell.json"))?))
.output()?;

Expand Down

0 comments on commit 511c26e

Please sign in to comment.