Skip to content

bug: missing field class_commitment while querying pathfinder_getClassProof #472

Description

@whichqua

SNOS version: V0_13_2

Current behavior:
Supposing I am making the following RPC call:

{
  "id": "0",
  "jsonrpc": "2.0",
  "method": "pathfinder_getClassProof",
  "params": {
    "block_id": {
      "block_number": 624
    },
    "class_hash": "0x1484c93b9d6cf61614d698ed069b3c6992c32549194fc3465258c2194734189"
  }
}

Pathfinder may return the following response:

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "class_proof": [
      {
        "edge": {
          "child": "0x5b1cf4fae08fc3e2ab46133cae791bf38337964146736e6baf1b9dbc92bb872",
          "path": {
            "len": 251,
            "value": "0x1484c93b9d6cf61614d698ed069b3c6992c32549194fc3465258c2194734189"
          }
        }
      }
    ]
  }
}

The json above fails to parse because we use the following struct for the response:

#[derive(Clone, Deserialize)]
pub struct PathfinderClassProof {
    pub class_commitment: Felt,
    pub class_proof: Vec<TrieNode>,
}

This panics, because the response does not include a class_commitment

thread 'main' panicked at snos/crates/bin/prove_block/src/lib.rs:285:78:
Failed to fetch class proofs: ReqwestError(reqwest::Error { kind: Decode, source: Error("missing field `class_commitment`", line: 1, column: 234) })

Expected behavior:
Since there are cases where the response is missing the class_commitment then we would need to read the response as:

#[derive(Clone, Deserialize)]
pub struct PathfinderClassProof {
    pub class_commitment: Option<Felt>,
    pub class_proof: Vec<TrieNode>,
}

Steps to reproduce:

  1. Setup and run Madara on port 9944
  2. Launch Pathfinder and connect it to Madara's feeder gateway:
cargo run --bin pathfinder -- \
  --network custom \
  --chain-id MADARA_DEVNET \
  --ethereum.url wss://eth-sepolia.g.alchemy.com/.. \
  --gateway-url http://localhost:8080/gateway \
  --feeder-gateway-url http://localhost:8080/feeder_gateway \
  --storage.state-tries archive \
  --data-directory ~/pathfinder_db/ \
  --http-rpc 127.0.0.1:9545
  1. Find the blocks immediately after the declare_v0 txn

Related code:
Here is a script to find blocks with this issue, you can adjust it as necessary

#!/bin/bash

# Output CSV file
output_file="failed_blocks.csv"

# Initialize the CSV file with headers
# echo "block_number" > $output_file

# Loop through blocks 1 to 100
for block_number in {1..100}
do
    # Run the command for the current block
    if ! cargo run -p prove_block -- --block-number $block_number; then
        # If the command fails, log the block number to the CSV
        echo "$block_number" >> $output_file
    fi
done

echo "Script finished. Failed block numbers are saved in $output_file."

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions