From a021ac8cd3ac5b663dfa6ff5b165e62179e4a275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Walter?= Date: Sun, 1 Dec 2024 15:59:53 +0100 Subject: [PATCH] Remove unused hints (#181) Just some unused and so misleading python hints --- cairo/src/precompiles/precompiles.cairo | 18 ++++----- cairo/tests/utils/hints.py | 53 +++++++++++-------------- 2 files changed, 32 insertions(+), 39 deletions(-) diff --git a/cairo/src/precompiles/precompiles.cairo b/cairo/src/precompiles/precompiles.cairo index 051d1f87..26c48005 100644 --- a/cairo/src/precompiles/precompiles.cairo +++ b/cairo/src/precompiles/precompiles.cairo @@ -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; diff --git a/cairo/tests/utils/hints.py b/cairo/tests/utils/hints.py index 4361873b..92b7dd53 100644 --- a/cairo/tests/utils/hints.py +++ b/cairo/tests/utils/hints.py @@ -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""" @@ -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, }