Skip to content

Commit

Permalink
go/registry: Add a Version field
Browse files Browse the repository at this point in the history
 * Just has the allowed MRSIGNER/MRENCLAVE pairs for now, will have
   also be where I move the non-SGX versioning when it happens.
  • Loading branch information
Yawning committed Aug 21, 2019
1 parent 9d6955c commit 07abec4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
6 changes: 6 additions & 0 deletions go/grpc/registry/runtime.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ message Runtime {
uint32 kind = 8;

bytes key_manager = 9;

VersionInfo version = 10;
}

message VersionInfo {
bytes tee = 1;
}

service RuntimeRegistry {
Expand Down
33 changes: 33 additions & 0 deletions go/registry/api/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/oasislabs/ekiden/go/common/crypto/hash"
"github.com/oasislabs/ekiden/go/common/crypto/signature"
"github.com/oasislabs/ekiden/go/common/node"
"github.com/oasislabs/ekiden/go/common/sgx"
pbRegistry "github.com/oasislabs/ekiden/go/grpc/registry"
storage "github.com/oasislabs/ekiden/go/storage/api"
)
Expand Down Expand Up @@ -70,6 +71,9 @@ type Runtime struct {

// KeyManager is the key manager runtime ID for this runtime.
KeyManager signature.PublicKey `codec:"key_manager"`

// Version is the runtime version information.
Version VersionInfo `codec:"versions"`
}

// String returns a string representation of itself.
Expand Down Expand Up @@ -110,6 +114,10 @@ func (c *Runtime) FromProto(pb *pbRegistry.Runtime) error {
return err
}

if err := c.Version.fromProto(pb.GetVersion()); err != nil {
return err
}

c.ReplicaGroupSize = pb.GetReplicaGroupSize()
c.ReplicaGroupBackupSize = pb.GetReplicaGroupBackupSize()
c.ReplicaAllowedStragglers = pb.GetReplicaAllowedStragglers()
Expand All @@ -134,6 +142,7 @@ func (c *Runtime) ToProto() *pbRegistry.Runtime {
if pb.KeyManager, err = c.KeyManager.MarshalBinary(); err != nil {
panic(err)
}
pb.Version = c.Version.toProto()
pb.ReplicaGroupSize = c.ReplicaGroupSize
pb.ReplicaGroupBackupSize = c.ReplicaGroupBackupSize
pb.ReplicaAllowedStragglers = c.ReplicaAllowedStragglers
Expand Down Expand Up @@ -181,6 +190,30 @@ func SignRuntime(signer signature.Signer, context []byte, runtime *Runtime) (*Si
}, nil
}

// VersionInfo is the per-runtime version information.
type VersionInfo struct {
// TEE is the enclave version information, in an enclave provider specific
// format if any.
TEE []byte `codec:"tee,omit_empty"`
}

func (v *VersionInfo) fromProto(pb *pbRegistry.VersionInfo) error {
v.TEE = append([]byte{}, pb.GetTee()...)
return nil
}

func (v *VersionInfo) toProto() *pbRegistry.VersionInfo {
pb := new(pbRegistry.VersionInfo)
pb.Tee = append([]byte{}, v.TEE...)
return pb
}

// VersionInfoIntelSGX is the SGX TEE version information.
type VersionInfoIntelSGX struct {
// Enclaves is the allowed MRSIGNER/MRENCLAVE pairs.
Enclaves []sgx.EnclaveIdentity `codec:"enclaves"`
}

// RuntimeGenesis is the runtime genesis information that is used to
// initialize runtime state in the first block.
type RuntimeGenesis struct {
Expand Down
3 changes: 3 additions & 0 deletions go/registry/api/runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ func TestSerialization(t *testing.T) {
ReplicaAllowedStragglers: 81,
StorageGroupSize: 90,
KeyManager: signature.PublicKey(key),
Version: VersionInfo{
TEE: []byte{},
},
}

cp := c.ToProto()
Expand Down

0 comments on commit 07abec4

Please sign in to comment.