Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.

Commit

Permalink
feat(proposer): add a --minimalBlockGasLimit flag to mitigate the p…
Browse files Browse the repository at this point in the history
…otential gas estimation issue (#225)

Co-authored-by: jeff <113397187+cyberhorsey@users.noreply.github.com>
  • Loading branch information
davidtaikocha and cyberhorsey authored May 15, 2023
1 parent dcead44 commit ab8305d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/flags/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ var (
Usage: "Time interval to propose empty blocks",
Category: proposerCategory,
}
MinBlockGasLimit = &cli.Uint64Flag{
Name: "minimalBlockGasLimit",
Usage: "Minimal block gasLimit when proposing a block",
Category: proposerCategory,
}
)

// All proposer flags.
Expand All @@ -56,4 +61,5 @@ var ProposerFlags = MergeFlags(CommonFlags, []cli.Flag{
CommitSlot,
TxPoolLocals,
ProposeEmptyBlocksInterval,
MinBlockGasLimit,
})
2 changes: 2 additions & 0 deletions proposer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Config struct {
CommitSlot uint64
LocalAddresses []common.Address
ProposeEmptyBlocksInterval *time.Duration
MinBlockGasLimit uint64
}

// NewConfigFromCliContext initializes a Config instance from
Expand Down Expand Up @@ -81,5 +82,6 @@ func NewConfigFromCliContext(c *cli.Context) (*Config, error) {
CommitSlot: c.Uint64(flags.CommitSlot.Name),
LocalAddresses: localAddresses,
ProposeEmptyBlocksInterval: proposeEmptyBlocksInterval,
MinBlockGasLimit: c.Uint64(flags.MinBlockGasLimit.Name),
}, nil
}
16 changes: 16 additions & 0 deletions proposer/proposer.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Proposer struct {
proposingTimer *time.Timer
commitSlot uint64
locals []common.Address
minBlockGasLimit *uint64

// Protocol configurations
protocolConfigs *bindings.TaikoDataConfig
Expand Down Expand Up @@ -96,6 +97,17 @@ func InitFromConfig(ctx context.Context, p *Proposer, cfg *Config) (err error) {
}
p.protocolConfigs = &protocolConfigs

if cfg.MinBlockGasLimit != 0 {
if cfg.MinBlockGasLimit > p.protocolConfigs.BlockMaxGasLimit.Uint64() {
return fmt.Errorf(
"minimal block gas limit too large, set: %d, limit: %d",
cfg.MinBlockGasLimit,
p.protocolConfigs.BlockMaxGasLimit,
)
}
p.minBlockGasLimit = &cfg.MinBlockGasLimit
}

log.Info("Protocol configs", "configs", p.protocolConfigs)

return nil
Expand Down Expand Up @@ -229,6 +241,10 @@ func (p *Proposer) ProposeTxList(
txListBytes []byte,
txNum uint,
) error {
if p.minBlockGasLimit != nil && meta.GasLimit < uint32(*p.minBlockGasLimit) {
meta.GasLimit = uint32(*p.minBlockGasLimit)
}

// Propose the transactions list
inputs, err := encoding.EncodeProposeBlockInput(meta)
if err != nil {
Expand Down

0 comments on commit ab8305d

Please sign in to comment.