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

Updating to latest reth #33

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1,239 changes: 689 additions & 550 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 12 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@ reth-transaction-pool = { git = "https://github.com/paradigmxyz/reth" }
reth-tracing = { git = "https://github.com/paradigmxyz/reth" }

# alloy
alloy-eips = "0.4"
alloy-consensus = "0.4"
alloy-primitives = "0.8"
alloy-rlp = "0.3"
alloy-rpc-types = "0.4"
alloy-signer = "0.4"
alloy-signer-local = "0.4"
alloy-sol-types = { version = "0.8", features = ["json"] }
alloy-eips = { version = "0.5.4", default-features = false }
alloy-consensus = { version = "0.5.4", default-features = false }
alloy-primitives = { version = "0.8.9", default-features = false }
alloy-rlp = "0.3.4"
alloy-rpc-types = { version = "0.5.4", features = [
"eth",
], default-features = false }
alloy-signer = { version = "0.5.4", default-features = false }
alloy-signer-local = { version = "0.5.4", default-features = false }
alloy-sol-types = { version = "0.8", features = ["json"] }

discv5 = "0.8"

# async
futures = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion discv5/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ reth-tracing.workspace = true
reth.workspace = true

# networking
discv5 = "0.7"
discv5.workspace = true
enr = "0.12"

# async
Expand Down
1 change: 1 addition & 0 deletions op-bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ reth.workspace = true
# alloy
alloy-primitives.workspace = true
alloy-sol-types.workspace = true
alloy-eips.workspace = true

# misc
eyre.workspace = true
Expand Down
3 changes: 2 additions & 1 deletion op-bridge/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ mod tests {
use std::pin::pin;

use alloy_consensus::TxLegacy;
use alloy_eips::eip7685::Requests;
use alloy_primitives::{Address, TxKind, U256};
use alloy_sol_types::SolEvent;
use reth::revm::db::BundleState;
Expand Down Expand Up @@ -360,7 +361,7 @@ mod tests {
BundleState::default(),
vec![deposit_tx_receipt, withdrawal_tx_receipt].into(),
block.number,
vec![block.body.requests.clone().unwrap_or_default()],
vec![Requests::default()],
),
None,
);
Expand Down
2 changes: 1 addition & 1 deletion oracle/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ alloy-signer-local.workspace = true
alloy-signer.workspace = true

# networking
discv5 = "0.7"
discv5.workspace = true
enr = "0.12"

# async
Expand Down
79 changes: 48 additions & 31 deletions remote/src/codec.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::sync::Arc;

use alloy_primitives::{Address, BlockHash, Bloom, TxHash, B256, B64, U256};
use eyre::OptionExt;
use eyre::{eyre, OptionExt};
use std::sync::Arc;

use crate::proto;

Expand Down Expand Up @@ -241,32 +240,42 @@ impl TryFrom<&reth::primitives::TransactionSigned> for proto::Transaction {
access_list,
authorization_list,
input,
}) => proto::transaction::Transaction::Eip7702(proto::TransactionEip7702 {
chain_id: *chain_id,
nonce: *nonce,
gas_limit: gas_limit.to_le_bytes().to_vec(),
max_fee_per_gas: max_fee_per_gas.to_le_bytes().to_vec(),
max_priority_fee_per_gas: max_priority_fee_per_gas.to_le_bytes().to_vec(),
to: to.to_vec(),
value: value.to_le_bytes_vec(),
access_list: access_list.iter().map(Into::into).collect(),
authorization_list: authorization_list
}) => {
// Map over the authorization_list and collect into a Result<Vec<_>, _>
let authorization_list: Vec<proto::AuthorizationListItem> = authorization_list
.iter()
.map(|authorization| proto::AuthorizationListItem {
authorization: Some(proto::Authorization {
chain_id: authorization.chain_id().to_le_bytes_vec(),
address: authorization.address().to_vec(),
nonce: authorization.nonce(),
}),
signature: Some(proto::Signature {
r: authorization.signature().r().to_le_bytes_vec(),
s: authorization.signature().s().to_le_bytes_vec(),
y_parity: authorization.signature().v().y_parity(),
}),
.map(|authorization| -> Result<proto::AuthorizationListItem, eyre::Error> {
let signature =
authorization.signature().map_err(|_| eyre!("signature missing"))?;

Ok(proto::AuthorizationListItem {
authorization: Some(proto::Authorization {
chain_id: authorization.chain_id().to_le_bytes().to_vec(),
address: authorization.address().to_vec(),
nonce: authorization.nonce(),
}),
signature: Some(proto::Signature {
r: signature.r().to_le_bytes_vec(),
s: signature.s().to_le_bytes_vec(),
y_parity: signature.v().y_parity(),
}),
})
})
.collect(),
input: input.to_vec(),
}),
.collect::<Result<Vec<_>, _>>()?;

proto::transaction::Transaction::Eip7702(proto::TransactionEip7702 {
chain_id: *chain_id,
nonce: *nonce,
gas_limit: gas_limit.to_le_bytes().to_vec(),
max_fee_per_gas: max_fee_per_gas.to_le_bytes().to_vec(),
max_priority_fee_per_gas: max_priority_fee_per_gas.to_le_bytes().to_vec(),
to: to.to_vec(),
value: value.to_le_bytes_vec(),
access_list: access_list.iter().map(Into::into).collect(),
authorization_list,
input: input.to_vec(),
})
}
};

