Skip to content

Commit

Permalink
Move value_payload in test config (#847)
Browse files Browse the repository at this point in the history
  • Loading branch information
ancazamfir authored Feb 12, 2025
1 parent 56c64fc commit 59b3d4f
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion code/crates/app/src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ where
{
use crate::types::config;

let value_payload = match cfg.consensus.value_payload {
let value_payload = match cfg.test.value_payload {
config::ValuePayload::PartsOnly => ValuePayload::PartsOnly,
config::ValuePayload::ProposalOnly => ValuePayload::ProposalOnly,
config::ValuePayload::ProposalAndParts => ValuePayload::ProposalAndParts,
Expand Down
6 changes: 3 additions & 3 deletions code/crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,6 @@ pub struct ConsensusConfig {
#[serde(flatten)]
pub timeouts: TimeoutConfig,

/// Message types that can carry values
pub value_payload: ValuePayload,

/// P2P configuration options
pub p2p: P2pConfig,
}
Expand Down Expand Up @@ -545,6 +542,8 @@ pub struct VoteExtensionsConfig {
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct TestConfig {
pub max_block_size: ByteSize,
/// Message types that can carry values
pub value_payload: ValuePayload,
pub tx_size: ByteSize,
pub txs_per_part: usize,
pub time_allowance_factor: f32,
Expand All @@ -559,6 +558,7 @@ impl Default for TestConfig {
fn default() -> Self {
Self {
max_block_size: ByteSize::mib(1),
value_payload: ValuePayload::default(),
tx_size: ByteSize::kib(1),
txs_per_part: 256,
time_allowance_factor: 0.5,
Expand Down
4 changes: 2 additions & 2 deletions code/crates/starknet/host/src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ async fn spawn_consensus_actor(
tx_event: TxEvent<MockContext>,
span: &tracing::Span,
) -> ConsensusRef<MockContext> {
let value_payload = match cfg.consensus.value_payload {
let value_payload = match cfg.test.value_payload {
malachitebft_config::ValuePayload::PartsOnly => ValuePayload::PartsOnly,
malachitebft_config::ValuePayload::ProposalOnly => ValuePayload::ProposalOnly,
malachitebft_config::ValuePayload::ProposalAndParts => ValuePayload::ProposalAndParts,
Expand Down Expand Up @@ -321,7 +321,7 @@ async fn spawn_host_actor(
metrics: Metrics,
span: &tracing::Span,
) -> HostRef<MockContext> {
let value_payload = match cfg.consensus.value_payload {
let value_payload = match cfg.test.value_payload {
malachitebft_config::ValuePayload::PartsOnly => ValuePayload::PartsOnly,
malachitebft_config::ValuePayload::ProposalOnly => ValuePayload::ProposalOnly,
malachitebft_config::ValuePayload::ProposalAndParts => ValuePayload::ProposalAndParts,
Expand Down
3 changes: 1 addition & 2 deletions code/crates/starknet/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ impl TestParams {
fn apply_to_config(&self, config: &mut Config) {
config.sync.enabled = self.enable_sync;
config.consensus.p2p.protocol = self.protocol;
config.consensus.value_payload = self.value_payload;
config.test.max_block_size = self.block_size;
config.test.value_payload = self.value_payload;
config.test.tx_size = self.tx_size;
config.test.txs_per_part = self.txs_per_part;
config.test.vote_extensions.enabled = self.vote_extensions.is_some();
Expand Down Expand Up @@ -718,7 +718,6 @@ pub fn make_node_config<S>(test: &Test<S>, i: usize) -> NodeConfig {
moniker: format!("node-{}", test.nodes[i].id),
logging: LoggingConfig::default(),
consensus: ConsensusConfig {
value_payload: ValuePayload::default(),
timeouts: TimeoutConfig::default(),
p2p: P2pConfig {
transport,
Expand Down
4 changes: 2 additions & 2 deletions code/crates/test/app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub async fn run(
error!("Failed to send GetValue reply");
}

if !state.config.consensus.value_payload.include_parts() {
if !state.config.test.value_payload.include_parts() {
return Ok(());
}

Expand Down Expand Up @@ -249,7 +249,7 @@ pub async fn run(
address,
value_id,
} => {
if !state.config.consensus.value_payload.include_parts() {
if !state.config.test.value_payload.include_parts() {
return Ok(());
}

Expand Down
1 change: 0 additions & 1 deletion code/crates/test/cli/src/cmd/distributed_testnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ fn generate_distributed_config(
Config {
moniker: format!("test-{}", index),
consensus: ConsensusConfig {
value_payload: ValuePayload::default(),
timeouts: TimeoutConfig::default(),
p2p: P2pConfig {
protocol: PubSubProtocol::default(),
Expand Down
1 change: 0 additions & 1 deletion code/crates/test/cli/src/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ pub fn generate_config(
Config {
moniker: format!("test-{}", index),
consensus: ConsensusConfig {
value_payload: ValuePayload::default(),
timeouts: TimeoutConfig::default(),
p2p: P2pConfig {
protocol: PubSubProtocol::default(),
Expand Down
3 changes: 1 addition & 2 deletions code/crates/test/framework/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ impl TestParams {
fn apply_to_config(&self, config: &mut Config) {
config.sync.enabled = self.enable_sync;
config.consensus.p2p.protocol = self.protocol;
config.consensus.value_payload = self.value_payload;
config.test.max_block_size = self.block_size;
config.test.value_payload = self.value_payload;
config.test.tx_size = self.tx_size;
config.test.txs_per_part = self.txs_per_part;
config.test.vote_extensions.enabled = self.vote_extensions.is_some();
Expand Down Expand Up @@ -717,7 +717,6 @@ pub fn make_node_config<S>(test: &Test<S>, i: usize) -> NodeConfig {
moniker: format!("node-{}", test.nodes[i].id),
logging: LoggingConfig::default(),
consensus: ConsensusConfig {
value_payload: ValuePayload::default(),
timeouts: TimeoutConfig::default(),
p2p: P2pConfig {
transport,
Expand Down
14 changes: 7 additions & 7 deletions code/examples/channel/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ log_format = "plaintext"
### Consensus Configuration Options ###
#######################################################
[consensus]
# The message(s) required by consensus to carry the value payload.
# Available options are:
# - "parts-only": Full value is included in the proposal parts and there is no explicit Proposal message (default)
# - "proposal-only": Full value is included in the (explicit) consensus Proposal message (untested)
# - "proposal-and-parts": Both proposal parts and Proposal message are required (similar to CometBFT implementation of Tendermint)
# Override with MALACHITE__CONSENSUS__VALUE_PAYLOAD env variable
value_payload = "parts-only"

## Timeouts

Expand Down Expand Up @@ -230,6 +223,13 @@ flavor = "single_threaded"
# Maximum block size
# Override with MALACHITE__TEST__MAX_BLOCK_SIZE env variable
max_block_size = "1 MiB"
# The message(s) required to carry the value payload.
# Available options are:
# - "parts-only": Full value is included in the proposal parts and there is no explicit Proposal message (default)
# - "proposal-only": Full value is included in the (explicit) consensus Proposal message (untested)
# - "proposal-and-parts": Both proposal parts and Proposal message are required (similar to CometBFT implementation of Tendermint)
# Override with MALACHITE__TEST__VALUE_PAYLOAD env variable
value_payload = "parts-only"
# Override with MALACHITE__TEST__TX_SIZE env variable
tx_size = "1 KiB"
# Override with MALACHITE__TEST__TXS_PER_PART env variable
Expand Down
2 changes: 1 addition & 1 deletion code/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ instances will also be terminated.
* The script overrides some of the configuration parameters for local testnet use:
```bash
export MALACHITE__CONSENSUS__P2P__PROTOCOL__TYPE="gossipsub"
export MALACHITE__CONSENSUS__VALUE_PAYLOAD="proposal-and-parts"
export MALACHITE__CONSENSUS__TIMEOUT_PROPOSE="2s"
export MALACHITE__CONSENSUS__TIMEOUT_PROPOSE_DELTA="1s"
export MALACHITE__CONSENSUS__TIMEOUT_PREVOTE="1s"
Expand All @@ -37,6 +36,7 @@ export MALACHITE__CONSENSUS__TIMEOUT_STEP="6s"
export MALACHITE__MEMPOOL__MAX_TX_COUNT="10000"
export MALACHITE__MEMPOOL__GOSSIP_BATCH_SIZE=0
export MALACHITE__TEST__MAX_BLOCK_SIZE="50KiB"
export MALACHITE__TEST__VALUE_PAYLOAD="proposal-and-parts"
export MALACHITE__TEST__TX_SIZE="1KiB"
export MALACHITE__TEST__TXS_PER_PART=256
export MALACHITE__TEST__TIME_ALLOWANCE_FACTOR=0.3
Expand Down
2 changes: 1 addition & 1 deletion code/scripts/spawn.bash
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ fi

# Environment variables
export MALACHITE__CONSENSUS__P2P__PROTOCOL__TYPE="gossipsub"
export MALACHITE__CONSENSUS__VALUE_PAYLOAD="parts-only"
export MALACHITE__CONSENSUS__TIMEOUT_PROPOSE="2s"
export MALACHITE__CONSENSUS__TIMEOUT_PROPOSE_DELTA="1s"
export MALACHITE__CONSENSUS__TIMEOUT_PREVOTE="1s"
Expand All @@ -48,6 +47,7 @@ export MALACHITE__CONSENSUS__TIMEOUT_STEP="6s"
export MALACHITE__MEMPOOL__MAX_TX_COUNT="10000"
export MALACHITE__MEMPOOL__GOSSIP_BATCH_SIZE=0
export MALACHITE__TEST__MAX_BLOCK_SIZE="50KiB"
export MALACHITE__TEST__VALUE_PAYLOAD="parts-only"
export MALACHITE__TEST__TX_SIZE="1KiB"
export MALACHITE__TEST__TXS_PER_PART=256
export MALACHITE__TEST__TIME_ALLOWANCE_FACTOR=0.3
Expand Down

0 comments on commit 59b3d4f

Please sign in to comment.