mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
Fix worker tracing nil pointer exception (#899)
The `baseFee` can be `nil` in certain situations, the tracing must not use `baseFee` unless it was checked otherwise if such case happen, Go is going to panic.
This commit is contained in:
parent
f25364ddd2
commit
7e0e4c8905
1 changed files with 19 additions and 3 deletions
|
|
@ -32,6 +32,7 @@ import (
|
||||||
|
|
||||||
mapset "github.com/deckarep/golang-set"
|
mapset "github.com/deckarep/golang-set"
|
||||||
lru "github.com/hashicorp/golang-lru"
|
lru "github.com/hashicorp/golang-lru"
|
||||||
|
"github.com/holiman/uint256"
|
||||||
"go.opentelemetry.io/otel"
|
"go.opentelemetry.io/otel"
|
||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
|
|
@ -670,7 +671,12 @@ func (w *worker) mainLoop(ctx context.Context) {
|
||||||
txs[acc] = append(txs[acc], tx)
|
txs[acc] = append(txs[acc], tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
txset := types.NewTransactionsByPriceAndNonce(w.current.signer, txs, cmath.FromBig(w.current.header.BaseFee))
|
var baseFee *uint256.Int
|
||||||
|
if w.current.header.BaseFee != nil {
|
||||||
|
baseFee = cmath.FromBig(w.current.header.BaseFee)
|
||||||
|
}
|
||||||
|
|
||||||
|
txset := types.NewTransactionsByPriceAndNonce(w.current.signer, txs, baseFee)
|
||||||
tcount := w.current.tcount
|
tcount := w.current.tcount
|
||||||
|
|
||||||
//nolint:contextcheck
|
//nolint:contextcheck
|
||||||
|
|
@ -1509,7 +1515,12 @@ func (w *worker) fillTransactions(ctx context.Context, interrupt *int32, env *en
|
||||||
var txs *types.TransactionsByPriceAndNonce
|
var txs *types.TransactionsByPriceAndNonce
|
||||||
|
|
||||||
tracing.Exec(ctx, "", "worker.LocalTransactionsByPriceAndNonce", func(ctx context.Context, span trace.Span) {
|
tracing.Exec(ctx, "", "worker.LocalTransactionsByPriceAndNonce", func(ctx context.Context, span trace.Span) {
|
||||||
txs = types.NewTransactionsByPriceAndNonce(env.signer, localTxs, cmath.FromBig(env.header.BaseFee))
|
var baseFee *uint256.Int
|
||||||
|
if env.header.BaseFee != nil {
|
||||||
|
baseFee = cmath.FromBig(env.header.BaseFee)
|
||||||
|
}
|
||||||
|
|
||||||
|
txs = types.NewTransactionsByPriceAndNonce(env.signer, localTxs, baseFee)
|
||||||
|
|
||||||
tracing.SetAttributes(
|
tracing.SetAttributes(
|
||||||
span,
|
span,
|
||||||
|
|
@ -1532,7 +1543,12 @@ func (w *worker) fillTransactions(ctx context.Context, interrupt *int32, env *en
|
||||||
var txs *types.TransactionsByPriceAndNonce
|
var txs *types.TransactionsByPriceAndNonce
|
||||||
|
|
||||||
tracing.Exec(ctx, "", "worker.RemoteTransactionsByPriceAndNonce", func(ctx context.Context, span trace.Span) {
|
tracing.Exec(ctx, "", "worker.RemoteTransactionsByPriceAndNonce", func(ctx context.Context, span trace.Span) {
|
||||||
txs = types.NewTransactionsByPriceAndNonce(env.signer, remoteTxs, cmath.FromBig(env.header.BaseFee))
|
var baseFee *uint256.Int
|
||||||
|
if env.header.BaseFee != nil {
|
||||||
|
baseFee = cmath.FromBig(env.header.BaseFee)
|
||||||
|
}
|
||||||
|
|
||||||
|
txs = types.NewTransactionsByPriceAndNonce(env.signer, remoteTxs, baseFee)
|
||||||
|
|
||||||
tracing.SetAttributes(
|
tracing.SetAttributes(
|
||||||
span,
|
span,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue