Skip to content

Commit

Permalink
Merge branch 'update-sequencer' into update-seq
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianGCalderon committed Dec 2, 2024
2 parents ee3925c + 6153a93 commit 2b0daa8
Show file tree
Hide file tree
Showing 11 changed files with 301 additions and 295 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
MLIR_SYS_190_PREFIX: /usr/lib/llvm-19/
LLVM_SYS_191_PREFIX: /usr/lib/llvm-19/
TABLEGEN_190_PREFIX: /usr/lib/llvm-19/
CAIRO_NATIVE_RUNTIME_LIBRARY: libcairo_native_runtime.a
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@1.82.0
Expand Down Expand Up @@ -152,7 +153,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: lambdaclass/cairo_native
ref: ae234bac7eb4b7f70715b3832363a843348c6927
ref: 76e83965d3bf1252eb6c68200a3accd5fd1ec004
path: cairo_native
- name: Build Cairo Native Runtime Library
shell: bash
Expand Down Expand Up @@ -189,7 +190,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: lambdaclass/cairo_native
ref: ae234bac7eb4b7f70715b3832363a843348c6927
ref: 76e83965d3bf1252eb6c68200a3accd5fd1ec004
path: cairo_native
- name: Build Cairo Native Runtime Library
run: |
Expand Down
11 changes: 6 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ tracing = "0.1"
serde_json = "1.0.116"
serde_with = "3.11.0"
serde = "1.0.197"
cairo-native = { git = "https://github.com/lambdaclass/cairo_native", rev = "5e60089288c461eca98bf3dbe03cc882778ff677" }
cairo-native = "=0.2.4"
# Sequencer Dependencies
starknet_api = { git = "https://github.com/lambdaclass/sequencer", branch = "native2.9.x" }
blockifier = { git = "https://github.com/lambdaclass/sequencer", branch = "native2.9.x" }
starknet_gateway = { git = "https://github.com/lambdaclass/sequencer", branch = "native2.9.x" }
starknet_api = { git = "https://github.com/lambdaclass/sequencer.git", branch = "update-main-2" } # main
blockifier = { git = "https://github.com/lambdaclass/sequencer.git", branch = "update-main-2", features = ["cairo_native"] } # main
starknet_gateway = { git = "https://github.com/lambdaclass/sequencer.git", branch = "update-main-2" } # main
blockifier_reexecution = { git = "https://github.com/lambdaclass/sequencer.git", branch = "update-main-2" } # main

[patch.'https://github.com/lambdaclass/cairo_native']
cairo-native = { git = "https://github.com/lambdaclass//cairo_native.git", rev = "5e60089288c461eca98bf3dbe03cc882778ff677" }
cairo-native = "=0.2.4"
9 changes: 4 additions & 5 deletions replay/src/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::time::Instant;

