Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add genesis time for testnets #540

Merged
merged 6 commits into from
Jun 28, 2023
Merged

Add genesis time for testnets #540

merged 6 commits into from
Jun 28, 2023

Conversation

nalepae
Copy link
Contributor

@nalepae nalepae commented Jun 26, 2023

📝 Summary

Display getHeader request start - %d milliseconds into slot %d and submitBlindedBlock request start - %d milliseconds into slot %d correctly only by setting the -<testnet-name> CLI option.

Example with -sepolia:

time="2023-06-26T20:27:36.041Z" level=info msg="getHeader request start - 41 milliseconds into slot 2673138" genesisTime=1655733600 method=getHeader msIntoSlot=41 parentHash=0xd373b3c498f26cf8c133a75299c25d6122a28ea5756dc2486d819bb8edb4d293 pubkey=0x906cde18b34f777027d0c64b16c94c9d8f94250449d353e94972d42c94dd4d915aa1b6c73a581da2986e09f336af9673 slot=2673138 slotTimeSec=12 slotUID=1079e776-8a60-4ff7-8071-0ec7a2b7de9f ua=teku/v23.6.0 version=v1.7-dev
time="2023-06-26T20:27:37.034Z" level=info msg="submitBlindedBlock request start - 1033 milliseconds into slot 2673138" blockHash=0xed0c16ac625401ffb4e9720865c36ff2884d75862b3659e403308689e340f304 genesisTime=1655733600 method=getPayload msIntoSlot=1033 parentHash=0xd373b3c498f26cf8c133a75299c25d6122a28ea5756dc2486d819bb8edb4d293 slot=2673138 slotTimeSec=12 slotUID=1079e776-8a60-4ff7-8071-0ec7a2b7de9f ua=okhttp/4.10.0 version=v1.7-dev

Design note

I removed the ability to set the genesis time by setting GENESIS_TIMESTAMP environment variable.
If requested, I can add a -genesis-timestamp CLI option, as done with -genesis-fork-version CLI option.

✅ I have run these commands

  • make lint ==> golangci-lint run cannot run it on develop branch
  • make test-race
  • go mod tidy

cli/main.go Show resolved Hide resolved
cli/main.go Outdated
mainnet = flag.Bool("mainnet", true, "use Mainnet")
sepolia = flag.Bool("sepolia", defaultUseSepolia, "use Sepolia")
goerli = flag.Bool("goerli", defaultUseGoerli, "use Goerli")
zhejiang = flag.Bool("zhejiang", defaultUseZhejiang, "use Zhejiang")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zhejiang is deprecated, can be removed

