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

FixTotalDifficulty db migration #5439

Conversation

deffrian
Copy link
Contributor

@deffrian deffrian commented Mar 16, 2023

Fixes Closes Resolves #

#5341

Changes

  • Adds FixTotalDifficulty migration

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

@deffrian deffrian changed the title SetTDRpcCall [DRAFT]SetTDRpcCall Mar 16, 2023
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.

I think if it is really needed we should write the FixTd process with block numbers (from and to) as an argument (check FixBlooms etc.) but not sure if it is the root cause of the problem

@deffrian deffrian changed the title [DRAFT]SetTDRpcCall SetTDRpcCall Mar 17, 2023
@deffrian deffrian changed the title SetTDRpcCall FixTotalDifficulty db migration Mar 17, 2023
@deffrian deffrian marked this pull request as ready for review March 17, 2023 18:24
@abcfy2
Copy link

abcfy2 commented Mar 27, 2023

And update about this PR ? Will this PR be merged ?

@deffrian
Copy link
Contributor Author

@abcfy2 Most probably will be merged next week. After that we can make custom docker image for you. Or you can wait until next release

@abcfy2
Copy link

abcfy2 commented Apr 1, 2023

Thanks. But I use Ubuntu ppa for deployment. So I have to wait for next release.

Thanks all the same.

private void RunMigration(long startingBlock, long? lastBlock, CancellationToken cancellationToken)
{
IChainLevelInfoRepository chainLevelInfoRepository = _api.ChainLevelInfoRepository ?? throw new ArgumentNullException(nameof(_api.ChainLevelInfoRepository));
IBlockTree blockTree = _api.BlockTree ?? throw new ArgumentNullException(nameof(_api.BlockTree));
Copy link
Contributor

Choose a reason for hiding this comment

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

If migration is only using BlockTree and ChainLevelInfoHistory, it could accept these interfaces in constructor and perform argument check earlier.


UInt256 expectedTd = previousTd + header.Difficulty;
ChainLevelInfo currentLevel = chainLevelInfoRepository.LoadLevel(blockNumber)!;
UInt256 actualTd = currentLevel.BlockInfos[0].TotalDifficulty;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a question - is this possible to have different TD in block info at any other index?

@deffrian deffrian merged commit 8e669bf into master Apr 12, 2023
@deffrian deffrian deleted the 5341-trace_block-error-systeminvalidoperationexception-block-without-total-difficulty-calculated-was-suggested-for-processing branch April 12, 2023 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants