Skip to content

Commit

Permalink
Add Float to U256 test, other minor review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
allboxes committed Oct 7, 2022
1 parent 648040f commit 0818f35
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var (
defaultListenAddr = getEnv("BOOST_LISTEN_ADDR", "localhost:18550")
defaultRelayCheck = os.Getenv("RELAY_STARTUP_CHECK") != ""
defaultGenesisForkVersion = getEnv("GENESIS_FORK_VERSION", "")
defaultRelayMinBidEth = getEnvFloat64("RELAY_MIN_BID", 0.001)
defaultRelayMinBidEth = getEnvFloat64("MIN_BID_ETH", 0.001)
defaultDisableLogVersion = os.Getenv("DISABLE_LOG_VERSION") == "1" // disables adding the version to every log entry

// mev-boost relay request timeouts (see also https://github.com/flashbots/mev-boost/issues/287)
Expand Down
16 changes: 16 additions & 0 deletions cli/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package cli

import (
"testing"

"github.com/flashbots/go-boost-utils/types"
"github.com/stretchr/testify/require"
)

func TestFloatEthTo256Wei(t *testing.T) {
// test with valid input
i := 0.000000000000012345
u256, err := floatEthTo256Wei(i)
require.Equal(t, types.IntToU256(12345), *u256)
require.NoError(t, err)
}
11 changes: 6 additions & 5 deletions server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,19 +361,20 @@ func (m *BoostService) handleGetHeader(w http.ResponseWriter, req *http.Request)
return
}

if responsePayload.Data.Message.Value.Cmp(&m.relayMinBid) == -1 {
log.Debug("ignoring bid below min-bid value")
return
}

log.Debug("bid received")
// Skip if value (fee) is lower than the minimum bid

mu.Lock()
defer mu.Unlock()

// Remember which relays delivered which bids (multiple relays might deliver the top bid)
relays[BlockHashHex(blockHash)] = append(relays[BlockHashHex(blockHash)], relay)

// Skip if value (fee) is lower than the minimum bid
if responsePayload.Data.Message.Value.Cmp(&m.relayMinBid) == -1 {
return
}

// Compare the bid with already known top bid (if any)
if result.response.Data != nil {
valueDiff := responsePayload.Data.Message.Value.Cmp(&result.response.Data.Message.Value)
Expand Down

0 comments on commit 0818f35

Please sign in to comment.