Skip to content

Commit

Permalink
Merge pull request #10 from chainbound/revert-8-lore/fix/multiple-rel…
Browse files Browse the repository at this point in the history
…ays-lock

Revert "fix(builder): introduce `updateConstraintsCacheLock`"
  • Loading branch information
thedevbirb authored Nov 12, 2024
2 parents 322fdc2 + 493e652 commit c8989eb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
8 changes: 0 additions & 8 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ type Builder struct {

// constraintsCache is a map from slot to the decoded constraints made by proposers
constraintsCache *shardmap.FIFOMap[uint64, types.HashToConstraintDecoded]
// NOTE: `shardmap` already provides locks, however for handling multiple
// relay subscriptions for constraints we need a lock to protect the cache
// between the `Get` and `Put` operation
updateConstraintsCacheLock sync.Mutex

limiter *rate.Limiter
submissionOffsetFromEndOfSlot time.Duration
Expand Down Expand Up @@ -397,9 +393,6 @@ func (b *Builder) subscribeToRelayForConstraints(relayBaseEndpoint string) error
continue
}

// Take the lock to update the constraints cache: both `Get` and `Put` must be done by the same entity
b.updateConstraintsCacheLock.Lock()
// For every constraint, we need to check if it has already been seen for the associated slot
slotConstraints, _ := b.constraintsCache.Get(constraint.Message.Slot)
if len(slotConstraints) == 0 {
b.constraintsCache.Put(constraint.Message.Slot, decodedConstraints)
Expand All @@ -413,7 +406,6 @@ func (b *Builder) subscribeToRelayForConstraints(relayBaseEndpoint string) error
}

b.constraintsCache.Put(constraint.Message.Slot, slotConstraints)
b.updateConstraintsCacheLock.Unlock()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion builder/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func Register(stack *node.Node, backend *eth.Ethereum, cfg *Config) error {
return errors.New("neither local nor remote relay specified")
}

if len(cfg.SecondaryRemoteRelayEndpoints) > 0 && (len(cfg.SecondaryRemoteRelayEndpoints) != 1 || cfg.SecondaryRemoteRelayEndpoints[0] != "") {
if len(cfg.SecondaryRemoteRelayEndpoints) > 0 && !(len(cfg.SecondaryRemoteRelayEndpoints) == 1 && cfg.SecondaryRemoteRelayEndpoints[0] == "") {
secondaryRelays := make([]IRelay, len(cfg.SecondaryRemoteRelayEndpoints))
for i, endpoint := range cfg.SecondaryRemoteRelayEndpoints {
relayConfig, err := getRelayConfig(endpoint)
Expand Down

0 comments on commit c8989eb

Please sign in to comment.