Skip to content
Open
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
15 changes: 15 additions & 0 deletions params/blob_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ func (bcfg *BlobConfig) MaxBlobGas() uint64 {
return uint64(bcfg.Max) * BlobTxBlobGasPerBlob
}

// validate checks that a blob config from a chain configuration is sane.
// UpdateFraction must be non-zero because it is used as a division denominator.
func (bcfg *BlobConfig) validate() error {
if bcfg.Max < 0 {
return errors.New("max < 0")
}
if bcfg.Target < 0 {
return errors.New("target < 0")
}
if bcfg.UpdateFraction == 0 {
return errors.New("update fraction must be defined and non-zero")
}
return nil
}

// blobPriceEIP4844 returns the price for EIP-4844 of one blob in Wei.
func (bcfg *BlobConfig) BlobPriceEIP4844(excessBlobGas uint64) *big.Int {
f := bcfg.BlobBaseFeeEIP4844(excessBlobGas)
Expand Down
15 changes: 14 additions & 1 deletion params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func (c *ChainConfig) Copy() *ChainConfig {

// BlobConfig returns the blob config associated with the provided fork.
func (c *ChainConfig) BlobConfig(head *big.Int) *BlobConfig {
if c.IsOsakaForkEnabled(head) {
if c.IsOsakaForkEnabled(head) && c.BlobScheduleConfig != nil {
return c.BlobScheduleConfig.Osaka
}
return nil
Expand Down Expand Up @@ -649,6 +649,19 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
lastFork = cur
}
}

// Check that the fork enabling blobs explicitly defines a valid blob schedule.
var osakaBlobConfig *BlobConfig
if c.BlobScheduleConfig != nil {
osakaBlobConfig = c.BlobScheduleConfig.Osaka
}
if osakaBlobConfig != nil {
if err := osakaBlobConfig.validate(); err != nil {
return fmt.Errorf("invalid chain configuration in blobSchedule for fork %q: %v", "osaka", err)
}
} else if c.OsakaCompatibleBlock != nil {
return fmt.Errorf("invalid chain configuration: missing entry for fork %q in blobSchedule", "osaka")
}
return nil
}

Expand Down
Loading