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

Localnet validator testing #541

Merged
merged 10 commits into from
Mar 22, 2021
Merged

Conversation

BeroBurny
Copy link
Collaborator

Short description of work done

  • implement validator tester on beacon node

PR Checklist

  • I have run type check locally
  • I have run linter locally
  • I have run unit and integration tests locally
  • Rebased to master branch / merged master

Changes

  • implement validator tester on beacon node
  • update lighthouse files
  • implement event source polyfill (needed for test)

Issues

Closes #528

@BeroBurny BeroBurny added the enhancement New feature or request label Mar 18, 2021
@BeroBurny BeroBurny self-assigned this Mar 18, 2021
@BeroBurny BeroBurny requested a review from a team as a code owner March 18, 2021 14:28
@codecov
Copy link

codecov bot commented Mar 18, 2021

Codecov Report

Merging #541 (342ceee) into develop (5f7e2d2) will decrease coverage by 0.09%.
The diff coverage is 16.66%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #541      +/-   ##
===========================================
- Coverage    58.65%   58.56%   -0.10%     
===========================================
  Files           75       75              
  Lines         1253     1255       +2     
  Branches       148      150       +2     
===========================================
  Hits           735      735              
- Misses         491      493       +2     
  Partials        27       27              
Flag Coverage Δ
unit 58.56% <16.66%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/renderer/services/api/http/httpClient.ts 11.76% <0.00%> (-0.74%) ⬇️
src/renderer/services/eth2/networks/local.ts 100.00% <100.00%> (ø)

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 5f7e2d2...342ceee. Read the comment docs.

integration/lighthouse.ts Outdated Show resolved Hide resolved
integration/restValidation.ts Outdated Show resolved Hide resolved
blockSlot: number,
ignoreBefore?: number,
): Promise<Committees[]> => {
const url = new URL(`/eth/v1/beacon/states/${blockSlot}/committees`, baseUrl);
Copy link
Member

Choose a reason for hiding this comment

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

can we use beacon api client rather than re-implementing everywhere?

API will receive changes over time and it will be nightmare to update on bunch of places.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

what if the validator beacon API master class has something wrongly implemented?

Copy link
Member

Choose a reason for hiding this comment

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

we override if there is non compliant api: #541 (comment)

integration/restValidation.ts Outdated Show resolved Hide resolved
const validatorIndex = Number(validator.data.data.index);

const url = new URL(`/eth/v1/events?topics=attestation,head`, baseUrl);
const eventSource = new EventSource(url.href);
Copy link
Member

Choose a reason for hiding this comment

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

you already have eth2API instance why not use that to listen on events?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

probably is this problem? ChainSafe/ssz#23
I tried validator on Teku Beacon node and got some error while szz deserializing

Copy link
Member

Choose a reason for hiding this comment

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

I think we should extend CgEth2Api with specific implementation for different clients until they all converge to be fully compliant with spec.

Like CgTekuEth2Api extends CgEth2Api and CgLighthouseEth2Api extends CgEth2Api where CgEth2Api is spec compliant implementation

Copy link
Member

Choose a reason for hiding this comment

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

probably is this problem? ChainSafe/ssz#23
I tried validator on Teku Beacon node and got some error while szz deserializing

Nope, you shouldn't get empty beacon blocks over API. Send me json you get from Teku, there is probably some discrepancies with data we get.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we should extend CgEth2Api with specific implementation for different clients until they all converge to be fully compliant with spec.

Like CgTekuEth2Api extends CgEth2Api and CgLighthouseEth2Api extends CgEth2Api where CgEth2Api is spec compliant implementation

and this will cause the problem mentioned above #541 (comment)
then will be better to provide client and version to the client and if there is some non-compliant we can override for specific (or range) client/version

Copy link
Member

Choose a reason for hiding this comment

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

But you know what client you will use for each testnet so you can provide that info in this PR and instantiate appropriate beacon api client instance. As for chainguardian, ideas was (and should still be) to query https://ethereum.github.io/eth2.0-APIs/#/Node/getNodeVersion and depending on that initialize either LighthouseBeaconApi instance or TekuBeaconApi instance or throw error if not supported.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it is out of scope for this task
for Teku there is #529 where we will proceed by this #541 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

It makes no sense to merge this PR with all those new beacon api implementation. If this Pr is only for Lighthouse testing, than just use CgEth2BeaconApi everywhere and we can have separate PR with teku specific implementation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

then what we gonna do with #529 ?

Copy link
Member

Choose a reason for hiding this comment

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

Ok then, just use CgEth2BeaconApi here (in this PR) and add other api client implementations as part of #529

Log spec discrepancies so we can report it upstream.

@BeroBurny BeroBurny mentioned this pull request Mar 19, 2021
Copy link
Member

@mpetrunic mpetrunic left a comment

Choose a reason for hiding this comment

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

LGTM, few more details

integration/lighthouse.ts Outdated Show resolved Hide resolved
CGBeaconEventType.ATTESTATION,
] as unknown) as BeaconEventType[]);
for await (const {type, message} of stream) {
if (((type as unknown) as CGBeaconEventType.ATTESTATION) === CGBeaconEventType.ATTESTATION) {
Copy link
Member

Choose a reason for hiding this comment

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

to make it more readable, could you move each case implementation to separate function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it's hard to do that, as this cases depends on the upper scope

Copy link
Member

Choose a reason for hiding this comment

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

Can't you pass required params as method args?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

CGBeaconEventType.ATTESTATION just use Map attestations
but CGBeaconEventType.HEAD uses from uper scope

  • slot
  • proposers
  • firstSlot
  • startEpoch
  • lastEpoch
  • committees
  • proposers
  • attestations

pretty needy case 🙈

Copy link
Member

Choose a reason for hiding this comment

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

pass everything as huge object. It's really hard to follow that huge piece of code 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

and then return as the very huge object to assign all variables to upper scope variables?

src/renderer/services/api/http/httpClient.ts Outdated Show resolved Hide resolved
@mpetrunic mpetrunic merged commit ea7aa4b into develop Mar 22, 2021
@mpetrunic mpetrunic deleted the beroburny/localnet-validator-testing branch March 22, 2021 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants