lambdaclass / starknet-replay

Provides a way of reading a real Starknet State, so you can re-execute an existing transaction in any of the Starknet networks in an easy way
Apache License 2.0
6 stars 1 forks source link

Add error reason to the logs #56

Closed FrancoGiachetta closed 2 months ago

FrancoGiachetta commented 2 months ago

This PR adds the root of the error, if it was the case. It could be because the execution status diverged or the events and messages count. Due to this, it shows which one of the four ( there could be a case where both events and messages count fail) has happend, having more precedence the execution status error.

github-actions[bot] commented 2 months ago

✅ Code is now correctly formatted.

FrancoGiachetta commented 2 months ago

Update: Changed the events count from the execution to be 1 more than the actual value. This is because, currently, the events counting is missing the events the produced by the main call, including just the one produced by its inner_calls:

sequencer/crates/blockifier/src/transaction/objects.rs:435

fn calculate_events_resources<'a>(
        call_infos: impl Iterator<Item = &'a CallInfo> + Clone,
    ) -> (usize, u128, u128) {
        let mut total_event_keys = 0;
        let mut total_event_data_size = 0;
        let mut n_events = 0;
        for call_info in call_infos.clone() {
            for inner_call in call_info.iter() {
                for OrderedEvent { event, .. } in inner_call.execution.events.iter() {
                    total_event_data_size += u128_from_usize(event.data.0.len());
                    total_event_keys += u128_from_usize(event.keys.len());
                }
                n_events += inner_call.execution.events.len();
            }
        }
        (n_events, total_event_keys, total_event_data_size)
    }

Due to this, the events count from the execution would never match the ones from the rpc. Thus, it would always show an error message.