MCPcopy Create free account
hub / github.com/BitVM/BitVM / utils_analyze_largest_segments

Function utils_analyze_largest_segments

bitvm/src/chunk/api_runtime_utils.rs:443–490  ·  view source on GitHub ↗

This is a duplicate of [`utils_execute_chunked_g16`], just to analyze worst case scenarios

(
    aux_hints: Vec<Vec<Hint>>,
    bc_hints: Vec<Script>,
    segments: &[Segment],
    disprove_scripts: &[ScriptBuf; NUM_TAPS],
)

Source from the content-addressed store, hash-verified

441
442/// This is a duplicate of [`utils_execute_chunked_g16`], just to analyze worst case scenarios
443fn utils_analyze_largest_segments(
444 aux_hints: Vec<Vec<Hint>>,
445 bc_hints: Vec<Script>,
446 segments: &[Segment],
447 disprove_scripts: &[ScriptBuf; NUM_TAPS],
448) {
449 let mut max_script_size = 0;
450 let mut max_script_size_index = 0;
451 let mut max_stack_depth = 0;
452 let mut max_stack_depth_index = 0;
453 let mut tap_script_index = 0;
454 for i in 0..aux_hints.len() {
455 if segments[i].scr_type == ScriptType::NonDeterministic {
456 continue;
457 }
458 let hint_script = script! {
459 for h in &aux_hints[i] {
460 {h.push()}
461 }
462 {bc_hints[i].clone()}
463 };
464 let total_script = hint_script
465 .clone()
466 .push_script(disprove_scripts[tap_script_index].clone());
467 let script_size = total_script.len();
468 if script_size > max_script_size {
469 max_script_size = script_size;
470 max_script_size_index = tap_script_index;
471 }
472
473 let exec_result = execute_script(total_script);
474 let stack_depth = exec_result.stats.max_nb_stack_items;
475 if stack_depth > max_stack_depth {
476 max_stack_depth = stack_depth;
477 max_stack_depth_index = tap_script_index;
478 }
479 tap_script_index += 1;
480 }
481
482 println!(
483 "Max script size with the current VK is {} at index {}",
484 max_script_size, max_script_size_index
485 );
486 println!(
487 "(This shouldn't change with the VK) Max stack depth used is {} at index {}",
488 max_stack_depth, max_stack_depth_index
489 );
490}
491
492pub(crate) fn execute_script_from_assertion(
493 segments: &[Segment],

Calls 3

execute_scriptFunction · 0.85
lenMethod · 0.80
cloneMethod · 0.80

Tested by

no test coverage detected