Skip to content

Commit

Permalink
Fixed gas 30m.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frozen committed Aug 31, 2023
1 parent 9f1576f commit 63b3c40
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions internal/params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ var (
big.NewInt(1), // LeaderRotationExternalBeaconLeaders
big.NewInt(0), // FeeCollectEpoch
big.NewInt(0), // ValidatorCodeFixEpoch
big.NewInt(0), // BlockGas30M
}

// TestChainConfig ...
Expand Down Expand Up @@ -366,6 +367,7 @@ var (
big.NewInt(1), // LeaderRotationExternalBeaconLeaders
big.NewInt(0), // FeeCollectEpoch
big.NewInt(0), // ValidatorCodeFixEpoch
big.NewInt(0), // BlockGas30M
}

// TestRules ...
Expand Down Expand Up @@ -522,6 +524,8 @@ type ChainConfig struct {
// Contracts can check the (presence of) validator code by calling the following:
// extcodesize, extcodecopy and extcodehash.
ValidatorCodeFixEpoch *big.Int `json:"validator-code-fix-epoch,omitempty"`

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

// String implements the fmt.Stringer interface.
Expand Down Expand Up @@ -737,6 +741,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.BlockGas30M, epoch)
}

func (c *ChainConfig) IsLeaderRotationExternalValidatorsAllowed(epoch *big.Int, shardID uint32) bool {
if !c.IsLeaderRotation(epoch) {
return false
Expand Down
14 changes: 13 additions & 1 deletion node/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,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 +602,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
}

0 comments on commit 63b3c40

Please sign in to comment.