Skip to content

Commit

Permalink
Merge pull request #2500 from eqlabs/krisztian/add-is-reverted-flag-t…
Browse files Browse the repository at this point in the history
…o-tx-traces

feat(rpc/trace): add `is_reverted` flag to `FUNCTION_INVOCATION`
  • Loading branch information
kkovaacs authored Jan 21, 2025
2 parents 243842b + 31a6ee1 commit f3edbd7
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 219 deletions.
2 changes: 2 additions & 0 deletions crates/executor/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ pub struct FunctionInvocation {
pub result: Vec<Felt>,
pub computation_resources: ComputationResources,
pub execution_resources: InnerCallExecutionResources,
pub is_reverted: bool,
}

#[derive(Debug, Clone, Eq, PartialEq)]
Expand Down Expand Up @@ -384,6 +385,7 @@ impl FunctionInvocation {
l1_gas: gas_vector.l1_gas.0.into(),
l2_gas: gas_vector.l2_gas.0.into(),
},
is_reverted: call_info.execution.failed,
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions crates/rpc/src/dto/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,13 @@ impl crate::dto::SerializeForVersion for &pathfinder_executor::types::FunctionIn
serializer.serialize_iter("messages", self.messages.len(), &mut self.messages.iter())?;
serializer.serialize_iter("result", self.result.len(), &mut self.result.iter())?;
match serializer.version {
RpcVersion::V08 => serializer.serialize_field(
"execution_resources",
&InnerCallExecutionResources(&self.execution_resources),
)?,
RpcVersion::V08 => {
serializer.serialize_field(
"execution_resources",
&InnerCallExecutionResources(&self.execution_resources),
)?;
serializer.serialize_field("is_reverted", &self.is_reverted)?;
}
_ => serializer.serialize_field(
"execution_resources",
&ComputationResources(&self.computation_resources),
Expand Down
18 changes: 17 additions & 1 deletion crates/rpc/src/method/simulate_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ pub(crate) mod tests {
execution_resources: pathfinder_executor::types::InnerCallExecutionResources::default(),
internal_calls: vec![],
computation_resources: pathfinder_executor::types::ComputationResources::default(),
is_reverted: false,
}),
validate_invocation: Some(
pathfinder_executor::types::FunctionInvocation {
Expand All @@ -344,7 +345,8 @@ pub(crate) mod tests {
computation_resources: pathfinder_executor::types::ComputationResources{
steps: 13,
..Default::default()
}
},
is_reverted: false,
},
),
fee_transfer_invocation: None,
Expand Down Expand Up @@ -446,6 +448,7 @@ pub(crate) mod tests {
steps: 12,
..Default::default()
},
is_reverted: false,
}
),
fee_transfer_invocation: Some(
Expand Down Expand Up @@ -484,6 +487,7 @@ pub(crate) mod tests {
pedersen_builtin_applications: 4,
..Default::default()
},
is_reverted: false,
}
),
state_diff: pathfinder_executor::types::StateDiff {
Expand Down Expand Up @@ -939,6 +943,7 @@ pub(crate) mod tests {
l1_gas: 4,
l2_gas: 0,
},
is_reverted: false,
}
}

Expand All @@ -962,6 +967,7 @@ pub(crate) mod tests {
l1_gas: 1,
l2_gas: 0,
},
is_reverted: false,
}
}

Expand Down Expand Up @@ -1242,6 +1248,7 @@ pub(crate) mod tests {
l1_gas: 1,
l2_gas: 0,
},
is_reverted: false,
}
}

Expand Down Expand Up @@ -1271,6 +1278,7 @@ pub(crate) mod tests {
result: vec![],
computation_resources: pathfinder_executor::types::ComputationResources::default(),
execution_resources: pathfinder_executor::types::InnerCallExecutionResources::default(),
is_reverted: false,
},
],
class_hash: Some(UNIVERSAL_DEPLOYER_CLASS_HASH.0),
Expand Down Expand Up @@ -1315,6 +1323,7 @@ pub(crate) mod tests {
..Default::default()
},
execution_resources: pathfinder_executor::types::InnerCallExecutionResources { l1_gas: 4, l2_gas: 0 },
is_reverted: false,
}
],
class_hash: Some(DUMMY_ACCOUNT_CLASS_HASH.0),
Expand Down Expand Up @@ -1344,6 +1353,7 @@ pub(crate) mod tests {
l1_gas: 6,
l2_gas: 0,
},
is_reverted: false,
}
}

Expand Down Expand Up @@ -1384,6 +1394,7 @@ pub(crate) mod tests {
l1_gas: 4,
l2_gas: 0,
},
is_reverted: false,
}
}

Expand Down Expand Up @@ -1638,6 +1649,7 @@ pub(crate) mod tests {
l2_gas: 0,
},
computation_resources: invoke_validate_computation_resources(),
is_reverted: false,
}
}

Expand Down Expand Up @@ -1670,6 +1682,7 @@ pub(crate) mod tests {
l1_gas: 1,
l2_gas: 0,
},
is_reverted: false,
}],
class_hash: Some(DUMMY_ACCOUNT_CLASS_HASH.0),
entry_point_type: pathfinder_executor::types::EntryPointType::External,
Expand All @@ -1689,6 +1702,7 @@ pub(crate) mod tests {
l1_gas: 3,
l2_gas: 0,
},
is_reverted: false,
}
}

Expand Down Expand Up @@ -1728,6 +1742,7 @@ pub(crate) mod tests {
l1_gas: 4,
l2_gas: 0,
},
is_reverted: false,
}
}

Expand Down Expand Up @@ -1916,6 +1931,7 @@ pub(crate) mod tests {
computation_resources: invoke_fee_transfer_computation_resources(),
execution_resources:
pathfinder_executor::types::InnerCallExecutionResources::default(),
is_reverted: false,
}
}

Expand Down
3 changes: 3 additions & 0 deletions crates/rpc/src/method/trace_block_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,9 @@ fn map_gateway_function_invocation(
l1_gas: gas_consumed.l1_gas,
l2_gas: gas_consumed.l2_gas.unwrap_or_default(),
},
// Pre-0.13.4 failures in individual calls are not possible -- the whole TX is reverted in
// that case.
is_reverted: false,
})
}

Expand Down
Loading

0 comments on commit f3edbd7

Please sign in to comment.