Skip to content

Commit

Permalink
chore: upgrade crate ethereum-types and rlp (#59)
Browse files Browse the repository at this point in the history
* chore: upgrade crate `ethereum-types` and `rlp`

* chore: fix the clippy warnings
  • Loading branch information
0xbillw authored Dec 27, 2024
1 parent b160820 commit 3be0d8f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 35 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ edition = "2021"

[dependencies]
bytes = { version = "1.0", default-features = false }
ethereum-types = { version = "0.14", default-features = false, features = ["rlp", "codec"] }
ethereum-types = { version = "0.15", default-features = false, features = ["rlp", "codec"] }
hash-db = { version = "0.16", default-features = false }
hash256-std-hasher = { version = "0.15", default-features = false }
rlp = { version = "0.5.2", default-features = false, features = ["derive"] }
rlp = { version = "0.6", default-features = false, features = ["derive"] }
sha3 = { version = "0.10", default-features = false }
trie-root = { version = "0.18", default-features = false }

Expand Down
2 changes: 1 addition & 1 deletion src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl Header {

#[must_use]
pub fn hash(&self) -> H256 {
H256::from_slice(Keccak256::digest(&rlp::encode(self)).as_slice())
H256::from_slice(Keccak256::digest(rlp::encode(self)).as_slice())
}
}

Expand Down
12 changes: 2 additions & 10 deletions src/transaction/eip1559.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,8 @@ impl rlp::Decodable for EIP1559Transaction {
input: rlp.val_at(7)?,
access_list: rlp.list_at(8)?,
odd_y_parity: rlp.val_at(9)?,
r: {
let mut rarr = [0_u8; 32];
rlp.val_at::<U256>(10)?.to_big_endian(&mut rarr);
H256::from(rarr)
},
s: {
let mut sarr = [0_u8; 32];
rlp.val_at::<U256>(11)?.to_big_endian(&mut sarr);
H256::from(sarr)
},
r: H256::from(rlp.val_at::<U256>(10)?.to_big_endian()),
s: H256::from(rlp.val_at::<U256>(11)?.to_big_endian()),
})
}
}
Expand Down
12 changes: 2 additions & 10 deletions src/transaction/eip2930.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,8 @@ impl rlp::Decodable for EIP2930Transaction {
input: rlp.val_at(6)?,
access_list: rlp.list_at(7)?,
odd_y_parity: rlp.val_at(8)?,
r: {
let mut rarr = [0_u8; 32];
rlp.val_at::<U256>(9)?.to_big_endian(&mut rarr);
H256::from(rarr)
},
s: {
let mut sarr = [0_u8; 32];
rlp.val_at::<U256>(10)?.to_big_endian(&mut sarr);
H256::from(sarr)
},
r: H256::from(rlp.val_at::<U256>(9)?.to_big_endian()),
s: H256::from(rlp.val_at::<U256>(10)?.to_big_endian()),
})
}
}
Expand Down
16 changes: 4 additions & 12 deletions src/transaction/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub struct LegacyTransaction {

impl LegacyTransaction {
pub fn hash(&self) -> H256 {
H256::from_slice(Keccak256::digest(&rlp::encode(self)).as_slice())
H256::from_slice(Keccak256::digest(rlp::encode(self)).as_slice())
}

pub fn to_message(self) -> LegacyTransactionMessage {
Expand Down Expand Up @@ -224,16 +224,8 @@ impl rlp::Decodable for LegacyTransaction {
}

let v = rlp.val_at(6)?;
let r = {
let mut rarr = [0_u8; 32];
rlp.val_at::<U256>(7)?.to_big_endian(&mut rarr);
H256::from(rarr)
};
let s = {
let mut sarr = [0_u8; 32];
rlp.val_at::<U256>(8)?.to_big_endian(&mut sarr);
H256::from(sarr)
};
let r = H256::from(rlp.val_at::<U256>(7)?.to_big_endian());
let s = H256::from(rlp.val_at::<U256>(8)?.to_big_endian());
let signature = TransactionSignature::new(v, r, s)
.ok_or(DecoderError::Custom("Invalid transaction signature format"))?;

Expand Down Expand Up @@ -262,7 +254,7 @@ pub struct LegacyTransactionMessage {

impl LegacyTransactionMessage {
pub fn hash(&self) -> H256 {
H256::from_slice(Keccak256::digest(&rlp::encode(self)).as_slice())
H256::from_slice(Keccak256::digest(rlp::encode(self)).as_slice())
}
}

Expand Down

0 comments on commit 3be0d8f

Please sign in to comment.