Skip to content

Commit

Permalink
go/worker/beacon: Don't submit VRF proofs if registration disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Yawning committed Mar 3, 2022
1 parent 1dcd53f commit fca1ac9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions .changelog/4536.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/worker/beacon: Don't submit VRF proofs if registration disabled
1 change: 1 addition & 0 deletions go/oasis-node/cmd/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ func (n *Node) initRuntimeWorkers() error {
n.Identity,
n.Consensus,
n.commonStore,
n.RegistrationWorker,
)
if err != nil {
return err
Expand Down
8 changes: 8 additions & 0 deletions go/worker/beacon/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/oasisprotocol/oasis-core/go/common/logging"
"github.com/oasisprotocol/oasis-core/go/common/persistent"
consensus "github.com/oasisprotocol/oasis-core/go/consensus/api"
"github.com/oasisprotocol/oasis-core/go/worker/registration"
)

const workerName = "worker/beacon"
Expand Down Expand Up @@ -61,6 +62,7 @@ func New(
identity *identity.Identity,
consensus consensus.Backend,
store *persistent.CommonStore,
registrationWorker *registration.Worker,
) (*Worker, error) {
var (
err error
Expand All @@ -74,6 +76,12 @@ func New(
}

initLogger := logging.GetLogger(workerName)
if registrationWorker.WillNeverRegister() {
// Some node configurations never register, and that's ok.
initLogger.Info("registration worker disabled, also disabling beacon worker")
close(w.allQuitCh)
return nil, nil
}

if w.vrf, err = newVRF(w); err == nil {
w.allQuitWg.Add(1)
Expand Down
7 changes: 6 additions & 1 deletion go/worker/registration/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,11 @@ func (w *Worker) RequestDeregistration() error {
return nil
}

// WillNeverRegister returns true iff the worker will never register.
func (w *Worker) WillNeverRegister() bool {
return !w.entityID.IsValid() || w.registrationSigner == nil
}

// GetRegistrationSigner loads the signing credentials as configured by this package's flags.
func GetRegistrationSigner(logger *logging.Logger, dataDir string, identity *identity.Identity) (signature.PublicKey, signature.Signer, error) {
var defaultPk signature.PublicKey
Expand Down Expand Up @@ -1041,7 +1046,7 @@ func (w *Worker) Start() error {
w.logger.Info("starting node registration service")

// HACK: This can be ok in certain configurations.
if !w.entityID.IsValid() || w.registrationSigner == nil {
if w.WillNeverRegister() {
w.logger.Warn("no entity/signer for this node, registration will NEVER succeed")
// Make sure the node is stopped on quit and that it can still respond to
// shutdown requests from the control api.
Expand Down

0 comments on commit fca1ac9

Please sign in to comment.