Skip to content

Commit a4aa2dc

Browse files
authored
Merge pull request #185 from flashbots/feat/run-contender
run contender
2 parents 863477d + c0d02a4 commit a4aa2dc

File tree

7 files changed

+42
-1
lines changed

7 files changed

+42
-1
lines changed

main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var networkName string
3030
var labels playground.MapStringFlag
3131
var disableLogs bool
3232
var platform string
33+
var contenderEnabled bool
3334

3435
var rootCmd = &cobra.Command{
3536
Use: "playground",
@@ -179,6 +180,7 @@ func main() {
179180
recipeCmd.Flags().Var(&labels, "labels", "list of labels to apply to the resources")
180181
recipeCmd.Flags().BoolVar(&disableLogs, "disable-logs", false, "disable logs")
181182
recipeCmd.Flags().StringVar(&platform, "platform", "", "docker platform to use")
183+
recipeCmd.Flags().BoolVar(&contenderEnabled, "contender", false, "spam nodes with contender")
182184

183185
cookCmd.AddCommand(recipeCmd)
184186
}
@@ -224,7 +226,7 @@ func runIt(recipe playground.Recipe) error {
224226
return err
225227
}
226228

227-
svcManager := recipe.Apply(&playground.ExContext{LogLevel: logLevel}, artifacts)
229+
svcManager := recipe.Apply(&playground.ExContext{LogLevel: logLevel, ContenderEnabled: contenderEnabled}, artifacts)
228230
if err := svcManager.Validate(); err != nil {
229231
return fmt.Errorf("failed to validate manifest: %w", err)
230232
}

playground/catalog.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ func init() {
2424
register(&nullService{})
2525
register(&OpRbuilder{})
2626
register(&FlashblocksRPC{})
27+
register(&Contender{})
2728
}
2829

2930
func FindComponent(name string) ServiceGen {

playground/components.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,3 +717,25 @@ func (n *nullService) Run(service *Service, ctx *ExContext) {
717717
func (n *nullService) Name() string {
718718
return "null"
719719
}
720+
721+
type Contender struct {
722+
}
723+
724+
func (c *Contender) Name() string {
725+
return "contender"
726+
}
727+
728+
func (c *Contender) Run(service *Service, ctx *ExContext) {
729+
args := []string{
730+
"spam",
731+
"-l", // loop indefinitely
732+
"--min-balance", "10 ether", // give each spammer 10 ether (sender must have 100 ether because default number of spammers is 10)
733+
"-r", Connect("el", "http"), // connect to whatever EL node is available
734+
"--tps", "20", // send 20 txs per second
735+
}
736+
service.WithImage("flashbots/contender").
737+
WithTag("latest").
738+
WithArgs(args...).
739+
DependsOnHealthy("beacon")
740+
741+
}

playground/manifest.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ type ExContext struct {
8282
// Bootnode reference for EL nodes.
8383
// TODO: Extend for CL nodes too
8484
Bootnode *BootnodeRef
85+
86+
ContenderEnabled bool
8587
}
8688

8789
type BootnodeRef struct {

playground/recipe_buildernet.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ func (b *BuilderNetRecipe) Apply(ctx *ExContext, artifacts *Artifacts) *Manifest
5959
})
6060
}
6161

62+
if ctx.ContenderEnabled {
63+
svcManager.AddService("contender", &Contender{})
64+
}
65+
6266
return svcManager
6367
}
6468

playground/recipe_l1.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ func (l *L1Recipe) Apply(ctx *ExContext, artifacts *Artifacts) *Manifest {
106106
ValidationServer: mevBoostValidationServer,
107107
})
108108
}
109+
110+
if ctx.ContenderEnabled {
111+
svcManager.AddService("contender", &Contender{})
112+
}
113+
109114
return svcManager
110115
}
111116

playground/recipe_opstack.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ func (o *OpRecipe) Apply(ctx *ExContext, artifacts *Artifacts) *Manifest {
126126
RollupNode: "op-node",
127127
MaxChannelDuration: o.batcherMaxChannelDuration,
128128
})
129+
130+
if ctx.ContenderEnabled {
131+
svcManager.AddService("contender", &Contender{})
132+
}
133+
129134
return svcManager
130135
}
131136

0 commit comments

Comments
 (0)