Skip to content

Commit

Permalink
update from comments
Browse files Browse the repository at this point in the history
  • Loading branch information
greged93 committed Sep 21, 2023
1 parent 06491c5 commit f076803
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 3 additions & 0 deletions crates/sequencer/src/sequencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use blockifier::state::state_api::{State, StateReader};
/// Sequencer is the main struct of the sequencer crate.
/// Using a trait bound for the state allows for better
/// speed, as the type of the state is known at compile time.
/// We bound S such that a mutable reference to S (&'a mut S)
/// must implement State and StateReader. The `for` keyword
/// indicates that the bound must hold for any lifetime 'a.
pub struct Sequencer<S>
where
for<'a> &'a mut S: State + StateReader,
Expand Down
16 changes: 10 additions & 6 deletions crates/sequencer/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct State {

/// State implementation for the sequencer. We use a mutable reference to the state
/// because this is what will be available during the implementation of the execution.
impl<'a> BlockifierState for &'a mut State {
impl BlockifierState for &mut State {
fn set_storage_at(
&mut self,
contract_address: ContractAddress,
Expand Down Expand Up @@ -90,8 +90,8 @@ impl<'a> BlockifierState for &'a mut State {
}
}

impl<'a> BlockifierStateReader for &'a mut State {
/// Default: 0 for an uninitialized contract address.
impl BlockifierStateReader for &mut State {
/// Default: 0 for an uninitialized contract address or key.
fn get_storage_at(
&mut self,
contract_address: ContractAddress,
Expand All @@ -113,7 +113,7 @@ impl<'a> BlockifierStateReader for &'a mut State {
.unwrap_or_default())
}

/// Default: 0 (uninitialized class hash) for an uninitialized contract address.
/// Default: 0 for an uninitialized contract address.
fn get_class_hash_at(&mut self, contract_address: ContractAddress) -> StateResult<ClassHash> {
Ok(self
.contracts
Expand All @@ -122,7 +122,9 @@ impl<'a> BlockifierStateReader for &'a mut State {
.unwrap_or_default())
}

/// Errors if the compiled class is not declared.
/// # Errors
///
/// If the compiled class is not declared.
fn get_compiled_contract_class(
&mut self,
class_hash: &ClassHash,
Expand All @@ -133,7 +135,9 @@ impl<'a> BlockifierStateReader for &'a mut State {
.ok_or_else(|| StateError::UndeclaredClassHash(class_hash.to_owned()))
}

/// Errors if the compiled class hash is not declared.
/// # Errors
///
/// If the compiled class hash is not declared.
fn get_compiled_class_hash(&mut self, class_hash: ClassHash) -> StateResult<CompiledClassHash> {
self.compiled_class_hashes
.get(&class_hash)
Expand Down

0 comments on commit f076803

Please sign in to comment.