diff --git a/main.go b/main.go index c3bd0d9..be63f77 100644 --- a/main.go +++ b/main.go @@ -30,6 +30,7 @@ var networkName string var labels playground.MapStringFlag var disableLogs bool var platform string +var contenderEnabled bool var rootCmd = &cobra.Command{ Use: "playground", @@ -179,6 +180,7 @@ func main() { recipeCmd.Flags().Var(&labels, "labels", "list of labels to apply to the resources") recipeCmd.Flags().BoolVar(&disableLogs, "disable-logs", false, "disable logs") recipeCmd.Flags().StringVar(&platform, "platform", "", "docker platform to use") + recipeCmd.Flags().BoolVar(&contenderEnabled, "contender", false, "spam nodes with contender") cookCmd.AddCommand(recipeCmd) } @@ -224,7 +226,7 @@ func runIt(recipe playground.Recipe) error { return err } - svcManager := recipe.Apply(&playground.ExContext{LogLevel: logLevel}, artifacts) + svcManager := recipe.Apply(&playground.ExContext{LogLevel: logLevel, ContenderEnabled: contenderEnabled}, artifacts) if err := svcManager.Validate(); err != nil { return fmt.Errorf("failed to validate manifest: %w", err) } diff --git a/playground/catalog.go b/playground/catalog.go index 6cf842c..2b6b540 100644 --- a/playground/catalog.go +++ b/playground/catalog.go @@ -24,6 +24,7 @@ func init() { register(&nullService{}) register(&OpRbuilder{}) register(&FlashblocksRPC{}) + register(&Contender{}) } func FindComponent(name string) ServiceGen { diff --git a/playground/components.go b/playground/components.go index fd01948..fd020e9 100644 --- a/playground/components.go +++ b/playground/components.go @@ -717,3 +717,25 @@ func (n *nullService) Run(service *Service, ctx *ExContext) { func (n *nullService) Name() string { return "null" } + +type Contender struct { +} + +func (c *Contender) Name() string { + return "contender" +} + +func (c *Contender) Run(service *Service, ctx *ExContext) { + args := []string{ + "spam", + "-l", // loop indefinitely + "--min-balance", "10 ether", // give each spammer 10 ether (sender must have 100 ether because default number of spammers is 10) + "-r", Connect("el", "http"), // connect to whatever EL node is available + "--tps", "20", // send 20 txs per second + } + service.WithImage("flashbots/contender"). + WithTag("latest"). + WithArgs(args...). + DependsOnHealthy("beacon") + +} diff --git a/playground/manifest.go b/playground/manifest.go index 8904734..030002d 100644 --- a/playground/manifest.go +++ b/playground/manifest.go @@ -82,6 +82,8 @@ type ExContext struct { // Bootnode reference for EL nodes. // TODO: Extend for CL nodes too Bootnode *BootnodeRef + + ContenderEnabled bool } type BootnodeRef struct { diff --git a/playground/recipe_buildernet.go b/playground/recipe_buildernet.go index b7cfa69..ce7af20 100644 --- a/playground/recipe_buildernet.go +++ b/playground/recipe_buildernet.go @@ -59,6 +59,10 @@ func (b *BuilderNetRecipe) Apply(ctx *ExContext, artifacts *Artifacts) *Manifest }) } + if ctx.ContenderEnabled { + svcManager.AddService("contender", &Contender{}) + } + return svcManager } diff --git a/playground/recipe_l1.go b/playground/recipe_l1.go index 86f37cb..d8b00f1 100644 --- a/playground/recipe_l1.go +++ b/playground/recipe_l1.go @@ -106,6 +106,11 @@ func (l *L1Recipe) Apply(ctx *ExContext, artifacts *Artifacts) *Manifest { ValidationServer: mevBoostValidationServer, }) } + + if ctx.ContenderEnabled { + svcManager.AddService("contender", &Contender{}) + } + return svcManager } diff --git a/playground/recipe_opstack.go b/playground/recipe_opstack.go index b720d51..edc51b6 100644 --- a/playground/recipe_opstack.go +++ b/playground/recipe_opstack.go @@ -126,6 +126,11 @@ func (o *OpRecipe) Apply(ctx *ExContext, artifacts *Artifacts) *Manifest { RollupNode: "op-node", MaxChannelDuration: o.batcherMaxChannelDuration, }) + + if ctx.ContenderEnabled { + svcManager.AddService("contender", &Contender{}) + } + return svcManager }