Skip to content

Commit

Permalink
fix(primitives): use decode_2718() to gracefully handle the tx type
Browse files Browse the repository at this point in the history
  • Loading branch information
merklefruit authored and clabby committed May 27, 2024
1 parent 935fe76 commit 4646398
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ alloy-primitives = { workspace = true, features = ["rlp"] }

# Alloy Types
alloy-sol-types = { version = "0.7.1", default-features = false }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "cb95183", default-features = false }
op-alloy-consensus = { git = "https://github.com/clabby/op-alloy", branch = "refcell/consensus-port", default-features = false }

# `serde` feature dependencies
Expand Down
8 changes: 5 additions & 3 deletions crates/primitives/src/payload.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Contains the execution payload type.

use alloc::vec::Vec;
use alloy_eips::eip2718::Decodable2718;
use alloy_primitives::{Address, Bloom, Bytes, B256, U256};
use anyhow::Result;
use op_alloy_consensus::{OpTxEnvelope, OpTxType};
Expand All @@ -17,7 +18,7 @@ use super::{
Block, BlockInfo, L1BlockInfoBedrock, L1BlockInfoEcotone, L1BlockInfoTx, L2BlockInfo, OpBlock,
RollupConfig, SystemConfig, Withdrawal,
};
use alloy_rlp::{Decodable, Encodable};
use alloy_rlp::Encodable;

#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -139,7 +140,8 @@ impl L2ExecutionPayloadEnvelope {
if ty != OpTxType::Deposit as u8 {
anyhow::bail!("First payload transaction has unexpected type: {:?}", ty);
}
let tx = OpTxEnvelope::decode(&mut execution_payload.transactions[0][1..].as_ref())

let tx = OpTxEnvelope::decode_2718(&mut execution_payload.transactions[0].as_ref())
.map_err(|e| anyhow::anyhow!(e))?;

let OpTxEnvelope::Deposit(tx) = tx else {
Expand Down Expand Up @@ -183,7 +185,7 @@ impl L2ExecutionPayloadEnvelope {
if ty != OpTxType::Deposit as u8 {
anyhow::bail!("First payload transaction has unexpected type: {:?}", ty);
}
let tx = OpTxEnvelope::decode(&mut execution_payload.transactions[0][1..].as_ref())
let tx = OpTxEnvelope::decode_2718(&mut execution_payload.transactions[0].as_ref())
.map_err(|e| anyhow::anyhow!(e))?;

let OpTxEnvelope::Deposit(tx) = tx else {
Expand Down

0 comments on commit 4646398

Please sign in to comment.