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

Revisit Block Structure #101

Merged
merged 29 commits into from
Feb 2, 2024
Merged

Revisit Block Structure #101

merged 29 commits into from
Feb 2, 2024

Conversation

aszepieniec
Copy link
Contributor

@aszepieniec aszepieniec commented Jan 30, 2024

This PR:

  • introduces a skeleton for verifying blocks using TritonVM
  • modifies the Block data structure
  • redefines the block's hash in MAST terms
  • refactors public scripts into public announcements
  • prefers the block hash over its header as index by which to fetch blocks from the database

Note that (some of) these changes are not backwards-compatible, meaning that this essentially corresponds to a new alphanet release.

@aszepieniec
Copy link
Contributor Author

Note that the unsuccessful test runs (in both cases) boil down to a single failing test: the flaky one from #100.

aszepieniec and others added 23 commits January 31, 2024 10:28
Specifically: replace public scripts (hashes) and inputs with public
announcements.

Closes #40.
So: populate proof with empty vec.
 - Add debug print statements in test.
 - In some mutator set method, turn `unwrap` into `unwrap_or_else`
   with `panic!` in order to display debug info.
Problem was using `block_digest` instead of `tip_digest` to lookup the
tip header.

Co-authored-by: Thorkil Værge <thor@neptune.cash>
The block header does not need to commit to the block body. It is a
potential source of discrepancy and at best surplus weight.

Note that the block header does not commit to the body. However, the
proof-of-work puzzle is defined in terms of the *block's hash*,
which is `H(H(header)||H(body))`, so the *pair* is committed to when
the miner expends energy.
The mutator set is already present in the block. Keeping its hash in
the header constitutes duplicate representation of data and is a
source of potential discrepancy. Moreover, it was not used anywhere,
as far as I can tell.
Copy link
Member

@Sword-Smith Sword-Smith left a comment

Choose a reason for hiding this comment

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

Excellent breakdown of the validity logic. I look forward to working with these traits SecretWitness and ValidationLogic. Also great that the block hash is not stored or transferred but always calculated.

I think we can avoid the manual implementation of discriminant. If the variants do not carry data, you can just cast the values to usize. I would keep the HasDiscriminant trait though as it's nice to have a uniform way of getting the discriminants for these field selectors.

For enums without associated data (as used here), casting to usize
gives the discriminant. This commit switches to that as it is less
prone to error, but keeps the `.discriminant()` interface.
@aszepieniec aszepieniec merged commit 2fa96ae into master Feb 2, 2024
1 of 3 checks passed
@aszepieniec aszepieniec deleted the alphanet-v6 branch February 2, 2024 10:29
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