-
Notifications
You must be signed in to change notification settings - Fork 149
oasis-core/go/oasis-test-runner: Add observer fixture and e2e test #6497
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
73507ad
go/oasis-test-runner/oasis: Add Observer node fixture
martintomazic d698df4
go/oasis-test-runner: Add runtime admission policy fixture
martintomazic fd0f549
runtimes/simple-keyvalue: Enable confidential queries
martintomazic 9b99580
go/oasis-test-runner: Add new e2e observer test
martintomazic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| package oasis | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
| "strconv" | ||
|
|
||
| "github.com/oasisprotocol/oasis-core/go/config" | ||
| "github.com/oasisprotocol/oasis-core/go/runtime/bundle" | ||
| runtimeConfig "github.com/oasisprotocol/oasis-core/go/runtime/config" | ||
| ) | ||
|
|
||
| const ( | ||
| observerIdentitySeedTemplate = "ekiden node observer %d" | ||
| ) | ||
|
|
||
| // Observer is an Oasis observer node. | ||
| type Observer struct { | ||
| *Node | ||
|
|
||
| consensusPort uint16 | ||
| p2pPort uint16 | ||
|
|
||
| runtimes []int | ||
| runtimeConfig map[int]map[string]any | ||
| runtimeProvisioner runtimeConfig.RuntimeProvisioner | ||
| } | ||
|
|
||
| // ObserverCfg is the Oasis observer node provisioning configuration. | ||
| type ObserverCfg struct { | ||
| NodeCfg | ||
|
|
||
| Runtimes []int | ||
| RuntimeConfig map[int]map[string]any | ||
| RuntimeProvisioner runtimeConfig.RuntimeProvisioner | ||
| } | ||
|
|
||
| // UpdateRuntimes updates the observer node runtimes. | ||
| func (o *Observer) UpdateRuntimes(runtimes []int) { | ||
| o.runtimes = runtimes | ||
| } | ||
|
|
||
| func (o *Observer) AddArgs(args *argBuilder) error { | ||
| args.appendNetwork(o.net) | ||
|
|
||
| if o.entity.isDebugTestEntity { | ||
| args.appendDebugTestEntity() | ||
| } | ||
|
|
||
| for _, idx := range o.runtimes { | ||
| v := o.net.runtimes[idx] | ||
| // XXX: could support configurable binary idx if ever needed. | ||
| o.addHostedRuntime(v, o.runtimeConfig[idx]) | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func (o *Observer) ModifyConfig() error { | ||
| o.Config.Consensus.ListenAddress = allInterfacesAddr + ":" + strconv.Itoa(int(o.consensusPort)) | ||
| o.Config.Consensus.ExternalAddress = localhostAddr + ":" + strconv.Itoa(int(o.consensusPort)) | ||
|
|
||
| if o.supplementarySanityInterval > 0 { | ||
| o.Config.Consensus.SupplementarySanity.Enabled = true | ||
| o.Config.Consensus.SupplementarySanity.Interval = o.supplementarySanityInterval | ||
| } | ||
|
|
||
| o.Config.P2P.Port = o.p2pPort | ||
|
|
||
| if !o.entity.isDebugTestEntity { | ||
| entityID, _ := o.entity.ID().MarshalText() // Cannot fail. | ||
| o.Config.Registration.EntityID = string(entityID) | ||
| } | ||
|
|
||
| o.Config.Mode = config.ModeClient | ||
| o.Config.Runtime.Provisioner = o.runtimeProvisioner | ||
| o.Config.Runtime.SGX.Loader = o.net.cfg.RuntimeSGXLoaderBinary | ||
| o.Config.Runtime.AttestInterval = o.net.cfg.RuntimeAttestInterval | ||
|
|
||
| o.AddSeedNodesToConfig() | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| // NewObserver provisions a new observer node and adds it to the network. | ||
| func (net *Network) NewObserver(cfg *ObserverCfg) (*Observer, error) { | ||
| observerName := fmt.Sprintf("observer-%d", len(net.observers)) | ||
| host, err := net.GetNamedNode(observerName, &cfg.NodeCfg) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| // Pre-provision the node identity so that we can identify the entity. | ||
| err = host.setProvisionedIdentity(fmt.Sprintf(observerIdentitySeedTemplate, len(net.observers))) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("oasis/observer: failed to provision node identity: %w", err) | ||
| } | ||
|
|
||
| if cfg.RuntimeProvisioner == "" { | ||
| cfg.RuntimeProvisioner = runtimeConfig.RuntimeProvisionerSandboxed | ||
| } | ||
|
|
||
| observer := &Observer{ | ||
| Node: host, | ||
| runtimes: cfg.Runtimes, | ||
| runtimeProvisioner: cfg.RuntimeProvisioner, | ||
| runtimeConfig: cfg.RuntimeConfig, | ||
| consensusPort: host.getProvisionedPort(nodePortConsensus), | ||
| p2pPort: host.getProvisionedPort(nodePortP2P), | ||
| } | ||
|
|
||
| // Remove any exploded bundles on cleanup. | ||
| net.env.AddOnCleanup(func() { | ||
| _ = os.RemoveAll(bundle.ExplodedPath(observer.dir.String())) | ||
| }) | ||
|
|
||
| net.observers = append(net.observers, observer) | ||
| host.features = append(host.features, observer) | ||
|
|
||
| return observer, nil | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
To be able to run this in non-sgx mode we would have to fix:
https://github.com/oasisprotocol/oasis-core/blob/master/go/worker/keymanager/secrets.go#L245:L264. I.e. in non-sgx mode access list obtained from the consensus registered nodes is not applied.
Imo out of scope, also fine with stronger test albeit less practical to test locally.