Skip to content

Commit

Permalink
Check features powerset for reth-primitives (#10138)
Browse files Browse the repository at this point in the history
  • Loading branch information
citizen-stig authored Aug 6, 2024
1 parent 35532e7 commit e24e4c7
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -471,4 +471,6 @@ pr:
check-features:
cargo hack check \
--package reth-codecs \
--package reth-primitives-traits \
--package reth-primitives \
--feature-powerset
8 changes: 4 additions & 4 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ once_cell.workspace = true
rayon.workspace = true
serde.workspace = true
tempfile = { workspace = true, optional = true }
thiserror-no-std = { workspace = true, default-features = false, optional = true }
thiserror = { workspace = true, optional = true }
zstd = { workspace = true, features = ["experimental"], optional = true }

# arbitrary utils
Expand Down Expand Up @@ -81,8 +81,8 @@ pprof = { workspace = true, features = [

[features]
default = ["c-kzg", "alloy-compat", "std", "reth-codec", "secp256k1"]
std = ["thiserror-no-std?/std", "reth-primitives-traits/std"]
reth-codec = ["dep:reth-codecs", "dep:zstd", "dep:modular-bitfield"]
std = ["thiserror", "reth-primitives-traits/std"]
reth-codec = ["dep:reth-codecs", "dep:zstd", "dep:modular-bitfield", "std"]
asm-keccak = ["alloy-primitives/asm-keccak"]
arbitrary = [
"reth-primitives-traits/arbitrary",
Expand All @@ -95,7 +95,7 @@ arbitrary = [
"reth-codec",
]
secp256k1 = ["dep:secp256k1"]
c-kzg = ["dep:c-kzg", "revm-primitives/c-kzg", "dep:tempfile", "alloy-eips/kzg", "dep:thiserror-no-std"]
c-kzg = ["dep:c-kzg", "revm-primitives/c-kzg", "dep:tempfile", "alloy-eips/kzg"]
optimism = [
"reth-chainspec/optimism",
"reth-ethereum-forks/optimism",
Expand Down
4 changes: 2 additions & 2 deletions crates/primitives/src/alloy_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use alloy_primitives::TxKind;
use alloy_rlp::Error as RlpError;

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use alloc::{string::ToString, vec::Vec};

impl TryFrom<alloy_rpc_types::Block> for Block {
type Error = alloy_rpc_types::ConversionError;
Expand Down Expand Up @@ -43,7 +43,7 @@ impl TryFrom<alloy_rpc_types::Block> for Block {
// alloy deserializes empty blocks into `BlockTransactions::Hashes`, if the tx
// root is the empty root then we can just return an empty vec.
if block.header.transactions_root == EMPTY_TRANSACTIONS {
Ok(vec![])
Ok(Vec::new())
} else {
Err(ConversionError::MissingFullTransactions)
}
Expand Down
10 changes: 8 additions & 2 deletions crates/primitives/src/constants/eip4844.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844#parameters) protocol constants and utils for shard Blob Transactions.
#[cfg(feature = "c-kzg")]
#[cfg(all(feature = "c-kzg", feature = "std"))]
pub use trusted_setup::*;

pub use alloy_eips::eip4844::{
Expand All @@ -8,6 +8,12 @@ pub use alloy_eips::eip4844::{
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;
Expand All @@ -26,7 +32,7 @@ mod trusted_setup {
}

/// Error type for loading the trusted setup.
#[derive(Debug, thiserror_no_std::Error)]
#[derive(Debug, thiserror::Error)]
pub enum LoadKzgSettingsError {
/// Failed to create temp file to store bytes for loading [`KzgSettings`] via
/// [`KzgSettings::load_trusted_setup_file`].
Expand Down
3 changes: 3 additions & 0 deletions crates/primitives/src/transaction/compat.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use crate::{Address, Transaction, TransactionSigned, TxKind, U256};
use revm_primitives::{AuthorizationList, TxEnv};

#[cfg(all(not(feature = "std"), feature = "optimism"))]
use alloc::vec::Vec;

/// Implements behaviour to fill a [`TxEnv`] from another transaction.
pub trait FillTxEnv {
/// Fills [`TxEnv`] with an [`Address`] and transaction.
Expand Down
3 changes: 2 additions & 1 deletion crates/primitives/src/transaction/optimism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ use alloy_rlp::{
length_of_length, Decodable, Encodable, Error as DecodeError, Header, EMPTY_STRING_CODE,
};
use bytes::Buf;
use core::mem;
#[cfg(any(test, feature = "reth-codec"))]
use reth_codecs::{reth_codec, Compact};
use serde::{Deserialize, Serialize};
use std::mem;

/// Deposit transactions, also known as deposits are initiated on L1, and executed on L2.
#[cfg_attr(any(test, feature = "reth-codec"), reth_codec)]
Expand Down

0 comments on commit e24e4c7

Please sign in to comment.