Skip to content

Commit

Permalink
Merge pull request #1000 from UniqueNetwork/fix/minting-prop-weight
Browse files Browse the repository at this point in the history
Refactor property writing + dev mode enhancements
  • Loading branch information
CertainLach authored Oct 2, 2023
2 parents dc6f0e2 + 630fc89 commit 22b45b5
Show file tree
Hide file tree
Showing 42 changed files with 2,320 additions and 1,648 deletions.
4 changes: 2 additions & 2 deletions .docker/Dockerfile-chain-dev
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ COPY . /dev_chain

WORKDIR /dev_chain

RUN cargo build --release
RUN cargo build --profile integration-tests --features=${NETWORK}-runtime
RUN echo "$NETWORK"

CMD cargo run --release --features=${NETWORK}-runtime -- --dev -linfo --rpc-cors=all --unsafe-rpc-external
CMD cargo run --profile integration-tests --features=${NETWORK}-runtime -- --dev -linfo --rpc-cors=all --unsafe-rpc-external
2 changes: 1 addition & 1 deletion .docker/Dockerfile-unique
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RUN --mount=type=cache,target=/cargo-home/registry \
--mount=type=cache,target=/unique_parachain/unique-chain/target \
cd unique-chain && \
echo "Using runtime features '$RUNTIME_FEATURES'" && \
CARGO_INCREMENTAL=0 cargo build --release --features="$RUNTIME_FEATURES" --locked && \
CARGO_INCREMENTAL=0 cargo build --profile integration-tests --features="$RUNTIME_FEATURES" --locked && \
mv ./target/release/unique-collator /unique_parachain/unique-chain/ && \
cd target/release/wbuild && find . -name "*.wasm" -exec sh -c 'mkdir -p "../../../wasm/$(dirname {})"; cp {} "../../../wasm/{}"' \;

Expand Down
2 changes: 1 addition & 1 deletion .docker/docker-compose.gov.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ services:
options:
max-size: "1m"
max-file: "3"
command: cargo run --release --features={{ NETWORK }}-runtime,gov-test-timings -- --dev -linfo --rpc-cors=all --unsafe-rpc-external
command: cargo run --profile integration-tests --features={{ NETWORK }}-runtime,gov-test-timings -- --dev -linfo --rpc-cors=all --unsafe-rpc-external
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ inherits = "release"
lto = true
opt-level = 3

[profile.integration-tests]
inherits = "release"
debug-assertions = true

[workspace.dependencies]
# Unique
app-promotion-rpc = { path = "primitives/app_promotion_rpc", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ evm_stubs: UniqueFungible UniqueNFT UniqueRefungible UniqueRefungibleToken Contr

.PHONY: _bench
_bench:
cargo run --release --features runtime-benchmarks,$(RUNTIME) -- \
cargo run --profile production --features runtime-benchmarks,$(RUNTIME) -- \
benchmark pallet --pallet pallet-$(if $(PALLET),$(PALLET),$(error Must set PALLET)) \
--wasm-execution compiled --extrinsic '*' \
$(if $(TEMPLATE),$(TEMPLATE),--template=.maintain/frame-weight-template.hbs) --steps=50 --repeat=80 --heap-pages=4096 \
Expand Down
12 changes: 11 additions & 1 deletion node/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,20 @@ pub struct Cli {
/// an empty block will be sealed automatically
/// after the `--idle-autoseal-interval` milliseconds.
///
/// The default interval is 500 milliseconds
/// The default interval is 500 milliseconds.
#[structopt(default_value = "500", long)]
pub idle_autoseal_interval: u64,

/// Disable auto-sealing blocks on new transactions in the `--dev` mode.
#[structopt(long)]
pub disable_autoseal_on_tx: bool,

/// Finalization delay (in seconds) of auto-sealed blocks in the `--dev` mode.
///
/// Disabled by default.
#[structopt(long)]
pub autoseal_finalization_delay: Option<u64>,

/// Disable automatic hardware benchmarks.
///
/// By default these benchmarks are automatically ran at startup and measure
Expand Down
5 changes: 1 addition & 4 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ use sc_cli::{
use sc_service::config::{BasePath, PrometheusConfig};
use sp_core::hexdisplay::HexDisplay;
use sp_runtime::traits::{AccountIdConversion, Block as BlockT};
use std::{time::Duration};

use up_common::types::opaque::{Block, RuntimeId};

Expand Down Expand Up @@ -481,14 +480,12 @@ pub fn run() -> Result<()> {
if is_dev_service {
info!("Running Dev service");

let autoseal_interval = Duration::from_millis(cli.idle_autoseal_interval);

let mut config = config;

config.state_pruning = Some(sc_service::PruningMode::ArchiveAll);

return start_node_using_chain_runtime! {
start_dev_node(config, autoseal_interval).map_err(Into::into)
start_dev_node(config, cli.idle_autoseal_interval, cli.autoseal_finalization_delay, cli.disable_autoseal_on_tx).map_err(Into::into)
};
};

Expand Down
33 changes: 27 additions & 6 deletions node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ pub struct AutosealInterval {
}

impl AutosealInterval {
pub fn new(config: &Configuration, interval: Duration) -> Self {
pub fn new(config: &Configuration, interval: u64) -> Self {
let _tokio_runtime = config.tokio_handle.enter();
let interval = tokio::time::interval(interval);
let interval = tokio::time::interval(Duration::from_millis(interval));

Self { interval }
}
Expand Down Expand Up @@ -885,7 +885,9 @@ pub struct OtherPartial {
/// the parachain inherent
pub fn start_dev_node<Runtime, RuntimeApi, ExecutorDispatch>(
config: Configuration,
autoseal_interval: Duration,
autoseal_interval: u64,
autoseal_finalize_delay: Option<u64>,
disable_autoseal_on_tx: bool,
) -> sc_service::error::Result<TaskManager>
where
Runtime: RuntimeInstance + Send + Sync + 'static,
Expand All @@ -912,7 +914,10 @@ where
+ sp_consensus_aura::AuraApi<Block, AuraId>,
ExecutorDispatch: NativeExecutionDispatch + 'static,
{
use sc_consensus_manual_seal::{run_manual_seal, EngineCommand, ManualSealParams};
use sc_consensus_manual_seal::{
run_manual_seal, run_delayed_finalize, EngineCommand, ManualSealParams,
DelayedFinalizeParams,
};
use fc_consensus::FrontierBlockImport;

let sc_service::PartialComponents {
Expand Down Expand Up @@ -980,20 +985,22 @@ where
.pool()
.validated_pool()
.import_notification_stream()
.filter(move |_| futures::future::ready(!disable_autoseal_on_tx))
.map(|_| EngineCommand::SealNewBlock {
create_empty: true,
finalize: false, // todo:collator finalize true
finalize: false,
parent_hash: None,
sender: None,
}),
);

let autoseal_interval = Box::pin(AutosealInterval::new(&config, autoseal_interval));

let idle_commands_stream: Box<
dyn Stream<Item = EngineCommand<Hash>> + Send + Sync + Unpin,
> = Box::new(autoseal_interval.map(|_| EngineCommand::SealNewBlock {
create_empty: true,
finalize: false, // todo:collator finalize true
finalize: false,
parent_hash: None,
sender: None,
}));
Expand All @@ -1003,6 +1010,20 @@ where
let slot_duration = cumulus_client_consensus_aura::slot_duration(&*client)?;
let client_set_aside_for_cidp = client.clone();

if let Some(delay_sec) = autoseal_finalize_delay {
let spawn_handle = task_manager.spawn_handle();

task_manager.spawn_essential_handle().spawn_blocking(
"finalization_task",
Some("block-authoring"),
run_delayed_finalize(DelayedFinalizeParams {
client: client.clone(),
delay_sec,
spawn_handle,
}),
);
}

task_manager.spawn_essential_handle().spawn_blocking(
"authorship_task",
Some("block-authoring"),
Expand Down
Loading

0 comments on commit 22b45b5

Please sign in to comment.