Full Nodes Will Have get_transaction Without account_history Plugin

inertia(74)
Published in
#steem
Words
238
Reading
2 min
Listen
Play
8y

Background

Right now, if you want to run a full node, you have to make a tough decision about how to enable account_history_api. You can back the account_history_api plugin with either account_history plugin or account_history_rocksdb plugin.

If you go with account_history_rocksdb plugin, you get better performance, but you lose condenser_api.get_transaction and account_history_api.get_transaction (see: #2309).

For that situation, we see:

This API is not supported for account history backed by RocksDB

TL;DR: In theory, you can use account_history_rocksdb and still have the ability to locate a trx_id if ...

Theory

There is a new API called transaction_status_api that hasn't been released yet. But I suspect that once transaction_status_api has been merged into steemd (see: #2458), API client tools should be able to simulate the original behavior of *.get_transaction by calling transaction_status_api.find_transaction, getting either status of within_reversible_block or within_irreversible_block along with the block_num.

Once we have block_num, we can request the block and grab the original transaction with trx_id.

Update [2019-09-16]: You can do this, but only for a 64,000 block window. I didn't know this at the time.

Example

Start up a node that has transaction_status_api enabled ...

docker run -d -p 8090:8090 inertia/tintoy:transaction-status-api

I have a trx_id but no other information (in reality, I got this by asking for block 95 from tintoy):

070a2a89005ef3c4ef3d881d069d143f78861828

So I can call transaction_status_api.find_transaction:

curl -s --data '{"jsonrpc":"2.0", "method":"transaction_status_api.find_transaction", "params": {"transaction_id": "070a2a89005ef3c4ef3d881d069d143f78861828"}, "id":1}' http://localhost:8090 | jq

Returns:

{
  "jsonrpc": "2.0",
  "result": {
    "status": "within_irreversible_block",
    "block_num": 95
  },
  "id": 1
}

Oh look! It's from block 95. Imagine that. Now I ask for the block:

curl -s --data '{"jsonrpc":"2.0", "method":"block_api.get_block", "params":{"block_num":95}, "id":1}'  http://localhost:8090 | jq

In the result (not show, not enough resource credits today) I can look at transaction_ids and find my trx_id. The index at my trx_id in transaction_ids is the same index at the transaction I want of transactions. It works, all without account_history plugin enabled!

Full Nodes Will Have get_transaction Without account_history Plugin | Ecency