Skip to content

Add new HTTP endpoint to get supply for a given state root #7102

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

Open
wants to merge 15 commits into
base: unstable
Choose a base branch
from

Conversation

alecalve
Copy link

@alecalve alecalve commented Mar 10, 2025

Issue Addressed

Computing how much ETH is on the Consensus layer requires currently querying /eth/v1/beacon/states/{state_id}/validator_balances and summing up all balances of all validators.

That data is 68MB of JSON which has to be downloaded and processed.

Proposed Changes

This PR instead adds a simple enpoint where the computation is done at the node level, the returned data is therefore minimal.

@CLAassistant
Copy link

CLAassistant commented Mar 10, 2025

CLA assistant check
All committers have signed the CLA.

@alecalve alecalve changed the base branch from stable to unstable March 10, 2025 15:11
@chong-he chong-he added ready-for-review The code is ready for review HTTP-API labels Mar 11, 2025
@michaelsproul
Copy link
Member

Looks like this needs a sneaky cargo fmt --all

@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 Mar 27, 2025
Copy link
Member

@macladson macladson left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! This will be a neat endpoint to have. Just a couple of minor things

Copy link
Member

@macladson macladson left a comment

Choose a reason for hiding this comment

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

Looks like it needs a make mdlint to fix the Markdown formatting.

Also noticed a typo (we spellcheck the docs so this would've got picked up by CI as well)

@alecalve
Copy link
Author

For Markdown linting, I took the liberty of moving the check earlier in the test process as it's fast to run. In this MR, the suite failed nearly 15mins into testing when it could have failed much earlier.

@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 Mar 27, 2025
@macladson
Copy link
Member

For Markdown linting, I took the liberty of moving the check earlier in the test process as it's fast to run. In this MR, the suite failed nearly 15mins into testing when it could have failed much earlier.

Nice, that's a good change!
And thanks for being prompt in implementing the suggestions, I'll test this out more thoroughly soon

@alecalve
Copy link
Author

@macladson I have no idea why the windows release tests failed, are they known to be flaky or could my changes somehow be the cause?

@macladson
Copy link
Member

@macladson I have no idea why the windows release tests failed, are they known to be flaky or could my changes somehow be the cause?

Not sure what happened but I retriggered the tests and it has passed now, must've just been flaky

@eserilev
Copy link
Member

Hi @alecalve thanks for all your work so far! I was wondering if you'd be up for writing a test case for this endpoint? If not, I can go ahead and push up a test case myself. Thanks!

@alecalve
Copy link
Author

Hi @alecalve thanks for all your work so far! I was wondering if you'd be up for writing a test case for this endpoint? If not, I can go ahead and push up a test case myself. Thanks!

I'll give it a try!

@eserilev
Copy link
Member

@alecalve this looks great!

There are two small lint issues that are blocking CI. If you run make lint-full you should see them.

@alecalve
Copy link
Author

I wasn't aware of this final step of linting, I only ran cargo fmt. To make clippy happy, I split the HTTP test function into GET/POST methods to avoid triggering this:

error: this function may allocate 513901 bytes on the stack
    --> beacon_node/http_api/tests/tests.rs:7342:1
     |
7342 |   #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
     |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
7343 |   async fn lighthouse_endpoints() {
7344 | /     ApiTester::new()
7345 | |         .await
     | |______________- this is the largest part, at 37296 bytes for type `{async fn body of tests::ApiTester::new()}`

Copy link

mergify bot commented May 19, 2025

Some required checks have failed. Could you please take a look @alecalve? 🙏

@mergify mergify bot 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 May 19, 2025
Copy link

mergify bot commented May 19, 2025

Some required checks have failed. Could you please take a look @alecalve? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HTTP-API waiting-on-author The reviewer has suggested changes and awaits thier implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants