Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account_history plugin: notify all related accounts after a new account is created #265

Closed
abitmore opened this issue Apr 21, 2017 · 17 comments · Fixed by #2480
Closed

Account_history plugin: notify all related accounts after a new account is created #265

abitmore opened this issue Apr 21, 2017 · 17 comments · Fixed by #2480
Assignees
Labels
6 Plugin Impact flag identifying at least one plugin 6 Protocol Impact flag identifying the blockchain logic, consensus, validation, etc. feature hardfork plugin

Comments

@abitmore
Copy link
Member

abitmore commented Apr 21, 2017

It's ideal to notify the new account, the registrar, the referrer and the ones in the owner authorities and the active authorities. Now only the new account and the registrar get notified.

Related code is here:

      if( op.op.which() == operation::tag< account_create_operation >::value )
         impacted.insert( oho.result.get<object_id_type>() );
      else
         graphene::app::operation_get_impacted_accounts( op.op, impacted );

It should be:

      if( op.op.which() == operation::tag< account_create_operation >::value )
         impacted.insert( oho.result.get<object_id_type>() );
      graphene::app::operation_get_impacted_accounts( op.op, impacted );

However, if we simply fix it this way, after a replay, there will be more account_transaction_history_object objects inserted into the object database, so object IDs of individual records will be changed, which will cause trouble for 3rd applications that rely on the consistence of the IDs.

Please discuss.

Update: This impacts history_api::get_relative_account_history API which relies on account_transaction_history_object::sequence and account_statistics_object::total_ops.

Update: PR #406 is trying to add an option to the plugin that provides the missed data when enabled, but disabled by default.

Update: fixed by PR #2480 - after the hard fork time (HARDFORK_CORE_265_TIME), new account creation operations will notify all impacted accounts (note: voting_account is still not in the impacted accounts list).

@oxarbitrage
Copy link
Member

i was watching this issue since a few days and i see your point, however i don't have an actual solution by now to the problem. i want to add @elmato here he maybe haves an idea.

@elmato
Copy link
Contributor

elmato commented May 6, 2017 via email

@elmato
Copy link
Contributor

elmato commented May 6, 2017

Now that i'm looking at the code:

The id of the account_transaction_history_object is never returned (2.9.X), instead we always return the operation_history_object id (1.11.X).
So operation_history_object ids will be the same even if we apply your patch and replay the blockchain.

@abitmore
Copy link
Member Author

abitmore commented May 6, 2017

Afaik bittrex is storing object ID's (1.11.x) for withdrawals (edit: and deposits). It could be OK if the patch doesn't affect this ID.

@abitmore
Copy link
Member Author

abitmore commented May 6, 2017

It's possible that account_transaction_history_object ID's are being used by 3rd apps to track deposits, for example, to store the latest processed deposit.

@elmato
Copy link
Contributor

elmato commented May 7, 2017

Just to make it clear, because my previous comment was misleading.

1.11.X objects are part of the state, so they preserve the I'd no matter what we do in any plugin.

2.9.X objects are implementation details and they can change if we modify the plugin as you posted in the first comment.

The RPC API always return 1.11.X objects so we can rest assured that 3rd parties can rely on this id.

2.9.X objects are never returned by the RPC api

@abitmore
Copy link
Member Author

abitmore commented May 7, 2017

OK, I got it.

The 2.9.X ID's are not being returned by get_account_history API, only 1.11.X ID's are being returned.

