Skip to content

Commit

Permalink
chore(mevboost): remove unused utility
Browse files Browse the repository at this point in the history
  • Loading branch information
thedevbirb committed Jul 26, 2024
1 parent 7884c73 commit 4e0442e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 95 deletions.
43 changes: 0 additions & 43 deletions mev-boost/server/constraints.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package server

import (
"slices"
"sort"

"github.com/attestantio/go-eth2-client/spec/phase0"
gethCommon "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
Expand Down Expand Up @@ -119,43 +116,3 @@ type (
Tx *types.Transaction
}
)

// ParseConstraintsDecoded receives a map of constraints and
// - creates a slice of constraints sorted by index
// - creates a slice of constraints without index sorted by nonce and hash
// Returns the concatenation of the slices
func ParseConstraintsDecoded(constraints HashToConstraintDecoded) []*ConstraintDecoded {
// Here we initialize and track the constraints left to be executed along
// with their gas requirements
constraintsOrderedByIndex := make([]*ConstraintDecoded, 0, len(constraints))
constraintsWithoutIndex := make([]*ConstraintDecoded, 0, len(constraints))

for _, constraint := range constraints {
if constraint.Index == nil {
constraintsWithoutIndex = append(constraintsWithoutIndex, constraint)
} else {
constraintsOrderedByIndex = append(constraintsOrderedByIndex, constraint)
}
}

// Sorts the constraints by index ascending
sort.Slice(constraintsOrderedByIndex, func(i, j int) bool {
// By assumption, all constraints here have a non-nil index
return *constraintsOrderedByIndex[i].Index < *constraintsOrderedByIndex[j].Index
})

// Sorts the unindexed constraints by nonce ascending and by hash
sort.Slice(constraintsWithoutIndex, func(i, j int) bool {
iNonce := constraintsWithoutIndex[i].Tx.Nonce()
jNonce := constraintsWithoutIndex[j].Tx.Nonce()
// Sort by hash
if iNonce == jNonce {
return constraintsWithoutIndex[i].Tx.Hash().Cmp(constraintsWithoutIndex[j].Tx.Hash()) < 0
}
return iNonce < jNonce
})

constraintsConcat := slices.Concat(constraintsOrderedByIndex, constraintsWithoutIndex)

return constraintsConcat
}
52 changes: 0 additions & 52 deletions mev-boost/server/constraints_test.go

This file was deleted.

0 comments on commit 4e0442e

Please sign in to comment.