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

ROM Tables (LLC, MLC, MOC) and Bitstring Accumulation Table #1222

Merged
merged 5 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
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
26 changes: 23 additions & 3 deletions aggregator/src/aggregation/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ use zkevm_circuits::{
util::Challenges,
};

use crate::aggregation::decoder::witgen::N_BLOCK_HEADER_BYTES;

use self::tables::{LiteralsHeaderTable, RomTagTable};
use self::{
tables::{
BitstringAccumulationTable, LiteralLengthCodes, LiteralsHeaderTable, MatchLengthCodes,
MatchOffsetCodes, RomSequenceCodes, RomTagTable,
},
witgen::N_BLOCK_HEADER_BYTES,
};

#[derive(Clone, Debug)]
pub struct DecoderConfig {
Expand Down Expand Up @@ -63,8 +67,16 @@ pub struct DecoderConfig {
range16: RangeTable<16>,
/// Helper table for decoding the regenerated size from LiteralsHeader.
literals_header_table: LiteralsHeaderTable,
/// Helper table for decoding bitstreams.
bitstring_accumulation_table: BitstringAccumulationTable,
/// ROM table for validating tag transition.
rom_tag_table: RomTagTable,
/// ROM table for Literal Length Codes.
rom_llc_table: RomSequenceCodes<LiteralLengthCodes>,
/// ROM table for Match Length Codes.
rom_mlc_table: RomSequenceCodes<MatchLengthCodes>,
/// ROM table for Match Offset Codes.
rom_moc_table: RomSequenceCodes<MatchOffsetCodes>,
}

#[derive(Clone, Debug)]
Expand Down Expand Up @@ -339,9 +351,13 @@ impl DecoderConfig {
) -> Self {
// Fixed tables
let rom_tag_table = RomTagTable::construct(meta);
let rom_llc_table = RomSequenceCodes::<LiteralLengthCodes>::construct(meta);
let rom_mlc_table = RomSequenceCodes::<MatchLengthCodes>::construct(meta);
let rom_moc_table = RomSequenceCodes::<MatchOffsetCodes>::construct(meta);

// Helper tables
let literals_header_table = LiteralsHeaderTable::configure(meta, range8, range16);
let bitstring_accumulation_table = BitstringAccumulationTable::configure(meta);

// Peripheral configs
let tag_config = TagConfig::configure(meta);
Expand Down Expand Up @@ -372,7 +388,11 @@ impl DecoderConfig {
range8,
range16,
literals_header_table,
bitstring_accumulation_table,
rom_tag_table,
rom_llc_table,
rom_mlc_table,
rom_moc_table,
};

macro_rules! is_tag {
Expand Down
12 changes: 12 additions & 0 deletions aggregator/src/aggregation/decoder/tables.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
/// Since bitstrings to decode can be spanned over more than one byte from the encoded bytes, we
/// construct a table to accumulate the binary values of the byte-unaligned bitstrings for decoding
/// convenience.
mod bitstring_accumulation;
pub use bitstring_accumulation::BitstringAccumulationTable;

/// Decode the regenerated size from the literals header.
mod literals_header;
pub use literals_header::LiteralsHeaderTable;

/// The fixed code to Baseline/NumBits for Literal Length.
mod rom_sequence_codes;
pub use rom_sequence_codes::{
LiteralLengthCodes, MatchLengthCodes, MatchOffsetCodes, RomSequenceCodes,
};

/// Validate the following tag given the tag currently being processed.
mod rom_tag;
pub use rom_tag::RomTagTable;
Loading
Loading