-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* commit trait * execution trait * implement commit and execution for sequencer * test one transaction on sequencer * fix constants * refactor committer * add cairo 1 contracts * update error handling * add cairo 1 test * update based on comments
- Loading branch information
Showing
16 changed files
with
21,706 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use blockifier::state::{ | ||
cached_state::CachedState, | ||
state_api::{State as BlockifierState, StateReader as BlockifierStateReader, StateResult}, | ||
}; | ||
|
||
pub trait Committer<S> | ||
where | ||
for<'a> &'a mut S: BlockifierState + BlockifierStateReader, | ||
{ | ||
fn commit(cached_state: &mut CachedState<&mut S>) -> StateResult<()> { | ||
let diff = cached_state.to_state_diff(); | ||
for (address, class_hash) in diff.address_to_class_hash { | ||
cached_state.state.set_class_hash_at(address, class_hash)?; | ||
} | ||
for (address, _) in diff.address_to_nonce { | ||
cached_state.state.increment_nonce(address)?; | ||
} | ||
for (address, storage_updates) in diff.storage_updates { | ||
for (k, v) in storage_updates { | ||
cached_state.state.set_storage_at(address, k, v); | ||
} | ||
} | ||
for (class_hash, compiled_class_hash) in diff.class_hash_to_compiled_class_hash { | ||
cached_state | ||
.state | ||
.set_compiled_class_hash(class_hash, compiled_class_hash)?; | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use blockifier::transaction::{ | ||
errors::TransactionExecutionError, transaction_execution::Transaction, | ||
}; | ||
|
||
pub trait Execution { | ||
fn execute(&mut self, transaction: Transaction) -> Result<(), TransactionExecutionError>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
pub mod commit; | ||
pub mod constants; | ||
pub mod execution; | ||
pub mod sequencer; | ||
pub mod state; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.