@@ -24,6 +24,7 @@ import (
2424
2525 "github.com/flashbots/mev-boost-relay/beaconclient"
2626 mevRCommon "github.com/flashbots/mev-boost-relay/common"
27+ "golang.org/x/mod/semver"
2728
2829 "github.com/ethereum/go-ethereum/core/types"
2930 ecrypto "github.com/ethereum/go-ethereum/crypto"
@@ -58,6 +59,7 @@ var validateFlag bool
5859var genesisDelayFlag uint64
5960var watchPayloadsFlag bool
6061var latestForkFlag bool
62+ var useRethForValidation bool
6163
6264var rootCmd = & cobra.Command {
6365 Use : "playground" ,
@@ -164,6 +166,7 @@ func main() {
164166 rootCmd .Flags ().Uint64Var (& genesisDelayFlag , "genesis-delay" , 5 , "" )
165167 rootCmd .Flags ().BoolVar (& watchPayloadsFlag , "watch-payloads" , false , "" )
166168 rootCmd .Flags ().BoolVar (& latestForkFlag , "electra" , false , "" )
169+ rootCmd .Flags ().BoolVar (& useRethForValidation , "use-reth-for-validation" , false , "enable flashbots_validateBuilderSubmissionV* on reth and use them for validation" )
167170
168171 downloadArtifactsCmd .Flags ().BoolVar (& validateFlag , "validate" , false , "" )
169172 validateCmd .Flags ().Uint64Var (& numBlocksValidate , "num-blocks" , 5 , "" )
@@ -361,12 +364,32 @@ func setupServices(svcManager *serviceManager, out *output) error {
361364 fmt .Printf ("(%d) %s (%s)\n " , indx , acc , ecrypto .PubkeyToAddress (priv .PublicKey ).Hex ())
362365 }
363366 fmt .Println ("" )
364-
365367 if err := os .WriteFile (defaultRethDiscoveryPrivKeyLoc , []byte (defaultRethDiscoveryPrivKey ), 0644 ); err != nil {
366368 return err
367369 }
368370
371+ rethVersion := func () string {
372+ cmd := exec .Command (rethBin , "--version" )
373+ out , err := cmd .Output ()
374+ if err != nil {
375+ return "unknown"
376+ }
377+ // find the line of the form:
378+ // reth Version: x.y.z
379+ for _ , line := range strings .Split (string (out ), "\n " ) {
380+ if strings .HasPrefix (line , "reth Version: " ) {
381+ v := strings .TrimSpace (strings .TrimPrefix (line , "reth Version: " ))
382+ if ! strings .HasPrefix (v , "v" ) {
383+ v = "v" + v
384+ }
385+ return semver .Canonical (v )
386+ }
387+ }
388+ return "unknown"
389+ }()
390+
369391 // start the reth el client
392+ fmt .Println ("Starting reth version " + rethVersion )
370393 svcManager .
371394 NewService ("reth" ).
372395 WithArgs (
@@ -387,6 +410,16 @@ func setupServices(svcManager *serviceManager, out *output) error {
387410 "--authrpc.port" , "8551" ,
388411 "--authrpc.jwtsecret" , "{{.Dir}}/jwtsecret" ,
389412 ).
413+ If (useRethForValidation , func (s * service ) * service {
414+ return s .WithArgs ("--http.api" , "eth,web3,net,rpc,flashbots" )
415+ }).
416+ If (
417+ semver .Compare (rethVersion , "v1.1.0" ) >= 0 ,
418+ func (s * service ) * service {
419+ // For versions >= v1.1.0, we need to run with --engine.legacy, at least for now
420+ return s .WithArgs ("--engine.legacy" )
421+ },
422+ ).
390423 WithPort ("rpc" , 30303 ).
391424 WithPort ("http" , 8545 ).
392425 WithPort ("authrpc" , 8551 ).
@@ -444,6 +477,7 @@ func setupServices(svcManager *serviceManager, out *output) error {
444477 if cfg .LogOutput , err = out .LogOutput ("mev-boost-relay" ); err != nil {
445478 return err
446479 }
480+ cfg .UseRethForValidation = useRethForValidation
447481 relay , err := mevboostrelay .New (cfg )
448482 if err != nil {
449483 return fmt .Errorf ("failed to create relay: %w" , err )
@@ -731,6 +765,13 @@ func (s *service) WithArgs(args ...string) *service {
731765 return s
732766}
733767
768+ func (s * service ) If (cond bool , fn func (* service ) * service ) * service {
769+ if cond {
770+ return fn (s )
771+ }
772+ return s
773+ }
774+
734775func (s * service ) Run () {
735776 s .srvMng .Run (s )
736777}
0 commit comments