Skip to content

Commit ba392b0

Browse files
committed
Merge branch 'release1.2.1'
2 parents 58dfcf3 + 1df8e21 commit ba392b0

5 files changed

Lines changed: 84 additions & 12 deletions

File tree

node/res/chain-data-ares-aura-raw.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"id": "gladios",
44
"chainType": "Live",
55
"bootNodes": [
6-
"/ip4/45.77.243.246/tcp/30334/ws/p2p/12D3KooWMqDofvvwRtP7AYSAyJ2udNYrj698wnYJbpjomNTHHK9E"
6+
"/ip4/45.77.243.246/tcp/30334/p2p/12D3KooWMqDofvvwRtP7AYSAyJ2udNYrj698wnYJbpjomNTHHK9E",
7+
"/ip4/202.182.100.187/tcp/30333/p2p/12D3KooWJnx6f4TLtgHcjwALcKZ8KGho1Qx7jrSowBmfPbBhr82m"
78
],
89
"telemetryEndpoints": null,
910
"protocolId": "ares",

node/src/chain_spec/ares_genesis.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ pub fn authority_keys_from_seed(seed: &str) -> (AccountId, AccountId, AuraId, Gr
4444
)
4545
}
4646

47-
fn session_keys(aura: AuraId, grandpa: GrandpaId, ares: AresId) -> SessionKeys {
48-
SessionKeys { aura, grandpa, ares }
47+
fn session_keys(aura: AuraId, grandpa: GrandpaId, ares: AresId, im_online: ImOnlineId) -> SessionKeys {
48+
SessionKeys { aura, grandpa, ares, im_online }
49+
// SessionKeys { aura, grandpa, ares }
4950
}
5051

5152
/// Configure initial storage state for FRAME modules.
@@ -95,7 +96,7 @@ pub fn make_ares_genesis(
9596
session: SessionConfig {
9697
keys: initial_authorities
9798
.iter()
98-
.map(|x| (x.0.clone(), x.0.clone(), session_keys(x.2.clone(), x.3.clone(), x.4.clone())))
99+
.map(|x| (x.0.clone(), x.0.clone(), session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone())))
99100
.collect::<Vec<_>>(),
100101
},
101102
grandpa: GrandpaConfig {

node/src/cli.rs

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
use sc_cli::RunCmd;
1+
use sc_cli::{GenericNumber, RunCmd};
22
use structopt::StructOpt;
3+
use std::{fmt::Debug, str::FromStr, sync::Arc};
4+
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
5+
use sc_client_api::{Backend, UsageProvider};
6+
use sc_cli::{Result, CliConfiguration};
7+
use sc_cli::{SharedParams, PruningParams};
8+
use sp_runtime::traits::Zero;
39

410
#[derive(Debug, StructOpt)]
511
pub struct Cli {
@@ -9,12 +15,6 @@ pub struct Cli {
915
#[structopt(flatten)]
1016
pub run: RunCmd,
1117

12-
// #[structopt(long = "request-base")]
13-
// pub request_base: Option<String>,
14-
//
15-
// #[structopt(long = "ares-keys-file")]
16-
// pub ares_keys_file: Option<String>,
17-
1818
#[structopt(long = "warehouse")]
1919
pub warehouse: Option<String>,
2020

@@ -47,7 +47,62 @@ pub enum Subcommand {
4747
/// Revert the chain to a previous state.
4848
Revert(sc_cli::RevertCmd),
4949

50+
/// Revert the chain to a previous state.
51+
ForceRevert(ForceRevertCmd),
52+
5053
/// The custom benchmark subcommmand benchmarking runtime pallets.
5154
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
5255
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
5356
}
57+
58+
59+
/// The `revert` command used revert the chain to a previous state.
60+
#[derive(Debug, StructOpt)]
61+
pub struct ForceRevertCmd {
62+
63+
/// Number of blocks to revert.
64+
#[structopt(default_value = "256")]
65+
pub num: GenericNumber,
66+
67+
#[allow(missing_docs)]
68+
#[structopt(flatten)]
69+
pub shared_params: SharedParams,
70+
71+
#[allow(missing_docs)]
72+
#[structopt(flatten)]
73+
pub pruning_params: PruningParams,
74+
}
75+
76+
impl ForceRevertCmd {
77+
/// Run the revert command
78+
pub async fn run<B, BA, C>(&self, client: Arc<C>, backend: Arc<BA>) -> Result<()>
79+
where
80+
B: BlockT,
81+
BA: Backend<B>,
82+
C: UsageProvider<B>,
83+
<<<B as BlockT>::Header as HeaderT>::Number as FromStr>::Err: Debug,
84+
{
85+
let blocks = self.num.parse()?;
86+
// let force = self.force.parse().unwrap_or(false);
87+
// revert_chain(client, backend, blocks)?;
88+
let reverted = backend.revert(blocks, true)?;
89+
let info = client.usage_info().chain;
90+
91+
if reverted.0.is_zero() {
92+
log::info!("There aren't any non-finalized blocks to force revert.");
93+
} else {
94+
log::info!("Force reverted {} blocks. Best: #{} ({})", reverted.0, info.best_number, info.best_hash);
95+
}
96+
Ok(())
97+
}
98+
}
99+
100+
impl CliConfiguration for ForceRevertCmd {
101+
fn shared_params(&self) -> &SharedParams {
102+
&self.shared_params
103+
}
104+
105+
fn pruning_params(&self) -> Option<&PruningParams> {
106+
Some(&self.pruning_params)
107+
}
108+
}

node/src/command.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,21 @@ pub fn run() -> sc_cli::Result<()> {
214214
Ok((cmd.run(client, backend), task_manager))
215215
})
216216
},
217+
Some(Subcommand::ForceRevert(cmd)) => {
218+
let runner = cli.create_runner(cmd)?;
219+
if runner.config().chain_spec.is_pioneer() {
220+
return runner.async_run(|config| {
221+
let PartialComponents { client, task_manager, backend, .. } =
222+
services::new_partial::<PRuntimeApi, PExecutorDispatch>(&config)?;
223+
Ok((cmd.run(client, backend), task_manager))
224+
})
225+
}
226+
runner.async_run(|config| {
227+
let PartialComponents { client, task_manager, backend, .. } =
228+
services::new_partial::<GRuntimeApi, GExecutorDispatch>(&config)?;
229+
Ok((cmd.run(client, backend), task_manager))
230+
})
231+
},
217232
Some(Subcommand::Benchmark(cmd)) =>
218233
if cfg!(feature = "runtime-benchmarks") {
219234
let runner = cli.create_runner(cmd)?;

runtime/gladios/src/network/part_session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl_opaque_keys! {
1414
pub aura: Aura,
1515
pub grandpa: Grandpa,
1616
pub ares: AresOracle,
17-
// pub im_online: ImOnline,
17+
pub im_online: ImOnline,
1818
}
1919
}
2020

0 commit comments

Comments
 (0)