Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray committed May 13, 2024
1 parent 594a70e commit 042803e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion ffi_interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ pub fn hash_commitments(commitments: &[CommitmentBytes]) -> Vec<ScalarBytes> {
/// This function assumes that the domain is always 256 values and commitment is 32bytes.
pub fn create_proof(context: &Context, input: Vec<u8>) -> Result<Vec<u8>, Error> {
// - Checks for the serialized proof queries
///
//
// Define the chunk size (8257 bytes)
// C_i, f_i(X), z_i, y_i
// 32, 8192, 1, 32
Expand Down
44 changes: 23 additions & 21 deletions verkle-trie/src/proof/golang_proof_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ struct StateDiff {
}

impl StateDiff {
#[allow(clippy::type_complexity)]
/// Returns the keys, their old values and their new values
pub fn keys_with_current_values(
&self,
) -> (Vec<[u8; 32]>, Vec<Option<[u8; 32]>>, Vec<Option<[u8; 32]>>) {
Expand Down Expand Up @@ -198,12 +200,12 @@ struct MultiPointProofGo {
}

pub fn hex_to_bytes32(hex: &str) -> [u8; 32] {
hex_to_bytesN(hex)
hex_to_fixed_size_array(hex)
}
fn hex_to_bytes31(hex: &str) -> [u8; 31] {
hex_to_bytesN(hex)
hex_to_fixed_size_array(hex)
}
fn hex_to_bytesN<const N: usize>(hex: &str) -> [u8; N] {
fn hex_to_fixed_size_array<const N: usize>(hex: &str) -> [u8; N] {
let hex = hex.trim_start_matches("0x");
let bytes = hex::decode(hex).unwrap();
let mut bytes_n = [0u8; N];
Expand Down Expand Up @@ -237,18 +239,6 @@ fn byte_to_depth_extension_present(value: u8) -> (ExtPresent, u8) {
(ext_status, depth)
}

fn bytes_to_depth_extension_present(bytes: &[u8]) -> (Vec<ExtPresent>, Vec<u8>) {
let mut ext_present_statuses = Vec::with_capacity(bytes.len());
let mut depths = Vec::with_capacity(bytes.len());
for byte in bytes.into_iter() {
let (ext_status, depth) = byte_to_depth_extension_present(*byte);
ext_present_statuses.push(ext_status);
depths.push(depth);
}

(ext_present_statuses, depths)
}

// Taken from https://github.com/ethereumjs/ethereumjs-monorepo/blob/master/packages/statemanager/test/testdata/verkleKaustinenBlock.json#L1-L2626
// Block number 0x62
pub const PREVIOUS_STATE_ROOT: &str =
Expand Down Expand Up @@ -308,8 +298,6 @@ pub mod serde_conversions {

use serde::{Deserialize, Serialize};

use super::EXECUTION_WITNESS_JSON;

#[derive(Serialize, Deserialize, Debug)]
pub struct ExecutionWitness {
#[serde(rename = "stateDiff")]
Expand Down Expand Up @@ -357,6 +345,7 @@ pub mod serde_conversions {

#[test]
fn test_serde_works() {
use super::EXECUTION_WITNESS_JSON;
let _: ExecutionWitness = serde_json::from_str(EXECUTION_WITNESS_JSON).unwrap();
}
}
Expand All @@ -367,13 +356,26 @@ mod tests {

use crate::proof::{
golang_proof_format::{
bytes32_to_element, bytes32_to_scalar, bytes_to_depth_extension_present, hex_to_bytes,
hex_to_bytes31, hex_to_bytes32, StateDiff, SuffixDiff, VerkleProofGo,
EXECUTION_WITNESS_JSON, PREVIOUS_STATE_ROOT,
bytes32_to_element, bytes32_to_scalar, hex_to_bytes, hex_to_bytes31, hex_to_bytes32,
StateDiff, SuffixDiff, VerkleProofGo, EXECUTION_WITNESS_JSON, PREVIOUS_STATE_ROOT,
},
VerificationHint, VerkleProof,
ExtPresent, VerificationHint, VerkleProof,
};

use super::byte_to_depth_extension_present;

fn bytes_to_depth_extension_present(bytes: &[u8]) -> (Vec<ExtPresent>, Vec<u8>) {
let mut ext_present_statuses = Vec::with_capacity(bytes.len());
let mut depths = Vec::with_capacity(bytes.len());
for byte in bytes.iter() {
let (ext_status, depth) = byte_to_depth_extension_present(*byte);
ext_present_statuses.push(ext_status);
depths.push(depth);
}

(ext_present_statuses, depths)
}

#[test]
fn test_proof_from_json_golang_manual_conversion() {
// block number 0x62
Expand Down

0 comments on commit 042803e

Please sign in to comment.