Skip to content

Commit f946d8f

Browse files
committed
feat(validations): make block signature validations aware of protocol versions
1 parent d5c6e82 commit f946d8f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

validations/src/validations.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use witnet_data_structures::{
3030
},
3131
error::{BlockError, DataRequestError, TransactionError},
3232
get_protocol_version,
33-
proto::versioning::ProtocolVersion,
33+
proto::versioning::{ProtocolVersion, VersionedHashable},
3434
radon_report::{RadonReport, ReportContext},
3535
transaction::{
3636
CommitTransaction, DRTransaction, MintTransaction, RevealTransaction, StakeTransaction,
@@ -1318,9 +1318,9 @@ pub fn validate_block_signature(
13181318
let signature = keyed_signature.signature.clone().try_into()?;
13191319
let public_key = keyed_signature.public_key.clone().try_into()?;
13201320

1321-
// TODO: take into account block epoch to decide protocol version (with regards to data
1322-
// structures and hashing)
1323-
let Hash::SHA256(message) = block.hash();
1321+
let Hash::SHA256(message) = block.versioned_hash(get_protocol_version(Some(
1322+
block.block_header.beacon.checkpoint,
1323+
)));
13241324

13251325
add_secp_block_signature_to_verify(signatures_to_verify, &public_key, &message, &signature);
13261326

0 commit comments

Comments
 (0)