Skip to content
This repository was archived by the owner on Aug 2, 2021. It is now read-only.
This repository was archived by the owner on Aug 2, 2021. It is now read-only.

Queue and persist pending blockchain interaction #2006

@ralph-pichler

Description

@ralph-pichler

To ensure that there are no nonce issues we want to allow at most one pending blockchain transaction at a time. This means transactions will have to be queued if another one is still pending. This queue should also be persisted, so it can resume after restarts.

Requirements:

  • As there are multiple transaction types (e.g. cashing out, depositing, withdrawal) the queue should be agnostic of that. Swap should be able to push a transaction requests into the (FIFO) queue.
  • The transaction should be signed and sent as soon as there is no other transaction pending.
  • Once the transaction has been mined Swap should be notified somehow.
  • This notification should occur even if the node was shutdown in-between the time of sending the transaction and it being mined.
  • If a transaction got queued but not executed prior to being shutdown it should automatically be back in the queue after restart. (optional)

Requirements that are part of other issues:

Design goals:

  • should be as decoupled from swap as possible (ideally no dependency on swap and testable in isolation)
  • different components should be able to use the same queue (necessary as even swap itself needs to send txs from the same account from both Swap and the CashoutProcessor)
  • should be exchangeable with a queue which can allow concurrent transactions (= should have a well defined interface)
  • should only care about sending transaction (or setting the nonce) and reliably notifying about the result even in case of restarts or network or backend problems (re-trying, etc. would be outside its responsibility).
  • the idea is that other place in the code which need to send transaction no longer need to be concerned with issue like io errors, network problems, restarts, etc.. They just queue the request and are guaranteed to be notified of its result at some point.

Related to #2005, #1929 and #1633.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions