Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Apr 4, 2024
1 parent 9f29dd7 commit 5eda6ad
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 42 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ The following crates support `no_std`:
- alloy-eips
- alloy-genesis
- alloy-serde
- alloy-consensus

If you would like to add `no_std` support to a crate, please make sure to update
`scripts/check_no_std.sh` as well.
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ default = ["std"]
std = ["alloy-eips/std", "c-kzg/std", "sha2/std"]
k256 = ["alloy-primitives/k256"]
kzg = ["std", "dep:c-kzg", "dep:thiserror", "alloy-eips/kzg"]
arbitrary = ["dep:arbitrary", "alloy-eips/arbitrary"]
arbitrary = ["std", "dep:arbitrary", "alloy-eips/arbitrary"]
serde = ["dep:serde", "alloy-primitives/serde", "dep:alloy-serde", "alloy-eips/serde"]
6 changes: 1 addition & 5 deletions crates/consensus/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ use alloy_primitives::{b256, keccak256, Address, BlockNumber, Bloom, Bytes, B256
use alloy_rlp::{
length_of_length, Buf, BufMut, Decodable, Encodable, EMPTY_LIST_CODE, EMPTY_STRING_CODE,
};
use core::mem;

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
#[cfg(not(feature = "std"))]
use core::mem;

#[cfg(feature = "std")]
use std::mem;

/// Ommer root of empty list.
pub const EMPTY_OMMER_ROOT_HASH: B256 =
Expand Down
1 change: 1 addition & 0 deletions crates/consensus/src/receipt/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ where
0 => Ok(Self::Legacy(receipt)),
1 => Ok(Self::Eip2930(receipt)),
2 => Ok(Self::Eip1559(receipt)),
3 => Ok(Self::Eip4844(receipt)),
_ => unreachable!(),
}
}
Expand Down
6 changes: 1 addition & 5 deletions crates/consensus/src/transaction/eip1559.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ use crate::{SignableTransaction, Signed, Transaction, TxType};
use alloy_eips::eip2930::AccessList;
use alloy_primitives::{keccak256, Bytes, ChainId, Signature, TxKind, U256};
use alloy_rlp::{BufMut, Decodable, Encodable, Header};
use core::mem;

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
#[cfg(not(feature = "std"))]
use core::mem;

#[cfg(feature = "std")]
use std::mem;

/// A transaction with a priority fee ([EIP-1559](https://eips.ethereum.org/EIPS/eip-1559)).
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
Expand Down
6 changes: 1 addition & 5 deletions crates/consensus/src/transaction/eip2930.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@ use crate::{SignableTransaction, Signed, Transaction, TxType};
use alloy_eips::eip2930::AccessList;
use alloy_primitives::{keccak256, Bytes, ChainId, Signature, TxKind, U256};
use alloy_rlp::{length_of_length, BufMut, Decodable, Encodable, Header};
use core::mem;

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
#[cfg(not(feature = "std"))]
use core::mem;

#[cfg(feature = "std")]
use std::mem;

/// Transaction with an [`AccessList`] ([EIP-2930](https://eips.ethereum.org/EIPS/eip-2930)).
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
Expand Down
6 changes: 1 addition & 5 deletions crates/consensus/src/transaction/eip4844.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ use alloy_primitives::{
keccak256, Address, Bytes, ChainId, FixedBytes, Signature, TxKind, B256, U256,
};
use alloy_rlp::{length_of_length, BufMut, Decodable, Encodable, Header};
use core::mem;
use sha2::{Digest, Sha256};

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
#[cfg(not(feature = "std"))]
use core::mem;

#[cfg(feature = "std")]
use std::mem;

#[cfg(not(feature = "kzg"))]
pub use alloy_eips::eip4844::{Blob, Bytes48};
Expand Down
9 changes: 2 additions & 7 deletions crates/consensus/src/transaction/eip4844/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@ use c_kzg::{Blob, KzgCommitment, KzgProof};

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
#[cfg(not(feature = "std"))]
use core::cmp;

#[cfg(feature = "std")]
use std::cmp;

use alloy_eips::eip4844::{BYTES_PER_BLOB, FIELD_ELEMENTS_PER_BLOB};

use super::utils::WholeFe;
use alloy_eips::eip4844::{BYTES_PER_BLOB, FIELD_ELEMENTS_PER_BLOB};
use core::cmp;

/// A builder for creating a [`BlobTransactionSidecar`].
///
Expand Down
4 changes: 0 additions & 4 deletions crates/consensus/src/transaction/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ use crate::{
};
use alloy_eips::eip2718::{Decodable2718, Eip2718Error, Encodable2718};
use alloy_rlp::{Decodable, Encodable, Header};

#[cfg(not(feature = "std"))]
use core::mem;
#[cfg(feature = "std")]
use std::mem;

/// Ethereum `TransactionType` flags as specified in EIPs [2718], [1559], and
/// [2930].
Expand Down
6 changes: 1 addition & 5 deletions crates/consensus/src/transaction/legacy.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
use crate::{SignableTransaction, Signed, Transaction};
use alloy_primitives::{keccak256, Bytes, ChainId, Signature, TxKind, U256};
use alloy_rlp::{length_of_length, BufMut, Decodable, Encodable, Header, Result};
use core::mem;

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
#[cfg(not(feature = "std"))]
use core::mem;

#[cfg(feature = "std")]
use std::mem;

/// Legacy transaction.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
Expand Down
6 changes: 1 addition & 5 deletions crates/consensus/src/transaction/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
use crate::Signed;
use alloy_primitives::{keccak256, ChainId, TxKind, B256, U256};
use core::any;

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
#[cfg(not(feature = "std"))]
use core::any;

#[cfg(feature = "std")]
use std::any;

mod eip1559;
pub use eip1559::TxEip1559;
Expand Down
1 change: 1 addition & 0 deletions scripts/check_no_std.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ no_std_packages=(
alloy-eips
alloy-genesis
alloy-serde
alloy-consensus
)

for package in "${no_std_packages[@]}"; do
Expand Down

0 comments on commit 5eda6ad

Please sign in to comment.