Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: feature gate by c-kzg
  • Loading branch information
0xWOLAND committed Jul 8, 2024
commit 824cd0d34e339d9873818634b0c6e38379557760
4 changes: 2 additions & 2 deletions crates/precompile/src/kzg_point_evaluation.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{Address, Error, Precompile, PrecompileResult, PrecompileWithAddress};
#[cfg(not(feature = "kzg-rs"))]
#[cfg(feature = "c-kzg")]
use c_kzg::{Bytes32, Bytes48, KzgProof, KzgSettings};
#[cfg(feature = "kzg-rs")]
#[cfg(not(feature = "c-kzg"))]
use kzg_rs::{Bytes32, Bytes48, KzgProof, KzgSettings};
use revm_primitives::{hex_literal::hex, Bytes, Env, PrecompileOutput};
use sha2::{Digest, Sha256};
Expand Down
6 changes: 3 additions & 3 deletions crates/primitives/src/kzg.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
mod env_settings;
mod trusted_setup_points;

#[cfg(feature = "kzg-rs")]
pub use kzg_rs::KzgSettings;
#[cfg(not(feature = "kzg-rs"))]
#[cfg(feature = "c-kzg")]
pub use c_kzg::KzgSettings;
#[cfg(not(feature = "c-kzg"))]
pub use kzg_rs::KzgSettings;

pub use env_settings::EnvKzgSettings;
pub use trusted_setup_points::{
Expand Down
8 changes: 5 additions & 3 deletions crates/primitives/src/kzg/env_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use std::{boxed::Box, sync::Arc};

/// KZG Settings that allow us to specify a custom trusted setup.
/// or use hardcoded default settings.
#[cfg(feature = "kzg-rs")]
#[cfg(not(feature = "c-kzg"))]
pub use kzg_rs::EnvKzgSettings;

#[cfg(not(feature = "kzg-rs"))]
#[cfg(feature = "c-kzg")]
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
pub enum EnvKzgSettings {
/// Default mainnet trusted setup
Expand All @@ -20,9 +20,11 @@ pub enum EnvKzgSettings {
Custom(Arc<c_kzg::KzgSettings>),
}

#[cfg(not(feature = "kzg-rs"))]
#[cfg(feature = "c-kzg")]
impl EnvKzgSettings {
/// Return set KZG settings.
///
/// In will initialize the default settings if it is not already loaded.
pub fn get(&self) -> &KzgSettings {
match self {
Self::Default => {
Expand Down