Skip to content

Commit

Permalink
params: add blob schedule config
Browse files Browse the repository at this point in the history
  • Loading branch information
lightclient committed Dec 13, 2024
1 parent 804d45c commit 0c0a560
Showing 1 changed file with 56 additions and 2 deletions.
58 changes: 56 additions & 2 deletions params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,9 @@ type ChainConfig struct {
DepositContractAddress common.Address `json:"depositContractAddress,omitempty"`

// Various consensus engines
Ethash *EthashConfig `json:"ethash,omitempty"`
Clique *CliqueConfig `json:"clique,omitempty"`
Ethash *EthashConfig `json:"ethash,omitempty"`
Clique *CliqueConfig `json:"clique,omitempty"`
BlobScheduleConfig *BlobScheduleConfig `json:"blobSchedule,omitempty"`
}

// EthashConfig is the consensus engine configs for proof-of-work based sealing.
Expand Down Expand Up @@ -425,6 +426,59 @@ func (c *ChainConfig) Description() string {
return banner
}

// BlobConfig specifies the target and max blobs per block for the associated
// fork.
type BlobConfig struct {
Target uint64 `json:"target"`
Max uint64 `json:"max"`
}

// BlobScheduleConfig determines target and max number of blobs allow per fork.
type BlobScheduleConfig struct {
Cancun *BlobConfig `json:"cancun,omitempty"`
Prague *BlobConfig `json:"prague,omitempty"`
}

// LatestTargetBlobsPerBlock returns the target blobs per block associated with
// requested time.
func (c *ChainConfig) LatestTargetBlobsPerBlock(time uint64) uint64 {
if c.BlobScheduleConfig == nil {
panic("blob schedule not defined")
}
var (
london = c.LondonBlock
s = c.BlobScheduleConfig
)
switch {
case c.IsPrague(london, time) && s.Prague != nil:
return s.Prague.Target
case c.IsCancun(london, time) && s.Cancun != nil:
return s.Cancun.Target
default:
return 0
}
}

// LatestMaxBlobsPerBlock returns the max blobs per block associated with
// requested time.
func (c *ChainConfig) LatestMaxBlobsPerBlock(time uint64) uint64 {
if c.BlobScheduleConfig == nil {
panic("blob schedule not defined")
}
var (
london = c.LondonBlock
s = c.BlobScheduleConfig
)
switch {
case c.IsPrague(london, time) && s.Prague != nil:
return s.Prague.Max
case c.IsCancun(london, time) && s.Cancun != nil:
return s.Cancun.Max
default:
return 0
}
}

// IsHomestead returns whether num is either equal to the homestead block or greater.
func (c *ChainConfig) IsHomestead(num *big.Int) bool {
return isBlockForked(c.HomesteadBlock, num)
Expand Down

0 comments on commit 0c0a560

Please sign in to comment.