@@ -31,6 +31,82 @@ import (
3131 "github.com/ethereum/go-ethereum/log"
3232)
3333
34+ type Service uint64
35+
36+ const (
37+ ServiceBatcher Service = iota
38+ ServiceCaffNode
39+ ServiceCaffNodeGeth
40+ ServiceChallenger
41+ ServiceDevNode
42+ ServiceHTTPProxy
43+ ServiceL1Beacon
44+ ServiceL1DataInit
45+ ServiceL1Genesis
46+ ServiceL1Geth
47+ ServiceL1Validator
48+ ServiceL2Genesis
49+ ServiceL2Rollup
50+ ServiceL2Seq
51+ ServiceL2SeqGeth
52+ ServiceL2Verif
53+ ServiceL2VerifGeth
54+ ServiceProposer
55+ )
56+
57+ const (
58+ ProfileDefault = "default"
59+ ProfileTee = "tee"
60+ )
61+
62+ type Profile struct {
63+ BatcherService string
64+ ProposerService string
65+ }
66+
67+ // modifyDefaultProfile creates a new profile based on the default profile with specified modifications
68+ func modifyDefaultProfile (modifications map [Service ]string ) map [Service ]string {
69+ result := make (map [Service ]string )
70+ // Copy all services from default profile
71+ for service , container := range defaultProfile {
72+ result [service ] = container
73+ }
74+ // Apply modifications
75+ for service , container := range modifications {
76+ result [service ] = container
77+ }
78+ return result
79+ }
80+
81+ var defaultProfile = map [Service ]string {
82+ ServiceBatcher : "op-batcher" ,
83+ ServiceCaffNode : "caff-node" ,
84+ ServiceCaffNodeGeth : "op-geth-caff-node" ,
85+ ServiceChallenger : "op-challenger" ,
86+ ServiceDevNode : "espresso-dev-node" ,
87+ ServiceHTTPProxy : "http-proxy" ,
88+ ServiceL1Beacon : "l1-beacon" ,
89+ ServiceL1DataInit : "l1-data-init" ,
90+ ServiceL1Genesis : "l1-genesis" ,
91+ ServiceL1Geth : "l1-geth" ,
92+ ServiceL1Validator : "l1-validator" ,
93+ ServiceL2Genesis : "l2-genesis" ,
94+ ServiceL2Rollup : "l2-rollup" ,
95+ ServiceL2Seq : "op-node-sequencer" ,
96+ ServiceL2SeqGeth : "op-geth-sequencer" ,
97+ ServiceL2Verif : "op-node-verifier" ,
98+ ServiceL2VerifGeth : "op-geth-verifier" ,
99+ ServiceProposer : "op-proposer" ,
100+ }
101+
102+ var Profiles = map [string ]map [Service ]string {
103+ ProfileDefault : defaultProfile ,
104+ ProfileTee : modifyDefaultProfile (map [Service ]string {
105+ ServiceBatcher : "op-batcher-tee" ,
106+ ServiceProposer : "op-proposer-tee" ,
107+ }),
108+ }
109+
34110type Devnet struct {
35111 ctx context.Context
36112 tee bool
@@ -81,13 +157,29 @@ func NewDevnet(ctx context.Context, t *testing.T) *Devnet {
81157 return d
82158}
83159
84- func ( d * Devnet ) Up () ( err error ) {
85- var profile string
160+ // getProfile returns the current profile name based on devnet configuration
161+ func ( d * Devnet ) getProfile () string {
86162 if d .tee {
87- profile = "tee"
88- } else {
89- profile = "default"
163+ return ProfileTee
90164 }
165+ return ProfileDefault
166+ }
167+
168+ // getServiceName returns the container name for a given service in the current profile
169+ func (d * Devnet ) getServiceName (service Service ) string {
170+ profile := d .getProfile ()
171+ if container , ok := Profiles [profile ][service ]; ok {
172+ return container
173+ }
174+ // Fall back to default profile if service not found
175+ if container , ok := Profiles [ProfileDefault ][service ]; ok {
176+ return container
177+ }
178+ return ""
179+ }
180+
181+ func (d * Devnet ) Up () (err error ) {
182+ profile := d .getProfile ()
91183
92184 cmd := exec .CommandContext (
93185 d .ctx ,
@@ -126,7 +218,7 @@ func (d *Devnet) Up() (err error) {
126218 // Stream logs to stdout while the test runs. This goroutine will automatically exit when
127219 // the context is cancelled.
128220 go func () {
129- cmd = exec .CommandContext (d .ctx , "docker" , "compose" , "logs" , "-f" )
221+ cmd = exec .CommandContext (d .ctx , "docker" , "compose" , "--profile" , profile , " logs" , "-f" )
130222 cmd .Stdout = os .Stdout
131223 // We don't care about the error return of this command, since it's always going to be
132224 // killed by the context cancellation.
@@ -135,49 +227,51 @@ func (d *Devnet) Up() (err error) {
135227 }
136228
137229 // Open RPC clients for the different nodes.
138- d .L2Seq , err = d .serviceClient ("op-geth-sequencer" , 8546 )
230+ d .L2Seq , err = d .serviceClient (d . getServiceName ( ServiceL2SeqGeth ) , 8546 )
139231 if err != nil {
140232 return err
141233 }
142- d .L2SeqRollup , err = d .rollupClient ("op-node-sequencer" , 9545 )
234+ d .L2SeqRollup , err = d .rollupClient (d . getServiceName ( ServiceL2Seq ) , 9545 )
143235 if err != nil {
144236 return err
145237 }
146- d .L2Verif , err = d .serviceClient ("op-geth-verifier" , 8546 )
238+ d .L2Verif , err = d .serviceClient (d . getServiceName ( ServiceL2VerifGeth ) , 8546 )
147239 if err != nil {
148240 return err
149241 }
150- d .L2VerifRollup , err = d .rollupClient ("op-node-verifier" , 9546 )
242+ d .L2VerifRollup , err = d .rollupClient (d . getServiceName ( ServiceL2Verif ) , 9546 )
151243 if err != nil {
152244 return err
153245 }
154- d .L1 , err = d .serviceClient ("l1-geth" , 8545 )
246+ d .L1 , err = d .serviceClient (d . getServiceName ( ServiceL1Geth ) , 8545 )
155247 if err != nil {
156248 return err
157249 }
158250
159251 return nil
160252}
161253
162- func (d * Devnet ) ServiceUp (service string ) error {
163- log .Info ("bringing up service" , "service" , service )
254+ func (d * Devnet ) ServiceUp (service Service ) error {
255+ serviceName := d .getServiceName (service )
256+ log .Info ("bringing up service" , "service" , serviceName )
164257 cmd := exec .CommandContext (
165258 d .ctx ,
166- "docker" , "compose" , "up" , "-d" , service ,
259+ "docker" , "compose" , "--profile" , d . getProfile (), " up" , "-d" , serviceName ,
167260 )
168261 return cmd .Run ()
169262}
170263
171- func (d * Devnet ) ServiceDown (service string ) error {
172- log .Info ("shutting down service" , "service" , service )
264+ func (d * Devnet ) ServiceDown (service Service ) error {
265+ serviceName := d .getServiceName (service )
266+ log .Info ("shutting down service" , "service" , serviceName )
173267 cmd := exec .CommandContext (
174268 d .ctx ,
175- "docker" , "compose" , "down" , service ,
269+ "docker" , "compose" , "--profile" , d . getProfile (), " down" , serviceName ,
176270 )
177271 return cmd .Run ()
178272}
179273
180- func (d * Devnet ) ServiceRestart (service string ) error {
274+ func (d * Devnet ) ServiceRestart (service Service ) error {
181275 if err := d .ServiceDown (service ); err != nil {
182276 return err
183277 }
@@ -386,7 +480,7 @@ func (d *Devnet) Down() error {
386480 log .Info ("devnet shutting down" )
387481 cmd := exec .CommandContext (
388482 d .ctx ,
389- "docker" , "compose" , "down" , "-v" , "--remove-orphans" ,
483+ "docker" , "compose" , "--profile" , d . getProfile (), " down" , "-v" , "--remove-orphans" ,
390484 )
391485 return cmd .Run ()
392486}
@@ -532,7 +626,8 @@ func (d *Devnet) OpChallengerOutput(opts ...string) (string, error) {
532626}
533627
534628func (d * Devnet ) opChallengerCmd (opts ... string ) * exec.Cmd {
535- opts = append ([]string {"compose" , "exec" , "op-challenger" , "entrypoint.sh" , "op-challenger" }, opts ... )
629+ serviceName := d .getServiceName (ServiceChallenger )
630+ opts = append ([]string {"compose" , "--profile" , d .getProfile (), "exec" , serviceName , "entrypoint.sh" , "op-challenger" }, opts ... )
536631 cmd := exec .CommandContext (
537632 d .ctx ,
538633 "docker" ,
@@ -552,7 +647,7 @@ func (d *Devnet) hostPort(service string, privatePort uint16) (uint16, error) {
552647 errBuf := new (bytes.Buffer )
553648 cmd := exec .CommandContext (
554649 d .ctx ,
555- "docker" , "compose" , "port" , service , fmt .Sprint (privatePort ),
650+ "docker" , "compose" , "--profile" , d . getProfile (), " port" , service , fmt .Sprint (privatePort ),
556651 )
557652 cmd .Stdout = buf
558653 cmd .Stderr = errBuf
0 commit comments