Full Nodes Will Have get_transaction Without account_history Plugin

in steem •  6 years ago  (edited)

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!

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

I guess, as long as it was built with -DSKIP_BY_TX_ID=OFF.

Hi, @inertia!

You just got a 2.61% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

Hi @inertia!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your UA account score is currently 6.469 which ranks you at #165 across all Steem accounts.
Your rank has not changed in the last three days.

In our last Algorithmic Curation Round, consisting of 219 contributions, your post is ranked at #142.

Evaluation of your UA score:
  • You've built up a nice network.
  • The readers like your work!
  • Try to work on user engagement: the more people that interact with you via the comments, the higher your UA score!

Feel free to join our @steem-ua Discord server