Skip to content

Conversation

@freshair18
Copy link
Collaborator

Provides consensus layer support for cryptographic receipts based on KIP15.

Additionally:

  • Adds a bfs iterator for the blockdag, currently incorporated only in new functions included in this PR, but potentially should be incorporated to the existing functions using bfs traversal.
  • Provides consensus infra for "primitive" Pochm, proof of publication, and "legacy" transaction receipts, by storing selected chain and its peripharies, as briefly described in https://github.com/kaspanet/kips/blob/master/kip-0006.md.

Supersedes #609, addresses #709.

1) create a witness for inclusion of a leaf in a merkle tree
2) verify the inclusion given a leaf and said witness
improved tests
removed legacy code
improved general structure of code
simplified test code
added ignore for the perfomance dependant test test_writer_reentrance per instructions of Aspect and Michael
Fixed error:changed daa score to blue score for posterity blocks
minor refactoring
get_pre_posterity
get_post_posterity
get posterity_by_bscore.
Changed/improved implementation of representative_log_parents
More error logic
bug fix regarding accepted txs
refactoring a few for loops
Copy link
Collaborator

@coderofstuff coderofstuff left a comment

Choose a reason for hiding this comment

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

Still need to wrap my head around the KIP and PR. Initial cosmetic comments first :)

use crate::header::Header;
use kaspa_hashes::Hash;
#[derive(Clone)]
pub struct Pochm {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please rename this struct to ProofOfChainMembership. I know what pochm means because I'm familiar with the KIP, but an arbitrary reader of this struct will not have that context immediately.

Also, please add comments to the struct or parts of the struct explaining what this it's intended. Take a different struct for example, it has this:

pub struct PruningPointReply {
    /// The most recent pruning sample from POV of the queried block (with distance up to ~F)
    pub pruning_sample: Hash,

    /// The pruning point of the queried block. I.e., the most recent pruning sample with
    /// depth P (except for shortly after the fork where the new P' is gradually reached)
    pub pruning_point: Hash,
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

see now

) -> ConsensusResult<ProofOfPublication> {
unimplemented!()
}
fn generate_pochm(&self, block: Hash) -> ConsensusResult<Pochm> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use generate_proof_of_chain_membership

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

addressed

fn verify_tx_receipt(&self, receipt: &TxReceipt) -> bool {
unimplemented!()
}
fn verify_proof_of_pub(&self, proof_of_pub: &ProofOfPublication) -> bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use verify_proof_of_publication

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

addressed

fn verify_proof_of_pub(&self, proof_of_pub: &ProofOfPublication) -> bool {
unimplemented!()
}
fn verify_pochm(&self, chain_purporter: Hash, pochm: &Pochm) -> bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use verify_proof_of_chain_membership

.map(|hash| (hash, self.headers_store.get_compact_header_data(hash).unwrap()))
.collect_vec()
}
/* this logic may not be the most efficient and reliable as of now */
Copy link
Collaborator

Choose a reason for hiding this comment

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

Inside this function are several large comment blocks. Please update this into a function comment explaining what this function does - maybe move parts of those large comments below to this function comment.

Take a look at this function elsewhere for an example:

pub fn select_transactions(&mut self) -> Vec<Transaction>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

see now

use kaspa_hashes::Hash;
#[derive(Clone)]
pub struct Pochm {
pub hdr_map: HashMap<Hash, Arc<Header>>,
Copy link
Collaborator

@IzioDev IzioDev Sep 2, 2025

Choose a reason for hiding this comment

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

At a first lecture, I thought hdr was reference to some specific object I wasn't aware of, would it be possible to rename it header instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

addressed

@freshair18 freshair18 mentioned this pull request Sep 7, 2025
@freshair18
Copy link
Collaborator Author

I removed proof of publication and proof of chain memberships as it became apparent to me these features' implementation is unsatisfactory, and the correct implementation not immediate. Coupled with the fact that it greatly complicated tests, and that the usecase was always dubious I decided to cut it off in the hopes that it will ease reviewing.

An implementation of proof of publication as it previously was can be found at https://github.com/freshair18/rusty-kaspa/tree/crypt_receipts_with_pop.

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.

3 participants