starcoinorg / starcoin

Starcoin - A Move smart contract blockchain network that scales by layering
Apache License 2.0
1.38k stars 289 forks source link

Remove merge red blocks when mining #4245

Open jackzhhuang opened 1 month ago

jackzhhuang commented 1 month ago

Pull request type

Please check the type of change your PR introduces:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

-

-

Other information

Summary by CodeRabbit

coderabbitai[bot] commented 1 month ago

Walkthrough

The changes introduce several enhancements across various modules in the codebase. A new method merge_check_and_ghostdata is added to the ChainReader trait, which allows for merge checks and ghost data retrieval. The MockChain struct is updated to reflect these changes, and significant renaming of verifier types occurs for clarity. Additionally, new structures and methods related to block depth management are introduced, alongside updates to existing methods for improved error handling and logging. Overall, the modifications aim to enhance functionality and clarity in blockchain operations.

Changes

File Path Change Summary
chain/api/src/chain.rs Added method merge_check_and_ghostdata to ChainReader trait.
chain/mock/src/mock_chain.rs Renamed blue_blocks to ghostdata, updated logging and block header collection logic.
chain/src/chain.rs Renamed verifier types, updated verify and apply methods in ChainReader and ChainWriter, added merge_check_and_ghostdata and verify_pruning_point methods.
chain/src/verifier/mod.rs Renamed DagVerifier to DagVerifierForMining and DagVerifierWithGhostData to DagVerifierForSync, updated verification logic.
config/src/genesis_config.rs Added static variable G_MERGE_DEPTH.
flexidag/src/block_depth/block_depth_info.rs Introduced BlockDepthManagerT struct with methods for managing block depth.
flexidag/src/block_depth/mod.rs Added new public module block_depth_info.
flexidag/src/blockdag.rs Enhanced BlockDAG with new methods for block depth management and updated constructors.
flexidag/src/consensusdb/consensus_block_depth.rs Introduced BlockDepthInfo struct, added schema and traits for block depth management.
flexidag/src/consensusdb/db.rs Added block_depth_info_store field to FlexiDagStorage.
flexidag/src/consensusdb/mod.rs Added new public module consensus_block_depth.
flexidag/src/lib.rs Added new module block_depth and function process_key_already_error.
flexidag/src/prune/pruning_point_manager.rs Updated logic in next_pruning_point method for pruning depth checks.
flexidag/tests/tests.rs Added new test function test_merge_bounded, updated existing test functions for improved assertions.
sync/src/block_connector/block_connector_service.rs Introduced G_MERGE_DEPTH constant, updated mining logic to use ghostdata.
sync/src/block_connector/write_block_chain.rs Modified reset and apply_failed methods for improved block management.
sync/src/parallel/executor.rs Updated apply_with_verifier to use DagVerifierForSync, modified waiting_for_parents method signature.
sync/src/tasks/block_sync_task.rs Enhanced collect method in BlockCollector for clearer control flow and logging.

Possibly related PRs

Suggested reviewers

Poem

🐰 In the code where blocks do flow,
New methods sprout, like seeds we sow.
Merging data, pruning with care,
A rabbit hops, with joy to share!
With ghostly whispers, depths we trace,
In the world of blocks, we find our place! 🌟


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 - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , 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 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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
github-actions[bot] commented 1 month ago

