Concordium / concordium-transaction-logger

A service that logs all transactions and indexes them in a postgres database
Mozilla Public License 2.0
2 stars 2 forks source link

Missing transaction? #6

Closed sderuiter closed 2 years ago

sderuiter commented 2 years ago

Bug Description It appears as if the transaction service is missing transactions? I've found at least 1 case where a row is found in summaries table, but no corresponding row in ati table referring back to said summary.

Steps to Reproduce Execute the following query:

select * from summaries 
where height > 150 and 
height <= 160 and 
summary#>>'{Left,type,type}' IN ('accountTransaction', 'credentialDeploymentTransaction')

This gives:

455 "binary data"   1623220093750   158 "{""Left"": {""cost"": ""0"", ""hash"": ""0432ef98e3d1bb5cc479983bcf2b102f0bcafe3842df902086877005959404b2"", ""type"": {""type"": ""credentialDeploymentTransaction"", ""contents"": ""initial""}, ""index"": 0, ""result"": {""events"": [{""tag"": ""AccountCreated"", ""contents"": ""42Hc6eq8GaKpz7w9B7tGD1mNWLjbYFq3iSyK5NjNPNif7fgNVS""}, {""tag"": ""CredentialDeployed"", ""regId"": ""848020e89b594104d703ca8a2c01ef80f3d45273055acb56eddd1c5bb464ef813600b0dbd09f72a7ac61b8c7f55c4bf3"", ""account"": ""42Hc6eq8GaKpz7w9B7tGD1mNWLjbYFq3iSyK5NjNPNif7fgNVS""}], ""outcome"": ""success""}, ""sender"": null, ""energyCost"": 1100}}"

whereby 158 is the height of the block where this transaction is finalised and 455 is the summary_id for the ati table.

Now, trying to find this summary in the ati table:

select * from ati where summary > 450 and summary <= 460

Results in:

id  account       summary
1709    "binary data"   451
1710    "binary data"   451
1711    "binary data"   452
1712    "binary data"   453
1713    "binary data"   453
1714    "binary data"   453
1715    "binary data"   453
1716    "binary data"   453
1717    "binary data"   453

Expected Result I would expect the summary of 455 to be present in the ati table.

Actual Result Not there.

Hence, using the preferred query by joining the ati table to the summaries table using:

FROM ati LEFT JOIN summaries ON ati.summary = summaries.id

will not produce this transaction.

abizjak commented 2 years ago

This is a "create account" transaction. https://dashboard.mainnet.concordium.software/lookup/0432ef98e3d1bb5cc479983bcf2b102f0bcafe3842df902086877005959404b2

As it is, these do not affect the balance of the account (they create the account though) so are not listed in the ATI table.

abizjak commented 2 years ago

I believe that is also how the node's transaction logging behaves.

sderuiter commented 2 years ago

Hmm, unfortunate decision in my opinion, but a decision nonetheless. Thanks.

sderuiter commented 2 years ago

Just to confirm:

  1. There's no way to get the account for such a tx using a query (like the previously mentioned query does)?
  2. Are there other transaction types that are logged in summaries but do not show up in the ati table?
abizjak commented 2 years ago

Hmm, unfortunate decision in my opinion, but a decision nonetheless. Thanks.

It was a decision made long ago (3 years) in the node's logging implementation and the current version of the logger is intended to replicate the behaviour of the node so we can transition to it gradually without affecting services that depend on the output of the logging.

The reason this decision was made in the node is that it falls out naturally from the fact that "account creation" transactions and "account transactions" are two different categories of transactions and they are handled quite differently. In particular account creation transactions do not affect any balances.

So this is the history. I can see why including them in the log would make sense as well and it would not be hard to modify the logger to do this. Alternatively not include the transaction in the summaries table. Which one of these would fit your needs best?

In addition to account creations, update instructions will also be like this, that is, in the summaries table, but not corresponding entry in the ATI or CTI tables.

sderuiter commented 2 years ago

Thank you. No need to change the logger. If I can search for the 'missing' txs myself, that's enough for me.

I'm currently adding 'credentialDeploymentTransaction' summaries myself. What is the 'type' for the update tx you mentioned was also missing from ati and cti?

abizjak commented 2 years ago

All of the transactions in this "Update" category http://developer.concordium.software/concordium-rust-sdk/concordium_rust_sdk/types/enum.BlockItemSummaryDetails.html#variant.Update

So concretely all of these types http://developer.concordium.software/concordium-rust-sdk/concordium_rust_sdk/types/enum.UpdateType.html

sderuiter commented 2 years ago

Thank you. I would classify all of these update types as not affecting individual accounts, so no need for me to add them.

abizjak commented 2 years ago

Can this issue be closed, or do you think there are any actions to follow up our discussion with?