From df76b51aa6c9706bdbff1c2b2b7688695a522dab Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 18 Sep 2023 11:42:41 +0100 Subject: [PATCH] Testnet launcher now works with SGX (#1488) * Enable a testnet to be spun up with sgx * fix flag * default the edgeless db docker image --- testnet/launcher/cmd/cli.go | 3 +++ testnet/launcher/cmd/cli_flags.go | 2 ++ testnet/launcher/cmd/main.go | 1 + testnet/launcher/config.go | 7 +++++++ testnet/launcher/docker.go | 6 ++++-- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/testnet/launcher/cmd/cli.go b/testnet/launcher/cmd/cli.go index 1d243c9d38..0db6b2838b 100644 --- a/testnet/launcher/cmd/cli.go +++ b/testnet/launcher/cmd/cli.go @@ -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. @@ -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 } diff --git a/testnet/launcher/cmd/cli_flags.go b/testnet/launcher/cmd/cli_flags.go index 95eac8047c..0d56afa952 100644 --- a/testnet/launcher/cmd/cli_flags.go +++ b/testnet/launcher/cmd/cli_flags.go @@ -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. @@ -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", } } diff --git a/testnet/launcher/cmd/main.go b/testnet/launcher/cmd/main.go index fd59d7ee8c..fb8cdc3713 100644 --- a/testnet/launcher/cmd/main.go +++ b/testnet/launcher/cmd/main.go @@ -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() diff --git a/testnet/launcher/config.go b/testnet/launcher/config.go index 554877bb48..75305b916b 100644 --- a/testnet/launcher/config.go +++ b/testnet/launcher/config.go @@ -10,6 +10,7 @@ type Config struct { validatorEnclaveDockerImage string validatorEnclaveDebug bool + isSGXEnabled bool } func NewTestnetConfig(opts ...Option) *Config { @@ -45,3 +46,9 @@ func WithValidatorEnclaveDebug(b bool) Option { c.validatorEnclaveDebug = b } } + +func WithSGXEnabled(b bool) Option { + return func(c *Config) { + c.isSGXEnabled = b + } +} diff --git a/testnet/launcher/docker.go b/testnet/launcher/docker.go index 80f4ad0390..9804d74f8e 100644 --- a/testnet/launcher/docker.go +++ b/testnet/launcher/docker.go @@ -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"), @@ -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) @@ -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"), @@ -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)