From da634e66ddf8bc47fb2e0aaa4cb1c89eff7a8d7b Mon Sep 17 00:00:00 2001 From: Sebastien Chapuis Date: Tue, 3 Dec 2024 14:30:52 +0100 Subject: [PATCH 1/3] Fix vrf inputs were processed in reverse order --- vrf/src/message.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/vrf/src/message.rs b/vrf/src/message.rs index 4cf0ba22c3..10f67bbb62 100644 --- a/vrf/src/message.rs +++ b/vrf/src/message.rs @@ -1,6 +1,6 @@ use ark_ff::{One, SquareRootField, Zero}; -use ledger::ToInputs; +use ledger::{proofs::transaction::legacy_input::to_bits, ToInputs}; use mina_curves::pasta::curves::pallas::Pallas as CurvePoint; use mina_p2p_messages::v2::EpochSeed; use o1_utils::FieldHelpers; @@ -98,13 +98,9 @@ impl ToInputs for VrfMessage { } }; inputs.append_field(epoch_seed); - for i in (0..LEDGER_DEPTH).rev() { - if self.delegator_index >> i & 1u64 == 1 { - inputs.append_bool(true); - } else { - inputs.append_bool(false); - } - } inputs.append_u32(self.global_slot); + for bit in to_bits::<_, LEDGER_DEPTH>(self.delegator_index) { + inputs.append_bool(bit); + } } } From 817978eb3a5e868cc65eb3ecbdf39ab57ca5d777 Mon Sep 17 00:00:00 2001 From: Sebastien Chapuis Date: Tue, 3 Dec 2024 14:32:44 +0100 Subject: [PATCH 2/3] Test `vrf` crate in CI --- .github/workflows/ci.yaml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c64c412c02..26e013c6e3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -77,6 +77,29 @@ jobs: cd ledger cargo test --release -- -Z unstable-options --report-time + vrf-tests: + runs-on: ubuntu-20.04 + steps: + - name: Git checkout + uses: actions/checkout@v4 + - name: Setup build dependencies + run: | + sudo apt update + sudo apt install -y protobuf-compiler + - name: Setup Rust + run: | + # Nightly to be able to use `--report-time` below + rustup install nightly + rustup override set nightly + - name: Build vrf tests + run: | + cd vrf + cargo build --release --tests + - name: Run vrf tests + run: | + cd vrf + cargo test --release -- -Z unstable-options --report-time + tx-fuzzer-check: runs-on: ubuntu-20.04 steps: From aa00de1d1c53fa200308e0b39e261f14b5c6612a Mon Sep 17 00:00:00 2001 From: Sebastien Chapuis Date: Tue, 3 Dec 2024 14:59:54 +0100 Subject: [PATCH 3/3] Fix test `vrf::output::tests::test_conv_to_mina_type` --- vrf/src/output.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vrf/src/output.rs b/vrf/src/output.rs index bfb92dc631..40b7410c70 100644 --- a/vrf/src/output.rs +++ b/vrf/src/output.rs @@ -157,7 +157,7 @@ mod test { let converted = ConsensusVrfOutputTruncatedStableV1::from(vrf_output); let converted_string = serde_json::to_string_pretty(&converted).unwrap(); let converted_string_deser: String = serde_json::from_str(&converted_string).unwrap(); - let expected = String::from("48H9Qk4D6RzS9kAJQX9HCDjiJ5qLiopxgxaS6xbDCWNaKQMQ9Y4C"); + let expected = String::from("39cyg4ZmMtnb_aFUIerNAoAJV8qtkfOpq0zFzPspjgM="); assert_eq!(expected, converted_string_deser); }