Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Disable approval/assignment checks
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
  • Loading branch information
sandreim committed Feb 2, 2023
1 parent 036fa25 commit 7ebf744
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 42 deletions.
68 changes: 38 additions & 30 deletions node/core/approval-voting/src/criteria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,10 @@ pub(crate) enum InvalidAssignmentReason {
CoreIndexOutOfBounds,
InvalidAssignmentKey,
IsInBackingGroup,
VRFModuloCoreIndexMismatch,
VRFModuloOutputMismatch,
//VRFModuloCoreIndexMismatch,
//VRFModuloOutputMismatch,
VRFDelayCoreIndexMismatch,
VRFDelayOutputMismatch,
//VRFDelayOutputMismatch,
}

/// Checks the crypto of an assignment cert. Failure conditions:
Expand All @@ -469,7 +469,7 @@ pub(crate) fn check_assignment_cert(
claimed_core_index: CoreIndex,
validator_index: ValidatorIndex,
config: &Config,
relay_vrf_story: RelayVRFStory,
_relay_vrf_story: RelayVRFStory,
assignment: &AssignmentCert,
backing_group: GroupIndex,
) -> Result<DelayTranche, InvalidAssignment> {
Expand All @@ -496,42 +496,50 @@ pub(crate) fn check_assignment_cert(
return Err(InvalidAssignment(Reason::IsInBackingGroup))
}

let &(ref vrf_output, ref vrf_proof) = &assignment.vrf;
let &(ref vrf_output, ref _vrf_proof) = &assignment.vrf;
match assignment.kind {
AssignmentCertKind::RelayVRFModulo { sample } => {
if sample >= config.relay_vrf_modulo_samples {
return Err(InvalidAssignment(Reason::SampleOutOfBounds))
}

let (vrf_in_out, _) = public
.vrf_verify_extra(
relay_vrf_modulo_transcript(relay_vrf_story, sample),
&vrf_output.0,
&vrf_proof.0,
assigned_core_transcript(claimed_core_index),
)
.map_err(|_| InvalidAssignment(Reason::VRFModuloOutputMismatch))?;

// ensure that the `vrf_in_out` actually gives us the claimed core.
if relay_vrf_modulo_core(&vrf_in_out, config.n_cores) == claimed_core_index {
Ok(0)
} else {
Err(InvalidAssignment(Reason::VRFModuloCoreIndexMismatch))
}
// let (vrf_in_out, _) = public
// .vrf_verify_extra(
// relay_vrf_modulo_transcript(relay_vrf_story, sample),
// &vrf_output.0,
// &vrf_proof.0,
// assigned_core_transcript(claimed_core_index),
// )
// .map_err(|_| InvalidAssignment(Reason::VRFModuloOutputMismatch))?;

// // ensure that the `vrf_in_out` actually gives us the claimed core.
// if relay_vrf_modulo_core(&vrf_in_out, config.n_cores) == claimed_core_index {
// Ok(0)
// } else {
// Err(InvalidAssignment(Reason::VRFModuloCoreIndexMismatch))
// }

Ok(0)
},
AssignmentCertKind::RelayVRFDelay { core_index } => {
if core_index != claimed_core_index {
return Err(InvalidAssignment(Reason::VRFDelayCoreIndexMismatch))
}

let (vrf_in_out, _) = public
.vrf_verify(
relay_vrf_delay_transcript(relay_vrf_story, core_index),
&vrf_output.0,
&vrf_proof.0,
)
.map_err(|_| InvalidAssignment(Reason::VRFDelayOutputMismatch))?;

// let (vrf_in_out, _) = public
// .vrf_verify(
// relay_vrf_delay_transcript(relay_vrf_story, core_index),
// &vrf_output.0,
// &vrf_proof.0,
// )
// .map_err(|_| InvalidAssignment(Reason::VRFDelayOutputMismatch))?;

let vrf_in_out = vrf_output
.0
.attach_input_hash(&public, Transcript::new(b"VRF"))
.expect("never fails; qed");
// let vrf_in_out = SecretKey::vrf_create_from_compressed_point(&vrf_output.0)
// .expect("create from compressed always works; qed");
Ok(relay_vrf_delay_tranche(
&vrf_in_out,
config.n_delay_tranches,
Expand Down Expand Up @@ -771,7 +779,7 @@ mod tests {
config: config.clone(),
};

let expected = match f(&mut mutated) {
let _expected = match f(&mut mutated) {
None => continue,
Some(e) => e,
};
Expand All @@ -788,7 +796,7 @@ mod tests {
)
.is_ok();

assert_eq!(expected, is_good)
// assert_eq!(expected, is_good)
}

assert!(counted > 0);
Expand Down
24 changes: 12 additions & 12 deletions node/core/approval-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//! on, performing those approval checks, and tracking the assignments and approvals
//! of others. It uses this information to determine when candidates and blocks have
//! been sufficiently approved to finalize.

#![allow(unused_imports)]
use polkadot_node_jaeger as jaeger;
use polkadot_node_primitives::{
approval::{
Expand Down Expand Up @@ -1855,17 +1855,17 @@ fn check_and_import_approval<T>(
};

// Signature check:
match DisputeStatement::Valid(ValidDisputeStatementKind::ApprovalChecking).check_signature(
&pubkey,
approved_candidate_hash,
block_entry.session(),
&approval.signature,
) {
Err(_) => respond_early!(ApprovalCheckResult::Bad(ApprovalCheckError::InvalidSignature(
approval.validator
),)),
Ok(()) => {},
};
// match DisputeStatement::Valid(ValidDisputeStatementKind::ApprovalChecking).check_signature(
// &pubkey,
// approved_candidate_hash,
// block_entry.session(),
// &approval.signature,
// ) {
// Err(_) => respond_early!(ApprovalCheckResult::Bad(ApprovalCheckError::InvalidSignature(
// approval.validator
// ),)),
// Ok(()) => {},
// };

let candidate_entry = match db.load_candidate_entry(&approved_candidate_hash)? {
Some(c) => c,
Expand Down

0 comments on commit 7ebf744

Please sign in to comment.