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

fix: failed to reorg when only one stale block #21

Merged
merged 1 commit into from
Apr 5, 2024

Conversation

yangby-cryptape
Copy link
Contributor

@yangby-cryptape yangby-cryptape commented Apr 5, 2024

Description

This is a contract issue:

  • When update Bitcoin SPV instance:

    Cell Deps:
    - Type Lock
    - SPV Client (id=k)
    - ... ...
    Inputs:
    - SPV Info (tip_client_id=k)
    - SPV Client (id=k+1)
    - ... ...
    Outputs:
    - SPV Info (tip_client_id=k+1)
    - SPV Client (id=k+1)
    - ... ...
    Witnesses:
    - SPV Update
    - ... ...
  • When reorg Bitcoin SPV instance when only 1 stale block:

    Cell Deps:
    - Type Lock
    - SPV Client (id=k)
    - ... ...
    Inputs:
    - SPV Info (tip_client_id=k+1)
    - SPV Client (id=k+1)
    - ... ...
    Outputs:
    - SPV Info (tip_client_id=k+1)
    - SPV Client (id=k+1)
    - ... ...
    Witnesses:
    - SPV Update
    - ... ...

They have exactly the same structure, but different tip-client-id in the SPV info cell.

So, the contract couldn't distinguish the operation for them.

Solution (Urgent, maybe Temporary)

Reorg two Bitcoin SPV clients when they are only 1 stale block.

PROS:

  • Quick to apply the patch, don't have to re-deploy the contract.

CONS:

  • Larger transaction, causes a bit more fee.

My Own Opionion

I think it may be a good final solution.

Since update and reorg-1 are so similar, and reorg are small probability events, adding a tag to all operations is not a good deal.

@yangby-cryptape yangby-cryptape requested review from Flouse and jjyr April 5, 2024 07:16
@yangby-cryptape yangby-cryptape marked this pull request as ready for review April 5, 2024 07:30
@yangby-cryptape yangby-cryptape added this pull request to the merge queue Apr 5, 2024
Merged via the queue into master with commit fc5b5b8 Apr 5, 2024
5 checks passed
@yangby-cryptape yangby-cryptape deleted the bugfix/reorg-failed-when-only-1-stale branch April 5, 2024 07:42
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