Skip to content

Commit 5b6b27b

Browse files
Update README of hint processor section (#2202)
* Update README of hint processor section * Remove private func * Add helper function * Update docs/hint_processor/builtin_hint_processor/README.md Co-authored-by: Gabriel Bosio <38794644+gabrielbosio@users.noreply.github.com> --------- Co-authored-by: Gabriel Bosio <38794644+gabrielbosio@users.noreply.github.com>
1 parent f6339d8 commit 5b6b27b

File tree

1 file changed

+12
-9
lines changed
  • docs/hint_processor/builtin_hint_processor

1 file changed

+12
-9
lines changed

docs/hint_processor/builtin_hint_processor/README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ cairo_run(
8282
.expect("Couldn't run program");
8383
```
8484
#### Final notes:
85-
The example used in this guide can be found [here](../../../custom_hint_example/).
85+
The example used in this guide can be found [here](../../../examples/custom_hint/).
8686
The example can be ran using `make example`
8787

8888
### How to code your hint implementation:
@@ -99,12 +99,16 @@ In order to code your custom hints you need to take into account the accessible
9999
These last two structures are used by helper functions to manage variables from the Cairo scope, and can be overlooked when coding your custom hint implementations. Just note that will have to be passed as arguments to some helper functions.
100100

101101
### Helper functions
102-
There are many helper functions available [here](../../../src/hint_processor/builtin_hint_processor/hint_utils.rs), that will allow you to easily manage cairo variables:
102+
There are many helper functions available [here](../../../vm/src/hint_processor/builtin_hint_processor/hint_utils.rs), that will allow you to easily manage cairo variables:
103103

104104
* **get_integer_from_var_name**: gets the value from memory of a integer variable.
105105
* **get_ptr_from_var_name**: gets the value from memory of a pointer variable.
106-
* **compute_addr_from_var_name**: gets the address of a given variable.
107-
* **insert_value_from_var_name**: assigns a value to a Cairo variable.
106+
* **get_address_from_var_name**: gets the address of a given variable as a MaybeRelocatable.
107+
* **get_relocatable_from_var_name**: gets the address of a given variable as a Relocatable.
108+
* **get_maybe_relocatable_from_var_name**: gets the value from memory of a variable as a MaybeRelocatable.
109+
* **get_constant_from_var_name**: gets the value of a constant.
110+
* **get_reference_from_var_name**: gets the value of a var name as a HintReference.
111+
* **insert_value_from_var_name**: assigns a value to a Cairo variable.
108112
* **insert_value_into_ap**: inserts a value to the memory cell pointed to by the ap register.
109113

110114
These methods take the name of the ids variable along with vm, ids_data and ap_tracking.
@@ -113,13 +117,12 @@ Note: When handling pointer type variables, computing the address and using it t
113117

114118
Note: Cairo's memory is write-once, read-only, so when using `insert_value_from_var_name` its important to first make sure that the variable doesnt contain any value (for example, it may be defined as local but never written) to avoid inconsistent memory errors.
115119

116-
There are also some helpers that dont depend on the hint processor used that can also be used to simplify coding hints [here](../../../src/hint_processor/hint_processor_utils.rs):
120+
There are also some helpers that dont depend on the hint processor used that can also be used to simplify coding hints [here](../../../vm/src/hint_processor/hint_processor_utils.rs):
117121

118-
* get_range_check_builtin
119-
* bigint_to_usize
120-
* bigint_to_u32
122+
* felt_to_usize
123+
* felt_to_u32
121124

122-
You can also find plenty of example implementations in the [builtin hint processor folder](../../../src/hint_processor/builtin_hint_processor).
125+
You can also find plenty of example implementations in the [builtin hint processor folder](../../../vm/src/hint_processor/builtin_hint_processor).
123126

124127
### Error Handling
125128
This API uses VirtualMachineError as error return type for hint functions, while its not possible to add error types to VirtualMachineError, you can use VirtualMachineError::CustomHint which receives a string and prints an error message with the format: "Hint Error: [your message]".

0 commit comments

Comments
 (0)