diff --git a/src/starkware/cairo/lang/VERSION b/src/starkware/cairo/lang/VERSION index d9df1bbc..193f2f4e 100644 --- a/src/starkware/cairo/lang/VERSION +++ b/src/starkware/cairo/lang/VERSION @@ -1 +1 @@ -0.11.0 +0.11.0.1 diff --git a/src/starkware/starknet/definitions/constants.py b/src/starkware/starknet/definitions/constants.py index 6bbbf760..98eb9b0c 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 f038a2c8..bb42c80a 100644 --- a/src/starkware/starknet/definitions/fields.py +++ b/src/starkware/starknet/definitions/fields.py @@ -11,11 +11,7 @@ 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_length, - validate_non_negative, - validate_positive, -) +from starkware.starkware_utils.field_validators import validate_non_negative, validate_positive from starkware.starkware_utils.marshmallow_dataclass_fields import ( BackwardCompatibleIntAsHex, BytesAsHex, @@ -37,15 +33,6 @@ 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( @@ -54,21 +41,12 @@ ) ) +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) @@ -93,11 +71,6 @@ 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. @@ -181,6 +154,15 @@ 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/feeder_gateway/response_objects.py b/src/starkware/starknet/services/api/feeder_gateway/response_objects.py index 7222f5f0..ede67203 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_metadata) + signature: List[int] = field(metadata=fields.signature_as_hex_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.calldata_as_hex_metadata) + constructor_calldata: List[int] = field(metadata=fields.call_data_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.calldata_as_hex_metadata) + constructor_calldata: List[int] = field(metadata=fields.call_data_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.calldata_as_hex_metadata) + calldata: List[int] = field(metadata=fields.call_data_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.calldata_as_hex_metadata) + calldata: List[int] = field(metadata=fields.call_data_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.calldata_as_hex_metadata) + calldata: List[int] = field(metadata=fields.call_data_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_metadata) + signature: List[int] = field(metadata=fields.signature_as_hex_metadata) @marshmallow_dataclass.dataclass(frozen=True) diff --git a/src/starkware/starkware_utils/field_validators.py b/src/starkware/starkware_utils/field_validators.py index a0b5881a..c0519d9b 100644 --- a/src/starkware/starkware_utils/field_validators.py +++ b/src/starkware/starkware_utils/field_validators.py @@ -131,14 +131,11 @@ 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, *, 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 - ) +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 ) - return marshmallow.validate.Length(max=max_length, error=error_message) + return marshmallow.validate.Length(equal=length, error=error_message) def validate_in_range(