Skip to content
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

Gate vote commitment again #3732

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions crates/libp2p-networking/src/network/behaviours/dht/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,16 @@ impl<R: RecordStore, K: SignatureKey> RecordStore for ValidatedStore<R, K>
where
K: 'static,
{
type ProvidedIter<'a> = R::ProvidedIter<'a> where R: 'a, K: 'a;
type RecordsIter<'a> = R::RecordsIter<'a> where R: 'a, K: 'a;
type ProvidedIter<'a>
= R::ProvidedIter<'a>
where
R: 'a,
K: 'a;
type RecordsIter<'a>
= R::RecordsIter<'a>
where
R: 'a,
K: 'a;

// Delegate all `RecordStore` methods except `put` to the inner store
delegate! {
Expand Down
16 changes: 11 additions & 5 deletions crates/types/src/simple_vote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{fmt::Debug, hash::Hash, marker::PhantomData};
use anyhow::Result;
use committable::{Commitment, Committable};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use vbs::version::Version;
use vbs::version::{StaticVersionType, Version};

use crate::{
data::Leaf,
Expand Down Expand Up @@ -240,10 +240,16 @@ impl<TYPES: NodeType, DATA: Voteable, V: Versions> Committable
for VersionedVoteData<TYPES, DATA, V>
{
fn commit(&self) -> Commitment<Self> {
committable::RawCommitmentBuilder::new("Vote")
.var_size_bytes(self.data.commit().as_ref())
.u64(*self.view)
.finalize()
if self.version < V::Marketplace::VERSION {
let bytes: [u8; 32] = self.data.commit().into();

Commitment::<Self>::from_raw(bytes)
} else {
committable::RawCommitmentBuilder::new("Vote")
.var_size_bytes(self.data.commit().as_ref())
.u64(*self.view)
.finalize()
}
}
}

Expand Down