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

feat: Preserve message proofs post-regenesis #1891

Merged
merged 36 commits into from
May 15, 2024

Conversation

bvrooman
Copy link
Contributor

@bvrooman bvrooman commented May 8, 2024

Related tickets:

This PR adds block Merkle data and metadata to the list of migrated tables during regenesis. Creating a snapshot now inlcudes the FuelBlockMerkleData and FuelBlockMerkleMetadata tables. Loading the snapshot writes the FuelBlockMerkleData and FuelBlockMerkleMetadata snapshot tables to the OldFuelBlockMerkleData and OldFuelBlockMerkleMetadata database tables respectively (2 new tables added to the off-chain database).

When querying for a message proof, we check the block height of the query. If the requested message proof is for block height at or above the regenesis block height, we continue to use the on-chain database for data lookups. If it is instead lower than the regenesis block height, we then check the off-chain database for the Old tables.

This PR also refactors the block proof logic to rely on a new trait called DatabaseMerklizedBlocks which provides an interface for querying block related Merkle data. Specifically, this includes retrieving Merkle block data and metadata, and loading the block Merkle tree. The DatabaseMessageProof is now implemented by default for any type that implements this trait, which include the on-chain and off-chain databases that define the corresponding tables.

This PR is intended to not be a breaking change.

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests
  • The specification matches the implemented behavior (link update PR if changes are needed)

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

After merging, notify other teams

[Add or remove entries as needed]

@bvrooman bvrooman self-assigned this May 10, 2024
@bvrooman bvrooman marked this pull request as ready for review May 10, 2024 20:45
@bvrooman bvrooman requested review from a team, MujkicA and segfault-magnet May 10, 2024 20:51
Copy link
Collaborator

@xgreenx xgreenx left a comment

Choose a reason for hiding this comment

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

FuelBlockMerkleData and FuelBlockMerkleMetadata should be on-chain data because all newly produced blocks should be connected to old blocks. Otherwise, it is impossible to withdraw money.

We need to update the Genesis block as well, not to use zero prev_root. It should be the root that contains all old blocks.

image

assert_eq!(nonces.len(), 1);

for nonce in nonces {
let proof = core
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to use the proof and validate it like in the can_get_message_proof test.

Because the proof returned here is not usable. The user is still unable to withdraw his funds because new blocks are not connected to old blocks.


// Then
assert_eq!(nonces.len(), 1);

Copy link
Collaborator

Choose a reason for hiding this comment

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

for block_height in message_block_height+1..latest_block_after_regenesis {

}

xgreenx
xgreenx previously approved these changes May 15, 2024
@xgreenx xgreenx merged commit 31d0741 into master May 15, 2024
34 checks passed
@xgreenx xgreenx deleted the bvrooman/feat/preserve-messages-post-regenesis branch May 15, 2024 11:26
@xgreenx xgreenx mentioned this pull request May 29, 2024
xgreenx added a commit that referenced this pull request May 29, 2024
## Version v0.27.0

### Added
- [#1898](#1898): Enforce
increasing of the `Executor::VERSION` on each release.

### Changed

- [#1906](#1906): Makes
`cli::snapshot::Command` members public such that clients can create and
execute snapshot commands programmatically. This enables snapshot
execution in external programs, such as the regenesis test suite.
- [#1891](#1891): Regenesis
now preserves `FuelBlockMerkleData` and `FuelBlockMerkleMetadata` in the
off-chain table. These tables are checked when querying message proofs.
- [#1886](#1886): Use ref to
`Block` in validation code
- [#1876](#1876): Updated
benchmark to include the worst scenario for `CROO` opcode. Also include
consensus parameters in bench output.
- [#1879](#1879): Return the
old behaviour for the `discovery_works` test.
- [#1848](#1848): Added
`version` field to the `Block` and `BlockHeader` GraphQL entities. Added
corresponding `version` field to the `Block` and `BlockHeader` client
types in `fuel-core-client`.
- [#1873](#1873): Separate
dry runs from block production in executor code, remove `ExecutionKind`
and `ExecutionType`, remove `thread_block_transaction` concept, remove
`PartialBlockComponent` type, refactor away `inner` functions.
- [#1900](#1900): Update the
root README as `fuel-core run` no longer has `--chain` as an option. It
has been replaced by `--snapshot`.

#### Breaking

- [#1894](#1894): Use testnet
configuration for local testnet.
- [#1894](#1894): Removed
support for helm chart.
- [#1910](#1910): `fuel-vm`
upgraded to `0.50.0`. More information in the
[changelog](https://github.com/FuelLabs/fuel-vm/releases/tag/v0.50.0).

## What's Changed
* feat: Support block and header versions gql by @bvrooman in
#1848
* Updated `croo` opcode benchmark to depend on the contract size by
@xgreenx in #1876
* Return the old behaviour for the `discovery_works` test by @xgreenx in
#1879
* Weekly `cargo update` by @github-actions in
#1880
* Separate production from dry runs in executor & Cleanup all execution
paths :) by @MitchTurner in
#1873
* Use ref instead of owned `Block` in validation by @MitchTurner in
#1886
* Weekly `cargo update` by @github-actions in
#1893
* ci: fix typos programmatically by @sdankel in
#1890
* feat: Preserve message proofs post-regenesis by @bvrooman in
#1891
* chore: update README fuel-core run options by @K1-R1 in
#1900
* Weekly `cargo update` by @github-actions in
#1903
* chore: Make snapshot command members pub accessible by @bvrooman in
#1906
* Use testnet configuration for local testnet by @xgreenx in
#1894
* Enforce increasing of the `Executor::VERSION` on each release by
@xgreenx in #1898
* Bumped the version of the `fuel-vm` to `0.50.0` by @xgreenx in
#1910

## New Contributors
* @K1-R1 made their first contribution in
#1900

**Full Changelog**:
v0.26.0...v0.27.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Users must be able to prove messages generated before regenesis to allow withdrawals
2 participants