diff --git a/builder/builder/builder.go b/builder/builder/builder.go index 09bd2597..273892c1 100644 --- a/builder/builder/builder.go +++ b/builder/builder/builder.go @@ -364,9 +364,9 @@ func (b *Builder) subscribeToRelayForConstraints(relayBaseEndpoint, authHeader s } for _, constraint := range constraintsSigned { - decodedConstraints, err := DecodeConstraint(constraint) + decodedConstraints, err := DecodeConstraints(constraint) if err != nil { - log.Error("Failed to decode transaction RLP: ", err) + log.Error("Failed to decode constraint: ", err) continue } @@ -378,20 +378,12 @@ func (b *Builder) subscribeToRelayForConstraints(relayBaseEndpoint, authHeader s continue } - // Temporary map to keep track of the constraints that are already in the slot - seenTx := make(map[common.Hash]bool) - for hash := range slotConstraints { - seenTx[hash] = true - } - for hash := range decodedConstraints { - if !seenTx[hash] { - // The constraint is new, we will add this to the slot constraints - slotConstraints[hash] = decodedConstraints[hash] - } + // Update the slot constraints + slotConstraints[hash] = decodedConstraints[hash] } - // Update the slot constraints + // Update the slot constraints in the cache b.constraintsCache.Put(constraint.Message.Slot, slotConstraints) } } diff --git a/builder/builder/builder_test.go b/builder/builder/builder_test.go index ef065e3a..b5d71a1e 100644 --- a/builder/builder/builder_test.go +++ b/builder/builder/builder_test.go @@ -632,7 +632,7 @@ func TestSubscribeProposerConstraints(t *testing.T) { require.Equal(t, true, ok) expectedConstraint := generateMockConstraintsForSlot(slot)[0] - decodedConstraint, err := DecodeConstraint(expectedConstraint) + decodedConstraint, err := DecodeConstraints(expectedConstraint) require.NoError(t, err) // Compare the keys of the cachedConstraints and decodedConstraint maps diff --git a/builder/builder/utils.go b/builder/builder/utils.go index 12478074..b6f3836b 100644 --- a/builder/builder/utils.go +++ b/builder/builder/utils.go @@ -16,9 +16,9 @@ import ( var errHTTPErrorResponse = errors.New("HTTP error response") -func DecodeConstraint(constraint *common.SignedConstraints) (types.HashToConstraintDecoded, error) { +func DecodeConstraints(constraints *common.SignedConstraints) (types.HashToConstraintDecoded, error) { decodedConstraints := make(types.HashToConstraintDecoded) - for _, tx := range constraint.Message.Constraints { + for _, tx := range constraints.Message.Constraints { decoded := new(types.Transaction) if err := decoded.UnmarshalBinary(tx.Tx); err != nil { return nil, err