vegaprotocol / data-node

A rich API server for Vega Protocol
https://vega.xyz
Other
3 stars 1 forks source link

Querying nodes does not return all nodes #673

Closed MuthuVega closed 2 years ago

MuthuVega commented 2 years ago

Started a network with 5 validators - 3 tendermint, 1 ersatz and 1 pending validator

However querying the nodes doesn't return all the nodes

query {
  nodes {
    id
    pubkey
    name
    status
    stakedTotal
    stakedByOperator
    stakedByDelegates
    pendingStake
    rewardScore {
      rawValidatorScore
      performanceScore
      multisigScore
      validatorScore
      normalisedScore
      validatorStatus
    }
    rankingScore {
      status
      previousStatus
      rankingScore
      stakeScore
      performanceScore
      votingPower
    }
  }
}

Response

{
  "data": {
    "nodes": [
      {
        "id": "23d82d52edb142db7d6823a94d73ce2b81b5c0a6bc74e852a1fad72afaf0cf47",
        "pubkey": "dfe9ee4c6475c26563c158a78138243998ba892584e8624d138f8f9a59cef14e",
        "name": "",
        "status": "Validator",
        "stakedTotal": "0",
        "stakedByOperator": "0",
        "stakedByDelegates": "0",
        "pendingStake": "0",
        "rewardScore": null,
        "rankingScore": {
          "status": "tendermint",
          "previousStatus": "tendermint",
          "rankingScore": "0",
          "stakeScore": "0",
          "performanceScore": "1",
          "votingPower": "10"
        }
      },
      {
        "id": "320443db88ca54c89a7032d581028ced6f48170260aed84494c415553280ba06",
        "pubkey": "f2f1ce20de0d86de8cfa5f4da13f20461dd460783faf004b2ce1be0f3ac9a441",
        "name": "",
        "status": "Validator",
        "stakedTotal": "0",
        "stakedByOperator": "0",
        "stakedByDelegates": "0",
        "pendingStake": "0",
        "rewardScore": null,
        "rankingScore": {
          "status": "tendermint",
          "previousStatus": "tendermint",
          "rankingScore": "0",
          "stakeScore": "0",
          "performanceScore": "0.7500000000000001",
          "votingPower": "10"
        }
      },
      {
        "id": "39986828759c1abcc2a48b3aa282667a5720093568589c1d2de6fa9feee1345d",
        "pubkey": "a25a8ea234e050182b6bd922adc6bf9af319f8dcab5ae4e33df85b8f3947d4f9",
        "name": "",
        "status": "Validator",
        "stakedTotal": "0",
        "stakedByOperator": "0",
        "stakedByDelegates": "0",
        "pendingStake": "0",
        "rewardScore": null,
        "rankingScore": {
          "status": "tendermint",
          "previousStatus": "tendermint",
          "rankingScore": "0",
          "stakeScore": "0",
          "performanceScore": "0.7500000000000001",
          "votingPower": "10"
        }
      }
    ]
  }
}

Querying one of the earliest epochs , all the nodes are returned

query {
  epoch (id:"1") {
    id
    validators {
      id
      name
      status
      stakedTotal
      stakedByOperator
      stakedByDelegates
      pendingStake
      rankingScore {
      status
      previousStatus
      rankingScore
      stakeScore
      performanceScore
      votingPower
        }
    }
    delegations {
      node {
        id
      }
      amount
      party {
        id
      }
      epoch
    }
  }
}

Response

