Skip to content

Commit 2bd6bd0

Browse files
committed
Merge branch 'master' into release/1.13
2 parents 7f131dc + 9038ba6 commit 2bd6bd0

File tree

19 files changed

+113
-74
lines changed

19 files changed

+113
-74
lines changed

cmd/clef/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ There are a couple of implementation for a UI. We'll try to keep this list up to
916916

917917
| Name | Repo | UI type| No external resources| Blocky support| Verifies permissions | Hash information | No secondary storage | Statically linked| Can modify parameters|
918918
| ---- | ---- | -------| ---- | ---- | ---- |---- | ---- | ---- | ---- |
919-
| QtSigner| https://github.com/holiman/qtsigner/| Python3/QT-based| :+1:| :+1:| :+1:| :+1:| :+1:| :x: | :+1: (partially)|
920-
| GtkSigner| https://github.com/holiman/gtksigner| Python3/GTK-based| :+1:| :x:| :x:| :+1:| :+1:| :x: | :x: |
921-
| Frame | https://github.com/floating/frame/commits/go-signer| Electron-based| :x:| :x:| :x:| :x:| ?| :x: | :x: |
922-
| Clef UI| https://github.com/ethereum/clef-ui| Golang/QT-based| :+1:| :+1:| :x:| :+1:| :+1:| :x: | :+1: (approve tx only)|
919+
| QtSigner| https://github.com/holiman/qtsigner/ | Python3/QT-based| :+1:| :+1:| :+1:| :+1:| :+1:| :x: | :+1: (partially)|
920+
| GtkSigner| https://github.com/holiman/gtksigner | Python3/GTK-based| :+1:| :x:| :x:| :+1:| :+1:| :x: | :x: |
921+
| Frame | https://github.com/floating/frame/commits/go-signer | Electron-based| :x:| :x:| :x:| :x:| ?| :x: | :x: |
922+
| Clef UI| https://github.com/ethereum/clef-ui | Golang/QT-based| :+1:| :+1:| :x:| :+1:| :+1:| :x: | :+1: (approve tx only)|

core/txpool/blobpool/blobpool.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ func (p *BlobPool) Init(gasTip uint64, head *types.Header, reserve txpool.Addres
402402
}
403403
var (
404404
basefee = uint256.MustFromBig(eip1559.CalcBaseFee(p.chain.Config(), p.head))
405-
blobfee = uint256.MustFromBig(big.NewInt(params.BlobTxMinBlobGasprice))
405+
blobfee = uint256.NewInt(params.BlobTxMinBlobGasprice)
406406
)
407407
if p.head.ExcessBlobGas != nil {
408408
blobfee = uint256.MustFromBig(eip4844.CalcBlobFee(*p.head.ExcessBlobGas))

core/txpool/blobpool/blobpool_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,24 @@ func TestAdd(t *testing.T) {
12281228
},
12291229
},
12301230
},
1231+
// Blob transactions that don't meet the min blob gas price should be rejected
1232+
{
1233+
seeds: map[string]seed{
1234+
"alice": {balance: 10000000},
1235+
},
1236+
adds: []addtx{
1237+
{ // New account, no previous txs, nonce 0, but blob fee cap too low
1238+
from: "alice",
1239+
tx: makeUnsignedTx(0, 1, 1, 0),
1240+
err: txpool.ErrUnderpriced,
1241+
},
1242+
{ // Same as above but blob fee cap equals minimum, should be accepted
1243+
from: "alice",
1244+
tx: makeUnsignedTx(0, 1, 1, params.BlobTxMinBlobGasprice),
1245+
err: nil,
1246+
},
1247+
},
1248+
},
12311249
}
12321250
for i, tt := range tests {
12331251
// Create a temporary folder for the persistent backend

core/txpool/blobpool/config.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ type Config struct {
3030
// DefaultConfig contains the default configurations for the transaction pool.
3131
var DefaultConfig = Config{
3232
Datadir: "blobpool",
33-
Datacap: 10 * 1024 * 1024 * 1024,
34-
PriceBump: 100, // either have patience or be aggressive, no mushy ground
33+
Datacap: 10 * 1024 * 1024 * 1024 / 4, // TODO(karalabe): /4 handicap for rollout, gradually bump back up to 10GB
34+
PriceBump: 100, // either have patience or be aggressive, no mushy ground
3535
}
3636

3737
// sanitize checks the provided user configurations and changes anything that's

core/txpool/errors.go

+6
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,10 @@ var (
5454
// ErrFutureReplacePending is returned if a future transaction replaces a pending
5555
// one. Future transactions should only be able to replace other future transactions.
5656
ErrFutureReplacePending = errors.New("future transaction tries to replace pending")
57+
58+
// ErrAlreadyReserved is returned if the sender address has a pending transaction
59+
// in a different subpool. For example, this error is returned in response to any
60+
// input transaction of non-blob type when a blob transaction from this sender
61+
// remains pending (and vice-versa).
62+
ErrAlreadyReserved = errors.New("address already reserved")
5763
)

core/txpool/legacypool/journal.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,12 @@ func (journal *journal) rotate(all map[common.Address]types.Transactions) error
164164
return err
165165
}
166166
journal.writer = sink
167-
log.Info("Regenerated local transaction journal", "transactions", journaled, "accounts", len(all))
167+
168+
logger := log.Info
169+
if len(all) == 0 {
170+
logger = log.Debug
171+
}
172+
logger("Regenerated local transaction journal", "transactions", journaled, "accounts", len(all))
168173

169174
return nil
170175
}

