没有收据但有 receipt_outcome 的 NEAR 交易

NEAR transaction without receipt but with receipt_outcome

使用EXPERIMENTAL_tx_status方法查询archival node交易时,有些交易没有receipts而有receipts_outcome。这怎么可能,该交易与其他交易有何不同?

如果我没理解错的话,receipts_outcome是应用receipts的结果。根据explorer,这笔交易有Convert Transaction To Receipt部分,所以应该会产生一些收据。

根据documentation

A Receipt is the only actionable object in the system. When we talk about "processing a transaction" on the NEAR platform, this eventually means "applying receipts" at some point.

A good mental model is to think of a Receipt as a paid message to be executed at the destination (receiver). And a Transaction is an externally issued request to create the Receipt (there is a 1 to 1 relationship).

我的查询

{
  "jsonrpc": "2.0",
  "id": "2",
  "method": "EXPERIMENTAL_tx_status",
  "params": ["7beNxrbHxMRspJWT9NeEVwx719kVcmY9tRdPG9SYro26", "bumbleee99.near"]
}

回应

{
    "jsonrpc": "2.0",
    "result": {
        "status": {
            "SuccessValue": ""
        },
        "transaction": {
            "signer_id": "bumbleee99.near",
            "public_key": "ed25519:DFM5GRGbpNkk4XkhcFnRUFeKG8a3nzTH8NwZp754pC48",
            "nonce": 59080995000003,
            "receiver_id": "bumbleee99.near",
            "actions": [
                {
                    "AddKey": {
                        "public_key": "ed25519:CUoNs153GHrPZ9F8HpvhzFr1mwuUFUdGQsRNE2CTNjVH",
                        "access_key": {
                            "nonce": 0,
                            "permission": "FullAccess"
                        }
                    }
                }
            ],
            "signature": "ed25519:15v34qoyCHSvSL5uLcaPqD9vXvjcPrCaZVStCMms8e58C62z2UHiazwUXzHajPEgdHpwn7s4J9dd5UPmtvzbYgM",
            "hash": "7beNxrbHxMRspJWT9NeEVwx719kVcmY9tRdPG9SYro26"
        },
        "transaction_outcome": {
            "proof": [
                {
                    "hash": "ECKDm5FVhzit7Wqs9sEyBB9NtuTrVRZmWwcxkkg2yUh4",
                    "direction": "Right"
                },
                {
                    "hash": "E4VXdwsNj3fZCbP6y9YH3M5oZHPDcdArqU9kbZJa95Qp",
                    "direction": "Right"
                }
            ],
            "block_hash": "ASY6HgDUQUXUa99L7dPEfghKEnEk5SNkwQrx24u3Fobz",
            "id": "7beNxrbHxMRspJWT9NeEVwx719kVcmY9tRdPG9SYro26",
            "outcome": {
                "logs": [],
                "receipt_ids": [
                    "JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ"
                ],
                "gas_burnt": 209824625000,
                "tokens_burnt": "20982462500000000000",
                "executor_id": "bumbleee99.near",
                "status": {
                    "SuccessReceiptId": "JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ"
                },
                "metadata": {
                    "version": 1,
                    "gas_profile": null
                }
            }
        },
        "receipts_outcome": [
            {
                "proof": [
                    {
                        "hash": "8RwCWE9HgqenPKv8JW9eg2iSLMaQW82wvebYSfjPbdTY",
                        "direction": "Left"
                    },
                    {
                        "hash": "E4VXdwsNj3fZCbP6y9YH3M5oZHPDcdArqU9kbZJa95Qp",
                        "direction": "Right"
                    }
                ],
                "block_hash": "ASY6HgDUQUXUa99L7dPEfghKEnEk5SNkwQrx24u3Fobz",
                "id": "JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ",
                "outcome": {
                    "logs": [],
                    "receipt_ids": [],
                    "gas_burnt": 209824625000,
                    "tokens_burnt": "20982462500000000000",
                    "executor_id": "bumbleee99.near",
                    "status": {
                        "SuccessValue": ""
                    },
                    "metadata": {
                        "version": 1,
                        "gas_profile": []
                    }
                }
            }
        ],
        "receipts": []
    },
    "id": "2"
}

您可以看到 transaction_outcome.outcome.receipt_idstransaction_outcome.outcome.status 都指向 ID 为 JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ 的收据。我试过使用 EXPERIMENTAL_receipt 方法查询有关此收据的节点

{
  "jsonrpc": "2.0",
  "id": "2",
  "method": "EXPERIMENTAL_receipt",
  "params": {"receipt_id": "JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ"}
}

但节点 returns 错误表明没有给定 ID 的收据

{
    "jsonrpc": "2.0",
    "error": {
        "name": "HANDLER_ERROR",
        "cause": {
            "name": "UNKNOWN_RECEIPT",
            "info": {
                "receipt_id": "JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ"
            }
        },
        "code": -32000,
        "message": "Server error",
        "data": {
            "name": "UNKNOWN_RECEIPT",
            "info": {
                "receipt_id": "JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ"
            }
        }
    },
    "id": "2"
}

TL;DR 收据是本地收据


您示例中的交易是一个简单的 AddKey 操作,其中发送方是接收方(记住这一点,这很重要)

  1. “执行”交易(意思是将交易转为Receipt)
  2. 应用收据

由于交易转换为收据的结果是您的transaction_outcome

"outcome": {
  "receipt_ids": [
    "JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ"
  ],
  "status": {
    "SuccessReceiptId": "JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ"
  },

这张收据即将被应用,predecessor_idreceiver_id相等。在 nearcore 中,此类收据称为 本地收据 (先生 - sender-is-receiver)并且这些收据未存储在 nearcore 数据库中。

We emulate them on NEAR Indexer Framework side(这就是为什么您可以在 NEAR Explorer 的交易详情页面上看到收据 JDnBrxh6L9KFgVUEg6U8d39rEUEmbvLQ5tZQUmJTMyFJ

并且由于 nearcore 没有将此类收据存储在您从 RPC 获得的 UNKNOWN_RECEIPT 数据库中。