Skip to content

Commit

Permalink
builtin cost ptr in bytecode
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed Jul 14, 2024
1 parent 7c7656e commit 1c12eb6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
15 changes: 11 additions & 4 deletions cairo0-bootloader/bootloader/contract/contract_bootloader.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ from starkware.cairo.common.cairo_builtins import (
)
from starkware.cairo.common.registers import get_fp_and_pc
from contract_class.compiled_class import CompiledClass, compiled_class_hash
from starkware.cairo.common.alloc import alloc

func main{
output_ptr: felt*,
Expand Down Expand Up @@ -39,10 +40,6 @@ func main{
visited_pcs=None,
)
# Append necessary footer to the bytecode of the contract
compiled_class.bytecode.append(0x208b7fff7fff7ffe)
compiled_class.bytecode_segment_lengths[-1] += 1
bytecode_segment_structure_with_footer = create_bytecode_segment_structure(
bytecode=compiled_class.bytecode,
bytecode_segment_lengths=compiled_class.bytecode_segment_lengths,
Expand All @@ -58,7 +55,17 @@ func main{
ids.compiled_class = segments.gen_arg(cairo_contract)
%}

let (builtin_costs: felt*) = alloc();
assert builtin_costs[0] = 0;
assert builtin_costs[1] = 0;
assert builtin_costs[2] = 0;
assert builtin_costs[3] = 0;
assert builtin_costs[4] = 0;

assert compiled_class.bytecode_ptr[compiled_class.bytecode_length] = 0x208b7fff7fff7ffe;
assert compiled_class.bytecode_ptr[compiled_class.bytecode_length + 1] = cast(
builtin_costs, felt
);

%{ bytecode_segment_structure = bytecode_segment_structure_no_footer %}

Expand Down
2 changes: 1 addition & 1 deletion cairo0-bootloader/contract_class/compiled_class.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func compiled_class_hash{range_check_ptr, poseidon_ptr: PoseidonBuiltin*}(
// Hash bytecode.
let bytecode_hash = bytecode_hash_node(
data_ptr=compiled_class.bytecode_ptr, data_length=compiled_class.bytecode_length - 1
data_ptr=compiled_class.bytecode_ptr, data_length=compiled_class.bytecode_length
);
hash_update_single(item=bytecode_hash);
}
Expand Down

0 comments on commit 1c12eb6

Please sign in to comment.