Skip to content

Commit 923a6c8

Browse files
authored
Merge pull request #1502 from Phala-Network/faster-e2e
phala-node: Configurable gossip duration.
2 parents 63fdb12 + e8d52cd commit 923a6c8

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

e2e/src/fullstack.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ const quickMode = process.env.QUICK == '1';
3232
let keyring;
3333

3434
const CENTS = 10_000_000_000;
35-
const blockInterval = quickMode ? 100 : 1000;
35+
const blockInterval = quickMode ? 100 : 300; // ms
36+
const gossipDuration = 20; // ms
3637

3738
console.log(`Testing in ${inSgx ? "SGX Hardware" : "Software"} mode`);
3839

@@ -1369,8 +1370,6 @@ class Cluster {
13691370
await this._reservePorts();
13701371
this._createProcesses();
13711372
await this._launchAndWait();
1372-
await this._createApi();
1373-
await this._transferPherryGasFree();
13741373
}
13751374

13761375
async kill() {
@@ -1498,6 +1497,8 @@ class Cluster {
14981497
waitNodeOutput(this.processNode),
14991498
...this.workers.map(w => waitPRuntimeOutput(w.processPRuntime)),
15001499
]);
1500+
await this._createApi();
1501+
await this._transferPherryGasFree();
15011502
// Launch relayers
15021503
await Promise.all(this.workers.map(w => waitRelayerOutput(w.processRelayer)));
15031504
}
@@ -1542,6 +1543,7 @@ function newNode(rpcPort, tmpPath, name = 'node') {
15421543
pathNode, [
15431544
'--dev',
15441545
`--block-millisecs=${blockInterval}`,
1546+
`--gossip-duration-millisecs=${gossipDuration}`,
15451547
'--base-path=' + path.resolve(tmpPath, 'phala-node'),
15461548
`--rpc-port=${rpcPort}`,
15471549
'--rpc-methods=Unsafe',

standalone/node/src/chain_spec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ pub(crate) mod tests {
579579
sync,
580580
transaction_pool,
581581
..
582-
} = new_full_base(config, false, |_, _| ())?;
582+
} = new_full_base(config, false, |_, _| (), None)?;
583583
Ok(sc_service_test::TestNetComponents::new(
584584
task_manager,
585585
client,

standalone/node/src/cli.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ pub struct Cli {
4040
/// Custom block duration in milliseconds (only useful with --dev)
4141
#[arg(long)]
4242
pub block_millisecs: Option<u64>,
43+
44+
/// Custom gossip duration in milliseconds.
45+
#[arg(long)]
46+
pub gossip_duration_millisecs: Option<u64>,
4347
}
4448

4549
/// Possible subcommands of the main binary.

standalone/node/src/command.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,12 @@ pub fn run() -> sc_cli::Result<()> {
9494
None => {
9595
let runner = cli.create_runner(&cli.run)?;
9696
runner.run_node_until_exit(|config| async move {
97-
service::new_full(config, cli.no_hardware_benchmarks)
98-
.map_err(sc_cli::Error::Service)
97+
service::new_full(
98+
config,
99+
cli.no_hardware_benchmarks,
100+
cli.gossip_duration_millisecs,
101+
)
102+
.map_err(sc_cli::Error::Service)
99103
})
100104
}
101105
Some(Subcommand::Inspect(cmd)) => {

standalone/node/src/service.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ pub fn new_full_base(
353353
&sc_consensus_babe::BabeBlockImport<Block, FullClient, FullGrandpaBlockImport>,
354354
&sc_consensus_babe::BabeLink<Block>,
355355
),
356+
gossip_duration_millis: Option<u64>,
356357
) -> Result<NewFullBase, ServiceError> {
357358
let hwbench = if !disable_hardware_benchmarks {
358359
config.database.path().map(|database_path| {
@@ -547,7 +548,7 @@ pub fn new_full_base(
547548

548549
let grandpa_config = grandpa::Config {
549550
// FIXME #1578 make this available through chainspec
550-
gossip_duration: std::time::Duration::from_millis(333),
551+
gossip_duration: std::time::Duration::from_millis(gossip_duration_millis.unwrap_or(333)),
551552
justification_generation_period: 1, // https://github.com/paritytech/substrate/pull/14423#issuecomment-1633837906
552553
name: Some(name),
553554
observer_enabled: false,
@@ -624,9 +625,15 @@ pub fn new_full_base(
624625
pub fn new_full(
625626
config: Configuration,
626627
disable_hardware_benchmarks: bool,
628+
gossip_duration_millis: Option<u64>,
627629
) -> Result<TaskManager, ServiceError> {
628-
new_full_base(config, disable_hardware_benchmarks, |_, _| ())
629-
.map(|NewFullBase { task_manager, .. }| task_manager)
630+
new_full_base(
631+
config,
632+
disable_hardware_benchmarks,
633+
|_, _| (),
634+
gossip_duration_millis,
635+
)
636+
.map(|NewFullBase { task_manager, .. }| task_manager)
630637
}
631638

632639
#[cfg(test)]
@@ -705,6 +712,7 @@ mod tests {
705712
babe_link: &sc_consensus_babe::BabeLink<Block>| {
706713
setup_handles = Some((block_import.clone(), babe_link.clone()));
707714
},
715+
None,
708716
)?;
709717

710718
let node = sc_service_test::TestNetComponents::new(
@@ -900,7 +908,7 @@ mod tests {
900908
sync,
901909
transaction_pool,
902910
..
903-
} = new_full_base(config, false, |_, _| ())?;
911+
} = new_full_base(config, false, |_, _| (), None)?;
904912
Ok(sc_service_test::TestNetComponents::new(
905913
task_manager,
906914
client,

0 commit comments

Comments
 (0)