Skip to content
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

Testnet launcher now works with SGX #1488

Merged
merged 4 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -62,6 +62,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 @@ -82,7 +83,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 @@ -102,6 +103,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