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

Adjust pruning proof root per level #627

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

coderofstuff
Copy link
Collaborator

Problem: When trying to find the estimated root per block level, find_sufficient_root will adjust the required level 0 depth in powers of 2 based on how much higher the current level being processed is against the current level of the DAG. This can lead to cases where a higher level can have too many headers on it if the network gets an influx of significantly high hashrate and then that hashrate leaves.

It testnet-11 where someone put an ASIC on the network and left, the results are as follows:

2025-01-29 23:58:57.067-07:00 [INFO ] Validating level 39 from the pruning point proof (6356 headers)
2025-01-29 23:58:58.619-07:00 [INFO ] Validating level 38 from the pruning point proof (9379 headers)
2025-01-29 23:59:00.958-07:00 [INFO ] Validating level 37 from the pruning point proof (11752 headers)
2025-01-29 23:59:03.868-07:00 [INFO ] Validating level 36 from the pruning point proof (15126 headers)
2025-01-29 23:59:07.693-07:00 [INFO ] Validating level 35 from the pruning point proof (18387 headers)
2025-01-29 23:59:13.436-07:00 [INFO ] Validating level 34 from the pruning point proof (23226 headers)
2025-01-29 23:59:20.770-07:00 [INFO ] Validating level 33 from the pruning point proof (34809 headers)
2025-01-29 23:59:31.882-07:00 [INFO ] Validating level 32 from the pruning point proof (35901 headers)
2025-01-29 23:59:41.655-07:00 [INFO ] Validating level 31 from the pruning point proof (33095 headers)
2025-01-29 23:59:51.857-07:00 [INFO ] Validating level 30 from the pruning point proof (4620 headers)
2025-01-29 23:59:53.192-07:00 [INFO ] Validating level 29 from the pruning point proof (6272 headers)
2025-01-29 23:59:54.921-07:00 [INFO ] Validating level 28 from the pruning point proof (6053 headers)
2025-01-29 23:59:56.468-07:00 [INFO ] Validating level 27 from the pruning point proof (2294 headers)
2025-01-29 23:59:57.044-07:00 [INFO ] Validating level 26 from the pruning point proof (2211 headers)
2025-01-29 23:59:57.606-07:00 [INFO ] Validating level 25 from the pruning point proof (2282 headers)
2025-01-29 23:59:58.196-07:00 [INFO ] Validating level 24 from the pruning point proof (2179 headers)

Note that this is really only occurs in testnets since it requires hashrate to abruptly increase (x8 or x16 kind of increase) which is unexpected to occur in mainnet.

Solution: After calculating the GD store for a level and assuming we satisfy all requirements for a pruning proof of a level, we can now call block_at_depth on it. Use that and the old root finding logic (from before #494) to determine the true sufficient root we need. This solution results in:

2025-01-30 00:00:49.519-07:00 [INFO ] Validating level 39 from the pruning point proof (6356 headers)
2025-01-30 00:00:51.126-07:00 [INFO ] Validating level 38 from the pruning point proof (9379 headers)
2025-01-30 00:00:53.498-07:00 [INFO ] Validating level 37 from the pruning point proof (11752 headers)
2025-01-30 00:00:56.398-07:00 [INFO ] Validating level 36 from the pruning point proof (2102 headers)
2025-01-30 00:00:56.940-07:00 [INFO ] Validating level 35 from the pruning point proof (2102 headers)
2025-01-30 00:00:57.496-07:00 [INFO ] Validating level 34 from the pruning point proof (2102 headers)
2025-01-30 00:00:58.055-07:00 [INFO ] Validating level 33 from the pruning point proof (2102 headers)
2025-01-30 00:00:58.615-07:00 [INFO ] Validating level 32 from the pruning point proof (2100 headers)
2025-01-30 00:00:59.110-07:00 [INFO ] Validating level 31 from the pruning point proof (2101 headers)
2025-01-30 00:00:59.612-07:00 [INFO ] Validating level 30 from the pruning point proof (2101 headers)
2025-01-30 00:01:00.129-07:00 [INFO ] Validating level 29 from the pruning point proof (2101 headers)
2025-01-30 00:01:00.650-07:00 [INFO ] Validating level 28 from the pruning point proof (2100 headers)
2025-01-30 00:01:01.247-07:00 [INFO ] Validating level 27 from the pruning point proof (2102 headers)
2025-01-30 00:01:01.857-07:00 [INFO ] Validating level 26 from the pruning point proof (2102 headers)
2025-01-30 00:01:02.477-07:00 [INFO ] Validating level 25 from the pruning point proof (2102 headers)
2025-01-30 00:01:03.087-07:00 [INFO ] Validating level 24 from the pruning point proof (2102 headers)

@coderofstuff coderofstuff force-pushed the gd-buffered-root branch 2 times, most recently from 47bb54c to 8d8f29f Compare January 30, 2025 07:23
@coderofstuff coderofstuff marked this pull request as ready for review January 30, 2025 07:25
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

Successfully merging this pull request may close these issues.

1 participant