Benchmark for dbaaa9c

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | accumulator_append | 791.4±125.07µs | 868.7±163.01µs | +9.77% | | block_apply/block_apply_10 | 454.5±69.98ms | **363.0±4.60ms** | **-20.13%** | | block_apply/block_apply_1000 | 43.3±1.65s | **41.0±1.39s** | **-5.31%** | | get_with_proof/db_store | 44.5±4.00µs | **43.3±0.92µs** | **-2.70%** | | get_with_proof/mem_store | 36.8±4.20µs | 35.7±2.32µs | -2.99% | | put_and_commit/db_store/1 | 122.0±13.16µs | 123.3±20.80µs | +1.07% | | put_and_commit/db_store/10 | **1118.3±102.07µs** | 1364.3±416.54µs | **+22.00%** | | put_and_commit/db_store/100 | 10.3±1.10ms | 11.2±1.80ms | +8.74% | | put_and_commit/db_store/5 | 555.8±30.72µs | 539.1±19.77µs | -3.00% | | put_and_commit/db_store/50 | 5.4±0.79ms | 5.0±0.61ms | -7.41% | | put_and_commit/mem_store/1 | 79.9±25.34µs | **71.1±7.70µs** | **-11.01%** | | put_and_commit/mem_store/10 | 701.0±90.26µs | 653.4±53.88µs | -6.79% | | put_and_commit/mem_store/100 | 6.6±0.80ms | 6.5±0.54ms | -1.52% | | put_and_commit/mem_store/5 | 341.0±51.17µs | 340.1±48.89µs | -0.26% | | put_and_commit/mem_store/50 | 3.4±0.34ms | 3.2±0.35ms | -5.88% | | query_block/query_block_in(10)_times(100) | 8.0±0.56ms | 8.4±0.47ms | +5.00% | | query_block/query_block_in(10)_times(1000) | 83.9±3.28ms | 82.2±3.52ms | -2.03% | | query_block/query_block_in(10)_times(10000) | 856.0±58.99ms | 873.0±57.11ms | +1.99% | | query_block/query_block_in(1000)_times(100) | 1253.1±61.24µs | 1240.1±100.94µs | -1.04% | | query_block/query_block_in(1000)_times(1000) | 14.4±2.61ms | **12.0±0.43ms** | **-16.67%** | | query_block/query_block_in(1000)_times(10000) | 132.9±13.80ms | **120.9±5.58ms** | **-9.03%** | | storage_transaction | 1201.9±478.40µs | 1123.8±491.89µs | -6.50% | | vm/transaction_execution/1 | **396.6±11.44ms** | 451.2±44.71ms | **+13.77%** | | vm/transaction_execution/10 | 140.5±12.57ms | **131.6±6.70ms** | **-6.33%** | | vm/transaction_execution/20 | 123.2±6.88ms | 120.8±2.90ms | -1.95% | | vm/transaction_execution/5 | 165.6±11.53ms | 171.2±14.40ms | +3.38% | | vm/transaction_execution/50 | 150.8±8.11ms | 145.1±10.30ms | -3.78% |
github-actions[bot] commented 1 month ago

Benchmark for e8a9e42

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | accumulator_append | 829.6±155.58µs | 833.8±152.69µs | +0.51% | | block_apply/block_apply_10 | 384.4±20.01ms | 373.7±13.90ms | -2.78% | | block_apply/block_apply_1000 | **41.4±1.45s** | 44.3±2.84s | **+7.00%** | | get_with_proof/db_store | 49.3±9.46µs | **43.9±4.06µs** | **-10.95%** | | get_with_proof/mem_store | 41.4±7.27µs | **35.9±2.21µs** | **-13.29%** | | put_and_commit/db_store/1 | 166.0±44.75µs | 141.1±30.75µs | -15.00% | | put_and_commit/db_store/10 | **1125.5±197.56µs** | 1639.6±323.71µs | **+45.68%** | | put_and_commit/db_store/100 | 10.9±1.68ms | 10.9±1.62ms | 0.00% | | put_and_commit/db_store/5 | 571.9±77.36µs | 613.9±127.07µs | +7.34% | | put_and_commit/db_store/50 | 5.3±1.13ms | 5.2±0.55ms | -1.89% | | put_and_commit/mem_store/1 | 71.1±8.56µs | 69.6±6.37µs | -2.11% | | put_and_commit/mem_store/10 | 687.3±89.10µs | 681.4±95.76µs | -0.86% | | put_and_commit/mem_store/100 | 6.5±0.41ms | 6.5±0.46ms | 0.00% | | put_and_commit/mem_store/5 | 375.4±61.09µs | 356.6±48.25µs | -5.01% | | put_and_commit/mem_store/50 | 3.6±0.62ms | 3.7±0.79ms | +2.78% | | query_block/query_block_in(10)_times(100) | **8.2±0.31ms** | 8.8±0.80ms | **+7.32%** | | query_block/query_block_in(10)_times(1000) | 89.2±6.69ms | 92.9±8.78ms | +4.15% | | query_block/query_block_in(10)_times(10000) | 884.8±68.92ms | **826.2±24.73ms** | **-6.62%** | | query_block/query_block_in(1000)_times(100) | 1279.1±47.42µs | **1220.8±58.00µs** | **-4.56%** | | query_block/query_block_in(1000)_times(1000) | 12.8±1.08ms | 12.7±0.84ms | -0.78% | | query_block/query_block_in(1000)_times(10000) | 148.1±16.72ms | **128.3±10.73ms** | **-13.37%** | | storage_transaction | 1208.5±497.25µs | 1257.5±541.88µs | +4.05% | | vm/transaction_execution/1 | **416.7±15.95ms** | 470.5±69.84ms | **+12.91%** | | vm/transaction_execution/10 | **135.2±8.29ms** | 145.9±11.49ms | **+7.91%** | | vm/transaction_execution/20 | 123.4±11.23ms | **118.3±5.04ms** | **-4.13%** | | vm/transaction_execution/5 | **162.6±4.88ms** | 175.6±13.73ms | **+8.00%** | | vm/transaction_execution/50 | 145.6±8.75ms | 148.0±10.14ms | +1.65% |