Skip to content

Commit

Permalink
feat(hints): add load compiled classes
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLucqs committed Sep 26, 2023
1 parent 266ec31 commit 0f44fa3
Show file tree
Hide file tree
Showing 12 changed files with 466 additions and 14 deletions.
309 changes: 309 additions & 0 deletions build/load_compiled_classes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,309 @@
{
"attributes": [],
"builtins": [
"output"
],
"compiler_version": "0.12.2",
"data": [
"0x40780017fff7fff",
"0x2",
"0x480a7ffd7fff8000",
"0x208b7fff7fff7ffe"
],
"debug_info": {
"file_contents": {},
"instruction_locations": {
"0": {
"accessible_scopes": [
"__main__",
"__main__.main"
],
"flow_tracking_data": {
"ap_tracking": {
"group": 0,
"offset": 0
},
"reference_ids": {
"__main__.main.output_ptr": 0
}
},
"hints": [],
"inst": {
"end_col": 18,
"end_line": 4,
"input_file": {
"filename": "tests/contracts/load_compiled_classes.cairo"
},
"start_col": 5,
"start_line": 4
}
},
"2": {
"accessible_scopes": [
"__main__",
"__main__.main"
],
"flow_tracking_data": {
"ap_tracking": {
"group": 0,
"offset": 2
},
"reference_ids": {
"__main__.main.compiled_class_facts": 1,
"__main__.main.n_compiled_class_facts": 2,
"__main__.main.output_ptr": 0
}
},
"hints": [
{
"location": {
"end_col": 24,
"end_line": 5,
"input_file": {
"filename": "tests/contracts/load_compiled_classes.cairo"
},
"start_col": 5,
"start_line": 5
},
"n_prefix_newlines": 0
},
{
"location": {
"end_col": 7,
"end_line": 14,
"input_file": {
"filename": "tests/contracts/load_compiled_classes.cairo"
},
"start_col": 5,
"start_line": 8
},
"n_prefix_newlines": 1
},
{
"location": {
"end_col": 27,
"end_line": 15,
"input_file": {
"filename": "tests/contracts/load_compiled_classes.cairo"
},
"start_col": 6,
"start_line": 15
},
"n_prefix_newlines": 0
}
],
"inst": {
"end_col": 28,
"end_line": 3,
"input_file": {
"filename": "tests/contracts/load_compiled_classes.cairo"
},
"parent_location": [
{
"end_col": 35,
"end_line": 16,
"input_file": {
"filename": "tests/contracts/load_compiled_classes.cairo"
},
"start_col": 25,
"start_line": 16
},
"While expanding the reference 'output_ptr' in:"
],
"start_col": 11,
"start_line": 3
}
},
"3": {
"accessible_scopes": [
"__main__",
"__main__.main"
],
"flow_tracking_data": {
"ap_tracking": {
"group": 0,
"offset": 3
},
"reference_ids": {
"__main__.main.compiled_class_facts": 1,
"__main__.main.n_compiled_class_facts": 2,
"__main__.main.output_ptr": 0
}
},
"hints": [],
"inst": {
"end_col": 37,
"end_line": 16,
"input_file": {
"filename": "tests/contracts/load_compiled_classes.cairo"
},
"start_col": 5,
"start_line": 16
}
}
}
},
"hints": {
"2": [
{
"accessible_scopes": [
"__main__",
"__main__.main"
],
"code": "mock_os_input",
"flow_tracking_data": {
"ap_tracking": {
"group": 0,
"offset": 2
},
"reference_ids": {
"__main__.main.output_ptr": 0
}
}
},
{
"accessible_scopes": [
"__main__",
"__main__.main"
],
"code": "ids.compiled_class_facts = segments.add()\nids.n_compiled_class_facts = len(os_input.compiled_classes)\nvm_enter_scope({\n 'compiled_class_facts': iter(os_input.compiled_classes.items()),\n})",
"flow_tracking_data": {
"ap_tracking": {
"group": 0,
"offset": 2
},
"reference_ids": {
"__main__.main.compiled_class_facts": 1,
"__main__.main.n_compiled_class_facts": 2,
"__main__.main.output_ptr": 0
}
}
},
{
"accessible_scopes": [
"__main__",
"__main__.main"
],
"code": "vm_exit_scope()",
"flow_tracking_data": {
"ap_tracking": {
"group": 0,
"offset": 2
},
"reference_ids": {
"__main__.main.compiled_class_facts": 1,
"__main__.main.n_compiled_class_facts": 2,
"__main__.main.output_ptr": 0
}
}
}
]
},
"identifiers": {
"__main__.main": {
"decorators": [],
"pc": 0,
"type": "function"
},
"__main__.main.Args": {
"full_name": "__main__.main.Args",
"members": {
"output_ptr": {
"cairo_type": "felt*",
"offset": 0
}
},
"size": 1,
"type": "struct"
},
"__main__.main.ImplicitArgs": {
"full_name": "__main__.main.ImplicitArgs",
"members": {},
"size": 0,
"type": "struct"
},
"__main__.main.Return": {
"cairo_type": "(output_ptr: felt*)",
"type": "type_definition"
},
"__main__.main.SIZEOF_LOCALS": {
"type": "const",
"value": 2
},
"__main__.main.compiled_class_facts": {
"cairo_type": "felt",
"full_name": "__main__.main.compiled_class_facts",
"references": [
{
"ap_tracking_data": {
"group": 0,
"offset": 2
},
"pc": 2,
"value": "[cast(fp, felt*)]"
}
],
"type": "reference"
},
"__main__.main.n_compiled_class_facts": {
"cairo_type": "felt",
"full_name": "__main__.main.n_compiled_class_facts",
"references": [
{
"ap_tracking_data": {
"group": 0,
"offset": 2
},
"pc": 2,
"value": "[cast(fp + 1, felt*)]"
}
],
"type": "reference"
},
"__main__.main.output_ptr": {
"cairo_type": "felt*",
"full_name": "__main__.main.output_ptr",
"references": [
{
"ap_tracking_data": {
"group": 0,
"offset": 0
},
"pc": 0,
"value": "[cast(fp + (-3), felt**)]"
}
],
"type": "reference"
}
},
"main_scope": "__main__",
"prime": "0x800000000000011000000000000000000000000000000000000000000000001",
"reference_manager": {
"references": [
{
"ap_tracking_data": {
"group": 0,
"offset": 0
},
"pc": 0,
"value": "[cast(fp + (-3), felt**)]"
},
{
"ap_tracking_data": {
"group": 0,
"offset": 2
},
"pc": 2,
"value": "[cast(fp, felt*)]"
},
{
"ap_tracking_data": {
"group": 0,
"offset": 2
},
"pc": 2,
"value": "[cast(fp + 1, felt*)]"
}
]
}
}
6 changes: 6 additions & 0 deletions src/hints/hints_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ os_input = StarknetOsInput.load(data=program_input)
ids.initial_carried_outputs.messages_to_l1 = segments.add_temp_segment()
ids.initial_carried_outputs.messages_to_l2 = segments.add_temp_segment()"#;

pub const LOAD_COMPILED_CLASS_FACTS: &str = r#"ids.compiled_class_facts = segments.add()
ids.n_compiled_class_facts = len(os_input.compiled_classes)
vm_enter_scope({
'compiled_class_facts': iter(os_input.compiled_classes.items()),
})"#;

pub const _VM_ENTER_SCOPE: &str = "
# This hint shouldn't be whitelisted.
vm_enter_scope(dict(
Expand Down
Loading

0 comments on commit 0f44fa3

Please sign in to comment.