@@ -8,9 +8,12 @@ import (
88
99 beacon "github.com/oasisprotocol/oasis-core/go/beacon/api"
1010 "github.com/oasisprotocol/oasis-core/go/common/crash"
11+ "github.com/oasisprotocol/oasis-core/go/common/crypto/signature"
12+ "github.com/oasisprotocol/oasis-core/go/common/entity"
1113 "github.com/oasisprotocol/oasis-core/go/common/grpc"
1214 "github.com/oasisprotocol/oasis-core/go/common/identity"
1315 "github.com/oasisprotocol/oasis-core/go/common/logging"
16+ "github.com/oasisprotocol/oasis-core/go/common/node"
1417 "github.com/oasisprotocol/oasis-core/go/common/persistent"
1518 "github.com/oasisprotocol/oasis-core/go/common/version"
1619 "github.com/oasisprotocol/oasis-core/go/config"
@@ -72,6 +75,7 @@ type Node struct {
7275
7376 Upgrader upgradeAPI.Backend
7477 Identity * identity.Identity
78+ EntityID * signature.PublicKey
7579 Sentry sentryAPI.Backend
7680
7781 RuntimeRegistry runtimeRegistry.Registry
@@ -190,9 +194,18 @@ func (n *Node) startRuntimeServices(genesisDoc *genesisAPI.Document) error {
190194}
191195
192196func (n * Node ) initRuntimeWorkers (genesisDoc * genesisAPI.Document ) error {
193- var err error
197+ // Parse sentry configuration.
198+ var sentryAddresses []node.TLSAddress
199+ for _ , v := range config .GlobalConfig .Runtime .SentryAddresses {
200+ var tlsAddr node.TLSAddress
201+ if err := tlsAddr .UnmarshalText ([]byte (v )); err != nil {
202+ return fmt .Errorf ("bad sentry address (%s): %w" , v , err )
203+ }
204+ sentryAddresses = append (sentryAddresses , tlsAddr )
205+ }
194206
195207 // Initialize runtime provisioner.
208+ var err error
196209 n .Provisioner , err = provisioner .New (n .dataDir , n .commonStore , n .Identity , n .Consensus , genesisDoc )
197210 if err != nil {
198211 return err
@@ -206,9 +219,11 @@ func (n *Node) initRuntimeWorkers(genesisDoc *genesisAPI.Document) error {
206219 n .svcMgr .Register (n .RuntimeRegistry )
207220
208221 // Initialize the common worker.
222+ commonCfg := workerCommon.Config {
223+ TxPool : config .GlobalConfig .Runtime .TxPool ,
224+ }
209225 n .CommonWorker , err = workerCommon .New (
210- n ,
211- n .dataDir ,
226+ commonCfg ,
212227 n .chainContext ,
213228 n .Identity ,
214229 n .Consensus ,
@@ -226,16 +241,15 @@ func (n *Node) initRuntimeWorkers(genesisDoc *genesisAPI.Document) error {
226241 }
227242 n .svcMgr .Register (n .CommonWorker )
228243
229- workerCommonCfg := n .CommonWorker .GetConfig ()
230-
231244 // Initialize the registration worker.
232245 n .RegistrationWorker , err = workerRegistration .New (
233246 n .Consensus .Beacon (),
234247 n .Consensus .Registry (),
235248 n .Identity ,
249+ n .EntityID ,
236250 n .Consensus ,
237251 n .P2P ,
238- & workerCommonCfg ,
252+ sentryAddresses ,
239253 n .commonStore ,
240254 n , // the delegate to be called on registration shutdown
241255 n .RuntimeRegistry ,
@@ -255,7 +269,7 @@ func (n *Node) initRuntimeWorkers(genesisDoc *genesisAPI.Document) error {
255269 n .BeaconWorker , err = workerBeacon .New (
256270 n .Identity ,
257271 n .Consensus ,
258- n .RegistrationWorker ,
272+ n .EntityID != nil ,
259273 )
260274 if err != nil {
261275 return err
@@ -445,6 +459,22 @@ func NewNode() (node *Node, err error) { // nolint: gocyclo
445459 return nil , err
446460 }
447461
462+ // Load the owning node's entity ID.
463+ var entityID * signature.PublicKey
464+ if flags .DebugTestEntity () {
465+ testEntity , _ , _ := entity .TestEntity ()
466+ entityID = & testEntity .ID
467+ } else {
468+ entityID , err = config .GlobalConfig .Registration .ResolveEntityID ()
469+ if err != nil {
470+ return nil , fmt .Errorf ("failed to resolve entity ID: %w" , err )
471+ }
472+ }
473+ if entityID != nil && ! entityID .IsValid () {
474+ return nil , fmt .Errorf ("invalid entity ID" )
475+ }
476+ node .EntityID = entityID
477+
448478 // Load configured values for all registered crash points.
449479 crash .LoadViperArgValues ()
450480
0 commit comments