eth/catalyst: add helper for ExecutableData telemetry attributes

This commit is contained in:
jonny rhea 2026-01-16 13:38:54 -06:00
parent b616d63c55
commit 2c270e2294
2 changed files with 16 additions and 53 deletions

View file

@ -626,14 +626,18 @@ func (api *ConsensusAPI) getBlobs(hashes []common.Hash, v2 bool) ([]*engine.Blob
// Helper for NewPayload* methods.
var invalidStatus = engine.PayloadStatusV1{Status: engine.INVALID}
// NewPayloadV1 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
func (api *ConsensusAPI) NewPayloadV1(ctx context.Context, params engine.ExecutableData) (result engine.PayloadStatusV1, err error) {
attrs := []telemetry.Attribute{
// executableDataAttrs returns telemetry attributes for an ExecutableData payload.
func executableDataAttrs(params engine.ExecutableData) []telemetry.Attribute {
return []telemetry.Attribute{
telemetry.Int64Attribute("block.number", int64(params.Number)),
telemetry.StringAttribute("block.hash", params.BlockHash.Hex()),
telemetry.Int64Attribute("tx.count", int64(len(params.Transactions))),
}
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadV1", attrs...)
}
// NewPayloadV1 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
func (api *ConsensusAPI) NewPayloadV1(ctx context.Context, params engine.ExecutableData) (result engine.PayloadStatusV1, err error) {
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadV1", executableDataAttrs(params)...)
defer spanEnd(err)
if params.Withdrawals != nil {
return invalidStatus, paramsErr("withdrawals not supported in V1")
@ -643,12 +647,7 @@ func (api *ConsensusAPI) NewPayloadV1(ctx context.Context, params engine.Executa
// NewPayloadV2 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
func (api *ConsensusAPI) NewPayloadV2(ctx context.Context, params engine.ExecutableData) (result engine.PayloadStatusV1, err error) {
attrs := []telemetry.Attribute{
telemetry.Int64Attribute("block.number", int64(params.Number)),
telemetry.StringAttribute("block.hash", params.BlockHash.Hex()),
telemetry.Int64Attribute("tx.count", int64(len(params.Transactions))),
}
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadV2", attrs...)
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadV2", executableDataAttrs(params)...)
defer spanEnd(err)
var (
cancun = api.config().IsCancun(api.config().LondonBlock, params.Timestamp)
@ -671,12 +670,7 @@ func (api *ConsensusAPI) NewPayloadV2(ctx context.Context, params engine.Executa
// NewPayloadV3 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
func (api *ConsensusAPI) NewPayloadV3(ctx context.Context, params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash) (result engine.PayloadStatusV1, err error) {
attrs := []telemetry.Attribute{
telemetry.Int64Attribute("block.number", int64(params.Number)),
telemetry.StringAttribute("block.hash", params.BlockHash.Hex()),
telemetry.Int64Attribute("tx.count", int64(len(params.Transactions))),
}
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadV3", attrs...)
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadV3", executableDataAttrs(params)...)
defer spanEnd(err)
switch {
case params.Withdrawals == nil:
@ -697,12 +691,7 @@ func (api *ConsensusAPI) NewPayloadV3(ctx context.Context, params engine.Executa
// NewPayloadV4 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
func (api *ConsensusAPI) NewPayloadV4(ctx context.Context, params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, executionRequests []hexutil.Bytes) (result engine.PayloadStatusV1, err error) {
attrs := []telemetry.Attribute{
telemetry.Int64Attribute("block.number", int64(params.Number)),
telemetry.StringAttribute("block.hash", params.BlockHash.Hex()),
telemetry.Int64Attribute("tx.count", int64(len(params.Transactions))),
}
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadV4", attrs...)
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadV4", executableDataAttrs(params)...)
defer spanEnd(err)
switch {
case params.Withdrawals == nil:
@ -745,16 +734,10 @@ func (api *ConsensusAPI) newPayload(ctx context.Context, params engine.Executabl
defer api.newPayloadLock.Unlock()
log.Trace("Engine API request received", "method", "NewPayload", "number", params.Number, "hash", params.BlockHash)
attrs := []telemetry.Attribute{
telemetry.Int64Attribute("block.number", int64(params.Number)),
telemetry.StringAttribute("block.hash", params.BlockHash.Hex()),
telemetry.Int64Attribute("tx.count", int64(len(params.Transactions))),
}
attrs := executableDataAttrs(params)
_, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayload.ExecutableDataToBlock", attrs...)
block, err := engine.ExecutableDataToBlock(params, versionedHashes, beaconRoot, requests)
spanEnd(err)
if err != nil {
bgu := "nil"
if params.BlobGasUsed != nil {

View file

@ -89,12 +89,7 @@ func (api *ConsensusAPI) ForkchoiceUpdatedWithWitnessV3(update engine.Forkchoice
// NewPayloadWithWitnessV1 is analogous to NewPayloadV1, only it also generates
// and returns a stateless witness after running the payload.
func (api *ConsensusAPI) NewPayloadWithWitnessV1(ctx context.Context, params engine.ExecutableData) (result engine.PayloadStatusV1, err error) {
attrs := []telemetry.Attribute{
telemetry.Int64Attribute("block.number", int64(params.Number)),
telemetry.StringAttribute("block.hash", params.BlockHash.Hex()),
telemetry.Int64Attribute("tx.count", int64(len(params.Transactions))),
}
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadWithWitnessV1", attrs...)
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadWithWitnessV1", executableDataAttrs(params)...)
defer spanEnd(err)
if params.Withdrawals != nil {
return engine.PayloadStatusV1{Status: engine.INVALID}, engine.InvalidParams.With(errors.New("withdrawals not supported in V1"))
@ -105,12 +100,7 @@ func (api *ConsensusAPI) NewPayloadWithWitnessV1(ctx context.Context, params eng
// NewPayloadWithWitnessV2 is analogous to NewPayloadV2, only it also generates
// and returns a stateless witness after running the payload.
func (api *ConsensusAPI) NewPayloadWithWitnessV2(ctx context.Context, params engine.ExecutableData) (result engine.PayloadStatusV1, err error) {
attrs := []telemetry.Attribute{
telemetry.Int64Attribute("block.number", int64(params.Number)),
telemetry.StringAttribute("block.hash", params.BlockHash.Hex()),
telemetry.Int64Attribute("tx.count", int64(len(params.Transactions))),
}
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadWithWitnessV2", attrs...)
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadWithWitnessV2", executableDataAttrs(params)...)
defer spanEnd(err)
var (
cancun = api.config().IsCancun(api.config().LondonBlock, params.Timestamp)
@ -134,12 +124,7 @@ func (api *ConsensusAPI) NewPayloadWithWitnessV2(ctx context.Context, params eng
// NewPayloadWithWitnessV3 is analogous to NewPayloadV3, only it also generates
// and returns a stateless witness after running the payload.
func (api *ConsensusAPI) NewPayloadWithWitnessV3(ctx context.Context, params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash) (result engine.PayloadStatusV1, err error) {
attrs := []telemetry.Attribute{
telemetry.Int64Attribute("block.number", int64(params.Number)),
telemetry.StringAttribute("block.hash", params.BlockHash.Hex()),
telemetry.Int64Attribute("tx.count", int64(len(params.Transactions))),
}
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadWithWitnessV3", attrs...)
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadWithWitnessV3", executableDataAttrs(params)...)
defer spanEnd(err)
switch {
case params.Withdrawals == nil:
@ -161,12 +146,7 @@ func (api *ConsensusAPI) NewPayloadWithWitnessV3(ctx context.Context, params eng
// NewPayloadWithWitnessV4 is analogous to NewPayloadV4, only it also generates
// and returns a stateless witness after running the payload.
func (api *ConsensusAPI) NewPayloadWithWitnessV4(ctx context.Context, params engine.ExecutableData, versionedHashes []common.Hash, beaconRoot *common.Hash, executionRequests []hexutil.Bytes) (result engine.PayloadStatusV1, err error) {
attrs := []telemetry.Attribute{
telemetry.Int64Attribute("block.number", int64(params.Number)),
telemetry.StringAttribute("block.hash", params.BlockHash.Hex()),
telemetry.Int64Attribute("tx.count", int64(len(params.Transactions))),
}
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadWithWitnessV4", attrs...)
ctx, _, spanEnd := telemetry.StartSpan(ctx, "engine.newPayloadWithWitnessV4", executableDataAttrs(params)...)
defer spanEnd(err)
switch {
case params.Withdrawals == nil: