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

Refactor/header caching #1347

Merged
merged 12 commits into from
Jul 21, 2021

Conversation

greymistcube
Copy link
Contributor

@greymistcube greymistcube commented Jun 17, 2021

This PR caches BlockHeader when creating a Block<T> instance. This is in preparation for dealing with #1164, like #1326 and #1341. Other than caching, this includes the following changes:

  • Internally, on-the-fly hash computation is now done by BlockHeader instead of Block<T>.
  • PreEvaluationHash validation moved to BlockHeader.
  • Partial argument constraints are added for a Block<T> constructor.

Several new constructors for BlockHeader have been introduced to convert some implicit logic more explicit. The main issue remains where there is still too much implicit logic embedded in the "manual" constructor for Block<T>. As left in the FIXME comments, this should be resolved on further refactoring. The first Block<T> constructor in the code should be separated into at least two, one where the constructor is purely used for manual creation of a Block<T> instance (possibly intended for testing) and another intended for block generation through mining.

@codecov
Copy link

codecov bot commented Jun 17, 2021

Codecov Report

Merging #1347 (19c1c70) into main (0033ed7) will decrease coverage by 12.30%.
The diff coverage is 47.13%.

❗ Current head 19c1c70 differs from pull request most recent head eb8897d. Consider uploading reports for the commit eb8897d to get more accurate results

@@             Coverage Diff             @@
##             main    #1347       +/-   ##
===========================================
- Coverage   86.03%   73.72%   -12.31%     
===========================================
  Files         361      253      -108     
  Lines       32457    17095    -15362     
===========================================
- Hits        27925    12604    -15321     
- Misses       2747     3931     +1184     
+ Partials     1785      560     -1225     
Impacted Files Coverage Δ
...bplanet.Explorer/Controllers/ExplorerController.cs 0.00% <0.00%> (ø)
...rer/Controllers/GenericControllerNameConvention.cs 0.00% <0.00%> (ø)
Libplanet.Explorer/Controllers/GraphQLBody.cs 0.00% <0.00%> (ø)
Libplanet.Explorer/ExplorerStartup.cs 0.00% <0.00%> (ø)
Libplanet.Explorer/GraphTypes/NodeStateType.cs 0.00% <0.00%> (ø)
...ibplanet.Explorer/Interfaces/IBlockChainContext.cs 0.00% <0.00%> (ø)
Libplanet.Explorer/Queries/BlockQuery.cs 0.00% <0.00%> (ø)
Libplanet.Explorer/Queries/ExplorerQuery.cs 0.00% <0.00%> (ø)
Libplanet.Explorer/Queries/TransactionQuery.cs 0.00% <0.00%> (ø)
Libplanet.Explorer/Store/AddressRefDoc.cs 0.00% <0.00%> (ø)
... and 255 more

@greymistcube greymistcube self-assigned this Jun 18, 2021
@greymistcube greymistcube added discussion needed We need to dicuss about this invalid This doesn't seem right suggestion Suggestion or feature request labels Jun 18, 2021
@greymistcube greymistcube marked this pull request as ready for review June 18, 2021 00:39
@greymistcube greymistcube removed invalid This doesn't seem right discussion needed We need to dicuss about this labels Jun 21, 2021
limebell
limebell previously approved these changes Jun 21, 2021
@greymistcube greymistcube force-pushed the refactor/header-caching branch 3 times, most recently from 47df0aa to 85cd2e4 Compare July 6, 2021 02:11
@stale
Copy link

stale bot commented Jul 20, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale The issue is stale label Jul 20, 2021
@limebell
Copy link
Member

not stale

@stale stale bot removed the stale The issue is stale label Jul 20, 2021
@greymistcube greymistcube force-pushed the refactor/header-caching branch from 85cd2e4 to fe88cd9 Compare July 20, 2021 17:13
@greymistcube greymistcube merged commit 63ff0c0 into planetarium:main Jul 21, 2021
@greymistcube greymistcube deleted the refactor/header-caching branch July 22, 2021 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion Suggestion or feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants