Skip to content

Commit

Permalink
Cairo v0.12.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
liorgold2 committed Jul 3, 2023
1 parent 3a32740 commit c98fc0b
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 7 deletions.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ http_archive(
"//src/starkware/starknet/compiler/v1:BUILD.cairo-compiler-archive",
),
strip_prefix = "cairo",
url = "https://github.com/starkware-libs/cairo/releases/download/v2.0.0-rc5/release-x86_64-unknown-linux-musl.tar.gz",
url = "https://github.com/starkware-libs/cairo/releases/download/v2.0.0/release-x86_64-unknown-linux-musl.tar.gz",
)

http_archive(
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.12.0a0
0.12.0
10 changes: 8 additions & 2 deletions src/starkware/starknet/business_logic/state/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,10 @@ def set_compiled_class_hash(self, class_hash: int, compiled_class_hash: int):
class_hash=class_hash, compiled_class_hash=compiled_class_hash
)

def count_actual_updates(self) -> Tuple[int, int, int, int]:
def count_actual_updates(
self,
sender_address: Optional[int],
) -> Tuple[int, int, int, int]:
"""
Returns a tuple of:
1. The number of modified contracts.
Expand Down Expand Up @@ -646,7 +649,10 @@ def count_actual_updates(self) -> Tuple[int, int, int, int]:
self.cache._nonce_writes, self.cache._nonce_initial_values
)
contracts_with_modified_nonce = set(nonce_updates.keys())

# Adds manually the account contract address since we increment the nonce after computing
# the state updates.
if sender_address is not None:
contracts_with_modified_nonce.add(sender_address)
# Modified contracts.
modified_contracts = (
contracts_with_modified_storage
Expand Down
10 changes: 10 additions & 0 deletions src/starkware/starknet/business_logic/transaction/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,9 @@ def _apply_specific_concurrent_changes(
resources_manager=resources_manager,
call_infos=[validate_info],
tx_type=self.tx_type,
sender_address=None
if self.version in [0, constants.QUERY_VERSION_BASE]
else self.sender_address,
)

return TransactionExecutionInfo.create_concurrent_stage_execution_info(
Expand Down Expand Up @@ -895,6 +898,7 @@ def _apply_specific_concurrent_changes(
resources_manager=resources_manager,
call_infos=[constructor_call_info, validate_info],
tx_type=self.tx_type,
sender_address=self.sender_address,
)

return TransactionExecutionInfo.create_concurrent_stage_execution_info(
Expand Down Expand Up @@ -1145,6 +1149,7 @@ def handle_empty_constructor(self, state: UpdatesTrackerState) -> TransactionExe
resources_manager=resources_manager,
call_infos=[call_info],
tx_type=self.tx_type,
sender_address=None,
)

return TransactionExecutionInfo.create_concurrent_stage_execution_info(
Expand Down Expand Up @@ -1187,6 +1192,7 @@ def invoke_constructor(
resources_manager=resources_manager,
call_infos=[call_info],
tx_type=self.tx_type,
sender_address=None,
)

return TransactionExecutionInfo.create_concurrent_stage_execution_info(
Expand Down Expand Up @@ -1444,6 +1450,9 @@ def _apply_specific_concurrent_changes(
resources_manager=resources_manager,
call_infos=[call_info, validate_info],
tx_type=self.tx_type,
sender_address=None
if self.version in [0, constants.QUERY_VERSION_BASE]
else self.sender_address,
)

return TransactionExecutionInfo.create_concurrent_stage_execution_info(
Expand Down Expand Up @@ -1623,6 +1632,7 @@ def _apply_specific_concurrent_changes(
call_infos=[call_info],
tx_type=self.tx_type,
l1_handler_payload_size=self.get_payload_size(),
sender_address=None,
)

# Enforce L1 fees.
Expand Down
3 changes: 2 additions & 1 deletion src/starkware/starknet/business_logic/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def calculate_tx_resources(
call_infos: Iterable[Optional[CallInfo]],
tx_type: TransactionType,
state: UpdatesTrackerState,
sender_address: Optional[int],
l1_handler_payload_size: Optional[int] = None,
) -> ResourcesMapping:
"""
Expand All @@ -211,7 +212,7 @@ def calculate_tx_resources(
n_storage_changes,
n_class_updates,
_n_nonce_updates,
) = state.count_actual_updates()
) = state.count_actual_updates(sender_address=sender_address)

return calculate_tx_resources_given_usage(
resources_manager=resources_manager,
Expand Down
1 change: 1 addition & 0 deletions src/starkware/starknet/compiler/v1/mainnet_libfuncs.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"felt252_sub",
"finalize_locals",
"function_call",
"get_block_hash_syscall",
"get_builtin_costs",
"get_execution_info_syscall",
"hades_permutation",
Expand Down
1 change: 1 addition & 0 deletions src/starkware/starknet/compiler/v1/testnet2_libfuncs.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"struct_snapshot_deconstruct",
"u256_sqrt",
"u256_is_zero",
"u256_safe_divmod",
"u128_const",
"u128_eq",
"u128_is_zero",
Expand Down
11 changes: 11 additions & 0 deletions src/starkware/starknet/definitions/general_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ class StarknetGeneralConfig(EverestGeneralConfig):

min_gas_price: int = field(metadata=fields.gas_price, default=DEFAULT_GAS_PRICE)

constant_gas_price: bool = field(
metadata=additional_metadata(
marshmallow_field=RequiredBoolean(),
description=(
"If True, sets the gas price to the `min_gas_price` value, regardless of the L1 "
"gas prices."
),
),
default=False,
)

sequencer_address: int = field(
metadata=additional_metadata(
**fields.sequencer_address_metadata, description="StarkNet sequencer address."
Expand Down
1 change: 1 addition & 0 deletions src/starkware/starknet/definitions/general_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ event_commitment_tree_height: 64
global_state_commitment_tree_height: 251
invoke_tx_max_n_steps: 1000000
min_gas_price: 100000000000
constant_gas_price: false
sequencer_address: '0x2d389df4ad1c4d382cb7751982ab7bf24ac40cbab4769667f108a7b93f9e987'
starknet_os_config:
chain_id: 1536727068981429685321 # StarknetChainId.TESTNET.value
Expand Down
4 changes: 2 additions & 2 deletions src/starkware/starknet/testing/test_cairo1.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod TestContract {
struct Storage {
}

#[external]
#[external(v0)]
fn read(ref self: ContractState, key: felt252) -> felt252 {
let domain_address = 0_u32; // Only address_domain 0 is currently supported.
let storage_address = storage_address_from_base_and_offset(
Expand All @@ -18,7 +18,7 @@ mod TestContract {
storage_read_syscall(domain_address, storage_address).unwrap_syscall()
}

#[external]
#[external(v0)]
fn write(ref self: ContractState, key: felt252, value: felt252) {
let domain_address = 0_u32; // Only address_domain 0 is currently supported.
let storage_address = storage_address_from_base_and_offset(
Expand Down

0 comments on commit c98fc0b

Please sign in to comment.