Skip to content

Commit d486f9f

Browse files
committed
update: fix memory
2 parents 0cd8d67 + 2afde45 commit d486f9f

File tree

42 files changed

+1247
-325
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1247
-325
lines changed

.env.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ ETHEREUM_SETTLEMENT_TXN_WAIT_SLEEP_DELAY_SECS=60
100100

101101
MADARA_ORCHESTRATOR_MADARA_RPC_URL=https://pathfinder-madara-ci.d.karnot.xyz
102102
# It's fine to use dummy for tests as it's not being used.
103-
MADARA_ORCHESTRATOR_MADARA_FEEDER_GATEWAY_URL=http://localhost:8080/feeder_gateway
103+
MADARA_ORCHESTRATOR_MADARA_FEEDER_GATEWAY_URL=http://localhost:8080
104104

105105

106106
#### SNOS ####

.github/workflows/task-test-cli.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
---
22
# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/refs/heads/master/src/schemas/json/github-workflow.json
33
name: Task - Run CLI tests
4-
54
on:
65
workflow_dispatch:
76
workflow_call:
8-
97
jobs:
108
test-cli:
119
runs-on: blacksmith-16vcpu-ubuntu-2204
@@ -14,24 +12,22 @@ jobs:
1412
uses: actions/checkout@v4
1513
with:
1614
submodules: recursive
17-
1815
- name: Load env
1916
uses: ./.github/actions/load-env
20-
2117
- name: Rust setup
2218
uses: ./.github/actions/setup-rust
2319
with:
2420
rust-version: ${{ env.BUILD_RUST_VERSION }}
2521
cache-key: madara-${{ runner.os }}
26-
2722
- name: Run cli without arguments
23+
timeout-minutes: 10
2824
run: |
2925
CARGO_TARGET_DIR=target cargo run --manifest-path madara/Cargo.toml --bin madara --release -- --no-l1-sync --devnet &
3026
MADARA_PID=$!
3127
while ! echo exit | nc localhost 9944; do sleep 1; done
3228
kill $MADARA_PID
33-
3429
- name: Run cli pointing to a file
30+
timeout-minutes: 10
3531
run: |
3632
CARGO_TARGET_DIR=target cargo run --manifest-path madara/Cargo.toml --bin madara --release -- --no-l1-sync --devnet --config-file ./configs/args/config.json &
3733
MADARA_PID=$!