core/txpool/txpool.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (p *TxPool) reserver(id int, subpool SubPool) AddressReserver {
122122
log.Error("pool attempted to reserve already-owned address", "address", addr)
123123
return nil // Ignore fault to give the pool a chance to recover while the bug gets fixed
124124
}
125-
return errors.New("address already reserved")
125+
return ErrAlreadyReserved
126126
}
127127
p.reservations[addr] = subpool
128128
if metrics.Enabled {

core/txpool/validation.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ import (
3030
"github.com/ethereum/go-ethereum/params"
3131
)
3232

33+
var (
34+
// blobTxMinBlobGasPrice is the big.Int version of the configured protocol
35+
// parameter to avoid constucting a new big integer for every transaction.
36+
blobTxMinBlobGasPrice = big.NewInt(params.BlobTxMinBlobGasprice)
37+
)
38+
3339
// ValidationOptions define certain differences between transaction validation
3440
// across the different pools without having to duplicate those checks.
3541
type ValidationOptions struct {
@@ -101,15 +107,17 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
101107
return err
102108
}
103109
if tx.Gas() < intrGas {
104-
return fmt.Errorf("%w: needed %v, allowed %v", core.ErrIntrinsicGas, intrGas, tx.Gas())
110+
return fmt.Errorf("%w: gas %v, minimum needed %v", core.ErrIntrinsicGas, tx.Gas(), intrGas)
105111
}
106-
// Ensure the gasprice is high enough to cover the requirement of the calling
107-
// pool and/or block producer
112+
// Ensure the gasprice is high enough to cover the requirement of the calling pool
108113
if tx.GasTipCapIntCmp(opts.MinTip) < 0 {
109-
return fmt.Errorf("%w: tip needed %v, tip permitted %v", ErrUnderpriced, opts.MinTip, tx.GasTipCap())
114+
return fmt.Errorf("%w: gas tip cap %v, minimum needed %v", ErrUnderpriced, tx.GasTipCap(), opts.MinTip)
110115
}
111-
// Ensure blob transactions have valid commitments
112116
if tx.Type() == types.BlobTxType {
117+
// Ensure the blob fee cap satisfies the minimum blob gas price
118+
if tx.BlobGasFeeCapIntCmp(blobTxMinBlobGasPrice) < 0 {
119+
return fmt.Errorf("%w: blob fee cap %v, minimum needed %v", ErrUnderpriced, tx.BlobGasFeeCap(), blobTxMinBlobGasPrice)
120+
}
113121
sidecar := tx.BlobTxSidecar()
114122
if sidecar == nil {
115123
return fmt.Errorf("missing sidecar in blob transaction")
@@ -123,6 +131,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
123131
if len(hashes) > params.MaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob {
124132
return fmt.Errorf("too many blobs in transaction: have %d, permitted %d", len(hashes), params.MaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob)
125133
}
134+
// Ensure commitments, proofs and hashes are valid
126135
if err := validateBlobSidecar(hashes, sidecar); err != nil {
127136
return err
128137
}

eth/catalyst/api.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ func (api *ConsensusAPI) NewPayloadV1(params engine.ExecutableData) (engine.Payl
488488
// NewPayloadV2 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
489489
func (api *ConsensusAPI) NewPayloadV2(params engine.ExecutableData) (engine.PayloadStatusV1, error) {
490490
if api.eth.BlockChain().Config().IsCancun(api.eth.BlockChain().Config().LondonBlock, params.Timestamp) {
491-
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("can't use new payload v2 post-shanghai"))
491+
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("can't use newPayloadV2 post-cancun"))
492492
}
493493
if api.eth.BlockChain().Config().LatestFork(params.Timestamp) == forks.Shanghai {
494494
if params.Withdrawals == nil {
@@ -503,7 +503,7 @@ func (api *ConsensusAPI) NewPayloadV2(params engine.ExecutableData) (engine.Payl
503503
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("non-nil excessBlobGas pre-cancun"))
504504
}
505505
if params.BlobGasUsed != nil {
506-
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("non-nil params.BlobGasUsed pre-cancun"))
506+
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("non-nil blobGasUsed pre-cancun"))
507507
}
508508
return api.newPayload(params, nil, nil)
509509
}
@@ -517,14 +517,14 @@ func (api *ConsensusAPI) NewPayloadV3(params engine.ExecutableData, versionedHas
517517
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil excessBlobGas post-cancun"))
518518
}
519519
if params.BlobGasUsed == nil {
520-
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil params.BlobGasUsed post-cancun"))
520+
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil blobGasUsed post-cancun"))
521521
}
522522

523523
if versionedHashes == nil {
524524
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil versionedHashes post-cancun"))
525525
}
526526
if beaconRoot == nil {
527-
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil parentBeaconBlockRoot post-cancun"))
527+
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil beaconRoot post-cancun"))
528528
}
529529

530530
if api.eth.BlockChain().Config().LatestFork(params.Timestamp) != forks.Cancun {
@@ -879,8 +879,7 @@ func getBody(block *types.Block) *engine.ExecutionPayloadBodyV1 {
879879
)
880880

881881
for j, tx := range body.Transactions {
882-
data, _ := tx.MarshalBinary()
883-
txs[j] = hexutil.Bytes(data)
882+
txs[j], _ = tx.MarshalBinary()
884883
}
885884

886885
// Post-shanghai withdrawals MUST be set to empty slice instead of nil

eth/catalyst/api_test.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,8 @@ func TestInvalidPayloadTimestamp(t *testing.T) {
262262
{0, true},
263263
{parent.Time, true},
264264
{parent.Time - 1, true},
265-
266-
// TODO (MariusVanDerWijden) following tests are currently broken,
267-
// fixed in upcoming merge-kiln-v2 pr
268-
//{parent.Time() + 1, false},
269-
//{uint64(time.Now().Unix()) + uint64(time.Minute), false},
265+
{parent.Time + 1, false},
266+
{uint64(time.Now().Unix()) + uint64(time.Minute), false},
270267
}
271268

272269
for i, test := range tests {

eth/tracers/api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
919919
config.BlockOverrides.Apply(&vmctx)
920920
}
921921
// Execute the trace
922-
msg, err := args.ToMessage(api.backend.RPCGasCap(), block.BaseFee())
922+
msg, err := args.ToMessage(api.backend.RPCGasCap(), vmctx.BaseFee)
923923
if err != nil {
924924
return nil, err
925925
}

eth/tracers/native/call.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func (t *callTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, sco
161161
return
162162
}
163163
// Avoid processing nested calls when only caring about top call
164-
if t.config.OnlyTopCall && depth > 0 {
164+
if t.config.OnlyTopCall && depth > 1 {
165165
return
166166
}
167167
// Skip if tracing was interrupted

internal/ethapi/api.go

+10-15
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func (s *PersonalAccountAPI) signTransaction(ctx context.Context, args *Transact
453453
return nil, err
454454
}
455455
// Set some sanity defaults and terminate on failure
456-
if err := args.setDefaults(ctx, s.b); err != nil {
456+
if err := args.setDefaults(ctx, s.b, false); err != nil {
457457
return nil, err
458458
}
459459
// Assemble the transaction and sign with the wallet
@@ -1093,14 +1093,14 @@ func doCall(ctx context.Context, b Backend, args TransactionArgs, state *state.S
10931093
defer cancel()
10941094

10951095
// Get a new instance of the EVM.
1096-
msg, err := args.ToMessage(globalGasCap, header.BaseFee)
1097-
if err != nil {
1098-
return nil, err
1099-
}
11001096
blockCtx := core.NewEVMBlockContext(header, NewChainContext(ctx, b), nil)
11011097
if blockOverrides != nil {
11021098
blockOverrides.Apply(&blockCtx)
11031099
}
1100+
msg, err := args.ToMessage(globalGasCap, blockCtx.BaseFee)
1101+
if err != nil {
1102+
return nil, err
1103+
}
11041104
evm := b.GetEVM(ctx, msg, state, header, &vm.Config{NoBaseFee: true}, &blockCtx)
11051105

11061106
// Wait for the context to be done and cancel the evm. Even if the
@@ -1485,14 +1485,9 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
14851485
if db == nil || err != nil {
14861486
return nil, 0, nil, err
14871487
}
1488-
// If the gas amount is not set, default to RPC gas cap.
1489-
if args.Gas == nil {
1490-
tmp := hexutil.Uint64(b.RPCGasCap())
1491-
args.Gas = &tmp
1492-
}
14931488

14941489
// Ensure any missing fields are filled, extract the recipient and input data
1495-
if err := args.setDefaults(ctx, b); err != nil {
1490+
if err := args.setDefaults(ctx, b, true); err != nil {
14961491
return nil, 0, nil, err
14971492
}
14981493
var to common.Address
@@ -1795,7 +1790,7 @@ func (s *TransactionAPI) SendTransaction(ctx context.Context, args TransactionAr
17951790
}
17961791

17971792
// Set some sanity defaults and terminate on failure
1798-
if err := args.setDefaults(ctx, s.b); err != nil {
1793+
if err := args.setDefaults(ctx, s.b, false); err != nil {
17991794
return common.Hash{}, err
18001795
}
18011796
// Assemble the transaction and sign with the wallet
@@ -1815,7 +1810,7 @@ func (s *TransactionAPI) FillTransaction(ctx context.Context, args TransactionAr
18151810
args.blobSidecarAllowed = true
18161811

18171812
// Set some sanity defaults and terminate on failure
1818-
if err := args.setDefaults(ctx, s.b); err != nil {
1813+
if err := args.setDefaults(ctx, s.b, false); err != nil {
18191814
return nil, err
18201815
}
18211816
// Assemble the transaction and obtain rlp
@@ -1884,7 +1879,7 @@ func (s *TransactionAPI) SignTransaction(ctx context.Context, args TransactionAr
18841879
if args.Nonce == nil {
18851880
return nil, errors.New("nonce not specified")
18861881
}
1887-
if err := args.setDefaults(ctx, s.b); err != nil {
1882+
if err := args.setDefaults(ctx, s.b, false); err != nil {
18881883
return nil, err
18891884
}
18901885
// Before actually sign the transaction, ensure the transaction fee is reasonable.
@@ -1933,7 +1928,7 @@ func (s *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs, g
19331928
if sendArgs.Nonce == nil {
19341929
return common.Hash{}, errors.New("missing transaction nonce in transaction spec")
19351930
}
1936-
if err := sendArgs.setDefaults(ctx, s.b); err != nil {
1931+
if err := sendArgs.setDefaults(ctx, s.b, false); err != nil {
19371932
return common.Hash{}, err
19381933
}
19391934
matchTx := sendArgs.toTransaction()

internal/ethapi/transaction_args.go

+30-23
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (args *TransactionArgs) data() []byte {
9696
}
9797

9898
// setDefaults fills in default values for unspecified tx fields.
99-
func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
99+
func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend, skipGasEstimation bool) error {
100100
if err := args.setBlobTxSidecar(ctx, b); err != nil {
101101
return err
102102
}
@@ -136,30 +136,37 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
136136
}
137137
}
138138

139-
// Estimate the gas usage if necessary.
140139
if args.Gas == nil {
141-
// These fields are immutable during the estimation, safe to
142-
// pass the pointer directly.
143-
data := args.data()
144-
callArgs := TransactionArgs{
145-
From: args.From,
146-
To: args.To,
147-
GasPrice: args.GasPrice,
148-
MaxFeePerGas: args.MaxFeePerGas,
149-
MaxPriorityFeePerGas: args.MaxPriorityFeePerGas,
150-
Value: args.Value,
151-
Data: (*hexutil.Bytes)(&data),
152-
AccessList: args.AccessList,
153-
BlobFeeCap: args.BlobFeeCap,
154-
BlobHashes: args.BlobHashes,
155-
}
156-
latestBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
157-
estimated, err := DoEstimateGas(ctx, b, callArgs, latestBlockNr, nil, b.RPCGasCap())
158-
if err != nil {
159-
return err
140+
if skipGasEstimation { // Skip gas usage estimation if a precise gas limit is not critical, e.g., in non-transaction calls.
141+
gas := hexutil.Uint64(b.RPCGasCap())
142+
if gas == 0 {
143+
gas = hexutil.Uint64(math.MaxUint64 / 2)
144+
}
145+
args.Gas = &gas
146+
} else { // Estimate the gas usage otherwise.
147+
// These fields are immutable during the estimation, safe to
148+
// pass the pointer directly.
149+
data := args.data()
150+
callArgs := TransactionArgs{
151+
From: args.From,
152+
To: args.To,
153+
GasPrice: args.GasPrice,
154+
MaxFeePerGas: args.MaxFeePerGas,
155+
MaxPriorityFeePerGas: args.MaxPriorityFeePerGas,
156+
Value: args.Value,
157+
Data: (*hexutil.Bytes)(&data),
158+
AccessList: args.AccessList,
159+
BlobFeeCap: args.BlobFeeCap,
160+
BlobHashes: args.BlobHashes,
161+
}
162+
latestBlockNr := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
163+
estimated, err := DoEstimateGas(ctx, b, callArgs, latestBlockNr, nil, b.RPCGasCap())
164+
if err != nil {
165+
return err
166+
}
167+
args.Gas = &estimated
168+
log.Trace("Estimate gas usage automatically", "gas", args.Gas)
160169
}
161-
args.Gas = &estimated
162-
log.Trace("Estimate gas usage automatically", "gas", args.Gas)
163170
}
164171

165172
// If chain id is provided, ensure it matches the local chain id. Otherwise, set the local

log/logger_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package log
22

33
import (
44
"bytes"
5+
"errors"
56
"fmt"
67
"io"
78
"math/big"
@@ -77,7 +78,7 @@ func benchmarkLogger(b *testing.B, l Logger) {
7778
tt = time.Now()
7879
bigint = big.NewInt(100)
7980
nilbig *big.Int
80-
err = fmt.Errorf("Oh nooes it's crap")
81+
err = errors.New("Oh nooes it's crap")
8182
)
8283
b.ReportAllocs()
8384
b.ResetTimer()
@@ -106,7 +107,7 @@ func TestLoggerOutput(t *testing.T) {
106107
tt = time.Time{}
107108
bigint = big.NewInt(100)
108109
nilbig *big.Int
109-
err = fmt.Errorf("Oh nooes it's crap")
110+
err = errors.New("Oh nooes it's crap")
110111
smallUint = uint256.NewInt(500_000)
111112
bigUint = &uint256.Int{0xff, 0xff, 0xff, 0xff}
112113
)

0 commit comments

Comments
 (0)