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

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
}

core/gen_genesis.go

Lines changed: 28 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/txpool/legacypool/legacypool.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,9 +1332,7 @@ func (pool *LegacyPool) runReorg(done chan struct{}, reset *txpoolResetRequest,
13321332
if len(events) > 0 {
13331333
var txs []*types.Transaction
13341334
for _, set := range events {
1335-
for _, tx := range set.Flatten() {
1336-
txs = append(txs, tx)
1337-
}
1335+
txs = append(txs, set.Flatten()...)
13381336
}
13391337
pool.txFeed.Send(core.NewTxsEvent{Txs: txs})
13401338
}

core/txpool/validation.go

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ type ValidationOptions struct {
3838
Accept uint8 // Bitmap of transaction types that should be accepted for the calling pool
3939
MaxSize uint64 // Maximum size of a transaction that the caller can meaningfully handle
4040
MinTip *big.Int // Minimum gas tip needed to allow a transaction into the caller pool
41-
42-
sbundle bool // Whether the transaction pool is from sbundle
4341
}
4442

4543
// ValidateTransaction is a helper method to check whether a transaction is valid
@@ -65,8 +63,8 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
6563
if !opts.Config.IsLondon(head.Number) && tx.Type() == types.DynamicFeeTxType {
6664
return fmt.Errorf("%w: type %d rejected, pool not yet in London", core.ErrTxTypeNotSupported, tx.Type())
6765
}
68-
if opts.Config.CancunTime == nil && tx.Type() == types.BlobTxType {
69-
return fmt.Errorf("%w: type %d rejected, pool not configured for Cancun", core.ErrTxTypeNotSupported, tx.Type())
66+
if !opts.Config.IsCancun(head.Number, head.Time) && tx.Type() == types.BlobTxType {
67+
return fmt.Errorf("%w: type %d rejected, pool not yet in Cancun", core.ErrTxTypeNotSupported, tx.Type())
7068
}
7169
// Check whether the init code size has been exceeded
7270
if opts.Config.IsShanghai(head.Number, head.Time) && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize {
@@ -96,21 +94,19 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
9694
if _, err := types.Sender(signer, tx); err != nil {
9795
return ErrInvalidSender
9896
}
99-
if !opts.sbundle {
100-
// Ensure the transaction has more gas than the bare minimum needed to cover
101-
// the transaction metadata
102-
intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, opts.Config.IsIstanbul(head.Number), opts.Config.IsShanghai(head.Number, head.Time))
103-
if err != nil {
104-
return err
105-
}
106-
if tx.Gas() < intrGas {
107-
return fmt.Errorf("%w: needed %v, allowed %v", core.ErrIntrinsicGas, intrGas, tx.Gas())
108-
}
109-
// Ensure the gasprice is high enough to cover the requirement of the calling
110-
// pool and/or block producer
111-
if tx.GasTipCapIntCmp(opts.MinTip) < 0 {
112-
return fmt.Errorf("%w: tip needed %v, tip permitted %v", ErrUnderpriced, opts.MinTip, tx.GasTipCap())
113-
}
97+
// Ensure the transaction has more gas than the bare minimum needed to cover
98+
// the transaction metadata
99+
intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, opts.Config.IsIstanbul(head.Number), opts.Config.IsShanghai(head.Number, head.Time))
100+
if err != nil {
101+
return err
102+
}
103+
if tx.Gas() < intrGas {
104+
return fmt.Errorf("%w: needed %v, allowed %v", core.ErrIntrinsicGas, intrGas, tx.Gas())
105+
}
106+
// Ensure the gasprice is high enough to cover the requirement of the calling
107+
// pool and/or block producer
108+
if tx.GasTipCapIntCmp(opts.MinTip) < 0 {
109+
return fmt.Errorf("%w: tip needed %v, tip permitted %v", ErrUnderpriced, opts.MinTip, tx.GasTipCap())
114110
}
115111
// Ensure blob transactions have valid commitments
116112
if tx.Type() == types.BlobTxType {

core/types/gen_account_rlp.go

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/types/gen_header_rlp.go

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/types/gen_log_rlp.go

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/types/gen_withdrawal_rlp.go

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

core/utils/gas_limit.go

Lines changed: 0 additions & 29 deletions
This file was deleted.

internal/ethapi/api.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1761,7 +1761,8 @@ func SubmitTransaction(ctx context.Context, b Backend, tx *types.Transaction, pr
17611761
return common.Hash{}, err
17621762
}
17631763
// Print a log with full tx details for manual investigations and interventions
1764-
signer := types.LatestSigner(b.ChainConfig())
1764+
head := b.CurrentBlock()
1765+
signer := types.MakeSigner(b.ChainConfig(), head.Number, head.Time)
17651766
from, err := types.Sender(signer, tx)
17661767
if err != nil {
17671768
return common.Hash{}, err

internal/ethapi/transaction_args.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) erro
204204
}
205205
return nil // No need to set anything, user already set MaxFeePerGas and MaxPriorityFeePerGas
206206
}
207+
207208
// Sanity check the non-EIP-1559 fee parameters.
208209
isLondon := b.ChainConfig().IsLondon(head.Number)
209210
if args.GasPrice != nil && !eip1559ParamsSet {

miner/sbundle_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,12 @@ func TestSBundles(t *testing.T) {
461461
expectedKickbackReceivers = make([]common.Address, 0, len(tt.ExtractedRefunds))
462462
)
463463
for _, refund := range tt.ExtractedRefunds {
464-
refundBeforSplit := common.PercentOf(refund.Value.ToInt(), refund.Percent)
464+
refundBeforeSplit := common.PercentOf((*uint256.Int)(refund.Value), refund.Percent)
465465

466466
fees := new(uint256.Int).Mul(uint256.MustFromBig(testSuite.Header.BaseFee), core.SbundlePayoutMaxCost)
467467
fees.Mul(fees, uint256.NewInt(uint64(len(refund.RefundSplit))))
468468
for recipient, split := range refund.RefundSplit {
469-
value := new(uint256.Int).Sub(refundBeforSplit, fees)
469+
value := new(uint256.Int).Sub(refundBeforeSplit, fees)
470470
value = common.PercentOf(value, split)
471471
expectedKickbackValues = append(expectedKickbackValues, value)
472472
expectedKickbackReceivers = append(expectedKickbackReceivers, recipient)

0 commit comments

Comments
 (0)