{
  "data": {
    "epoch": {
      "id": "1",
      "validators": [
        {
          "id": "23d82d52edb142db7d6823a94d73ce2b81b5c0a6bc74e852a1fad72afaf0cf47",
          "name": "",
          "status": "Validator",
          "stakedTotal": "0",
          "stakedByOperator": "0",
          "stakedByDelegates": "0",
          "pendingStake": "0",
          "rankingScore": {
            "status": "tendermint",
            "previousStatus": "tendermint",
            "rankingScore": "0",
            "stakeScore": "0",
            "performanceScore": "1",
            "votingPower": "10"
          }
        },
        {
          "id": "320443db88ca54c89a7032d581028ced6f48170260aed84494c415553280ba06",
          "name": "",
          "status": "Validator",
          "stakedTotal": "0",
          "stakedByOperator": "0",
          "stakedByDelegates": "0",
          "pendingStake": "0",
          "rankingScore": {
            "status": "tendermint",
            "previousStatus": "tendermint",
            "rankingScore": "0",
            "stakeScore": "0",
            "performanceScore": "0.05",
            "votingPower": "10"
          }
        },
        {
          "id": "39986828759c1abcc2a48b3aa282667a5720093568589c1d2de6fa9feee1345d",
          "name": "",
          "status": "Validator",
          "stakedTotal": "0",
          "stakedByOperator": "0",
          "stakedByDelegates": "0",
          "pendingStake": "0",
          "rankingScore": {
            "status": "tendermint",
            "previousStatus": "tendermint",
            "rankingScore": "0",
            "stakeScore": "0",
            "performanceScore": "0.05",
            "votingPower": "10"
          }
        },
        {
          "id": "f708e8713fc5e2a80371b4183f3f643e041372d41555762edba1757a36c57a06",
          "name": "",
          "status": "Validator",
          "stakedTotal": "0",
          "stakedByOperator": "0",
          "stakedByDelegates": "0",
          "pendingStake": "0",
          "rankingScore": {
            "status": "ersatz",
            "previousStatus": "tendermint",
            "rankingScore": "0",
            "stakeScore": "0",
            "performanceScore": "0.05",
            "votingPower": "0"
          }
        },
        {
          "id": "f8fc7f29c11e3b179f69bbfe4c524b0073fb76c9bc74f39148bdebc458654828",
          "name": "",
          "status": "Validator",
          "stakedTotal": "0",
          "stakedByOperator": "0",
          "stakedByDelegates": "0",
          "pendingStake": "0",
          "rankingScore": {
            "status": "pending",
            "previousStatus": "tendermint",
            "rankingScore": "0",
            "stakeScore": "0",
            "performanceScore": "0.05",
            "votingPower": "0"
          }
        }
      ],
      "delegations": []
    }
  }
}
pscott31 commented 2 years ago

I'm not sure this is a bug, but rather the nodes being removed - I've posted on slack asking for clarifiaction:

https://vegaprotocol.slack.com/archives/CD4AKTFQT/p1655998645192109

pscott31 commented 2 years ago

OK after some investigation I think this is NotABug(tm). When I ran a network with 5 nodes, but network.validators.tendermint.number set to 3 - I initially could see the 3 validator nodes, 1 pending, 1 ersatz.

However on epoch 10 they are removed. After discussing with Zohar, and looking at the logs, I believe this is intended behaviour because they have 0 stake. The core logs say:

removing validator with 0 positive ranking for too long {"node-id": "bc2ce8bf7366b5326a46afad43f292c690d8ffc0c7aaff9e2993f3e7d56e3ed5"}
removing validator with 0 positive ranking for too long {"node-id": "d7ddcf5384f3006016d8faf058eefe4c0897812b73ae31a08bbe2c0467a8ef89"}

And I can see in the database that the Datanode is picking up this event and recording these nodes as not being active; thus excluding them from the results of the node query.

It's possible that what I described isn't exactly the scenario you had @MuthuVega, if you disagree feel free to re-open the ticket but I'm going to close it now as I'm fairly sure it's doing what it was supposed to do.

That said it took me a while to figure out and is perhaps a bit confusing - it might be nice to see all the nodes in the query but with a status of 'Removed' or something, which would have gotten us to this answer a lot quicker. That wouldn't be too tricky to do, if it would be useful feel very free to make a ticket and we'll put it on the list.

MuthuVega commented 2 years ago

Happy with this explanation.