Skip to content

Commit

Permalink
Merge pull request eqlabs#2118 from eqlabs/krisztian/fix-rpc-receipt-…
Browse files Browse the repository at this point in the history
…serialization-for-zero-steps

fix(rpc/dto/receipt): allow `steps` to be zero in COMPUTATION_RESOURCES
  • Loading branch information
kkovaacs authored Jul 11, 2024
2 parents 6b3e462 + f6aebab commit b373bb1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Pathfinder exits with an error when detecting a one-block reorg if `--storage.state-tries` is set to `0`.
- Pathfinder returns an internal error for `starknet_getTransactionReceipt` requests where `steps` would be zero in COMPUTATION_RESOURCES.

## [0.13.2] - 2024-06-24

Expand Down
8 changes: 4 additions & 4 deletions crates/rpc/src/dto/receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,10 @@ impl SerializeForVersion for ComputationResources<'_> {
fn serialize(&self, serializer: Serializer) -> Result<serialize::Ok, serialize::Error> {
use std::num::NonZeroU64;

// All values are required to be non-zero. Steps MUST be non-zero as it is
// required, however the rest are simply skipped if zero.
let steps = NonZeroU64::new(self.0.n_steps)
.ok_or_else(|| serde_json::error::Error::custom("steps was zero which is invalid"))?;
// We're technically breaking the spec here if `steps` is zero but turns out
// there _are_ transactions on Starknet mainnet with steps being zero:
// https://starkscan.co/tx/0x04026b1598e5915737d439e8b8493cce9e47a5a334948e28f55c391bc2e0c2e2
let steps = self.0.n_steps;
let memory_holes = NonZeroU64::new(self.0.n_memory_holes);
let range_check = NonZeroU64::new(self.0.builtins.range_check);
let pedersen = NonZeroU64::new(self.0.builtins.pedersen);
Expand Down

0 comments on commit b373bb1

Please sign in to comment.