Skip to content

Commit

Permalink
Initial code to add denunciations in block header
Browse files Browse the repository at this point in the history
  • Loading branch information
sydhds committed Apr 12, 2023
1 parent 1f16c3a commit 8888e99
Show file tree
Hide file tree
Showing 27 changed files with 300 additions and 141 deletions.
4 changes: 2 additions & 2 deletions massa-bootstrap/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ impl Deserializer<BootstrapServerMessage> for BootstrapServerMessageDeserializer
/// max_datastore_entry_count: 1000, max_bootstrap_error_length: 1000, max_changes_slot_count: 1000,
/// max_rolls_length: 1000, max_production_stats_length: 1000, max_credits_length: 1000,
/// max_executed_ops_length: 1000, max_ops_changes_length: 1000,
/// mip_store_stats_block_considered: 100, mip_store_stats_counters_max: 10
/// };
/// mip_store_stats_block_considered: 100, mip_store_stats_counters_max: 10,
/// max_denunciations_per_block_header: 128,};
/// let message_deserializer = BootstrapServerMessageDeserializer::new(args);
/// let bootstrap_server_message = BootstrapServerMessage::BootstrapTime {
/// server_time: MassaTime::from(0),
Expand Down
5 changes: 5 additions & 0 deletions massa-bootstrap/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ pub struct BootstrapConfig {
pub mip_store_stats_block_considered: usize,
/// max number of counters for versioning stats
pub mip_store_stats_counters_max: usize,
/// max denunciations in block header
pub max_denunciations_per_block_header: u32,
}

/// Bootstrap server binding
Expand Down Expand Up @@ -173,6 +175,7 @@ pub struct BootstrapClientConfig {
pub max_ops_changes_length: u64,
pub mip_store_stats_block_considered: usize,
pub mip_store_stats_counters_max: usize,
pub max_denunciations_per_block_header: u32,
}

/// Bootstrap Message der args
Expand Down Expand Up @@ -202,6 +205,7 @@ pub struct BootstrapServerMessageDeserializerArgs {
pub max_ops_changes_length: u64,
pub mip_store_stats_block_considered: usize,
pub mip_store_stats_counters_max: usize,
pub max_denunciations_per_block_header: u32,
}

