Skip to content

Commit

Permalink
Merge remote-tracking branch 'pha/master' into frontier
Browse files Browse the repository at this point in the history
  • Loading branch information
kvinwang committed Jan 4, 2024
2 parents 1038129 + e4dac85 commit 11dfceb
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

8 changes: 5 additions & 3 deletions e2e/src/fullstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const quickMode = process.env.QUICK == '1';
let keyring;

const CENTS = 10_000_000_000;
const blockInterval = quickMode ? 100 : 1000;
const blockInterval = quickMode ? 100 : 300; // ms
const gossipDuration = 20; // ms

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

Expand Down Expand Up @@ -1369,8 +1370,6 @@ class Cluster {
await this._reservePorts();
this._createProcesses();
await this._launchAndWait();
await this._createApi();
await this._transferPherryGasFree();
}

async kill() {
Expand Down Expand Up @@ -1498,6 +1497,8 @@ class Cluster {
waitNodeOutput(this.processNode),
...this.workers.map(w => waitPRuntimeOutput(w.processPRuntime)),
]);
await this._createApi();
await this._transferPherryGasFree();
// Launch relayers
await Promise.all(this.workers.map(w => waitRelayerOutput(w.processRelayer)));
}
Expand Down Expand Up @@ -1542,6 +1543,7 @@ function newNode(rpcPort, tmpPath, name = 'node') {
pathNode, [
'--dev',
`--block-millisecs=${blockInterval}`,
`--gossip-duration-millisecs=${gossipDuration}`,
'--base-path=' + path.resolve(tmpPath, 'phala-node'),
`--rpc-port=${rpcPort}`,
'--rpc-methods=Unsafe',
Expand Down
2 changes: 1 addition & 1 deletion standalone/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ pub(crate) mod tests {
sync,
transaction_pool,
..
} = new_full_base(config, Default::default(), false)?;
} = new_full_base(config, Default::default(), false, None)?;
Ok(sc_service_test::TestNetComponents::new(
task_manager,
client,
Expand Down
4 changes: 4 additions & 0 deletions standalone/node/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ pub struct Cli {
#[arg(long)]
pub block_millisecs: Option<u64>,

/// Custom gossip duration in milliseconds.
#[arg(long)]
pub gossip_duration_millisecs: Option<u64>,

/// Ethereum RPC configuration.
#[command(flatten)]
pub eth: EthConfiguration,
Expand Down
11 changes: 8 additions & 3 deletions standalone/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,14 @@ pub fn run() -> sc_cli::Result<()> {
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node_until_exit(|config| async move {
service::new_full(config, &cli.eth, cli.no_hardware_benchmarks)
.await
.map_err(sc_cli::Error::Service)
service::new_full(
config,
&cli.eth,
cli.no_hardware_benchmarks,
cli.gossip_duration_millisecs,
)
.await
.map_err(sc_cli::Error::Service)
})
}
Some(Subcommand::Inspect(cmd)) => {
Expand Down
15 changes: 11 additions & 4 deletions standalone/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ pub async fn new_full_base(
config: Configuration,
eth_config: &EthConfiguration,
disable_hardware_benchmarks: bool,
gossip_duration_millis: Option<u64>,
) -> Result<NewFullBase, ServiceError> {
let hwbench = if !disable_hardware_benchmarks {
config.database.path().map(|database_path| {
Expand Down Expand Up @@ -660,7 +661,7 @@ pub async fn new_full_base(

let grandpa_config = grandpa::Config {
// FIXME #1578 make this available through chainspec
gossip_duration: std::time::Duration::from_millis(333),
gossip_duration: std::time::Duration::from_millis(gossip_duration_millis.unwrap_or(333)),
justification_generation_period: 1, // https://github.com/paritytech/substrate/pull/14423#issuecomment-1633837906
name: Some(name),
observer_enabled: false,
Expand Down Expand Up @@ -736,10 +737,16 @@ pub async fn new_full(
config: Configuration,
eth_config: &EthConfiguration,
disable_hardware_benchmarks: bool,
gossip_duration_millis: Option<u64>,
) -> Result<TaskManager, ServiceError> {
new_full_base(config, eth_config, disable_hardware_benchmarks)
.await
.map(|NewFullBase { task_manager, .. }| task_manager)
new_full_base(
config,
eth_config,
disable_hardware_benchmarks,
gossip_duration_millis,
)
.await
.map(|NewFullBase { task_manager, .. }| task_manager)
}

/// Build the import queue for the runtime (babe + grandpa).
Expand Down
2 changes: 1 addition & 1 deletion standalone/prouter/Cargo.lock

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

43 changes: 1 addition & 42 deletions standalone/pruntime/Cargo.lock

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

3 changes: 2 additions & 1 deletion standalone/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ impl OnUnbalanced<NegativeImbalance> for DealWithServiceFee {

parameter_types! {
pub EIP712Name: Vec<u8> = b"PhalaNetwork".to_vec();
pub EIP712Version: Vec<u8> = b"1".to_vec();
pub EIP712Version: Vec<u8> = b"2".to_vec();
pub EIP712ChainID: pallet_evm_account_mapping::EIP712ChainID = sp_core::U256::from(0);
pub EIP712VerifyingContractAddress: pallet_evm_account_mapping::EIP712VerifyingContractAddress = sp_core::H160::from([0u8; 20]);
}
Expand All @@ -1583,6 +1583,7 @@ impl pallet_evm_account_mapping::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Currency = Balances;
type AddressConverter = pallet_evm_account_mapping::EvmTransparentConverter;
type ServiceFee = ConstU128<10000000000>; // 0.01 PHA
type OnUnbalancedForServiceFee = DealWithServiceFee;
type CallFilter = frame_support::traits::Everything;
Expand Down

0 comments on commit 11dfceb

Please sign in to comment.