Skip to content

Commit

Permalink
Move MAX_TRANSACTIONS_PER_CHECKPOINT to protocol-constants crate (Mys…
Browse files Browse the repository at this point in the history
  • Loading branch information
lxfind authored Jan 31, 2023
1 parent 65243a5 commit 04956ee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/sui-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ sui-core = { path = "../sui-core" }
sui-storage = { path = "../sui-storage" }
sui-network = { path = "../sui-network" }
sui-json-rpc = { path = "../sui-json-rpc" }
sui-protocol-constants = { path = "../sui-protocol-constants" }
sui-telemetry = { path = "../sui-telemetry" }
sui-types = { path = "../sui-types" }
mysten-metrics = { path = "../mysten-metrics" }
Expand Down
13 changes: 9 additions & 4 deletions crates/sui-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ use sui_json_rpc::{JsonRpcServerBuilder, ServerHandle};
use sui_network::api::ValidatorServer;
use sui_network::discovery;
use sui_network::{state_sync, DEFAULT_CONNECT_TIMEOUT_SEC, DEFAULT_HTTP2_KEEPALIVE_SEC};

#[cfg(not(test))]
use sui_protocol_constants::MAX_TRANSACTIONS_PER_CHECKPOINT;
#[cfg(test)]
use sui_protocol_constants::MAX_TRANSACTIONS_PER_CHECKPOINT_FOR_TESTING;

use sui_storage::{
event_store::{EventStoreType, SqlEventStore},
IndexStore,
Expand Down Expand Up @@ -575,11 +581,10 @@ impl SuiNode {
});

let certified_checkpoint_output = SendCheckpointToStateSync::new(state_sync_handle);
// Note that this is constant and not a config as validators must have this set to the same value, otherwise they *will* fork
#[cfg(test)]
const MAX_TRANSACTIONS_PER_CHECKPOINT: usize = 2;
let max_tx_per_checkpoint = MAX_TRANSACTIONS_PER_CHECKPOINT_FOR_TESTING;
#[cfg(not(test))]
const MAX_TRANSACTIONS_PER_CHECKPOINT: usize = 1000;
let max_tx_per_checkpoint = MAX_TRANSACTIONS_PER_CHECKPOINT;

CheckpointService::spawn(
state.clone(),
Expand All @@ -590,7 +595,7 @@ impl SuiNode {
Box::new(certified_checkpoint_output),
Box::new(NetworkTransactionCertifier::default()),
checkpoint_metrics,
MAX_TRANSACTIONS_PER_CHECKPOINT,
max_tx_per_checkpoint,
)
}

Expand Down
7 changes: 7 additions & 0 deletions crates/sui-protocol-constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,10 @@ pub const STAKE_SUBSIDY_RATE: u64 = 1;

/// Unit gas price, Mist per internal gas unit.
pub const STORAGE_GAS_PRICE: u64 = 1;

/// === Core Protocol ===
/// Max number of transactions per checkpoint.
/// Note that this is constant and not a config as validators must have this set to the same value, otherwise they *will* fork
pub const MAX_TRANSACTIONS_PER_CHECKPOINT: usize = 1000;
pub const MAX_TRANSACTIONS_PER_CHECKPOINT_FOR_TESTING: usize = 2;

0 comments on commit 04956ee

Please sign in to comment.