Skip to content

Commit

Permalink
Cairo v0.13.0a3 (pre).
Browse files Browse the repository at this point in the history
  • Loading branch information
liorgold2 committed Dec 5, 2023
1 parent 51c287a commit ee7ce74
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 16 deletions.
13 changes: 8 additions & 5 deletions bazel_utils/python.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,19 @@ def test_and_debug_targets(name, srcs, timeout, is_pypy, **kwargs):
)

def _py_wrappers_impl(ctx):
# Construct py_binary path.
# Note that the label package may be empty - it happens in the case that the label is defined in
# the BUILD file adjacent to the WORKSPACE file.
workspace_part = "%s/" % (ctx.label.workspace_name or ctx.workspace_name)
package_part = ("%s/" % ctx.label.package) if ctx.label.package else ""
py_binary_path = workspace_part + package_part + ctx.attr.py_binary_name

ctx.actions.run(
outputs = [ctx.outputs.py_wrapper, ctx.outputs.sh_wrapper],
executable = ctx.executable._gen_python_exe,
arguments = [
"--py_binary_path",
"%s/%s/%s" % (
ctx.label.workspace_name or ctx.workspace_name,
ctx.label.package,
ctx.attr.py_binary_name,
),
py_binary_path,
"--output_py",
ctx.outputs.py_wrapper.path,
"--output_sh",
Expand Down
8 changes: 6 additions & 2 deletions src/services/external_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,11 @@ def __init__(
retry_config: Optional[RetryConfig] = None,
request_timeout: Optional[int] = None,
headers: Optional[Mapping[str, str]] = None,
log_errors: bool = True,
):
self.url = url
self.ssl_context: Optional[ssl.SSLContext] = None
self.log_errors = log_errors

self.retry_config = RetryConfig() if retry_config is None else retry_config
assert (
Expand Down Expand Up @@ -216,15 +218,17 @@ async def _send_request(
f"{error_message} "
f"Status code: {exception.status_code}; text: {exception.text}."
)
logger.error(full_error_message, exc_info=True)
if self.log_errors:
logger.error(full_error_message, exc_info=True)
raise

logger.debug(f"{error_message}, retrying...")
except Exception as exception:
error_message = f"Got {type(exception).__name__} while trying to access {url}."

if limited_retries and n_retries_left == 0:
logger.error(error_message, exc_info=True)
if self.log_errors:
logger.error(error_message, exc_info=True)
raise

logger.debug(f"{error_message}, retrying...")
Expand Down
2 changes: 1 addition & 1 deletion src/starkware/cairo/lang/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.13.0a2
0.13.0a3
21 changes: 15 additions & 6 deletions src/starkware/starknet/core/os/execution/execute_entry_point.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,6 @@ func execute_entry_point{
local entry_point_return_values: EntryPointReturnValues* = cast(
return_values_ptr, EntryPointReturnValues*
);
%{
syscall_handler.validate_and_discard_syscall_ptr(
syscall_ptr_end=ids.entry_point_return_values.syscall_ptr
)
execution_helper.exit_call()
%}

// Check that the execution was successful.
%{
Expand All @@ -249,6 +243,21 @@ func execute_entry_point{
print(f" Selector: {hex(ids.execution_context.execution_info.selector)}")
print(f" Size: {retdata_size}")
print(f" Error (at most 100 elements): {error}")

if execution_helper.perform_extended_checks:
# Validate the predicted gas cost.
actual = ids.remaining_gas - ids.entry_point_return_values.gas_builtin
predicted = execution_helper.call_info.gas_consumed
assert actual == predicted, (
"Predicted gas costs are inconsistent with the actual execution; "
f"{predicted=}, {actual=}."
)

# Exit call.
syscall_handler.validate_and_discard_syscall_ptr(
syscall_ptr_end=ids.entry_point_return_values.syscall_ptr
)
execution_helper.exit_call()
%}
assert entry_point_return_values.failure_flag = 0;

Expand Down
4 changes: 4 additions & 0 deletions src/starkware/starknet/core/os/syscall_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,10 +1141,12 @@ def __init__(
storage_by_address: Mapping[int, OsSingleStarknetStorage],
old_block_number_and_hash: Optional[Tuple[int, int]],
loop: asyncio.AbstractEventLoop,
perform_extended_checks: bool,
):
"""
Private constructor.
"""
self.perform_extended_checks = perform_extended_checks
self.tx_execution_info_iterator: Iterator[TransactionExecutionInfo] = iter(
tx_execution_infos
)
Expand Down Expand Up @@ -1197,6 +1199,7 @@ async def create(
block_info: BlockInfo,
updated_block_hash_contract_state: ContractState,
ffc: FactFetchingContext,
perform_extended_checks: bool,
) -> "OsExecutionHelper":
# Fetch the hash of the (current_block_number - buffer) block from the updated state
# (was written by the Batcher).
Expand All @@ -1214,6 +1217,7 @@ async def create(
storage_by_address=storage_by_address,
old_block_number_and_hash=old_block_number_and_hash,
loop=asyncio.get_running_loop(),
perform_extended_checks=perform_extended_checks,
)

def compute_storage_commitments(self) -> Mapping[int, CommitmentInfo]:
Expand Down
2 changes: 2 additions & 0 deletions src/starkware/starknet/definitions/error_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class StarknetErrorCode(ErrorCode):
BLOCK_NOT_FOUND = 0
BLOCKED_TRANSACTION_TYPE = auto()
SENDER_ADDRESS_IS_BLOCKED = auto()
CLASS_ALREADY_DECLARED = auto()
COMPILATION_FAILED = auto()
Expand Down Expand Up @@ -161,6 +162,7 @@ def from_raw_code(cls, code: str) -> "StarknetErrorCode":
main_gateway_error_code_whitelist: FrozenSet[ErrorCode] = frozenset(
[
*common_error_codes,
StarknetErrorCode.BLOCKED_TRANSACTION_TYPE,
StarknetErrorCode.DEPRECATED_TRANSACTION,
StarknetErrorCode.DUPLICATED_TRANSACTION,
StarknetErrorCode.SENDER_ADDRESS_IS_BLOCKED,
Expand Down
4 changes: 2 additions & 2 deletions src/starkware/starknet/definitions/general_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
}

DEFAULT_ETH_IN_STRK_WEI = 10**21
DEFAULT_MIN_STRK_L1_GAS_PRICE = 10**10
DEFAULT_MAX_STRK_L1_GAS_PRICE = 10**12
DEFAULT_MIN_STRK_L1_GAS_PRICE = 10**6
DEFAULT_MAX_STRK_L1_GAS_PRICE = 10**18


# Configuration schema definition.
Expand Down

0 comments on commit ee7ce74

Please sign in to comment.