Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added TinyRlp encoding for bloom filter and logs #1117

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions zkevm-circuits/src/witness/receipt.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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::<Vec<_>>());
}
}
Loading