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

Bump edition #458

Open
wants to merge 6 commits into
base: emhane/bump-rust-version
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resolver = "2"

[workspace.package]
version = "0.10.5"
edition = "2021"
edition = "2024"
rust-version = "1.85"
authors = ["Alloy Contributors"]
license = "MIT OR Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/src/alloy_compat.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Additional compatibility implementations.

use crate::{OpTxEnvelope, TxDeposit, DEPOSIT_TX_TYPE_ID};
use crate::{DEPOSIT_TX_TYPE_ID, OpTxEnvelope, TxDeposit};
use alloc::string::ToString;
use alloy_consensus::Sealed;
use alloy_eips::Typed2718;
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/src/eip1559.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Support for EIP-1559 parameters after holocene.

use alloy_eips::eip1559::BaseFeeParams;
use alloy_primitives::{Bytes, B64};
use alloy_primitives::{B64, Bytes};

/// Extracts the Holocene 1599 parameters from the encoded form:
/// <https://github.com/ethereum-optimism/specs/blob/main/specs/protocol/holocene/exec-engine.md#eip1559params-encoding>
Expand Down
8 changes: 4 additions & 4 deletions crates/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ pub use receipt::{OpDepositReceipt, OpDepositReceiptWithBloom, OpReceiptEnvelope

mod transaction;
pub use transaction::{
DepositTransaction, OpPooledTransaction, OpTxEnvelope, OpTxType, OpTypedTransaction, TxDeposit,
DEPOSIT_TX_TYPE_ID,
DEPOSIT_TX_TYPE_ID, DepositTransaction, OpPooledTransaction, OpTxEnvelope, OpTxType,
OpTypedTransaction, TxDeposit,
};

pub mod eip1559;
pub use eip1559::{
decode_eip_1559_params, decode_holocene_extra_data, encode_holocene_extra_data,
EIP1559ParamError,
EIP1559ParamError, decode_eip_1559_params, decode_holocene_extra_data,
encode_holocene_extra_data,
};

mod source;
Expand Down
12 changes: 7 additions & 5 deletions crates/consensus/src/receipt/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use crate::{OpDepositReceipt, OpDepositReceiptWithBloom, OpTxType};
use alloc::vec::Vec;
use alloy_consensus::{Eip658Value, Receipt, ReceiptWithBloom, TxReceipt};
use alloy_eips::{
eip2718::{Decodable2718, Eip2718Error, Eip2718Result, Encodable2718},
Typed2718,
eip2718::{Decodable2718, Eip2718Error, Eip2718Result, Encodable2718},
};
use alloy_primitives::{logs_bloom, Bloom, Log};
use alloy_rlp::{length_of_length, BufMut, Decodable, Encodable};
use alloy_primitives::{Bloom, Log, logs_bloom};
use alloy_rlp::{BufMut, Decodable, Encodable, length_of_length};

/// Receipt envelope, as defined in [EIP-2718], modified for OP Stack chains.
///
Expand Down Expand Up @@ -320,7 +320,7 @@ mod tests {
use super::*;
use alloy_consensus::{Receipt, ReceiptWithBloom};
use alloy_eips::eip2718::Encodable2718;
use alloy_primitives::{address, b256, bytes, hex, Log, LogData};
use alloy_primitives::{Log, LogData, address, b256, bytes, hex};
use alloy_rlp::Encodable;

#[cfg(not(feature = "std"))]
Expand All @@ -329,7 +329,9 @@ mod tests {
// Test vector from: https://eips.ethereum.org/EIPS/eip-2481
#[test]
fn encode_legacy_receipt() {
let expected = hex!("f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff");
let expected = hex!(
"f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff"
);

let mut data = vec![];
let receipt = OpReceiptEnvelope::Legacy(ReceiptWithBloom {
Expand Down
67 changes: 38 additions & 29 deletions crates/consensus/src/receipt/receipts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ pub(crate) mod serde_bincode_compat {
///
/// Intended to use with the [`serde_with::serde_as`] macro in the following way:
/// ```rust
/// use op_alloy_consensus::{serde_bincode_compat, OpDepositReceipt};
/// use serde::{de::DeserializeOwned, Deserialize, Serialize};
/// use op_alloy_consensus::{OpDepositReceipt, serde_bincode_compat};
/// use serde::{Deserialize, Serialize, de::DeserializeOwned};
/// use serde_with::serde_as;
///
/// #[serde_as]
Expand Down Expand Up @@ -296,11 +296,11 @@ pub(crate) mod serde_bincode_compat {

#[cfg(test)]
mod tests {
use super::super::{serde_bincode_compat, OpDepositReceipt};
use super::super::{OpDepositReceipt, serde_bincode_compat};
use alloy_primitives::Log;
use arbitrary::Arbitrary;
use rand::Rng;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde::{Deserialize, Serialize, de::DeserializeOwned};
use serde_with::serde_as;

#[test]
Expand Down Expand Up @@ -332,7 +332,7 @@ pub(crate) mod serde_bincode_compat {
mod tests {
use super::*;
use alloy_consensus::Receipt;
use alloy_primitives::{address, b256, bytes, hex, Bytes, Log, LogData};
use alloy_primitives::{Bytes, Log, LogData, address, b256, bytes, hex};
use alloy_rlp::{Decodable, Encodable};

#[cfg(not(feature = "std"))]
Expand All @@ -341,31 +341,36 @@ mod tests {
// Test vector from: https://eips.ethereum.org/EIPS/eip-2481
#[test]
fn decode_legacy_receipt() {
let data = hex!("f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff");
let data = hex!(
"f901668001b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f85ff85d940000000000000000000000000000000000000011f842a0000000000000000000000000000000000000000000000000000000000000deada0000000000000000000000000000000000000000000000000000000000000beef830100ff"
);

// EIP658Receipt
let expected =
OpDepositReceiptWithBloom {
receipt: OpDepositReceipt {
inner: Receipt {
status: false.into(),
cumulative_gas_used: 0x1,
logs: vec![Log {
address: address!("0000000000000000000000000000000000000011"),
data: LogData::new_unchecked(
vec![
b256!("000000000000000000000000000000000000000000000000000000000000dead"),
b256!("000000000000000000000000000000000000000000000000000000000000beef"),
],
bytes!("0100ff"),
),
}],
},
deposit_nonce: None,
deposit_receipt_version: None,
let expected = OpDepositReceiptWithBloom {
receipt: OpDepositReceipt {
inner: Receipt {
status: false.into(),
cumulative_gas_used: 0x1,
logs: vec![Log {
address: address!("0000000000000000000000000000000000000011"),
data: LogData::new_unchecked(
vec![
b256!(
"000000000000000000000000000000000000000000000000000000000000dead"
),
b256!(
"000000000000000000000000000000000000000000000000000000000000beef"
),
],
bytes!("0100ff"),
),
}],
},
logs_bloom: [0; 256].into(),
};
deposit_nonce: None,
deposit_receipt_version: None,
},
logs_bloom: [0; 256].into(),
};

let receipt = OpDepositReceiptWithBloom::decode(&mut &data[..]).unwrap();
assert_eq!(receipt, expected);
Expand Down Expand Up @@ -415,7 +420,9 @@ mod tests {

#[test]
fn regolith_receipt_roundtrip() {
let data = hex!("f9010c0182b741b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0833d3bbf");
let data = hex!(
"f9010c0182b741b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0833d3bbf"
);

// Deposit Receipt (post-regolith)
let expected = OpDepositReceiptWithBloom {
Expand All @@ -441,7 +448,9 @@ mod tests {

#[test]
fn post_canyon_receipt_roundtrip() {
let data = hex!("f9010d0182b741b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0833d3bbf01");
let data = hex!(
"f9010d0182b741b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0833d3bbf01"
);

// Deposit Receipt (post-regolith)
let expected = OpDepositReceiptWithBloom {
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/src/source.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Classification of deposit transaction source

use alloc::string::String;
use alloy_primitives::{keccak256, B256};
use alloy_primitives::{B256, keccak256};

/// Source domain identifiers for deposit transactions.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Copy)]
Expand Down
14 changes: 8 additions & 6 deletions crates/consensus/src/transaction/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use alloy_eips::{
eip2930::AccessList,
};
use alloy_primitives::{
keccak256, Address, Bytes, ChainId, PrimitiveSignature as Signature, TxHash, TxKind, B256, U256,
Address, B256, Bytes, ChainId, PrimitiveSignature as Signature, TxHash, TxKind, U256, keccak256,
};
use alloy_rlp::{
Buf, BufMut, Decodable, Encodable, Error as DecodeError, Header, EMPTY_STRING_CODE,
Buf, BufMut, Decodable, EMPTY_STRING_CODE, Encodable, Error as DecodeError, Header,
};
use core::mem;

Expand Down Expand Up @@ -462,7 +462,9 @@ mod tests {

#[test]
fn test_rlp_roundtrip() {
let bytes = Bytes::from_static(&hex!("7ef9015aa044bae9d41b8380d781187b426c6fe43df5fb2fb57bd4466ef6a701e1f01e015694deaddeaddeaddeaddeaddeaddeaddeaddead000194420000000000000000000000000000000000001580808408f0d18001b90104015d8eb900000000000000000000000000000000000000000000000000000000008057650000000000000000000000000000000000000000000000000000000063d96d10000000000000000000000000000000000000000000000000000000000009f35273d89754a1e0387b89520d989d3be9c37c1f32495a88faf1ea05c61121ab0d1900000000000000000000000000000000000000000000000000000000000000010000000000000000000000002d679b567db6187c0c8323fa982cfb88b74dbcc7000000000000000000000000000000000000000000000000000000000000083400000000000000000000000000000000000000000000000000000000000f4240"));
let bytes = Bytes::from_static(&hex!(
"7ef9015aa044bae9d41b8380d781187b426c6fe43df5fb2fb57bd4466ef6a701e1f01e015694deaddeaddeaddeaddeaddeaddeaddeaddead000194420000000000000000000000000000000000001580808408f0d18001b90104015d8eb900000000000000000000000000000000000000000000000000000000008057650000000000000000000000000000000000000000000000000000000063d96d10000000000000000000000000000000000000000000000000000000000009f35273d89754a1e0387b89520d989d3be9c37c1f32495a88faf1ea05c61121ab0d1900000000000000000000000000000000000000000000000000000000000000010000000000000000000000002d679b567db6187c0c8323fa982cfb88b74dbcc7000000000000000000000000000000000000000000000000000000000000083400000000000000000000000000000000000000000000000000000000000f4240"
));
let tx_a = TxDeposit::decode(&mut bytes[1..].as_ref()).unwrap();
let mut buf_a = BytesMut::default();
tx_a.encode(&mut buf_a);
Expand Down Expand Up @@ -573,15 +575,15 @@ mod tests {
#[cfg(all(feature = "serde", feature = "serde-bincode-compat"))]
pub(super) mod serde_bincode_compat {
use alloc::borrow::Cow;
use alloy_primitives::{Address, Bytes, TxKind, B256, U256};
use alloy_primitives::{Address, B256, Bytes, TxKind, U256};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_with::{DeserializeAs, SerializeAs};

/// Bincode-compatible [`super::TxDeposit`] serde implementation.
///
/// Intended to use with the [`serde_with::serde_as`] macro in the following way:
/// ```rust
/// use op_alloy_consensus::{serde_bincode_compat, TxDeposit};
/// use op_alloy_consensus::{TxDeposit, serde_bincode_compat};
/// use serde::{Deserialize, Serialize};
/// use serde_with::serde_as;
///
Expand Down Expand Up @@ -661,7 +663,7 @@ pub(super) mod serde_bincode_compat {
use serde::{Deserialize, Serialize};
use serde_with::serde_as;

use super::super::{serde_bincode_compat, TxDeposit};
use super::super::{TxDeposit, serde_bincode_compat};

#[test]
fn test_tx_deposit_bincode_roundtrip() {
Expand Down
12 changes: 7 additions & 5 deletions crates/consensus/src/transaction/envelope.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use crate::{OpTxType, OpTypedTransaction, TxDeposit};
use alloy_consensus::{
transaction::RlpEcdsaTx, Sealable, Sealed, Signed, Transaction, TxEip1559, TxEip2930,
TxEip7702, TxEnvelope, TxLegacy, Typed2718,
Sealable, Sealed, Signed, Transaction, TxEip1559, TxEip2930, TxEip7702, TxEnvelope, TxLegacy,
Typed2718, transaction::RlpEcdsaTx,
};
use alloy_eips::{
eip2718::{Decodable2718, Eip2718Error, Eip2718Result, Encodable2718},
eip2930::AccessList,
eip7702::SignedAuthorization,
};
use alloy_primitives::{Address, Bytes, TxKind, B256, U256};
use alloy_primitives::{Address, B256, Bytes, TxKind, U256};
use alloy_rlp::{Decodable, Encodable};

/// The Ethereum [EIP-2718] Transaction Envelope, modified for OP Stack chains.
Expand Down Expand Up @@ -623,7 +623,7 @@ mod tests {
use super::*;
use alloc::vec;
use alloy_consensus::SignableTransaction;
use alloy_primitives::{hex, Address, Bytes, PrimitiveSignature, TxKind, B256, U256};
use alloy_primitives::{Address, B256, Bytes, PrimitiveSignature, TxKind, U256, hex};

#[test]
fn test_tx_gas_limit() {
Expand Down Expand Up @@ -698,7 +698,9 @@ mod tests {
#[test]
fn eip2718_deposit_decode() {
// <https://basescan.org/tx/0xc468b38a20375922828c8126912740105125143b9856936085474b2590bbca91>
let b = hex!("7ef8f8a0417d134467f4737fcdf2475f0ecdd2a0ed6d87ecffc888ba9f60ee7e3b8ac26a94deaddeaddeaddeaddeaddeaddeaddeaddead00019442000000000000000000000000000000000000158080830f424080b8a4440a5e20000008dd00101c1200000000000000040000000066c352bb000000000139c4f500000000000000000000000000000000000000000000000000000000c0cff1460000000000000000000000000000000000000000000000000000000000000001d4c88f4065ac9671e8b1329b90773e89b5ddff9cf8675b2b5e9c1b28320609930000000000000000000000005050f69a9786f081509234f1a7f4684b5e5b76c9");
let b = hex!(
"7ef8f8a0417d134467f4737fcdf2475f0ecdd2a0ed6d87ecffc888ba9f60ee7e3b8ac26a94deaddeaddeaddeaddeaddeaddeaddeaddead00019442000000000000000000000000000000000000158080830f424080b8a4440a5e20000008dd00101c1200000000000000040000000066c352bb000000000139c4f500000000000000000000000000000000000000000000000000000000c0cff1460000000000000000000000000000000000000000000000000000000000000001d4c88f4065ac9671e8b1329b90773e89b5ddff9cf8675b2b5e9c1b28320609930000000000000000000000005050f69a9786f081509234f1a7f4684b5e5b76c9"
);

let tx = OpTxEnvelope::decode_2718(&mut b[..].as_ref()).unwrap();
let deposit = tx.as_deposit().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod deposit;
pub use deposit::{DepositTransaction, TxDeposit};

mod tx_type;
pub use tx_type::{OpTxType, DEPOSIT_TX_TYPE_ID};
pub use tx_type::{DEPOSIT_TX_TYPE_ID, OpTxType};

mod envelope;
pub use envelope::OpTxEnvelope;
Expand Down
Loading
Loading