Skip to content

Commit d434d05

Browse files
committed
merge latest changes
2 parents d7a0a2f + 4207e59 commit d434d05

File tree

11 files changed

+491
-110
lines changed

11 files changed

+491
-110
lines changed

.github/workflows/checks.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,21 @@ jobs:
4747
name: playground-logs-${{ matrix.flags }}
4848
path: /tmp/playground-logs
4949
retention-days: 5
50+
51+
artifacts:
52+
name: Artifacts
53+
strategy:
54+
matrix:
55+
os: [ubuntu-latest, macos-13]
56+
runs-on: ${{ matrix.os }}
57+
steps:
58+
- name: Check out code
59+
uses: actions/checkout@v2
60+
61+
- name: Set up Go
62+
uses: actions/setup-go@v2
63+
with:
64+
go-version: 1.24
65+
66+
- name: Download and test artifacts
67+
run: go run main.go artifacts-all

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ Flags:
4949

5050
- `--external-builder`: URL of an external builder to use (enables rollup-boost)
5151

52+
### Example Commands
53+
54+
Here's a complete example showing how to run the L1 recipe with the latest fork enabled and custom output directory:
55+
56+
```bash
57+
$ builder-playground cook l1 --latest-fork --output ~/my-builder-testnet --genesis-delay 15 --log-level debug
58+
```
59+
5260
## Common Options
5361

5462
- `--output` (string): The directory where the chain data and artifacts are stored. Defaults to `$HOME/.playground/devnet`

internal/artifacts.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ var opState []byte
5757
//go:embed config.yaml.tmpl
5858
var clConfigContent []byte
5959

