forked from flashbots/mev-boost
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
log ms into slot when getHeader/getPayload requests start (flashbots#508
) * submitBlindedBlock - log milliseconds into slot when request started * also log msIntoSlot in getHeader * log getPayload request start always, for later debugging * cleanup & PR review feedback
- Loading branch information
Showing
6 changed files
with
108 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,9 @@ lint: | |
staticcheck ./... | ||
golangci-lint run | ||
|
||
.PHONY: lt | ||
lt: lint test | ||
|
||
.PHONY: fmt | ||
fmt: | ||
gofmt -s -w . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package common | ||
|
||
import ( | ||
"math/big" | ||
"os" | ||
"strconv" | ||
|
||
"github.com/flashbots/go-boost-utils/types" | ||
) | ||
|
||
const ( | ||
GenesisTimeMainnet = 1606824023 | ||
SlotTimeSecMainnet = 12 | ||
) | ||
|
||
func GetEnv(key, defaultValue string) string { | ||
if value, ok := os.LookupEnv(key); ok { | ||
return value | ||
} | ||
return defaultValue | ||
} | ||
|
||
func GetEnvInt(key string, defaultValue int) int { | ||
if value, ok := os.LookupEnv(key); ok { | ||
val, err := strconv.Atoi(value) | ||
if err == nil { | ||
return val | ||
} | ||
} | ||
return defaultValue | ||
} | ||
|
||
func GetEnvFloat64(key string, defaultValue float64) float64 { | ||
if value, ok := os.LookupEnv(key); ok { | ||
val, err := strconv.ParseFloat(value, 64) | ||
if err == nil { | ||
return val | ||
} | ||
} | ||
return defaultValue | ||
} | ||
|
||
// FloatEthTo256Wei converts a float (precision 10) denominated in eth to a U256Str denominated in wei | ||
func FloatEthTo256Wei(val float64) (*types.U256Str, error) { | ||
weiU256 := new(types.U256Str) | ||
ethFloat := new(big.Float) | ||
weiFloat := new(big.Float) | ||
weiFloatLessPrecise := new(big.Float) | ||
weiInt := new(big.Int) | ||
|
||
ethFloat.SetFloat64(val) | ||
weiFloat.Mul(ethFloat, big.NewFloat(1e18)) | ||
weiFloatLessPrecise.SetString(weiFloat.String()) | ||
weiFloatLessPrecise.Int(weiInt) | ||
|
||
err := weiU256.FromBig(weiInt) | ||
return weiU256, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters