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

Function utils_execute_chunked_g16

bitvm/src/chunk/api_runtime_utils.rs:389–440  ·  view source on GitHub ↗
(
    aux_hints: Vec<Vec<Hint>>,
    bc_hints: Vec<Script>,
    segments: &[Segment],
    disprove_scripts: &[ScriptBuf; NUM_TAPS],
)

Source from the content-addressed store, hash-verified

387}
388
389fn utils_execute_chunked_g16(
390 aux_hints: Vec<Vec<Hint>>,
391 bc_hints: Vec<Script>,
392 segments: &[Segment],
393 disprove_scripts: &[ScriptBuf; NUM_TAPS],
394) -> Option<(usize, Script)> {
395 let mut tap_script_index = 0;
396 for i in 0..aux_hints.len() {
397 if segments[i].scr_type == ScriptType::NonDeterministic {
398 continue;
399 }
400 let hint_script = script! {
401 for h in &aux_hints[i] {
402 {h.push()}
403 }
404 {bc_hints[i].clone()}
405 };
406 let total_script = hint_script
407 .clone()
408 .push_script(disprove_scripts[tap_script_index].clone());
409 let exec_result = execute_script(total_script);
410 if exec_result.final_stack.len() > 1 {
411 for i in 0..exec_result.final_stack.len() {
412 println!("{i:} {:?}", exec_result.final_stack.get(i));
413 }
414 }
415 if !exec_result.success {
416 if exec_result.final_stack.len() != 1 {
417 println!("final {:?}", i);
418 println!("final {:?}", segments[i].scr_type);
419 panic!();
420 }
421 if exec_result.remaining_script != "OP_PUSHNUM_1" && exec_result.remaining_script != ""
422 {
423 println!(
424 "Script terminated early {:?} {:?}",
425 exec_result.remaining_script, segments[i].scr_type
426 );
427 panic!();
428 }
429 } else {
430 println!(
431 "disprove script {}: tapindex {}, {:?}",
432 i, tap_script_index, segments[i].scr_type
433 );
434 let disprove_hint = (tap_script_index, hint_script);
435 return Some(disprove_hint);
436 }
437 tap_script_index += 1;
438 }
439 None
440}
441
442/// This is a duplicate of [`utils_execute_chunked_g16`], just to analyze worst case scenarios
443fn utils_analyze_largest_segments(

Callers 2

Calls 3

execute_scriptFunction · 0.85
lenMethod · 0.80
cloneMethod · 0.80

Tested by

no test coverage detected