Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(blockifier): change deserialization of versioned_constants #2818

Conversation

Yonatan-Starkware
Copy link
Contributor

No description provided.

@reviewable-StarkWare
Copy link

This change is Reviewable

@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/moving_gas_costs_to_os_resources branch from e46d6c7 to 6edcfc1 Compare December 19, 2024 12:15
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/split_builtin_gas_costs_from_base_gas_costs branch from 1fb5bb8 to cf1721c Compare December 19, 2024 12:18
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/moving_gas_costs_to_os_resources branch from 6edcfc1 to 122d0e3 Compare December 19, 2024 12:18
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/split_builtin_gas_costs_from_base_gas_costs branch from cf1721c to 9b7c19f Compare December 19, 2024 12:40
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/moving_gas_costs_to_os_resources branch from 122d0e3 to 2dac98b Compare December 19, 2024 12:40
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/split_builtin_gas_costs_from_base_gas_costs branch from 9b7c19f to 5214bf3 Compare December 22, 2024 07:56
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/split_builtin_gas_costs_from_base_gas_costs branch from 5214bf3 to 813f4d2 Compare December 22, 2024 13:39
@Yonatan-Starkware Yonatan-Starkware changed the base branch from yonatank/blockifier/split_builtin_gas_costs_from_base_gas_costs to graphite-base/2818 December 22, 2024 14:06
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/moving_gas_costs_to_os_resources branch from 2dac98b to 9731180 Compare December 22, 2024 14:06
@Yonatan-Starkware Yonatan-Starkware changed the base branch from graphite-base/2818 to main December 22, 2024 14:07
@Yonatan-Starkware Yonatan-Starkware force-pushed the yonatank/blockifier/moving_gas_costs_to_os_resources branch from 9731180 to f5fabe7 Compare December 22, 2024 14:07
Comment on lines +816 to +855
fn set_syscall_price(&self, selector: &SyscallSelector, amount: u64) {
match *selector {
SyscallSelector::CallContract => self.call_contract = amount,
SyscallSelector::Deploy => self.deploy = amount,
SyscallSelector::EmitEvent => self.emit_event = amount,
SyscallSelector::GetBlockHash => self.get_block_hash = amount,
SyscallSelector::GetExecutionInfo => self.get_execution_info = amount,
SyscallSelector::GetClassHashAt => self.get_class_hash_at = amount,
SyscallSelector::Keccak => {self.keccak = amount;
self.keccak_round_cost = 180000},
SyscallSelector::Sha256ProcessBlock => self.sha256_process_block = amount,
SyscallSelector::LibraryCall => self.library_call = amount,
SyscallSelector::ReplaceClass => self.replace_class = amount,
SyscallSelector::Secp256k1Add => self.secp256k1_add = amount,
SyscallSelector::Secp256k1GetPointFromX => self.secp256k1_get_point_from_x = amount,
SyscallSelector::Secp256k1GetXy => self.secp256k1_get_xy = amount,
SyscallSelector::Secp256k1Mul => self.secp256k1_mul = amount,
SyscallSelector::Secp256k1New => self.secp256k1_new = amount,
SyscallSelector::Secp256r1Add => self.secp256r1_add = amount,
SyscallSelector::Secp256r1GetPointFromX => self.secp256r1_get_point_from_x = amount,
SyscallSelector::Secp256r1GetXy => self.secp256r1_get_xy = amount,
SyscallSelector::Secp256r1Mul => self.secp256r1_mul = amount,
SyscallSelector::Secp256r1New => self.secp256r1_new = amount,
SyscallSelector::SendMessageToL1 => self.send_message_to_l1 = amount,
SyscallSelector::StorageRead => self.storage_read = amount,
SyscallSelector::StorageWrite => self.storage_write = amount,
SyscallSelector::DelegateCall
| SyscallSelector::DelegateL1Handler
| SyscallSelector::GetBlockNumber
| SyscallSelector::GetBlockTimestamp
| SyscallSelector::GetCallerAddress
| SyscallSelector::GetContractAddress
| SyscallSelector::GetTxInfo
| SyscallSelector::GetSequencerAddress
| SyscallSelector::GetTxSignature
| SyscallSelector::LibraryCallL1Handler => {
return Err(GasCostsError::DeprecatedSyscall { selector: *selector });
}
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function signature set_syscall_price needs a return type of Result<(), GasCostsError> to match its implementation, which attempts to return an error in the deprecated syscall case. Currently the function signature indicates it returns nothing (implicit unit type) but the implementation includes an Err return.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +521 to +532
let constants = Arc::new(OsConstants {
gas_costs,
validate_rounding_consts: tmp_versioned_constants.tmp_os_constants.validate_rounding_consts,
os_contract_addresses: tmp_versioned_constants.tmp_os_constants.os_contract_addresses,
});

} else {
let constants = Arc::new(OsConstants {
gas_costs: tmp_versioned_constants.tmp_os_constants.gas_costs,
validate_rounding_consts: tmp_versioned_constants.tmp_os_constants.validate_rounding_consts,
os_contract_addresses: tmp_versioned_constants.tmp_os_constants.os_contract_addresses,
});
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constants variable is created but not used in the final VersionedConstants struct construction. Please assign constants to the os_constants field in the Ok(VersionedConstants { ... }) return value.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +981 to +983
fn is_syscall_gas_costs_none (&self) ->bool {
self.gas_costs.is_none()
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The is_syscall_gas_costs_none() method is calling is_none() on the wrong field. It should be self.gas_costs.syscalls.is_none() since syscalls is the Option field that needs to be checked, not gas_costs itself which is a struct.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +816 to +855
fn set_syscall_price(&self, selector: &SyscallSelector, amount: u64) {
match *selector {
SyscallSelector::CallContract => self.call_contract = amount,
SyscallSelector::Deploy => self.deploy = amount,
SyscallSelector::EmitEvent => self.emit_event = amount,
SyscallSelector::GetBlockHash => self.get_block_hash = amount,
SyscallSelector::GetExecutionInfo => self.get_execution_info = amount,
SyscallSelector::GetClassHashAt => self.get_class_hash_at = amount,
SyscallSelector::Keccak => {self.keccak = amount;
self.keccak_round_cost = 180000},
SyscallSelector::Sha256ProcessBlock => self.sha256_process_block = amount,
SyscallSelector::LibraryCall => self.library_call = amount,
SyscallSelector::ReplaceClass => self.replace_class = amount,
SyscallSelector::Secp256k1Add => self.secp256k1_add = amount,
SyscallSelector::Secp256k1GetPointFromX => self.secp256k1_get_point_from_x = amount,
SyscallSelector::Secp256k1GetXy => self.secp256k1_get_xy = amount,
SyscallSelector::Secp256k1Mul => self.secp256k1_mul = amount,
SyscallSelector::Secp256k1New => self.secp256k1_new = amount,
SyscallSelector::Secp256r1Add => self.secp256r1_add = amount,
SyscallSelector::Secp256r1GetPointFromX => self.secp256r1_get_point_from_x = amount,
SyscallSelector::Secp256r1GetXy => self.secp256r1_get_xy = amount,
SyscallSelector::Secp256r1Mul => self.secp256r1_mul = amount,
SyscallSelector::Secp256r1New => self.secp256r1_new = amount,
SyscallSelector::SendMessageToL1 => self.send_message_to_l1 = amount,
SyscallSelector::StorageRead => self.storage_read = amount,
SyscallSelector::StorageWrite => self.storage_write = amount,
SyscallSelector::DelegateCall
| SyscallSelector::DelegateL1Handler
| SyscallSelector::GetBlockNumber
| SyscallSelector::GetBlockTimestamp
| SyscallSelector::GetCallerAddress
| SyscallSelector::GetContractAddress
| SyscallSelector::GetTxInfo
| SyscallSelector::GetSequencerAddress
| SyscallSelector::GetTxSignature
| SyscallSelector::LibraryCallL1Handler => {
return Err(GasCostsError::DeprecatedSyscall { selector: *selector });
}
}
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function signature needs to be modified to:

fn set_syscall_price(&mut self, selector: &SyscallSelector, amount: u64) -> Result<(), GasCostsError>

Two changes are required:

  1. Add mut to allow modification of the struct's fields
  2. Return Result<(), GasCostsError> to properly handle the error case

Additionally, add Ok(()) after the successful assignments in the match statement to return success.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

Comment on lines +981 to +983
fn is_syscall_gas_costs_none (&self) ->bool {
self.gas_costs.is_none()
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method is checking the wrong field - it should be checking self.gas_costs.syscalls.is_none() rather than self.gas_costs.is_none(). The gas_costs field itself is not optional, but its syscalls field is.

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.

@Yonatan-Starkware Yonatan-Starkware deleted the yonatank/blockifier/moving_gas_costs_to_os_resources branch December 22, 2024 15:27
@github-actions github-actions bot locked and limited conversation to collaborators Dec 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants