Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block gas 30m. #4501

Merged
merged 3 commits into from
Sep 19, 2023
Merged
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
8 changes: 8 additions & 0 deletions internal/params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ var (
big.NewInt(1), // LeaderRotationExternalBeaconLeaders
big.NewInt(0), // FeeCollectEpoch
big.NewInt(0), // ValidatorCodeFixEpoch
big.NewInt(0), // BlockGas30M
big.NewInt(0), // HIP30Epoch
}

Expand Down Expand Up @@ -374,6 +375,7 @@ var (
big.NewInt(0), // FeeCollectEpoch
big.NewInt(0), // ValidatorCodeFixEpoch
big.NewInt(0), // HIP30Epoch
big.NewInt(0), // BlockGas30M
}

// TestRules ...
Expand Down Expand Up @@ -537,6 +539,8 @@ type ChainConfig struct {
// 3. Change from 250 to 200 nodes for remaining shards (mainnet and localnet)
// 4. Change the minimum validator commission from 5 to 7% (all nets)
HIP30Epoch *big.Int `json:"hip30-epoch,omitempty"`

BlockGas30MEpoch *big.Int `json:"block-gas-30m-epoch,omitempty"`
}

// String implements the fmt.Stringer interface.
Expand Down Expand Up @@ -772,6 +776,10 @@ func (c *ChainConfig) IsLeaderRotation(epoch *big.Int) bool {
return isForked(c.LeaderRotationExternalNonBeaconLeaders, epoch)
}

func (c *ChainConfig) IsBlockGas30M(epoch *big.Int) bool {
return isForked(c.BlockGas30MEpoch, epoch)
}

func (c *ChainConfig) IsLeaderRotationExternalValidatorsAllowed(epoch *big.Int, shardID uint32) bool {
if !c.IsLeaderRotation(epoch) {
return false
Expand Down
20 changes: 13 additions & 7 deletions node/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ func (w *Worker) CommitSortedTransactions(
coinbase common.Address,
) {
for {
if w.current.gasPool.Gas() < 50000000 {
// Temporary solution to reduce the fullness of the block. Break here when the available gas left hit 50M.
// Effectively making the gas limit 30M (since 80M is the default gas limit)
utils.Logger().Info().Uint64("have", w.current.gasPool.Gas()).Uint64("want", params.TxGas).Msg("[Temp Gas Limit] Not enough gas for further transactions")
break
}
// If we don't have enough gas for any further transactions then we're done
if w.current.gasPool.Gas() < params.TxGas {
utils.Logger().Info().Uint64("have", w.current.gasPool.Gas()).Uint64("want", params.TxGas).Msg("Not enough gas for further transactions")
Expand Down Expand Up @@ -308,7 +302,7 @@ func (w *Worker) UpdateCurrent() error {
header := w.factory.NewHeader(epoch).With().
ParentHash(parent.Hash()).
Number(num.Add(num, common.Big1)).
GasLimit(core.CalcGasLimit(parent, w.gasFloor, w.gasCeil)).
GasLimit(core.CalcGasLimit(parent, w.GasFloor(epoch), w.gasCeil)).
Time(big.NewInt(timestamp)).
ShardID(w.chain.ShardID()).
Header()
Expand Down Expand Up @@ -602,3 +596,15 @@ func New(

return worker
}

func (w *Worker) GasFloor(epoch *big.Int) uint64 {
if w.chain.Config().IsBlockGas30M(epoch) {
return 30_000_000
}

return w.gasFloor
}

func (w *Worker) GasCeil() uint64 {
return w.gasCeil
}