ckb icon indicating copy to clipboard operation
ckb copied to clipboard

feat: add CellsCommitments softfork

Open quake opened this issue 2 years ago • 0 comments

What problem does this PR solve?

This PR adds a softfork implementation of CellsCommitments that can be used to prove transaction output (cell) existence and status (live / dead).

What is changed and how it works?

The implementation uses the merkle mountian range (MMR) as internal data structure, the hash of cell status is stored as MMR element. This PR is still in draft, and is created only for early code review. Please noted that no additional unit or integration tests have been added to this PR, as the relevant code logic has already been covered by the original tests, e.g. whether the MMR root was updated correctly when the chain was reorging.

There are 4 more TODOs.

  • [ ] Because the transactions in the block will affect the MMR root, the original way of adding transactions by blank block template without modifying the extension field is no longer suitable for the integration test, there are about 30+ integration tests that need to be modified, and some of them have been modified so far, and need to be handled in a unified way.

  • [x] lack of 2 RPC to generate and verify MMR proof.

  • [ ] DB migration, there may be a need for an efficient way to update MMR for historical data.

  • [x] the corresponding RFC is being prepared, and will be submitted together with the RFC when this PR is formally submitted. https://github.com/nervosnetwork/rfcs/pull/424

Check List

Tests

  • Unit test
  • Integration test

Side effects

  • There may be performance regression, need more test on mainnet and testnet real data.

Release note

Note: Add a note under the PR title in the release note.

quake avatar Aug 04 '23 01:08 quake