Skip to content

Commit

Permalink
Merge pull request #9 from chainbound/lore/fix/sse-and-flags
Browse files Browse the repository at this point in the history
fix(sse; cli): avoid infinite loop on possible relay failure; cli flag not passed correctly
  • Loading branch information
thedevbirb authored Nov 12, 2024
2 parents 28acd2f + 282a481 commit eca6ad5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
22 changes: 11 additions & 11 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,17 @@ func (b *Builder) subscribeToRelayForConstraints(relayBaseEndpoint string) error
for {
line, err := bufReader.ReadString('\n')
if err != nil {
// If we encounter an EOF or another serious error, break out to reconnect
isEOF := err == io.EOF || strings.Contains(err.Error(), "EOF")
if isEOF {
log.Error("Encountered EOF. Connection to relay lost, attempting to reconnect...", "relayBaseEndpoint", relayBaseEndpoint)
time.Sleep(retryInterval)
break // Break to reconnect by restarting the main `for` loop
}

// Log other errors but continue reading if recoverable
log.Error(fmt.Sprintf("Error reading from response body: %v", err))
continue
// It is better to break and trying to reconnect (by restarting
// the main loop), otherwise there is an high change we might run into
// an infinite loop because the error isn't recoverable.
log.Error(
fmt.Sprintf("Error reading from response body from relay %s: %v. Connection might be lost. Attempting to reconnect in %d seconds...",
relayBaseEndpoint,
err,
retryInterval,
))
time.Sleep(retryInterval)
break
}

if !strings.HasPrefix(line, "data: ") {
Expand Down
17 changes: 9 additions & 8 deletions builder/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,20 +290,21 @@ func Register(stack *node.Node, backend *eth.Ethereum, cfg *Config) error {
}

builderArgs := BuilderArgs{
sk: builderSk,
beaconClient: beaconClient,
blockConsumer: blockConsumer,
ds: ds,
builderBlockResubmitInterval: builderRateLimitInterval,
builderSigningDomain: builderSigningDomain,
discardRevertibleTxOnErr: cfg.DiscardRevertibleTxOnErr,
dryRun: cfg.DryRun,
ds: ds,
eth: ethereumService,
ignoreLatePayloadAttributes: cfg.IgnoreLatePayloadAttributes,
limiter: limiter,
relay: relay,
builderSigningDomain: builderSigningDomain,
builderBlockResubmitInterval: builderRateLimitInterval,
sk: builderSk,
submissionOffsetFromEndOfSlot: submissionOffset,
discardRevertibleTxOnErr: cfg.DiscardRevertibleTxOnErr,
ignoreLatePayloadAttributes: cfg.IgnoreLatePayloadAttributes,
validator: validator,
beaconClient: beaconClient,
limiter: limiter,
verifyConstraints: cfg.VerifyConstraints,
}

builderBackend, err := NewBuilder(builderArgs)
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ var (
utils.BuilderDiscardRevertibleTxOnErr,
utils.BuilderEnableCancellations,
utils.BuilderBlockProcessorURL,
utils.BuilderVerifyConstraints,
}

rpcFlags = []cli.Flag{
Expand Down

0 comments on commit eca6ad5

Please sign in to comment.