Skip to content

Commit 18256c2

Browse files
authored
Merge pull request #341 from OffchainLabs/merge-v1.13.14
[NIT-2671] Merge v1.13.14
2 parents 777f7b9 + 227dc3f commit 18256c2

File tree

18 files changed

+108
-69
lines changed

18 files changed

+108
-69
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 {
@@ -102,15 +108,17 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
102108
return err
103109
}
104110
if tx.Gas() < intrGas {
105-
return fmt.Errorf("%w: needed %v, allowed %v", core.ErrIntrinsicGas, intrGas, tx.Gas())
111+
return fmt.Errorf("%w: gas %v, minimum needed %v", core.ErrIntrinsicGas, tx.Gas(), intrGas)
106112
}
107-
// Ensure the gasprice is high enough to cover the requirement of the calling
108-
// pool and/or block producer
113+
// Ensure the gasprice is high enough to cover the requirement of the calling pool
109114
if tx.GasTipCapIntCmp(opts.MinTip) < 0 {
110-
return fmt.Errorf("%w: tip needed %v, tip permitted %v", ErrUnderpriced, opts.MinTip, tx.GasTipCap())
115+
return fmt.Errorf("%w: gas tip cap %v, minimum needed %v", ErrUnderpriced, tx.GasTipCap(), opts.MinTip)
111116
}
112-
// Ensure blob transactions have valid commitments
113117
if tx.Type() == types.BlobTxType {
118+
// Ensure the blob fee cap satisfies the minimum blob gas price
119+
if tx.BlobGasFeeCapIntCmp(blobTxMinBlobGasPrice) < 0 {
120+
return fmt.Errorf("%w: blob fee cap %v, minimum needed %v", ErrUnderpriced, tx.BlobGasFeeCap(), blobTxMinBlobGasPrice)
121+
}
114122
sidecar := tx.BlobTxSidecar()
115123
if sidecar == nil {
116124
return fmt.Errorf("missing sidecar in blob transaction")
@@ -124,6 +132,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types
124132
if len(hashes) > params.MaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob {
125133
return fmt.Errorf("too many blobs in transaction: have %d, permitted %d", len(hashes), params.MaxBlobGasPerBlock/params.BlobTxBlobGasPerBlob)
126134
}
135+
// Ensure commitments, proofs and hashes are valid
127136
if err := validateBlobSidecar(hashes, sidecar); err != nil {
128137
return err
129138
}

eth/catalyst/api.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ func (api *ConsensusAPI) NewPayloadV1(params engine.ExecutableData) (engine.Payl
489489
func (api *ConsensusAPI) NewPayloadV2(params engine.ExecutableData) (engine.PayloadStatusV1, error) {
490490
arbosVersion := types.DeserializeHeaderExtraInformation(api.eth.BlockChain().CurrentHeader()).ArbOSFormatVersion
491491
if api.eth.BlockChain().Config().IsCancun(api.eth.BlockChain().Config().LondonBlock, params.Timestamp, arbosVersion) {
492-
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("can't use new payload v2 post-shanghai"))
492+
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("can't use newPayloadV2 post-cancun"))
493493
}
494494
if api.eth.BlockChain().Config().LatestFork(params.Timestamp, arbosVersion) == forks.Shanghai {
495495
if params.Withdrawals == nil {
@@ -504,7 +504,7 @@ func (api *ConsensusAPI) NewPayloadV2(params engine.ExecutableData) (engine.Payl
504504
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("non-nil excessBlobGas pre-cancun"))
505505
}
506506
if params.BlobGasUsed != nil {
507-
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("non-nil params.BlobGasUsed pre-cancun"))
507+
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("non-nil blobGasUsed pre-cancun"))
508508
}
509509
return api.newPayload(params, nil, nil)
510510
}
@@ -519,14 +519,14 @@ func (api *ConsensusAPI) NewPayloadV3(params engine.ExecutableData, versionedHas
519519
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil excessBlobGas post-cancun"))
520520
}
521521
if params.BlobGasUsed == nil {
522-
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil params.BlobGasUsed post-cancun"))
522+
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil blobGasUsed post-cancun"))
523523
}
524524

525525
if versionedHashes == nil {
526526
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil versionedHashes post-cancun"))
527527
}
528528
if beaconRoot == nil {
529-
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil parentBeaconBlockRoot post-cancun"))
529+
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("nil beaconRoot post-cancun"))
530530
}
531531

