-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: send partial witnesses faster #12640
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -249,14 +249,14 @@ impl PartialWitnessActor { | |
} | ||
|
||
// Function to generate the parts of the state witness and return them as a tuple of chunk_validator and part. | ||
fn generate_state_witness_parts( | ||
fn generate_and_send_state_witness_parts( | ||
&mut self, | ||
epoch_id: EpochId, | ||
chunk_header: &ShardChunkHeader, | ||
witness_bytes: EncodedChunkStateWitness, | ||
chunk_validators: &[AccountId], | ||
signer: &ValidatorSigner, | ||
) -> Result<Vec<(AccountId, PartialEncodedStateWitness)>, Error> { | ||
) -> Result<(), Error> { | ||
tracing::debug!( | ||
target: "client", | ||
chunk_hash=?chunk_header.chunk_hash(), | ||
|
@@ -268,11 +268,8 @@ impl PartialWitnessActor { | |
let encoder = self.witness_encoders.entry(chunk_validators.len()); | ||
let (parts, encoded_length) = encoder.encode(&witness_bytes); | ||
|
||
Ok(chunk_validators | ||
.iter() | ||
.zip_eq(parts) | ||
.enumerate() | ||
.map(|(part_ord, (chunk_validator, part))| { | ||
chunk_validators.iter().zip_eq(parts).enumerate().for_each( | ||
stedfn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|(part_ord, (chunk_validator, part))| { | ||
// It's fine to unwrap part here as we just constructed the parts above and we expect | ||
// all of them to be present. | ||
let partial_witness = PartialEncodedStateWitness::new( | ||
|
@@ -283,9 +280,16 @@ impl PartialWitnessActor { | |
encoded_length, | ||
signer, | ||
); | ||
(chunk_validator.clone(), partial_witness) | ||
}) | ||
.collect_vec()) | ||
let validator_witness_tuple = (chunk_validator.clone(), partial_witness); | ||
|
||
// Send the parts to the corresponding chunk validator owners. | ||
self.network_adapter.send(PeerManagerMessageRequest::NetworkRequests( | ||
NetworkRequests::PartialEncodedStateWitness(validator_witness_tuple), | ||
)); | ||
}, | ||
); | ||
|
||
Ok(()) | ||
} | ||
|
||
fn generate_contract_deploys_parts( | ||
|
@@ -343,7 +347,7 @@ impl PartialWitnessActor { | |
let encode_timer = metrics::PARTIAL_WITNESS_ENCODE_TIME | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it worth specifying it? I guess it just adds a message to the channel on every iteration which should not be expensive There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually it can block if the channel is bounded and full but I am struggling to understand the macro to be sure |
||
.with_label_values(&[shard_id_label.as_str()]) | ||
.start_timer(); | ||
let validator_witness_tuple = self.generate_state_witness_parts( | ||
self.generate_and_send_state_witness_parts( | ||
epoch_id, | ||
chunk_header, | ||
witness_bytes, | ||
|
@@ -357,13 +361,9 @@ impl PartialWitnessActor { | |
self.state_witness_tracker.record_witness_sent( | ||
chunk_hash, | ||
witness_size_in_bytes, | ||
validator_witness_tuple.len(), | ||
chunk_validators.len(), | ||
); | ||
|
||
// Send the parts to the corresponding chunk validator owners. | ||
self.network_adapter.send(PeerManagerMessageRequest::NetworkRequests( | ||
NetworkRequests::PartialEncodedStateWitness(validator_witness_tuple), | ||
)); | ||
Ok(()) | ||
} | ||
|
||
|
@@ -598,7 +598,7 @@ impl PartialWitnessActor { | |
|
||
/// Sends the contract accesses to the same chunk validators | ||
/// (except for the chunk producers that track the same shard), | ||
/// which will receive the state witness for the new chunk. | ||
/// which will receive the state witness for the new chunk. | ||
fn send_contract_accesses_to_chunk_validators( | ||
&self, | ||
key: ChunkProductionKey, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might have to wait for Akhi's PR to land