@@ -13,6 +13,7 @@ import (
1313 mevboostrelay "github.com/flashbots/builder-playground/mev-boost-relay"
1414 "github.com/flashbots/go-boost-utils/bls"
1515 "github.com/flashbots/go-boost-utils/utils"
16+ "github.com/goccy/go-yaml"
1617)
1718
1819var (
@@ -547,7 +548,9 @@ func (l *LighthouseBeaconNode) Apply(ctx *ExContext) *Component {
547548 "--http-address" , "0.0.0.0" ,
548549 "--http-allow-origin" , "*" ,
549550 "--disable-packet-filter" ,
550- "--target-peers" , "0" ,
551+ "--target-peers" , "1" ,
552+ //"--target-peers", "0",
553+ "--subscribe-all-subnets" ,
551554 "--execution-endpoint" , Connect (l .ExecutionNode , "authrpc" ),
552555 "--execution-jwt" , "/data/jwtsecret" ,
553556 "--always-prepare-payload" ,
@@ -558,7 +561,8 @@ func (l *LighthouseBeaconNode) Apply(ctx *ExContext) *Component {
558561 WithArtifact ("/data/jwtsecret" , "jwtsecret" ).
559562 WithVolume ("data" , "/data_beacon" )
560563
561- UseHealthmon (component , svc , healthmonBeacon )
564+ // TODO: Enable later - doesn't work with --target-peers=1 which is required for builder VM
565+ //UseHealthmon(component, svc, healthmonBeacon)
562566
563567 if l .MevBoostNode != "" {
564568 svc .WithArgs (
@@ -635,7 +639,8 @@ func (m *MevBoostRelay) Apply(ctx *ExContext) *Component {
635639 WithTag (latestPlaygroundUtilsTag ).
636640 WithEnv ("ALLOW_SYNCING_BEACON_NODE" , "1" ).
637641 WithEntrypoint ("mev-boost-relay" ).
638- DependsOnHealthy (m .BeaconClient ).
642+ // TODO: Enable later - doesn't work when beacon healthmon is disabled.
643+ //DependsOnHealthy(m.BeaconClient).
639644 WithArgs (
640645 "--api-listen-addr" , "0.0.0.0" ,
641646 "--api-listen-port" , `{{Port "http" 5555}}` ,
@@ -942,8 +947,8 @@ func (b *BuilderHub) Apply(ctx *ExContext) *Component {
942947 StartPeriod : 2 * time .Second ,
943948 })
944949
945- // API service
946- apiSrv := component .NewService ("builder-hub-api" ).
950+ // API service
951+ component .NewService ("builder-hub-api" ).
947952 WithImage ("docker.io/flashbots/builder-hub" ).
948953 WithTag ("0.3.1-alpha1" ).
949954 DependsOnHealthy ("builder-hub-db" ).
@@ -965,15 +970,14 @@ func (b *BuilderHub) Apply(ctx *ExContext) *Component {
965970 Timeout : 30 * time .Second ,
966971 Retries : 3 ,
967972 StartPeriod : 1 * time .Second ,
973+ }).
974+ WithPostHook (& postHook {
975+ Name : "register-builder" ,
976+ Action : func (m * Manifest , s * Service ) error {
977+ return registerBuilderHook (ctx , m , s , b )
978+ },
968979 })
969980
970- apiSrv .WithPostHook (& postHook {
971- Name : "register-builder" ,
972- Action : func (s * Service ) error {
973- return registerBuilderHook (ctx , s , b )
974- },
975- })
976-
977981 // Proxy service
978982 component .NewService ("builder-hub-proxy" ).
979983 WithImage ("docker.io/flashbots/builder-hub-mock-proxy" ).
@@ -992,14 +996,33 @@ func (b *BuilderHub) Apply(ctx *ExContext) *Component {
992996 return component
993997}
994998
995- func registerBuilderHook (ctx * ExContext , s * Service , b * BuilderHub ) error {
999+ type builderHubConfig struct {
1000+ Playground struct {
1001+ BuilderHubConfig struct {
1002+ BuilderID string `yaml:"builder_id"`
1003+ BuilderIP string `yaml:"builder_ip"`
1004+ MeasurementID string `yaml:"measurement_id"`
1005+ Network string `yaml:"network"`
1006+ } `yaml:"builder_hub_config"`
1007+ } `yaml:"playground"`
1008+ }
1009+
1010+ func registerBuilderHook (ctx * ExContext , manifest * Manifest , s * Service , b * BuilderHub ) error {
9961011 genesis , err := ctx .Output .Read ("genesis.json" )
9971012 if err != nil {
9981013 return err
9991014 }
10001015
1001- configYaml , err := os .ReadFile (b .BuilderConfig )
1002- if err != nil {
1016+ configYaml := defaultBuilderHubConfig
1017+ if len (b .BuilderConfig ) > 0 {
1018+ configYaml , err = os .ReadFile (b .BuilderConfig )
1019+ if err != nil {
1020+ return err
1021+ }
1022+ }
1023+
1024+ var config builderHubConfig
1025+ if err := yaml .Unmarshal ([]byte (configYaml ), & config ); err != nil {
10031026 return err
10041027 }
10051028
@@ -1016,15 +1039,17 @@ func registerBuilderHook(ctx *ExContext, s *Service, b *BuilderHub) error {
10161039 return err
10171040 }
10181041
1019- endpoint := fmt .Sprintf ("http://localhost:%d" , s .MustGetPort ("admin" ).HostPort )
10201042 input := & builderHubRegisterBuilderInput {
1021- BuilderID : "builder" ,
1022- BuilderIP : b .BuilderIP ,
1023- MeasurementID : "test" ,
1024- Network : "playground" ,
1043+ BuilderID : config . Playground . BuilderHubConfig . BuilderID ,
1044+ BuilderIP : config . Playground . BuilderHubConfig .BuilderIP ,
1045+ MeasurementID : config . Playground . BuilderHubConfig . MeasurementID ,
1046+ Network : config . Playground . BuilderHubConfig . Network ,
10251047 Config : string (configJSON ),
10261048 }
1027- if err := registerBuilder (endpoint , input ); err != nil {
1049+ adminApi := fmt .Sprintf ("http://localhost:%d" , manifest .MustGetService ("builder-hub-api" ).MustGetPort ("admin" ).HostPort )
1050+ beaconApi := fmt .Sprintf ("http://localhost:%d" , manifest .MustGetService ("beacon" ).MustGetPort ("http" ).HostPort )
1051+ rethApi := fmt .Sprintf ("http://localhost:%d" , manifest .MustGetService ("el" ).MustGetPort ("http" ).HostPort )
1052+ if err := registerBuilder (adminApi , beaconApi , rethApi , input ); err != nil {
10281053 return err
10291054 }
10301055 return nil
@@ -1052,3 +1077,25 @@ func UseHealthmon(component *Component, s *Service, chain string) {
10521077 StartPeriod : 1 * time .Second ,
10531078 })
10541079}
1080+
1081+ // Fileserver serves genesis and testnet files over HTTP using Caddy.
1082+ // This allows VMs or external clients to fetch configuration files.
1083+ type Fileserver struct {}
1084+
1085+ func (f * Fileserver ) Apply (ctx * ExContext ) * Component {
1086+ component := NewComponent ("fileserver" )
1087+
1088+ component .NewService ("server" ).
1089+ WithImage ("caddy" ).
1090+ WithTag ("2-alpine" ).
1091+ WithArgs (
1092+ "caddy" , "file-server" ,
1093+ "--root" , "/data" ,
1094+ "--listen" , `:{{Port "http" 8100}}` ,
1095+ "--browse" ,
1096+ ).
1097+ WithArtifact ("/data/genesis.json" , "genesis.json" ).
1098+ WithArtifact ("/data/testnet" , "testnet" )
1099+
1100+ return component
1101+ }
0 commit comments