Skip to content

Commit 859e7a8

Browse files
committed
go/oasis-test-runner: Add e2e test for compute runtime quote policy
1 parent 0044558 commit 859e7a8

6 files changed

Lines changed: 83 additions & 9 deletions

File tree

.buildkite/code.pipeline.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,10 @@ steps:
356356
command:
357357
- trap 'buildkite-agent artifact upload "coverage-merged-e2e-*.txt;/tmp/e2e/**/*.log;/tmp/e2e/**/genesis.json;/tmp/e2e/**/runtime_genesis.json"' EXIT
358358
- .buildkite/scripts/download_e2e_test_artifacts_mocksgx.sh
359-
- .buildkite/scripts/test_e2e.sh --timeout 20m --scenario e2e/runtime/runtime-encryption
359+
- .buildkite/scripts/test_e2e.sh --timeout 20m
360+
--scenario e2e/runtime/runtime-encryption
361+
--scenario e2e/runtime/compute-policy
362+
360363
env:
361364
OASIS_TEE_HARDWARE: intel-sgx
362365
OASIS_UNSAFE_MOCK_TEE: "1"

go/oasis-test-runner/oasis/fixture.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/oasisprotocol/oasis-core/go/common/crypto/hash"
1010
"github.com/oasisprotocol/oasis-core/go/common/node"
1111
"github.com/oasisprotocol/oasis-core/go/common/sgx"
12+
"github.com/oasisprotocol/oasis-core/go/common/sgx/quote"
1213
"github.com/oasisprotocol/oasis-core/go/consensus/cometbft/config"
1314
"github.com/oasisprotocol/oasis-core/go/oasis-test-runner/env"
1415
"github.com/oasisprotocol/oasis-core/go/oasis-test-runner/log"
@@ -247,6 +248,9 @@ type RuntimeFixture struct {
247248

248249
GovernanceModel registry.RuntimeGovernanceModel `json:"governance_model"`
249250

251+
// ComputePolicy is an optional compute runtime quote policy.
252+
ComputePolicy *quote.Policy `json:"compute_policy,omitempty"`
253+
250254
Pruner RuntimePrunerCfg `json:"pruner,omitempty"`
251255

252256
ExcludeFromGenesis bool `json:"exclude_from_genesis,omitempty"`
@@ -279,6 +283,7 @@ func (f *RuntimeFixture) Create(netFixture *NetworkFixture, net *Network) (*Runt
279283
Keymanager: km,
280284
TEEHardware: netFixture.TEE.Hardware,
281285
MrSigner: netFixture.TEE.MrSigner,
286+
ComputePolicy: f.ComputePolicy,
282287
Executor: f.Executor,
283288
TxnScheduler: f.TxnScheduler,
284289
Storage: f.Storage,

go/oasis-test-runner/oasis/runtime.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/oasisprotocol/oasis-core/go/common/crypto/hash"
1515
"github.com/oasisprotocol/oasis-core/go/common/node"
1616
"github.com/oasisprotocol/oasis-core/go/common/sgx"
17+
"github.com/oasisprotocol/oasis-core/go/common/sgx/quote"
1718
"github.com/oasisprotocol/oasis-core/go/common/version"
1819
"github.com/oasisprotocol/oasis-core/go/oasis-test-runner/env"
1920
registry "github.com/oasisprotocol/oasis-core/go/registry/api"
@@ -48,8 +49,9 @@ type Runtime struct {
4849
// of this file is discouraged (if not entirely forbidden).
4950
cfgSave runtimeCfgSave
5051

51-
teeHardware node.TEEHardware
52-
mrSigner *sgx.MrSigner
52+
teeHardware node.TEEHardware
53+
mrSigner *sgx.MrSigner
54+
computePolicy *quote.Policy
5355

5456
pruner RuntimePrunerCfg
5557

@@ -59,12 +61,13 @@ type Runtime struct {
5961

6062
// RuntimeCfg is the Oasis runtime provisioning configuration.
6163
type RuntimeCfg struct {
62-
ID common.Namespace
63-
Kind registry.RuntimeKind
64-
Entity *Entity
65-
Keymanager *Runtime
66-
TEEHardware node.TEEHardware
67-
MrSigner *sgx.MrSigner
64+
ID common.Namespace
65+
Kind registry.RuntimeKind
66+
Entity *Entity
67+
Keymanager *Runtime
68+
TEEHardware node.TEEHardware
69+
MrSigner *sgx.MrSigner
70+
ComputePolicy *quote.Policy
6871

6972
Deployments []DeploymentCfg
7073
GenesisRound uint64
@@ -231,12 +234,14 @@ func (rt *Runtime) toRuntimeBundle(index int, cfg *deploymentCfg) (*bundle.Bundl
231234
}
232235

233236
cfg.versionInfo.TEE = cbor.Marshal(node.SGXConstraints{
237+
Versioned: cbor.NewVersioned(1),
234238
Enclaves: []sgx.EnclaveIdentity{
235239
{
236240
MrEnclave: *mrEnclave,
237241
MrSigner: *rt.mrSigner,
238242
},
239243
},
244+
ComputePolicy: rt.computePolicy,
240245
})
241246
cfg.mrEnclave = mrEnclave
242247
return nil
@@ -371,6 +376,7 @@ func (net *Network) NewRuntime(cfg *RuntimeCfg) (*Runtime, error) {
371376
kind: cfg.Kind,
372377
teeHardware: cfg.TEEHardware,
373378
mrSigner: cfg.MrSigner,
379+
computePolicy: cfg.ComputePolicy,
374380
pruner: cfg.Pruner,
375381
excludeFromGenesis: cfg.ExcludeFromGenesis,
376382
descriptor: descriptor,
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package runtime
2+
3+
import (
4+
"context"
5+
6+
"github.com/oasisprotocol/oasis-core/go/common/sgx/pcs"
7+
"github.com/oasisprotocol/oasis-core/go/common/sgx/quote"
8+
"github.com/oasisprotocol/oasis-core/go/oasis-test-runner/env"
9+
"github.com/oasisprotocol/oasis-core/go/oasis-test-runner/oasis"
10+
"github.com/oasisprotocol/oasis-core/go/oasis-test-runner/scenario"
11+
)
12+
13+
// ComputePolicy is the compute runtime quote policy e2e test scenario.
14+
var ComputePolicy scenario.Scenario = newComputePolicyImpl()
15+
16+
type computePolicyImpl struct {
17+
Scenario
18+
}
19+
20+
func newComputePolicyImpl() scenario.Scenario {
21+
return &computePolicyImpl{
22+
Scenario: *NewScenario("compute-policy", NewTestClient().WithScenario(SimpleScenario)),
23+
}
24+
}
25+
26+
func (sc *computePolicyImpl) Clone() scenario.Scenario {
27+
return &computePolicyImpl{
28+
Scenario: *sc.Scenario.Clone().(*Scenario),
29+
}
30+
}
31+
32+
func (sc *computePolicyImpl) Fixture() (*oasis.NetworkFixture, error) {
33+
f, err := sc.Scenario.Fixture()
34+
if err != nil {
35+
return nil, err
36+
}
37+
38+
f.Runtimes[1].ComputePolicy = &quote.Policy{
39+
PCS: &pcs.QuotePolicy{
40+
TCBValidityPeriod: 90,
41+
MinTCBEvaluationDataNumber: 12,
42+
},
43+
}
44+
45+
return f, nil
46+
}
47+
48+
func (sc *computePolicyImpl) Run(ctx context.Context, childEnv *env.Env) error {
49+
if err := sc.StartNetworkAndTestClient(ctx, childEnv); err != nil {
50+
return err
51+
}
52+
53+
return sc.WaitTestClientAndCheckLogs()
54+
}

go/oasis-test-runner/scenario/e2e/runtime/scenario.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ func RegisterScenarios() error {
419419
// it is identical to the txsource-multi-short, only using fewer nodes
420420
// due to SGX CI instance resource constrains.
421421
TxSourceMultiShortSGX,
422+
// SGXConstraints tests.
423+
ComputePolicy,
422424
} {
423425
if err := cmd.RegisterNondefault(s); err != nil {
424426
return err

runtime/src/consensus/registry.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,10 @@ pub enum SGXConstraints {
703703
#[cbor(optional)]
704704
policy: sgx::QuotePolicy,
705705

706+
/// The compute runtime quote policy.
707+
#[cbor(optional)]
708+
compute_policy: sgx::QuotePolicy,
709+
706710
/// The maximum attestation age (in blocks).
707711
#[cbor(optional)]
708712
max_attestation_age: u64,

0 commit comments

Comments
 (0)