Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking features on important crates #8

Closed
16 changes: 16 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,19 @@ jobs:
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}

features:
name: features
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@clippy
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- name: cargo install cargo-hack
uses: taiki-e/install-action@cargo-hack
- run: make check-features
env:
RUSTFLAGS: -D warnings
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: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ revm-primitives = { version = "7.1.0", features = [
# eth
alloy-chains = "0.1.18"
alloy-dyn-abi = "0.7.2"
alloy-primitives = "0.7.2"
alloy-primitives = { version = "0.7.2", default-features = false }
alloy-rlp = "0.3.4"
alloy-sol-types = "0.7.2"
alloy-trie = { version = "0.4", default-features = false }
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -467,3 +467,11 @@ pr:
make lint && \
make update-book-cli && \
make test

check-features:
cargo hack check \
--package reth-primitives-traits \
--package reth-primitives \
--package reth-rpc-types \
--package reth-codecs \
--feature-powerset
9 changes: 5 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,10 +81,11 @@ 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 = ["reth-primitives-traits/std"]
reth-codec = ["dep:reth-codecs", "dep:zstd", "dep:modular-bitfield", "std"]
asm-keccak = ["alloy-primitives/asm-keccak"]
arbitrary = [
"std",
"reth-primitives-traits/arbitrary",
"revm-primitives/arbitrary",
"reth-chainspec?/arbitrary",
Expand All @@ -95,7 +96,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", "dep:thiserror", "std"]
optimism = [
"reth-chainspec/optimism",
"reth-ethereum-forks/optimism",
Expand Down
5 changes: 4 additions & 1 deletion crates/primitives/src/alloy_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use alloy_rlp::Error as RlpError;
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

#[cfg(not(feature = "std"))]
use crate::alloc::string::ToString;

impl TryFrom<alloy_rpc_types::Block> for Block {
type Error = alloy_rpc_types::ConversionError;

Expand Down Expand Up @@ -43,7 +46,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
6 changes: 2 additions & 4 deletions crates/primitives/src/compression/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use std::{cell::RefCell, thread_local};
use zstd::bulk::{Compressor, Decompressor};

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use zstd::bulk::{Compressor, Decompressor};

/// Compression/Decompression dictionary for `Receipt`.
pub static RECEIPT_DICTIONARY: &[u8] = include_bytes!("./receipt_dictionary.bin");
Expand Down Expand Up @@ -74,7 +72,7 @@ impl ReusableDecompressor {
reserved_upper_bound = true;
if let Some(upper_bound) = Decompressor::upper_bound(src) {
if let Some(additional) = upper_bound.checked_sub(self.buf.capacity()) {
break 'b additional
break 'b additional;
}
}
}
Expand Down
4 changes: 2 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 @@ -26,7 +26,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
2 changes: 1 addition & 1 deletion crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern crate alloc;
mod alloy_compat;
pub mod basefee;
mod block;
#[cfg(feature = "reth-codec")]
#[cfg(all(feature = "reth-codec", feature = "std"))]
mod compression;
pub mod constants;
pub mod eip4844;
Expand Down
21 changes: 15 additions & 6 deletions crates/primitives/src/receipt.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
#[cfg(feature = "reth-codec")]
#[cfg(all(feature = "reth-codec", feature = "std"))]
use crate::compression::{RECEIPT_COMPRESSOR, RECEIPT_DECOMPRESSOR};
use crate::{logs_bloom, Bloom, Bytes, TxType, B256};
use alloy_primitives::Log;
use alloy_rlp::{length_of_length, Decodable, Encodable, RlpDecodable, RlpEncodable};
use bytes::{Buf, BufMut};
use core::{cmp::Ordering, ops::Deref};
use derive_more::{Deref, DerefMut, From, IntoIterator};
#[cfg(feature = "reth-codec")]
#[cfg(all(feature = "reth-codec", not(feature = "std")))]
use reth_codecs::Compact;
#[cfg(all(feature = "reth-codec", feature = "std"))]
use reth_codecs::{Compact, CompactZstd};
use serde::{Deserialize, Serialize};

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

/// Receipt containing result of transaction execution.
#[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::reth_codec(no_arbitrary, zstd))]
#[cfg_attr(
any(test, all(feature = "reth-codec", feature = "std")),
reth_codecs::reth_codec(no_arbitrary, zstd)
)]
#[cfg_attr(
all(not(test), feature = "reth-codec", not(feature = "std")),
reth_codecs::reth_codec(no_arbitrary)
)]
#[cfg_attr(any(test, feature = "reth-codec"), reth_codecs::add_arbitrary_tests)]
#[derive(
Clone, Debug, PartialEq, Eq, Default, RlpEncodable, RlpDecodable, Serialize, Deserialize,
Expand Down Expand Up @@ -249,7 +258,7 @@ impl ReceiptWithBloom {
let b = &mut &**buf;
let rlp_head = alloy_rlp::Header::decode(b)?;
if !rlp_head.list {
return Err(alloy_rlp::Error::UnexpectedString)
return Err(alloy_rlp::Error::UnexpectedString);
}
let started_len = b.len();

Expand Down Expand Up @@ -294,7 +303,7 @@ impl ReceiptWithBloom {
return Err(alloy_rlp::Error::ListLengthMismatch {
expected: rlp_head.payload_length,
got: consumed,
})
});
}
*buf = *b;
Ok(this)
Expand Down Expand Up @@ -451,7 +460,7 @@ impl<'a> ReceiptWithBloomEncoder<'a> {
fn encode_inner(&self, out: &mut dyn BufMut, with_header: bool) {
if matches!(self.receipt.tx_type, TxType::Legacy) {
self.encode_fields(out);
return
return;
}

let mut payload = Vec::new();
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
Loading
Loading