Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validator:status command to check if a validator signer is online and producing blocks #1906

Merged
merged 45 commits into from
Dec 5, 2019

Conversation

nategraf
Copy link
Contributor

@nategraf nategraf commented Nov 26, 2019

Description

Create a validator:status command to check the registration, election, and signing status of a validator.

Tested

Manually tested against local testnet

Backwards compatibility

Will not break anything. New command will work with networks that have parent seals in the block header.

Related Issues

Fixes: #1782

@codecov
Copy link

codecov bot commented Nov 26, 2019

Codecov Report

Merging #1906 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           master    #1906    +/-   ##
========================================
  Coverage   74.42%   74.42%            
========================================
  Files         281      281            
  Lines        7824     7824            
  Branches      687      975   +288     
========================================
  Hits         5823     5823            
  Misses       1884     1884            
  Partials      117      117
Flag Coverage Δ
#mobile 74.42% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fdc4839...1f0c5c5. Read the comment docs.

@nategraf
Copy link
Contributor Author

I've added a note to the running-a-validator doc to suggest using this command.

Copy link
Contributor

@mcortesi mcortesi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check lodash, i don't think it's included in package.json...

The rest are minor details!

@mcortesi mcortesi assigned nategraf and unassigned mcortesi Nov 27, 2019
packages/cli/src/commands/validator/status.ts Show resolved Hide resolved
packages/cli/src/commands/validator/status.ts Show resolved Hide resolved
// Use redundant checks to help the user diagnose issues.
await newCheckBuilder(this, signer)
.canSignValidatorTxs()
.signerMeetsValidatorBalanceRequirements()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect us to fail this check whenever the validator has an authorized validator signer...

Where else is this used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used here. https://github.com/celo-org/celo-monorepo/blob/master/packages/cli/src/commands/validator/register.ts#L32
I believe it should work. It calls signerToAccount on the provided signer then checks the balance requirement on the account that was retrieved. It's not strictly necessary though.

const signers = await election.getCurrentValidatorSigners()
const signerIndex = signers.map((a) => a.toLowerCase()).indexOf(signer.toLowerCase())
if (signerIndex < 0) {
// Determine whether the signer will be elected at the next epoch to provide a helpful error.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Can we put this functionality in the election module instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a command like election:validator-is-elected, but I personally don't see a ton of value in that because election:current and election:run exist and combined with grep you can tell whether a specific validator is in the set.

packages/cli/src/commands/validator/status.ts Show resolved Hide resolved
packages/cli/src/commands/validator/status.ts Outdated Show resolved Hide resolved
@asaj asaj removed their assignment Nov 27, 2019
static flags = {
...BaseCommand.flags,
signer: Flags.address({
description: 'address of the validator to check if elected and validating',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these descriptions swapped?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Fixed.


static flags = {
...BaseCommand.flags,
signer: Flags.address({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make these flags exclusive? Example in validatorgroup:member

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

const account = res.flags.validator
checker.isValidator(account).meetsValidatorBalanceRequirements(account)
} else if (res.flags.signer) {
checker.signerMeetsValidatorBalanceRequirements().signerAccountIsValidator()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than add additional checks, why don't we just pull the account from the signer and run the same checks on the account?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point in the code it is unclear whether the accounts given are valid and I wanted to avoid an opaque call reversion. I realized that as coded it still has that issue, so I've added an isAccount check.

const frontrunners = await election.electValidatorSigners()
if (frontrunners.some((a) => eqAddress(a, signer))) {
this.error(
`Signer ${signer} is not elected for this epoch, but is currently winning in the upcoming election. Wait for the next epoch.`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but would be elected to the validator set for the next epoch if an election were to be held now. Please wait until the next epoch.

)
} else {
this.error(
`Signer ${signer} is not elected for this epoch, and is not currently winning the upcoming election.`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and would not be elected to the validator set for the next epoch if an election were to be held now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@asaj asaj assigned nategraf and unassigned asaj Dec 5, 2019
@nategraf nategraf merged commit 0ad5e9a into master Dec 5, 2019
aaronmgdr added a commit that referenced this pull request Dec 5, 2019
…g/celo-monorepo into aaronmgdr/protect-proxied-routes

* 'aaronmgdr/protect-proxied-routes' of github.com:celo-org/celo-monorepo:
  Add validator:status command to check if a validator signer is online and producing blocks (#1906)
aaronmgdr added a commit that referenced this pull request Dec 5, 2019
* master: (208 commits)
  Fix potential hard timeouts (#2072)
  Add checkzero,blockscout,mulit-address support to faucet. Fix broken envType checks (#2068)
  README added mission (#1972)
  Add dev-utils README (#2081)
  Add validator:status command to check if a validator signer is online and producing blocks (#1906)
  Experience Brand Kit 1.0 (#1948)
  Adjust reference to the rewards app (#2065)
  [Wallet] Compatibility with exchange rate in string format (#2060)
  Fix Typo in CI config (#2056)
  Fix additional attestations instructions (#2057)
  Allow a specified address to disable/enable rewards distribution (#1828)
  Aaronmgdr/leaderboard patch (#2055)
  Move attestation service instructions to main page (#2051)
  Point To Updated Join Celo Video (#2052)
  Fix minor issue withe the ordering of instructions
  changes to docs related to discovery (#2025)
  [Docs] Fix typos in Running a Validator docs (#2045)
  Add node flag to celocli to set the target node for a single command (#2020)
  Fix broken links and spruce up CLI docs for accounts command (#2027)
  Prevent clipping of arrow component (#2036)
  ...

# Conflicts:
#	packages/web/src/layout/BookLayout.tsx
#	packages/web/src/lib.dom.d.ts
@cmcewen cmcewen deleted the victor/vx-online branch December 30, 2019 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validators SBAT reference getting started documentation on how to see if they're validating
4 participants