near / read-rpc

Read-only NEAR RPC centralized-like performant solution
16 stars 4 forks source link

Add a JSON-RPC method to get a parent transaction hash for a given receipt ID #264

Closed khorolets closed 1 month ago

khorolets commented 1 month ago

Goal

We need a new method accepting receipt_id: String that will respond with either "not found" or some set of data about where the given receipt originated from:

Possible structure:

{
  "receipt_id", // Requested receipt id for consistency
  "parent_transaction_hash" // the hash of the transaction that initiated the events leading to the requested receipt creation
  "block_height" // height where the receipt was observed
  "shard_id" // ID of the shard the receipt was observed
}

Context

Matching receipts with the transaction they originated from is a long-standing issue for many developers who work closely with data. For all these years, people have invented different workarounds to handle this problem. When we started the ReadRPC project, we made the receipts_map table and collected data.

"CREATE TABLE IF NOT EXISTS receipts_map (
    receipt_id varchar,
    block_height varint,
    parent_transaction_hash varchar,
    shard_id varint,
    PRIMARY KEY (receipt_id)
)

Implementing this method is low-hanging fruit. It is not tough to implement but introduces a lot of value for the community.

Helpful references

Testing data

ScyllaDB doesn't provide any way to back up the data, and the feature might be needed for testing. I am @kobayurii is attaching the CSV with the data. We don't have a tool to propagate the data to the development setup from CSV. It's up to a developer to handle this. Sorry.

// Sample data receipts_map.csv

khorolets commented 1 month ago

Done by #266