-
Notifications
You must be signed in to change notification settings - Fork 0
TA4: Enclave restart test #215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: celo-integration-rebase-13.2
Are you sure you want to change the base?
Changes from all commits
3be1bd2
61766cc
ab312ae
1b9e42e
31b6271
523723d
081d914
076c8b6
88186fd
f961472
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ import ( | |
| "time" | ||
|
|
||
| "github.com/ethereum-optimism/optimism/op-e2e/bindings" | ||
| "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/geth" | ||
| "github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait" | ||
| "github.com/ethereum-optimism/optimism/op-e2e/system/helpers" | ||
| "github.com/ethereum-optimism/optimism/op-node/rollup" | ||
|
|
@@ -32,8 +33,85 @@ import ( | |
| "github.com/ethereum-optimism/optimism/op-e2e/config/secrets" | ||
| ) | ||
|
|
||
| type Service uint64 | ||
|
|
||
| const ( | ||
| ServiceBatcher Service = iota | ||
| ServiceCaffNode | ||
| ServiceCaffNodeGeth | ||
| ServiceChallenger | ||
| ServiceDevNode | ||
| ServiceHTTPProxy | ||
| ServiceL1Beacon | ||
| ServiceL1DataInit | ||
| ServiceL1Genesis | ||
| ServiceL1Geth | ||
| ServiceL1Validator | ||
| ServiceL2Genesis | ||
| ServiceL2Rollup | ||
| ServiceL2Seq | ||
| ServiceL2SeqGeth | ||
| ServiceL2Verif | ||
| ServiceL2VerifGeth | ||
| ServiceProposer | ||
| ) | ||
|
|
||
| const ( | ||
| ProfileDefault = "default" | ||
| ProfileTee = "tee" | ||
| ) | ||
|
|
||
| type Profile struct { | ||
| BatcherService string | ||
| ProposerService string | ||
| } | ||
|
|
||
| // modifyDefaultProfile creates a new profile based on the default profile with specified modifications | ||
| func modifyDefaultProfile(modifications map[Service]string) map[Service]string { | ||
| result := make(map[Service]string) | ||
| // Copy all services from default profile | ||
| for service, container := range defaultProfile { | ||
| result[service] = container | ||
| } | ||
| // Apply modifications | ||
| for service, container := range modifications { | ||
| result[service] = container | ||
| } | ||
| return result | ||
| } | ||
|
|
||
| var defaultProfile = map[Service]string{ | ||
| ServiceBatcher: "op-batcher", | ||
| ServiceCaffNode: "caff-node", | ||
| ServiceCaffNodeGeth: "op-geth-caff-node", | ||
| ServiceChallenger: "op-challenger", | ||
| ServiceDevNode: "espresso-dev-node", | ||
| ServiceHTTPProxy: "http-proxy", | ||
| ServiceL1Beacon: "l1-beacon", | ||
| ServiceL1DataInit: "l1-data-init", | ||
| ServiceL1Genesis: "l1-genesis", | ||
| ServiceL1Geth: "l1-geth", | ||
| ServiceL1Validator: "l1-validator", | ||
| ServiceL2Genesis: "l2-genesis", | ||
| ServiceL2Rollup: "l2-rollup", | ||
| ServiceL2Seq: "op-node-sequencer", | ||
| ServiceL2SeqGeth: "op-geth-sequencer", | ||
| ServiceL2Verif: "op-node-verifier", | ||
| ServiceL2VerifGeth: "op-geth-verifier", | ||
| ServiceProposer: "op-proposer", | ||
| } | ||
|
|
||
| var Profiles = map[string]map[Service]string{ | ||
| ProfileDefault: defaultProfile, | ||
| ProfileTee: modifyDefaultProfile(map[Service]string{ | ||
| ServiceBatcher: "op-batcher-tee", | ||
| ServiceProposer: "op-proposer-tee", | ||
| }), | ||
| } | ||
|
|
||
| type Devnet struct { | ||
| ctx context.Context | ||
| tee bool | ||
| secrets secrets.Secrets | ||
| outageTime time.Duration | ||
| successTime time.Duration | ||
|
|
@@ -85,7 +163,7 @@ func NewDevnet(ctx context.Context, t *testing.T) *Devnet { | |
| func (d *Devnet) isRunning() bool { | ||
| cmd := exec.CommandContext( | ||
| d.ctx, | ||
| "docker", "compose", "ps", "-q", | ||
| "docker", "compose", "--profile", d.getProfile(), "ps", "-q", | ||
| ) | ||
| buf := new(bytes.Buffer) | ||
| cmd.Stdout = buf | ||
|
|
@@ -97,6 +175,27 @@ func (d *Devnet) isRunning() bool { | |
| return len(out) > 0 | ||
| } | ||
|
|
||
| // getProfile returns the current profile name based on devnet configuration | ||
| func (d *Devnet) getProfile() string { | ||
| if d.tee { | ||
| return ProfileTee | ||
| } | ||
| return ProfileDefault | ||
| } | ||
|
|
||
| // getServiceName returns the container name for a given service in the current profile | ||
| func (d *Devnet) getServiceName(service Service) string { | ||
| profile := d.getProfile() | ||
| if container, ok := Profiles[profile][service]; ok { | ||
| return container | ||
| } | ||
| // Fall back to default profile if service not found | ||
| if container, ok := Profiles[ProfileDefault][service]; ok { | ||
| return container | ||
| } | ||
| return "" | ||
| } | ||
|
|
||
| func (d *Devnet) Up() (err error) { | ||
| if d.isRunning() { | ||
| if err := d.Down(); err != nil { | ||
|
|
@@ -107,9 +206,11 @@ func (d *Devnet) Up() (err error) { | |
| return fmt.Errorf("devnet is already running, this should be a clean state; please shut it down first") | ||
| } | ||
|
|
||
| profile := d.getProfile() | ||
|
|
||
| cmd := exec.CommandContext( | ||
| d.ctx, | ||
| "docker", "compose", "up", "-d", | ||
| "docker", "compose", "--profile", profile, "up", "-d", | ||
| ) | ||
| cmd.Env = append( | ||
| cmd.Env, | ||
|
|
@@ -144,7 +245,7 @@ func (d *Devnet) Up() (err error) { | |
| // Stream logs to stdout while the test runs. This goroutine will automatically exit when | ||
| // the context is cancelled. | ||
| go func() { | ||
| cmd = exec.CommandContext(d.ctx, "docker", "compose", "logs", "-f") | ||
| cmd = exec.CommandContext(d.ctx, "docker", "compose", "--profile", profile, "logs", "-f") | ||
| cmd.Stdout = os.Stdout | ||
| // We don't care about the error return of this command, since it's always going to be | ||
| // killed by the context cancellation. | ||
|
|
@@ -153,50 +254,65 @@ func (d *Devnet) Up() (err error) { | |
| } | ||
|
|
||
| // Open RPC clients for the different nodes. | ||
| d.L2Seq, err = d.serviceClient("op-geth-sequencer", 8546) | ||
| d.L2Seq, err = d.serviceClient(d.getServiceName(ServiceL2SeqGeth), 8546) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| d.L2SeqRollup, err = d.rollupClient("op-node-sequencer", 9545) | ||
| d.L2SeqRollup, err = d.rollupClient(d.getServiceName(ServiceL2Seq), 9545) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| d.L2Verif, err = d.serviceClient("op-geth-verifier", 8546) | ||
| d.L2Verif, err = d.serviceClient(d.getServiceName(ServiceL2VerifGeth), 8546) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| d.L2VerifRollup, err = d.rollupClient("op-node-verifier", 9546) | ||
| d.L2VerifRollup, err = d.rollupClient(d.getServiceName(ServiceL2Verif), 9546) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| d.L1, err = d.serviceClient("l1-geth", 8545) | ||
| d.L1, err = d.serviceClient(d.getServiceName(ServiceL1Geth), 8545) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func (d *Devnet) ServiceUp(service string) error { | ||
| log.Info("bringing up service", "service", service) | ||
| func (d *Devnet) WaitForL2Operational() error { | ||
|
|
||
| timeout := time.Minute * 5 | ||
|
|
||
| // Batcher needs more time to startup in tee | ||
| if d.getProfile() == "tee" { | ||
| timeout = time.Minute * 10 | ||
| } | ||
|
|
||
| _, err := geth.WaitForBlockToBeSafe(big.NewInt(1), d.L2Verif, timeout) | ||
| return err | ||
| } | ||
|
|
||
| func (d *Devnet) ServiceUp(service Service) error { | ||
| serviceName := d.getServiceName(service) | ||
| log.Info("bringing up service", "service", serviceName) | ||
| cmd := exec.CommandContext( | ||
| d.ctx, | ||
| "docker", "compose", "up", "-d", service, | ||
| "docker", "compose", "--profile", d.getProfile(), "up", "-d", serviceName, | ||
| ) | ||
| return cmd.Run() | ||
| } | ||
|
|
||
| func (d *Devnet) ServiceDown(service string) error { | ||
| log.Info("shutting down service", "service", service) | ||
| func (d *Devnet) ServiceDown(service Service) error { | ||
| serviceName := d.getServiceName(service) | ||
| log.Info("shutting down service", "service", serviceName) | ||
| cmd := exec.CommandContext( | ||
| d.ctx, | ||
| "docker", "compose", "down", service, | ||
| "docker", "compose", "--profile", d.getProfile(), "down", serviceName, | ||
| ) | ||
| return cmd.Run() | ||
| } | ||
|
Comment on lines
+305
to
313
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This reminds me of one thing:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh interesting. I'll see what we can do here |
||
|
|
||
| func (d *Devnet) ServiceRestart(service string) error { | ||
| func (d *Devnet) ServiceRestart(service Service) error { | ||
| if err := d.ServiceDown(service); err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -422,7 +538,7 @@ func (d *Devnet) Down() error { | |
| // Use timeout flag for faster Docker shutdown | ||
| cmd := exec.CommandContext( | ||
| d.ctx, | ||
| "docker", "compose", "down", "-v", "--remove-orphans", "--timeout", "10", | ||
| "docker", "compose", "--profile", d.getProfile(), "down", "-v", "--remove-orphans", "--timeout", "10", | ||
| ) | ||
| return cmd.Run() | ||
| } | ||
|
|
@@ -568,7 +684,8 @@ func (d *Devnet) OpChallengerOutput(opts ...string) (string, error) { | |
| } | ||
|
|
||
| func (d *Devnet) opChallengerCmd(opts ...string) *exec.Cmd { | ||
| opts = append([]string{"compose", "exec", "op-challenger", "entrypoint.sh", "op-challenger"}, opts...) | ||
| serviceName := d.getServiceName(ServiceChallenger) | ||
| opts = append([]string{"compose", "--profile", d.getProfile(), "exec", serviceName, "entrypoint.sh", "op-challenger"}, opts...) | ||
| cmd := exec.CommandContext( | ||
| d.ctx, | ||
| "docker", | ||
|
|
@@ -588,7 +705,7 @@ func (d *Devnet) hostPort(service string, privatePort uint16) (uint16, error) { | |
| errBuf := new(bytes.Buffer) | ||
| cmd := exec.CommandContext( | ||
| d.ctx, | ||
| "docker", "compose", "port", service, fmt.Sprint(privatePort), | ||
| "docker", "compose", "--profile", d.getProfile(), "port", service, fmt.Sprint(privatePort), | ||
| ) | ||
| cmd.Stdout = buf | ||
| cmd.Stderr = errBuf | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized to restart op-batcher-tee we not only need profile to be tee but also need things like restarting the service op-batcher-tee specifically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's a big catch for sure, thanks. No idea how it passed for me in the first place.