Skip to content

Commit

Permalink
Revert crates/types/src/vid.rs to 01ea0ab (#3813)
Browse files Browse the repository at this point in the history
* revert crates/types/src/vid.rs to 01ea0ab

* clippy pacification

* more clippy

* just fmt_check
  • Loading branch information
ggutoski authored Oct 28, 2024
1 parent 83d9684 commit 5d9ed74
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 146 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions crates/example-types/src/block_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ impl<
}

fn payload_commitment(&self) -> VidCommitment {
self.payload_commitment.clone()
self.payload_commitment
}

fn metadata(&self) -> &<TYPES::BlockPayload as BlockPayload<TYPES>>::Metadata {
Expand All @@ -395,7 +395,9 @@ impl Committable for TestBlockHeader {
)
.constant_str("payload commitment")
.fixed_size_bytes(
<TestBlockHeader as BlockHeader<TestTypes>>::payload_commitment(self).as_ref(),
<TestBlockHeader as BlockHeader<TestTypes>>::payload_commitment(self)
.as_ref()
.as_ref(),
)
.finalize()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/task-impls/src/da.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> DaTaskState<TYP
// Generate and send vote
let vote = DaVote::create_signed_vote(
DaData {
payload_commit: payload_commitment.clone(),
payload_commit: payload_commitment,
},
view_number,
&self.public_key,
Expand Down
2 changes: 1 addition & 1 deletion crates/task-impls/src/quorum_proposal/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ impl<TYPES: NodeType, V: Versions> HandleDepOutput for ProposalDependencyHandle<
auction_result,
) => {
commit_and_metadata = Some(CommitmentAndMetadata {
commitment: payload_commitment.clone(),
commitment: *payload_commitment,
builder_commitment: builder_commitment.clone(),
metadata: metadata.clone(),
fees: fees.clone(),
Expand Down
4 changes: 2 additions & 2 deletions crates/task-impls/src/quorum_vote/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES> + 'static, V: Versions> Handl
return;
}
} else {
payload_commitment = Some(cert_payload_comm.clone());
payload_commitment = Some(*cert_payload_comm);
}
}
HotShotEvent::VidShareValidated(share) => {
Expand All @@ -322,7 +322,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES> + 'static, V: Versions> Handl
return;
}
} else {
payload_commitment = Some(vid_payload_commitment.clone());
payload_commitment = Some(*vid_payload_commitment);
}
}
_ => {}
Expand Down
39 changes: 17 additions & 22 deletions crates/task-impls/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
self.builder_timeout.saturating_sub(start.elapsed()),
async {
let client = BuilderClientMarketplace::new(url);
client
.bundle(*parent_view, parent_hash.clone(), *block_view)
.await
client.bundle(*parent_view, parent_hash, *block_view).await
},
));
}
Expand Down Expand Up @@ -539,7 +537,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask

match &view_data.view_inner {
ViewInner::Da { payload_commitment } => {
return Ok((target_view, payload_commitment.clone()))
return Ok((target_view, *payload_commitment))
}
ViewInner::Leaf {
leaf: leaf_commitment,
Expand Down Expand Up @@ -590,7 +588,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
match async_timeout(
self.builder_timeout
.saturating_sub(task_start_time.elapsed()),
self.block_from_builder(parent_comm.clone(), parent_view, &parent_comm_sig),
self.block_from_builder(parent_comm, parent_view, &parent_comm_sig),
)
.await
{
Expand Down Expand Up @@ -631,23 +629,20 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>, V: Versions> TransactionTask
.builder_clients
.iter()
.enumerate()
.map(|(builder_idx, client)| {
let parent_comm = parent_comm.clone();
async move {
client
.available_blocks(
parent_comm,
view_number.u64(),
self.public_key.clone(),
parent_comm_sig,
)
.await
.map(move |blocks| {
blocks
.into_iter()
.map(move |block_info| (block_info, builder_idx))
})
}
.map(|(builder_idx, client)| async move {
client
.available_blocks(
parent_comm,
view_number.u64(),
self.public_key.clone(),
parent_comm_sig,
)
.await
.map(move |blocks| {
blocks
.into_iter()
.map(move |block_info| (block_info, builder_idx))
})
})
.collect::<FuturesUnordered<_>>();
let mut results = Vec::with_capacity(self.builder_clients.len());
Expand Down
2 changes: 1 addition & 1 deletion crates/task-impls/src/vid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl<TYPES: NodeType, I: NodeImplementation<TYPES>> VidTaskState<TYPES, I> {
vid_precompute.clone(),
)
.await;
let payload_commitment = vid_disperse.payload_commitment.clone();
let payload_commitment = vid_disperse.payload_commitment;
let shares = VidDisperseShare::from_vid_disperse(vid_disperse.clone());
let mut consensus_writer = self.consensus.write().await;
for share in shares {
Expand Down
36 changes: 8 additions & 28 deletions crates/testing/tests/tests_1/da_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,8 @@ async fn test_da_task() {
proposals.push(view.da_proposal.clone());
leaders.push(view.leader_public_key);
votes.push(
view.create_da_vote(
DaData {
payload_commit: payload_commit.clone(),
},
&handle,
)
.await,
view.create_da_vote(DaData { payload_commit }, &handle)
.await,
);
dacs.push(view.da_certificate.clone());
vids.push(view.vid_proposal.clone());
Expand All @@ -87,13 +82,8 @@ async fn test_da_task() {
proposals.push(view.da_proposal.clone());
leaders.push(view.leader_public_key);
votes.push(
view.create_da_vote(
DaData {
payload_commit: payload_commit.clone(),
},
&handle,
)
.await,
view.create_da_vote(DaData { payload_commit }, &handle)
.await,
);
dacs.push(view.da_certificate.clone());
vids.push(view.vid_proposal.clone());
Expand Down Expand Up @@ -180,13 +170,8 @@ async fn test_da_task_storage_failure() {
proposals.push(view.da_proposal.clone());
leaders.push(view.leader_public_key);
votes.push(
view.create_da_vote(
DaData {
payload_commit: payload_commit.clone(),
},
&handle,
)
.await,
view.create_da_vote(DaData { payload_commit }, &handle)
.await,
);
dacs.push(view.da_certificate.clone());
vids.push(view.vid_proposal.clone());
Expand All @@ -198,13 +183,8 @@ async fn test_da_task_storage_failure() {
proposals.push(view.da_proposal.clone());
leaders.push(view.leader_public_key);
votes.push(
view.create_da_vote(
DaData {
payload_commit: payload_commit.clone(),
},
&handle,
)
.await,
view.create_da_vote(DaData { payload_commit }, &handle)
.await,
);
dacs.push(view.da_certificate.clone());
vids.push(view.vid_proposal.clone());
Expand Down
2 changes: 1 addition & 1 deletion crates/testing/tests/tests_1/vid_task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async fn test_vid_task() {
let encoded_transactions = Arc::from(TestTransaction::encode(&transactions));
let vid_disperse = vid.disperse(&encoded_transactions).unwrap();
let (_, vid_precompute) = vid.commit_only_precompute(&encoded_transactions).unwrap();
let payload_commitment = vid_disperse.commit.clone();
let payload_commitment = vid_disperse.commit;

let signature = <TestTypes as NodeType>::SignatureKey::sign(
handle.private_key(),
Expand Down
1 change: 0 additions & 1 deletion crates/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ time = { workspace = true }
tracing = { workspace = true }
typenum = { workspace = true }
derivative = "2"
derive_more = { workspace = true, features = ["display"] } # TODO promote display feature to workspace?
jf-vid = { workspace = true }
jf-pcs = { workspace = true }
jf-signature = { workspace = true, features = ["schnorr"] }
Expand Down
4 changes: 2 additions & 2 deletions crates/types/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ impl<TYPES: NodeType> VidDisperseShare<TYPES> {
recipient_key,
view_number: vid_disperse.view_number,
common: vid_disperse.common.clone(),
payload_commitment: vid_disperse.payload_commitment.clone(),
payload_commitment: vid_disperse.payload_commitment,
})
.collect()
}
Expand Down Expand Up @@ -345,7 +345,7 @@ impl<TYPES: NodeType> VidDisperseShare<TYPES> {
recipient_key,
view_number: vid_disperse_proposal.data.view_number,
common: vid_disperse_proposal.data.common.clone(),
payload_commitment: vid_disperse_proposal.data.payload_commitment.clone(),
payload_commitment: vid_disperse_proposal.data.payload_commitment,
},
signature: vid_disperse_proposal.signature.clone(),
_pd: vid_disperse_proposal._pd,
Expand Down
4 changes: 2 additions & 2 deletions crates/types/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<TYPES: NodeType> Clone for ViewInner<TYPES> {
fn clone(&self) -> Self {
match self {
Self::Da { payload_commitment } => Self::Da {
payload_commitment: payload_commitment.clone(),
payload_commitment: *payload_commitment,
},
Self::Leaf { leaf, state, delta } => Self::Leaf {
leaf: *leaf,
Expand Down Expand Up @@ -123,7 +123,7 @@ impl<TYPES: NodeType> ViewInner<TYPES> {
#[must_use]
pub fn payload_commitment(&self) -> Option<VidCommitment> {
if let Self::Da { payload_commitment } = self {
Some(payload_commitment.clone())
Some(*payload_commitment)
} else {
None
}
Expand Down
Loading

0 comments on commit 5d9ed74

Please sign in to comment.