Skip to content

Commit

Permalink
remove verify_partial_witness_signature
Browse files Browse the repository at this point in the history
  • Loading branch information
stedfn committed Nov 8, 2024
1 parent 69d0922 commit c8eab17
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 25 deletions.
7 changes: 0 additions & 7 deletions chain/chain/src/test_utils/kv_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1022,13 +1022,6 @@ impl EpochManagerAdapter for MockEpochManager {
Ok(true)
}

fn verify_partial_witness_signature(
&self,
_partial_witness: &PartialEncodedStateWitness,
) -> Result<bool, Error> {
Ok(true)
}

fn verify_witness_contract_accesses_signature(
&self,
_accesses: &ChunkContractAccesses,
Expand Down
4 changes: 3 additions & 1 deletion chain/client/src/stateless_validation/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ pub fn validate_partial_encoded_state_witness(
return Ok(false);
}

if !epoch_manager.verify_partial_witness_signature(&partial_witness)? {
let chunk_producer =
epoch_manager.get_chunk_producer_info(&partial_witness.chunk_production_key())?;
if !partial_witness.verify(chunk_producer.public_key()) {
return Err(Error::InvalidPartialChunkStateWitness("Invalid signature".to_string()));
}

Expand Down
14 changes: 0 additions & 14 deletions chain/epoch-manager/src/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,6 @@ pub trait EpochManagerAdapter: Send + Sync {
endorsement: &ChunkEndorsement,
) -> Result<bool, Error>;

fn verify_partial_witness_signature(
&self,
partial_witness: &PartialEncodedStateWitness,
) -> Result<bool, Error>;

fn verify_witness_contract_accesses_signature(
&self,
accesses: &ChunkContractAccesses,
Expand Down Expand Up @@ -1177,15 +1172,6 @@ impl EpochManagerAdapter for EpochManagerHandle {
Ok(endorsement.verify(validator.public_key()))
}

fn verify_partial_witness_signature(
&self,
partial_witness: &PartialEncodedStateWitness,
) -> Result<bool, Error> {
let chunk_producer =
self.read().get_chunk_producer_info(&partial_witness.chunk_production_key())?;
Ok(partial_witness.verify(chunk_producer.public_key()))
}

fn verify_witness_contract_accesses_signature(
&self,
accesses: &ChunkContractAccesses,
Expand Down
8 changes: 5 additions & 3 deletions chain/epoch-manager/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3360,11 +3360,13 @@ fn test_verify_partial_witness_signature() {
7,
signer.as_ref(),
);
assert!(epoch_manager.verify_partial_witness_signature(&partial_witness).unwrap());
let chunk_producer =
epoch_manager.get_chunk_producer_info(&partial_witness.chunk_production_key()).unwrap();
assert!(partial_witness.verify(chunk_producer.public_key()));

// Check invalid chunk state witness signature.
partial_witness.signature = Signature::default();
assert!(!epoch_manager.verify_partial_witness_signature(&partial_witness).unwrap());
assert!(!partial_witness.verify(chunk_producer.public_key()));

// Check chunk state witness invalidity when signer is not a chunk validator.
let bad_signer = Arc::new(create_test_signer("test2"));
Expand All @@ -3376,7 +3378,7 @@ fn test_verify_partial_witness_signature() {
7,
bad_signer.as_ref(),
);
assert!(!epoch_manager.verify_partial_witness_signature(&bad_partial_witness).unwrap());
assert!(!bad_partial_witness.verify(chunk_producer.public_key()));
}

/// Simulate the blockchain over a few epochs and verify that possible_epochs_of_height_around_tip()
Expand Down

0 comments on commit c8eab17

Please sign in to comment.