-
Notifications
You must be signed in to change notification settings - Fork 188
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
Bump blockifier
to support Cairo 2.7
#2180
Merged
Merged
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
a46c723
workign bump for blockifier to ver 2.7. of cairo
kariy da1d5e0
wip
kariy bbcb978
wip
kariy 58de95e
wip
kariy 0dcfddf
wip
kariy 67eeb78
wip
kariy 6c488c2
wip
kariy 22d14c6
wip
kariy 013251e
wip
kariy 72fbbcf
wip
kariy b17ccac
wip
kariy be99879
no error
kariy d019c76
update resources log
kariy a6d4e34
remove commented code
kariy c19e325
clippy
kariy 74c5db1
fmt
kariy a674436
restore lockfile
kariy a786e57
remove comment
kariy 15e7e06
remove unused dep
kariy 5009503
fmt
kariy 8c6bffe
wip
kariy c7d6539
update blockifier rev
kariy ad83f47
fmt
kariy 772f55f
Update crates/katana/executor/src/implementation/blockifier/state.rs
kariy 603a3c5
Update crates/katana/executor/src/implementation/blockifier/state.rs
kariy 40c3b2c
apply suggestion
kariy 20d50ab
remove dbg
kariy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,5 @@ | ||
use std::collections::HashMap; | ||
|
||
use cairo_vm::vm::runners::builtin_runner::{ | ||
BITWISE_BUILTIN_NAME, EC_OP_BUILTIN_NAME, HASH_BUILTIN_NAME, KECCAK_BUILTIN_NAME, | ||
OUTPUT_BUILTIN_NAME, POSEIDON_BUILTIN_NAME, RANGE_CHECK_BUILTIN_NAME, | ||
SEGMENT_ARENA_BUILTIN_NAME, SIGNATURE_BUILTIN_NAME, | ||
}; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct BlockContextGenerator { | ||
pub block_timestamp_offset: i64, | ||
pub next_block_start_time: u64, | ||
} | ||
|
||
pub fn get_default_vm_resource_fee_cost() -> HashMap<String, f64> { | ||
HashMap::from([ | ||
(String::from("n_steps"), 1_f64), | ||
(HASH_BUILTIN_NAME.to_string(), 1_f64), | ||
(RANGE_CHECK_BUILTIN_NAME.to_string(), 1_f64), | ||
(SIGNATURE_BUILTIN_NAME.to_string(), 1_f64), | ||
(BITWISE_BUILTIN_NAME.to_string(), 1_f64), | ||
(POSEIDON_BUILTIN_NAME.to_string(), 1_f64), | ||
(OUTPUT_BUILTIN_NAME.to_string(), 1_f64), | ||
(EC_OP_BUILTIN_NAME.to_string(), 1_f64), | ||
(KECCAK_BUILTIN_NAME.to_string(), 1_f64), | ||
(SEGMENT_ARENA_BUILTIN_NAME.to_string(), 1_f64), | ||
]) | ||
} |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,9 @@ pub mod utils; | |
|
||
use std::num::NonZeroU128; | ||
|
||
use blockifier::block::{BlockInfo, GasPrices}; | ||
use blockifier::blockifier::block::{BlockInfo, GasPrices}; | ||
use blockifier::context::BlockContext; | ||
use blockifier::state::cached_state::{self, GlobalContractCache, MutRefState}; | ||
use blockifier::state::cached_state::{self, MutRefState}; | ||
use blockifier::state::state_api::StateReader; | ||
use katana_cairo::starknet_api::block::{BlockNumber, BlockTimestamp}; | ||
use katana_primitives::block::{ExecutableBlock, GasPrices as KatanaGasPrices, PartialHeader}; | ||
|
@@ -26,12 +26,6 @@ use crate::{ | |
|
||
pub(crate) const LOG_TARGET: &str = "katana::executor::blockifier"; | ||
|
||
// TODO: @kariy Which value should be considered here? I took the default | ||
// value from the previous implementation. | ||
// Previous: https://github.com/dojoengine/blockifier/blob/7459891173b64b148a7ce870c0b1d5907af15b8d/crates/blockifier/src/state/cached_state.rs#L731 | ||
// New code: https://github.com/starkware-libs/blockifier/blob/a6200402ab635d8a8e175f7f135be5914c960007/crates/blockifier/src/state/global_cache.rs#L17C11-L17C46 | ||
pub(crate) const CACHE_SIZE: usize = 100; | ||
|
||
#[derive(Debug)] | ||
pub struct BlockifierFactory { | ||
cfg: CfgEnv, | ||
|
@@ -111,8 +105,8 @@ impl<'a> StarknetVMProcessor<'a> { | |
// TODO: @kariy, not sure here if we should add some functions to alter it | ||
// instead of cloning. Or did I miss a function? | ||
// https://github.com/starkware-libs/blockifier/blob/a6200402ab635d8a8e175f7f135be5914c960007/crates/blockifier/src/context.rs#L23 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
let versioned_constants = self.block_context.versioned_constants(); | ||
let chain_info = self.block_context.chain_info(); | ||
let versioned_constants = self.block_context.versioned_constants().clone(); | ||
let chain_info = self.block_context.chain_info().clone(); | ||
let block_info = BlockInfo { | ||
block_number: number, | ||
block_timestamp: timestamp, | ||
|
@@ -127,7 +121,7 @@ impl<'a> StarknetVMProcessor<'a> { | |
}; | ||
|
||
self.block_context = | ||
BlockContext::new_unchecked(&block_info, chain_info, versioned_constants); | ||
BlockContext::new(block_info, chain_info, versioned_constants, Default::default()); | ||
} | ||
|
||
fn simulate_with<F, T>( | ||
|
@@ -140,11 +134,8 @@ impl<'a> StarknetVMProcessor<'a> { | |
F: FnMut(&mut dyn StateReader, (TxWithHash, ExecutionResult)) -> T, | ||
{ | ||
let block_context = &self.block_context; | ||
let state = &mut self.state.0.write().inner; | ||
let mut state = cached_state::CachedState::new( | ||
MutRefState::new(state), | ||
GlobalContractCache::new(CACHE_SIZE), | ||
); | ||
let state = &mut self.state.0.lock().inner; | ||
let mut state = cached_state::CachedState::new(MutRefState::new(state)); | ||
|
||
let mut results = Vec::with_capacity(transactions.len()); | ||
for exec_tx in transactions { | ||
|
@@ -170,7 +161,7 @@ impl<'a> BlockExecutor<'a> for StarknetVMProcessor<'a> { | |
) -> ExecutorResult<()> { | ||
let block_context = &self.block_context; | ||
let flags = &self.simulation_flags; | ||
let mut state = self.state.write(); | ||
let mut state = self.state.0.lock(); | ||
|
||
for exec_tx in transactions { | ||
// Collect class artifacts if its a declare tx | ||
|
@@ -187,7 +178,8 @@ impl<'a> BlockExecutor<'a> for StarknetVMProcessor<'a> { | |
match &res { | ||
ExecutionResult::Success { receipt, trace } => { | ||
self.stats.l1_gas_used += receipt.fee().gas_consumed; | ||
self.stats.cairo_steps_used += receipt.resources_used().steps as u128; | ||
self.stats.cairo_steps_used += | ||
receipt.resources_used().vm_resources.n_steps as u128; | ||
|
||
if let Some(reason) = receipt.revert_reason() { | ||
info!(target: LOG_TARGET, %reason, "Transaction reverted."); | ||
|
@@ -280,7 +272,7 @@ impl ExecutorExt for StarknetVMProcessor<'_> { | |
|
||
fn call(&self, call: EntryPointCall) -> Result<Vec<FieldElement>, ExecutionError> { | ||
let block_context = &self.block_context; | ||
let mut state = self.state.0.write(); | ||
let mut state = self.state.0.lock(); | ||
let state = MutRefState::new(&mut state.inner); | ||
let retdata = utils::call(call, state, block_context, 1_000_000_000)?; | ||
Ok(retdata) | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Curious, is this
CACHE_SIZE
something that we want to customize at some point, or we shouldn't care more about it?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.
unsure but they have removed the
GlobalContractCache
when creating a newCachedState
which what we usedCACHE_SIZE
before.this was before:
https://github.com/dojoengine/blockifier/blob/57c115864b5d2e9876efe289bd3dfbf05744a76b/crates/blockifier/src/state/cached_state.rs#L40