eth/catalyst: prettier output on bad new payloads (#29259)
When we receive a bad NewPayload, we currently emit a lot of data to the logging facilities. This PR makes it so we print less data.
This commit is contained in:
parent
95715fdb03
commit
40cac1d0e2
@ -475,3 +475,14 @@ func (d *Decimal) UnmarshalJSON(input []byte) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PrettyBytes []byte
|
||||||
|
|
||||||
|
// TerminalString implements log.TerminalStringer, formatting a string for console
|
||||||
|
// output during logging.
|
||||||
|
func (b PrettyBytes) TerminalString() string {
|
||||||
|
if len(b) < 7 {
|
||||||
|
return fmt.Sprintf("%x", b)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%#x...%x (%dB)", b[:3], b[len(b)-3:], len(b))
|
||||||
|
}
|
||||||
|
@ -20,6 +20,7 @@ package catalyst
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -540,7 +541,33 @@ func (api *ConsensusAPI) newPayload(params engine.ExecutableData, versionedHashe
|
|||||||
log.Trace("Engine API request received", "method", "NewPayload", "number", params.Number, "hash", params.BlockHash)
|
log.Trace("Engine API request received", "method", "NewPayload", "number", params.Number, "hash", params.BlockHash)
|
||||||
block, err := engine.ExecutableDataToBlock(params, versionedHashes, beaconRoot)
|
block, err := engine.ExecutableDataToBlock(params, versionedHashes, beaconRoot)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warn("Invalid NewPayload params", "params", params, "error", err)
|
bgu := "nil"
|
||||||
|
if params.BlobGasUsed != nil {
|
||||||
|
bgu = strconv.Itoa(int(*params.BlobGasUsed))
|
||||||
|
}
|
||||||
|
ebg := "nil"
|
||||||
|
if params.BlobGasUsed != nil {
|
||||||
|
ebg = strconv.Itoa(int(*params.ExcessBlobGas))
|
||||||
|
}
|
||||||
|
log.Warn("Invalid NewPayload params",
|
||||||
|
"params.Number", params.Number,
|
||||||
|
"params.ParentHash", params.ParentHash,
|
||||||
|
"params.BlockHash", params.BlockHash,
|
||||||
|
"params.StateRoot", params.StateRoot,
|
||||||
|
"params.FeeRecipient", params.FeeRecipient,
|
||||||
|
"params.LogsBloom", common.PrettyBytes(params.LogsBloom),
|
||||||
|
"params.Random", params.Random,
|
||||||
|
"params.GasLimit", params.GasLimit,
|
||||||
|
"params.GasUsed", params.GasUsed,
|
||||||
|
"params.Timestamp", params.Timestamp,
|
||||||
|
"params.ExtraData", common.PrettyBytes(params.ExtraData),
|
||||||
|
"params.BaseFeePerGas", params.BaseFeePerGas,
|
||||||
|
"params.BlobGasUsed", bgu,
|
||||||
|
"params.ExcessBlobGas", ebg,
|
||||||
|
"len(params.Transactions)", len(params.Transactions),
|
||||||
|
"len(params.Withdrawals)", len(params.Withdrawals),
|
||||||
|
"beaconRoot", beaconRoot,
|
||||||
|
"error", err)
|
||||||
return api.invalid(err, nil), nil
|
return api.invalid(err, nil), nil
|
||||||
}
|
}
|
||||||
// Stash away the last update to warn the user if the beacon client goes offline
|
// Stash away the last update to warn the user if the beacon client goes offline
|
||||||
|
Loading…
Reference in New Issue
Block a user