From 8076c8d2b815a6c30b685c7c7d4aacdedb615e82 Mon Sep 17 00:00:00 2001 From: Michal Swietek Date: Tue, 21 Feb 2023 09:38:32 +0100 Subject: [PATCH 1/4] enforce-heap-pages --- bin/node/src/main.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bin/node/src/main.rs b/bin/node/src/main.rs index 5f9be712aa..10bfcd4f2b 100644 --- a/bin/node/src/main.rs +++ b/bin/node/src/main.rs @@ -6,10 +6,11 @@ use aleph_runtime::Block; use log::warn; use sc_cli::{clap::Parser, CliConfiguration, PruningParams, SubstrateCli}; use sc_network::config::Role; -use sc_service::PartialComponents; +use sc_service::{Configuration, PartialComponents}; const STATE_PRUNING: &str = "archive"; const BLOCKS_PRUNING: &str = "archive-canonical"; +const HEAP_PAGES: u64 = 4094; fn pruning_changed(params: &PruningParams) -> bool { let state_pruning_changed = @@ -21,6 +22,12 @@ fn pruning_changed(params: &PruningParams) -> bool { state_pruning_changed || blocks_pruning_changed } +// The default number of heap pages in substrate is 2048. Every heap page is 64KB, +// so value of 4096 gives 256MB memory for entire runtime. +fn enforce_heap_pages(config: &mut Configuration) { + config.default_heap_pages = Some(HEAP_PAGES); +} + fn main() -> sc_cli::Result<()> { let mut cli = Cli::parse(); let overwritten_pruning = pruning_changed(&cli.run.import_params.pruning_params); @@ -115,7 +122,7 @@ fn main() -> sc_cli::Result<()> { None => { let runner = cli.create_runner(&cli.run)?; if cli.aleph.experimental_pruning() { - warn!("Experimental_pruning was turned on. Usage of this flag can lead to misbehaviour, which can be punished. State pruning: {:?}; Blocks pruning: {:?};", + warn!("Experimental_pruning was turned on. Usage of this flag can lead to misbehaviour, which can be punished. State pruning: {:?}; Blocks pruning: {:?};", cli.run.state_pruning()?.unwrap_or_default(), cli.run.blocks_pruning()?, ); @@ -124,7 +131,9 @@ fn main() -> sc_cli::Result<()> { } let aleph_cli_config = cli.aleph; - runner.run_node_until_exit(|config| async move { + runner.run_node_until_exit(|mut config| async move { + enforce_heap_pages(&mut config); + match config.role { Role::Authority => { new_authority(config, aleph_cli_config).map_err(sc_cli::Error::Service) From d6b68bfe6063fb7054485113c9c39c94d3a9c8e3 Mon Sep 17 00:00:00 2001 From: Michal Swietek Date: Tue, 21 Feb 2023 09:43:12 +0100 Subject: [PATCH 2/4] set call stack --- bin/runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/runtime/src/lib.rs b/bin/runtime/src/lib.rs index 70a2f8223c..e6dc697bc0 100644 --- a/bin/runtime/src/lib.rs +++ b/bin/runtime/src/lib.rs @@ -681,7 +681,7 @@ impl pallet_contracts::Config for Runtime { type DeletionQueueDepth = DeletionQueueDepth; type DeletionWeightLimit = DeletionWeightLimit; type Schedule = Schedule; - type CallStack = [pallet_contracts::Frame; 31]; + type CallStack = [pallet_contracts::Frame; 16]; type AddressGenerator = pallet_contracts::DefaultAddressGenerator; type MaxCodeLen = ConstU32<{ 128 * 1024 }>; type MaxStorageKeyLen = ConstU32<128>; From 317d87836433e2304d7ca714db29c85bf4554d20 Mon Sep 17 00:00:00 2001 From: Michal Swietek Date: Tue, 21 Feb 2023 09:47:01 +0100 Subject: [PATCH 3/4] bump-spec-version --- bin/runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/runtime/src/lib.rs b/bin/runtime/src/lib.rs index e6dc697bc0..753b807773 100644 --- a/bin/runtime/src/lib.rs +++ b/bin/runtime/src/lib.rs @@ -106,7 +106,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("aleph-node"), impl_name: create_runtime_str!("aleph-node"), authoring_version: 1, - spec_version: 52, + spec_version: 53, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 14, From 11bf454942dca9aadb8cbbe00511789c269cad0a Mon Sep 17 00:00:00 2001 From: Michal Swietek Date: Tue, 21 Feb 2023 10:09:13 +0100 Subject: [PATCH 4/4] fix-typo --- bin/node/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/node/src/main.rs b/bin/node/src/main.rs index 10bfcd4f2b..ac331bc132 100644 --- a/bin/node/src/main.rs +++ b/bin/node/src/main.rs @@ -10,7 +10,7 @@ use sc_service::{Configuration, PartialComponents}; const STATE_PRUNING: &str = "archive"; const BLOCKS_PRUNING: &str = "archive-canonical"; -const HEAP_PAGES: u64 = 4094; +const HEAP_PAGES: u64 = 4096; fn pruning_changed(params: &PruningParams) -> bool { let state_pruning_changed =