Ok(proto::Transaction { hash, signature: Some(signature), transaction: Some(transaction) })
Expand Down Expand Up @@ -593,7 +602,6 @@ impl TryFrom<&proto::Block> for reth::primitives::SealedBlockWithSenders {
transactions,
ommers,
withdrawals: Default::default(),
requests: Default::default(),
},
),
senders,
Expand Down Expand Up @@ -635,7 +643,7 @@ impl TryFrom<&proto::Header> for reth::primitives::Header {
.as_ref()
.map(|root| B256::try_from(root.as_slice()))
.transpose()?,
requests_root: None,
requests_hash: None,
extra_data: header.extra_data.as_slice().to_vec().into(),
})
}
Expand All @@ -652,6 +660,7 @@ impl TryFrom<&proto::Transaction> for reth::primitives::TransactionSigned {
U256::try_from_le_slice(signature.s.as_slice()).ok_or_eyre("failed to parse s")?,
signature.y_parity,
)?;

let transaction = match transaction.transaction.as_ref().ok_or_eyre("no transaction")? {
proto::transaction::Transaction::Legacy(proto::TransactionLegacy {
chain_id,
Expand Down Expand Up @@ -802,9 +811,17 @@ impl TryFrom<&proto::Transaction> for reth::primitives::TransactionSigned {

let authorization =
authorization.authorization.as_ref().ok_or_eyre("no authorization")?;

let chain_id: u64 = u64::from_le_bytes(
authorization
.chain_id
.as_slice()
.try_into()
.map_err(|_| eyre::eyre!("chain_id must be exactly 8 bytes"))?,
);

Ok(alloy_eips::eip7702::Authorization {
chain_id: U256::try_from_le_slice(authorization.chain_id.as_slice())
.ok_or_eyre("failed to parse chain id")?,
chain_id,
address: Address::try_from(authorization.address.as_slice())?,
nonce: authorization.nonce,
}
Expand Down
2 changes: 1 addition & 1 deletion rollup/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ reth.workspace = true
# alloy
alloy-consensus = { workspace = true, features = ["k256"] }
alloy-eips.workspace = true
alloy-genesis = "0.4"
alloy-genesis = "0.5.4"
alloy-primitives.workspace = true
alloy-rlp.workspace = true
alloy-sol-types.workspace = true
Expand Down
12 changes: 6 additions & 6 deletions rollup/src/execution.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use crate::{db::Database, Zenith, CHAIN_ID, CHAIN_SPEC};
use alloy_consensus::{Blob, SidecarCoder, SimpleCoder};
use alloy_eips::{eip2718::Decodable2718, eip4844::kzg_to_versioned_hash};
use alloy_consensus::{Blob, SidecarCoder, SimpleCoder, Transaction};
use alloy_eips::{
eip1559::INITIAL_BASE_FEE, eip2718::Decodable2718, eip4844::kzg_to_versioned_hash,
};
use alloy_primitives::{keccak256, Address, Bytes, B256, U256};
use alloy_rlp::Decodable as _;
use eyre::OptionExt;
Expand All @@ -9,7 +11,6 @@ use reth_execution_errors::BlockValidationError;
use reth_node_api::{ConfigureEvm, ConfigureEvmEnv};
use reth_node_ethereum::EthEvmConfig;
use reth_primitives::{
constants,
revm_primitives::{CfgEnvWithHandlerCfg, EVMError, ExecutionResult, ResultAndState},
Block, BlockBody, BlockWithSenders, EthereumHardfork, Header, Receipt, TransactionSigned,
TxType,
Expand Down Expand Up @@ -71,7 +72,7 @@ fn construct_header(db: &Database, header: &Zenith::BlockHeader) -> eyre::Result
// Calculate base fee per gas for EIP-1559 transactions
let base_fee_per_gas =
if CHAIN_SPEC.fork(EthereumHardfork::London).transitions_at_block(block_number) {
constants::EIP1559_INITIAL_BASE_FEE
INITIAL_BASE_FEE
} else {
parent_block
.as_ref()
Expand Down Expand Up @@ -263,12 +264,11 @@ fn execute_transactions(
mod tests {
use std::time::{SystemTime, UNIX_EPOCH};

use alloy_consensus::{SidecarBuilder, SimpleCoder, TxEip2930};
use alloy_consensus::{constants::ETH_TO_WEI, SidecarBuilder, SimpleCoder, TxEip2930};
use alloy_eips::eip2718::Encodable2718;
use alloy_primitives::{bytes, keccak256, BlockNumber, TxKind, U256};
use alloy_sol_types::{sol, SolCall};
use reth_primitives::{
constants::ETH_TO_WEI,
public_key_to_address,
revm_primitives::{AccountInfo, ExecutionResult, Output, TxEnv},
Receipt, SealedBlockWithSenders, Transaction,
Expand Down
Loading