@@ -15,21 +15,26 @@ import (
1515)
1616
1717type ProdBeaconInstance struct {
18- log * logrus.Entry
19- beaconURI string
18+ log * logrus.Entry
19+ beaconURI string
20+ beaconPublishURI string
2021
2122 // feature flags
2223 ffUseV1PublishBlockEndpoint bool
2324 ffUseSSZEncodingPublishBlock bool
25+
26+ // http clients
27+ publishingClient * http.Client
2428}
2529
26- func NewProdBeaconInstance (log * logrus.Entry , beaconURI string ) * ProdBeaconInstance {
30+ func NewProdBeaconInstance (log * logrus.Entry , beaconURI , beaconPublishURI string ) * ProdBeaconInstance {
2731 _log := log .WithFields (logrus.Fields {
28- "component" : "beaconInstance" ,
29- "beaconURI" : beaconURI ,
32+ "component" : "beaconInstance" ,
33+ "beaconURI" : beaconURI ,
34+ "beaconPublishURI" : beaconPublishURI ,
3035 })
3136
32- client := & ProdBeaconInstance {_log , beaconURI , false , false }
37+ client := & ProdBeaconInstance {_log , beaconURI , beaconPublishURI , false , false , & http. Client {} }
3338
3439 // feature flags
3540 if os .Getenv ("USE_V1_PUBLISH_BLOCK_ENDPOINT" ) != "" {
@@ -179,7 +184,7 @@ func (c *ProdBeaconInstance) SyncStatus() (*SyncStatusPayloadData, error) {
179184 uri := c .beaconURI + "/eth/v1/node/syncing"
180185 timeout := 5 * time .Second
181186 resp := new (SyncStatusPayload )
182- _ , err := fetchBeacon (http .MethodGet , uri , nil , resp , & timeout , http.Header {}, false )
187+ _ , err := fetchBeacon (http .MethodGet , uri , nil , resp , & http. Client { Timeout : timeout } , http.Header {}, false )
183188 if err != nil {
184189 return nil , err
185190 }
@@ -248,12 +253,16 @@ func (c *ProdBeaconInstance) GetURI() string {
248253 return c .beaconURI
249254}
250255
256+ func (c * ProdBeaconInstance ) GetPublishURI () string {
257+ return c .beaconPublishURI
258+ }
259+
251260func (c * ProdBeaconInstance ) PublishBlock (block * common.VersionedSignedProposal , broadcastMode BroadcastMode ) (code int , err error ) {
252261 var uri string
253262 if c .ffUseV1PublishBlockEndpoint {
254- uri = fmt .Sprintf ("%s/eth/v1/beacon/blocks" , c .beaconURI )
263+ uri = fmt .Sprintf ("%s/eth/v1/beacon/blocks" , c .beaconPublishURI )
255264 } else {
256- uri = fmt .Sprintf ("%s/eth/v2/beacon/blocks?broadcast_validation=%s" , c .beaconURI , broadcastMode )
265+ uri = fmt .Sprintf ("%s/eth/v2/beacon/blocks?broadcast_validation=%s" , c .beaconPublishURI , broadcastMode )
257266 }
258267 headers := http.Header {}
259268 headers .Add ("Eth-Consensus-Version" , strings .ToLower (block .Version .String ())) // optional in v1, required in v2
@@ -279,7 +288,7 @@ func (c *ProdBeaconInstance) PublishBlock(block *common.VersionedSignedProposal,
279288 }
280289 publishingStartTime := time .Now ().UTC ()
281290 encodeDurationMs := publishingStartTime .Sub (encodeStartTime ).Milliseconds ()
282- code , err = fetchBeacon (http .MethodPost , uri , payloadBytes , nil , nil , headers , useSSZ )
291+ code , err = fetchBeacon (http .MethodPost , uri , payloadBytes , nil , c . publishingClient , headers , useSSZ )
283292 publishDurationMs := time .Now ().UTC ().Sub (publishingStartTime ).Milliseconds ()
284293 log .WithFields (logrus.Fields {
285294 "slot" : slot ,
0 commit comments