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!: add new header field #6686

Merged
merged 8 commits into from
Nov 14, 2024

Conversation

SWvheerden
Copy link
Collaborator

@SWvheerden SWvheerden commented Nov 12, 2024

Description

Add new header field, block output mmr which only tracks outputs in current block

Motivation and Context

This is needed in order to validate that all outputs included in the block is correctly captured in the pow of the header. The current strategy is to only use the output smt, which commits to all outputs on the blockchain. This is required for horizon sync and prune mode to verify the blockchain as we sync.
But someone else wants to verify the block outputs, they have to have the entire outputs set aka entire blockchain in order to verify that the outputs are indeed locked behind pow.
This addition allows any person to take only the block and know that the outputs contained in that block, is correctly locked behind the pow of the header.

The output field is constructed as two merkle mountain ranges.
the primary one used in the header field is constructed as
[coinbase_1, coinbase_2, .., coinbase_x, non_coinbase_ouputs_merkle_root]
with the non_coinbase_ouputs_merkle_root constructed as
[output_1, output_2, .., output_x]

This double mountain range approach allows you to prove the output are in the block header, as well as create a proof for a specific output. But separating them allows p2pool to only need to store a single hash + list of all outputs in order to verify all coin bases are correctly included in the header. Rather than all outputs or before this pr, the entire block.

Breaking change

Need to resync database

@SWvheerden SWvheerden requested a review from a team as a code owner November 12, 2024 15:25
Copy link

github-actions bot commented Nov 12, 2024

Test Results (CI)

    3 files    129 suites   35m 36s ⏱️
1 344 tests 1 344 ✅ 0 💤 0 ❌
4 030 runs  4 030 ✅ 0 💤 0 ❌

Results for commit 389c3d2.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Nov 12, 2024

Test Results (Integration tests)

 2 files  + 2  11 suites  +11   25m 18s ⏱️ + 25m 18s
36 tests +36  34 ✅ +34  0 💤 ±0  2 ❌ +2 
38 runs  +38  36 ✅ +36  0 💤 ±0  2 ❌ +2 

For more details on these failures, see this check.

Results for commit 389c3d2. ± Comparison against base commit a2aa20e.

♻️ This comment has been updated with latest results.

hansieodendaal
hansieodendaal previously approved these changes Nov 13, 2024
Copy link
Contributor

@hansieodendaal hansieodendaal left a comment

Choose a reason for hiding this comment

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

utACK

Looks good, some nits only, apart from CI that should pass

base_layer/core/src/chain_storage/blockchain_database.rs Outdated Show resolved Hide resolved
base_layer/core/src/chain_storage/blockchain_database.rs Outdated Show resolved Hide resolved
review comments
@SWvheerden SWvheerden merged commit 69a5872 into tari-project:development Nov 14, 2024
16 of 17 checks passed
@SWvheerden SWvheerden deleted the sw_new_header_field branch November 14, 2024 08:21
SWvheerden added a commit that referenced this pull request Nov 14, 2024
Description
---
Add new header field, block output mmr which only tracks outputs in
current block

Motivation and Context
---
This is needed in order to validate that all outputs included in the
block is correctly captured in the pow of the header. The current
strategy is to only use the output smt, which commits to all outputs on
the blockchain. This is required for horizon sync and prune mode to
verify the blockchain as we sync.
But someone else wants to verify the block outputs, they have to have
the entire outputs set aka entire blockchain in order to verify that the
outputs are indeed locked behind pow.
This addition allows any person to take only the block and know that the
outputs contained in that block, is correctly locked behind the pow of
the header.

The output field is constructed as two merkle mountain ranges.
the primary one used in the header field is constructed as
[coinbase_1, coinbase_2, .., coinbase_x,
non_coinbase_ouputs_merkle_root]
with the non_coinbase_ouputs_merkle_root constructed as
[output_1, output_2, .., output_x]

This double mountain range approach allows you to prove the output are
in the block header, as well as create a proof for a specific output.
But separating them allows p2pool to only need to store a single hash +
list of all outputs in order to verify all coin bases are correctly
included in the header. Rather than all outputs or before this pr, the
entire block.

Breaking change
---
Need to resync database
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.

2 participants