From a8da5398bd3e12fe23535a6b39f524f67f53d306 Mon Sep 17 00:00:00 2001 From: jigarparmar519 Date: Thu, 22 Feb 2024 20:34:18 +0530 Subject: [PATCH] Added TinyRlp encoding for bloom filter and logs --- zkevm-circuits/src/witness/receipt.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/zkevm-circuits/src/witness/receipt.rs b/zkevm-circuits/src/witness/receipt.rs index acb9aded3a..2224ac194c 100644 --- a/zkevm-circuits/src/witness/receipt.rs +++ b/zkevm-circuits/src/witness/receipt.rs @@ -1,13 +1,11 @@ use ethers_core::{ types::{Bloom, Log}, - utils::rlp::{Encodable, RlpStream}, + utils::rlp::{Encodable, RlpStream, TinyRlp}, }; /// EVM log's receipt. #[derive(Clone, Debug, Default)] pub struct Receipt { - /// Denotes the ID of the tx. - pub id: usize, /// Denotes whether or not the tx was executed successfully. pub status: u8, /// Denotes the cumulative gas used by the tx execution. @@ -23,13 +21,9 @@ impl Encodable for Receipt { s.begin_list(4); s.append(&self.status); s.append(&self.cumulative_gas_used); - s.append(&self.bloom); - s.begin_list(self.logs.len()); - for log in self.logs.iter() { - s.begin_list(3); - s.append(&log.address); - s.append_list(&log.topics); - s.append(&log.data.0); - } + // Encode bloom filter using TinyRlp to reduce code size + s.append(&TinyRlp(&self.bloom.0)); + // Use TinyRlp to encode logs to reduce code size + s.append_list(&self.logs.iter().map(|log| TinyRlp(log)).collect::>()); } }