Skip to content

Commit

Permalink
Add ProposerFactory limits to the cli (#893)
Browse files Browse the repository at this point in the history
* Add `ProposerFactory` limits to the cli

* Bump collator version

* Fix for not(evm-tracing) start functions

* Refactor start parameters to a struct

* Add comments to `StartupConfiguration`

* Use default values for proposer cli args
  • Loading branch information
0x7CFE authored Mar 29, 2023
1 parent 0b9a435 commit 6ba5f3c
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 94 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.

2 changes: 1 addition & 1 deletion bin/collator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astar-collator"
version = "5.1.0"
version = "5.2.0"
description = "Astar collator implementation in Rust."
build = "build.rs"
default-run = "astar-collator"
Expand Down
8 changes: 8 additions & 0 deletions bin/collator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,14 @@ pub struct Cli {
/// Relaychain arguments
#[clap(raw = true)]
pub relaychain_args: Vec<String>,

/// Proposer's maximum block size limit in bytes
#[clap(long, default_value = sc_basic_authorship::DEFAULT_BLOCK_SIZE_LIMIT.to_string())]
pub proposer_block_size_limit: usize,

/// Proposer's soft deadline in percents of block size
#[clap(long, default_value = "50")]
pub proposer_soft_deadline_percent: u8,
}

/// Possible subcommands of the main binary.
Expand Down
67 changes: 59 additions & 8 deletions bin/collator/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use crate::{
cli::{Cli, RelayChainCli, Subcommand},
local::{self, development_config},
parachain::{
self, astar, chain_spec, shibuya, shiden, start_astar_node, start_shibuya_node,
start_shiden_node,
self, astar, chain_spec, service::StartupConfiguration, shibuya, shiden, start_astar_node,
start_shibuya_node, start_shiden_node,
},
primitives::Block,
};
Expand Down Expand Up @@ -884,17 +884,44 @@ pub fn run() -> Result<()> {

#[cfg(feature = "evm-tracing")]
if config.chain_spec.is_astar() {
start_astar_node(config, polkadot_config, evm_tracing_config, collator_options, para_id, cli.enable_evm_rpc)
start_astar_node(StartupConfiguration {
parachain_config: config,
polkadot_config,
evm_tracing_config,
collator_options,
id: para_id,
enable_evm_rpc: cli.enable_evm_rpc,
proposer_block_size_limit: cli.proposer_block_size_limit,
proposer_soft_deadline_percent: cli.proposer_soft_deadline_percent,
})
.await
.map(|r| r.0)
.map_err(Into::into)
} else if config.chain_spec.is_shiden() {
start_shiden_node(config, polkadot_config, evm_tracing_config, collator_options, para_id, cli.enable_evm_rpc)
start_shiden_node(StartupConfiguration {
parachain_config: config,
polkadot_config,
evm_tracing_config,
collator_options,
id: para_id,
enable_evm_rpc: cli.enable_evm_rpc,
proposer_block_size_limit: cli.proposer_block_size_limit,
proposer_soft_deadline_percent: cli.proposer_soft_deadline_percent,
})
.await
.map(|r| r.0)
.map_err(Into::into)
} else if config.chain_spec.is_shibuya() {
start_shibuya_node(config, polkadot_config, evm_tracing_config, collator_options, para_id, cli.enable_evm_rpc)
start_shibuya_node(StartupConfiguration {
parachain_config: config,
polkadot_config,
evm_tracing_config,
collator_options,
id: para_id,
enable_evm_rpc: cli.enable_evm_rpc,
proposer_block_size_limit: cli.proposer_block_size_limit,
proposer_soft_deadline_percent: cli.proposer_soft_deadline_percent,
})
.await
.map(|r| r.0)
.map_err(Into::into)
Expand All @@ -906,17 +933,41 @@ pub fn run() -> Result<()> {

#[cfg(not(feature = "evm-tracing"))]
if config.chain_spec.is_astar() {
start_astar_node(config, polkadot_config, collator_options, para_id, cli.enable_evm_rpc)
start_astar_node(StartupConfiguration {
parachain_config: config,
polkadot_config,
collator_options,
id: para_id,
enable_evm_rpc: cli.enable_evm_rpc,
proposer_block_size_limit: cli.proposer_block_size_limit,
proposer_soft_deadline_percent: cli.proposer_soft_deadline_percent,
})
.await
.map(|r| r.0)
.map_err(Into::into)
} else if config.chain_spec.is_shiden() {
start_shiden_node(config, polkadot_config, collator_options, para_id, cli.enable_evm_rpc)
start_shiden_node(StartupConfiguration {
parachain_config: config,
polkadot_config,
collator_options,
id: para_id,
enable_evm_rpc: cli.enable_evm_rpc,
proposer_block_size_limit: cli.proposer_block_size_limit,
proposer_soft_deadline_percent: cli.proposer_soft_deadline_percent,
})
.await
.map(|r| r.0)
.map_err(Into::into)
} else if config.chain_spec.is_shibuya() {
start_shibuya_node(config, polkadot_config, collator_options, para_id, cli.enable_evm_rpc)
start_shibuya_node(StartupConfiguration {
parachain_config: config,
polkadot_config,
collator_options,
id: para_id,
enable_evm_rpc: cli.enable_evm_rpc,
proposer_block_size_limit: cli.proposer_block_size_limit,
proposer_soft_deadline_percent: cli.proposer_soft_deadline_percent,
})
.await
.map(|r| r.0)
.map_err(Into::into)
Expand Down
Loading

0 comments on commit 6ba5f3c

Please sign in to comment.