holgern/beem

custom_json writing stability issue

Closed this issue · 4 comments

This is a crosspost of steemit/steem#3630

Is there any way whether it is really written or not at the beem library level?

Many thanks.

I've been running a dapp @steemfinex https://steemfinex.com for about 9 months. In the past months, there was no issue, but recently, writing custom_json operation is unstable. I'm using beem python library, and the library returned success, but custom_json wasn't actually written.

Since this is for steem-engine token transfer, reliability is very important. There is no way to decide whether it's just a delay or ultimate failure. Not entirely sure if this is the chain problem or beem. But as far as I heard, custom_json op is non-consensus tx. Is this why it's less stable than others, especially under the circumstances not many witness nodes are running now?

This has nothing to do with the beem library. A broadcasted operation needs to be accepted by the witness nodes and written to the chain. On steem there are currently some witnesses that are running 0.22.8888 and some are running a lower version. This may lead to a disagreement on a specific block which reject than the op in it.

How to solve it:

  • parse all blocks and check for your custom_json. Store all of your custom_json in a database.
  • broadcast a custom_json and add a new row to your database that a new custom_json needs to be found
  • wait for your custom_json
  • After a timeout, check if it stored in your database. When not, broadcast it again.

Thanks @holgern for your explanation.

Is there any way to check whether it's actually written easily using beem? Of course, one way is using account history but that may be inefficient and unreliable.

Most efficient way is to use the stream function from blockchain:

b = Blockchain()
start_block = ...
for op in b.stream(start=start_block, opNames=["custom_json"]):
    if op["id"] == "ssc-mainnet" and op["required_auths"] == ['steemfinex"]:
        ....

Thanks. Actually that's what I was thinking of (another way is using history api), but one problem is it's hard to decide until when I should wait to say it fails. So currently I've decided to do it manually, but when it occurs more often, I should do it automatically with enough delay to avoid dup transfers.

Regarding stream, I actually have another question. in some cases, it returns an older block than the previous one. this happens quite often these days on Steem, probably due to lack of stable api server. But for this, I think beem library can handle this, if the returned block is older than previous, skip it.