diff --git a/Cargo.toml b/Cargo.toml index 8135929..e265217 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/src/header.rs b/src/header.rs index 037f6b3..a684f85 100644 --- a/src/header.rs +++ b/src/header.rs @@ -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()) } } diff --git a/src/transaction/eip1559.rs b/src/transaction/eip1559.rs index 1429fd0..e39445f 100644 --- a/src/transaction/eip1559.rs +++ b/src/transaction/eip1559.rs @@ -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::(10)?.to_big_endian(&mut rarr); - H256::from(rarr) - }, - s: { - let mut sarr = [0_u8; 32]; - rlp.val_at::(11)?.to_big_endian(&mut sarr); - H256::from(sarr) - }, + r: H256::from(rlp.val_at::(10)?.to_big_endian()), + s: H256::from(rlp.val_at::(11)?.to_big_endian()), }) } } diff --git a/src/transaction/eip2930.rs b/src/transaction/eip2930.rs index d613139..f53315c 100644 --- a/src/transaction/eip2930.rs +++ b/src/transaction/eip2930.rs @@ -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::(9)?.to_big_endian(&mut rarr); - H256::from(rarr) - }, - s: { - let mut sarr = [0_u8; 32]; - rlp.val_at::(10)?.to_big_endian(&mut sarr); - H256::from(sarr) - }, + r: H256::from(rlp.val_at::(9)?.to_big_endian()), + s: H256::from(rlp.val_at::(10)?.to_big_endian()), }) } } diff --git a/src/transaction/legacy.rs b/src/transaction/legacy.rs index 792a7aa..5cc961b 100644 --- a/src/transaction/legacy.rs +++ b/src/transaction/legacy.rs @@ -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 { @@ -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::(7)?.to_big_endian(&mut rarr); - H256::from(rarr) - }; - let s = { - let mut sarr = [0_u8; 32]; - rlp.val_at::(8)?.to_big_endian(&mut sarr); - H256::from(sarr) - }; + let r = H256::from(rlp.val_at::(7)?.to_big_endian()); + let s = H256::from(rlp.val_at::(8)?.to_big_endian()); let signature = TransactionSignature::new(v, r, s) .ok_or(DecoderError::Custom("Invalid transaction signature format"))?; @@ -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()) } }