@@ -62,6 +62,7 @@ type BoostServiceOpts struct {
Relays []RelayEntry
RelayMonitors []*url.URL
GenesisForkVersionHex string
GenesisTime int64
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be uint64

Copy link
Contributor Author

@nalepae nalepae Jun 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add a commit for that. However at the end, time.Now().UTC().UnixMilli() is int64 not uint64, so we still need a cast. IMO it would be better to consider all times as int64.

@metachris
Copy link
Collaborator

golangci-lint run does run on the develop branch for me. what error are you seeing?

@codecov-commenter
Copy link

codecov-commenter commented Jun 27, 2023

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 35.00000% with 13 lines in your changes missing coverage. Please review.

Project coverage is 70.16%. Comparing base (54eeaa2) to head (e9a89fa).
Report is 309 commits behind head on develop.

Files with missing lines Patch % Lines
cli/main.go 0.00% 13 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #540      +/-   ##
===========================================
- Coverage    70.24%   70.16%   -0.08%     
===========================================
  Files            6        7       +1     
  Lines          541     1106     +565     
===========================================
+ Hits           380      776     +396     
- Misses         132      285     +153     
- Partials        29       45      +16     
Flag Coverage Δ
unittests 70.16% <35.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@metachris
Copy link
Collaborator

nice addition, btw -- thanks for the contribution 👍

@metachris
Copy link
Collaborator

btw, please fix the linter too

@nalepae
Copy link
Contributor Author

nalepae commented Jun 27, 2023

golangci-lint run does run on the develop branch for me. what error are you seeing?

 mev-boost git:(develop) golangci-lint run
cli/main.go:10:2: import 'github.com/flashbots/mev-boost/common' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/mev-boost/common"
        ^
cli/main.go:11:2: import 'github.com/flashbots/mev-boost/config' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/mev-boost/config"
        ^
cli/main.go:12:2: import 'github.com/flashbots/mev-boost/server' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/mev-boost/server"
        ^
cli/main.go:13:2: import 'github.com/sirupsen/logrus' is not allowed from list 'Main' (depguard)
        "github.com/sirupsen/logrus"
        ^
cli/main.go:139:26: var-declaration: should drop = 0 from declaration of var genesisTime; it is the zero value (revive)
        var genesisTime int64 = 0
                                ^
cli/main_test.go:8:2: import 'github.com/flashbots/mev-boost/common' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/mev-boost/common"
        ^
cli/main_test.go:9:2: import 'github.com/stretchr/testify/require' is not allowed from list 'Main' (depguard)
        "github.com/stretchr/testify/require"
        ^
cmd/test-cli/beacon.go:8:2: import 'github.com/ethereum/go-ethereum/common' is not allowed from list 'Main' (depguard)
        "github.com/ethereum/go-ethereum/common"
        ^
cmd/test-cli/beacon.go:9:2: import 'github.com/flashbots/mev-boost/server' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/mev-boost/server"
        ^
cmd/test-cli/engine.go:4:2: import 'github.com/ethereum/go-ethereum/common' is not allowed from list 'Main' (depguard)
        "github.com/ethereum/go-ethereum/common"
        ^
cmd/test-cli/engine.go:5:2: import 'github.com/ethereum/go-ethereum/common/hexutil' is not allowed from list 'Main' (depguard)
        "github.com/ethereum/go-ethereum/common/hexutil"
        ^
cmd/test-cli/main.go:11:2: import 'github.com/ethereum/go-ethereum/common' is not allowed from list 'Main' (depguard)
        "github.com/ethereum/go-ethereum/common"
        ^
cmd/test-cli/main.go:12:2: import 'github.com/flashbots/go-boost-utils/types' is not allowed from list 'Main' (depguard)
        boostTypes "github.com/flashbots/go-boost-utils/types"
        ^
cmd/test-cli/main.go:13:2: import 'github.com/flashbots/mev-boost/server' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/mev-boost/server"
        ^
cmd/test-cli/main.go:14:2: import 'github.com/sirupsen/logrus' is not allowed from list 'Main' (depguard)
        "github.com/sirupsen/logrus"
        ^
cmd/test-cli/validator.go:8:2: import 'github.com/ethereum/go-ethereum/common/hexutil' is not allowed from list 'Main' (depguard)
        "github.com/ethereum/go-ethereum/common/hexutil"
        ^
cmd/test-cli/validator.go:9:2: import 'github.com/flashbots/go-boost-utils/bls' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/go-boost-utils/bls"
        ^
cmd/test-cli/validator.go:10:2: import 'github.com/flashbots/go-boost-utils/types' is not allowed from list 'Main' (depguard)
        boostTypes "github.com/flashbots/go-boost-utils/types"
        ^
common/common.go:8:2: import 'github.com/flashbots/go-boost-utils/types' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/go-boost-utils/types"
        ^
config/vars.go:6:2: import 'github.com/flashbots/mev-boost/common' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/mev-boost/common"
        ^
main.go:4:2: import 'github.com/flashbots/mev-boost/cli' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/mev-boost/cli"
        ^
server/mock_relay.go:13:2: import 'github.com/attestantio/go-builder-client/api' is not allowed from list 'Main' (depguard)
        "github.com/attestantio/go-builder-client/api"
        ^
server/mock_relay.go:14:2: import 'github.com/attestantio/go-builder-client/api/bellatrix' is not allowed from list 'Main' (depguard)
        apibellatrix "github.com/attestantio/go-builder-client/api/bellatrix"
        ^
server/mock_relay.go:15:2: import 'github.com/attestantio/go-builder-client/api/capella' is not allowed from list 'Main' (depguard)
        apicapella "github.com/attestantio/go-builder-client/api/capella"
        ^
server/mock_relay.go:16:2: import 'github.com/attestantio/go-builder-client/spec' is not allowed from list 'Main' (depguard)
        "github.com/attestantio/go-builder-client/spec"
        ^
server/mock_relay.go:17:2: import 'github.com/attestantio/go-eth2-client/spec' is not allowed from list 'Main' (depguard)
        consensusspec "github.com/attestantio/go-eth2-client/spec"
        ^
server/mock_relay.go:18:2: import 'github.com/attestantio/go-eth2-client/spec/bellatrix' is not allowed from list 'Main' (depguard)
        "github.com/attestantio/go-eth2-client/spec/bellatrix"
        ^
server/mock_relay.go:19:2: import 'github.com/attestantio/go-eth2-client/spec/capella' is not allowed from list 'Main' (depguard)
        "github.com/attestantio/go-eth2-client/spec/capella"
        ^
server/mock_relay.go:20:2: import 'github.com/attestantio/go-eth2-client/spec/phase0' is not allowed from list 'Main' (depguard)
        "github.com/attestantio/go-eth2-client/spec/phase0"
        ^
server/mock_relay.go:21:2: import 'github.com/ethereum/go-ethereum/common/hexutil' is not allowed from list 'Main' (depguard)
        "github.com/ethereum/go-ethereum/common/hexutil"
        ^
server/mock_relay.go:22:2: import 'github.com/flashbots/go-boost-utils/bls' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/go-boost-utils/bls"
        ^
server/mock_relay.go:24:2: import 'github.com/gorilla/mux' is not allowed from list 'Main' (depguard)
        "github.com/gorilla/mux"
        ^
server/mock_relay.go:25:2: import 'github.com/holiman/uint256' is not allowed from list 'Main' (depguard)
        "github.com/holiman/uint256"
        ^
server/mock_relay.go:26:2: import 'github.com/stretchr/testify/require' is not allowed from list 'Main' (depguard)
        "github.com/stretchr/testify/require"
        ^
server/mock_relay.go:131:55: unused-parameter: parameter 'req' seems to be unused, consider removing or renaming it as _ (revive)
func (m *mockRelay) handleRoot(w http.ResponseWriter, req *http.Request) {
                                                      ^
server/mock_relay.go:138:57: unused-parameter: parameter 'req' seems to be unused, consider removing or renaming it as _ (revive)
func (m *mockRelay) handleStatus(w http.ResponseWriter, req *http.Request) {
                                                        ^
server/mock_types.go:6:2: import 'github.com/sirupsen/logrus' is not allowed from list 'Main' (depguard)
        "github.com/sirupsen/logrus"
        ^
server/service.go:18:2: import 'github.com/attestantio/go-builder-client/api' is not allowed from list 'Main' (depguard)
        "github.com/attestantio/go-builder-client/api"
        ^
server/service.go:19:2: import 'github.com/attestantio/go-builder-client/spec' is not allowed from list 'Main' (depguard)
        "github.com/attestantio/go-builder-client/spec"
        ^
server/service.go:20:2: import 'github.com/attestantio/go-eth2-client/api/v1/capella' is not allowed from list 'Main' (depguard)
        "github.com/attestantio/go-eth2-client/api/v1/capella"
        ^
server/service.go:21:2: import 'github.com/attestantio/go-eth2-client/spec/phase0' is not allowed from list 'Main' (depguard)
        "github.com/attestantio/go-eth2-client/spec/phase0"
        ^
server/service.go:23:2: import 'github.com/flashbots/go-utils/httplogger' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/go-utils/httplogger"
        ^
server/service.go:24:2: import 'github.com/flashbots/mev-boost/config' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/mev-boost/config"
        ^
server/service.go:25:2: import 'github.com/google/uuid' is not allowed from list 'Main' (depguard)
        "github.com/google/uuid"
        ^
server/service.go:26:2: import 'github.com/gorilla/mux' is not allowed from list 'Main' (depguard)
        "github.com/gorilla/mux"
        ^
server/service.go:540:29: unnecessary conversion (unconvert)
        slotStartTimestamp := int64(m.genesisTime) + (int64(payload.Message.Slot) * config.SlotTimeSec)
                                   ^
server/utils.go:16:2: import 'github.com/attestantio/go-builder-client/spec' is not allowed from list 'Main' (depguard)
        "github.com/attestantio/go-builder-client/spec"
        ^
server/utils.go:17:2: import 'github.com/attestantio/go-eth2-client/spec/capella' is not allowed from list 'Main' (depguard)
        "github.com/attestantio/go-eth2-client/spec/capella"
        ^
server/utils.go:18:2: import 'github.com/attestantio/go-eth2-client/spec/phase0' is not allowed from list 'Main' (depguard)
        "github.com/attestantio/go-eth2-client/spec/phase0"
        ^
server/utils.go:21:2: import 'github.com/ethereum/go-ethereum/core/types' is not allowed from list 'Main' (depguard)
        "github.com/ethereum/go-ethereum/core/types"
        ^
server/utils.go:22:2: import 'github.com/ethereum/go-ethereum/trie' is not allowed from list 'Main' (depguard)
        "github.com/ethereum/go-ethereum/trie"
        ^
server/utils.go:23:2: import 'github.com/flashbots/go-boost-utils/bls' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/go-boost-utils/bls"
        ^
server/utils.go:25:2: import 'github.com/flashbots/mev-boost/config' is not allowed from list 'Main' (depguard)
        "github.com/flashbots/mev-boost/config"
        ^
server/utils.go:26:2: import 'github.com/holiman/uint256' is not allowed from list 'Main' (depguard)
        "github.com/holiman/uint256"
        ^
server/utils.go:159:2: if-return: redundant if ...; err != nil check, just return error instead. (revive)
        if err := decoder.Decode(dst); err != nil {
                return err
        }
server/utils.go:197:34: unused-parameter: parameter 'req' seems to be unused, consider removing or renaming it as _ (revive)
func httpClientDisallowRedirects(req *http.Request, via []*http.Request) error {

cli/main.go Outdated
}
log.Infof("using genesis fork version: %s", genesisForkVersionHex)

switch {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't add a second switch here, assign the time in the switch above, and then below just do a simple if *useCustomGenesisTime > -1

@nalepae nalepae requested a review from metachris June 27, 2023 14:21
Copy link
Collaborator

@metachris metachris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, thanks!

@metachris metachris merged commit b8be122 into flashbots:develop Jun 28, 2023
@nalepae nalepae deleted the genesis-time-testnets branch June 28, 2023 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants