Skip to content

Commit 6aac116

Browse files
[upgrade] Migrate to CL@v0.0.58 (#141)
* add buffer pool * update size
1 parent b39de55 commit 6aac116

File tree

3 files changed

+50
-42
lines changed

3 files changed

+50
-42
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ resolver = "2"
1010
[workspace.dependencies]
1111
alto-client = { version = "0.0.13", path = "client" }
1212
alto-types = { version = "0.0.13", path = "types" }
13-
commonware-broadcast = { version = "0.0.57" }
14-
commonware-codec = { version = "0.0.57" }
15-
commonware-consensus = { version = "0.0.57" }
16-
commonware-cryptography = { version = "0.0.57" }
17-
commonware-deployer = { version = "0.0.57", default-features = false }
18-
commonware-macros = { version = "0.0.57" }
19-
commonware-p2p = { version = "0.0.57" }
20-
commonware-resolver = { version = "0.0.57" }
21-
commonware-runtime = { version = "0.0.57" }
22-
commonware-storage = { version = "0.0.57" }
23-
commonware-stream = { version = "0.0.57" }
24-
commonware-utils = { version = "0.0.57" }
13+
commonware-broadcast = { version = "0.0.58" }
14+
commonware-codec = { version = "0.0.58" }
15+
commonware-consensus = { version = "0.0.58" }
16+
commonware-cryptography = { version = "0.0.58" }
17+
commonware-deployer = { version = "0.0.58", default-features = false }
18+
commonware-macros = { version = "0.0.58" }
19+
commonware-p2p = { version = "0.0.58" }
20+
commonware-resolver = { version = "0.0.58" }
21+
commonware-runtime = { version = "0.0.58" }
22+
commonware-storage = { version = "0.0.58" }
23+
commonware-stream = { version = "0.0.58" }
24+
commonware-utils = { version = "0.0.58" }
2525
thiserror = "2.0.12"
2626
bytes = "1.7.1"
2727
rand = "0.8.5"

chain/src/engine.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ use commonware_cryptography::{
1717
Signer,
1818
};
1919
use commonware_p2p::{Blocker, Receiver, Sender};
20-
use commonware_runtime::{Clock, Handle, Metrics, Spawner, Storage};
20+
use commonware_runtime::{buffer::PoolRef, Clock, Handle, Metrics, Spawner, Storage};
21+
use commonware_utils::{NZUsize, NZU64};
2122
use futures::future::try_join_all;
2223
use governor::clock::Clock as GClock;
2324
use governor::Quota;
2425
use rand::{CryptoRng, Rng};
25-
use std::time::Duration;
26+
use std::{num::NonZero, time::Duration};
2627
use tracing::{error, warn};
2728

2829
/// Reporter type for [threshold_simplex::Engine].
@@ -32,14 +33,16 @@ type Reporter<E, I> =
3233
/// To better support peers near tip during network instability, we multiply
3334
/// the consensus activity timeout by this factor.
3435
const SYNCER_ACTIVITY_TIMEOUT_MULTIPLIER: u64 = 10;
35-
const PRUNABLE_ITEMS_PER_SECTION: u64 = 4_096;
36-
const IMMUTABLE_ITEMS_PER_SECTION: u64 = 262_144;
36+
const PRUNABLE_ITEMS_PER_SECTION: NonZero<u64> = NZU64!(4_096);
37+
const IMMUTABLE_ITEMS_PER_SECTION: NonZero<u64> = NZU64!(262_144);
3738
const FREEZER_TABLE_RESIZE_FREQUENCY: u8 = 4;
3839
const FREEZER_TABLE_RESIZE_CHUNK_SIZE: u32 = 2u32.pow(16); // 3MB
3940
const FREEZER_JOURNAL_TARGET_SIZE: u64 = 1024 * 1024 * 1024; // 1GB
4041
const FREEZER_JOURNAL_COMPRESSION: Option<u8> = Some(3);
41-
const REPLAY_BUFFER: usize = 8 * 1024 * 1024; // 8MB
42-
const WRITE_BUFFER: usize = 1024 * 1024; // 1MB
42+
const REPLAY_BUFFER: NonZero<usize> = NZUsize!(8 * 1024 * 1024); // 8MB
43+
const WRITE_BUFFER: NonZero<usize> = NZUsize!(1024 * 1024); // 1MB
44+
const BUFFER_POOL_PAGE_SIZE: NonZero<usize> = NZUsize!(4_096); // 4KB
45+
const BUFFER_POOL_CAPACITY: NonZero<usize> = NZUsize!(8_192); // 32MB
4346
const MAX_REPAIR: u64 = 20;
4447

4548
/// Configuration for the [Engine].
@@ -130,6 +133,9 @@ impl<
130133
},
131134
);
132135

136+
// Create the buffer pool
137+
let buffer_pool = PoolRef::new(BUFFER_POOL_PAGE_SIZE, BUFFER_POOL_CAPACITY);
138+
133139
// Create marshal
134140
let (marshal, marshal_mailbox): (_, marshal::Mailbox<MinSig, Block>) =
135141
marshal::Actor::init(
@@ -152,6 +158,7 @@ impl<
152158
freezer_table_resize_chunk_size: FREEZER_TABLE_RESIZE_CHUNK_SIZE,
153159
freezer_journal_target_size: FREEZER_JOURNAL_TARGET_SIZE,
154160
freezer_journal_compression: FREEZER_JOURNAL_COMPRESSION,
161+
freezer_journal_buffer_pool: buffer_pool.clone(),
155162
replay_buffer: REPLAY_BUFFER,
156163
write_buffer: WRITE_BUFFER,
157164
codec_config: (),
@@ -198,6 +205,7 @@ impl<
198205
replay_buffer: REPLAY_BUFFER,
199206
write_buffer: WRITE_BUFFER,
200207
blocker: cfg.blocker,
208+
buffer_pool,
201209
},
202210
);
203211

0 commit comments

Comments
 (0)