Skip to content

Handle new VERTEX_REMOVED event #180

@glevco

Description

@glevco

PR HathorNetwork/hathor-core#1093 introduced changes in the Event Queue system from the hathor-core side, so the wallet-service must be updated. These are breaking changes.

When reorgs decrease the best height, transactions may be invalidated and removed from the mempool (in fact, completely deleted from the storage). Before, the Event Queue system did not handle this scenario. When this happens, there are two consequences that should be correctly handled by the wallet-service:

  1. Every dependency of a removed transaction will have its metadata updated, removing the transaction from itself. That is, parents will have that transaction removed from their children metadata, and input vertices will have that transaction removed from their spent_outputs.
  2. A new VERTEX_REMOVED event will be emitted. Its only data is a vertex_id key with the hash of the removed transaction.

Note that the order above will always be respected. So, summing up events that could be received when a reorg occurs, in order:

  1. A REORG_STARTED event is received (this existed before this update).
  2. Multiple VERTEX_METADATA_CHANGED events could be received containing metadata that was updated because of the reorg (this existed before).
    • It's possible that some of those updates reflect removal of transactions, as explained above (this is new).
  3. Multiple VERTEX_REMOVED could be received (this is new).
  4. A REORG_FINISHED event is received (this existed before).
  5. A NEW_VERTEX_ACCEPTED is received for the vertex that caused the reorg (this existed before).

A new INVALID_MEMPOOL_TRANSACTION simulation scenario is provided so this can be covered in integration tests.

Action items

  • Handle new VERTEX_REMOVED event.
  • Handle metadata updated with transaction removals (it's possible that this is naturally handled by existing code, but it should be checked).
  • Implement integration test for the new INVALID_MEMPOOL_TRANSACTION scenario.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions