Documentation
¶
Index ¶
- Constants
- func CalculateBlobGasPrice(excessBlobGas uint64) *big.Int
- func ComputeCommitment(blob *kzg4844.Blob) (kzg4844.Commitment, error)
- func ComputeProof(blob *kzg4844.Blob, commitment kzg4844.Commitment) (kzg4844.Proof, error)
- func ComputeVersionedHash(commitment kzg4844.Commitment) common.Hash
- func EstimateBlobCost(blobCount int, blobGasPrice *big.Int) (*big.Int, error)
- func EstimateBlobGas(blobCount int) (uint64, error)
- func InitKZG() error
- func ValidateBlobCount(count int) error
- func ValidateBlobGasParameters(tx *types.Transaction, excessBlobGas uint64) error
- func ValidateBlobGasPrice(maxFeePerBlobGas *big.Int, excessBlobGas uint64) error
- func ValidateBlobSize(data []byte) error
- func ValidateKZGProof(blobData *BlobData) error
- func VerifyProof(blob *kzg4844.Blob, commitment kzg4844.Commitment, proof kzg4844.Proof) error
- type BlobData
- func BatchProcessBlobs(rawDataList [][]byte) ([]*BlobData, error)
- func GenerateBlob(genType GeneratorType, size int) (*BlobData, error)
- func GenerateBlobs(genType GeneratorType, count int, sizePerBlob int) ([]*BlobData, error)
- func GenerateRandomBlobs(count int) ([]*BlobData, error)
- func ProcessBlobData(rawData []byte) (*BlobData, error)
- type BlobGasParams
- type BlobTransaction
- type Generator
- type GeneratorType
- type L2DataGenerator
- type PatternGenerator
- type RandomGenerator
- type ZeroGenerator
Constants ¶
const BlobDataSize = 131072
BlobDataSize is the standard size of a blob (128 KB)
const BytesPerFieldElement = 32
BytesPerFieldElement is the number of bytes per field element
const FieldElementsPerBlob = 4096
FieldElementsPerBlob is the number of field elements in a blob
const MaxBlobsPerTransaction = 6
MaxBlobsPerTransaction is the maximum number of blobs per transaction
Variables ¶
This section is empty.
Functions ¶
func CalculateBlobGasPrice ¶
CalculateBlobGasPrice calculates the blob gas price based on excess blob gas Formula: fake_exponential(MIN_BLOB_GASPRICE, excess_blob_gas, BLOB_GASPRICE_UPDATE_FRACTION)
func ComputeCommitment ¶
func ComputeCommitment(blob *kzg4844.Blob) (kzg4844.Commitment, error)
ComputeCommitment computes the KZG commitment for a blob
func ComputeProof ¶
ComputeProof computes the KZG proof for a blob and commitment
func ComputeVersionedHash ¶
func ComputeVersionedHash(commitment kzg4844.Commitment) common.Hash
ComputeVersionedHash computes the versioned hash from a commitment Format: sha256(commitment)[0] | 0x01
func EstimateBlobCost ¶
EstimateBlobCost estimates the cost of blob gas for a transaction
func EstimateBlobGas ¶
EstimateBlobGas estimates the blob gas required for a transaction
func InitKZG ¶
func InitKZG() error
InitKZG initializes the KZG library with trusted setup This must be called before any KZG operations
func ValidateBlobCount ¶
ValidateBlobCount validates the number of blobs in a transaction
func ValidateBlobGasParameters ¶
func ValidateBlobGasParameters(tx *types.Transaction, excessBlobGas uint64) error
ValidateBlobGasParameters validates blob gas related parameters
func ValidateBlobGasPrice ¶
ValidateBlobGasPrice validates the blob gas price against current network conditions
func ValidateBlobSize ¶
ValidateBlobSize validates the size of blob data
func ValidateKZGProof ¶
ValidateKZGProof validates the KZG proof for blob data
func VerifyProof ¶
VerifyProof verifies a KZG proof for a blob and commitment
Types ¶
type BlobData ¶
type BlobData struct {
// Raw data (up to 128 KB)
Raw []byte
// Standard blob format (128 KB, properly formatted for KZG)
Blob kzg4844.Blob
// KZG commitment to the blob
Commitment kzg4844.Commitment
// KZG proof for the commitment
Proof kzg4844.Proof
// Versioned hash (sha256(commitment)[0] | 0x01)
VersionedHash common.Hash
}
BlobData represents a single blob with its cryptographic commitments
func BatchProcessBlobs ¶
BatchProcessBlobs processes multiple raw data chunks into BlobData structures
func GenerateBlob ¶
func GenerateBlob(genType GeneratorType, size int) (*BlobData, error)
GenerateBlob generates a single blob with the specified generator and size
func GenerateBlobs ¶
func GenerateBlobs(genType GeneratorType, count int, sizePerBlob int) ([]*BlobData, error)
GenerateBlobs generates multiple blobs
func GenerateRandomBlobs ¶
GenerateRandomBlobs is a convenience function to generate random blobs
func ProcessBlobData ¶
ProcessBlobData processes raw data into a complete BlobData structure This includes computing the commitment, proof, and versioned hash
type BlobGasParams ¶
type BlobGasParams struct {
// Current excess blob gas
ExcessBlobGas uint64
// Current blob gas price
BlobGasPrice uint64
// Max fee per blob gas willing to pay
MaxFeePerBlobGas uint64
}
BlobGasParams holds blob gas pricing parameters
type BlobTransaction ¶
type BlobTransaction struct {
// The transaction itself (Type 3)
Tx *types.Transaction
// Associated blob data (1-6 blobs)
Blobs []*BlobData
// Sidecar format for network transmission
Sidecars []types.BlobTxSidecar
}
BlobTransaction represents a complete blob transaction with all sidecars
type Generator ¶
type Generator interface {
// Generate creates blob data of the specified size
Generate(size int) ([]byte, error)
// Type returns the generator type
Type() GeneratorType
}
Generator defines the interface for blob data generators
func NewGenerator ¶
func NewGenerator(genType GeneratorType) (Generator, error)
NewGenerator creates a new generator based on the specified type
type GeneratorType ¶
type GeneratorType string
GeneratorType defines the type of blob data generator
const ( // GeneratorRandom generates random blob data GeneratorRandom GeneratorType = "random" // GeneratorPattern generates patterned blob data (for testing) GeneratorPattern GeneratorType = "pattern" // GeneratorZero generates zero-filled blob data GeneratorZero GeneratorType = "zero" // GeneratorL2Data simulates L2 rollup data format GeneratorL2Data GeneratorType = "l2-data" )
type L2DataGenerator ¶
L2DataGenerator simulates L2 rollup data format
func (*L2DataGenerator) Type ¶
func (g *L2DataGenerator) Type() GeneratorType
type PatternGenerator ¶
type PatternGenerator struct {
Pattern []byte
}
PatternGenerator generates patterned blob data for testing
func (*PatternGenerator) Type ¶
func (g *PatternGenerator) Type() GeneratorType
type RandomGenerator ¶
type RandomGenerator struct{}
RandomGenerator generates random blob data
func (*RandomGenerator) Type ¶
func (g *RandomGenerator) Type() GeneratorType
type ZeroGenerator ¶
type ZeroGenerator struct{}
ZeroGenerator generates zero-filled blob data
func (*ZeroGenerator) Type ¶
func (g *ZeroGenerator) Type() GeneratorType