From 51b365b9004d57caf7dc369df7eb08b600948e34 Mon Sep 17 00:00:00 2001 From: classicalliu Date: Mon, 25 Jul 2022 11:37:47 +0800 Subject: [PATCH] fix(indexer): r & s in rlp encode should be integer rather than bytes Fix for eth_tx_hash calculation in indexer, the `eth_tx_hash` will be wrong when r / s with leading zeros --- crates/indexer/src/types.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/indexer/src/types.rs b/crates/indexer/src/types.rs index 29d5d7fb..165a1cad 100644 --- a/crates/indexer/src/types.rs +++ b/crates/indexer/src/types.rs @@ -110,11 +110,14 @@ impl Transaction { s.append(&vec![0u8; 0]); } }; + // r & s should be integer format in RLP + let r_num = U256::from(&self.r); + let s_num = U256::from(&self.s); s.append(&self.value) .append(&self.data) .append(&self.add_chain_replay_protection()) - .append(&self.r.to_vec()) - .append(&self.s.to_vec()); + .append(&r_num) + .append(&s_num); s.finalize_unbounded_list(); s.out().freeze().to_vec() }