use blockifier::{
context::BlockContext,
execution::contract_class::RunnableCompiledClass,
state::{cached_state::CachedState, state_api::StateReader},
};
use rpc_state_reader::{
Expand Down Expand Up @@ -176,13 +177,11 @@ impl<S: StateReader> StateReader for OptionalStateReader<S> {
self.get_inner().get_class_hash_at(contract_address)
}

fn get_compiled_contract_class(
fn get_compiled_class(
&self,
class_hash: starknet_api::core::ClassHash,
) -> blockifier::state::state_api::StateResult<
blockifier::execution::contract_class::ContractClass,
> {
self.get_inner().get_compiled_contract_class(class_hash)
) -> blockifier::state::state_api::StateResult<RunnableCompiledClass> {
self.get_inner().get_compiled_class(class_hash)
}

fn get_compiled_class_hash(
Expand Down
32 changes: 19 additions & 13 deletions replay/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use blockifier::state::cached_state::CachedState;
use blockifier::state::errors::StateError;
use blockifier::transaction::objects::TransactionExecutionInfo;
use blockifier::transaction::objects::{RevertError, TransactionExecutionInfo};
use clap::{Parser, Subcommand};

use rpc_state_reader::execution::execute_tx_configurable;
Expand Down Expand Up @@ -359,8 +359,8 @@ fn compare_execution(

let events_and_msgs = format!(
"{{ events_number: {}, l2_to_l1_messages_number: {} }}",
exec_rsc.n_events + 1,
exec_rsc.message_cost_info.l2_to_l1_payload_lengths.len(),
exec_rsc.archival_data.event_summary.n_events + 1,
exec_rsc.messages.l2_to_l1_payload_lengths.len(),
);
let rpc_events_and_msgs = format!(
"{{ events_number: {}, l2_to_l1_messages_number: {} }}",
Expand All @@ -370,25 +370,31 @@ fn compare_execution(

// currently adding 1 because the sequencer is counting only the
// events produced by the inner calls of a callinfo
let events_match = exec_rsc.n_events + 1 == rpc_receipt.events.len();
let msgs_match = rpc_receipt.messages_sent.len()
== exec_rsc.message_cost_info.l2_to_l1_payload_lengths.len();
let events_match =
exec_rsc.archival_data.event_summary.n_events + 1 == rpc_receipt.events.len();
let msgs_match =
rpc_receipt.messages_sent.len() == exec_rsc.messages.l2_to_l1_payload_lengths.len();

let events_msgs_match = events_match && msgs_match;

let state_changes = exec_rsc.state_changes_for_fee;
let state_changes = exec_rsc.state.state_changes_for_fee;
let state_changes_for_fee_str = format!(
"{{ n_class_hash_updates: {}, n_compiled_class_hash_updates: {}, n_modified_contracts: {}, n_storage_updates: {} }}",
state_changes.n_class_hash_updates,
state_changes.n_compiled_class_hash_updates,
state_changes.n_modified_contracts,
state_changes.n_storage_updates
state_changes.state_changes_count.n_class_hash_updates,
state_changes.state_changes_count.n_compiled_class_hash_updates,
state_changes.state_changes_count.n_modified_contracts,
state_changes.state_changes_count.n_storage_updates
);

let execution_gas = execution.receipt.fee;
let rpc_gas = rpc_receipt.actual_fee;
debug!(?execution_gas, ?rpc_gas, "execution actual fee");

let revert_error = execution.revert_error.map(|err| match err {
RevertError::Execution(e) => e.to_string(),
RevertError::PostExecution(p) => p.to_string(),
});

if !status_matches || !events_msgs_match {
let root_of_error = if !status_matches {
"EXECUTION STATUS DIVERGED"
Expand All @@ -404,7 +410,7 @@ fn compare_execution(
reverted,
rpc_reverted,
root_of_error = root_of_error,
execution_error_message = execution.revert_error,
execution_error_message = revert_error,
n_events_and_messages = events_and_msgs,
rpc_n_events_and_msgs = rpc_events_and_msgs,
da_gas = da_gas_str,
Expand All @@ -417,7 +423,7 @@ fn compare_execution(
info!(
reverted,
rpc_reverted,
execution_error_message = execution.revert_error,
execution_error_message = revert_error,
n_events_and_messages = events_and_msgs,
rpc_n_events_and_msgs = rpc_events_and_msgs,
da_gas = da_gas_str,
Expand Down
37 changes: 26 additions & 11 deletions replay/src/state_dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@ use blockifier::{
cached_state::{CachedState, StateMaps, StorageEntry},
state_api::StateReader,
},
transaction::{
errors::TransactionExecutionError,
objects::{GasVector, TransactionExecutionInfo},
},
transaction::{errors::TransactionExecutionError, objects::TransactionExecutionInfo},
};
use serde::{Deserialize, Serialize};
use serde_with::serde_as;
use starknet_api::{
contract_class::EntryPointType,
core::{ClassHash, CompiledClassHash, ContractAddress, EntryPointSelector, Nonce},
deprecated_contract_class::EntryPointType,
execution_resources::GasVector,
state::StorageKey,
transaction::Calldata,
transaction::fields::Calldata,
};
use starknet_types_core::felt::Felt;

Expand All @@ -38,7 +36,7 @@ pub fn dump_state_diff(
let _ = fs::create_dir_all(parent);
}

let state_maps = SerializableStateMaps::from(state.to_state_diff()?);
let state_maps = SerializableStateMaps::from(state.get_initial_reads()?);
let execution_info = SerializableExecutionInfo::new(execution_info);
let info = Info {
execution_info,
Expand Down Expand Up @@ -123,6 +121,7 @@ struct SerializableExecutionInfo {

impl SerializableExecutionInfo {
pub fn new(execution_info: &TransactionExecutionInfo) -> Self {
let reverted = execution_info.revert_error.clone().map(|f| f.to_string());
Self {
validate_call_info: execution_info
.validate_call_info
Expand All @@ -136,62 +135,78 @@ impl SerializableExecutionInfo {
.fee_transfer_call_info
.clone()
.map(From::<CallInfo>::from),
reverted: execution_info.revert_error.clone(),
reverted,
receipt: SerializableTransactionReceipt {
resources: SerializableTransactionResources {
starknet_resources: SerializableStarknetResources {
calldata_length: execution_info
.receipt
.resources
.starknet_resources
.archival_data
.calldata_length,
state_changes_for_fee: SerializableStateChangesCount {
n_storage_updates: execution_info
.receipt
.resources
.starknet_resources
.state
.state_changes_for_fee
.state_changes_count
.n_storage_updates,
n_class_hash_updates: execution_info
.receipt
.resources
.starknet_resources
.state
.state_changes_for_fee
.state_changes_count
.n_class_hash_updates,
n_compiled_class_hash_updates: execution_info
.receipt
.resources
.starknet_resources
.state
.state_changes_for_fee
.state_changes_count
.n_compiled_class_hash_updates,
n_modified_contracts: execution_info
.receipt
.resources
.starknet_resources
.state
.state_changes_for_fee
.state_changes_count
.n_modified_contracts,
},
message_cost_info: SerializableMessageL1CostInfo {
l2_to_l1_payload_lengths: execution_info
.receipt
.resources
.starknet_resources
.message_cost_info
.messages
.l2_to_l1_payload_lengths
.clone(),
message_segment_length: execution_info
.receipt
.resources
.starknet_resources
.message_cost_info
.messages
.message_segment_length,
},
l1_handler_payload_size: execution_info
.receipt
.resources
.starknet_resources
.messages
.l1_handler_payload_size,
n_events: execution_info.receipt.resources.starknet_resources.n_events,
n_events: execution_info
.receipt
.resources
.starknet_resources
.archival_data
.event_summary
.n_events,
},
},
da_gas: execution_info.receipt.da_gas,
Expand Down
7 changes: 4 additions & 3 deletions rpc-state-reader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ serde_json = { version = "1.0", features = [
"raw_value",
] }
starknet_api = {workspace = true}
cairo-lang-starknet-classes = "2.9.0-dev.0"
cairo-lang-utils = "2.9.0-dev.0"
cairo-lang-starknet-classes = "=2.9.0-dev.0"
cairo-lang-utils = "=2.9.0-dev.0"
cairo-native = { workspace = true }
starknet = "0.7.0"
starknet = "0.6.0"
flate2 = "1.0.25"
cairo-vm = "1.0.0-rc5"
blockifier = { workspace = true }
blockifier_reexecution = { workspace = true }
starknet_gateway = { workspace = true }
tracing = { workspace = true }

Expand Down
Loading

0 comments on commit 2b0daa8

Please sign in to comment.