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

feat: eip-7702 #9214

Merged
merged 36 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
2009282
feat: add EIP-7702 support
lattejed Jun 4, 2024
d6a5f2a
wip adjustments for new alloy/revm
onbjerg Jul 1, 2024
f69a6ff
chore: disable rpc conversion for now
onbjerg Jul 1, 2024
efdbf65
patch revm
onbjerg Jul 1, 2024
2f7fd78
feat: compact for `SignedAuthorization`
onbjerg Jul 1, 2024
038bfd4
chore: revm changes
onbjerg Jul 1, 2024
0de610a
chore: manual arbitrary/hash impls
onbjerg Jul 5, 2024
9a1865b
revm adjustments part 2
onbjerg Jul 5, 2024
a32761e
typo
onbjerg Jul 5, 2024
c7d1d87
more fixups
onbjerg Jul 5, 2024
af10866
clippy
onbjerg Jul 5, 2024
7940fec
chore: more clippy
onbjerg Jul 5, 2024
b381c48
some touhups
mattsse Jul 8, 2024
b400a4e
Merge remote-tracking branch 'origin/main' into onbjerg/eip-7702
joshieDo Jul 9, 2024
a8b7780
clippy & rpc todo
joshieDo Jul 9, 2024
6ca5fee
fix cargo docs
joshieDo Jul 9, 2024
a3951bf
fix compact impl + proptest
joshieDo Jul 9, 2024
d946989
fix sig proptest generation
joshieDo Jul 9, 2024
010f8b6
clippy
joshieDo Jul 9, 2024
df5495c
fmt
joshieDo Jul 9, 2024
5a494fb
write to the same buf
joshieDo Jul 10, 2024
46bb2e0
add a default signature in case arbitrary one generated a failed one
joshieDo Jul 10, 2024
5764c95
clippy
joshieDo Jul 10, 2024
2189326
smol review
joshieDo Jul 10, 2024
8b5a991
rm todo
joshieDo Jul 10, 2024
d3cfe0b
clippy
joshieDo Jul 10, 2024
78482c4
Merge remote-tracking branch 'origin/main' into onbjerg/eip-7702
joshieDo Jul 10, 2024
21c0adf
fix test_u64_to_tx_type
joshieDo Jul 10, 2024
67b3ffd
remove dup proptest
joshieDo Jul 10, 2024
a451bdf
clippy
joshieDo Jul 10, 2024
e864fa1
Update crates/primitives/src/transaction/eip7702.rs
joshieDo Jul 10, 2024
258cc95
Update crates/primitives/src/transaction/eip7702.rs
joshieDo Jul 10, 2024
0044c4c
rm todo
joshieDo Jul 10, 2024
ef0ec71
add gas checks
joshieDo Jul 10, 2024
c940291
rm TODO
joshieDo Jul 10, 2024
68f7dbf
fmt
joshieDo Jul 10, 2024
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 @@ -386,7 +386,7 @@ revm-primitives = { version = "6.0.0", features = [
revm-inspectors = "0.4"

# eth
alloy-chains = "0.1.15"
alloy-chains = "0.1.18"
alloy-primitives = "0.7.2"
alloy-dyn-abi = "0.7.2"
alloy-sol-types = "0.7.2"
Expand Down
7 changes: 7 additions & 0 deletions crates/chainspec/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,13 @@ impl ChainSpecBuilder {
self
}

/// Enable Prague at genesis.
pub fn prague_activated(mut self) -> Self {
self = self.cancun_activated();
self.hardforks.insert(EthereumHardfork::Prague, ForkCondition::Timestamp(0));
self
}

/// Enable Bedrock at genesis
#[cfg(feature = "optimism")]
pub fn bedrock_activated(mut self) -> Self {
Expand Down
8 changes: 8 additions & 0 deletions crates/net/network/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,9 @@ pub struct AnnouncedTxTypesMetrics {

/// Histogram for tracking frequency of EIP-4844 transaction type
pub(crate) eip4844: Histogram,

/// Histogram for tracking frequency of EIP-7702 transaction type
pub(crate) eip7702: Histogram,
}

#[derive(Debug, Default)]
Expand All @@ -350,6 +353,7 @@ pub struct TxTypesCounter {
pub(crate) eip2930: usize,
pub(crate) eip1559: usize,
pub(crate) eip4844: usize,
pub(crate) eip7702: usize,
}

impl TxTypesCounter {
Expand All @@ -368,6 +372,9 @@ impl TxTypesCounter {
TxType::Eip4844 => {
self.eip4844 += 1;
}
TxType::Eip7702 => {
self.eip7702 += 1;
}
_ => {}
}
}
Expand All @@ -381,5 +388,6 @@ impl AnnouncedTxTypesMetrics {
self.eip2930.record(tx_types_counter.eip2930 as f64);
self.eip1559.record(tx_types_counter.eip1559 as f64);
self.eip4844.record(tx_types_counter.eip4844 as f64);
self.eip7702.record(tx_types_counter.eip7702 as f64);
}
}
1 change: 1 addition & 0 deletions crates/net/network/src/transactions/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ impl FilterAnnouncement for EthMessageFilter {
}
}

// TODO(eip7702): update tests as needed
#[cfg(test)]
mod test {
use super::*;
Expand Down
28 changes: 28 additions & 0 deletions crates/primitives/src/alloy_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,34 @@ impl TryFrom<alloy_rpc_types::Transaction> for Transaction {
.ok_or(ConversionError::MissingMaxFeePerBlobGas)?,
}))
}
Some(TxType::Eip7702) => {
// this is currently unsupported as it is not present in alloy due to missing rpc
// specs
Err(ConversionError::Custom("Unimplemented".to_string()))
/*
// EIP-7702
Ok(Transaction::Eip7702(TxEip7702 {
chain_id: tx.chain_id.ok_or(ConversionError::MissingChainId)?,
nonce: tx.nonce,
max_priority_fee_per_gas: tx
.max_priority_fee_per_gas
.ok_or(ConversionError::MissingMaxPriorityFeePerGas)?,
max_fee_per_gas: tx
.max_fee_per_gas
.ok_or(ConversionError::MissingMaxFeePerGas)?,
gas_limit: tx
.gas
.try_into()
.map_err(|_| ConversionError::Eip2718Error(RlpError::Overflow.into()))?,
to: tx.to.map_or(TxKind::Create, TxKind::Call),
value: tx.value,
access_list: tx.access_list.ok_or(ConversionError::MissingAccessList)?,
authorization_list: tx
.authorization_list
.ok_or(ConversionError::MissingAuthorizationList)?,
input: tx.input,
}))*/
}
#[cfg(feature = "optimism")]
Some(TxType::Deposit) => {
let fields = tx
Expand Down
4 changes: 2 additions & 2 deletions crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ pub use transaction::{
AccessList, AccessListItem, IntoRecoveredTransaction, InvalidTransactionError, Signature,
Transaction, TransactionMeta, TransactionSigned, TransactionSignedEcRecovered,
TransactionSignedNoHash, TryFromRecoveredTransaction, TxEip1559, TxEip2930, TxEip4844,
TxHashOrNumber, TxLegacy, TxType, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID,
LEGACY_TX_TYPE_ID,
TxEip7702, TxHashOrNumber, TxLegacy, TxType, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID,
EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID, LEGACY_TX_TYPE_ID,
};

// Re-exports
Expand Down
7 changes: 7 additions & 0 deletions crates/primitives/src/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ impl Decodable for ReceiptWithBloom {
buf.advance(1);
Self::decode_receipt(buf, TxType::Eip4844)
}
0x04 => {
buf.advance(1);
Self::decode_receipt(buf, TxType::Eip7702)
}
#[cfg(feature = "optimism")]
0x7E => {
buf.advance(1);
Expand Down Expand Up @@ -471,6 +475,9 @@ impl<'a> ReceiptWithBloomEncoder<'a> {
TxType::Eip4844 => {
out.put_u8(0x03);
}
TxType::Eip7702 => {
out.put_u8(0x04);
}
#[cfg(feature = "optimism")]
TxType::Deposit => {
out.put_u8(0x7E);
Expand Down
17 changes: 16 additions & 1 deletion crates/primitives/src/transaction/compat.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{Address, Transaction, TransactionSigned, TxKind, U256};
use revm_primitives::TxEnv;
use revm_primitives::{AuthorizationList, TxEnv};

/// Implements behaviour to fill a [`TxEnv`] from another transaction.
pub trait FillTxEnv {
Expand Down Expand Up @@ -70,6 +70,21 @@ impl FillTxEnv for TransactionSigned {
tx_env.blob_hashes.clone_from(&tx.blob_versioned_hashes);
tx_env.max_fee_per_blob_gas = Some(U256::from(tx.max_fee_per_blob_gas));
}
Transaction::Eip7702(tx) => {
tx_env.gas_limit = tx.gas_limit;
tx_env.gas_price = U256::from(tx.max_fee_per_gas);
tx_env.gas_priority_fee = Some(U256::from(tx.max_priority_fee_per_gas));
tx_env.transact_to = tx.to;
tx_env.value = tx.value;
tx_env.data = tx.input.clone();
tx_env.chain_id = Some(tx.chain_id);
tx_env.nonce = Some(tx.nonce);
tx_env.access_list = tx.access_list.0.clone();
tx_env.blob_hashes.clear();
tx_env.max_fee_per_blob_gas.take();
tx_env.authorization_list =
Some(AuthorizationList::Signed(tx.authorization_list.clone()));
}
#[cfg(feature = "optimism")]
Transaction::Deposit(tx) => {
tx_env.access_list.clear();
Expand Down
Loading
Loading