Conversation
OCaml Reference Validation ResultsRepository: https://github.com/MinaProtocol/mina.git Click to see full validation output |
✓ Code Reference Verification PassedAll code references in the documentation have been verified successfully! Total references checked: 1 The documentation is in sync with the codebase on the |
There was a problem hiding this comment.
🤔 this is already in the mina-poseidon crate...
| pub trait SpongeParamsForField<F: FieldWitness> { | ||
| fn get_params(is_legacy: bool) -> &'static SpongeParams<F>; | ||
| } |
There was a problem hiding this comment.
This could be a const
|
|
||
| let expected_root_hash = LedgerHash::from_str(expected_root_hash).unwrap().0.clone(); | ||
|
|
||
| assert_eq!(root_hash, expected_root_hash); |
There was a problem hiding this comment.
sus that this was deleted (the whole test that is)
| //! | ||
| //! // Initialize SNARK state with configuration | ||
| //! let config = SnarkConfig { /* ... */ }; | ||
| //! let config: SnarkConfig = todo!(); |
crates/vrf/src/lib.rs
Outdated
| } | ||
|
|
||
| #[test] | ||
| // #[ignore = "Runs long, remember to re-enable me!"] |
There was a problem hiding this comment.
Now remember to delete the comment
poseidon/src/lib.rs
Outdated
There was a problem hiding this comment.
There shouldn't be any changes in here, this whole file/crate should be deleted
POSEIDON_EXECUTION_PLAN.md
Outdated
POSEIDON_MIGRATION_PLAN.md
Outdated
dd96b2f to
66d0efc
Compare
| } | ||
|
|
||
| fn block_cipher<F: FieldWitness>( | ||
| fn block_cipher<F: FieldWitness + SpongeParamsForField<F>>( |
There was a problem hiding this comment.
And here... but does it make sense that this even has to be re-implemented?
| params: &SpongeParams<F>, | ||
| w: &mut Witness<F>, | ||
| ) { | ||
| let round_constants = &<F as SpongeParamsForField<F>>::get_params(false).round_constants; |
There was a problem hiding this comment.
This is odd. This is just a constant based on F. It should be a different generic argument, I would think, not a trait bound on F.
| .zip(params.mds[i].iter()) | ||
| .fold(F::zero(), |x, (s, &m)| m * s + x) | ||
| }) | ||
| fn apply_mds_matrix<F: FieldWitness + SpongeParamsForField<F>>(state: &[F; 3]) -> [F; 3] { |
There was a problem hiding this comment.
This should already exist in mina_poseidon
|
|
||
| for state_i in state.iter_mut() { | ||
| *state_i = sbox::<F>(*state_i); | ||
| *state_i = sbox(*state_i); |
There was a problem hiding this comment.
sbox should already exist in mina-poseidon. How is this different?
There was a problem hiding this comment.
It's because of the witness
crates/ledger/src/proofs/step.rs
Outdated
| let xi_chal: [u64; 2] = sponge.squeeze_limbs(); | ||
| let r_chal: [u64; 2] = sponge.squeeze_limbs(); | ||
| let xi_chal: [u64; 2] = sponge.squeeze_limbs(2).try_into().unwrap(); | ||
| let r_chal: [u64; 2] = sponge.squeeze_limbs(2).try_into().unwrap(); |
|
|
||
| fn to_fqs(fps: &[Fp]) -> Vec<Fq> { | ||
| fps.iter().map(|fp| Fq::from((*fp).into_bigint())).collect() | ||
| } |
There was a problem hiding this comment.
...this is odd that we have to do this
| pub fields: Vec<F>, | ||
| pub bits: Vec<bool>, |
There was a problem hiding this comment.
These probably shouldn't be pub
There was a problem hiding this comment.
This is kind of crazy too. Can and should use bytemuck to do something more efficient
| fields: Vec::with_capacity(256), | ||
| bits: Vec::with_capacity(512), |
There was a problem hiding this comment.
Comment on sizes here
There was a problem hiding this comment.
I'm not sure where these hashes came with to begin with
| Unattached { hashes, .. } => hashes, | ||
| Root { database, .. } => return dbg!(database.get_cached_hash(addr)), | ||
| Attached { hashes, .. } => dbg!(hashes), | ||
| Unattached { hashes, .. } => dbg!(hashes), |
| let of_coord = | ||
| |(x, y): &(BigInt, BigInt)| Ok(Vesta::of_coordinates(x.to_field()?, y.to_field()?)); | ||
| let of_coord = |(x, y): &(BigInt, BigInt)| { | ||
| Vesta::of_coordinates(x.to_field::<Fq>(), y.to_field::<Fq>()) |
There was a problem hiding this comment.
Fq can be inferred herer
| BigInt: From<&'a <G as AffineRepr>::ScalarField>, | ||
| BigInt: From<&'a <G as AffineRepr>::BaseField>, | ||
| BigInt: From<<G as AffineRepr>::ScalarField>, | ||
| BigInt: From<<G as AffineRepr>::BaseField>, |
There was a problem hiding this comment.
These are Copy types, we shouldn't be dealing with references here
| fn block_cipher<F: FieldWitness>( | ||
| fn block_cipher<F: FieldWitness + SpongeParamsForField<F>>( | ||
| mut state: [F; M], | ||
| params: &SpongeParams<F>, |
There was a problem hiding this comment.
did I need this for Legacy-params?
| number: number.to_ne_bytes(), | ||
| } | ||
| .take(NBITS) | ||
| pub fn bits_iter<N: Pod, const NBITS: usize>(number: &N) -> impl Iterator<Item = bool> + '_ { |
There was a problem hiding this comment.
Need to double check this
|
|
||
| pub fn to_bits<N: Into<u64>, const NBITS: usize>(number: N) -> [bool; NBITS] { | ||
| let mut iter = bits_iter::<N, NBITS>(number); | ||
| pub fn to_bits<N: Pod, const NBITS: usize>(number: N) -> [bool; NBITS] { |
|
|
||
| for key in keys { | ||
| match BaseLedger::location_of_account(&ledger, key) { | ||
| match BaseLedger::location_of_account(&ledger, dbg!(key)) { |
There was a problem hiding this comment.
Couple of dbg! statements that need to be deleted here
| self.0.clone() | ||
| } | ||
| fn domain_string(_: ()) -> Option<String> { | ||
| Some("MinaProtoState".to_string()) |
There was a problem hiding this comment.
Should use HashParam if it's accessible
| ROInput::new() | ||
| } | ||
| fn domain_string(_: ()) -> Option<String> { | ||
| Some("CoinbaseStack".to_string()) |
| test_to_field!(to_field_u64_test: append_u64(u64::MIN, u64::MAX/2, u64::MAX) = "ffffffffffffffffffffffffffffff7f00000000000000000000000000000000"); | ||
| test_to_field!(to_field_u48_test: append_u48(u48(u64::MIN), u48(u64::MAX/2), u48(u64::MAX)) = "ffffffffffffffffffffffff0000000000000000000000000000000000000000"); | ||
| test_to_field!(to_field_bytes_test: append_bytes(&[0, 1, 255]) = "ff80000000000000000000000000000000000000000000000000000000000000"); | ||
| test_to_field!(to_field_bytes_test: append_bytes_be(&[0, 1, 255]) = "ff80000000000000000000000000000000000000000000000000000000000000"); |
There was a problem hiding this comment.
PaddedSeq wraps an array, so we should just delegate to an array's Serialize and Deserialize implementations
| where | ||
| S: serde::Serializer, | ||
| { | ||
| let mut serializer = serializer.serialize_tuple(N + 1)?; |
There was a problem hiding this comment.
No idea why the + 1 was here
| inputs | ||
| } | ||
| fn domain_string(height: u32) -> Option<String> { | ||
| Some(format!("MinaMklTree{:03}", height)) |
There was a problem hiding this comment.
Should use HashParam
| self.0.clone() | ||
| } | ||
| fn domain_string(_: Self::D) -> Option<String> { | ||
| Some("MinaVrfMessage".to_string()) |
| delegator_index: u64, | ||
| pub global_slot: u32, | ||
| pub epoch_seed: EpochSeed, | ||
| pub delegator_index: u64, |
There was a problem hiding this comment.
🤔 why are these pub?
| inputs.append(x); | ||
| inputs.append(y); | ||
| fn domain_string(_: Self::D) -> Option<String> { | ||
| Some("MinaVrfOutput".to_string()) |
This is a draft. Will edit soon