However, the get_account_history API was buggy (for example #92, #168, #193), so some applications were using get_object API with 2.9.X ID's to fetch account histories by their own. That's why I thought it's a bit risky to change the code.

@oxarbitrage
Copy link
Member

Hi guys, 2.9.X just for your consideration objects are yes returned by the api already.

here is a sample, request an account will return between other things a statistics object.

root@alfredo:~# curl --data '{"jsonrpc": "2.0", "params": ["database", "get_objects", [["1.2.167006"]]], "method": "call", "id": 10}' http://127.0.0.18090/rpc | jq

...
"statistics": "2.6.167006",
...

Inside this statistic object most_recent_op is a 2.9.X object.

root@alfredo:~# curl --data '{"jsonrpc": "2.0", "params": ["database", "get_objects", [["2.6.167006"]]], "method": "call", "id": 10}' http://localhost:8090/rp
c | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   305  100   202  100   103   288k   147k --:--:-- --:--:-- --:--:--  197k
{
  "id": 10,
  "result": [
    {
      "id": "2.6.167006",
      "owner": "1.2.167006",
      "most_recent_op": "2.9.15497698",
      "total_ops": 24,
      "total_core_in_orders": 0,
      "lifetime_fees_paid": 807192,
      "pending_fees": 0,
      "pending_vested_fees": 0
    }
  ]
}
root@alfredo:~# 

By now, i think it is exposed just as last op. The client may be relying on the object id itself or not but it is possible for some that a change here can break their programs.

@abitmore
Copy link
Member Author

abitmore commented May 9, 2017

This impacts history_api::get_relative_account_history API which relies on account_transaction_history_object::sequence and account_statistics_object::total_ops.

@abitmore
Copy link
Member Author

abitmore commented May 9, 2017

#276 is related.

@abitmore
Copy link
Member Author

abitmore commented Jun 2, 2017

I think we can add an option to the plugin that provides the missed data when enabled, but disabled by default.

@oxarbitrage
Copy link
Member

i am going to work on this as an additional plugin option disabled by default as i am already making some work in the account_history_plugin and this should not be very hard to add.

@oxarbitrage oxarbitrage self-assigned this Sep 19, 2017
@oxarbitrage
Copy link
Member

#406

@abitmore
Copy link
Member Author

Lately I think it's better to fix the issue in a consensus-upgrade style, although strictly it's not a consensus change, because many 3rd-party applications rely on consistent numbering in account history. That said, only track all related accounts (for newly created accounts) after a defined time.

@abitmore abitmore added hardfork 2d Developing Status indicating currently designing and developing a solution 6 Protocol Impact flag identifying the blockchain logic, consensus, validation, etc. 6 Plugin Impact flag identifying at least one plugin labels Aug 23, 2018
@abitmore abitmore added this to New -Awaiting Core Team Evaluation in Project Backlog via automation Aug 23, 2018
@pmconrad
Copy link
Contributor

The primary purpose of account_transaction_history is to provide an auditable log of balance changes. I think we shouldn't abuse it as some form of generic notification infrastructure, especially because of the numbering issue.
Better provide a separate mechanism for historic events.

@abitmore
Copy link
Member Author

On the contrary I don't think it's abuse, but is fair use. I agree with a separate mechanism though. For example, classify the events in account history.

@abitmore abitmore removed this from New -Awaiting Core Team Evaluation in Project Backlog Jun 27, 2021
@abitmore abitmore added this to To Do in Protocol Upgrade Release (6.0.0) via automation Jun 27, 2021
@abitmore abitmore moved this from To Do to In Development in Protocol Upgrade Release (6.0.0) Jun 27, 2021
@abitmore abitmore linked a pull request Jun 27, 2021 that will close this issue
5 tasks
@abitmore abitmore removed a link to a pull request Jun 27, 2021
5 tasks
@abitmore abitmore linked a pull request Jun 27, 2021 that will close this issue
@abitmore
Copy link
Member Author

Fixed by #2480.

Protocol Upgrade Release (6.0.0) automation moved this from In Development to Done Jun 28, 2021
@abitmore abitmore removed the 2d Developing Status indicating currently designing and developing a solution label Jun 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6 Plugin Impact flag identifying at least one plugin 6 Protocol Impact flag identifying the blockchain logic, consensus, validation, etc. feature hardfork plugin
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

4 participants