Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit f1fcfd7

Browse files
authored
minimize diff from upstream (#147)
1 parent 5ac33b5 commit f1fcfd7

File tree

23 files changed

+89
-124
lines changed

23 files changed

+89
-124
lines changed

Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ lint: ## Run linters.
2727
$(GORUN) build/ci.go lint
2828

2929
fmt:
30-
gofmt -s -w .
31-
gofumpt -extra -w .
32-
gci write .
30+
go fmt
3331
go mod tidy
3432

3533
clean:

cmd/geth/chaincmd.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ if one is set. Otherwise it prints the genesis from the datadir.`,
8686
utils.CacheGCFlag,
8787
utils.MetricsEnabledFlag,
8888
utils.MetricsEnabledExpensiveFlag,
89-
utils.MetricsEnabledBuilderFlag,
9089
utils.MetricsHTTPFlag,
9190
utils.MetricsPortFlag,
9291
utils.MetricsEnableInfluxDBFlag,

common/big.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ var (
2929
Big3 = big.NewInt(3)
3030
Big0 = big.NewInt(0)
3131
Big32 = big.NewInt(32)
32-
Big100 = big.NewInt(100)
3332
Big256 = big.NewInt(256)
3433
Big257 = big.NewInt(257)
3534

common/hexutil/json.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,6 @@ func (b *U256) UnmarshalText(input []byte) error {
265265
return (*uint256.Int)(b).SetFromHex(string(input))
266266
}
267267

268-
// ToInt converts b to a uint256.Int.
269-
func (b *U256) ToInt() *uint256.Int {
270-
return (*uint256.Int)(b)
271-
}
272-
273268
// String returns the hex encoding of b.
274269
func (b *U256) String() string {
275270
return (*uint256.Int)(b).Hex()

consensus/beacon/consensus.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,9 @@ func (beacon *Beacon) FinalizeAndAssemble(chain consensus.ChainHeaderReader, hea
395395
//
396396
// Note, the method returns immediately and will send the result async. More
397397
// than one result may also be returned depending on the consensus algorithm.
398-
func (beacon *Beacon) Seal(chain consensus.ChainHeaderReader, block *types.Block, profit *big.Int, results chan<- *types.Block, stop <-chan struct{}) error {
398+
func (beacon *Beacon) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
399399
if !beacon.IsPoSHeader(block.Header()) {
400-
return beacon.ethone.Seal(chain, block, profit, results, stop)
400+
return beacon.ethone.Seal(chain, block, results, stop)
401401
}
402402
// The seal verification is done by the external consensus engine,
403403
// return directly without pushing any block back. In another word

consensus/clique/clique.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ func (c *Clique) Authorize(signer common.Address, signFn SignerFn) {
612612

613613
// Seal implements consensus.Engine, attempting to create a sealed block using
614614
// the local signing credentials.
615-
func (c *Clique) Seal(chain consensus.ChainHeaderReader, block *types.Block, profit *big.Int, results chan<- *types.Block, stop <-chan struct{}) error {
615+
func (c *Clique) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
616616
header := block.Header()
617617

618618
// Sealing the genesis block is not supported

consensus/consensus.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ type Engine interface {
104104
//
105105
// Note, the method returns immediately and will send the result async. More
106106
// than one result may also be returned depending on the consensus algorithm.
107-
Seal(chain ChainHeaderReader, block *types.Block, profit *big.Int, results chan<- *types.Block, stop <-chan struct{}) error
107+
Seal(chain ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error
108108

109109
// SealHash returns the hash of a block prior to it being sealed.
110110
SealHash(header *types.Header) common.Hash

consensus/ethash/ethash.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package ethash
1919

2020
import (
21-
"math/big"
2221
"time"
2322

2423
"github.com/ethereum/go-ethereum/consensus"
@@ -81,6 +80,6 @@ func (ethash *Ethash) APIs(chain consensus.ChainHeaderReader) []rpc.API {
8180
// Seal generates a new sealing request for the given input block and pushes
8281
// the result into the given channel. For the ethash engine, this method will
8382
// just panic as sealing is not supported anymore.
84-
func (ethash *Ethash) Seal(chain consensus.ChainHeaderReader, block *types.Block, profit *big.Int, results chan<- *types.Block, stop <-chan struct{}) error {
83+
func (ethash *Ethash) Seal(chain consensus.ChainHeaderReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
8584
panic("ethash (pow) sealing not supported any more")
8685
}

core/block_validator.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"github.com/ethereum/go-ethereum/consensus"
2424
"github.com/ethereum/go-ethereum/core/state"
2525
"github.com/ethereum/go-ethereum/core/types"
26-
"github.com/ethereum/go-ethereum/core/utils"
2726
"github.com/ethereum/go-ethereum/params"
2827
"github.com/ethereum/go-ethereum/trie"
2928
)
@@ -146,6 +145,28 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
146145
return nil
147146
}
148147

148+
// CalcGasLimit computes the gas limit of the next block after parent. It aims
149+
// to keep the baseline gas close to the provided target, and increase it towards
150+
// the target if the baseline gas is lower.
149151
func CalcGasLimit(parentGasLimit, desiredLimit uint64) uint64 {
150-
return utils.CalcGasLimit(parentGasLimit, desiredLimit)
152+
delta := parentGasLimit/params.GasLimitBoundDivisor - 1
153+
limit := parentGasLimit
154+
if desiredLimit < params.MinGasLimit {
155+
desiredLimit = params.MinGasLimit
156+
}
157+
// If we're outside our allowed gas range, we try to hone towards them
158+
if limit < desiredLimit {
159+
limit = parentGasLimit + delta
160+
if limit > desiredLimit {
161+
limit = desiredLimit
162+
}
163+
return limit
164+
}
165+
if limit > desiredLimit {
166+
limit = parentGasLimit - delta
167+
if limit < desiredLimit {
168+
limit = desiredLimit
169+
}
170+
}
171+
return limit
151172
}

core/blockchain.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import (
3838
"github.com/ethereum/go-ethereum/core/state"
3939
"github.com/ethereum/go-ethereum/core/state/snapshot"
4040
"github.com/ethereum/go-ethereum/core/types"
41-
"github.com/ethereum/go-ethereum/core/utils"
4241
"github.com/ethereum/go-ethereum/core/vm"
4342
"github.com/ethereum/go-ethereum/ethdb"
4443
"github.com/ethereum/go-ethereum/event"
@@ -2471,7 +2470,7 @@ func (bc *BlockChain) ValidatePayload(block *types.Block, feeRecipient common.Ad
24712470
return errors.New("parent not found")
24722471
}
24732472

2474-
calculatedGasLimit := utils.CalcGasLimit(parent.GasLimit, registeredGasLimit)
2473+
calculatedGasLimit := CalcGasLimit(parent.GasLimit, registeredGasLimit)
24752474
if calculatedGasLimit != header.GasLimit {
24762475
return errors.New("incorrect gas limit set")
24772476
}

0 commit comments

Comments
 (0)