lighthouse icon indicating copy to clipboard operation
lighthouse copied to clipboard

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

Open alecalve opened this issue 8 months ago • 12 comments

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.

alecalve avatar Mar 10 '25 15:03 alecalve

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Mar 10 '25 15:03 CLAassistant

Looks like this needs a sneaky cargo fmt --all

michaelsproul avatar Mar 27 '25 01:03 michaelsproul

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.

alecalve avatar Mar 27 '25 14:03 alecalve

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

macladson avatar Mar 27 '25 14:03 macladson

@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?

alecalve avatar Mar 31 '25 11:03 alecalve

@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

macladson avatar Mar 31 '25 12:03 macladson

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!

eserilev avatar Apr 25 '25 01:04 eserilev

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!

alecalve avatar Apr 25 '25 08:04 alecalve

@alecalve this looks great!

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

eserilev avatar Apr 25 '25 16:04 eserilev

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()}`

alecalve avatar Apr 25 '25 19:04 alecalve

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

mergify[bot] avatar May 19 '25 05:05 mergify[bot]

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

mergify[bot] avatar May 19 '25 07:05 mergify[bot]

Hi @alecalve, this pull request has been closed automatically due to 30 days of inactivity. If you’d like to continue working on it, feel free to reopen at any time.

mergify[bot] avatar Jun 19 '25 15:06 mergify[bot]