Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial code for DenunciationFactory & DenunciationPool #3734

Merged
merged 13 commits into from
Apr 3, 2023
2 changes: 2 additions & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions massa-consensus-exports/src/channels.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use massa_execution_exports::ExecutionController;
use massa_models::block::{Block, FilledBlock};
use massa_models::block_header::BlockHeader;
use massa_models::denunciation::DenunciationPrecursor;
use massa_pool_exports::PoolController;
use massa_pos_exports::SelectorController;
use massa_protocol_exports::ProtocolCommandSender;
Expand All @@ -26,4 +27,6 @@ pub struct ConsensusChannels {
pub block_header_sender: tokio::sync::broadcast::Sender<BlockHeader>,
/// Channel use by Websocket (if they are enable) to broadcast a new block integrated
pub filled_block_sender: tokio::sync::broadcast::Sender<FilledBlock>,
/// Channel use for Denunciation factory to create denunciations
pub denunciation_factory_sender: crossbeam_channel::Sender<DenunciationPrecursor>,
}
10 changes: 10 additions & 0 deletions massa-consensus-worker/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use massa_consensus_exports::{
bootstrapable_graph::BootstrapableGraph, error::ConsensusError,
export_active_block::ExportActiveBlock, ConsensusChannels, ConsensusController,
};
use massa_models::denunciation::DenunciationPrecursor;
use massa_models::{
block::{BlockGraphStatus, FilledBlock},
block_header::BlockHeader,
Expand Down Expand Up @@ -281,6 +282,15 @@ impl ConsensusController for ConsensusControllerImpl {
.block_header_sender
.send(header.clone().content);
}

if let Err(e) = self
.channels
.denunciation_factory_sender
.send(DenunciationPrecursor::try_from(&header).unwrap())
{
warn!("Cannot send header to denunciation factory: {}", e);
damip marked this conversation as resolved.
Show resolved Hide resolved
}

if let Err(err) = self
.command_sender
.try_send(ConsensusCommand::RegisterBlockHeader(block_id, header))
Expand Down
2 changes: 1 addition & 1 deletion massa-execution-worker/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use massa_storage::Storage;
use parking_lot::{Mutex, RwLock};
use std::collections::{BTreeMap, BTreeSet, HashMap};
use std::sync::Arc;
use tracing::{debug, error, info, warn};
use tracing::{debug, info, warn};

/// Used to acquire a lock on the execution context
macro_rules! context_guard {
Expand Down
9 changes: 9 additions & 0 deletions massa-factory-exports/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,13 @@ pub struct FactoryConfig {

/// maximum number of operation ids in block
pub max_operations_per_block: u32,

/// cycle duration in periods
pub periods_per_cycle: u64,

/// denunciation expiration as periods
pub denunciation_expire_periods: u64,

/// Cycle delta to accept items in denunciation factory
pub denunciation_items_max_cycle_delta: u64,
}
3 changes: 3 additions & 0 deletions massa-factory-exports/src/test_exports/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ impl Default for FactoryConfig {
max_block_size: MAX_BLOCK_SIZE as u64,
max_block_gas: MAX_GAS_PER_BLOCK,
max_operations_per_block: MAX_OPERATIONS_PER_BLOCK,
periods_per_cycle: PERIODS_PER_CYCLE,
denunciation_expire_periods: DENUNCIATION_EXPIRE_PERIODS,
denunciation_items_max_cycle_delta: DENUNCIATION_ITEMS_MAX_CYCLE_DELTA,
}
}
}
1 change: 1 addition & 0 deletions massa-factory-worker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ anyhow = "1.0"
parking_lot = { version = "0.12", features = ["deadlock_detection"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
crossbeam-channel = "0.5"
tracing = "0.1"
# custom modules
massa_models = { path = "../massa-models" }
Expand Down
Loading