Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare committed Aug 2, 2024
1 parent 1b3c6cd commit 6a83f83
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 30 deletions.
24 changes: 24 additions & 0 deletions evm_arithmetization/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ impl From<PublicValues> for FinalPublicValues {
}
}

impl<'a> From<&'a PublicValues> for FinalPublicValues {
fn from(value: &'a PublicValues) -> Self {
value.clone().into()
}
}

/// Trie hashes.
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct TrieRoots {
Expand Down Expand Up @@ -810,6 +816,24 @@ pub struct FinalPublicValuesTarget {
pub extra_block_data: ExtraBlockDataTarget,
}

impl From<PublicValuesTarget> for FinalPublicValuesTarget {
fn from(value: PublicValuesTarget) -> Self {
Self {
trie_roots_before: value.trie_roots_before,
trie_roots_after: value.trie_roots_after,
block_metadata: value.block_metadata,
block_hashes: value.block_hashes,
extra_block_data: value.extra_block_data,
}
}
}

impl<'a> From<&'a PublicValuesTarget> for FinalPublicValuesTarget {
fn from(value: &'a PublicValuesTarget) -> Self {
value.into()
}
}

impl FinalPublicValuesTarget {
const SIZE: usize = TrieRootsTarget::SIZE * 2
+ BlockMetadataTarget::SIZE
Expand Down
39 changes: 9 additions & 30 deletions evm_arithmetization/src/recursive_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,11 +601,14 @@ pub(crate) fn add_virtual_public_values<F: RichField + Extendable<D>, const D: u
builder: &mut CircuitBuilder<F, D>,
len_mem_cap: usize,
) -> PublicValuesTarget {
let trie_roots_before = add_virtual_trie_roots(builder);
let trie_roots_after = add_virtual_trie_roots(builder);
let block_metadata = add_virtual_block_metadata(builder);
let block_hashes = add_virtual_block_hashes(builder);
let extra_block_data = add_virtual_extra_block_data(builder);
let FinalPublicValuesTarget {
trie_roots_before,
trie_roots_after,
block_metadata,
block_hashes,
extra_block_data,
} = add_virtual_final_public_values(builder);

let registers_before = add_virtual_registers_data(builder);
let registers_after = add_virtual_registers_data(builder);

Expand Down Expand Up @@ -742,31 +745,7 @@ where
F: RichField + Extendable<D>,
W: Witness<F>,
{
set_trie_roots_target(
witness,
&public_values_target.trie_roots_before,
&public_values.trie_roots_before,
);
set_trie_roots_target(
witness,
&public_values_target.trie_roots_after,
&public_values.trie_roots_after,
);
set_block_metadata_target(
witness,
&public_values_target.block_metadata,
&public_values.block_metadata,
)?;
set_block_hashes_target(
witness,
&public_values_target.block_hashes,
&public_values.block_hashes,
);
set_extra_public_values_target(
witness,
&public_values_target.extra_block_data,
&public_values.extra_block_data,
)?;
set_final_public_value_targets(witness, &public_values_target.into(), &public_values.into())?;
set_registers_target(
witness,
&public_values_target.registers_before,
Expand Down

0 comments on commit 6a83f83

Please sign in to comment.