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

[bitcoin_move] Improve reorg and pending block #2691

Merged
merged 2 commits into from
Sep 25, 2024

Conversation

jolestar
Copy link
Contributor

@jolestar jolestar commented Sep 25, 2024

Summary

[bitcoin_move] Improve reorg and pending block logic.
[test] Add reorg failed test case
[rpc] Add rooch_status API to get the rpc service, Rooch, and Bitcoin status.

rooch rpc request --method rooch_status 
{
  "service_status": "active",
  "rooch_status": {
    "sequencer_info": {
      "last_order": "224",
      "last_accumulator_info": {
        "accumulator_root": "0x47cf3562c72f93e360017b08374e2bbb8ba319c824c649946a4dfa4511599347",
        "frozen_subtree_roots": [
          "0x3795aa636d75ff68d282b9afad889ba9c0efca46fcd9b93e79ea703d65759a4d",
          "0x96e1b6e9e0c2bfa2a92bc83db25baf2e1a8789147246898a331f9a9fb4ec31bd",
          "0xb81ea651ae858bb6522b25a4d2b1617d6be684114f5cf9e71987a339c858543d",
          "0x65a9391a914f641cf723ea9780f04e9682f10e42fe0f129826e6f5e9cc6a34e8"
        ],
        "num_leaves": "225",
        "num_nodes": "446"
      }
    },
    "root_state": {
      "state_root": "0x9df91a21bb06383597f3c422f5767eca7cd1af89fc7ab6ada10c81af16a40576",
      "size": "57"
    }
  },
  "bitcoin_status": {
    "confirmed_block": {
      "block_height": "106",
      "block_hash": "77aefde90a4c8dc6786a3c44911cbf1547239118650ef44cd9145aa131226366"
    },
    "pending_block": {
      "block_height": "106",
      "block_hash": "77aefde90a4c8dc6786a3c44911cbf1547239118650ef44cd9145aa131226366"
    }
  }
}

relative issue: #2653

Copy link

vercel bot commented Sep 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rooch-portal-v2.1 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2024 10:24am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
rooch ⬜️ Ignored (Inspect) Sep 25, 2024 10:24am

Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

@@ -308,6 +311,13 @@ module bitcoin_move::pending_block{
};
let block_hash = *simple_map::borrow(&store.pending_blocks, &ready_block_height);
let block_obj = borrow_pending_block(block_hash);
let prev_block_hash = types::prev_blockhash(&object::borrow(block_obj).header);
while(exists_pending_block(prev_block_hash)){
Copy link
Collaborator

Choose a reason for hiding this comment

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

这段代码是为了确保 penging 区块即使在排序异常的情况下,也能优先处理最早的区块?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

原来的逻辑下,pending 的 block 要恰好比 reorg count 多 1,如果否则就会把后面的块先处理了。

}

fun handle_reog(store: &mut PendingStore, reorg_block_height: u64){
fun handle_reorg(store: &mut PendingStore, reorg_block_height: u64){
Copy link
Collaborator

Choose a reason for hiding this comment

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

直接 remove private 的 fun,有没有兼容性问题?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

private fun 可以随便改。

@jolestar jolestar merged commit 3f30c9b into main Sep 25, 2024
10 checks passed
@jolestar jolestar deleted the improve_reorg_and_pending_block branch September 25, 2024 12:16
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.

3 participants