Skip to content

Commit

Permalink
Change constants to config and don't return in case of error in calcu…
Browse files Browse the repository at this point in the history
…lating slot.
  • Loading branch information
AurelienFT committed Sep 20, 2022
1 parent 69023a8 commit 374d799
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 26 deletions.
4 changes: 0 additions & 4 deletions massa-models/src/config/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@ pub const MAX_BOOTSTRAP_ERROR_LENGTH: u32 = 10000;
pub const PROTOCOL_CONTROLLER_CHANNEL_SIZE: usize = 1024;
/// Event channel size
pub const PROTOCOL_EVENT_CHANNEL_SIZE: usize = 1024;
/// Time threshold after which operation are not propagated
pub const MAX_OPERATIONS_PROPAGATION_TIME: MassaTime = T0.saturating_mul(2);
/// Time threshold after which operation are not propagated
pub const MAX_ENDORSEMENTS_PROPAGATION_TIME: MassaTime = T0.saturating_mul(3);
// ***********************
// Constants used for execution module (injected from ConsensusConfig)
//
Expand Down
4 changes: 4 additions & 0 deletions massa-node/base_config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@
asked_operations_pruning_period = 100000
# Max number of operation per message, same as network param but can be smaller
max_operations_per_message = 1024
# Time threshold after which operation are not propagated
max_operations_propagation_time = 32000
# Time threshold after which operation are not propagated
max_endorsements_propagation_time = 48000

[network]
# port on which to listen for protocol communication
Expand Down
7 changes: 3 additions & 4 deletions massa-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ use massa_models::config::constants::{
PERIODS_PER_CYCLE, ROLL_PRICE, T0, THREAD_COUNT, VERSION,
};
use massa_models::config::{
ASYNC_POOL_PART_SIZE_MESSAGE_BYTES, CHANNEL_SIZE, DELTA_F0, MAX_ENDORSEMENTS_PROPAGATION_TIME,
MAX_OPERATIONS_PROPAGATION_TIME, NETWORK_NODE_COMMAND_CHANNEL_SIZE,
ASYNC_POOL_PART_SIZE_MESSAGE_BYTES, CHANNEL_SIZE, DELTA_F0, NETWORK_NODE_COMMAND_CHANNEL_SIZE,
NETWORK_NODE_EVENT_CHANNEL_SIZE, POS_MISS_RATE_DEACTIVATION_THRESHOLD,
PROTOCOL_CONTROLLER_CHANNEL_SIZE, PROTOCOL_EVENT_CHANNEL_SIZE,
};
Expand Down Expand Up @@ -326,8 +325,8 @@ async fn launch(
event_channel_size: PROTOCOL_EVENT_CHANNEL_SIZE,
genesis_timestamp: *GENESIS_TIMESTAMP,
t0: T0,
max_operations_propagation_time: MAX_OPERATIONS_PROPAGATION_TIME,
max_endorsements_propagation_time: MAX_ENDORSEMENTS_PROPAGATION_TIME,
max_operations_propagation_time: SETTINGS.protocol.max_operations_propagation_time,
max_endorsements_propagation_time: SETTINGS.protocol.max_endorsements_propagation_time,
};
let (protocol_command_sender, protocol_event_receiver, protocol_manager) =
start_protocol_controller(
Expand Down
4 changes: 4 additions & 0 deletions massa-node/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ pub struct ProtocolSettings {
pub asked_operations_pruning_period: MassaTime,
/// Maximum of operations sent in one message.
pub max_operations_per_message: u64,
/// Time threshold after which operation are not propagated
pub max_operations_propagation_time: MassaTime,
/// Time threshold after which operation are not propagated
pub max_endorsements_propagation_time: MassaTime,
}

#[cfg(test)]
Expand Down
44 changes: 26 additions & 18 deletions massa-protocol-worker/src/protocol_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -964,15 +964,19 @@ impl ProtocolWorker {
self.config.t0,
self.config.genesis_timestamp,
Slot::new(expire_period, 0),
)
.ok()?;
if expire_period_timestamp
.saturating_add(self.config.max_operations_propagation_time)
< now
{
Some(*op_id)
} else {
None
);
match expire_period_timestamp {
Ok(slot_timestamp) => {
if slot_timestamp
.saturating_add(self.config.max_endorsements_propagation_time)
< now
{
Some(*op_id)
} else {
None
}
}
Err(_) => Some(*op_id),
}
})
.collect()
Expand Down Expand Up @@ -1056,15 +1060,19 @@ impl ProtocolWorker {
self.config.t0,
self.config.genesis_timestamp,
slot_endorsed_block,
)
.ok()?;
if slot_timestamp
.saturating_add(self.config.max_endorsements_propagation_time)
< now
{
Some(*endorsement_id)
} else {
None
);
match slot_timestamp {
Ok(slot_timestamp) => {
if slot_timestamp.saturating_add(
self.config.max_endorsements_propagation_time,
) < now
{
Some(*endorsement_id)
} else {
None
}
}
Err(_) => Some(*endorsement_id),
}
})
.collect()
Expand Down

0 comments on commit 374d799

Please sign in to comment.