From ff1480a666373badd1a0a123c945fd597918cb07 Mon Sep 17 00:00:00 2001 From: Mykhailo Slyvka Date: Fri, 28 Jun 2024 12:09:41 +0300 Subject: [PATCH 1/3] fix recover_signer in consensus crate --- crates/consensus/src/signed.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/consensus/src/signed.rs b/crates/consensus/src/signed.rs index 7248ae24a..4ef9a8dbf 100644 --- a/crates/consensus/src/signed.rs +++ b/crates/consensus/src/signed.rs @@ -57,8 +57,7 @@ impl> Signed { pub fn recover_signer( &self, ) -> Result { - todo!(); - // let sighash = self.tx.signature_hash(); - // self.signature.recover_address_from_prehash(&sighash) + let sighash = self.tx.signature_hash(); + self.signature.recover_address_from_prehash(&sighash) } } From b0014eb0bc1639b5685cdcdd1c81ad638999bbf5 Mon Sep 17 00:00:00 2001 From: Mykhailo Slyvka Date: Fri, 28 Jun 2024 12:13:30 +0300 Subject: [PATCH 2/3] replace Address with IcanAddress in consesnsus crate --- crates/consensus/src/signed.rs | 2 +- crates/consensus/src/transaction/envelope.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/consensus/src/signed.rs b/crates/consensus/src/signed.rs index 4ef9a8dbf..02db5304f 100644 --- a/crates/consensus/src/signed.rs +++ b/crates/consensus/src/signed.rs @@ -56,7 +56,7 @@ impl> Signed { /// Recover the signer of the transaction pub fn recover_signer( &self, - ) -> Result { + ) -> Result { let sighash = self.tx.signature_hash(); self.signature.recover_address_from_prehash(&sighash) } diff --git a/crates/consensus/src/transaction/envelope.rs b/crates/consensus/src/transaction/envelope.rs index 7a1c9925e..33a732dbf 100644 --- a/crates/consensus/src/transaction/envelope.rs +++ b/crates/consensus/src/transaction/envelope.rs @@ -144,7 +144,7 @@ impl TxEnvelope { #[cfg(feature = "k256")] pub fn recover_signer( &self, - ) -> Result { + ) -> Result { match self { TxEnvelope::Legacy(tx) => tx.recover_signer(), TxEnvelope::Eip2930(tx) => tx.recover_signer(), @@ -312,7 +312,7 @@ mod tests { #[cfg(feature = "k256")] // Test vector from https://etherscan.io/tx/0xce4dc6d7a7549a98ee3b071b67e970879ff51b5b95d1c340bacd80fa1e1aab31 fn test_decode_live_1559_tx() { - use alloy_primitives::address; + use alloy_primitives::cAddress; let raw_tx = alloy_primitives::hex::decode("02f86f0102843b9aca0085029e7822d68298f094d9e1459a7a482635700cbc20bbaf52d495ab9c9680841b55ba3ac080a0c199674fcb29f353693dd779c017823b954b3c69dffa3cd6b2a6ff7888798039a028ca912de909e7e6cdef9cdcaf24c54dd8c1032946dfa1d85c206b32a9064fe8").unwrap(); let res = TxEnvelope::decode(&mut raw_tx.as_slice()).unwrap(); @@ -333,7 +333,7 @@ mod tests { #[cfg(feature = "k256")] // Test vector from https://etherscan.io/tx/0x280cde7cdefe4b188750e76c888f13bd05ce9a4d7767730feefe8a0e50ca6fc4 fn test_decode_live_legacy_tx() { - use alloy_primitives::address; + use alloy_primitives::cAddress;s let raw_tx = alloy_primitives::hex::decode("f9015482078b8505d21dba0083022ef1947a250d5630b4cf539739df2c5dacb4c659f2488d880c46549a521b13d8b8e47ff36ab50000000000000000000000000000000000000000000066ab5a608bd00a23f2fe000000000000000000000000000000000000000000000000000000000000008000000000000000000000000048c04ed5691981c42154c6167398f95e8f38a7ff00000000000000000000000000000000000000000000000000000000632ceac70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006c6ee5e31d828de241282b9606c8e98ea48526e225a0c9077369501641a92ef7399ff81c21639ed4fd8fc69cb793cfa1dbfab342e10aa0615facb2f1bcf3274a354cfe384a38d0cc008a11c2dd23a69111bc6930ba27a8").unwrap(); let res = TxEnvelope::decode(&mut raw_tx.as_slice()).unwrap(); From 90dbe8f832b61885b986dffe23ff33e8fd3d5567 Mon Sep 17 00:00:00 2001 From: Mykhailo Slyvka Date: Fri, 28 Jun 2024 12:15:25 +0300 Subject: [PATCH 3/3] fix typo --- crates/consensus/src/transaction/envelope.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/consensus/src/transaction/envelope.rs b/crates/consensus/src/transaction/envelope.rs index 33a732dbf..c015f7200 100644 --- a/crates/consensus/src/transaction/envelope.rs +++ b/crates/consensus/src/transaction/envelope.rs @@ -301,7 +301,7 @@ mod tests { use super::*; use crate::transaction::SignableTransaction; use alloy_eips::eip2930::{AccessList, AccessListItem}; - use alloy_primitives::{hex, Address, Bytes, IcanAddress, TxKind, Signature, U256}; + use alloy_primitives::{hex, Address, Bytes, IcanAddress, Signature, TxKind, U256}; use core::str::FromStr; use std::{fs, path::PathBuf, vec}; @@ -333,7 +333,7 @@ mod tests { #[cfg(feature = "k256")] // Test vector from https://etherscan.io/tx/0x280cde7cdefe4b188750e76c888f13bd05ce9a4d7767730feefe8a0e50ca6fc4 fn test_decode_live_legacy_tx() { - use alloy_primitives::cAddress;s + use alloy_primitives::cAddress; let raw_tx = alloy_primitives::hex::decode("f9015482078b8505d21dba0083022ef1947a250d5630b4cf539739df2c5dacb4c659f2488d880c46549a521b13d8b8e47ff36ab50000000000000000000000000000000000000000000066ab5a608bd00a23f2fe000000000000000000000000000000000000000000000000000000000000008000000000000000000000000048c04ed5691981c42154c6167398f95e8f38a7ff00000000000000000000000000000000000000000000000000000000632ceac70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc20000000000000000000000006c6ee5e31d828de241282b9606c8e98ea48526e225a0c9077369501641a92ef7399ff81c21639ed4fd8fc69cb793cfa1dbfab342e10aa0615facb2f1bcf3274a354cfe384a38d0cc008a11c2dd23a69111bc6930ba27a8").unwrap(); let res = TxEnvelope::decode(&mut raw_tx.as_slice()).unwrap();