532532
if api.eth.BlockChain().Config().LatestFork(params.Timestamp, arbosVersion) != forks.Cancun {
@@ -881,8 +881,7 @@ func getBody(block *types.Block) *engine.ExecutionPayloadBodyV1 {
881881
)
882882

883883
for j, tx := range body.Transactions {
884-
data, _ := tx.MarshalBinary()
885-
txs[j] = hexutil.Bytes(data)
884+
txs[j], _ = tx.MarshalBinary()
886885
}
887886

888887
// 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/native/call.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func (t *callTracer) CaptureState(pc uint64, op vm.OpCode, gas, cost uint64, sco
175175
return
176176
}
177177
// Avoid processing nested calls when only caring about top call
178-
if t.config.OnlyTopCall && depth > 0 {
178+
if t.config.OnlyTopCall && depth > 1 {
179179
return
180180
}
181181
// Skip if tracing was interrupted

internal/ethapi/api.go

+6-11
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ func (s *PersonalAccountAPI) signTransaction(ctx context.Context, args *Transact
441441
return nil, err
442442
}
443443
// Set some sanity defaults and terminate on failure
444-
if err := args.setDefaults(ctx, s.b); err != nil {
444+
if err := args.setDefaults(ctx, s.b, false); err != nil {
445445
return nil, err
446446
}
447447
// Assemble the transaction and sign with the wallet
@@ -1702,14 +1702,9 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
17021702
if db == nil || err != nil {
17031703
return nil, 0, nil, err
17041704
}
1705-
// If the gas amount is not set, default to RPC gas cap.
1706-
if args.Gas == nil {
1707-
tmp := hexutil.Uint64(b.RPCGasCap())
1708-
args.Gas = &tmp
1709-
}
17101705

17111706
// Ensure any missing fields are filled, extract the recipient and input data
1712-
if err := args.setDefaults(ctx, b); err != nil {
1707+
if err := args.setDefaults(ctx, b, true); err != nil {
17131708
return nil, 0, nil, err
17141709
}
17151710
var to common.Address
@@ -2038,7 +2033,7 @@ func (s *TransactionAPI) SendTransaction(ctx context.Context, args TransactionAr
20382033
}
20392034

20402035
// Set some sanity defaults and terminate on failure
2041-
if err := args.setDefaults(ctx, s.b); err != nil {
2036+
if err := args.setDefaults(ctx, s.b, false); err != nil {
20422037
return common.Hash{}, err
20432038
}
20442039
// Assemble the transaction and sign with the wallet
@@ -2058,7 +2053,7 @@ func (s *TransactionAPI) FillTransaction(ctx context.Context, args TransactionAr
20582053
args.blobSidecarAllowed = true
20592054

20602055
// Set some sanity defaults and terminate on failure
2061-
if err := args.setDefaults(ctx, s.b); err != nil {
2056+
if err := args.setDefaults(ctx, s.b, false); err != nil {
20622057
return nil, err
20632058
}
20642059
// Assemble the transaction and obtain rlp
@@ -2126,7 +2121,7 @@ func (s *TransactionAPI) SignTransaction(ctx context.Context, args TransactionAr
21262121
if args.Nonce == nil {
21272122
return nil, errors.New("nonce not specified")
21282123
}
2129-
if err := args.setDefaults(ctx, s.b); err != nil {
2124+
if err := args.setDefaults(ctx, s.b, false); err != nil {
21302125
return nil, err
21312126
}
21322127
// Before actually sign the transaction, ensure the transaction fee is reasonable.
@@ -2185,7 +2180,7 @@ func (s *TransactionAPI) Resend(ctx context.Context, sendArgs TransactionArgs, g
21852180
if sendArgs.Nonce == nil {
21862181
return common.Hash{}, errors.New("missing transaction nonce in transaction spec")
21872182
}
2188-
if err := sendArgs.setDefaults(ctx, s.b); err != nil {
2183+
if err := sendArgs.setDefaults(ctx, s.b, false); err != nil {
21892184
return common.Hash{}, err
21902185
}
21912186
matchTx := sendArgs.toTransaction()

internal/ethapi/transaction_args.go

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

100100
// setDefaults fills in default values for unspecified tx fields.
101-
func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
101+
func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend, skipGasEstimation bool) error {
102102
if err := args.setBlobTxSidecar(ctx); err != nil {
103103
return err
104104
}
@@ -138,30 +138,37 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
138138
}
139139
}
140140

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

167174
// 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
)

p2p/server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -914,13 +914,13 @@ func (srv *Server) checkInboundConn(remoteIP net.IP) error {
914914
}
915915
// Reject connections that do not match NetRestrict.
916916
if srv.NetRestrict != nil && !srv.NetRestrict.Contains(remoteIP) {
917-
return fmt.Errorf("not in netrestrict list")
917+
return errors.New("not in netrestrict list")
918918
}
919919
// Reject Internet peers that try too often.
920920
now := srv.clock.Now()
921921
srv.inboundHistory.expire(now, nil)
922922
if !netutil.IsLAN(remoteIP) && srv.inboundHistory.contains(remoteIP.String()) {
923-
return fmt.Errorf("too many attempts")
923+
return errors.New("too many attempts")
924924
}
925925
srv.inboundHistory.add(remoteIP.String(), now.Add(inboundThrottleTime))
926926
return nil

p2p/transport.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package p2p
1919
import (
2020
"bytes"
2121
"crypto/ecdsa"
22+
"errors"
2223
"fmt"
2324
"io"
2425
"net"
@@ -157,7 +158,7 @@ func readProtocolHandshake(rw MsgReader) (*protoHandshake, error) {
157158
return nil, err
158159
}
159160
if msg.Size > baseProtocolMaxMsgSize {
160-
return nil, fmt.Errorf("message too big")
161+
return nil, errors.New("message too big")
161162
}
162163
if msg.Code == discMsg {
163164
// Disconnect before protocol handshake is valid according to the

0 commit comments

Comments
 (0)