nervosnetwork / ckb-light-client

CKB light client reference implementation
MIT License
14 stars 16 forks source link

Light client inconsistently reporting transaction not found for a non-existent transaction. #144

Open jordanmack opened 1 year ago

jordanmack commented 1 year ago

I set up a local testnet ckb light client and I'm trying to query for the following transaction.

https://explorer.nervos.org/transaction/0x4bb9a6969c516dcf98f5b79271b056294190ddb3c70509f3fb089fe1097efa33

The results I get are inconsistent using fetch_transaction. If I query repeatedly I get "not_found", "fetching", and "added". It should never be present since this hash is a mainnet transaction, not testnet. Are these results expected?

Query

{
  "id": 42,
  "jsonrpc": "2.0",
  "method": "fetch_transaction",
  "params": ["0x4bb9a6969c516dcf98f5b79271b056294190ddb3c70509f3fb089fe1097efa33"]
}

Results

{
    "jsonrpc": "2.0",
    "result": {
        "status": "not_found"
    },
    "id": 42
}
{
    "jsonrpc": "2.0",
    "result": {
        "first_sent": "0x187fef819ab",
        "status": "fetching"
    },
    "id": 42
}
{
    "jsonrpc": "2.0",
    "result": {
        "status": "added",
        "timestamp": "0x187fef9f6e6"
    },
    "id": 42
}

A query using get_transaction always returns unknown.

quake commented 1 year ago

yes, it's by design.

jordanmack commented 1 year ago

When is fetch_transaction supposed to be used? I do not understand it's usage based on the RPC description.

quake commented 1 year ago

When the user sends a transaction through the light client, it will verify the transaction locally before broadcasting to the network, and if the inputs or cell deps are not locally available, for example, if a lock or type script is used that is not in the genesis block, it needs to be pre-fetched with this rpc before it can be verified successfully.