configs/args/config.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
"db_memtable_blocks_budget_mib": 1024,
2828
"db_memtable_contracts_budget_mib": 128,
2929
"db_memtable_other_budget_mib": 128,
30-
"db_memtable_prefix_bloom_filter_ratio": 0
30+
"db_memtable_prefix_bloom_filter_ratio": 0,
31+
"db_wal": true,
32+
"db_fsync": false
3133
},
3234
"l2_sync_params": {
3335
"l2_sync_disabled": false,
@@ -105,6 +107,7 @@
105107
},
106108
"block_production_params": {
107109
"block_production_disabled": false,
110+
"close_preconfirmed_block_upon_restart": false,
108111
"devnet_contracts": 10
109112
},
110113
"chain_config_override": {

configs/chain_config.example.yaml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Chain config version - REQUIRED field
2+
# This version number is used to track breaking changes to the chain config format.
3+
# Current version: 1
4+
config_version: 1
5+
16
# Human readable chain name, for displaying to the console.
27
chain_name: "Starknet Mainnet"
38

@@ -76,6 +81,20 @@ mempool_max_declare_transactions: 20
7681
# Max age of a transaction in the mempool. Null for no age limit.
7782
# mempool_tx_max_age: "5h"
7883
mempool_ttl: null
79-
l2_gas_target: 2000000000
80-
min_l2_gas_price: 100000
81-
l2_gas_price_max_change_denominator: 48
84+
85+
# L2 gas price configuration - choose either 'fixed' or 'eip1559'.
86+
# To override this through CLI, you need to override both the type and the values, or it will panic or lead to unexpected results!
87+
#
88+
# Option 1: Fixed gas price
89+
# l2_gas_price:
90+
# type: fixed
91+
# price: 2500
92+
# For overriding through CLI, use `--chain-config-override=l2_gas_price.type=fixed,l2_gas_price.price=25000`
93+
#
94+
# Option 2: EIP-1559 dynamic gas pricing
95+
# For overriding through CLI, use `--chain-config-override=l2_gas_price.type=eip1559,l2_gas_price.target=2000000000,l2_gas_price.min_price=100000,l2_gas_price.max_change_denominator=48`
96+
l2_gas_price:
97+
type: eip1559
98+
target: 2000000000
99+
min_price: 100000
100+
max_change_denominator: 48

configs/presets/devnet.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
config_version: 1
12
chain_name: "Madara"
23
chain_id: "MADARA_DEVNET"
34
feeder_gateway_url: "http://localhost:8080/feeder_gateway/"
@@ -36,6 +37,8 @@ eth_gps_statement_verifier: "0xf294781D719D2F4169cE54469C28908E6FA752C1"
3637
mempool_max_transactions: 10000
3738
mempool_max_declare_transactions: 20
3839
mempool_ttl: null
39-
l2_gas_target: 2000000000
40-
min_l2_gas_price: 100000
41-
l2_gas_price_max_change_denominator: 48
40+
l2_gas_price:
41+
type: eip1559
42+
target: 2000000000
43+
min_price: 100000
44+
max_change_denominator: 48

configs/presets/integration.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
config_version: 1
12
chain_name: "Starknet Sepolia"
23
chain_id: "SN_INTEGRATION_SEPOLIA"
34
feeder_gateway_url: "https://integration-sepolia.starknet.io/feeder_gateway/"
@@ -36,6 +37,8 @@ eth_gps_statement_verifier: "0x2046B966994Adcb88D83f467a41b75d64C2a619F"
3637
mempool_max_transactions: 10000
3738
mempool_max_declare_transactions: 20
3839
mempool_ttl: "5h"
39-
l2_gas_target: 2000000000
40-
min_l2_gas_price: 100000
41-
l2_gas_price_max_change_denominator: 48
40+
l2_gas_price:
41+
type: eip1559
42+
target: 2000000000
43+
min_price: 100000
44+
max_change_denominator: 48

configs/presets/mainnet.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
config_version: 1
12
chain_name: "Starknet Mainnet"
23
chain_id: "SN_MAIN"
34
feeder_gateway_url: "https://alpha-mainnet.starknet.io/feeder_gateway/"
@@ -36,6 +37,8 @@ eth_gps_statement_verifier: "0x47312450B3Ac8b5b8e247a6bB6d523e7605bDb60"
3637
mempool_max_transactions: 10000
3738
mempool_max_declare_transactions: 20
3839
mempool_ttl: "5h"
39-
l2_gas_target: 2000000000
40-
min_l2_gas_price: 100000
41-
l2_gas_price_max_change_denominator: 48
40+
l2_gas_price:
41+
type: eip1559
42+
target: 2000000000
43+
min_price: 100000
44+
max_change_denominator: 48

configs/presets/sepolia.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
config_version: 1
12
chain_name: "Starknet Sepolia"
23
chain_id: "SN_SEPOLIA"
34
feeder_gateway_url: "https://alpha-sepolia.starknet.io/feeder_gateway/"
@@ -36,6 +37,8 @@ eth_gps_statement_verifier: "0xf294781D719D2F4169cE54469C28908E6FA752C1"
3637
mempool_max_transactions: 10000
3738
mempool_max_declare_transactions: 20
3839
mempool_ttl: "5h"
39-
l2_gas_target: 2000000000
40-
min_l2_gas_price: 100000
41-
l2_gas_price_max_change_denominator: 48
40+
l2_gas_price:
41+
type: eip1559
42+
target: 2000000000
43+
min_price: 100000
44+
max_change_denominator: 48

madara/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

madara/crates/client/block_production/src/lib.rs

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ pub struct BlockProductionTask {
252252
bypass_pending_count: Arc<AtomicU64>,
253253
executor_batch_pending_count: Arc<AtomicU64>,
254254
executor_commands_pending_count: Arc<AtomicU64>,
255+
close_preconfirmed_block_upon_restart: bool,
255256
}
256257

257258
impl BlockProductionTask {
@@ -261,6 +262,7 @@ impl BlockProductionTask {
261262
metrics: Arc<BlockProductionMetrics>,
262263
l1_client: Arc<dyn SettlementClient>,
263264
no_charge_fee: bool,
265+
close_preconfirmed_block_upon_restart: bool,
264266
) -> Self {
265267
let (sender, recv) = mpsc::unbounded_channel();
266268
let (bypass_input_sender, bypass_tx_input) = mpsc::channel(16);
@@ -288,6 +290,7 @@ impl BlockProductionTask {
288290
bypass_pending_count,
289291
executor_batch_pending_count,
290292
executor_commands_pending_count,
293+
close_preconfirmed_block_upon_restart,
291294
}
292295
}
293296

@@ -312,18 +315,35 @@ impl BlockProductionTask {
312315
///
313316
/// This avoids re-executing transaction by re-adding them to the [Mempool].
314317
async fn close_pending_block_if_exists(&mut self) -> anyhow::Result<()> {
315-
if self.backend.has_preconfirmed_block() {
316-
tracing::debug!("Close pending block on startup.");
317-
let backend = self.backend.clone();
318-
global_spawn_rayon_task(move || {
319-
backend
320-
.write_access()
321-
.close_preconfirmed(
322-
/* pre_v0_13_2_hash_override */ true, None, /*this won't be none in ideal case*/
323-
)
324-
.context("Closing preconfirmed block on startup")
325-
})
326-
.await?;
318+
if let Some(preconfirmed_block) = self.backend.preconfirmed_block() {
319+
// Get the preconfirmed block info for logging
320+
let block_number = preconfirmed_block.header.block_number;
321+
let tx_count = preconfirmed_block.transaction_count();
322+
323+
if self.close_preconfirmed_block_upon_restart {
324+
tracing::info!(
325+
"📦 Preconfirmed block #{} found with {} transactions. Closing it.",
326+
block_number,
327+
tx_count
328+
);
329+
let backend = self.backend.clone();
330+
global_spawn_rayon_task(move || {
331+
backend
332+
.write_access()
333+
.close_preconfirmed(
334+
/* pre_v0_13_2_hash_override */ true, None, /*this won't be none in ideal case*/
335+
)
336+
.context("Closing preconfirmed block on startup")
337+
})
338+
.await?;
339+
tracing::info!("✅ Preconfirmed block #{} closed successfully on startup.", block_number);
340+
} else {
341+
tracing::info!(
342+
"📦 Preconfirmed block #{} found with {} transactions. Resuming block production.",
343+
block_number,
344+
tx_count
345+
);
346+
}
327347
}
328348
Ok(())
329349
}
@@ -580,6 +600,7 @@ pub(crate) mod tests {
580600
self.metrics.clone(),
581601
Arc::new(self.l1_client.clone()),
582602
true,
603+
true, // close_preconfirmed_block_upon_restart - default to true for tests
583604
)
584605
}
585606
}

0 commit comments

Comments
 (0)