mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Remove load_trusted_setup_from_bytes (#10719)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
committed by
GitHub
parent
80d511bf16
commit
2b6b715b95
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -8038,9 +8038,7 @@ dependencies = [
|
|||||||
"secp256k1",
|
"secp256k1",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tempfile",
|
|
||||||
"test-fuzz",
|
"test-fuzz",
|
||||||
"thiserror",
|
|
||||||
"zstd",
|
"zstd",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -22,9 +22,9 @@ use reth_node_api::{NodeTypesWithDB, NodeTypesWithEngine, PayloadBuilderAttribut
|
|||||||
use reth_node_ethereum::EthExecutorProvider;
|
use reth_node_ethereum::EthExecutorProvider;
|
||||||
use reth_payload_builder::database::CachedReads;
|
use reth_payload_builder::database::CachedReads;
|
||||||
use reth_primitives::{
|
use reth_primitives::{
|
||||||
constants::eip4844::LoadKzgSettingsError, revm_primitives::KzgSettings, Address,
|
revm_primitives::KzgSettings, Address, BlobTransaction, BlobTransactionSidecar, Bytes,
|
||||||
BlobTransaction, BlobTransactionSidecar, Bytes, PooledTransactionsElement, SealedBlock,
|
PooledTransactionsElement, SealedBlock, SealedBlockWithSenders, Transaction, TransactionSigned,
|
||||||
SealedBlockWithSenders, Transaction, TransactionSigned, TxEip4844, B256, U256,
|
TxEip4844, B256, U256,
|
||||||
};
|
};
|
||||||
use reth_provider::{
|
use reth_provider::{
|
||||||
providers::BlockchainProvider, BlockHashReader, BlockReader, BlockWriter, ChainSpecProvider,
|
providers::BlockchainProvider, BlockHashReader, BlockReader, BlockWriter, ChainSpecProvider,
|
||||||
@ -107,7 +107,9 @@ impl<C: ChainSpecParser<ChainSpec = ChainSpec>> Command<C> {
|
|||||||
fn kzg_settings(&self) -> eyre::Result<EnvKzgSettings> {
|
fn kzg_settings(&self) -> eyre::Result<EnvKzgSettings> {
|
||||||
if let Some(ref trusted_setup_file) = self.trusted_setup_file {
|
if let Some(ref trusted_setup_file) = self.trusted_setup_file {
|
||||||
let trusted_setup = KzgSettings::load_trusted_setup_file(trusted_setup_file)
|
let trusted_setup = KzgSettings::load_trusted_setup_file(trusted_setup_file)
|
||||||
.map_err(LoadKzgSettingsError::KzgError)?;
|
.wrap_err_with(|| {
|
||||||
|
format!("Failed to load trusted setup file: {:?}", trusted_setup_file)
|
||||||
|
})?;
|
||||||
Ok(EnvKzgSettings::Custom(Arc::new(trusted_setup)))
|
Ok(EnvKzgSettings::Custom(Arc::new(trusted_setup)))
|
||||||
} else {
|
} else {
|
||||||
Ok(EnvKzgSettings::Default)
|
Ok(EnvKzgSettings::Default)
|
||||||
|
|||||||
@ -33,7 +33,9 @@ alloy-eips = { workspace = true, features = ["serde"] }
|
|||||||
|
|
||||||
# optimism
|
# optimism
|
||||||
op-alloy-rpc-types = { workspace = true, optional = true }
|
op-alloy-rpc-types = { workspace = true, optional = true }
|
||||||
op-alloy-consensus = { workspace = true, features = ["arbitrary"], optional = true }
|
op-alloy-consensus = { workspace = true, features = [
|
||||||
|
"arbitrary",
|
||||||
|
], optional = true }
|
||||||
|
|
||||||
# crypto
|
# crypto
|
||||||
secp256k1 = { workspace = true, features = [
|
secp256k1 = { workspace = true, features = [
|
||||||
@ -52,8 +54,6 @@ modular-bitfield = { workspace = true, optional = true }
|
|||||||
rayon.workspace = true
|
rayon.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
once_cell.workspace = true
|
once_cell.workspace = true
|
||||||
tempfile = { workspace = true, optional = true }
|
|
||||||
thiserror = { workspace = true, optional = true }
|
|
||||||
zstd = { workspace = true, features = ["experimental"], optional = true }
|
zstd = { workspace = true, features = ["experimental"], optional = true }
|
||||||
|
|
||||||
# arbitrary utils
|
# arbitrary utils
|
||||||
@ -87,7 +87,7 @@ pprof = { workspace = true, features = [
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["c-kzg", "alloy-compat", "std", "reth-codec", "secp256k1"]
|
default = ["c-kzg", "alloy-compat", "std", "reth-codec", "secp256k1"]
|
||||||
std = ["thiserror", "reth-primitives-traits/std"]
|
std = ["reth-primitives-traits/std"]
|
||||||
reth-codec = ["dep:reth-codecs", "dep:zstd", "dep:modular-bitfield", "std"]
|
reth-codec = ["dep:reth-codecs", "dep:zstd", "dep:modular-bitfield", "std"]
|
||||||
asm-keccak = ["alloy-primitives/asm-keccak"]
|
asm-keccak = ["alloy-primitives/asm-keccak"]
|
||||||
arbitrary = [
|
arbitrary = [
|
||||||
@ -101,7 +101,12 @@ arbitrary = [
|
|||||||
"reth-codec",
|
"reth-codec",
|
||||||
]
|
]
|
||||||
secp256k1 = ["dep:secp256k1"]
|
secp256k1 = ["dep:secp256k1"]
|
||||||
c-kzg = ["dep:c-kzg", "revm-primitives/c-kzg", "dep:tempfile", "alloy-eips/kzg", "alloy-consensus/kzg"]
|
c-kzg = [
|
||||||
|
"dep:c-kzg",
|
||||||
|
"revm-primitives/c-kzg",
|
||||||
|
"alloy-eips/kzg",
|
||||||
|
"alloy-consensus/kzg",
|
||||||
|
]
|
||||||
optimism = [
|
optimism = [
|
||||||
"reth-chainspec/optimism",
|
"reth-chainspec/optimism",
|
||||||
"reth-ethereum-forks/optimism",
|
"reth-ethereum-forks/optimism",
|
||||||
@ -110,7 +115,12 @@ optimism = [
|
|||||||
"dep:reth-optimism-chainspec",
|
"dep:reth-optimism-chainspec",
|
||||||
"dep:op-alloy-consensus",
|
"dep:op-alloy-consensus",
|
||||||
]
|
]
|
||||||
alloy-compat = ["reth-primitives-traits/alloy-compat", "dep:alloy-rpc-types", "dep:alloy-serde", "dep:op-alloy-rpc-types"]
|
alloy-compat = [
|
||||||
|
"reth-primitives-traits/alloy-compat",
|
||||||
|
"dep:alloy-rpc-types",
|
||||||
|
"dep:alloy-serde",
|
||||||
|
"dep:op-alloy-rpc-types",
|
||||||
|
]
|
||||||
test-utils = ["reth-primitives-traits/test-utils"]
|
test-utils = ["reth-primitives-traits/test-utils"]
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
|
|||||||
@ -1,45 +1,7 @@
|
|||||||
//! [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844#parameters) protocol constants and utils for shard Blob Transactions.
|
//! [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844#parameters) protocol constants and utils for shard Blob Transactions.
|
||||||
#[cfg(all(feature = "c-kzg", feature = "std"))]
|
|
||||||
pub use trusted_setup::*;
|
|
||||||
|
|
||||||
pub use alloy_eips::eip4844::{
|
pub use alloy_eips::eip4844::{
|
||||||
BLOB_GASPRICE_UPDATE_FRACTION, BLOB_TX_MIN_BLOB_GASPRICE, DATA_GAS_PER_BLOB,
|
BLOB_GASPRICE_UPDATE_FRACTION, BLOB_TX_MIN_BLOB_GASPRICE, DATA_GAS_PER_BLOB,
|
||||||
FIELD_ELEMENTS_PER_BLOB, FIELD_ELEMENT_BYTES, MAX_BLOBS_PER_BLOCK, MAX_DATA_GAS_PER_BLOCK,
|
FIELD_ELEMENTS_PER_BLOB, FIELD_ELEMENT_BYTES, MAX_BLOBS_PER_BLOCK, MAX_DATA_GAS_PER_BLOCK,
|
||||||
TARGET_BLOBS_PER_BLOCK, TARGET_DATA_GAS_PER_BLOCK, VERSIONED_HASH_VERSION_KZG,
|
TARGET_BLOBS_PER_BLOCK, TARGET_DATA_GAS_PER_BLOCK, VERSIONED_HASH_VERSION_KZG,
|
||||||
};
|
};
|
||||||
|
|
||||||
// These 2 to silence unused
|
|
||||||
#[cfg(all(feature = "c-kzg", not(feature = "std")))]
|
|
||||||
use tempfile as _;
|
|
||||||
#[cfg(all(not(feature = "c-kzg"), feature = "std"))]
|
|
||||||
use thiserror as _;
|
|
||||||
|
|
||||||
#[cfg(all(feature = "c-kzg", feature = "std"))]
|
|
||||||
mod trusted_setup {
|
|
||||||
use crate::kzg::KzgSettings;
|
|
||||||
use std::io::Write;
|
|
||||||
|
|
||||||
/// Loads the trusted setup parameters from the given bytes and returns the [`KzgSettings`].
|
|
||||||
///
|
|
||||||
/// This creates a temp file to store the bytes and then loads the [`KzgSettings`] from the file
|
|
||||||
/// via [`KzgSettings::load_trusted_setup_file`].
|
|
||||||
pub fn load_trusted_setup_from_bytes(
|
|
||||||
bytes: &[u8],
|
|
||||||
) -> Result<KzgSettings, LoadKzgSettingsError> {
|
|
||||||
let mut file = tempfile::NamedTempFile::new().map_err(LoadKzgSettingsError::TempFileErr)?;
|
|
||||||
file.write_all(bytes).map_err(LoadKzgSettingsError::TempFileErr)?;
|
|
||||||
KzgSettings::load_trusted_setup_file(file.path()).map_err(LoadKzgSettingsError::KzgError)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Error type for loading the trusted setup.
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
|
||||||
pub enum LoadKzgSettingsError {
|
|
||||||
/// Failed to create temp file to store bytes for loading [`KzgSettings`] via
|
|
||||||
/// [`KzgSettings::load_trusted_setup_file`].
|
|
||||||
#[error("failed to setup temp file: {0}")]
|
|
||||||
TempFileErr(#[from] std::io::Error),
|
|
||||||
/// Kzg error
|
|
||||||
#[error("KZG error: {0:?}")]
|
|
||||||
KzgError(#[from] c_kzg::Error),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user