Skip to content

Commit

Permalink
Testnet launcher now works with SGX (#1488)
Browse files Browse the repository at this point in the history
* Enable a testnet to be spun up with sgx

* fix flag

* default the edgeless db docker image
  • Loading branch information
otherview authored Sep 18, 2023
1 parent c638627 commit df76b51
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions testnet/launcher/cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type TestnetConfigCLI struct {
validatorEnclaveDebug bool
sequencerEnclaveDockerImage string
sequencerEnclaveDebug bool
isSGXEnabled bool
}

// ParseConfigCLI returns a NodeConfigCLI based the cli params and defaults.
Expand All @@ -21,12 +22,14 @@ func ParseConfigCLI() *TestnetConfigCLI {
validatorEnclaveDebug := flag.Bool(validatorEnclaveDebugFlag, false, flagUsageMap[validatorEnclaveDebugFlag])
sequencerEnclaveDockerImage := flag.String(sequencerEnclaveDockerImageFlag, "testnetobscuronet.azurecr.io/obscuronet/enclave:latest", flagUsageMap[sequencerEnclaveDockerImageFlag])
sequencerEnclaveDebug := flag.Bool(sequencerEnclaveDebugFlag, false, flagUsageMap[sequencerEnclaveDebugFlag])
isSGXEnabled := flag.Bool(isSGXEnabledFlag, false, flagUsageMap[isSGXEnabledFlag])
flag.Parse()

cfg.validatorEnclaveDockerImage = *validatorEnclaveDockerImage
cfg.sequencerEnclaveDockerImage = *sequencerEnclaveDockerImage
cfg.validatorEnclaveDebug = *validatorEnclaveDebug
cfg.sequencerEnclaveDebug = *sequencerEnclaveDebug
cfg.isSGXEnabled = *isSGXEnabled

return cfg
}
2 changes: 2 additions & 0 deletions testnet/launcher/cmd/cli_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const (
validatorEnclaveDebugFlag = "validator-enclave-debug"
sequencerEnclaveDockerImageFlag = "sequencer-enclave-docker-image"
sequencerEnclaveDebugFlag = "sequencer-enclave-debug"
isSGXEnabledFlag = "is-sgx-enabled"
)

// Returns a map of the flag usages.
Expand All @@ -16,5 +17,6 @@ func getFlagUsageMap() map[string]string {
validatorEnclaveDebugFlag: "Enables the use of DLV to debug the validator enclave",
sequencerEnclaveDockerImageFlag: "The docker image that runs the sequencer enclave",
sequencerEnclaveDebugFlag: "Enables the use of DLV to debug the sequencer enclave",
isSGXEnabledFlag: "Enables the SGX usage",
}
}
1 change: 1 addition & 0 deletions testnet/launcher/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func main() {
launcher.WithValidatorEnclaveDebug(cliConfig.validatorEnclaveDebug),
launcher.WithSequencerEnclaveDockerImage(cliConfig.sequencerEnclaveDockerImage),
launcher.WithSequencerEnclaveDebug(cliConfig.sequencerEnclaveDebug),
launcher.WithSGXEnabled(cliConfig.isSGXEnabled),
),
)
err := testnet.Start()
Expand Down
7 changes: 7 additions & 0 deletions testnet/launcher/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Config struct {

validatorEnclaveDockerImage string
validatorEnclaveDebug bool
isSGXEnabled bool
}

func NewTestnetConfig(opts ...Option) *Config {
Expand Down Expand Up @@ -45,3 +46,9 @@ func WithValidatorEnclaveDebug(b bool) Option {
c.validatorEnclaveDebug = b
}
}

func WithSGXEnabled(b bool) Option {
return func(c *Config) {
c.isSGXEnabled = b
}
}
6 changes: 4 additions & 2 deletions testnet/launcher/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (t *Testnet) Start() error {
node.WithNodeName("sequencer"),
node.WithNodeType("sequencer"),
node.WithGenesis(true),
node.WithSGXEnabled(false),
node.WithSGXEnabled(t.cfg.isSGXEnabled),
node.WithEnclaveImage(t.cfg.sequencerEnclaveDockerImage),
node.WithEnclaveDebug(t.cfg.sequencerEnclaveDebug),
node.WithHostImage("testnetobscuronet.azurecr.io/obscuronet/host:latest"),
Expand All @@ -61,6 +61,7 @@ func (t *Testnet) Start() error {
node.WithInMemoryHostDB(true),
node.WithDebugNamespaceEnabled(true),
node.WithLogLevel(4),
node.WithEdgelessDBImage("ghcr.io/edgelesssys/edgelessdb-sgx-4gb:v0.3.2"), // default edgeless db value
)

sequencerNode := node.NewDockerNode(sequencerNodeConfig)
Expand All @@ -81,7 +82,7 @@ func (t *Testnet) Start() error {
node.WithNodeName("validator"),
node.WithNodeType("validator"),
node.WithGenesis(false),
node.WithSGXEnabled(false),
node.WithSGXEnabled(t.cfg.isSGXEnabled),
node.WithEnclaveImage(t.cfg.validatorEnclaveDockerImage),
node.WithEnclaveDebug(t.cfg.validatorEnclaveDebug),
node.WithHostImage("testnetobscuronet.azurecr.io/obscuronet/host:latest"),
Expand All @@ -100,6 +101,7 @@ func (t *Testnet) Start() error {
node.WithInMemoryHostDB(true),
node.WithDebugNamespaceEnabled(true),
node.WithLogLevel(4),
node.WithEdgelessDBImage("ghcr.io/edgelesssys/edgelessdb-sgx-4gb:v0.3.2"), // default edgeless db value
)

validatorNode := node.NewDockerNode(validatorNodeConfig)
Expand Down

0 comments on commit df76b51

Please sign in to comment.