From f260522fe8bcaed187dce2310bb34c0838286748 Mon Sep 17 00:00:00 2001 From: Lior Goldberg Date: Mon, 20 Mar 2023 21:59:21 +0200 Subject: [PATCH] Cairo v0.11.0. --- scripts/requirements-gen.txt | 2 +- src/starkware/cairo/lang/VERSION | 2 +- src/starkware/cairo/lang/setup.py | 7 ++++ src/starkware/cairo/sharp/config.json | 2 +- .../starknet/business_logic/CMakeLists.txt | 1 - .../business_logic/execution/CMakeLists.txt | 2 - .../execution/execute_entry_point.py | 2 +- .../execution/execute_entry_point_base.py | 2 +- .../business_logic/execution/objects.py | 28 ++++++++++++- .../business_logic/fact_state/state.py | 27 ------------ .../business_logic/transaction/CMakeLists.txt | 2 - .../business_logic/transaction/fee.py | 2 +- .../business_logic/transaction/objects.py | 2 +- .../starknet/business_logic/utils.py | 2 +- src/starkware/starknet/core/os/CMakeLists.txt | 1 - .../starknet/core/os/syscall_handler.py | 2 +- .../starknet/definitions/constants.py | 2 +- src/starkware/starknet/definitions/fields.py | 42 +++++++++++++------ .../contracts/test_contract_cairo1.cairo | 20 ++++++++- .../api/feeder_gateway/response_objects.py | 14 +++---- .../starknet/services/utils/CMakeLists.txt | 1 - .../services/utils/sequencer_api_utils.py | 7 +++- .../starknet/storage/starknet_storage.py | 2 +- .../starkware_utils/field_validators.py | 11 +++-- 24 files changed, 113 insertions(+), 72 deletions(-) diff --git a/scripts/requirements-gen.txt b/scripts/requirements-gen.txt index 27d65ca9..dda84ec9 100644 --- a/scripts/requirements-gen.txt +++ b/scripts/requirements-gen.txt @@ -18,4 +18,4 @@ pytest-asyncio PyYAML typeguard<3.0.0 sympy -Web3 +Web3<6.0.0 diff --git a/src/starkware/cairo/lang/VERSION b/src/starkware/cairo/lang/VERSION index a09c7eb7..d9df1bbc 100644 --- a/src/starkware/cairo/lang/VERSION +++ b/src/starkware/cairo/lang/VERSION @@ -1 +1 @@ -0.11.0a2 +0.11.0 diff --git a/src/starkware/cairo/lang/setup.py b/src/starkware/cairo/lang/setup.py index f00a5701..967d6548 100644 --- a/src/starkware/cairo/lang/setup.py +++ b/src/starkware/cairo/lang/setup.py @@ -30,6 +30,13 @@ "starkware.crypto.signature": ["pedersen_params.json"], "starkware.starknet": ["common/*.cairo", "definitions/*.yml"], "starkware.starknet.business_logic.execution": ["os_resources.json"], + "starkware.starknet.compiler.v1": [ + "corelib/*.cairo", + "corelib/src/*.cairo", + "corelib/src/starknet/*.cairo", + "bin/starknet-sierra-compile", + "bin/starknet-compile", + ], "starkware.starknet.core.os": ["*/*.cairo", "*.cairo", "*.json"], "starkware.starknet.core.test_contract": ["*.cairo", "*.json"], "starkware.starknet.security": ["whitelists/*.json"], diff --git a/src/starkware/cairo/sharp/config.json b/src/starkware/cairo/sharp/config.json index 37620868..9585a014 100644 --- a/src/starkware/cairo/sharp/config.json +++ b/src/starkware/cairo/sharp/config.json @@ -1,5 +1,5 @@ { "prover_url": "https://testnet.provingservice.io", - "verifier_address": "0x87b653D97B4e507A19a4A16bbF7434dcEf853AaA", + "verifier_address": "0x8f97970aC5a9aa8D130d35146F5b59c4aef57963", "steps_limit": 1000000 } diff --git a/src/starkware/starknet/business_logic/CMakeLists.txt b/src/starkware/starknet/business_logic/CMakeLists.txt index e74c54fa..a3119a8e 100644 --- a/src/starkware/starknet/business_logic/CMakeLists.txt +++ b/src/starkware/starknet/business_logic/CMakeLists.txt @@ -13,7 +13,6 @@ python_lib(starknet_business_logic_utils_lib cairo_function_runner_lib cairo_vm_lib starknet_abi_lib - starknet_business_logic_fact_state_lib starknet_business_logic_patricia_state_lib starknet_business_logic_state_lib starknet_contract_class_lib diff --git a/src/starkware/starknet/business_logic/execution/CMakeLists.txt b/src/starkware/starknet/business_logic/execution/CMakeLists.txt index 789b4bcb..af3a5a1f 100644 --- a/src/starkware/starknet/business_logic/execution/CMakeLists.txt +++ b/src/starkware/starknet/business_logic/execution/CMakeLists.txt @@ -30,7 +30,6 @@ python_lib(starknet_execute_entry_point_base_lib execute_entry_point_base.py LIBS - starknet_business_logic_fact_state_lib starknet_business_logic_state_lib starknet_contract_class_lib starknet_general_config_lib @@ -51,7 +50,6 @@ python_lib(starknet_execute_entry_point_lib everest_definitions_lib segment_arena_builtin_lib starknet_abi_lib - starknet_business_logic_fact_state_lib starknet_business_logic_state_lib starknet_business_logic_utils_lib starknet_contract_class_lib diff --git a/src/starkware/starknet/business_logic/execution/execute_entry_point.py b/src/starkware/starknet/business_logic/execution/execute_entry_point.py index 98354666..848de279 100644 --- a/src/starkware/starknet/business_logic/execution/execute_entry_point.py +++ b/src/starkware/starknet/business_logic/execution/execute_entry_point.py @@ -22,11 +22,11 @@ CallInfo, CallResult, CallType, + ExecutionResourcesManager, OrderedEvent, OrderedL2ToL1Message, TransactionExecutionContext, ) -from starkware.starknet.business_logic.fact_state.state import ExecutionResourcesManager from starkware.starknet.business_logic.state.state import ContractStorageState, StateSyncifier from starkware.starknet.business_logic.state.state_api import State, SyncState from starkware.starknet.business_logic.utils import ( diff --git a/src/starkware/starknet/business_logic/execution/execute_entry_point_base.py b/src/starkware/starknet/business_logic/execution/execute_entry_point_base.py index e77b1289..9557c509 100644 --- a/src/starkware/starknet/business_logic/execution/execute_entry_point_base.py +++ b/src/starkware/starknet/business_logic/execution/execute_entry_point_base.py @@ -5,9 +5,9 @@ from starkware.starknet.business_logic.execution.objects import ( CallInfo, CallType, + ExecutionResourcesManager, TransactionExecutionContext, ) -from starkware.starknet.business_logic.fact_state.state import ExecutionResourcesManager from starkware.starknet.business_logic.state.state_api import SyncState from starkware.starknet.definitions.general_config import StarknetGeneralConfig from starkware.starknet.services.api.contract_class.contract_class import EntryPointType diff --git a/src/starkware/starknet/business_logic/execution/objects.py b/src/starkware/starknet/business_logic/execution/objects.py index 0bfacd05..4c13680e 100644 --- a/src/starkware/starknet/business_logic/execution/objects.py +++ b/src/starkware/starknet/business_logic/execution/objects.py @@ -4,7 +4,7 @@ import operator from dataclasses import field from enum import Enum, auto -from typing import FrozenSet, Iterable, Iterator, List, Mapping, Optional, Set, cast +from typing import Dict, FrozenSet, Iterable, Iterator, List, Mapping, Optional, Set, cast import marshmallow.fields as mfields import marshmallow_dataclass @@ -747,3 +747,29 @@ def get_state_selector_of_many( (execution_info.get_state_selector() for execution_info in execution_infos), StateSelector.empty(), ) + + +class ExecutionResourcesManager: + """ + Aggregates execution resources throughout transaction stream processing. + """ + + def __init__( + self, + cairo_usage: ExecutionResources, + syscall_counter: Dict[str, int], + ): + # The accumulated Cairo usage. + self.cairo_usage = cairo_usage + + # A mapping from system call to the cumulative times it was invoked. + self.syscall_counter = syscall_counter + + # Alternative constructors. + + @classmethod + def empty(cls) -> "ExecutionResourcesManager": + return cls( + cairo_usage=ExecutionResources.empty(), + syscall_counter={}, + ) diff --git a/src/starkware/starknet/business_logic/fact_state/state.py b/src/starkware/starknet/business_logic/fact_state/state.py index 00d11998..94afa0c3 100644 --- a/src/starkware/starknet/business_logic/fact_state/state.py +++ b/src/starkware/starknet/business_logic/fact_state/state.py @@ -10,7 +10,6 @@ SharedStateBase, StateSelectorBase, ) -from starkware.cairo.lang.vm.cairo_pie import ExecutionResources from starkware.cairo.lang.vm.crypto import poseidon_hash_many from starkware.python.utils import ( from_bytes, @@ -48,32 +47,6 @@ ContractCarriedStateMapping = MutableMapping[int, ContractCarriedState] -class ExecutionResourcesManager: - """ - Aggregates execution resources throughout transaction stream processing. - """ - - def __init__( - self, - cairo_usage: ExecutionResources, - syscall_counter: Dict[str, int], - ): - # The accumulated Cairo usage. - self.cairo_usage = cairo_usage - - # A mapping from system call to the cumulative times it was invoked. - self.syscall_counter = syscall_counter - - # Alternative constructors. - - @classmethod - def empty(cls) -> "ExecutionResourcesManager": - return cls( - cairo_usage=ExecutionResources.empty(), - syscall_counter={}, - ) - - class CarriedState(CarriedStateBase): """ A state containing a mapping from contract addresses to their states and the accumulated diff --git a/src/starkware/starknet/business_logic/transaction/CMakeLists.txt b/src/starkware/starknet/business_logic/transaction/CMakeLists.txt index b88d1e0c..ac2550a0 100644 --- a/src/starkware/starknet/business_logic/transaction/CMakeLists.txt +++ b/src/starkware/starknet/business_logic/transaction/CMakeLists.txt @@ -11,7 +11,6 @@ python_lib(starknet_transaction_objects_lib everest_internal_transaction_lib everest_transaction_lib starknet_abi_lib - starknet_business_logic_fact_state_lib starknet_business_logic_patricia_state_lib starknet_business_logic_state_lib starknet_business_logic_utils_lib @@ -71,7 +70,6 @@ python_lib(starknet_transaction_fee_lib LIBS starknet_abi_lib - starknet_business_logic_fact_state_lib starknet_business_logic_state_lib starknet_business_logic_utils_lib starknet_contract_class_lib diff --git a/src/starkware/starknet/business_logic/transaction/fee.py b/src/starkware/starknet/business_logic/transaction/fee.py index 8a7e15b6..1775dd02 100644 --- a/src/starkware/starknet/business_logic/transaction/fee.py +++ b/src/starkware/starknet/business_logic/transaction/fee.py @@ -3,10 +3,10 @@ from starkware.starknet.business_logic.execution.execute_entry_point import ExecuteEntryPoint from starkware.starknet.business_logic.execution.objects import ( CallInfo, + ExecutionResourcesManager, ResourcesMapping, TransactionExecutionContext, ) -from starkware.starknet.business_logic.fact_state.state import ExecutionResourcesManager from starkware.starknet.business_logic.state.state_api import SyncState from starkware.starknet.business_logic.utils import extract_l1_gas_and_cairo_usage from starkware.starknet.definitions.constants import GasCost diff --git a/src/starkware/starknet/business_logic/transaction/objects.py b/src/starkware/starknet/business_logic/transaction/objects.py index 4ac16190..804c2952 100644 --- a/src/starkware/starknet/business_logic/transaction/objects.py +++ b/src/starkware/starknet/business_logic/transaction/objects.py @@ -16,12 +16,12 @@ from starkware.starknet.business_logic.execution.execute_entry_point import ExecuteEntryPoint from starkware.starknet.business_logic.execution.objects import ( CallInfo, + ExecutionResourcesManager, ResourcesMapping, TransactionExecutionContext, TransactionExecutionInfo, ) from starkware.starknet.business_logic.fact_state.contract_state_objects import StateSelector -from starkware.starknet.business_logic.fact_state.state import ExecutionResourcesManager from starkware.starknet.business_logic.state.state import UpdatesTrackerState from starkware.starknet.business_logic.state.state_api import SyncState from starkware.starknet.business_logic.state.state_api_objects import BlockInfo diff --git a/src/starkware/starknet/business_logic/utils.py b/src/starkware/starknet/business_logic/utils.py index fc55e021..2d1a621c 100644 --- a/src/starkware/starknet/business_logic/utils.py +++ b/src/starkware/starknet/business_logic/utils.py @@ -10,6 +10,7 @@ from starkware.starknet.business_logic.execution.objects import ( CallInfo, CallResult, + ExecutionResourcesManager, ResourcesMapping, TransactionExecutionInfo, ) @@ -19,7 +20,6 @@ ContractClassFact, DeprecatedCompiledClassFact, ) -from starkware.starknet.business_logic.fact_state.state import ExecutionResourcesManager from starkware.starknet.business_logic.state.state import UpdatesTrackerState from starkware.starknet.business_logic.state.state_api import SyncState from starkware.starknet.definitions import constants, fields diff --git a/src/starkware/starknet/core/os/CMakeLists.txt b/src/starkware/starknet/core/os/CMakeLists.txt index 7aa820a6..cadbef3e 100644 --- a/src/starkware/starknet/core/os/CMakeLists.txt +++ b/src/starkware/starknet/core/os/CMakeLists.txt @@ -32,7 +32,6 @@ python_lib(starknet_os_utils_lib cairo_run_lib cairo_vm_lib starknet_abi_lib - starknet_business_logic_fact_state_lib starknet_business_logic_patricia_state_lib starknet_business_logic_state_lib starknet_contract_address_lib diff --git a/src/starkware/starknet/core/os/syscall_handler.py b/src/starkware/starknet/core/os/syscall_handler.py index 5600275a..dffdbaeb 100644 --- a/src/starkware/starknet/core/os/syscall_handler.py +++ b/src/starkware/starknet/core/os/syscall_handler.py @@ -29,12 +29,12 @@ CallInfo, CallResult, CallType, + ExecutionResourcesManager, OrderedEvent, OrderedL2ToL1Message, TransactionExecutionContext, TransactionExecutionInfo, ) -from starkware.starknet.business_logic.fact_state.state import ExecutionResourcesManager from starkware.starknet.business_logic.state.state import ContractStorageState from starkware.starknet.business_logic.state.state_api import SyncState from starkware.starknet.business_logic.state.state_api_objects import BlockInfo diff --git a/src/starkware/starknet/definitions/constants.py b/src/starkware/starknet/definitions/constants.py index 98eb9b0c..6bbbf760 100644 --- a/src/starkware/starknet/definitions/constants.py +++ b/src/starkware/starknet/definitions/constants.py @@ -40,9 +40,9 @@ GAS_PRICE_LOWER_BOUND = 0 GAS_PRICE_UPPER_BOUND = 2**128 MAX_MESSAGE_TO_L1_LENGTH = 100 -MAX_CALLDATA_LENGTH = 2**30 NONCE_LOWER_BOUND = 0 NONCE_UPPER_BOUND = 2**NONCE_BITS +SIERRA_ARRAY_LEN_BOUND = 2**32 SYSCALL_SELECTOR_UPPER_BOUND = FIELD_SIZE TRANSACTION_COMMITMENT_TREE_HEIGHT = 64 TRANSACTION_HASH_LOWER_BOUND = 0 diff --git a/src/starkware/starknet/definitions/fields.py b/src/starkware/starknet/definitions/fields.py index bb42c80a..f038a2c8 100644 --- a/src/starkware/starknet/definitions/fields.py +++ b/src/starkware/starknet/definitions/fields.py @@ -11,7 +11,11 @@ from starkware.starknet.definitions import constants from starkware.starknet.definitions.error_codes import StarknetErrorCode from starkware.starknet.definitions.transaction_type import TransactionType -from starkware.starkware_utils.field_validators import validate_non_negative, validate_positive +from starkware.starkware_utils.field_validators import ( + validate_length, + validate_non_negative, + validate_positive, +) from starkware.starkware_utils.marshmallow_dataclass_fields import ( BackwardCompatibleIntAsHex, BytesAsHex, @@ -33,6 +37,15 @@ marshmallow_field=mfields.List(everest_fields.FeltField.get_marshmallow_field()) ) +bounded_felt_as_hex_list_metadata = dict( + marshmallow_field=mfields.List( + everest_fields.FeltField.get_marshmallow_field(), + validate=validate_length( + field_name="felt_list", max_length=constants.SIERRA_ARRAY_LEN_BOUND - 1 + ), + ) +) + felt_as_hex_or_str_list_metadata = dict( marshmallow_field=mfields.List( BackwardCompatibleIntAsHex( @@ -41,12 +54,21 @@ ) ) -calldata_metadata = felt_as_hex_or_str_list_metadata - felt_list_metadata = dict( marshmallow_field=mfields.List(IntAsStr(validate=everest_fields.FeltField.validate)) ) +bounded_felt_as_hex_or_str_list_metadata = dict( + marshmallow_field=mfields.List( + BackwardCompatibleIntAsHex( + allow_decimal_loading=True, validate=everest_fields.FeltField.validate + ), + validate=validate_length( + field_name="felt_list", max_length=constants.SIERRA_ARRAY_LEN_BOUND - 1 + ), + ) +) + def felt_formatter(hex_felt: str) -> str: return field_element_repr(val=int(hex_felt, 16), prime=everest_fields.FeltField.upper_bound) @@ -71,6 +93,11 @@ def new_class_hash_dict_keys_metadata( marshmallow_field=StrictRequiredInteger(validate=validate_non_negative("timestamp")) ) +calldata_metadata = bounded_felt_as_hex_or_str_list_metadata +signature_metadata = bounded_felt_as_hex_or_str_list_metadata +calldata_as_hex_metadata = bounded_felt_as_hex_list_metadata +retdata_as_hex_metadata = felt_as_hex_list_metadata + # Address. @@ -154,15 +181,6 @@ def address_metadata(name: str, error_code: StarknetErrorCode) -> Dict[str, Any] field_name="Transaction index", required=False, load_default=None ) - -# InvokeFunction. - -call_data_as_hex_metadata = felt_as_hex_list_metadata -signature_as_hex_metadata = felt_as_hex_or_str_list_metadata -signature_metadata = felt_list_metadata -retdata_as_hex_metadata = felt_as_hex_list_metadata - - # L1Handler. payload_metadata = felt_as_hex_list_metadata diff --git a/src/starkware/starknet/services/api/contract_class/contracts/test_contract_cairo1.cairo b/src/starkware/starknet/services/api/contract_class/contracts/test_contract_cairo1.cairo index 6e3bc98f..445fff35 100644 --- a/src/starkware/starknet/services/api/contract_class/contracts/test_contract_cairo1.cairo +++ b/src/starkware/starknet/services/api/contract_class/contracts/test_contract_cairo1.cairo @@ -20,7 +20,13 @@ mod TestContract { const UNEXPECTED_ERROR: felt252 = 'UNEXPECTED ERROR'; struct Storage { - my_storage_var: felt252 + my_storage_var: felt252, + public_key: felt252 + } + + #[constructor] + fn constructor() { + public_key::write('public_key'); } #[external] @@ -149,5 +155,17 @@ mod TestContract { z } + #[external] + fn test_deploy( + class_hash: ClassHash, + contract_address_salt: felt252, + calldata: Array::, + deploy_from_zero: bool, + ) { + starknet::syscalls::deploy_syscall( + class_hash, contract_address_salt, calldata.span(), deploy_from_zero + ).unwrap_syscall(); + + } } diff --git a/src/starkware/starknet/services/api/feeder_gateway/response_objects.py b/src/starkware/starknet/services/api/feeder_gateway/response_objects.py index ede67203..7222f5f0 100644 --- a/src/starkware/starknet/services/api/feeder_gateway/response_objects.py +++ b/src/starkware/starknet/services/api/feeder_gateway/response_objects.py @@ -261,7 +261,7 @@ def from_internal(cls, internal_tx: InternalTransaction) -> "TransactionSpecific @marshmallow_dataclass.dataclass(frozen=True) # type: ignore[misc] class AccountTransactionSpecificInfo(TransactionSpecificInfo): max_fee: int = field(metadata=fields.fee_metadata) - signature: List[int] = field(metadata=fields.signature_as_hex_metadata) + signature: List[int] = field(metadata=fields.signature_metadata) nonce: Optional[int] = field(metadata=fields.optional_nonce_metadata) @property @@ -307,7 +307,7 @@ class DeploySpecificInfo(TransactionSpecificInfo): contract_address: int = field(metadata=fields.contract_address_metadata) contract_address_salt: int = field(metadata=fields.contract_address_salt_metadata) class_hash: Optional[int] = field(metadata=fields.OptionalClassHashIntField.metadata()) - constructor_calldata: List[int] = field(metadata=fields.call_data_as_hex_metadata) + constructor_calldata: List[int] = field(metadata=fields.calldata_as_hex_metadata) tx_type: ClassVar[TransactionType] = TransactionType.DEPLOY @@ -328,7 +328,7 @@ class DeployAccountSpecificInfo(AccountTransactionSpecificInfo): contract_address: int = field(metadata=fields.contract_address_metadata) contract_address_salt: int = field(metadata=fields.contract_address_salt_metadata) class_hash: int = field(metadata=fields.ClassHashIntField.metadata()) - constructor_calldata: List[int] = field(metadata=fields.call_data_as_hex_metadata) + constructor_calldata: List[int] = field(metadata=fields.calldata_as_hex_metadata) version: int = field(metadata=fields.tx_version_metadata) # Repeat `nonce` to narrow its type to non-optional int. nonce: int = field(metadata=fields.nonce_metadata) @@ -364,7 +364,7 @@ class InvokeSpecificInfo(AccountTransactionSpecificInfo): entry_point_selector: Optional[int] = field( metadata=fields.optional_entry_point_selector_metadata ) - calldata: List[int] = field(metadata=fields.call_data_as_hex_metadata) + calldata: List[int] = field(metadata=fields.calldata_as_hex_metadata) tx_type: ClassVar[TransactionType] = TransactionType.INVOKE_FUNCTION @@ -421,7 +421,7 @@ class L1HandlerSpecificInfo(TransactionSpecificInfo): contract_address: int = field(metadata=fields.contract_address_metadata) entry_point_selector: int = field(metadata=fields.entry_point_selector_metadata) nonce: Optional[int] = field(metadata=fields.optional_nonce_metadata) - calldata: List[int] = field(metadata=fields.call_data_as_hex_metadata) + calldata: List[int] = field(metadata=fields.calldata_as_hex_metadata) tx_type: ClassVar[TransactionType] = TransactionType.L1_HANDLER @@ -754,7 +754,7 @@ class FunctionInvocation(BaseResponseObject, SerializableMarshmallowDataclass): metadata=fields.L2AddressField.metadata(field_name="caller_address") ) contract_address: int = field(metadata=fields.contract_address_metadata) - calldata: List[int] = field(metadata=fields.call_data_as_hex_metadata) + calldata: List[int] = field(metadata=fields.calldata_as_hex_metadata) call_type: Optional[CallType] = field(metadata=nonrequired_optional_metadata) class_hash: Optional[int] = field(metadata=fields.OptionalClassHashIntField.metadata()) selector: Optional[int] = field(metadata=fields.optional_entry_point_selector_metadata) @@ -811,7 +811,7 @@ class TransactionTrace(ValidatedResponseObject): validate_invocation: Optional[FunctionInvocation] function_invocation: Optional[FunctionInvocation] fee_transfer_invocation: Optional[FunctionInvocation] - signature: List[int] = field(metadata=fields.signature_as_hex_metadata) + signature: List[int] = field(metadata=fields.signature_metadata) @marshmallow_dataclass.dataclass(frozen=True) diff --git a/src/starkware/starknet/services/utils/CMakeLists.txt b/src/starkware/starknet/services/utils/CMakeLists.txt index 9692326f..08254b5f 100644 --- a/src/starkware/starknet/services/utils/CMakeLists.txt +++ b/src/starkware/starknet/services/utils/CMakeLists.txt @@ -6,7 +6,6 @@ python_lib(starknet_sequencer_api_utils_lib LIBS everest_transaction_lib - starknet_business_logic_fact_state_lib starknet_business_logic_state_lib starknet_feeder_gateway_response_objects_lib starknet_general_config_lib diff --git a/src/starkware/starknet/services/utils/sequencer_api_utils.py b/src/starkware/starknet/services/utils/sequencer_api_utils.py index 1c1d8201..a965b894 100644 --- a/src/starkware/starknet/services/utils/sequencer_api_utils.py +++ b/src/starkware/starknet/services/utils/sequencer_api_utils.py @@ -2,8 +2,11 @@ from typing import ClassVar, Optional, Tuple, Type from services.everest.api.gateway.transaction import EverestTransaction -from starkware.starknet.business_logic.execution.objects import CallInfo, ResourcesMapping -from starkware.starknet.business_logic.fact_state.state import ExecutionResourcesManager +from starkware.starknet.business_logic.execution.objects import ( + CallInfo, + ExecutionResourcesManager, + ResourcesMapping, +) from starkware.starknet.business_logic.state.state_api import SyncState from starkware.starknet.business_logic.transaction.fee import calculate_tx_fee from starkware.starknet.business_logic.transaction.objects import ( diff --git a/src/starkware/starknet/storage/starknet_storage.py b/src/starkware/starknet/storage/starknet_storage.py index 52772df0..97b422ed 100644 --- a/src/starkware/starknet/storage/starknet_storage.py +++ b/src/starkware/starknet/storage/starknet_storage.py @@ -69,7 +69,7 @@ async def create( class OsSingleStarknetStorage: """ Represents a single contract storage. - It is used by the StarkNet OS run in the GpsAmbassador. + It is used by the Starknet OS run in the GpsAmbassador. """ def __init__(self, commitment_info: CommitmentInfo, ongoing_storage_changes: Dict[int, int]): diff --git a/src/starkware/starkware_utils/field_validators.py b/src/starkware/starkware_utils/field_validators.py index c0519d9b..a0b5881a 100644 --- a/src/starkware/starkware_utils/field_validators.py +++ b/src/starkware/starkware_utils/field_validators.py @@ -131,11 +131,14 @@ def validate_equal(field_name: str, *, allowed_value: T) -> ValidatorType: return marshmallow.validate.Equal(comparable=allowed_value, error=error_message) -def validate_length(field_name: str, *, length: int) -> ValidatorType: - error_message = "Invalid {field_name}: {{input}}; must be of length: {length}".format( - field_name=field_name, length=length +def validate_length(field_name: str, *, max_length: int) -> ValidatorType: + error_message = ( + "Invalid {field_name}: {{input}}; " + "must be of length less than or equal to: {max_length}.".format( + field_name=field_name, max_length=max_length + ) ) - return marshmallow.validate.Length(equal=length, error=error_message) + return marshmallow.validate.Length(max=max_length, error=error_message) def validate_in_range(