diff --git a/benchmarks/tasm_neptune_transaction_removal_records_integrity.json b/benchmarks/tasm_neptune_transaction_removal_records_integrity.json index fa9fe7729..f6af9b30e 100644 --- a/benchmarks/tasm_neptune_transaction_removal_records_integrity.json +++ b/benchmarks/tasm_neptune_transaction_removal_records_integrity.json @@ -3,7 +3,7 @@ "name": "tasm_neptune_transaction_removal_records_integrity", "clock_cycle_count": 29649, "hash_table_height": 5633, - "u32_table_height": 13245, + "u32_table_height": 13250, "case": "CommonCase" } ] \ No newline at end of file diff --git a/src/models/blockchain/block/validity.rs b/src/models/blockchain/block/validity.rs index 083ea6b62..691f1617f 100644 --- a/src/models/blockchain/block/validity.rs +++ b/src/models/blockchain/block/validity.rs @@ -1,26 +1,34 @@ use get_size::GetSize; use serde::{Deserialize, Serialize}; -use tasm_lib::twenty_first; +use tasm_lib::{ + triton_vm::program::{NonDeterminism, Program}, + twenty_first::{self, shared_math::b_field_element::BFieldElement}, +}; use twenty_first::shared_math::bfield_codec::BFieldCodec; +use crate::models::consensus::SecretWitness; + use self::{ coinbase_is_valid::CoinbaseIsValid, correct_control_parameter_update::CorrectControlParameterUpdate, correct_mmr_update::CorrectMmrUpdate, correct_mutator_set_update::CorrectMutatorSetUpdate, - predecessor_is_valid::PredecessorIsValid, transaction_is_valid::TransactionIsValid, + mmr_membership::MmrMembership, predecessor_is_valid::PredecessorIsValid, + transaction_is_valid::TransactionIsValid, }; +use super::Block; + pub mod coinbase_is_valid; pub mod correct_control_parameter_update; pub mod correct_mmr_update; pub mod correct_mutator_set_update; +pub mod mmr_membership; pub mod predecessor_is_valid; pub mod transaction_is_valid; -/// The validity of a block, when it is not the genesis block and when it does not -/// come with proofs, decomposes into these subclaims. +/// The validity of a block, in the principal case, decomposes into these subclaims. #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, GetSize, BFieldCodec)] -pub struct BlockValidationLogic { +pub struct PrincipalBlockValidationLogic { // program: recursive-verify-or-is-genesis, input: block kernel, output: [] pub predecessor_is_valid: PredecessorIsValid, @@ -39,3 +47,28 @@ pub struct BlockValidationLogic { // program: update-control-parameters, input: block kernel, output: [] pub correct_control_parameter_update: CorrectControlParameterUpdate, } + +/// Alternatively, the validity of a block follows from that of a successor. This pathway +/// two subclaims, both of which are relative to the successor block. +/// 1. the current block lives in the block mmr of the successor block +/// 2. the successor block is valid +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, GetSize, BFieldCodec)] +pub struct AlternativeBlockValidationLogic { + pub mmr_membership: MmrMembership, + pub successor_is_valid: PrincipalBlockValidationLogic, +} + +#[derive(Debug, Clone, BFieldCodec, GetSize, PartialEq, Eq, Serialize, Deserialize)] +pub struct PrincipalBlockValidationWitness { + pub successor: Block, // includes proof +} + +impl SecretWitness for PrincipalBlockValidationWitness { + fn nondeterminism(&self) -> NonDeterminism { + todo!() + } + + fn subprogram(&self) -> Program { + todo!() + } +} diff --git a/src/models/blockchain/block/validity/mmr_membership.rs b/src/models/blockchain/block/validity/mmr_membership.rs new file mode 100644 index 000000000..160e68713 --- /dev/null +++ b/src/models/blockchain/block/validity/mmr_membership.rs @@ -0,0 +1,31 @@ +use crate::models::blockchain::block::BFieldCodec; +use crate::models::blockchain::block::Deserialize; +use crate::models::blockchain::block::GetSize; +use crate::models::blockchain::block::Serialize; +use crate::models::blockchain::shared::Hash; +use crate::models::consensus::SecretWitness; +use crate::models::consensus::SupportedClaim; +use crate::triton_vm::program::Program; +use tasm_lib::triton_vm::program::NonDeterminism; +use tasm_lib::twenty_first::shared_math::b_field_element::BFieldElement; +use tasm_lib::twenty_first::util_types::mmr::mmr_membership_proof::MmrMembershipProof; + +#[derive(Debug, Clone, BFieldCodec, GetSize, PartialEq, Eq, Serialize, Deserialize)] +pub struct MmrMembershipWitness { + pub membership_proof: MmrMembershipProof, +} + +impl SecretWitness for MmrMembershipWitness { + fn nondeterminism(&self) -> NonDeterminism { + todo!() + } + + fn subprogram(&self) -> Program { + todo!() + } +} + +#[derive(Debug, Clone, BFieldCodec, GetSize, PartialEq, Eq, Serialize, Deserialize)] +pub struct MmrMembership { + supported_claim: SupportedClaim, +}