Skip to content

Commit

Permalink
Merge pull request #2881 from oasislabs/kostko/feature/tm-light-client
Browse files Browse the repository at this point in the history
Basic consensus light client support
  • Loading branch information
kostko authored May 6, 2020
2 parents 892cc0b + 20107f5 commit 6c55f94
Show file tree
Hide file tree
Showing 22 changed files with 570 additions and 51 deletions.
1 change: 1 addition & 0 deletions .changelog/2440.feature.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/consensus: Add basic API for supporting light consensus clients
9 changes: 9 additions & 0 deletions .changelog/2440.feature.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
go/worker/consensusrpc: Add public consensus RPC services worker

A public consensus services worker enables any full consensus node to expose
light client services to other nodes that may need them (e.g., they are needed
to support light clients).

The worker can be enabled using `--worker.consensusrpc.enabled` and is
disabled by default. Enabling the public consensus services worker exposes
the light consensus client interface over publicly accessible gRPC.
1 change: 1 addition & 0 deletions .changelog/2881.breaking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/common/node: Add RoleConsensusRPC role bit
17 changes: 11 additions & 6 deletions go/common/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,20 @@ type Node struct {
type RolesMask uint32

const (
// RoleComputeWorker is Oasis compute worker role.
// RoleComputeWorker is the compute worker role.
RoleComputeWorker RolesMask = 1 << 0
// RoleStorageWorker is Oasis storage worker role.
// RoleStorageWorker is the storage worker role.
RoleStorageWorker RolesMask = 1 << 1
// RoleKeyManager is the Oasis key manager role.
// RoleKeyManager is the the key manager role.
RoleKeyManager RolesMask = 1 << 2
// RoleValidator is the Oasis validator role.
// RoleValidator is the validator role.
RoleValidator RolesMask = 1 << 3
// RoleConsensusRPC is the public consensus RPC services worker role.
RoleConsensusRPC RolesMask = 1 << 4

// RoleReserved are all the bits of the Oasis node roles bitmask
// that are reserved and must not be used.
RoleReserved RolesMask = ((1 << 32) - 1) & ^((RoleValidator << 1) - 1)
RoleReserved RolesMask = ((1 << 32) - 1) & ^((RoleConsensusRPC << 1) - 1)
)

// IsSingleRole returns true if RolesMask encodes a single valid role.
Expand All @@ -102,11 +104,14 @@ func (m RolesMask) String() string {
ret = append(ret, "storage")
}
if m&RoleKeyManager != 0 {
ret = append(ret, "key_manager")
ret = append(ret, "key-manager")
}
if m&RoleValidator != 0 {
ret = append(ret, "validator")
}
if m&RoleConsensusRPC != 0 {
ret = append(ret, "consensus-rpc")
}

return strings.Join(ret, ",")
}
Expand Down
10 changes: 8 additions & 2 deletions go/consensus/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package api

import (
"context"
"time"

beacon "github.com/oasislabs/oasis-core/go/beacon/api"
"github.com/oasislabs/oasis-core/go/common/cbor"
Expand Down Expand Up @@ -42,9 +43,10 @@ var (
ErrVersionNotFound = errors.New(moduleName, 3, "consensus: version not found")
)

// ClientBackend is a limited consensus interface used by clients that
// connect to the local node.
// ClientBackend is a limited consensus interface used by clients that connect to the local full
// node. This is separate from light clients which use the LightClientBackend interface.
type ClientBackend interface {
LightClientBackend
TransactionAuthHandler

// SubmitTx submits a signed consensus transaction.
Expand Down Expand Up @@ -87,6 +89,10 @@ type ClientBackend interface {
type Block struct {
// Height contains the block height.
Height int64 `json:"height"`
// Hash contains the block header hash.
Hash []byte `json:"hash"`
// Time is the second-granular consensus time.
Time time.Time `json:"time"`
// Meta contains the consensus backend specific block metadata.
Meta cbor.RawMessage `json:"meta"`
}
Expand Down
Loading

0 comments on commit 6c55f94

Please sign in to comment.