feat(BundleDataClient): Support refunds for pre-fills/slow-fill-requests and duplicate deposits#835
Merged
nicholaspai merged 118 commits intomasterfrom Feb 3, 2025
Merged
feat(BundleDataClient): Support refunds for pre-fills/slow-fill-requests and duplicate deposits#835nicholaspai merged 118 commits intomasterfrom
nicholaspai merged 118 commits intomasterfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Definitions
Core logic for refunding pre-fills:
Evaluate all deposits in the current bundle that were not filled in the current bundle. Figure out whether the deposit was filled, by either:
If there is a fill for this deposit then we need to issue a refund for this fill because the fill occurred in a previous bundle where it might not have been refunded.
We need to use a similar algorithm for creating slow fill leaves for pre-slow-fill-requests with the caveat that we cannot create slow fill leaves for deposits that have expired
Non-determinism for refunding pre-fills
We don't deterministically know whether this pre-fill was refunded in the prior bundle because we don't know for certain what kind of event search window the proposer of the prior bundle used when constructing the bundle.
To illustrate this problem, imagine if a fill and a deposit are sent 10 minutes apart such that the fill is at the end of the current bundle and the deposit is at the beginning of the next. The prior bundle proposer probably would have issued a refund for this fill, but we don't know for certain.
So, one way around this non-determinism is to introduce a new rule to the UMIP:
Do not issue refunds for fills or slow fill leaves where the matched deposit is later than the current bundle block range
This rule makes it always apparent which bundle should include a refund or slow fill leaf for a pre-fill or pre-slow-fill-request.
This will require a UMIP change to this PR
findFillEvents
When we need to query
fillStatuses()on-chain to detect whether a deposit corresponds to a very old pre-fill, then we also need to locate that old fill. We assume this is rare and will use the relatively expensivefindFillEvents()function which is built off of the existingfindFillBlock()function to locate that event.Duplicate deposits
This PR also adds support for duplicate deposits that are possible to create with unsafeDeposit. Duplicate deposits are added to
bundleDepositsfor they should be included inrunningBalances. Duplicate deposits can be refunded upon expiry but for all deposits, expiry refunds cannot occur once the deposit has been filled.Due to the presence of pre-fills, we can now no longer instantly include that a deposit submitted in the current bundle that has expired is due a refund. We now need to check its relay status in the case where we don't see a matching fill in our memory.
Unit tests
Can be found here: across-protocol/relayer#2010