Skip to content

Settle payment rails in order of last settlement time #529

@pyropy

Description

@pyropy

In #353, I proposed a different design that does not require multiple concurrent transactions:

  1. For each data set, keep a column in our DB storing the time of the last successful attempt to settle the linked payment rail. For new data sets, set this value to the time when the data set was created.
  2. Periodically pick a data set with the oldest time of the last rail settlement. Ignore data sets that were settled less than X days ago, where X is the interval of how often we want to settle. I propose 1 day for calibnet and 1 week for mainnet.
  3. Settle the payment rail for this data set.
  4. If the TX is successful, then update our DB with the new time of the last successful settlement.
  5. If the TX failed - TODO, we need to figure out how to handle this.
  6. If the outer TX takes too long to get accepted by the network because of the elevated gas base fee. We need to replace the TX with a new TX using the same nonce. The new TX does not need to be the same.

Since the time I wrote my comment, we have moved to settling CDN payment rails in batches. The steps above can remain mostly the same with a slight tweak - we can settle up to N oldest data sets in a single transaction.

Originally posted by @bajtos in #353

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions