planetarium / libplanet

Blockchain in C#/.NET for on-chain, decentralized gaming
https://docs.libplanet.io/
GNU Lesser General Public License v2.1
510 stars 144 forks source link

Event-Transaction Indexing Service #1370

Closed kfangw closed 1 year ago

kfangw commented 3 years ago

related to #1321

Background

When a transaction executed there are many events observable but not recorded in any store. For example, when a transfer transaction executed, there is relevant information such as recipient, sender, and amount. And timestamp.

You might want to query a balance sheet for your account. To do that, If a node built indexes for Sender(Account)->Tx and Recipient(Account)->Tx, it is straightforward to retrieve the data.

AS-IS

libplanet has those similar indexes in IStore. They are not about state transition though.

TO-BE

Generalize the indexing service including the above indexes. It can be divided into 2 parts

  1. Events emitted handling blocks (like AS-IS indexes)
  2. Events emitted from the execution of the transaction(actions) The first one is handled by libplanet like AS-IS. But for the second one, libplanet provides a tool for emitting events and lets IAction implementations emit events using the tool. libplanet gather the events and build the index(Event->TxId)

The collected event data isolated from IStore and managed solely. This data can be reproducible by replay blockchain. The full node even for Miner does not need those data for their functionalities. It is only useful for end-users who want to query information for their interest. I expect a volunteer to launch a rich query service with the event-transaction indexing service.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.