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

fix: Save genesis bootstrap congestion info into DB and reuse it at node restarts #11724

Merged
merged 34 commits into from
Jul 5, 2024

Conversation

tayfunelmas
Copy link
Contributor

This addresses #11702.

The issue happens for forknet and local testing where the network starts from the genesis block and the genesis protocol version supports congestion control. In this case, every time the node restarts, it attempts to re-generate the genesis congestion info. However, this is done using the state roots at genesis; these state roots are garbage collected and causes the bootstrapping to fail.

We fix this by storing the genesis congestion info (CongestionInfo for each shard) in DB. If it exists, the node directly uses it instead of attempting to re-compute it from state roots.

We store the congestion info in BlockMisc column with key GENESIS_CONGESTION_INFO.

This PR also adds a testloop test to check if the congestion info is saved (and not cleaned up by GC) and re-enables the previously disabled nayducks tests due to this problem.

@tayfunelmas tayfunelmas marked this pull request as ready for review July 4, 2024 15:55
@tayfunelmas tayfunelmas requested a review from a team as a code owner July 4, 2024 15:55
@tayfunelmas tayfunelmas requested review from saketh-are and wacban July 4, 2024 15:55
Copy link

codecov bot commented Jul 4, 2024

Codecov Report

Attention: Patch coverage is 82.05128% with 7 lines in your changes missing coverage. Please review.

Project coverage is 71.80%. Comparing base (dfd2ca0) to head (fff0f32).

Files Patch % Lines
chain/chain/src/chain.rs 75.00% 1 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11724      +/-   ##
==========================================
- Coverage   71.80%   71.80%   -0.01%     
==========================================
  Files         792      792              
  Lines      162526   162544      +18     
  Branches   162526   162544      +18     
==========================================
+ Hits       116698   116707       +9     
- Misses      40787    40793       +6     
- Partials     5041     5044       +3     
Flag Coverage Δ
backward-compatibility 0.23% <0.00%> (-0.01%) ⬇️
db-migration 0.23% <0.00%> (-0.01%) ⬇️
genesis-check 1.35% <0.00%> (-0.01%) ⬇️
integration-tests 37.89% <82.05%> (+<0.01%) ⬆️
linux 71.29% <82.05%> (+<0.01%) ⬆️
linux-nightly 71.38% <82.05%> (+<0.01%) ⬆️
macos 54.54% <82.05%> (-0.01%) ⬇️
pytests 1.58% <0.00%> (-0.01%) ⬇️
sanity-checks 1.38% <0.00%> (-0.01%) ⬇️
unittests 66.21% <82.05%> (-0.01%) ⬇️
upgradability 0.27% <0.00%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@wacban wacban left a comment

Choose a reason for hiding this comment

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

LGTM
Can you add some debug logs when reading and storing the infos in the db? The bootstrapping already has a comment so no need to add another one there.

chain/chain/src/chain.rs Outdated Show resolved Hide resolved
@tayfunelmas tayfunelmas enabled auto-merge July 5, 2024 13:18
@tayfunelmas tayfunelmas added this pull request to the merge queue Jul 5, 2024
Merged via the queue into near:master with commit 20af8fe Jul 5, 2024
30 checks passed
@tayfunelmas tayfunelmas deleted the congestion-control-bootstrap branch July 5, 2024 13:54
github-merge-queue bot pushed a commit that referenced this pull request Aug 7, 2024
I thought the test failed because of 1.4 -> 2.0 migration, but it was
due to the [actual fix](#11724)
missing in both of the binaries. See
https://near.zulipchat.com/#narrow/stream/295302-general/topic/Database.20migration.20CI.20check.20is.20consistently.20failing/near/457086995
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.

2 participants