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) error
- func PassRlpList(r *bytes.Reader) error
- func ScanBlockByteLen(b []byte) (int, 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) (ok bool, err error)
- func (bm *BlobMaker) Written() int
- type Header
Constants ¶
const ( PackingSizeU256 = fr381.Bits - 1 ByteLenEncodingBytes = 3 NbElemsEncodingBytes = 2 // These also impact the circuit constraints (compile / setup time) MaxUncompressedBytes = 756240 // ~738.5KB defines the max size we can handle for a blob (uncompressed) input MaxUsableBytes = 32 * 4096 // 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 EncodeBlockForCompression ¶
EncodeBlockForCompression encodes a block for compression.
func PassRlpList ¶
PassRlpList advances the reader through an RLP list assuming the reader is currently pointing to an RLP-encoded list. This is used to scan the encoded number of bytes of an encoded blocks and more specifically to find the boundaries of an RLP-encoded transaction.
func ScanBlockByteLen ¶
ScanBlockByteLen scans the stream of bytes `b`, expecting to find an encoded block starting from position 0 and returns the length of the block. It returns an error if the scanner goes out of bound.
Types ¶
type BlobMaker ¶
type BlobMaker struct { Limit int // maximum size of the compressed data Header Header // 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.
type Header ¶
type Header struct { BatchSizes []int // BatchSizes[i] == byte size of the i-th batch CurrBatchBlocksLen []int // CurrBatchBlocksLen[i] == byte size of the i-th block in the current batch DictChecksum [fr.Bytes]byte }
A Header is a list of batches of blocks of len(blocks) len(BatchSizes) == nb of batches in the blob
func DecompressBlob ¶
func DecompressBlob(b []byte, dictStore dictionary.Store) (blobHeader *Header, rawPayload []byte, blocks [][]byte, err error)
DecompressBlob decompresses a blob and returns the header and the blocks as they were compressed.