In #353, I proposed a different design that does not require multiple concurrent transactions:
- 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.
- 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.
- Settle the payment rail for this data set.
- If the TX is successful, then update our DB with the new time of the last successful settlement.
- If the TX failed - TODO, we need to figure out how to handle this.
- 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
Originally posted by @bajtos in #353