Skip to content

Conversation

macladson
Copy link
Member

@macladson macladson commented Dec 22, 2021

Issue Addressed

N/A

Proposed Changes

Add a HTTP API which can be used to compute the attestation performances of a validator (or all validators) over a discrete range of epochs.
Performances can be computed for a single validator, or for the global validator set.

Usage

Request

The API can be used as follows:

curl "http://localhost:5052/lighthouse/analysis/attestation_performance/{validator_index}?start_epoch=57730&end_epoch=57732"

Alternatively, to compute performances for the global validator set:

curl "http://localhost:5052/lighthouse/analysis/attestation_performance/global?start_epoch=57730&end_epoch=57732"

Response

The response is JSON formatted as follows:

[
  {
    "index": 72,
    "epochs": {
      "57730": {
        "active": true,
        "head": false,
        "target": false,
        "source": false
      },
      "57731": {
        "active": true,
        "head": true,
        "target": true,
        "source": true,
        "delay": 1
      },
      "57732": {
        "active": true,
        "head": true,
        "target": true,
        "source": true,
        "delay": 1
      },
    }
  }
]

Note that the "epochs" are not guaranteed to be in ascending order.

Additional Info

  • This API is intended to be used in our upcoming validator analysis tooling (Add initial version of beacon watch #2873) and will likely not be very useful for regular users. Some advanced users or block explorers may find this API useful however.
  • The request range is limited to 100 epochs (since the range is inclusive and it also computes the end_epoch it's actually 101 epochs) to prevent Lighthouse using exceptionally large amounts of memory.

@macladson macladson added the ready-for-review The code is ready for review label Dec 22, 2021
Copy link
Member

@michaelsproul michaelsproul left a comment

Choose a reason for hiding this comment

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

Looks good on a first pass. Just a few perf improvements suggested 👌

@michaelsproul michaelsproul added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review labels Jan 17, 2022
@macladson macladson added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Jan 17, 2022
Copy link
Member

@michaelsproul michaelsproul left a comment

Choose a reason for hiding this comment

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

Happy to merge modulo one smol optimisation

@michaelsproul michaelsproul added waiting-on-author The reviewer has suggested changes and awaits thier implementation. ready-for-merge This PR is ready to merge. blocked and removed ready-for-review The code is ready for review waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Jan 18, 2022
@michaelsproul
Copy link
Member

Will merge once v2.1.0 is released.

@michaelsproul michaelsproul added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed blocked ready-for-merge This PR is ready to merge. labels Jan 18, 2022
@macladson macladson added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Jan 19, 2022
Copy link
Member

@michaelsproul michaelsproul left a comment

Choose a reason for hiding this comment

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

Let's do it!

bors r+

@bors
Copy link

bors bot commented Jan 27, 2022

Merge conflict.

@michaelsproul michaelsproul added ready-for-merge This PR is ready to merge. waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed ready-for-review The code is ready for review ready-for-merge This PR is ready to merge. labels Jan 27, 2022
@macladson macladson force-pushed the attestation-performance-api branch from 054536d to 8fc449b Compare January 27, 2022 07:18
@macladson macladson added ready-for-review The code is ready for review and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels Jan 27, 2022
@michaelsproul michaelsproul added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Jan 27, 2022
@michaelsproul
Copy link
Member

I think we're blocked on CLA assistant working again (or getting disabled)

@michaelsproul
Copy link
Member

Re-check CLA

@michaelsproul
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Jan 27, 2022
## Issue Addressed

N/A

## Proposed Changes

Add a HTTP API which can be used to compute the attestation performances of a validator (or all validators) over a discrete range of epochs.
Performances can be computed for a single validator, or for the global validator set. 

## Usage
### Request
The API can be used as follows:
```
curl "http://localhost:5052/lighthouse/analysis/attestation_performance/{validator_index}?start_epoch=57730&end_epoch=57732"
```
Alternatively, to compute performances for the global validator set:
```
curl "http://localhost:5052/lighthouse/analysis/attestation_performance/global?start_epoch=57730&end_epoch=57732"
```

### Response
The response is JSON formatted as follows:
```
[
  {
    "index": 72,
    "epochs": {
      "57730": {
        "active": true,
        "head": false,
        "target": false,
        "source": false
      },
      "57731": {
        "active": true,
        "head": true,
        "target": true,
        "source": true,
        "delay": 1
      },
      "57732": {
        "active": true,
        "head": true,
        "target": true,
        "source": true,
        "delay": 1
      },
    }
  }
]
```
> Note that the `"epochs"` are not guaranteed to be in ascending order. 

## Additional Info

- This API is intended to be used in our upcoming validator analysis tooling (#2873) and will likely not be very useful for regular users. Some advanced users or block explorers may find this API useful however.
- The request range is limited to 100 epochs (since the range is inclusive and it also computes the `end_epoch` it's actually 101 epochs) to prevent Lighthouse using exceptionally large amounts of memory.
@bors
Copy link

bors bot commented Jan 28, 2022

@bors bors bot changed the title Add API to compute discrete validator attestation performance [Merged by Bors] - Add API to compute discrete validator attestation performance Jan 28, 2022
@bors bors bot closed this Jan 28, 2022
@macladson macladson deleted the attestation-performance-api branch January 28, 2022 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge This PR is ready to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants