-
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.
* implement blockifier * move blockifier from workspace to maintain two versions * view toml * update manifests * lock * update from comments * add rust doc, update should panic * remove unnecessary comments * rename constants + TODO
- Loading branch information
Showing
9 changed files
with
365 additions
and
125 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#[cfg(test)] | ||
pub mod test_constants { | ||
use starknet::core::types::FieldElement; | ||
use starknet_api::{ | ||
block::{BlockNumber, BlockTimestamp}, | ||
core::{ClassHash, CompiledClassHash, ContractAddress, PatriciaKey}, | ||
hash::StarkFelt, | ||
}; | ||
|
||
lazy_static::lazy_static! { | ||
pub static ref TEST_CONTRACT_ADDRESS: ContractAddress = ContractAddress(*ONE_PATRICIA); | ||
pub static ref TEST_CONTRACT_ACCOUNT: ContractAddress = ContractAddress(*TWO_PATRICIA); | ||
pub static ref TEST_ADDRESS: StarkFelt = *ONE_FELT; | ||
pub static ref TEST_CONTRACT: StarkFelt = *TWO_FELT; | ||
pub static ref SENDER_ADDRESS: FieldElement = FieldElement::from(2u8); | ||
pub static ref SEQUENCER_ADDRESS: ContractAddress = ContractAddress(TryInto::<PatriciaKey>::try_into(StarkFelt::from(1234u16)).unwrap()); | ||
pub static ref FEE_TOKEN_ADDRESS: ContractAddress = ContractAddress(TryInto::<PatriciaKey>::try_into(StarkFelt::from(12345u16)).unwrap()); | ||
|
||
pub static ref ONE_FELT: StarkFelt = StarkFelt::from(1u8); | ||
pub static ref TWO_FELT: StarkFelt = StarkFelt::from(2u8); | ||
pub static ref ONE_PATRICIA: PatriciaKey = TryInto::<PatriciaKey>::try_into(*ONE_FELT).unwrap(); | ||
pub static ref TWO_PATRICIA: PatriciaKey = TryInto::<PatriciaKey>::try_into(*TWO_FELT).unwrap(); | ||
pub static ref ONE_CLASS_HASH: ClassHash = ClassHash(*ONE_FELT); | ||
pub static ref TWO_CLASS_HASH: ClassHash = ClassHash(*TWO_FELT); | ||
pub static ref ONE_COMPILED_CLASS_HASH: CompiledClassHash = CompiledClassHash(*ONE_FELT); | ||
pub static ref ONE_BLOCK_NUMBER: BlockNumber = BlockNumber(1); | ||
pub static ref ONE_BLOCK_TIMESTAMP: BlockTimestamp = BlockTimestamp(1); | ||
} | ||
} |
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,3 @@ | ||
pub mod config; | ||
pub mod constants; | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
use crate::config::SequencerConfig; | ||
use blockifier::block_context::BlockContext; | ||
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. | ||
pub struct Sequencer<S: State + StateReader> { | ||
pub config: SequencerConfig, | ||
/// 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. | ||
/// For more details, check out https://doc.rust-lang.org/nomicon/hrtb.html | ||
pub struct Sequencer<S> | ||
where | ||
for<'a> &'a mut S: State + StateReader, | ||
{ | ||
pub context: BlockContext, | ||
pub state: S, | ||
} | ||
|
||
impl<S: State + StateReader> Sequencer<S> { | ||
impl<S> Sequencer<S> | ||
where | ||
for<'a> &'a mut S: State + StateReader, | ||
{ | ||
/// Creates a new Sequencer instance. | ||
pub fn new(config: SequencerConfig, state: S) -> Self { | ||
Self { config, state } | ||
pub fn new(context: BlockContext, state: S) -> Self { | ||
Self { context, 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