Beem-0.20.14: beempy verify --use-api fails with TypeError

in utopian-io •  9 months ago 

Project Information

The beempy verify command allows users to check "who" signed operations on the blockchain. This enables in some cases to distinguish bot-votes and manual votes, or provides information on which dApp acted in the name of the user. The beempy verify command has a --use-api option that instructs the tool to use the get_potential_signatures Steem API call to find the signers of transactions.

A GitHub issue as well as a Pull Request to fix the problem were created. The PR was approved and merged by the PO and the fix will be part of the next beem release.

Expected behavior

beempy verify --trx [trx_num] --use-api [block_num] should use the get_potential_signatures call to find the signing keys for a given block or transaction.

Actual behavior

beempy verify --trx [trx_num] --use-api [block_num] raises a TypeError.

How to reproduce

# beempy verify --trx 37 --use-api 28592655
Traceback (most recent call last):
[...]
  File "/usr/local/lib/python3.6/site-packages/beem/cli.py", line 3146, in verify
    public_keys = tx.get_potential_signatures()
  File "/usr/local/lib/python3.6/site-packages/beem/transactionbuilder.py", line 339, in get_potential_signatures
    ret = self.steem.rpc.get_potential_signatures(args, api="database")
  File "/usr/local/lib/python3.6/site-packages/beemapi/graphenerpc.py", line 467, in method
    query = get_query(self.is_appbase_ready() and not self.use_condenser, self.get_request_id(), api_name, name, args)
  File "/usr/local/lib/python3.6/site-packages/beemapi/rpcutils.py", line 33, in get_query
    args = json.loads(json.dumps(args))
[...]
TypeError: Object of type 'datetime' is not JSON serializable

Fix

The problem in this case was that the corresponding raw transaction data was parsed already and timestamp strings were replaced by datetime objects. The TransactionBuilder class used to load that transaction tried to JSON-serialize these objects and failed. By passing the raw JSON transaction data to the TransactionBuilder class instead of the preprocessed data, the class can properly serialized the data. See PR#138.

GitHub Account

https://github.com/crokkon

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:  

Hi @stmdev, thanks for making this contribution..

JSON serialization can be tricky at times, try to be too careful and you still mix it up.. Good find.

I see you already fixed this and your pull request was approved and merged.

My feedback:

  1. I like how you explained the function of the beempy verify command and then went on to describe what the error was. By this you pointed the difference in behavior between what was expected and what was currently at play.

  2. The steps you provided are such that the tester or PO can just copy and paste to replicate the error.

The report adds significant value to the beem project. We look forward to more of your contributions.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thank you for your review, @fego! Keep up the good work!

Hi @stmdev!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @stmdev!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!