Documentation ¶
Index ¶
- Constants
- func DecodeBlockFromUncompressed(r *bytes.Reader) (encode.DecodedBlockData, error)
- func DecodeTxFromUncompressed(r *bytes.Reader, from *common.Address) (types.TxData, error)
- func EncodeBlockForCompression(block *types.Block, w io.Writer, encodingOptions ...encode.Option) error
- func EncodeTxForCompression(tx *types.Transaction, w io.Writer, encodingOptions ...encode.Option) error
- func PackAlign(w io.Writer, a, b []byte) (n int64, err error)
- func PackAlignSize(a, b []byte) (n int)
- func ReadTxAsRlp(r *bytes.Reader) (fields []any, _type uint8, err error)
- func UnpackAlign(r []byte) ([]byte, error)
- type BlobMaker
- func (bm *BlobMaker) Bytes() []byte
- func (bm *BlobMaker) Clone() *BlobMaker
- func (bm *BlobMaker) Equals(other *BlobMaker) bool
- func (bm *BlobMaker) Len() int
- func (bm *BlobMaker) RawCompressedSize(data []byte) (int, error)
- func (bm *BlobMaker) Reset()
- func (bm *BlobMaker) StartNewBatch()
- func (bm *BlobMaker) WorstCompressedBlockSize(rlpBlock []byte) (bool, int, error)
- func (bm *BlobMaker) WorstCompressedTxSize(rlpTx []byte) (int, error)
- func (bm *BlobMaker) Write(rlpBlock []byte, forceReset bool, encodingOptions ...encode.Option) (ok bool, err error)
- func (bm *BlobMaker) Written() int
- type Header
- func (s *Header) BlockLength(i, j int) int
- func (s *Header) ByteSize() int
- func (s *Header) ByteSizePacked() int
- func (s *Header) CheckEquality(other *Header) error
- func (s *Header) Equals(other *Header) bool
- func (s *Header) NbBatches() int
- func (s *Header) NbBlocksInBatch(i int) int
- func (s *Header) ReadFrom(r io.Reader) (int64, error)
- func (s *Header) WriteTo(w io.Writer) (int64, error)
Constants ¶
const ( // These also impact the circuit constraints (compile / setup time) MaxUncompressedBytes = 800_000 // defines the max size we can handle for a blob (uncompressed) input MaxUsableBytes = 32 * 4096 // TODO @gbotrel confirm this value // defines the number of bytes available in a blob )
Variables ¶
This section is empty.
Functions ¶
func DecodeBlockFromUncompressed ¶
func DecodeBlockFromUncompressed(r *bytes.Reader) (encode.DecodedBlockData, error)
DecodeBlockFromUncompressed inverts EncodeBlockForCompression. It is primarily meant for testing and ensuring the encoding is bijective.
func DecodeTxFromUncompressed ¶
DecodeTxFromUncompressed puts all the transaction data into the output, except for the from address, which will be put where the argument "from" is referencing
func EncodeBlockForCompression ¶
func EncodeBlockForCompression(block *types.Block, w io.Writer, encodingOptions ...encode.Option) error
EncodeBlockForCompression encodes a block for compression.
func EncodeTxForCompression ¶
func EncodeTxForCompression(tx *types.Transaction, w io.Writer, encodingOptions ...encode.Option) error
EncodeTxForCompression encodes a transaction for compression. this code is from zk-evm-monorepo/prover/... but doesn't include the chainID
func PackAlign ¶
PackAlign writes a and b to w, aligned to fr.Element (bls12-377) boundary. It returns the length of the data written to w.
func PackAlignSize ¶
PackAlignSize returns the size of the data when packed with PackAlign.
func UnpackAlign ¶
UnpackAlign unpacks r (packed with PackAlign) and returns the unpacked data.
Types ¶
type BlobMaker ¶
type BlobMaker struct {
// contains filtered or unexported fields
}
BlobMaker is a bm for RLP encoded blocks (see EIP-4844). It takes a batch of blocks as input (see StartNewBatch and Write). And it compresses them into a "blob" (see Bytes).
func NewBlobMaker ¶
NewBlobMaker returns a new bm.
func (*BlobMaker) Bytes ¶
Bytes returns the compressed data. Note that it returns a slice of the internal buffer, it is the caller's responsibility to copy the data if needed.
func (*BlobMaker) Clone ¶
Clone returns a (almost) deep copy of the bm -- this is used for test purposes.
func (*BlobMaker) Equals ¶
Equals returns true if the two compressors are ~equal -- this is used for test purposes.
func (*BlobMaker) RawCompressedSize ¶
RawCompressedSize compresses the (raw) input and returns the length of the compressed data. The returned length account for the "padding" used by the blob maker to fit the data in field elements. Input size must be less than 256kB. If an error occurred, returns -1.
This function is thread-safe. Concurrent calls are allowed, but the other functions are not thread-safe.
func (*BlobMaker) StartNewBatch ¶
func (bm *BlobMaker) StartNewBatch()
StartNewBatch starts a new batch of blocks.
func (*BlobMaker) WorstCompressedBlockSize ¶
WorstCompressedBlockSize returns the size of the given block, as compressed by an "empty" blob maker. That is, with more context, blob maker could compress the block further, but this function returns the maximum size that can be achieved.
The input is a RLP encoded block. Returns the length of the compressed data, or -1 if an error occurred.
This function is thread-safe. Concurrent calls are allowed, but the other functions may not be thread-safe.
func (*BlobMaker) WorstCompressedTxSize ¶
WorstCompressedTxSize returns the size of the given transaction, as compressed by an "empty" blob maker. That is, with more context, blob maker could compress the transaction further, but this function returns the maximum size that can be achieved.
The input is a RLP encoded transaction. Returns the length of the compressed data, or -1 if an error occurred.
This function is thread-safe. Concurrent calls are allowed, but the other functions may not be thread-safe.
func (*BlobMaker) Write ¶
func (bm *BlobMaker) Write(rlpBlock []byte, forceReset bool, encodingOptions ...encode.Option) (ok bool, err error)
Write attempts to append the RLP block to the current batch. if forceReset is set; this will NOT append the bytes but still returns true if the chunk could have been appended
type Header ¶
A Header is a list of batches of blocks of len(blocks) len(Header) == nb of batches in the blob len(Header[i]) == nb of blocks in the batch i Header[i][j] == len (bytes) of the j-th block in the batch i
func DecompressBlob ¶
func DecompressBlob(b []byte, dictStore dictionary.Store) (blobHeader *Header, rawBlocks []byte, blocks [][]byte, err error)
DecompressBlob decompresses a blob and returns the header and the blocks as they were compressed. rawBlocks is the raw payload of the blob, delivered in packed format @TODO bad idea. fix
func (*Header) BlockLength ¶
func (*Header) ByteSizePacked ¶
func (*Header) CheckEquality ¶
CheckEquality similar to Equals but returning a description of the mismatch, returning nil if the objects are equal
func (*Header) NbBlocksInBatch ¶
Directories ¶
Path | Synopsis |
---|---|
lzss/internal/suffixarray
Package suffixarray implements substring search in logarithmic time using an in-memory suffix array.
|
Package suffixarray implements substring search in logarithmic time using an in-memory suffix array. |