From 97a7d0cb28359cccd214c8a63471818162293ae3 Mon Sep 17 00:00:00 2001 From: Kriptikz Date: Wed, 24 Jul 2024 22:38:29 -0500 Subject: [PATCH] update comments --- program/src/declare_proof.rs | 13 +++++++++++-- program/src/mine.rs | 9 +-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/program/src/declare_proof.rs b/program/src/declare_proof.rs index b99fb23..9f4e458 100644 --- a/program/src/declare_proof.rs +++ b/program/src/declare_proof.rs @@ -11,8 +11,8 @@ use solana_program::{ /// DeclareProof is used by other instructions in the same transaction. /// - Other instructions will use transaction introspection to ensure they /// only process the declared proof. -/// - Other instructions that need to get the declared proof for validation -/// will only look at the first and second instructions in the transaction +/// - Other instructions will use find_and_parse_declared_proof with the +/// introspection data /// /// Safety requirements: /// - No safety requirements are required in this instruction to keep cu's as @@ -33,6 +33,15 @@ pub fn process_declare_proof<'a, 'info>( Ok(()) } +/// Require that only the declared proof can be processed in this transaction. +/// +/// The intent here is to disincentivize sybil. As long as a user can fit multiple hashes in a single +/// transaction, there is a financial incentive to sybil multiple keypairs and pack as many hashes +/// as possible into each transaction to minimize fee / hash. +/// +/// If each transaction is limited to one hash only, then a user will minimize their fee / hash +/// by allocating all their hashpower to finding the single most difficult hash they can. +/// /// Errors if: /// - Fails to find and parse the declared proof pubkey in the second instruction /// of the transaction diff --git a/program/src/mine.rs b/program/src/mine.rs index b8a12ce..6f70ea8 100644 --- a/program/src/mine.rs +++ b/program/src/mine.rs @@ -38,6 +38,7 @@ use crate::{find_and_parse_declared_proof, utils::AccountDeserialize}; /// - Can only succeed if mining is not paused. /// - Can only succeed if the last reset was less than 60 seconds ago. /// - Can only succeed if the provided hash satisfies the minimum difficulty requirement. +/// - Can only succeed if the miners proof pubkey matches the declared proof pubkey. /// - The provided proof account must be associated with the signer. /// - The provided bus, config, noise, stake, and slot hash sysvar must be valid. pub fn process_mine<'a, 'info>( @@ -61,14 +62,6 @@ pub fn process_mine<'a, 'info>( load_sysvar(instructions_sysvar, sysvar::instructions::id())?; load_sysvar(slot_hashes_sysvar, sysvar::slot_hashes::id())?; - /// Require that only the declared proof can be processed in this transaction. - /// - /// The intent here is to disincentivize sybil. As long as a user can fit multiple hashes in a single - /// transaction, there is a financial incentive to sybil multiple keypairs and pack as many hashes - /// as possible into each transaction to minimize fee / hash. - /// - /// If each transaction is limited to one hash only, then a user will minimize their fee / hash - /// by allocating all their hashpower to finding the single most difficult hash they can. if let Ok(pubkey) = find_and_parse_declared_proof(&instructions_sysvar.data.borrow()) { if !pubkey.eq(proof_info.key) { return Err(OreError::DeclaredProofMissmatch.into());