60+
//go:embed utils/query.sh
61+
var queryReadyCheck []byte
62+
6063
type ArtifactsBuilder struct {
6164
outputDir string
6265
applyLatestL1Fork bool
@@ -91,7 +94,7 @@ type Artifacts struct {
9194
}
9295

9396
func (b *ArtifactsBuilder) Build() (*Artifacts, error) {
94-
homeDir, err := getHomeDir()
97+
homeDir, err := GetHomeDir()
9598
if err != nil {
9699
return nil, err
97100
}
@@ -230,6 +233,7 @@ func (b *ArtifactsBuilder) Build() (*Artifacts, error) {
230233
"testnet/genesis_validators_root.txt": hex.EncodeToString(state.GenesisValidatorsRoot()),
231234
"data_validator/": &lighthouseKeystore{privKeys: priv},
232235
"deterministic_p2p_key.txt": defaultDiscoveryPrivKey,
236+
"scripts/query.sh": queryReadyCheck,
233237
})
234238
if err != nil {
235239
return nil, err
@@ -523,7 +527,7 @@ type sszObject interface {
523527
MarshalSSZ() ([]byte, error)
524528
}
525529

526-
func getHomeDir() (string, error) {
530+
func GetHomeDir() (string, error) {
527531
homeDir, err := os.UserHomeDir()
528532
if err != nil {
529533
return "", fmt.Errorf("error getting user home directory: %w", err)

internal/catalog.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package internal
2+
3+
var Components = []Service{}
4+
5+
func register(component Service) {
6+
Components = append(Components, component)
7+
}
8+
9+
func init() {
10+
register(&OpBatcher{})
11+
register(&OpGeth{})
12+
register(&OpNode{})
13+
register(&RethEL{})
14+
register(&LighthouseBeaconNode{})
15+
register(&LighthouseValidator{})
16+
register(&ClProxy{})
17+
register(&MevBoostRelay{})
18+
register(&RollupBoost{})
19+
register(&OpReth{})
20+
register(&BuilderHub{})
21+
register(&BuilderHubPostgres{})
22+
register(&BuilderHubMockProxy{})
23+
}
24+
25+
func FindComponent(name string) Service {
26+
for _, component := range Components {
27+
if component.Name() == name {
28+
return component
29+
}
30+
}
31+
return nil
32+
}

internal/components.go

Lines changed: 103 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ func (r *RollupBoost) Run(service *service, ctx *ExContext) {
2828
)
2929
}
3030

31+
func (r *RollupBoost) Name() string {
32+
return "rollup-boost"
33+
}
34+
3135
type OpBatcher struct {
3236
L1Node string
3337
L2Node string
@@ -51,6 +55,10 @@ func (o *OpBatcher) Run(service *service, ctx *ExContext) {
5155
)
5256
}
5357

58+
func (o *OpBatcher) Name() string {
59+
return "op-batcher"
60+
}
61+
5462
type OpNode struct {
5563
L1Node string
5664
L1Beacon string
@@ -62,6 +70,7 @@ func (o *OpNode) Run(service *service, ctx *ExContext) {
6270
WithImage("us-docker.pkg.dev/oplabs-tools-artifacts/images/op-node").
6371
WithTag("v1.11.0").
6472
WithEntrypoint("op-node").
73+
WithEnv("A", "B"). // this is just a placeholder to make sure env works since we e2e test with the recipes
6574
WithArgs(
6675
"--l1", Connect(o.L1Node, "http"),
6776
"--l1.beacon", Connect(o.L1Beacon, "http"),
@@ -90,6 +99,10 @@ func (o *OpNode) Run(service *service, ctx *ExContext) {
9099
)
91100
}
92101

102+
func (o *OpNode) Name() string {
103+
return "op-node"
104+
}
105+
93106
type OpGeth struct {
94107
UseDeterministicP2PKey bool
95108

@@ -159,16 +172,14 @@ func (o *OpGeth) Run(service *service, ctx *ExContext) {
159172
)
160173
}
161174

162-
var _ ServiceReady = &OpGeth{}
163-
164-
func (o *OpGeth) Ready(out io.Writer, service *service, ctx context.Context) error {
165-
logs := service.logs
175+
func (o *OpGeth) Name() string {
176+
return "op-geth"
177+
}
166178

167-
if err := logs.WaitForLog("HTTP server started", 5*time.Second); err != nil {
168-
return err
169-
}
179+
var _ ServiceReady = &OpGeth{}
170180

171-
enodeLine, err := logs.FindLog("enode://")
181+
func (o *OpGeth) Ready(service *service) error {
182+
enodeLine, err := service.logs.FindLog("enode://")
172183
if err != nil {
173184
return err
174185
}
@@ -262,6 +273,10 @@ func (r *RethEL) Run(svc *service, ctx *ExContext) {
262273
}
263274
}
264275

276+
func (r *RethEL) Name() string {
277+
return "reth"
278+
}
279+
265280
var _ ServiceWatchdog = &RethEL{}
266281

267282
func (r *RethEL) Watchdog(out io.Writer, service *service, ctx context.Context) error {
@@ -283,15 +298,9 @@ func (l *LighthouseBeaconNode) Run(svc *service, ctx *ExContext) {
283298
"bn",
284299
"--datadir", "{{.Dir}}/data_beacon_node",
285300
"--testnet-dir", "{{.Dir}}/testnet",
301+
"--enable-private-discovery",
286302
"--disable-peer-scoring",
287303
"--staking",
288-
"--disable-discovery",
289-
"--disable-upnp",
290-
"--disable-packet-filter",
291-
"--target-peers", "0",
292-
"--boot-nodes", "",
293-
"--debug-level", "error",
294-
"--logfile-debug-level", "error",
295304
"--enr-address", "127.0.0.1",
296305
"--enr-udp-port", `{{Port "p2p" 9000}}`,
297306
"--enr-tcp-port", `{{Port "p2p" 9000}}`,
@@ -302,12 +311,21 @@ func (l *LighthouseBeaconNode) Run(svc *service, ctx *ExContext) {
302311
"--http-port", `{{Port "http" 3500}}`,
303312
"--http-address", "0.0.0.0",
304313
"--http-allow-origin", "*",
314+
"--disable-packet-filter",
315+
"--target-peers", "0",
305316
"--execution-endpoint", Connect(l.ExecutionNode, "authrpc"),
306317
"--execution-jwt", "{{.Dir}}/jwtsecret",
307318
"--always-prepare-payload",
308319
"--prepare-payload-lookahead", "8000",
309320
"--suggested-fee-recipient", "0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990",
310-
)
321+
).
322+
WithReady(ReadyCheck{
323+
QueryURL: "http://localhost:3500/eth/v1/node/syncing",
324+
Interval: 1 * time.Second,
325+
Timeout: 30 * time.Second,
326+
Retries: 3,
327+
StartPeriod: 1 * time.Second,
328+
})
311329

312330
if l.MevBoostNode != "" {
313331
svc.WithArgs(
@@ -318,15 +336,8 @@ func (l *LighthouseBeaconNode) Run(svc *service, ctx *ExContext) {
318336
}
319337
}
320338

321-
var _ ServiceReady = &LighthouseBeaconNode{}
322-
323-
func (l *LighthouseBeaconNode) Ready(logOutput io.Writer, service *service, ctx context.Context) error {
324-
beaconNodeURL := fmt.Sprintf("http://localhost:%d", service.MustGetPort("http").HostPort)
325-
326-
if err := waitForChainAlive(ctx, logOutput, beaconNodeURL, 30*time.Second); err != nil {
327-
return err
328-
}
329-
return nil
339+
func (l *LighthouseBeaconNode) Name() string {
340+
return "lighthouse-beacon-node"
330341
}
331342

332343
type LighthouseValidator struct {
@@ -351,6 +362,10 @@ func (l *LighthouseValidator) Run(service *service, ctx *ExContext) {
351362
)
352363
}
353364

365+
func (l *LighthouseValidator) Name() string {
366+
return "lighthouse-validator"
367+
}
368+
354369
type ClProxy struct {
355370
PrimaryBuilder string
356371
SecondaryBuilder string
@@ -368,6 +383,10 @@ func (c *ClProxy) Run(service *service, ctx *ExContext) {
368383
)
369384
}
370385

386+
func (c *ClProxy) Name() string {
387+
return "cl-proxy"
388+
}
389+
371390
type MevBoostRelay struct {
372391
BeaconClient string
373392
ValidationServer string
@@ -378,6 +397,7 @@ func (m *MevBoostRelay) Run(service *service, ctx *ExContext) {
378397
WithImage("docker.io/flashbots/playground-utils").
379398
WithTag("latest").
380399
WithEntrypoint("mev-boost-relay").
400+
DependsOnHealthy(m.BeaconClient).
381401
WithArgs(
382402
"--api-listen-addr", "0.0.0.0",
383403
"--api-listen-port", `{{Port "http" 5555}}`,
@@ -389,6 +409,10 @@ func (m *MevBoostRelay) Run(service *service, ctx *ExContext) {
389409
}
390410
}
391411

412+
func (m *MevBoostRelay) Name() string {
413+
return "mev-boost-relay"
414+
}
415+
392416
var _ ServiceWatchdog = &MevBoostRelay{}
393417

394418
func (m *MevBoostRelay) Watchdog(out io.Writer, service *service, ctx context.Context) error {
@@ -413,24 +437,24 @@ func (b *BuilderHubPostgres) Run(service *service, ctx *ExContext) {
413437
WithImage("docker.io/flashbots/builder-hub-db").
414438
WithTag("latest").
415439
WithPort("postgres", 5432).
416-
WithLabel("POSTGRES_USER", "postgres").
417-
WithLabel("POSTGRES_PASSWORD", "postgres").
418-
WithLabel("POSTGRES_DB", "postgres")
440+
WithEnv("POSTGRES_USER", "postgres").
441+
WithEnv("POSTGRES_PASSWORD", "postgres").
442+
WithEnv("POSTGRES_DB", "postgres").
443+
WithReady(ReadyCheck{
444+
Test: []string{"pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"},
445+
Interval: 1 * time.Second,
446+
Timeout: 30 * time.Second,
447+
Retries: 3,
448+
StartPeriod: 1 * time.Second,
449+
})
419450
}
420451

421-
var _ ServiceReady = &BuilderHubPostgres{}
422-
423-
func (b *BuilderHubPostgres) Ready(out io.Writer, service *service, ctx context.Context) error {
424-
logs := service.logs
425-
if err := logs.WaitForLog("database system is ready to accept connections", 30*time.Second); err != nil {
426-
return err
427-
}
428-
429-
fmt.Fprintln(out, "PostgreSQL is ready for builder-hub")
430-
return nil
452+
func (b *BuilderHubPostgres) Name() string {
453+
return "builder-hub-postgres"
431454
}
432455

433456
type BuilderHub struct {
457+
postgres string
434458
}
435459

436460
func (b *BuilderHub) Run(service *service, ctx *ExContext) {
@@ -444,22 +468,14 @@ func (b *BuilderHub) Run(service *service, ctx *ExContext) {
444468
"--metrics-addr", fmt.Sprintf("0.0.0.0:%s", `{{Port "metrics" 8090}}`),
445469
"--log-json", "true",
446470
"--log-debug",
447-
// Use proper template format for postgres connection
448-
"--postgres-dsn", `postgres://postgres:postgres@{{Service "builder-hub-postgres" "postgres"}}/postgres?sslmode=disable`,
449-
"--mock-secrets", "true", // Use mock secrets for easier testing
450-
)
471+
"--postgres-dsn", "postgres://postgres:postgres@"+Connect(b.postgres, "postgres")+":5432/postgres?sslmode=disable",
472+
"--mock-secrets", "true",
473+
).
474+
DependsOnHealthy(b.postgres)
451475
}
452476

453-
var _ ServiceReady = &BuilderHub{}
454-
455-
func (b *BuilderHub) Ready(out io.Writer, service *service, ctx context.Context) error {
456-
logs := service.logs
457-
if err := logs.WaitForLog("Starting API service", 30*time.Second); err != nil {
458-
return err
459-
}
460-
461-
fmt.Fprintln(out, "Builder-Hub service is ready")
462-
return nil
477+
func (b *BuilderHub) Name() string {
478+
return "builder-hub"
463479
}
464480

465481
type BuilderHubMockProxy struct {
@@ -473,9 +489,40 @@ func (b *BuilderHubMockProxy) Run(service *service, ctx *ExContext) {
473489
WithPort("http", 8888)
474490

475491
if b.TargetService != "" {
476-
service.nodeRefs = append(service.nodeRefs, &NodeRef{
477-
Service: b.TargetService,
478-
PortLabel: "http",
479-
})
492+
service.DependsOnHealthy(b.TargetService)
493+
}
494+
}
495+
496+
func (b *BuilderHubMockProxy) Name() string {
497+
return "builder-hub-mock-proxy"
498+
}
499+
500+
type OpReth struct {
501+
}
502+
503+
func (o *OpReth) Run(service *service, ctx *ExContext) {
504+
panic("BUG: op-reth is not implemented yet")
505+
}
506+
507+
func (o *OpReth) Name() string {
508+
return "op-reth"
509+
}
510+
511+
func (o *OpReth) ReleaseArtifact() *release {
512+
return &release{
513+
Name: "op-reth",
514+
Repo: "reth",
515+
Org: "paradigmxyz",
516+
Version: "v1.3.4",
517+
Arch: func(goos, goarch string) string {
518+
if goos == "linux" {
519+
return "x86_64-unknown-linux-gnu"
520+
} else if goos == "darwin" && goarch == "arm64" { // Apple M1
521+
return "aarch64-apple-darwin"
522+
} else if goos == "darwin" && goarch == "amd64" {
523+
return "x86_64-apple-darwin"
524+
}
525+
return ""
526+
},
480527
}
481528
}

0 commit comments

Comments
 (0)