diff --git a/benchmarks/CollectTypeScripts-2in-2out.json b/benchmarks/CollectTypeScripts-2in-2out.json index ffe7ad5f..e2399747 100644 --- a/benchmarks/CollectTypeScripts-2in-2out.json +++ b/benchmarks/CollectTypeScripts-2in-2out.json @@ -2,11 +2,11 @@ { "name": "CollectTypeScripts-2in-2out", "benchmark_result": { - "clock_cycle_count": 1599, - "hash_table_height": 506, - "u32_table_height": 194, - "op_stack_table_height": 1417, - "ram_table_height": 391 + "clock_cycle_count": 2393, + "hash_table_height": 740, + "u32_table_height": 294, + "op_stack_table_height": 1943, + "ram_table_height": 433 }, "case": "CommonCase" } diff --git a/benchmarks/CollectTypeScripts-4in-4out.json b/benchmarks/CollectTypeScripts-4in-4out.json index 420d1b17..42336a13 100644 --- a/benchmarks/CollectTypeScripts-4in-4out.json +++ b/benchmarks/CollectTypeScripts-4in-4out.json @@ -2,11 +2,11 @@ { "name": "CollectTypeScripts-4in-4out", "benchmark_result": { - "clock_cycle_count": 2659, - "hash_table_height": 578, - "u32_table_height": 195, - "op_stack_table_height": 2401, - "ram_table_height": 743 + "clock_cycle_count": 4125, + "hash_table_height": 812, + "u32_table_height": 295, + "op_stack_table_height": 3375, + "ram_table_height": 821 }, "case": "CommonCase" } diff --git a/profiles/CollectTypeScripts-2in-2out.profile b/profiles/CollectTypeScripts-2in-2out.profile index 83f26565..576bc62d 100644 --- a/profiles/CollectTypeScripts-2in-2out.profile +++ b/profiles/CollectTypeScripts-2in-2out.profile @@ -1,20 +1,23 @@ CollectTypeScripts-2in-2out: -| Subroutine | Processor | Op Stack | RAM | Hash | U32 | -|:-----------------------------------------------------------------------|---------------------:|---------------------:|---------------------:|---------------------:|---------------------:| -| tasmlib_list_new___digest | 32 ( 2.0%) | 25 ( 1.8%) | 3 ( 0.8%) | 0 ( 0.0%) | 32 ( 16.5%) | -| ··tasmlib_memory_dyn_malloc | 25 ( 1.6%) | 21 ( 1.5%) | 2 ( 0.5%) | 0 ( 0.0%) | 32 ( 16.5%) | -| ····tasmlib_memory_dyn_malloc_initialize | 4 ( 0.3%) | 2 ( 0.1%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | -| tasmlib_hashing_algebraic_hasher_hash_varlen | 396 ( 24.8%) | 298 ( 21.0%) | 126 ( 32.2%) | 98 ( 19.4%) | 12 ( 6.2%) | -| ··tasmlib_hashing_absorb_multiple | 368 ( 23.0%) | 268 ( 18.9%) | 126 ( 32.2%) | 84 ( 16.6%) | 12 ( 6.2%) | -| ····tasmlib_hashing_absorb_multiple_hash_all_full_chunks | 84 ( 5.3%) | 56 ( 4.0%) | 120 ( 30.7%) | 72 ( 14.2%) | 0 ( 0.0%) | -| ····tasmlib_hashing_absorb_multiple_pad_varnum_zeros | 144 ( 9.0%) | 92 ( 6.5%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | -| ····tasmlib_hashing_absorb_multiple_read_remainder | 66 ( 4.1%) | 38 ( 2.7%) | 6 ( 1.5%) | 0 ( 0.0%) | 0 ( 0.0%) | -| tasmlib_hashing_eq_digest | 32 ( 2.0%) | 18 ( 1.3%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | -| neptune_consensus_transaction_collect_type_script_hashes_from_utxo | 1010 ( 63.2%) | 950 ( 67.0%) | 244 ( 62.4%) | 0 ( 0.0%) | 90 ( 46.4%) | -| ··neptune_consensus_transaction_collect_type_script_hashes_from_coin | 866 ( 54.2%) | 830 ( 58.6%) | 232 ( 59.3%) | 0 ( 0.0%) | 60 ( 30.9%) | -| ····tasmlib_list_contains___digest | 482 ( 30.1%) | 474 ( 33.5%) | 148 ( 37.9%) | 0 ( 0.0%) | 0 ( 0.0%) | -| ······tasmlib_list_contains___digest_loop | 354 ( 22.1%) | 338 ( 23.9%) | 100 ( 25.6%) | 0 ( 0.0%) | 0 ( 0.0%) | -| ····neptune_consensus_transaction_push_digest_to_list | 80 ( 5.0%) | 76 ( 5.4%) | 28 ( 7.2%) | 0 ( 0.0%) | 0 ( 0.0%) | -| ······tasmlib_list_push___digest | 42 ( 2.6%) | 40 ( 2.8%) | 16 ( 4.1%) | 0 ( 0.0%) | 0 ( 0.0%) | -| netpune_consensus_transaction_write_all_digests | 34 ( 2.1%) | 44 ( 3.1%) | 10 ( 2.6%) | 0 ( 0.0%) | 0 ( 0.0%) | -| Total | 1599 (100.0%) | 1417 (100.0%) | 391 (100.0%) | 506 (100.0%) | 194 (100.0%) | +| Subroutine | Processor | Op Stack | RAM | Hash | U32 | +|:----------------------------------------------------------------------------------|---------------------:|---------------------:|---------------------:|---------------------:|---------------------:| +| tasmlib_structure_verify_nd_si_integrity___CollectTypeScriptsWitness | 792 ( 33.1%) | 524 ( 27.0%) | 42 ( 9.7%) | 0 ( 0.0%) | 250 ( 85.0%) | +| ··tasmlib_structure_tasmobject_verify_size_indicators_dyn_elem_sizes___Utxo | 684 ( 28.6%) | 456 ( 23.5%) | 36 ( 8.3%) | 0 ( 0.0%) | 180 ( 61.2%) | +| ····tasmlib_structure_tasmobject_verify_size_indicators_dyn_elem_sizes___Coin | 448 ( 18.7%) | 304 ( 15.6%) | 24 ( 5.5%) | 0 ( 0.0%) | 120 ( 40.8%) | +| tasmlib_list_new___digest | 32 ( 1.3%) | 25 ( 1.3%) | 3 ( 0.7%) | 0 ( 0.0%) | 32 ( 10.9%) | +| ··tasmlib_memory_dyn_malloc | 25 ( 1.0%) | 21 ( 1.1%) | 2 ( 0.5%) | 0 ( 0.0%) | 32 ( 10.9%) | +| ····tasmlib_memory_dyn_malloc_initialize | 4 ( 0.2%) | 2 ( 0.1%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | +| tasmlib_hashing_algebraic_hasher_hash_varlen | 396 ( 16.5%) | 298 ( 15.3%) | 126 ( 29.1%) | 98 ( 13.2%) | 12 ( 4.1%) | +| ··tasmlib_hashing_absorb_multiple | 368 ( 15.4%) | 268 ( 13.8%) | 126 ( 29.1%) | 84 ( 11.4%) | 12 ( 4.1%) | +| ····tasmlib_hashing_absorb_multiple_hash_all_full_chunks | 84 ( 3.5%) | 56 ( 2.9%) | 120 ( 27.7%) | 72 ( 9.7%) | 0 ( 0.0%) | +| ····tasmlib_hashing_absorb_multiple_pad_varnum_zeros | 144 ( 6.0%) | 92 ( 4.7%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | +| ····tasmlib_hashing_absorb_multiple_read_remainder | 66 ( 2.8%) | 38 ( 2.0%) | 6 ( 1.4%) | 0 ( 0.0%) | 0 ( 0.0%) | +| tasmlib_hashing_eq_digest | 32 ( 1.3%) | 18 ( 0.9%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | +| neptune_consensus_transaction_collect_type_script_hashes_from_utxo | 1010 ( 42.2%) | 950 ( 48.9%) | 244 ( 56.4%) | 0 ( 0.0%) | 0 ( 0.0%) | +| ··neptune_consensus_transaction_collect_type_script_hashes_from_coin | 866 ( 36.2%) | 830 ( 42.7%) | 232 ( 53.6%) | 0 ( 0.0%) | 0 ( 0.0%) | +| ····tasmlib_list_contains___digest | 482 ( 20.1%) | 474 ( 24.4%) | 148 ( 34.2%) | 0 ( 0.0%) | 0 ( 0.0%) | +| ······tasmlib_list_contains___digest_loop | 354 ( 14.8%) | 338 ( 17.4%) | 100 ( 23.1%) | 0 ( 0.0%) | 0 ( 0.0%) | +| ····neptune_consensus_transaction_push_digest_to_list | 80 ( 3.3%) | 76 ( 3.9%) | 28 ( 6.5%) | 0 ( 0.0%) | 0 ( 0.0%) | +| ······tasmlib_list_push___digest | 42 ( 1.8%) | 40 ( 2.1%) | 16 ( 3.7%) | 0 ( 0.0%) | 0 ( 0.0%) | +| netpune_consensus_transaction_write_all_digests | 34 ( 1.4%) | 44 ( 2.3%) | 10 ( 2.3%) | 0 ( 0.0%) | 0 ( 0.0%) | +| Total | 2393 (100.0%) | 1943 (100.0%) | 433 (100.0%) | 740 (100.0%) | 294 (100.0%) | diff --git a/profiles/CollectTypeScripts-4in-4out.profile b/profiles/CollectTypeScripts-4in-4out.profile index 17d88655..61d804b2 100644 --- a/profiles/CollectTypeScripts-4in-4out.profile +++ b/profiles/CollectTypeScripts-4in-4out.profile @@ -1,20 +1,23 @@ CollectTypeScripts-4in-4out: -| Subroutine | Processor | Op Stack | RAM | Hash | U32 | -|:-----------------------------------------------------------------------|---------------------:|---------------------:|---------------------:|---------------------:|---------------------:| -| tasmlib_list_new___digest | 32 ( 1.2%) | 25 ( 1.0%) | 3 ( 0.4%) | 0 ( 0.0%) | 32 ( 16.4%) | -| ··tasmlib_memory_dyn_malloc | 25 ( 0.9%) | 21 ( 0.9%) | 2 ( 0.3%) | 0 ( 0.0%) | 32 ( 16.4%) | -| ····tasmlib_memory_dyn_malloc_initialize | 4 ( 0.2%) | 2 ( 0.1%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | -| tasmlib_hashing_algebraic_hasher_hash_varlen | 476 ( 17.9%) | 354 ( 14.7%) | 242 ( 32.6%) | 170 ( 29.4%) | 13 ( 6.7%) | -| ··tasmlib_hashing_absorb_multiple | 448 ( 16.8%) | 324 ( 13.5%) | 242 ( 32.6%) | 156 ( 27.0%) | 13 ( 6.7%) | -| ····tasmlib_hashing_absorb_multiple_hash_all_full_chunks | 156 ( 5.9%) | 104 ( 4.3%) | 240 ( 32.3%) | 144 ( 24.9%) | 0 ( 0.0%) | -| ····tasmlib_hashing_absorb_multiple_pad_varnum_zeros | 188 ( 7.1%) | 120 ( 5.0%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | -| ····tasmlib_hashing_absorb_multiple_read_remainder | 30 ( 1.1%) | 18 ( 0.7%) | 2 ( 0.3%) | 0 ( 0.0%) | 0 ( 0.0%) | -| tasmlib_hashing_eq_digest | 32 ( 1.2%) | 18 ( 0.7%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | -| neptune_consensus_transaction_collect_type_script_hashes_from_utxo | 1990 ( 74.8%) | 1878 ( 78.2%) | 480 ( 64.6%) | 0 ( 0.0%) | 90 ( 46.2%) | -| ··neptune_consensus_transaction_collect_type_script_hashes_from_coin | 1714 ( 64.5%) | 1646 ( 68.6%) | 456 ( 61.4%) | 0 ( 0.0%) | 60 ( 30.8%) | -| ····tasmlib_list_contains___digest | 1026 ( 38.6%) | 1010 ( 42.1%) | 316 ( 42.5%) | 0 ( 0.0%) | 0 ( 0.0%) | -| ······tasmlib_list_contains___digest_loop | 770 ( 29.0%) | 738 ( 30.7%) | 220 ( 29.6%) | 0 ( 0.0%) | 0 ( 0.0%) | -| ····neptune_consensus_transaction_push_digest_to_list | 80 ( 3.0%) | 76 ( 3.2%) | 28 ( 3.8%) | 0 ( 0.0%) | 0 ( 0.0%) | -| ······tasmlib_list_push___digest | 42 ( 1.6%) | 40 ( 1.7%) | 16 ( 2.2%) | 0 ( 0.0%) | 0 ( 0.0%) | -| netpune_consensus_transaction_write_all_digests | 34 ( 1.3%) | 44 ( 1.8%) | 10 ( 1.3%) | 0 ( 0.0%) | 0 ( 0.0%) | -| Total | 2659 (100.0%) | 2401 (100.0%) | 743 (100.0%) | 578 (100.0%) | 195 (100.0%) | +| Subroutine | Processor | Op Stack | RAM | Hash | U32 | +|:----------------------------------------------------------------------------------|---------------------:|---------------------:|---------------------:|---------------------:|---------------------:| +| tasmlib_structure_verify_nd_si_integrity___CollectTypeScriptsWitness | 1464 ( 35.5%) | 972 ( 28.8%) | 78 ( 9.5%) | 0 ( 0.0%) | 250 ( 84.7%) | +| ··tasmlib_structure_tasmobject_verify_size_indicators_dyn_elem_sizes___Utxo | 1356 ( 32.9%) | 904 ( 26.8%) | 72 ( 8.8%) | 0 ( 0.0%) | 180 ( 61.0%) | +| ····tasmlib_structure_tasmobject_verify_size_indicators_dyn_elem_sizes___Coin | 896 ( 21.7%) | 608 ( 18.0%) | 48 ( 5.8%) | 0 ( 0.0%) | 120 ( 40.7%) | +| tasmlib_list_new___digest | 32 ( 0.8%) | 25 ( 0.7%) | 3 ( 0.4%) | 0 ( 0.0%) | 32 ( 10.8%) | +| ··tasmlib_memory_dyn_malloc | 25 ( 0.6%) | 21 ( 0.6%) | 2 ( 0.2%) | 0 ( 0.0%) | 32 ( 10.8%) | +| ····tasmlib_memory_dyn_malloc_initialize | 4 ( 0.1%) | 2 ( 0.1%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | +| tasmlib_hashing_algebraic_hasher_hash_varlen | 476 ( 11.5%) | 354 ( 10.5%) | 242 ( 29.5%) | 170 ( 20.9%) | 13 ( 4.4%) | +| ··tasmlib_hashing_absorb_multiple | 448 ( 10.9%) | 324 ( 9.6%) | 242 ( 29.5%) | 156 ( 19.2%) | 13 ( 4.4%) | +| ····tasmlib_hashing_absorb_multiple_hash_all_full_chunks | 156 ( 3.8%) | 104 ( 3.1%) | 240 ( 29.2%) | 144 ( 17.7%) | 0 ( 0.0%) | +| ····tasmlib_hashing_absorb_multiple_pad_varnum_zeros | 188 ( 4.6%) | 120 ( 3.6%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | +| ····tasmlib_hashing_absorb_multiple_read_remainder | 30 ( 0.7%) | 18 ( 0.5%) | 2 ( 0.2%) | 0 ( 0.0%) | 0 ( 0.0%) | +| tasmlib_hashing_eq_digest | 32 ( 0.8%) | 18 ( 0.5%) | 0 ( 0.0%) | 0 ( 0.0%) | 0 ( 0.0%) | +| neptune_consensus_transaction_collect_type_script_hashes_from_utxo | 1990 ( 48.2%) | 1878 ( 55.6%) | 480 ( 58.5%) | 0 ( 0.0%) | 0 ( 0.0%) | +| ··neptune_consensus_transaction_collect_type_script_hashes_from_coin | 1714 ( 41.6%) | 1646 ( 48.8%) | 456 ( 55.5%) | 0 ( 0.0%) | 0 ( 0.0%) | +| ····tasmlib_list_contains___digest | 1026 ( 24.9%) | 1010 ( 29.9%) | 316 ( 38.5%) | 0 ( 0.0%) | 0 ( 0.0%) | +| ······tasmlib_list_contains___digest_loop | 770 ( 18.7%) | 738 ( 21.9%) | 220 ( 26.8%) | 0 ( 0.0%) | 0 ( 0.0%) | +| ····neptune_consensus_transaction_push_digest_to_list | 80 ( 1.9%) | 76 ( 2.3%) | 28 ( 3.4%) | 0 ( 0.0%) | 0 ( 0.0%) | +| ······tasmlib_list_push___digest | 42 ( 1.0%) | 40 ( 1.2%) | 16 ( 1.9%) | 0 ( 0.0%) | 0 ( 0.0%) | +| netpune_consensus_transaction_write_all_digests | 34 ( 0.8%) | 44 ( 1.3%) | 10 ( 1.2%) | 0 ( 0.0%) | 0 ( 0.0%) | +| Total | 4125 (100.0%) | 3375 (100.0%) | 821 (100.0%) | 812 (100.0%) | 295 (100.0%) | diff --git a/src/models/blockchain/transaction/validity/collect_type_scripts.rs b/src/models/blockchain/transaction/validity/collect_type_scripts.rs index c1c5c784..013279c5 100644 --- a/src/models/blockchain/transaction/validity/collect_type_scripts.rs +++ b/src/models/blockchain/transaction/validity/collect_type_scripts.rs @@ -16,6 +16,7 @@ use tasm_lib::list::push::Push; use tasm_lib::memory::encode_to_memory; use tasm_lib::memory::FIRST_NON_DETERMINISTICALLY_INITIALIZED_MEMORY_ADDRESS; use tasm_lib::structure::tasm_object::TasmObject; +use tasm_lib::structure::verify_nd_si_integrity::VerifyNdSiIntegrity; use tasm_lib::triton_vm::prelude::*; use tasm_lib::twenty_first::util_types::algebraic_hasher::AlgebraicHasher; use tasm_lib::Digest; @@ -174,6 +175,7 @@ impl ConsensusProgram for CollectTypeScripts { })); let hash_varlen = library.import(Box::new(HashVarlen)); let eq_digest = library.import(Box::new(EqDigest)); + let collect_type_script_hashes_from_utxos = "neptune_consensus_transaction_collect_type_script_hashes_from_utxo".to_string(); let collect_type_script_hashes_from_coins = @@ -211,11 +213,22 @@ impl ConsensusProgram for CollectTypeScripts { pop 3 // _ *ctsw *type_script_hashes }; + + let audit_preloaded_data = library.import(Box::new(VerifyNdSiIntegrity::< + CollectTypeScriptsWitness, + >::default())); let payload = triton_asm! { push {FIRST_NON_DETERMINISTICALLY_INITIALIZED_MEMORY_ADDRESS} // _ *ctsw + dup 0 + call {audit_preloaded_data} + // _ *ctsw witness_size + + pop 1 + // _ *ctsw + call {new_list} // _ *ctsw *type_script_hashes