Skip to content

Commit dadcc4f

Browse files
authored
Merge pull request #104 from weaveVM/dev
merge: dev to main
2 parents f077b8a + c0517e2 commit dadcc4f

File tree

5 files changed

+37
-11
lines changed

5 files changed

+37
-11
lines changed

Cargo.lock

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/node/core/src/args/txpool.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub struct TxPoolArgs {
6161
pub blob_transaction_price_bump: u128,
6262

6363
/// Max size in bytes of a single transaction allowed to enter the pool
64-
#[arg(long = "txpool.max-tx-input-bytes", alias = "txpool.max_tx_input_bytes", default_value_t = DEFAULT_MAX_TX_INPUT_BYTES)]
64+
#[arg(long = "txpool.max-tx-input-bytes", alias = "txpool.max_tx_input_bytes", default_value_t = internal_default_max_tx_bytes())]
6565
pub max_tx_input_bytes: usize,
6666

6767
/// The maximum number of blobs to keep in the in memory blob cache.
@@ -90,6 +90,10 @@ pub struct TxPoolArgs {
9090
pub new_tx_listener_buffer_size: usize,
9191
}
9292

93+
fn internal_default_max_tx_bytes() -> usize {
94+
*DEFAULT_MAX_TX_INPUT_BYTES
95+
}
96+
9397
impl Default for TxPoolArgs {
9498
fn default() -> Self {
9599
Self {
@@ -104,7 +108,7 @@ impl Default for TxPoolArgs {
104108
minimal_protocol_basefee: MIN_PROTOCOL_BASE_FEE.load(SeqCst),
105109
gas_limit: *ETHEREUM_BLOCK_GAS_LIMIT,
106110
blob_transaction_price_bump: REPLACE_BLOB_PRICE_BUMP,
107-
max_tx_input_bytes: DEFAULT_MAX_TX_INPUT_BYTES,
111+
max_tx_input_bytes: *DEFAULT_MAX_TX_INPUT_BYTES,
108112
max_cached_entries: DEFAULT_MAX_CACHED_BLOBS,
109113
no_locals: false,
110114
locals: Default::default(),

crates/transaction-pool/src/validate/constants.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
use std::cell::LazyCell;
2+
use std::env::VarError;
3+
use reth_primitives::constants::ETHEREUM_BLOCK_GAS_LIMIT;
4+
15
/// [`TX_SLOT_BYTE_SIZE`] is used to calculate how many data slots a single transaction
26
/// takes up based on its byte size. The slots are used as `DoS` protection, ensuring
37
/// that validating a new transaction remains a constant operation (in reality
@@ -9,7 +13,25 @@ pub const TX_SLOT_BYTE_SIZE: usize = 32 * 1024;
913
/// more expensive to propagate; larger transactions also take more resources
1014
/// to validate whether they fit into the pool or not. Default is 4 times [`TX_SLOT_BYTE_SIZE`],
1115
/// which defaults to 32 KiB, so 128 KiB.
12-
pub const DEFAULT_MAX_TX_INPUT_BYTES: usize = 4 * TX_SLOT_BYTE_SIZE; // 128KB
16+
pub const DEFAULT_MAX_TX_INPUT_BYTES: LazyCell<usize> = LazyCell::new(|| {
17+
let default_value = {
18+
// 20k (gas) ----> 128kb
19+
// 500k (gas) ----> x // 3200
20+
let gas_limit = (&*ETHEREUM_BLOCK_GAS_LIMIT).clone();
21+
22+
(((gas_limit * 128_000) / 20_000) / 1000) as usize // -> to bytes (3.2mb)
23+
};
24+
25+
let env_var = std::env::var("WVM_DEFAULT_MAX_TX_INPUT_BYTES");
26+
match env_var {
27+
Ok(res) => {
28+
res.parse::<usize>().unwrap_or(default_value)
29+
}
30+
Err(_) => {
31+
default_value
32+
}
33+
}
34+
}); // 128KB
1335

1436
/// This represents how big we want to allow a contract size to be in multiples of 24kb
1537
/// 2 = 48kb

crates/transaction-pool/src/validate/eth.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ impl EthTransactionValidatorBuilder {
521521
additional_tasks: 1,
522522
kzg_settings: EnvKzgSettings::Default,
523523
local_transactions_config: Default::default(),
524-
max_tx_input_bytes: DEFAULT_MAX_TX_INPUT_BYTES,
524+
max_tx_input_bytes: *DEFAULT_MAX_TX_INPUT_BYTES,
525525

526526
// by default all transaction types are allowed
527527
eip2718: true,

wvm-apps/wvm-exexed/crates/reth-exexed/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ async fn exex_etl_processor<Node: FullNodeComponents>(
131131

132132
/// Main loop of the exexed WVM node
133133
fn main() -> eyre::Result<()> {
134-
let _init_fee_manager = &*reth_primitives::constants::WVM_FEE_MANAGER;
135134
reth::cli::Cli::parse_args().run(|builder, _| async move {
135+
let _init_fee_manager = &*reth_primitives::constants::WVM_FEE_MANAGER;
136136
// Original config
137137
let mut config = builder.config().clone();
138138
let pruning_args = config.pruning.clone();

0 commit comments

Comments
 (0)