Skip to content

Commit e7a8757

Browse files
authored
feat(ethexe-consensus): Limits for BatchCommitment abi encoding (#5214)
1 parent e47979d commit e7a8757

File tree

22 files changed

+1907
-1172
lines changed

22 files changed

+1907
-1172
lines changed

.ethexe.example.local.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ validator-session = "0x02ba5734d8f7091719471e7f7ed6b9df170dc70cc661ca05e688601ad
7979
# (optional, max block gas limit: 9_000_000_000_000, default: 4_000_000_000_000).
8080
# block-gas-limit = 4_000_000_000_000
8181

82+
# Batch size limit for the node.
83+
# (optional, max batch size limit 122_880, default 102_400)
84+
# batch-size-limit = 102_400
85+
8286
# Number of blocks that must pass before applying canonical (Ethereum) events.
8387
# NOTE: Customize this parameter only for development purposes. In production, your node
8488
# may fail to reach consensus with other nodes if this value is changed.

.ethexe.example.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@
7979
# (optional, max block gas limit: 9_000_000_000_000, default: 4_000_000_000_000).
8080
# block-gas-limit = 4_000_000_000_000
8181

82+
# Batch size limit for the node.
83+
# (optional, max batch size limit 122_880, default 102_400)
84+
# batch-size-limit = 102_400
85+
8286
# Number of blocks that must pass before applying canonical (Ethereum) events.
8387
# NOTE: Customize this parameter only for development purposes. In production, your node
8488
# may fail to reach consensus with other nodes if this value is changed.

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.

ethexe/cli/src/params/node.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use clap::Parser;
2222
use directories::ProjectDirs;
2323
use ethexe_common::{
2424
DEFAULT_BLOCK_GAS_LIMIT,
25-
consensus::DEFAULT_CHAIN_DEEPNESS_THRESHOLD,
25+
consensus::{DEFAULT_BATCH_SIZE_LIMIT, DEFAULT_CHAIN_DEEPNESS_THRESHOLD, MAX_BATCH_SIZE_LIMIT},
2626
gear::{CANONICAL_QUARANTINE, MAX_BLOCK_GAS_LIMIT},
2727
};
2828
use ethexe_processor::DEFAULT_CHUNK_SIZE;
@@ -91,6 +91,12 @@ pub struct NodeParams {
9191
#[serde(rename = "block-gas-limit")]
9292
pub block_gas_limit: Option<u64>,
9393

94+
/// Batch size limit for the node.
95+
#[arg(long)]
96+
#[serde(rename = "batch-size-limit")]
97+
pub batch_size_limit: Option<u64>,
98+
99+
/// Quarantine for canonical (Ethereum) messages.
94100
#[arg(long)]
95101
#[serde(rename = "canonical-quarantine")]
96102
pub canonical_quarantine: Option<u8>,
@@ -137,6 +143,10 @@ impl NodeParams {
137143
.block_gas_limit
138144
.unwrap_or(DEFAULT_BLOCK_GAS_LIMIT)
139145
.min(MAX_BLOCK_GAS_LIMIT),
146+
batch_size_limit: self
147+
.batch_size_limit
148+
.unwrap_or(DEFAULT_BATCH_SIZE_LIMIT)
149+
.min(MAX_BATCH_SIZE_LIMIT),
140150
canonical_quarantine: self.canonical_quarantine.unwrap_or(CANONICAL_QUARANTINE),
141151
dev: self.dev,
142152
pre_funded_accounts: self
@@ -216,6 +226,7 @@ impl MergeParams for NodeParams {
216226
.or(with.chunk_processing_threads),
217227

218228
block_gas_limit: self.block_gas_limit.or(with.block_gas_limit),
229+
batch_size_limit: self.batch_size_limit.or(with.batch_size_limit),
219230
canonical_quarantine: self.canonical_quarantine.or(with.canonical_quarantine),
220231

221232
fast_sync: self.fast_sync || with.fast_sync,

ethexe/common/src/consensus.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ use k256::sha2::Digest as _;
2727
use parity_scale_codec::{Decode, Encode};
2828
use sha3::Keccak256;
2929

30+
/// The maximum batch size limit - 120 KB.
31+
pub const MAX_BATCH_SIZE_LIMIT: u64 = 120 * 1024;
32+
33+
/// The default batch size - 100 KB.
34+
pub const DEFAULT_BATCH_SIZE_LIMIT: u64 = 100 * 1024;
35+
36+
/// Default threshold for producer to submit commitment despite of no transitions
37+
pub const DEFAULT_CHAIN_DEEPNESS_THRESHOLD: u32 = 500;
38+
3039
pub type VerifiedAnnounce = VerifiedData<Announce>;
3140
pub type VerifiedValidationRequest = VerifiedData<BatchCommitmentValidationRequest>;
3241
pub type VerifiedValidationReply = VerifiedData<BatchCommitmentValidationReply>;
@@ -104,6 +113,3 @@ impl ToDigest for BatchCommitmentValidationReply {
104113
hasher.update(signature.into_pre_eip155_bytes())
105114
}
106115
}
107-
108-
/// Default threshold for producer to submit commitment despite of no transitions
109-
pub const DEFAULT_CHAIN_DEEPNESS_THRESHOLD: u32 = 500;

ethexe/consensus/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ lru.workspace = true
3232
metrics.workspace = true
3333
metrics-derive.workspace = true
3434
gear-workspace-hack.workspace = true
35+
alloy.workspace = true
3536

3637
[dev-dependencies]
3738
ethexe-common = { workspace = true, features = ["mock"] }

0 commit comments

Comments
 (0)