Documentation ¶
Index ¶
- func CheckBatchCompressedDataCompatibility(batch *Batch, codecVersion CodecVersion) (bool, error)
- func CheckChunkCompressedDataCompatibility(chunk *Chunk, codecVersion CodecVersion) (bool, error)
- func DecodeBitmap(skippedL1MessageBitmap []byte, totalL1MessagePopped int) ([]*big.Int, error)
- func GetBatchEnableCompression(codecVersion CodecVersion, batch *Batch) (bool, error)
- func GetChunkEnableCompression(codecVersion CodecVersion, chunk *Chunk) (bool, error)
- func GetHardforkName(config *params.ChainConfig, blockHeight, blockTimestamp uint64) string
- func IsL1MessageSkipped(skippedBitmap []*big.Int, index uint64) bool
- func TxsToTxsData(txs types.Transactions) []*types.TransactionData
- type Batch
- type Block
- type Chunk
- type Codec
- type CodecVersion
- type DABatch
- type DABlock
- type DAChunk
- type DAChunkRawTx
- type DACodecV0
- func (d *DACodecV0) CheckBatchCompressedDataCompatibility(b *Batch) (bool, error)
- func (d *DACodecV0) CheckChunkCompressedDataCompatibility(c *Chunk) (bool, error)
- func (d *DACodecV0) DecodeDAChunksRawTx(chunkBytes [][]byte) ([]*DAChunkRawTx, error)
- func (d *DACodecV0) DecodeTxsFromBlob(blob *kzg4844.Blob, chunks []*DAChunkRawTx) error
- func (d *DACodecV0) EstimateBatchL1CommitBatchSizeAndBlobSize(b *Batch) (uint64, uint64, error)
- func (d *DACodecV0) EstimateBatchL1CommitCalldataSize(b *Batch) (uint64, error)
- func (d *DACodecV0) EstimateBatchL1CommitGas(b *Batch) (uint64, error)
- func (d *DACodecV0) EstimateBlockL1CommitCalldataSize(b *Block) (uint64, error)
- func (d *DACodecV0) EstimateBlockL1CommitGas(b *Block) (uint64, error)
- func (d *DACodecV0) EstimateChunkL1CommitBatchSizeAndBlobSize(c *Chunk) (uint64, uint64, error)
- func (d *DACodecV0) EstimateChunkL1CommitCalldataSize(c *Chunk) (uint64, error)
- func (d *DACodecV0) EstimateChunkL1CommitGas(c *Chunk) (uint64, error)
- func (c *DACodecV0) JSONFromBytes(data []byte) ([]byte, error)
- func (d *DACodecV0) MaxNumChunksPerBatch() int
- func (d *DACodecV0) NewDABatch(batch *Batch) (DABatch, error)
- func (d *DACodecV0) NewDABatchFromBytes(data []byte) (DABatch, error)
- func (d *DACodecV0) NewDABlock(block *Block, totalL1MessagePoppedBefore uint64) (DABlock, error)
- func (d *DACodecV0) NewDAChunk(chunk *Chunk, totalL1MessagePoppedBefore uint64) (DAChunk, error)
- func (d *DACodecV0) Version() CodecVersion
- type DACodecV1
- func (d *DACodecV1) DecodeDAChunksRawTx(chunkBytes [][]byte) ([]*DAChunkRawTx, error)
- func (d *DACodecV1) DecodeTxsFromBlob(blob *kzg4844.Blob, chunks []*DAChunkRawTx) error
- func (d *DACodecV1) EstimateBatchL1CommitBatchSizeAndBlobSize(b *Batch) (uint64, uint64, error)
- func (d *DACodecV1) EstimateBatchL1CommitCalldataSize(b *Batch) (uint64, error)
- func (d *DACodecV1) EstimateBatchL1CommitGas(b *Batch) (uint64, error)
- func (d *DACodecV1) EstimateBlockL1CommitCalldataSize(_ *Block) (uint64, error)
- func (d *DACodecV1) EstimateBlockL1CommitGas(b *Block) (uint64, error)
- func (d *DACodecV1) EstimateChunkL1CommitBatchSizeAndBlobSize(c *Chunk) (uint64, uint64, error)
- func (d *DACodecV1) EstimateChunkL1CommitCalldataSize(c *Chunk) (uint64, error)
- func (d *DACodecV1) EstimateChunkL1CommitGas(c *Chunk) (uint64, error)
- func (d *DACodecV1) NewDABatch(batch *Batch) (DABatch, error)
- func (d *DACodecV1) NewDABatchFromBytes(data []byte) (DABatch, error)
- func (d *DACodecV1) NewDAChunk(chunk *Chunk, totalL1MessagePoppedBefore uint64) (DAChunk, error)
- func (d *DACodecV1) Version() CodecVersion
- type DACodecV2
- func (d *DACodecV2) CheckBatchCompressedDataCompatibility(b *Batch) (bool, error)
- func (d *DACodecV2) CheckChunkCompressedDataCompatibility(c *Chunk) (bool, error)
- func (d *DACodecV2) DecodeTxsFromBlob(blob *kzg4844.Blob, chunks []*DAChunkRawTx) error
- func (d *DACodecV2) EstimateBatchL1CommitBatchSizeAndBlobSize(b *Batch) (uint64, uint64, error)
- func (d *DACodecV2) EstimateChunkL1CommitBatchSizeAndBlobSize(c *Chunk) (uint64, uint64, error)
- func (d *DACodecV2) MaxNumChunksPerBatch() int
- func (d *DACodecV2) NewDABatch(batch *Batch) (DABatch, error)
- func (d *DACodecV2) NewDABatchFromBytes(data []byte) (DABatch, error)
- func (d *DACodecV2) Version() CodecVersion
- type DACodecV3
- func (d *DACodecV3) EstimateBatchL1CommitGas(b *Batch) (uint64, error)
- func (d *DACodecV3) EstimateChunkL1CommitGas(c *Chunk) (uint64, error)
- func (d *DACodecV3) JSONFromBytes(data []byte) ([]byte, error)
- func (d *DACodecV3) NewDABatch(batch *Batch) (DABatch, error)
- func (d *DACodecV3) NewDABatchFromBytes(data []byte) (DABatch, error)
- func (d *DACodecV3) Version() CodecVersion
- type DACodecV4
- func (d *DACodecV4) CheckBatchCompressedDataCompatibility(b *Batch) (bool, error)
- func (d *DACodecV4) CheckChunkCompressedDataCompatibility(c *Chunk) (bool, error)
- func (d *DACodecV4) DecodeTxsFromBlob(blob *kzg4844.Blob, chunks []*DAChunkRawTx) error
- func (d *DACodecV4) EstimateBatchL1CommitBatchSizeAndBlobSize(b *Batch) (uint64, uint64, error)
- func (d *DACodecV4) EstimateChunkL1CommitBatchSizeAndBlobSize(c *Chunk) (uint64, uint64, error)
- func (d *DACodecV4) JSONFromBytes(data []byte) ([]byte, error)
- func (d *DACodecV4) NewDABatch(batch *Batch) (DABatch, error)
- func (d *DACodecV4) NewDABatchFromBytes(data []byte) (DABatch, error)
- func (d *DACodecV4) Version() CodecVersion
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckBatchCompressedDataCompatibility ¶
func CheckBatchCompressedDataCompatibility(batch *Batch, codecVersion CodecVersion) (bool, error)
CheckBatchCompressedDataCompatibility checks compressed data compatibility of a batch built by a single chunk.
func CheckChunkCompressedDataCompatibility ¶
func CheckChunkCompressedDataCompatibility(chunk *Chunk, codecVersion CodecVersion) (bool, error)
CheckChunkCompressedDataCompatibility checks compressed data compatibility of a batch built by a single chunk.
func DecodeBitmap ¶
DecodeBitmap decodes skipped L1 message bitmap of the batch from bytes to big.Int's.
func GetBatchEnableCompression ¶
func GetBatchEnableCompression(codecVersion CodecVersion, batch *Batch) (bool, error)
GetBatchEnableCompression returns whether to enable compression for the given block height and timestamp.
func GetChunkEnableCompression ¶
func GetChunkEnableCompression(codecVersion CodecVersion, chunk *Chunk) (bool, error)
GetChunkEnableCompression returns whether to enable compression for the given block height and timestamp.
func GetHardforkName ¶
func GetHardforkName(config *params.ChainConfig, blockHeight, blockTimestamp uint64) string
GetHardforkName returns the name of the hardfork active at the given block height and timestamp.
func IsL1MessageSkipped ¶
IsL1MessageSkipped checks if the L1 message at the given index is skipped.
func TxsToTxsData ¶
func TxsToTxsData(txs types.Transactions) []*types.TransactionData
TxsToTxsData converts transactions to a TransactionData array.
Types ¶
type Batch ¶
type Batch struct { Index uint64 TotalL1MessagePoppedBefore uint64 ParentBatchHash common.Hash Chunks []*Chunk }
Batch represents a batch of chunks.
func (*Batch) WithdrawRoot ¶
WithdrawRoot gets the withdraw root after committing/finalizing the batch.
type Block ¶
type Block struct { Header *types.Header Transactions []*types.TransactionData WithdrawRoot common.Hash `json:"withdraw_trie_root,omitempty"` RowConsumption *types.RowConsumption `json:"row_consumption,omitempty"` }
Block represents an L2 block.
func (*Block) NumL1Messages ¶
NumL1Messages returns the number of L1 messages in this block. This number is the sum of included and skipped L1 messages.
func (*Block) NumL2Transactions ¶
NumL2Transactions returns the number of L2 transactions in this block.
type Chunk ¶
type Chunk struct {
Blocks []*Block `json:"blocks"`
}
Chunk represents a group of blocks.
func (*Chunk) NumL1Messages ¶
NumL1Messages returns the number of L1 messages in this chunk. This number is the sum of included and skipped L1 messages.
func (*Chunk) NumL2Transactions ¶
NumL2Transactions calculates the total number of L2 transactions in a Chunk.
func (*Chunk) NumTransactions ¶
NumTransactions calculates the total number of transactions in a Chunk.
func (*Chunk) TotalGasUsed ¶
TotalGasUsed calculates the total gas of transactions in a Chunk.
type Codec ¶
type Codec interface { Version() CodecVersion MaxNumChunksPerBatch() int NewDABlock(*Block, uint64) (DABlock, error) NewDAChunk(*Chunk, uint64) (DAChunk, error) NewDABatch(*Batch) (DABatch, error) NewDABatchFromBytes([]byte) (DABatch, error) DecodeDAChunksRawTx(chunkBytes [][]byte) ([]*DAChunkRawTx, error) DecodeTxsFromBlob(blob *kzg4844.Blob, chunks []*DAChunkRawTx) error CheckChunkCompressedDataCompatibility(*Chunk) (bool, error) CheckBatchCompressedDataCompatibility(*Batch) (bool, error) EstimateChunkL1CommitBatchSizeAndBlobSize(*Chunk) (uint64, uint64, error) EstimateBatchL1CommitBatchSizeAndBlobSize(*Batch) (uint64, uint64, error) EstimateBlockL1CommitCalldataSize(*Block) (uint64, error) EstimateChunkL1CommitCalldataSize(*Chunk) (uint64, error) EstimateChunkL1CommitGas(*Chunk) (uint64, error) EstimateBatchL1CommitGas(*Batch) (uint64, error) EstimateBatchL1CommitCalldataSize(*Batch) (uint64, error) JSONFromBytes([]byte) ([]byte, error) // convert batch header bytes to JSON, this is only used to provide witness data for the prover. }
Codec represents the interface for encoding and decoding DA-related structures.
func CodecFromConfig ¶
func CodecFromConfig(chainCfg *params.ChainConfig, startBlockNumber *big.Int, startBlockTimestamp uint64) Codec
CodecFromConfig determines and returns the appropriate codec based on chain configuration, block number, and timestamp.
func CodecFromVersion ¶
func CodecFromVersion(version CodecVersion) (Codec, error)
CodecFromVersion returns the appropriate codec for the given version.
type CodecVersion ¶
type CodecVersion uint8
CodecVersion represents the version of the codec.
const ( CodecV0 CodecVersion = iota CodecV1 CodecV2 CodecV3 CodecV4 )
func GetCodecVersion ¶
func GetCodecVersion(config *params.ChainConfig, blockHeight, blockTimestamp uint64) CodecVersion
GetCodecVersion returns the encoding codec version for the given block height and timestamp.
type DABatch ¶
type DABatch interface { Encode() []byte Hash() common.Hash DataHash() common.Hash BlobDataProofForPointEvaluation() ([]byte, error) Blob() *kzg4844.Blob BlobBytes() []byte Version() CodecVersion SkippedL1MessageBitmap() []byte }
DABatch contains metadata about a batch of DAChunks.
type DABlock ¶
type DABlock interface { Encode() []byte Decode([]byte) error Number() uint64 NumTransactions() uint16 NumL1Messages() uint16 Timestamp() uint64 BaseFee() *big.Int GasLimit() uint64 }
DABlock represents a Data Availability Block.
type DAChunk ¶
type DAChunk interface { Encode() ([]byte, error) Hash() (common.Hash, error) BlockRange() (uint64, uint64, error) }
DAChunk groups consecutive DABlocks with their transactions.
type DAChunkRawTx ¶
type DAChunkRawTx struct { Blocks []DABlock Transactions []types.Transactions }
DAChunkRawTx groups consecutive DABlocks with their L2 transactions, L1 msgs are loaded in another place.
type DACodecV0 ¶
type DACodecV0 struct{}
func (*DACodecV0) CheckBatchCompressedDataCompatibility ¶
CheckBatchCompressedDataCompatibility checks the compressed data compatibility for a batch.
func (*DACodecV0) CheckChunkCompressedDataCompatibility ¶
CheckChunkCompressedDataCompatibility checks the compressed data compatibility for a batch built from a single chunk.
func (*DACodecV0) DecodeDAChunksRawTx ¶
func (d *DACodecV0) DecodeDAChunksRawTx(chunkBytes [][]byte) ([]*DAChunkRawTx, error)
DecodeDAChunksRawTx takes a byte slice and decodes it into a []*DAChunkRawTx.
func (*DACodecV0) DecodeTxsFromBlob ¶
func (d *DACodecV0) DecodeTxsFromBlob(blob *kzg4844.Blob, chunks []*DAChunkRawTx) error
DecodeTxsFromBlob decodes txs from blob bytes and writes to chunks
func (*DACodecV0) EstimateBatchL1CommitBatchSizeAndBlobSize ¶
EstimateBatchL1CommitBatchSizeAndBlobSize estimates the L1 commit batch size and blob size for a batch.
func (*DACodecV0) EstimateBatchL1CommitCalldataSize ¶
EstimateBatchL1CommitCalldataSize calculates the calldata size in l1 commit for this batch approximately.
func (*DACodecV0) EstimateBatchL1CommitGas ¶
EstimateBatchL1CommitGas calculates the total L1 commit gas for this batch approximately.
func (*DACodecV0) EstimateBlockL1CommitCalldataSize ¶
EstimateBlockL1CommitCalldataSize calculates the calldata size in l1 commit for this block approximately.
func (*DACodecV0) EstimateBlockL1CommitGas ¶
EstimateBlockL1CommitGas calculates the total L1 commit gas for this block approximately.
func (*DACodecV0) EstimateChunkL1CommitBatchSizeAndBlobSize ¶
EstimateChunkL1CommitBatchSizeAndBlobSize estimates the L1 commit batch size and blob size for a single chunk.
func (*DACodecV0) EstimateChunkL1CommitCalldataSize ¶
EstimateChunkL1CommitCalldataSize calculates the calldata size needed for committing a chunk to L1 approximately.
func (*DACodecV0) EstimateChunkL1CommitGas ¶
EstimateChunkL1CommitGas calculates the total L1 commit gas for this chunk approximately.
func (*DACodecV0) JSONFromBytes ¶
JSONFromBytes for CodecV0 returns empty values.
func (*DACodecV0) MaxNumChunksPerBatch ¶
MaxNumChunksPerBatch returns the maximum number of chunks per batch.
func (*DACodecV0) NewDABatch ¶
NewDABatch creates a DABatch from the provided Batch.
func (*DACodecV0) NewDABatchFromBytes ¶
NewDABatchFromBytes decodes the given byte slice into a DABatch.
func (*DACodecV0) NewDABlock ¶
NewDABlock creates a new DABlock from the given Block and the total number of L1 messages popped before.
func (*DACodecV0) NewDAChunk ¶
NewDAChunk creates a new DAChunk from the given Chunk and the total number of L1 messages popped before.
func (*DACodecV0) Version ¶
func (d *DACodecV0) Version() CodecVersion
Version returns the codec version.
type DACodecV1 ¶
type DACodecV1 struct {
DACodecV0
}
func (*DACodecV1) DecodeDAChunksRawTx ¶
func (d *DACodecV1) DecodeDAChunksRawTx(chunkBytes [][]byte) ([]*DAChunkRawTx, error)
DecodeDAChunksRawTx takes a byte slice and decodes it into a []*DAChunkRawTx. Beginning from codecv1 tx data posted to blobs, not to chunk bytes in calldata
func (*DACodecV1) DecodeTxsFromBlob ¶
func (d *DACodecV1) DecodeTxsFromBlob(blob *kzg4844.Blob, chunks []*DAChunkRawTx) error
DecodeTxsFromBlob decodes txs from blob bytes and writes to chunks
func (*DACodecV1) EstimateBatchL1CommitBatchSizeAndBlobSize ¶
EstimateBatchL1CommitBatchSizeAndBlobSize estimates the L1 commit batch size and blob size for a batch.
func (*DACodecV1) EstimateBatchL1CommitCalldataSize ¶
EstimateBatchL1CommitCalldataSize calculates the calldata size in l1 commit for this batch approximately.
func (*DACodecV1) EstimateBatchL1CommitGas ¶
EstimateBatchL1CommitGas calculates the total L1 commit gas for this batch approximately.
func (*DACodecV1) EstimateBlockL1CommitCalldataSize ¶
EstimateBlockL1CommitCalldataSize calculates the calldata size in l1 commit for this block approximately.
func (*DACodecV1) EstimateBlockL1CommitGas ¶
EstimateBlockL1CommitGas calculates the total L1 commit gas for this block approximately.
func (*DACodecV1) EstimateChunkL1CommitBatchSizeAndBlobSize ¶
EstimateChunkL1CommitBatchSizeAndBlobSize estimates the L1 commit batch size and blob size for a single chunk.
func (*DACodecV1) EstimateChunkL1CommitCalldataSize ¶
EstimateChunkL1CommitCalldataSize calculates the calldata size needed for committing a chunk to L1 approximately.
func (*DACodecV1) EstimateChunkL1CommitGas ¶
EstimateChunkL1CommitGas calculates the total L1 commit gas for this chunk approximately.
func (*DACodecV1) NewDABatch ¶
NewDABatch creates a DABatch from the provided Batch.
func (*DACodecV1) NewDABatchFromBytes ¶
NewDABatchFromBytes decodes the given byte slice into a DABatch. Note: This function only populates the batch header, it leaves the blob-related fields empty.
func (*DACodecV1) NewDAChunk ¶
NewDAChunk creates a new DAChunk from the given Chunk and the total number of L1 messages popped before.
func (*DACodecV1) Version ¶
func (d *DACodecV1) Version() CodecVersion
Version returns the codec version.
type DACodecV2 ¶
type DACodecV2 struct {
DACodecV1
}
func (*DACodecV2) CheckBatchCompressedDataCompatibility ¶
CheckBatchCompressedDataCompatibility checks the compressed data compatibility for a batch. It constructs a batch payload, compresses the data, and checks the compressed data compatibility if the uncompressed data exceeds 128 KiB.
func (*DACodecV2) CheckChunkCompressedDataCompatibility ¶
CheckChunkCompressedDataCompatibility checks the compressed data compatibility for a batch built from a single chunk. It constructs a batch payload, compresses the data, and checks the compressed data compatibility if the uncompressed data exceeds 128 KiB.
func (*DACodecV2) DecodeTxsFromBlob ¶
func (d *DACodecV2) DecodeTxsFromBlob(blob *kzg4844.Blob, chunks []*DAChunkRawTx) error
DecodeTxsFromBlob decodes txs from blob bytes and writes to chunks
func (*DACodecV2) EstimateBatchL1CommitBatchSizeAndBlobSize ¶
EstimateBatchL1CommitBatchSizeAndBlobSize estimates the L1 commit batch size and blob size for a batch.
func (*DACodecV2) EstimateChunkL1CommitBatchSizeAndBlobSize ¶
EstimateChunkL1CommitBatchSizeAndBlobSize estimates the L1 commit batch size and blob size for a single chunk.
func (*DACodecV2) MaxNumChunksPerBatch ¶
MaxNumChunksPerBatch returns the maximum number of chunks per batch.
func (*DACodecV2) NewDABatch ¶
NewDABatch creates a DABatch from the provided Batch.
func (*DACodecV2) NewDABatchFromBytes ¶
NewDABatchFromBytes decodes the given byte slice into a DABatch. Note: This function only populates the batch header, it leaves the blob-related fields empty.
func (*DACodecV2) Version ¶
func (d *DACodecV2) Version() CodecVersion
Version returns the codec version.
type DACodecV3 ¶
type DACodecV3 struct {
DACodecV2
}
func (*DACodecV3) EstimateBatchL1CommitGas ¶
EstimateBatchL1CommitGas calculates the total L1 commit gas for this batch approximately.
func (*DACodecV3) EstimateChunkL1CommitGas ¶
EstimateChunkL1CommitGas calculates the total L1 commit gas for this chunk approximately.
func (*DACodecV3) JSONFromBytes ¶
JSONFromBytes converts the bytes to a daBatchV3 and then marshals it to JSON.
func (*DACodecV3) NewDABatch ¶
NewDABatch creates a DABatch from the provided Batch.
func (*DACodecV3) NewDABatchFromBytes ¶
NewDABatchFromBytes decodes the given byte slice into a DABatch. Note: This function only populates the batch header, it leaves the blob-related fields and skipped L1 message bitmap empty.
func (*DACodecV3) Version ¶
func (d *DACodecV3) Version() CodecVersion
Version returns the codec version.
type DACodecV4 ¶
type DACodecV4 struct {
DACodecV3
}
func (*DACodecV4) CheckBatchCompressedDataCompatibility ¶
CheckBatchCompressedDataCompatibility checks the compressed data compatibility for a batch.
func (*DACodecV4) CheckChunkCompressedDataCompatibility ¶
CheckChunkCompressedDataCompatibility checks the compressed data compatibility for a batch built from a single chunk.
func (*DACodecV4) DecodeTxsFromBlob ¶
func (d *DACodecV4) DecodeTxsFromBlob(blob *kzg4844.Blob, chunks []*DAChunkRawTx) error
DecodeTxsFromBlob decodes txs from blob bytes and writes to chunks
func (*DACodecV4) EstimateBatchL1CommitBatchSizeAndBlobSize ¶
EstimateBatchL1CommitBatchSizeAndBlobSize estimates the L1 commit batch size and blob size for a batch.
func (*DACodecV4) EstimateChunkL1CommitBatchSizeAndBlobSize ¶
EstimateChunkL1CommitBatchSizeAndBlobSize estimates the L1 commit batch size and blob size for a single chunk.
func (*DACodecV4) JSONFromBytes ¶
JSONFromBytes converts the bytes to a daBatchV3 and then marshals it to JSON.
func (*DACodecV4) NewDABatch ¶
NewDABatch creates a DABatch from the provided Batch.
func (*DACodecV4) NewDABatchFromBytes ¶
NewDABatchFromBytes decodes the given byte slice into a DABatch. Note: This function only populates the batch header, it leaves the blob-related fields and skipped L1 message bitmap empty.
func (*DACodecV4) Version ¶
func (d *DACodecV4) Version() CodecVersion
Version returns the codec version.