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

[Config] Change default barriers of mainnet to 0 #6225

Merged

Conversation

smartprogrammer93
Copy link
Contributor

@smartprogrammer93 smartprogrammer93 commented Oct 25, 2023

Changes

  • change default of barriers to 0 for mainnet without affecting previously synced nodes

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Notes on testing

  • @shashankshampi we need to run a test for this one where we sync a node with default configurations from master then update the node to this branch and check if it syncs the old data or not. if not, then all is good.

Documentation

Requires documentation update

  • Yes
  • No

Requires explanation in Release Notes

  • Yes
  • No

default to barriers on mainnet configuration changed to 0 to support the network. If you wish to use the old default barrier you need to set it manually.

|| WithinOldBarrierDefault;

// This property was introduced when we switched defaults of barriers from 11052984 to 0 to not disturb existing node operators
private bool WithinOldBarrierDefault => _blockTree.LowestInsertedBodyNumber <= DepositContractBarrier
Copy link
Contributor

Choose a reason for hiding this comment

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

are you sure it will work correctly in every case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We are covering 99 percent of cases. the only case that is not covered is if someone is syncing, and suddenly stopped the client at exactly around the old default, then unfortunately the sync will stop.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do other network have barrier too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, they do. The assumption is we only want to do that for mainnet

Copy link
Member

Choose a reason for hiding this comment

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

By default we only had barriers on mainnet

@@ -231,6 +231,20 @@ public async Task When_configured_to_skip_receipts_then_finishes_immediately()
_measuredProgressQueue.HasEnded.Should().BeTrue();
}

[Test]
public async Task When_finished_sync_with_old_default_barrier_then_finishes_imedietely()
Copy link
Contributor

Choose a reason for hiding this comment

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

tests for ReceiptsSyncFeed, but no tests for bodies
no tests for every possible case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are no tests for bodies in the first place. which was surprising tbh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added more cases for receipts

@@ -16,8 +16,6 @@
"PivotHash": "0x24290b7c113efe59095ff1d3afc15efec735655e6d4065d24704759fa5c9a308",
"PivotTotalDifficulty": "58750003716598352816469",
"FastBlocks": true,
"AncientBodiesBarrier": 11052984,
"AncientReceiptsBarrier": 11052984,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to remove these values completely? If user decide to enable them he can set value close to the head and CL will not be able to sync deposit contract. Maybe we can introduce something like Sync.EnableBarrier?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dont think the user will set the value from his mind. If the user wants to enable them, we can have something in the docs to guide?

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair, but I think it's better option to have default value for this. User may decide to set it to current head

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If that is desired, we can just make another config file, like mainet-barriers, for example

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd better go with mainnet-light or something but not sure.

@asdacap
Copy link
Contributor

asdacap commented Oct 25, 2023

You'll need to change SyncProgressResolver also, there is a duplicated logic there. See #6184 for an attempt to consolidate the logic.

@smartprogrammer93 smartprogrammer93 marked this pull request as draft October 27, 2023 11:47
@smartprogrammer93 smartprogrammer93 force-pushed the feature/change-mainnet-default-barriers-to-0 branch from 455cbd1 to a86d436 Compare November 3, 2023 13:10
@smartprogrammer93 smartprogrammer93 changed the base branch from master to refactor/encapsulate-sync-state November 3, 2023 13:11
@smartprogrammer93 smartprogrammer93 marked this pull request as ready for review November 3, 2023 17:04
@smartprogrammer93
Copy link
Contributor Author

Following tests were perfomed

  • Sync this branch fully on mainnet (all bodies and receipts synced)
  • Sync Master with barriers and then switch to this branch
    Dont see any issues.

The current implementation covers the following case:

  • Node syncing from scretch = syncing all bodies and receipts
  • Node already synced with barriers = no change. It will not sync the rest even with the config change.
  • Node syncing from scratch restarted at any point, including at the previous barrier default = will continue sync no problem.
  • Node syncing from scratch with barriers configured = will stop at the barrier no problem
    I believe this covers all cases.

@asdacap asdacap force-pushed the refactor/encapsulate-sync-state branch from 189f2b0 to 44ab04c Compare November 6, 2023 03:42
Base automatically changed from refactor/encapsulate-sync-state to master November 6, 2023 10:36
@smartprogrammer93 smartprogrammer93 force-pushed the feature/change-mainnet-default-barriers-to-0 branch from 7bf3b7d to e25b7d2 Compare November 6, 2023 19:29
@kamilchodola
Copy link
Contributor

@smartprogrammer93 Let's make sure it is well tested since may break some setups.

@shashankshampi Important topic - please prepare a lot of scenarios including nodes synced on all version (before and after autopivot). Please also put a summary of testing here under PR before it would be merged - let's don't rush this one - it would be included in next version so we have a lot of time to make sure we are well prepared.

@shashankshampi
Copy link
Contributor

The test is done and looks good to go.

Copy link
Contributor

@shashankshampi shashankshampi left a comment

Choose a reason for hiding this comment

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

Tested this branch with couple of scenarios and looks stable to process ahead

Copy link
Contributor

@MarekM25 MarekM25 left a comment

Choose a reason for hiding this comment

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

It looks much better now. Added two comments to consider, but PR looks good

else if (_specProvider.ChainId == BlockchainIds.Mainnet)
{
// Assume the receipts barrier was the previous defualt (deposit contract barrier) only for mainnet
_barrierWhenStarted = DepositContractBarrier;
Copy link
Contributor

Choose a reason for hiding this comment

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

Edge case (not sure if worth handling): if the mainnet user with config barriers different than default deposits will upgrade Nethermind during receipts download it will stop receipts sync.

Copy link
Member

Choose a reason for hiding this comment

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

I would ignore case when someone upgrades during sync

@@ -72,8 +92,27 @@ public override void InitializeFeed()
_barrier = _syncConfig.AncientBodiesBarrierCalc;
if (_logger.IsInfo) _logger.Info($"Changed pivot in bodies sync. Now using pivot {_pivotNumber} and barrier {_barrier}");
ResetSyncStatusList();
if (_blockTree.LowestInsertedBodyNumber is null || _blockTree.LowestInsertedBodyNumber >= _syncConfig.PivotNumberParsed)
Copy link
Contributor

Choose a reason for hiding this comment

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

Think about refactoring BodiesSyncFeed and ReceiptSyncFeed to reuse the same (similar) code

Copy link
Contributor

@MarekM25 MarekM25 left a comment

Choose a reason for hiding this comment

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

Looks good to me. Make sure that it was retested after all changes.

@smartprogrammer93
Copy link
Contributor Author

Retested and got green light from kamil. Merging

@smartprogrammer93 smartprogrammer93 merged commit 5a1eeec into master Dec 7, 2023
65 checks passed
@smartprogrammer93 smartprogrammer93 deleted the feature/change-mainnet-default-barriers-to-0 branch December 7, 2023 15:32
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.

None yet

7 participants