// TODO: add a proc macro for this case
Expand All @@ -212,6 +216,7 @@ impl From<&BootstrapServerMessageDeserializerArgs> for BlockDeserializerArgs {
thread_count: value.thread_count,
max_operations_per_block: value.max_operations_per_block,
endorsement_count: value.endorsement_count,
max_denunciations_per_block_header: value.max_denunciations_per_block_header,
last_start_period: None,
}
}
Expand Down
8 changes: 5 additions & 3 deletions massa-bootstrap/src/tests/binders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ use massa_models::config::{
MAX_BOOTSTRAP_ASYNC_POOL_CHANGES, MAX_BOOTSTRAP_BLOCKS, MAX_BOOTSTRAP_ERROR_LENGTH,
MAX_BOOTSTRAP_FINAL_STATE_PARTS_SIZE, MAX_BOOTSTRAP_MESSAGE_SIZE, MAX_DATASTORE_ENTRY_COUNT,
MAX_DATASTORE_KEY_LENGTH, MAX_DATASTORE_VALUE_LENGTH, MAX_DEFERRED_CREDITS_LENGTH,
MAX_EXECUTED_OPS_CHANGES_LENGTH, MAX_EXECUTED_OPS_LENGTH, MAX_LEDGER_CHANGES_COUNT,
MAX_OPERATIONS_PER_BLOCK, MAX_PRODUCTION_STATS_LENGTH, MAX_ROLLS_COUNT_LENGTH,
MIP_STORE_STATS_BLOCK_CONSIDERED, MIP_STORE_STATS_COUNTERS_MAX, THREAD_COUNT,
MAX_DENUNCIATIONS_PER_BLOCK_HEADER, MAX_EXECUTED_OPS_CHANGES_LENGTH, MAX_EXECUTED_OPS_LENGTH,
MAX_LEDGER_CHANGES_COUNT, MAX_OPERATIONS_PER_BLOCK, MAX_PRODUCTION_STATS_LENGTH,
MAX_ROLLS_COUNT_LENGTH, MIP_STORE_STATS_BLOCK_CONSIDERED, MIP_STORE_STATS_COUNTERS_MAX,
THREAD_COUNT,
};
use massa_models::node::NodeId;
use massa_models::version::Version;
Expand Down Expand Up @@ -58,6 +59,7 @@ impl<D: Duplex> BootstrapClientBinder<D> {
max_ops_changes_length: MAX_EXECUTED_OPS_CHANGES_LENGTH,
mip_store_stats_block_considered: MIP_STORE_STATS_BLOCK_CONSIDERED,
mip_store_stats_counters_max: MIP_STORE_STATS_COUNTERS_MAX,
max_denunciations_per_block_header: MAX_DENUNCIATIONS_PER_BLOCK_HEADER,
};
BootstrapClientBinder::new(client_duplex, remote_pubkey, cfg)
}
Expand Down
15 changes: 9 additions & 6 deletions massa-bootstrap/src/tests/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ use massa_models::config::{
MAX_BOOTSTRAP_ASYNC_POOL_CHANGES, MAX_BOOTSTRAP_BLOCKS, MAX_BOOTSTRAP_ERROR_LENGTH,
MAX_BOOTSTRAP_FINAL_STATE_PARTS_SIZE, MAX_BOOTSTRAP_MESSAGE_SIZE, MAX_CONSENSUS_BLOCKS_IDS,
MAX_DATASTORE_ENTRY_COUNT, MAX_DATASTORE_KEY_LENGTH, MAX_DATASTORE_VALUE_LENGTH,
MAX_DEFERRED_CREDITS_LENGTH, MAX_EXECUTED_OPS_CHANGES_LENGTH, MAX_EXECUTED_OPS_LENGTH,
MAX_FUNCTION_NAME_LENGTH, MAX_LEDGER_CHANGES_COUNT, MAX_OPERATIONS_PER_BLOCK,
MAX_OPERATION_DATASTORE_ENTRY_COUNT, MAX_OPERATION_DATASTORE_KEY_LENGTH,
MAX_OPERATION_DATASTORE_VALUE_LENGTH, MAX_PARAMETERS_SIZE, MAX_PRODUCTION_STATS_LENGTH,
MAX_ROLLS_COUNT_LENGTH, MIP_STORE_STATS_BLOCK_CONSIDERED, MIP_STORE_STATS_COUNTERS_MAX,
PERIODS_PER_CYCLE, THREAD_COUNT,
MAX_DEFERRED_CREDITS_LENGTH, MAX_DENUNCIATIONS_PER_BLOCK_HEADER,
MAX_EXECUTED_OPS_CHANGES_LENGTH, MAX_EXECUTED_OPS_LENGTH, MAX_FUNCTION_NAME_LENGTH,
MAX_LEDGER_CHANGES_COUNT, MAX_OPERATIONS_PER_BLOCK, MAX_OPERATION_DATASTORE_ENTRY_COUNT,
MAX_OPERATION_DATASTORE_KEY_LENGTH, MAX_OPERATION_DATASTORE_VALUE_LENGTH, MAX_PARAMETERS_SIZE,
MAX_PRODUCTION_STATS_LENGTH, MAX_ROLLS_COUNT_LENGTH, MIP_STORE_STATS_BLOCK_CONSIDERED,
MIP_STORE_STATS_COUNTERS_MAX, PERIODS_PER_CYCLE, THREAD_COUNT,
};
use massa_models::node::NodeId;
use massa_models::{
Expand Down Expand Up @@ -340,6 +340,7 @@ pub fn get_bootstrap_config(bootstrap_public_key: NodeId) -> BootstrapConfig {
max_consensus_block_ids: MAX_CONSENSUS_BLOCKS_IDS,
mip_store_stats_block_considered: MIP_STORE_STATS_BLOCK_CONSIDERED,
mip_store_stats_counters_max: MIP_STORE_STATS_COUNTERS_MAX,
max_denunciations_per_block_header: MAX_DENUNCIATIONS_PER_BLOCK_HEADER,
}
}

Expand Down Expand Up @@ -415,6 +416,7 @@ pub fn get_boot_state() -> BootstrapableGraph {
)
.unwrap(),
],
denunciations: vec![],
},
BlockHeaderSerializer::new(),
&keypair,
Expand Down Expand Up @@ -443,6 +445,7 @@ pub fn get_boot_state() -> BootstrapableGraph {
thread_count: THREAD_COUNT,
max_operations_per_block: MAX_OPERATIONS_PER_BLOCK,
endorsement_count: ENDORSEMENT_COUNT,
max_denunciations_per_block_header: MAX_DENUNCIATIONS_PER_BLOCK_HEADER,
last_start_period: Some(0),
};
let bootstrapable_graph_deserializer =
Expand Down
2 changes: 1 addition & 1 deletion massa-consensus-exports/src/bootstrapable_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl Deserializer<BootstrapableGraph> for BootstrapableGraphDeserializer {
/// let mut buffer = Vec::new();
/// BootstrapableGraphSerializer::new().serialize(&bootstrapable_graph, &mut buffer).unwrap();
/// let args = BlockDeserializerArgs {
/// thread_count: 32,max_operations_per_block: 16,endorsement_count: 10,last_start_period: Some(0),};
/// thread_count: 32,max_operations_per_block: 16,endorsement_count: 10,max_denunciations_per_block_header: 128,last_start_period: Some(0),};
/// let (rest, bootstrapable_graph_deserialized) = BootstrapableGraphDeserializer::new(args, 10).deserialize::<DeserializeError>(&buffer).unwrap();
/// let mut buffer2 = Vec::new();
/// BootstrapableGraphSerializer::new().serialize(&bootstrapable_graph_deserialized, &mut buffer2).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions massa-consensus-exports/src/export_active_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl Deserializer<ExportActiveBlock> for ExportActiveBlockDeserializer {
/// )
/// .unwrap(),
/// ],
/// },
/// denunciations: vec![],},
/// BlockHeaderSerializer::new(),
/// &keypair,
/// )
Expand All @@ -221,7 +221,7 @@ impl Deserializer<ExportActiveBlock> for ExportActiveBlockDeserializer {
/// let mut serialized = Vec::new();
/// ExportActiveBlockSerializer::new().serialize(&export_active_block, &mut serialized).unwrap();
/// let args = BlockDeserializerArgs {
/// thread_count: 32, max_operations_per_block: 16, endorsement_count: 1000,last_start_period: Some(0),};
/// thread_count: 32, max_operations_per_block: 16, endorsement_count: 1000,max_denunciations_per_block_header: 128,last_start_period: Some(0),};
/// let (rest, export_deserialized) = ExportActiveBlockDeserializer::new(args).deserialize::<DeserializeError>(&serialized).unwrap();
/// assert_eq!(export_deserialized.block.id, export_active_block.block.id);
/// assert_eq!(export_deserialized.block.serialized_data, export_active_block.block.serialized_data);
Expand Down
1 change: 1 addition & 0 deletions massa-consensus-worker/src/worker/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub fn create_genesis_block(
parents: Vec::new(),
operation_merkle_root: Hash::compute_from(&Vec::new()),
endorsements: Vec::new(),
denunciations: Vec::new(),
},
BlockHeaderSerializer::new(),
keypair,
Expand Down
1 change: 1 addition & 0 deletions massa-execution-worker/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ pub fn create_block(
parents: vec![],
operation_merkle_root,
endorsements: vec![],
denunciations: vec![],
},
BlockHeaderSerializer::new(),
&creator_keypair,
Expand Down
1 change: 1 addition & 0 deletions massa-factory-exports/src/test_exports/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub fn create_empty_block(keypair: &KeyPair, slot: &Slot) -> SecureShareBlock {
parents: Vec::new(),
operation_merkle_root: Hash::compute_from(&Vec::new()),
endorsements: Vec::new(),
denunciations: vec![],
},
BlockHeaderSerializer::new(),
keypair,
Expand Down
1 change: 1 addition & 0 deletions massa-factory-worker/src/block_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ impl BlockFactoryWorker {
parents: parents.into_iter().map(|(id, _period)| id).collect(),
operation_merkle_root: global_operations_hash,
endorsements,
denunciations: Vec::new(), // TODO / FIXME: feed
},
BlockHeaderSerializer::new(), // TODO reuse self.block_header_serializer
block_producer_keypair,
Expand Down
2 changes: 2 additions & 0 deletions massa-grpc/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,6 @@ pub struct GrpcConfig {
pub draw_lookahead_period_count: u64,
/// last_start_period of the network, used to deserialize blocks
pub last_start_period: u64,
/// Max denunciations in block header
pub max_denunciations_per_block_header: u32,
}
1 change: 1 addition & 0 deletions massa-grpc/src/stream/send_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub(crate) async fn send_blocks(
thread_count: config.thread_count,
max_operations_per_block: config.max_operations_per_block,
endorsement_count: config.endorsement_count,
max_denunciations_per_block_header: config.max_denunciations_per_block_header,
last_start_period: Some(config.last_start_period),
};
// Deserialize and verify received block in the incoming message
Expand Down
11 changes: 6 additions & 5 deletions massa-grpc/src/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use massa_consensus_exports::test_exports::MockConsensusController;
use massa_consensus_exports::ConsensusChannels;
use massa_execution_exports::test_exports::MockExecutionController;
use massa_models::config::{
ENDORSEMENT_COUNT, GENESIS_TIMESTAMP, MAX_DATASTORE_VALUE_LENGTH, MAX_ENDORSEMENTS_PER_MESSAGE,
MAX_FUNCTION_NAME_LENGTH, MAX_OPERATIONS_PER_BLOCK, MAX_OPERATIONS_PER_MESSAGE,
MAX_OPERATION_DATASTORE_ENTRY_COUNT, MAX_OPERATION_DATASTORE_KEY_LENGTH,
MAX_OPERATION_DATASTORE_VALUE_LENGTH, MAX_PARAMETERS_SIZE, PROTOCOL_CONTROLLER_CHANNEL_SIZE,
T0, THREAD_COUNT, VERSION,
ENDORSEMENT_COUNT, GENESIS_TIMESTAMP, MAX_DATASTORE_VALUE_LENGTH,
MAX_DENUNCIATIONS_PER_BLOCK_HEADER, MAX_ENDORSEMENTS_PER_MESSAGE, MAX_FUNCTION_NAME_LENGTH,
MAX_OPERATIONS_PER_BLOCK, MAX_OPERATIONS_PER_MESSAGE, MAX_OPERATION_DATASTORE_ENTRY_COUNT,
MAX_OPERATION_DATASTORE_KEY_LENGTH, MAX_OPERATION_DATASTORE_VALUE_LENGTH, MAX_PARAMETERS_SIZE,
PROTOCOL_CONTROLLER_CHANNEL_SIZE, T0, THREAD_COUNT, VERSION,
};
use massa_pool_exports::test_exports::MockPoolController;
use massa_pool_exports::PoolChannels;
Expand Down Expand Up @@ -85,6 +85,7 @@ async fn test_start_grpc_server() {
max_channel_size: 128,
draw_lookahead_period_count: 10,
last_start_period: 0,
max_denunciations_per_block_header: MAX_DENUNCIATIONS_PER_BLOCK_HEADER,
};

let service = MassaGrpc {
Expand Down
Loading

0 comments on commit 8888e99

Please sign in to comment.