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

Clean the pruning log and add config for parallel and parents count #4372

Open
wants to merge 18 commits into
base: dag-master
Choose a base branch
from

Conversation

jackzhhuang
Copy link
Collaborator

@jackzhhuang jackzhhuang commented Jan 16, 2025

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Other information

Summary by CodeRabbit

Release Notes

  • Configuration Enhancements

    • Added configurable maximum parents count for miners.
    • Introduced lightweight sync configuration with max gap setting.
  • Synchronization Improvements

    • Enhanced block synchronization logic with more flexible gap checking.
    • Improved block connection and verification processes.
  • Performance Optimizations

    • Updated block DAG management to handle pruning points more efficiently.
    • Modified storage write operations for potential performance gains.
  • New Features

    • Added ability to configure maximum number of parent blocks.
    • Implemented more granular block synchronization controls.
    • Introduced a method for accessing the k value in the GhostdagManager.
    • Added a method to check historical blocks in the BlockDAG.

Copy link

coderabbitai bot commented Jan 16, 2025

Walkthrough

This pull request introduces several configuration and functionality enhancements across the Starcoin blockchain's core components. The primary changes focus on improving block production, synchronization, and pruning processes. Key modifications include adding a new G_MAX_PARENTS_COUNT constant, updating configuration options for miners and synchronization, and refining block verification and ghostdata management logic. The changes aim to provide more flexibility in handling block relationships, parent count, and synchronization strategies.

Changes

File Change Summary
chain/mock/src/mock_chain.rs Added import for G_MAX_PARENTS_COUNT
chain/src/chain.rs Updated verify_and_ghostdata method to include latest pruning point
config/src/lib.rs Made miner_config module public
config/src/miner_config.rs Added G_MAX_PARENTS_COUNT constant and maximum_parents_count configuration
config/src/sync_config.rs Added lightweight_sync_max_gap configuration option
flexidag/src/blockdag.rs Enhanced block verification, ghostdata, and tip calculation logic
flexidag/src/consensusdb/db.rs Changed write batch method from synchronous to potentially asynchronous
flexidag/src/ghostdag/protocol.rs Added public k() method to GhostdagManager
flexidag/tests/tests.rs Added import for G_MAX_PARENTS_COUNT in tests
sync/src/block_connector/block_connector_service.rs Updated is_near_block method with configurable gap logic

Possibly related PRs

  • Dag sync continue #4153: The changes in this PR involve modifications to the BlockDAG implementation, which includes updates to methods related to block verification and pruning, potentially connecting to the main PR's focus on pruning logic.
  • Pruning logic #4194: This PR introduces significant modifications to the ChainReader and BlockChain implementations, enhancing their functionality for managing blockchain data and pruning, which aligns with the main PR's focus on pruning logic.
  • Reset dag chain #4227: The changes in this PR involve enhancements to the BlockDAG struct, including new methods for managing DAG state and pruning, which are directly related to the main PR's focus on pruning logic.

Suggested reviewers

  • welbon
  • nkysg
  • yourmoonlight
  • simonjiao
  • sanlee42

Poem

🐰 Blocks dance in the DAG's embrace,
Parents counted with newfound grace.
Configuration's gentle art,
Sync and prune, a rabbit's smart start!
Blockchain evolves, one hop at a time. 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jackzhhuang jackzhhuang marked this pull request as draft January 16, 2025 02:08
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (7)
flexidag/src/blockdag.rs (3)

106-111: Consider refactoring duplicated error handling code

The error handling logic in lines 106-111 is similar to the code in lines 121-126. To improve maintainability and reduce code duplication, consider refactoring this logic into a helper function.


121-126: Consider refactoring duplicated error handling code

Similar to lines 106-111, the error handling in lines 121-126 can be refactored into a helper function to enhance code readability and reduce duplication.


719-721: Format multi-line expression as a single line

The pipeline warning indicates that the multi-line expression in lines 719-721 should be formatted as a single line to adhere to code style guidelines.

Consider reformatting the code as:

let next_pruning_point = self.pruning_point_manager().next_pruning_point(previous_pruning_point, previous_ghostdata, &next_ghostdata, pruning_depth, pruning_finality)?;
🧰 Tools
🪛 GitHub Actions: Build and Test

