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

ssv-scanner miscounting validator_count in case of multiple events in the same block #8

Open
RaekwonIII opened this issue Sep 22, 2023 · 0 comments

Comments

@RaekwonIII
Copy link
Collaborator

Hello team, a query from a user triggered an investigation this morning, resulted in finding a. possible but in ssv-scanner.

the problem

The user lamented ssv-scanner reporting a validator count of 2, while his expectation was to have 4 validators assigned to his cluster:

massi@MacBook-Pro:~/dev/ssv-scanner|main ⇒  yarn cli cluster \
-n https://goerli.infura.io/v3/2a1be98f319e4b059b85f853a140b315 \
-ca 0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D \
-oa 0xc97A3092dd785e1b65155Dd56664dD358B981e2d \
-oids 181,184,185,186
yarn run v1.22.19
$ node ./dist/tsc/src/cli.js cluster -n https://goerli.infura.io/v3/2a1be98f319e4b059b85f853a140b315 -ca 0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D -oa 0xc97A3092dd785e1b65155Dd56664dD358B981e2d -oids 181,184,185,186

Scanning blockchain...
 ████████████████████████████████████████ 100% | ETA: 0s | 9738699/9738699
┌───────────┬──────────────────────────────────────────────┐
│  (index)  │                    Values                    │
├───────────┼──────────────────────────────────────────────┤
│   Owner   │ '0xc97A3092dd785e1b65155Dd56664dD358B981e2d' │
│ Operators │              '181,184,185,186'               │
│   Block   │                   9727805                    │
│   Data    │      '2,0,0,true,20000000000000000000'       │
└───────────┴──────────────────────────────────────────────┘
Cluster snapshot:
┌─────────────────┬────────────────────────┐
│     (index)     │         Values         │
├─────────────────┼────────────────────────┤
│ validatorCount  │          '2'           │
│ networkFeeIndex │          '0'           │
│      index      │          '0'           │
│     active      │          true          │
│     balance     │ '20000000000000000000' │
└─────────────────┴────────────────────────┘
{
  "block": 9727805,
  "cluster snapshot": {
    "validatorCount": "2",
    "networkFeeIndex": "0",
    "index": "0",
    "active": true,
    "balance": "20000000000000000000"
  },
  "cluster": [
    "2",
    "0",
    "0",
    true,
    "20000000000000000000"
  ]
}

For comparison, the SSV API "correctly" says there are 4 validators assigned to this cluster:

massi@MacBook-Pro:~/dev/ssv-scanner|main ⇒  curl -X 'GET' \
  'https://api.ssv.network/api/v4/prater/clusters/owner/0xc97A3092dd785e1b65155Dd56664dD358B981e2d?page=1&perPage=10' \
  -H 'accept: */*'

{
  "pagination": {
    "total": 1,
    "page": 1,
    "pages": 1,
    "per_page": 10
  },
  "clusters": [
    {
      "id": 14165,
      "id_str": "14165",
      "owner_address": "0xc97A3092dd785e1b65155Dd56664dD358B981e2d",
      "validator_count": 4,
      "network_fee_index": 0,
      "index": 0,
      "balance": "40000000000000000000",
      "active": true,
      "operators": [
        181,
        184,
        185,
        186
      ]
    }
  ]
}

A quick look at etherscan made us realize that he's not interacting directly with our contract, but with a contract of his own making:

https://goerli.etherscan.io/txs?a=0xc97A3092dd785e1b65155Dd56664dD358B981e2d

Thanks to the help of ssv-scan tool built by the community we found out that the user is experimenting with bulk calls to the contract:

https://testnet.ssvscan.io/account/0xc97a3092dd785e1b65155dd56664dd358b981e2d

And as you can see, 3 ValidatorAdded Events were triggered on the same block.

I took a look at the code responsible for cluster snapshot and it appears to me that it is overwriting the cluster snapshot based on the event's block number. But because the last 3 events have the same block number, it is not picking up the latest, so it's only counting up until 2 validators.

https://github.com/bloxapp/ssv-scanner/blob/main/src/lib/ClusterScanner/ClusterScanner.ts#L72

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

No branches or pull requests

1 participant