Skip to content

Commit 0256577

Browse files
committed
feat: add skip_check option
1 parent a8da976 commit 0256577

File tree

4 files changed

+212
-145
lines changed

4 files changed

+212
-145
lines changed

consensus/poscan_grid2d/src/lib.rs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,20 +176,34 @@ impl DoubleHash {
176176
pub struct PoscanAlgorithm<Block, C, AccountId, BlockNumber> {
177177
client: Arc<C>,
178178
_phantom: PhantomData<(Block, AccountId, BlockNumber)>,
179+
skip_check: bool,
179180
}
180181

181182
impl<Block, C, AccountId, BlockNumber> PoscanAlgorithm<Block, C, AccountId, BlockNumber> {
182183
pub fn new(client: Arc<C>) -> Self {
183184
Self {
184185
client,
185186
_phantom: PhantomData,
187+
skip_check: false,
188+
}
189+
}
190+
191+
pub fn with_skip_check(client: Arc<C>, skip_check: bool) -> Self {
192+
Self {
193+
client,
194+
_phantom: PhantomData,
195+
skip_check,
186196
}
187197
}
188198
}
189199

190200
impl<Block, C, AccountId, BlockNumber> Clone for PoscanAlgorithm<Block, C, AccountId, BlockNumber> {
191201
fn clone(&self) -> Self {
192-
Self::new(self.client.clone())
202+
Self {
203+
client: self.client.clone(),
204+
_phantom: PhantomData,
205+
skip_check: self.skip_check,
206+
}
193207
}
194208
}
195209

@@ -297,6 +311,10 @@ where
297311
}
298312
};
299313

314+
if self.skip_check {
315+
return Ok(true);
316+
}
317+
300318
let parent_id = BlockId::<B>::hash(*parent);
301319
let parent_num = self
302320
.client
@@ -323,17 +341,6 @@ where
323341
let obj = poscan_data.obj.clone().to_vec();
324342
let hashes = poscan_data.hashes.clone();
325343

326-
// let ver = self.client
327-
// .runtime_api()
328-
// .version(&parent_id)
329-
// // .map(|d| if parent_num >= SCALE_DIFF_SINCE.into() { d / SCALE_DIFF_BY } else { d })
330-
// .map_err(|err| {
331-
// sc_consensus_poscan::Error::<B>::Environment(format!(
332-
// ">>> get version call failed: {:?}",
333-
// err
334-
// ))
335-
// })?;
336-
337344
if ver.spec_version >= 123 {
338345
info!("poscan: start validate");
339346

@@ -461,6 +468,10 @@ where
461468
}
462469
};
463470

471+
if self.skip_check {
472+
return Ok(true);
473+
}
474+
464475
let parent_id = BlockId::<B>::hash(*parent);
465476
let parent_num = self
466477
.client

nodes/poscan-consensus/src/cli.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ pub struct Cli {
1515

1616
#[clap(long)]
1717
pub threads: Option<usize>,
18+
19+
#[clap(long, help = "Skip verification checks for finalized blocks")]
20+
pub skip_check: bool,
1821
}
1922

2023
#[derive(Debug, clap::Parser)]

nodes/poscan-consensus/src/command.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub fn run() -> sc_cli::Result<()> {
9090
task_manager,
9191
import_queue,
9292
..
93-
} = service::new_partial(&config, None)?;
93+
} = service::new_partial(&config, None, false)?;
9494
Ok((cmd.run(client, import_queue), task_manager))
9595
})
9696
}
@@ -101,7 +101,7 @@ pub fn run() -> sc_cli::Result<()> {
101101
client,
102102
task_manager,
103103
..
104-
} = service::new_partial(&config, None)?;
104+
} = service::new_partial(&config, None, false)?;
105105
Ok((cmd.run(client, config.database), task_manager))
106106
})
107107
}
@@ -112,7 +112,7 @@ pub fn run() -> sc_cli::Result<()> {
112112
client,
113113
task_manager,
114114
..
115-
} = service::new_partial(&config, None)?;
115+
} = service::new_partial(&config, None, false)?;
116116
Ok((cmd.run(client, config.chain_spec), task_manager))
117117
})
118118
}
@@ -124,7 +124,7 @@ pub fn run() -> sc_cli::Result<()> {
124124
task_manager,
125125
import_queue,
126126
..
127-
} = service::new_partial(&config, None)?;
127+
} = service::new_partial(&config, None, false)?;
128128
Ok((cmd.run(client, import_queue), task_manager))
129129
})
130130
}
@@ -140,7 +140,7 @@ pub fn run() -> sc_cli::Result<()> {
140140
task_manager,
141141
backend,
142142
..
143-
} = service::new_partial(&config, None)?;
143+
} = service::new_partial(&config, None, false)?;
144144
// TODO:!!! None ?`
145145
Ok((cmd.run(client, backend, None), task_manager))
146146
})
@@ -241,6 +241,7 @@ pub fn run() -> sc_cli::Result<()> {
241241
config,
242242
cli.author.as_ref().map(|s| s.as_str()),
243243
cli.threads.unwrap_or(1),
244+
cli.skip_check,
244245
),
245246
}
246247
.map_err(sc_cli::Error::Service)

0 commit comments

Comments
 (0)