[warning] 719-721: Code formatting issue: Multi-line expression should be formatted as a single line

config/src/miner_config.rs (2)

10-10: Document the rationale for G_MAX_PARENTS_COUNT value.

Please add a doc comment explaining why 16 was chosen as the default maximum parents count. This helps future maintainers understand the reasoning behind this constant.

+/// Default maximum number of parent blocks allowed.
+/// Set to 16 because... <add rationale here>
 pub static G_MAX_PARENTS_COUNT: u64 = 16;

70-72: Add documentation for the maximum_parents_count method.

The method lacks documentation explaining its purpose and behavior.

+    /// Returns the configured maximum number of parent blocks allowed.
+    /// If not configured, returns the default value from G_MAX_PARENTS_COUNT.
     pub fn maximum_parents_count(&self) -> u64 {
         self.maximum_parents_count.unwrap_or(G_MAX_PARENTS_COUNT)
     }
flexidag/src/ghostdag/protocol.rs (1)

489-491: Add documentation for the k method.

Please add documentation explaining the purpose of this method and what the k value represents in the GHOSTDAG protocol.

+    /// Returns the k parameter of the GHOSTDAG protocol.
+    /// This parameter limits the size of the anticone that can be blue.
+    /// For more details, see: https://eprint.iacr.org/2018/104.pdf
     pub fn k(&self) -> KType {
         self.k
     }
chain/src/chain.rs (1)

1384-1397: LGTM! Good addition of latest pruning point to ghostdata verification.

