-
Notifications
You must be signed in to change notification settings - Fork 28
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
chore(blockifier): change deserialization of versioned_constants #2818
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
e46d6c7
to
6edcfc1
Compare
1fb5bb8
to
cf1721c
Compare
6edcfc1
to
122d0e3
Compare
cf1721c
to
9b7c19f
Compare
122d0e3
to
2dac98b
Compare
9b7c19f
to
5214bf3
Compare
5214bf3
to
813f4d2
Compare
813f4d2
to
4f26fc6
Compare
2dac98b
to
9731180
Compare
9731180
to
f5fabe7
Compare
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 }); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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.
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, | ||
}); |
There was a problem hiding this comment.
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.
fn is_syscall_gas_costs_none (&self) ->bool { | ||
self.gas_costs.is_none() | ||
} |
There was a problem hiding this comment.
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.
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 }); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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:
- Add
mut
to allow modification of the struct's fields - 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.
fn is_syscall_gas_costs_none (&self) ->bool { | ||
self.gas_costs.is_none() | ||
} |
There was a problem hiding this comment.
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.
No description provided.