Skip to content

Commit

Permalink
generate_state_witness_parts cannot fail (#12645)
Browse files Browse the repository at this point in the history
Does not return a `Result` from `generate_state_witness_parts()` as it
cannot fail and some knock on removal of unnecessary `Result`s.
  • Loading branch information
akhi3030 authored Jan 2, 2025
1 parent 69ae722 commit 23e6b81
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,11 @@ impl PartialWitnessActor {
witness_bytes,
&chunk_validators,
&signer,
)?;
);

if !contract_deploys.is_empty() {
self.send_chunk_contract_deploys_parts(key, contract_deploys)?;
}

Ok(())
}

Expand All @@ -256,7 +255,7 @@ impl PartialWitnessActor {
witness_bytes: EncodedChunkStateWitness,
chunk_validators: &[AccountId],
signer: &ValidatorSigner,
) -> Result<Vec<(AccountId, PartialEncodedStateWitness)>, Error> {
) -> Vec<(AccountId, PartialEncodedStateWitness)> {
tracing::debug!(
target: "client",
chunk_hash=?chunk_header.chunk_hash(),
Expand All @@ -268,7 +267,7 @@ impl PartialWitnessActor {
let encoder = self.witness_encoders.entry(chunk_validators.len());
let (parts, encoded_length) = encoder.encode(&witness_bytes);

Ok(chunk_validators
chunk_validators
.iter()
.zip_eq(parts)
.enumerate()
Expand All @@ -285,7 +284,7 @@ impl PartialWitnessActor {
);
(chunk_validator.clone(), partial_witness)
})
.collect_vec())
.collect_vec()
}

fn generate_contract_deploys_parts(
Expand Down Expand Up @@ -333,7 +332,7 @@ impl PartialWitnessActor {
witness_bytes: EncodedChunkStateWitness,
chunk_validators: &[AccountId],
signer: &ValidatorSigner,
) -> Result<(), Error> {
) {
// Capture these values first, as the sources are consumed before calling record_witness_sent.
let chunk_hash = chunk_header.chunk_hash();
let witness_size_in_bytes = witness_bytes.size_bytes();
Expand All @@ -349,7 +348,7 @@ impl PartialWitnessActor {
witness_bytes,
chunk_validators,
signer,
)?;
);
encode_timer.observe_duration();

// Record the witness in order to match the incoming acks for measuring round-trip times.
Expand All @@ -364,7 +363,6 @@ impl PartialWitnessActor {
self.network_adapter.send(PeerManagerMessageRequest::NetworkRequests(
NetworkRequests::PartialEncodedStateWitness(validator_witness_tuple),
));
Ok(())
}

/// Sends the witness part to the chunk validators, except the chunk producer that generated the witness part.
Expand Down

0 comments on commit 23e6b81

Please sign in to comment.