The changes properly handle the pruning point retrieval with appropriate error handling. Consider extracting the pruning point retrieval logic into a separate method for better readability.

 impl ChainReader for BlockChain {
+    fn get_latest_pruning_point(&self) -> Result<Option<HashValue>> {
+        Ok(match self.storage.get_startup_info()? {
+            Some(startup_info) => self
+                .storage
+                .get_block_header_by_hash(startup_info.main)?
+                .map(|head_block| head_block.pruning_point()),
+            None => None,
+        })
+    }
+
     fn verify_and_ghostdata(
         &self,
         uncles: &[BlockHeader],
         header: &BlockHeader,
     ) -> Result<starcoin_dag::types::ghostdata::GhostdagData> {
-        let latest_pruning_point = {
-            match self.storage.get_startup_info().unwrap_or(None) {
-                Some(startup_info) => self
-                    .storage
-                    .get_block_header_by_hash(startup_info.main)
-                    .unwrap_or(None)
-                    .map(|head_block| head_block.pruning_point()),
-                None => None,
-            }
-        };
-
+        let latest_pruning_point = self.get_latest_pruning_point()?;
         Ok(self
             .dag()
             .verify_and_ghostdata(uncles, header, latest_pruning_point)?)
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d448e3 and f2e442e.

📒 Files selected for processing (10)
  • chain/mock/src/mock_chain.rs (2 hunks)
  • chain/src/chain.rs (1 hunks)
  • config/src/lib.rs (1 hunks)
  • config/src/miner_config.rs (4 hunks)
  • config/src/sync_config.rs (3 hunks)
  • flexidag/src/blockdag.rs (9 hunks)
  • flexidag/src/consensusdb/db.rs (1 hunks)
  • flexidag/src/ghostdag/protocol.rs (1 hunks)
  • flexidag/tests/tests.rs (3 hunks)
  • sync/src/block_connector/block_connector_service.rs (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • flexidag/tests/tests.rs
🧰 Additional context used
🪛 GitHub Actions: Build and Test
flexidag/src/blockdag.rs

[error] 709-709: Left behind trailing whitespace at the end of line


[error] 726-726: Left behind trailing whitespace at the end of line


[warning] 719-721: Code formatting issue: Multi-line expression should be formatted as a single line

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: run benchmark
🔇 Additional comments (9)
config/src/sync_config.rs (3)

32-42: Well-defined addition of 'lightweight_sync_max_gap' field

The addition of the lightweight_sync_max_gap field enhances synchronization configuration flexibility. The field is properly annotated with serialization attributes and command-line argument definitions.


54-56: Accessor method for 'lightweight_sync_max_gap' is correctly implemented

The lightweight_sync_max_gap method provides convenient access to the new configuration field.


69-71: Correct merging logic for 'lightweight_sync_max_gap'

The merge_with_opt method appropriately updates lightweight_sync_max_gap from command-line options if provided.

flexidag/src/consensusdb/db.rs (1)

107-107: Verify impact of changing from synchronous to asynchronous batch write

Switching from raw_write_batch_sync to raw_write_batch may affect data durability guarantees. Ensure that this change does not introduce data consistency issues, especially in scenarios involving system crashes or power failures.

To confirm whether data durability is maintained, please review the write options and ensure that write-ahead logging or synchronous writes are appropriately configured if required.

config/src/miner_config.rs (1)

116-119: LGTM!

The implementation of merging the maximum_parents_count configuration is correct.

chain/mock/src/mock_chain.rs (1)

7-7: LGTM!

The import and usage of G_MAX_PARENTS_COUNT is appropriate for the pruning functionality.

Also applies to: 270-270

config/src/lib.rs (1)

36-36: LGTM!

Making the miner_config module public is appropriate as it contains the new G_MAX_PARENTS_COUNT constant that needs to be accessible from other crates.

sync/src/block_connector/block_connector_service.rs (2)

139-152: LGTM! Good improvements to the gap calculation logic.

The changes make the gap configurable while maintaining safe arithmetic operations. The added debug logging will help with troubleshooting synchronization issues.


456-456: LGTM! Good addition of configurable maximum parents count.

The change allows flexible configuration of the maximum number of parent blocks during mining.

flexidag/src/blockdag.rs Show resolved Hide resolved
flexidag/src/blockdag.rs Outdated Show resolved Hide resolved
flexidag/src/blockdag.rs Outdated Show resolved Hide resolved
config/src/miner_config.rs Outdated Show resolved Hide resolved
…ain net

2, add checking for the first pruning point
@jackzhhuang jackzhhuang marked this pull request as ready for review January 16, 2025 06:22
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
flexidag/src/blockdag.rs (1)

777-796: Adjust logging levels for detailed messages

Multiple info! log statements are used within check_historical_block for detailed conditional messages. Consider using debug! or trace! levels for these logs to prevent cluttering the info logs and to better categorize log severity.

chain/src/chain.rs (1)

1385-1394: Simplify nested unwrap_or calls for better readability.

The nested unwrap_or calls make the code harder to follow. Consider refactoring for better readability and error handling.

-        let latest_pruning_point = {
-            match self.storage.get_startup_info().unwrap_or(None) {
-                Some(startup_info) => self
-                    .storage
-                    .get_block_header_by_hash(startup_info.main)
-                    .unwrap_or(None)
-                    .map(|head_block| head_block.pruning_point()),
-                None => None,
-            }
-        };
+        let latest_pruning_point = self
+            .storage
+            .get_startup_info()
+            .ok()
+            .flatten()
+            .and_then(|startup_info| {
+                self.storage
+                    .get_block_header_by_hash(startup_info.main)
+                    .ok()
+                    .flatten()
+                    .map(|head_block| head_block.pruning_point())
+            });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f2e442e and d2eaca8.

📒 Files selected for processing (10)
  • chain/mock/src/mock_chain.rs (2 hunks)
  • chain/src/chain.rs (2 hunks)
  • config/src/lib.rs (1 hunks)
  • config/src/miner_config.rs (4 hunks)
  • config/src/sync_config.rs (3 hunks)
  • flexidag/src/blockdag.rs (9 hunks)
  • flexidag/src/consensusdb/db.rs (1 hunks)
  • flexidag/src/ghostdag/protocol.rs (1 hunks)
  • flexidag/tests/tests.rs (3 hunks)
  • sync/src/block_connector/block_connector_service.rs (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • config/src/lib.rs
  • flexidag/tests/tests.rs
  • flexidag/src/ghostdag/protocol.rs
  • chain/mock/src/mock_chain.rs
  • flexidag/src/consensusdb/db.rs
  • config/src/miner_config.rs
🔇 Additional comments (5)
config/src/sync_config.rs (3)

31-42: LGTM

The addition of lightweight_sync_max_gap to SyncConfig is implemented correctly, enhancing synchronization flexibility.


54-56: LGTM

The new method lightweight_sync_max_gap correctly returns the configuration value.


69-71: LGTM

The merge_with_opt method properly merges the lightweight_sync_max_gap option from command-line arguments.

sync/src/block_connector/block_connector_service.rs (1)

139-152: LGTM

The updated logic in is_near_block correctly utilizes the new lightweight_sync_max_gap configuration parameter, improving synchronization behavior.

chain/src/chain.rs (1)

1396-1398: LGTM! The DAG verification call is properly updated.

The changes correctly pass the latest pruning point to the DAG's verify_and_ghostdata method while maintaining proper error handling.

Comment on lines +661 to +681
let a_blue_work = self
.storage
.ghost_dag_store
.get_blue_work(*a)
.unwrap_or_else(|e| {
panic!(
"the ghostdag data should be existed for {:?}, e: {:?}",
a, e
)
});
let b_blue_work = self
.storage
.ghost_dag_store
.get_blue_work(*b)
.unwrap_or_else(|e| {
panic!(
"the ghostdag data should be existed for {:?}, e: {:?}",
b, e
)
});
if a_blue_work == b_blue_work {
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid panicking inside the sorting comparator

Using panic! inside the sorted_by comparator may cause the application to terminate unexpectedly if get_blue_work fails. Consider handling the error gracefully by propagating the error or using a default value.

Apply this diff to handle the error without panicking:

 .sorted_by(|a, b| {
     let a_blue_work = self
         .storage
         .ghost_dag_store
         .get_blue_work(*a)
-        .unwrap_or_else(|e| {
-            panic!(
-                "the ghostdag data should be existed for {:?}, e: {:?}",
-                a, e
-            )
-        });
+        .unwrap_or_default();
     let b_blue_work = self
         .storage
         .ghost_dag_store
         .get_blue_work(*b)
-        .unwrap_or_else(|e| {
-            panic!(
-                "the ghostdag data should be existed for {:?}, e: {:?}",
-                b, e
-            )
-        });
+        .unwrap_or_default();
     if a_blue_work == b_blue_work {
         a.cmp(b)
     } else {
         b_blue_work.cmp(&a_blue_work)
     }
 })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let a_blue_work = self
.storage
.ghost_dag_store
.get_blue_work(*a)
.unwrap_or_else(|e| {
panic!(
"the ghostdag data should be existed for {:?}, e: {:?}",
a, e
)
});
let b_blue_work = self
.storage
.ghost_dag_store
.get_blue_work(*b)
.unwrap_or_else(|e| {
panic!(
"the ghostdag data should be existed for {:?}, e: {:?}",
b, e
)
});
if a_blue_work == b_blue_work {
let a_blue_work = self
.storage
.ghost_dag_store
.get_blue_work(*a)
.unwrap_or_default();
let b_blue_work = self
.storage
.ghost_dag_store
.get_blue_work(*b)
.unwrap_or_default();
if a_blue_work == b_blue_work {

@jackzhhuang jackzhhuang marked this pull request as draft January 16, 2025 06:27
Copy link

Benchmark for 94baa71

Click to view benchmark
Test Base PR %
accumulator_append 816.4±215.63µs 836.5±105.71µs +2.46%
block_apply/block_apply_10 533.6±54.93ms 367.0±10.12ms -31.22%
block_apply/block_apply_1000 42.6±1.53s 40.8±0.73s -4.23%
get_with_proof/db_store 44.0±2.12µs 45.3±2.90µs +2.95%
get_with_proof/mem_store 35.8±1.29µs 37.0±2.01µs +3.35%
put_and_commit/db_store/1 116.4±5.19µs 129.1±18.61µs +10.91%
put_and_commit/db_store/10 1081.3±66.53µs 1076.9±154.05µs -0.41%
put_and_commit/db_store/100 9.7±0.71ms 9.9±0.75ms +2.06%
put_and_commit/db_store/5 537.8±23.89µs 589.0±65.08µs +9.52%
put_and_commit/db_store/50 4.9±0.23ms 4.9±0.39ms 0.00%
put_and_commit/mem_store/1 73.2±9.36µs 85.4±21.25µs +16.67%
put_and_commit/mem_store/10 660.8±54.40µs 681.6±80.44µs +3.15%
put_and_commit/mem_store/100 6.6±0.52ms 6.3±0.27ms -4.55%
put_and_commit/mem_store/5 343.6±35.47µs 334.7±43.22µs -2.59%
put_and_commit/mem_store/50 3.2±0.13ms 3.3±0.30ms +3.13%
query_block/query_block_in(10)_times(100) 8.3±0.22ms 8.5±0.51ms +2.41%
query_block/query_block_in(10)_times(1000) 83.9±2.40ms 85.3±5.97ms +1.67%
query_block/query_block_in(10)_times(10000) 1009.4±267.30ms 862.3±53.00ms -14.57%
query_block/query_block_in(1000)_times(100) 1232.1±43.24µs 1265.7±76.72µs +2.73%
query_block/query_block_in(1000)_times(1000) 12.2±0.43ms 15.7±5.71ms +28.69%
query_block/query_block_in(1000)_times(10000) 121.0±4.54ms 142.4±13.91ms +17.69%
storage_transaction 1072.6±418.12µs 1174.5±524.08µs +9.50%
vm/transaction_execution/1 415.8±15.51ms 424.4±17.90ms +2.07%
vm/transaction_execution/10 127.8±3.26ms 134.4±5.32ms +5.16%
vm/transaction_execution/20 117.7±4.36ms 131.9±33.87ms +12.06%
vm/transaction_execution/5 155.7±5.46ms 163.8±11.05ms +5.20%
vm/transaction_execution/50 140.8±13.55ms 146.2±9.13ms +3.84%

@jackzhhuang jackzhhuang marked this pull request as ready for review January 16, 2025 13:47
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
flexidag/src/blockdag.rs (1)

654-692: ⚠️ Potential issue

Replace panic with safe error handling in the sorting comparator.

Using panic! inside a sorting comparator is dangerous as it can crash the application. Consider using unwrap_or_default() or a default comparison when get_blue_work fails.

This is a duplicate of a previous review comment. The suggested fix remains the same:

  • Replace panic with safe error handling
  • Use default values when ghost data retrieval fails
🧹 Nitpick comments (2)
flexidag/src/prune/pruning_point_manager.rs (2)

45-47: Document the zero hash case handling.

The special handling of HashValue::zero() should be documented to explain why this case warrants immediate return of current tips. This helps maintainers understand the relationship between zero hash and pruning point equality.

Add a comment explaining the zero hash case:

+    // HashValue::zero() indicates [explain special case], which should be treated
+    // the same as when current and next pruning points match
     if next_pruning_point == HashValue::zero() {
         return Ok(dag_state.tips.clone());
     }

45-50: Consider refactoring duplicate return logic.

Both conditions (HashValue::zero() and equality check) return the same result. Consider combining them to improve maintainability.

-    if next_pruning_point == HashValue::zero() {
-        return Ok(dag_state.tips.clone());
-    }
-    if current_pruning_point == next_pruning_point {
+    if next_pruning_point == HashValue::zero() || current_pruning_point == next_pruning_point {
         return Ok(dag_state.tips.clone());
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d2eaca8 and adf48be.

📒 Files selected for processing (2)
  • flexidag/src/blockdag.rs (10 hunks)
  • flexidag/src/prune/pruning_point_manager.rs (1 hunks)
🔇 Additional comments (4)
flexidag/src/blockdag.rs (4)

Line range hint 106-126: LGTM! Improved error handling implementation.

The refactored error handling is more efficient and provides better error messages. Using has() checks instead of direct retrieval is a good optimization.


767-803: LGTM! Well-documented historical block check implementation.

The function is well-structured with:

  • Clear documentation explaining the purpose and special cases
  • Comprehensive logging for each decision path
  • Proper handling of edge cases, especially for the Vega chain

806-817: LGTM! Clean implementation of verification logic.

The function effectively:

  • Uses the new historical block check to determine processing path
  • Properly delegates to appropriate processing methods
  • Maintains clean error handling

Line range hint 323-355: Fix inconsistent parent hash usage in virtual selected parent hints.

There's an inconsistency in the parent hash used for hinting virtual selected parent:

  • In the first implementation (lines 330), it uses header.parent_hash()
  • In the second implementation (line 485), it also uses header.parent_hash()
  • However, in the first case, this is used when header.pruning_point() is zero, while in the second case, it's used when the pruning point differs from the reindex root.

This inconsistency could lead to different behavior in these two scenarios.

Let's verify the impact:

Also applies to: 483-490

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