Skip to content

Commit

Permalink
Remove unused hints (#181)
Browse files Browse the repository at this point in the history
Just some unused and so misleading python hints
  • Loading branch information
ClementWalter authored Dec 1, 2024
1 parent 14e3cf2 commit a021ac8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 39 deletions.
18 changes: 9 additions & 9 deletions cairo/src/precompiles/precompiles.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -98,23 +98,23 @@ namespace Precompiles {
jmp rel offset;
call unknown_precompile; // 0x0
ret;
call PrecompileEcRecover.run; // 0x1
call PrecompileEcRecover.run; // 0x1 EC_RECOVER
ret;
call not_implemented_precompile; // 0x2
call not_implemented_precompile; // 0x2 SHA2-256
ret;
call PrecompileRIPEMD160.run; // 0x3
call PrecompileRIPEMD160.run; // 0x3 RIPEMD-160
ret;
call PrecompileDataCopy.run; // 0x4
call PrecompileDataCopy.run; // 0x4 DATA_COPY
ret;
call not_implemented_precompile; // 0x5
call not_implemented_precompile; // 0x5 MODEXP
ret;
call not_implemented_precompile; // 0x6
call not_implemented_precompile; // 0x6 EC_ADD
ret;
call not_implemented_precompile; // 0x7
call not_implemented_precompile; // 0x7 EC_MUL
ret;
call not_implemented_precompile; // 0x8
call not_implemented_precompile; // 0x8 EC_PAIRING
ret;
call PrecompileBlake2f.run; // 0x9
call PrecompileBlake2f.run; // 0x9 BLAKE2-F
ret;
call not_implemented_precompile; // 0x0a: POINT_EVALUATION_PRECOMPILE
ret;
Expand Down
53 changes: 23 additions & 30 deletions cairo/tests/utils/hints.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,33 @@ def gen_arg_pydantic(
__dict_manager = DictManager()
"""

block = f"""
{dict_manager}
from tests.utils.hints import gen_arg_pydantic
dict_copy = """
from starkware.cairo.common.dict import DictTracker
ids.block = gen_arg_pydantic(__dict_manager, segments, program_input["block"])
data = __dict_manager.trackers[ids.dict_start.address_.segment_index].data.copy()
__dict_manager.trackers[ids.new_start.address_.segment_index] = DictTracker(
data=data,
current_ptr=ids.new_end.address_,
)
"""

block_hashes = """
import random
dict_squash = """
from starkware.cairo.common.dict import DictTracker
ids.block_hashes = segments.gen_arg([random.randint(0, 2**128 - 1) for _ in range(256 * 2)])
data = __dict_manager.get_dict(ids.dict_accesses_end).copy()
base = segments.add()
assert base.segment_index not in __dict_manager.trackers
__dict_manager.trackers[base.segment_index] = DictTracker(
data=data, current_ptr=base
)
memory[ap] = base
"""

account = f"""
block = f"""
{dict_manager}
from tests.utils.hints import gen_arg_pydantic
ids.account = gen_arg_pydantic(__dict_manager, segments, program_input["account"])
ids.block = gen_arg_pydantic(__dict_manager, segments, program_input["block"])
"""

state = f"""
Expand All @@ -118,36 +127,20 @@ def gen_arg_pydantic(
ids.chain_id = {CHAIN_ID}
"""

dict_copy = """
from starkware.cairo.common.dict import DictTracker
block_hashes = """
import random
data = __dict_manager.trackers[ids.dict_start.address_.segment_index].data.copy()
__dict_manager.trackers[ids.new_start.address_.segment_index] = DictTracker(
data=data,
current_ptr=ids.new_end.address_,
)
ids.block_hashes = segments.gen_arg([random.randint(0, 2**128 - 1) for _ in range(256 * 2)])
"""

dict_squash = """
from starkware.cairo.common.dict import DictTracker
data = __dict_manager.get_dict(ids.dict_accesses_end).copy()
base = segments.add()
assert base.segment_index not in __dict_manager.trackers
__dict_manager.trackers[base.segment_index] = DictTracker(
data=data, current_ptr=base
)
memory[ap] = base
"""

hints = {
"dict_manager": dict_manager,
"dict_copy": dict_copy,
"dict_squash": dict_squash,
"block": block,
"account": account,
"state": state,
"chain_id": chain_id,
"dict_copy": dict_copy,
"dict_squash": dict_squash,
"block_hashes": block_hashes,
}

Expand Down

0 comments on commit a021ac8

Please sign in to comment.