-
Notifications
You must be signed in to change notification settings - Fork 2
Introduce trait StakeTableScheme and migrate previous implementations #66
Conversation
…Proof->::QC, partial_sign->sign, active_keys->signers
Q: should we make currently our stake table implementation uses concrete types This decision forces me to write: /// Public parameters for [`BitVectorQC`].
/// generic over the stake table type `ST` and aggregated signature type `A`
#[derive(Serialize, Deserialize, PartialEq, Debug)]
pub struct QCParams<A: AggregateableSignatureSchemes, ST: StakeTableScheme> {
// pub stake_entries: Vec<StakeTableEntry<V>>,
pub stake_table: Arc<ST>,
pub threshold: U256,
pub agg_sig_pp: A::PublicParameter,
}
impl<A, ST> QuorumCertificate<A> for BitVectorQC<A, ST>
where
A: AggregateableSignatureSchemes + Serialize + for<'a> Deserialize<'a>,
ST: StakeTableScheme<Amount = U256>,
ST::Key: From<A::VerificationKey>,
A::VerificationKey: From<ST::Key>, instead of impl<A, ST> QuorumCertificate<A> for BitVectorQC<A, ST>
where
A: AggregateableSignatureSchemes + Serialize + for<'a> Deserialize<'a>,
ST: StakeTableScheme<Key = A::VerificationKey>,
ST::Amount: Add<Output = Self>, Apart from having cleaner trait bound, the main advantages of the latter (if we have generic In short, I would propose that we make turn our Stake Table generic |
@alxiong Good idea on generalizing pub fn update(
&mut self,
key: &EncodedPublicKey,
delta: U256,
negative: bool,
) -> Result<U256, StakeTableError>; |
right, all I need is to add trait bound related to |
Yep. Also that's the only place with all troubles. |
* refactor: make stake table impl generic over key type * fix err * feat: QC key aggregate gadget (#74) * update to the newest interface * refactor keyagg gadget * update doc * update test name * public inputs * remove cargo.lock * refactor qc gadgets * refactor qc gadgets * remove branch from jellyfish deps * updated comments * more comments --------- Co-authored-by: Chengyu Lin <[email protected]>
Here's a problem: previously, we had this VerKey -> ark_bn254::Fq conversion: hotshot-primitives/src/stake_table/mod.rs Line 240 in e9bda5c
but this code has the wrong assumption that
at the current stage of this PR, I introduce this And I think I might be better refactoring it to hotshot-primitives/src/stake_table/utils.rs Lines 94 to 100 in e9bda5c
and hotshot-primitives/src/stake_table/config.rs Lines 13 to 14 in e9bda5c
into maybe There's another almost hacky way to avoid deserialization error. that is to define and manually implement serialization of ^^ the problem with this approach is given a serialized @mrain let's chat and see which one do we prefer and what to do next. |
After discussion with @mrain, we decide to go with: |
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.
Generally LGTM, with some minor comments
Resolve #65.
(a follow-up of, and should be merged after, #64)
Major changes include:
trait StakeTableScheme
SnapshotVersion
frompending/frozen/active
tohead/epoch_start/last_epoch_start
for better readabilitylen()
,contains_key()
,deregister()
(left unimplemented and future work); notable changes include:lookup()
now returns(Amount, Proof)
instead of justMerkleProof
as before.struct StakeTableEntry<V>
with generic API fromtrait StakeTableScheme
PersistentMerkleNode
, implementIntoIterator
forStakeTableScheme
K
instead of fixated onEncodedPublicKey