Skip to content

Move NullifierTree and BlockChain from node#1304

Merged
PhilippGackstatter merged 15 commits intonextfrom
pgackst-nullifier-tree-blockchain
May 5, 2025
Merged

Move NullifierTree and BlockChain from node#1304
PhilippGackstatter merged 15 commits intonextfrom
pgackst-nullifier-tree-blockchain

Conversation

@PhilippGackstatter
Copy link
Copy Markdown
Contributor

@PhilippGackstatter PhilippGackstatter commented Apr 25, 2025

Moves the NullifierTree and BlockChain from miden-node to miden-base.

Notable changes/additions:

  • NullifierTree ensures that every nullifier is only spent once.
  • BlockChain does not assume that the genesis block is always present. This assumption from miden-node is not nicely compatible with MockChain and this seems like a miden-node level guarantee instead of a protocol-level guarantee. The only impact is that BlockChain::chain_tip returns Option<BlockNumber> rather than BlockNumber. This is easily fixable in miden-node by moving the assumption (the expect) to InnerState::latest_block_num.
  • Using more appropriate types in BlockChain. I.e. using BlockNumber instead of usize as the "forest" for the chain, which is named "state block" as a concept. "Forest" does not really make sense in the block chain context and I find state block somewhat clearer (see the type level docs for an explanation).
  • More documentation for both of these types.
  • Add basic unit tests for nullifier tree.

Builds on top of #1301 to be able to address all the changes in miden-node in one PR.

closes #1302

Note that I will address #1173 in a separate PR.

Base automatically changed from pgackst-account-tree-improv to next April 26, 2025 06:22
Copy link
Copy Markdown
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you! I left some comments inline - but all of them are pretty minor.

Comment thread crates/miden-objects/src/block/block_chain.rs
Comment thread crates/miden-objects/src/block/block_chain.rs Outdated
Comment thread crates/miden-objects/src/block/block_chain.rs
Comment thread crates/miden-objects/src/block/nullifier_tree.rs Outdated
Comment thread crates/miden-objects/src/block/nullifier_tree.rs
/// # Errors
///
/// Returns an error if:
/// - the nullifier was already spent.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we clarify here that this only applies if two nullifiers were spent in different blocks?

Comment thread crates/miden-objects/src/block/nullifier_tree.rs
@PhilippGackstatter PhilippGackstatter merged commit 621fe23 into next May 5, 2025
16 checks passed
@PhilippGackstatter PhilippGackstatter deleted the pgackst-nullifier-tree-blockchain branch May 5, 2025 13:33
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