@@ -626,14 +626,18 @@ func (api *ConsensusAPI) getBlobs(hashes []common.Hash, v2 bool) ([]*engine.Blob
626626// Helper for NewPayload* methods.
627627var invalidStatus = engine.PayloadStatusV1 {Status : engine .INVALID }
628628
629- // NewPayloadV1 creates an Eth1 block, inserts it in the chain, and returns the status of the chain .
630- func ( api * ConsensusAPI ) NewPayloadV1 ( ctx context. Context , params engine.ExecutableData ) ( result engine. PayloadStatusV1 , err error ) {
631- attrs := []telemetry.Attribute {
629+ // executableDataAttrs returns telemetry attributes for an ExecutableData payload .
630+ func executableDataAttrs ( params engine.ExecutableData ) []telemetry. Attribute {
631+ return []telemetry.Attribute {
632632 telemetry .Int64Attribute ("block.number" , int64 (params .Number )),
633633 telemetry .StringAttribute ("block.hash" , params .BlockHash .Hex ()),
634634 telemetry .Int64Attribute ("tx.count" , int64 (len (params .Transactions ))),
635635 }
636- ctx , _ , spanEnd := telemetry .StartSpan (ctx , "engine.newPayloadV1" , attrs ... )
636+ }
637+
638+ // NewPayloadV1 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
639+ func (api * ConsensusAPI ) NewPayloadV1 (ctx context.Context , params engine.ExecutableData ) (result engine.PayloadStatusV1 , err error ) {
640+ ctx , _ , spanEnd := telemetry .StartSpan (ctx , "engine.newPayloadV1" , executableDataAttrs (params )... )
637641 defer spanEnd (err )
638642 if params .Withdrawals != nil {
639643 return invalidStatus , paramsErr ("withdrawals not supported in V1" )
@@ -643,12 +647,7 @@ func (api *ConsensusAPI) NewPayloadV1(ctx context.Context, params engine.Executa
643647
644648// NewPayloadV2 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
645649func (api * ConsensusAPI ) NewPayloadV2 (ctx context.Context , params engine.ExecutableData ) (result engine.PayloadStatusV1 , err error ) {
646- attrs := []telemetry.Attribute {
647- telemetry .Int64Attribute ("block.number" , int64 (params .Number )),
648- telemetry .StringAttribute ("block.hash" , params .BlockHash .Hex ()),
649- telemetry .Int64Attribute ("tx.count" , int64 (len (params .Transactions ))),
650- }
651- ctx , _ , spanEnd := telemetry .StartSpan (ctx , "engine.newPayloadV2" , attrs ... )
650+ ctx , _ , spanEnd := telemetry .StartSpan (ctx , "engine.newPayloadV2" , executableDataAttrs (params )... )
652651 defer spanEnd (err )
653652 var (
654653 cancun = api .config ().IsCancun (api .config ().LondonBlock , params .Timestamp )
@@ -671,12 +670,7 @@ func (api *ConsensusAPI) NewPayloadV2(ctx context.Context, params engine.Executa
671670
672671// NewPayloadV3 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
673672func (api * ConsensusAPI ) NewPayloadV3 (ctx context.Context , params engine.ExecutableData , versionedHashes []common.Hash , beaconRoot * common.Hash ) (result engine.PayloadStatusV1 , err error ) {
674- attrs := []telemetry.Attribute {
675- telemetry .Int64Attribute ("block.number" , int64 (params .Number )),
676- telemetry .StringAttribute ("block.hash" , params .BlockHash .Hex ()),
677- telemetry .Int64Attribute ("tx.count" , int64 (len (params .Transactions ))),
678- }
679- ctx , _ , spanEnd := telemetry .StartSpan (ctx , "engine.newPayloadV3" , attrs ... )
673+ ctx , _ , spanEnd := telemetry .StartSpan (ctx , "engine.newPayloadV3" , executableDataAttrs (params )... )
680674 defer spanEnd (err )
681675 switch {
682676 case params .Withdrawals == nil :
@@ -697,12 +691,7 @@ func (api *ConsensusAPI) NewPayloadV3(ctx context.Context, params engine.Executa
697691
698692// NewPayloadV4 creates an Eth1 block, inserts it in the chain, and returns the status of the chain.
699693func (api * ConsensusAPI ) NewPayloadV4 (ctx context.Context , params engine.ExecutableData , versionedHashes []common.Hash , beaconRoot * common.Hash , executionRequests []hexutil.Bytes ) (result engine.PayloadStatusV1 , err error ) {
700- attrs := []telemetry.Attribute {
701- telemetry .Int64Attribute ("block.number" , int64 (params .Number )),
702- telemetry .StringAttribute ("block.hash" , params .BlockHash .Hex ()),
703- telemetry .Int64Attribute ("tx.count" , int64 (len (params .Transactions ))),
704- }
705- ctx , _ , spanEnd := telemetry .StartSpan (ctx , "engine.newPayloadV4" , attrs ... )
694+ ctx , _ , spanEnd := telemetry .StartSpan (ctx , "engine.newPayloadV4" , executableDataAttrs (params )... )
706695 defer spanEnd (err )
707696 switch {
708697 case params .Withdrawals == nil :
@@ -745,16 +734,10 @@ func (api *ConsensusAPI) newPayload(ctx context.Context, params engine.Executabl
745734 defer api .newPayloadLock .Unlock ()
746735
747736 log .Trace ("Engine API request received" , "method" , "NewPayload" , "number" , params .Number , "hash" , params .BlockHash )
748-
749- attrs := []telemetry.Attribute {
750- telemetry .Int64Attribute ("block.number" , int64 (params .Number )),
751- telemetry .StringAttribute ("block.hash" , params .BlockHash .Hex ()),
752- telemetry .Int64Attribute ("tx.count" , int64 (len (params .Transactions ))),
753- }
737+ attrs := executableDataAttrs (params )
754738 _ , _ , spanEnd := telemetry .StartSpan (ctx , "engine.newPayload.ExecutableDataToBlock" , attrs ... )
755739 block , err := engine .ExecutableDataToBlock (params , versionedHashes , beaconRoot , requests )
756740 spanEnd (err )
757-
758741 if err != nil {
759742 bgu := "nil"
760743 if params .BlobGasUsed != nil {
0 commit comments