Skip to content

Commit

Permalink
feat: add complete block sign verification
Browse files Browse the repository at this point in the history
  • Loading branch information
aoudiamoncef committed Mar 2, 2023
1 parent dfb7c40 commit 2a100b3
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions massa-grpc/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use massa_consensus_exports::{ConsensusChannels, ConsensusController};
use massa_models::{
block::{BlockDeserializer, BlockDeserializerArgs, SecureShareBlock},
config::{ENDORSEMENT_COUNT, MAX_OPERATIONS_PER_BLOCK, THREAD_COUNT},
error::ModelsError,
secure_share::SecureShareDeserializer,
};
use massa_pool_exports::PoolChannels;
Expand Down Expand Up @@ -193,9 +194,23 @@ impl grpc::grpc_server::Grpc for MassaService {
Ok(tuple) => {
let (rest, res_block): (&[u8], SecureShareBlock) = tuple;
if rest.is_empty() {
if let Ok(_verify_signature) =
//TODO add endorsements signatures check
res_block.verify_signature()
if let Ok(_verify_signature) = res_block
.verify_signature()
.and_then(|_| {
res_block.content.header.verify_signature()
})
.map(|_| {
res_block
.content
.header
.content
.endorsements
.iter()
.map(|endorsement| {
endorsement.verify_signature()
})
.collect::<Vec<Result<(), ModelsError>>>()
})
{
let block_id = res_block.id;
let slot = res_block.content.header.content.slot;
Expand Down Expand Up @@ -255,12 +270,11 @@ impl grpc::grpc_server::Grpc for MassaService {
.await;
};
} else {
let error = "incomplete deserialization";
let _res = sendblocks_notify_error(
req_content.id.clone(),
tx.clone(),
tonic::Code::InvalidArgument,
error.to_owned(),
"incomplete deserialization".to_owned(),
)
.await;
}
Expand Down

0 comments on commit 2a100b3

Please sign in to comment.