-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: minted early tracking #11066
base: master
Are you sure you want to change the base?
fix: minted early tracking #11066
Conversation
- ensure multiples of the same NFA+amount are tracked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good test.
We should have a multiset abstraction. Either with durable multiset or a light wrapper to make MapStore act like one.
@@ -174,8 +175,8 @@ export const prepareSettler = ( | |||
intermediateRecipient: config.intermediateRecipient, | |||
/** @type {HostInterface<TargetRegistration>|undefined} */ | |||
registration: undefined, | |||
/** @type {SetStore<ReturnType<typeof makeMintedEarlyKey>>} */ | |||
mintedEarly: zone.detached().setStore('mintedEarly'), | |||
/** @type {MapStore<ReturnType<typeof makeMintedEarlyKey>, bigint>} */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What we really want is a MultiSet. Endo Patterns has CopyBag for that. I'm looking into whether we have a durable option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool didn't know that was option. Will look out for your reply on what to use here.
@@ -221,7 +222,7 @@ export const prepareSettler = ( | |||
|
|||
case PendingTxStatus.Advancing: | |||
log('⚠️ tap: minted while advancing', nfa, amount); | |||
this.state.mintedEarly.add(makeMintedEarlyKey(nfa, amount)); | |||
self.queueMintedEarly(nfa, amount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not really a queuing operation because there's no distinguishing the items. I think it should still be add
. But ideally we don't need this separate method because the data store is a multiset that manages repeated items itself.
@@ -256,7 +257,12 @@ export const prepareSettler = ( | |||
const { value: fullValue } = fullAmount; | |||
const key = makeMintedEarlyKey(forwardingAddress, fullValue); | |||
if (mintedEarly.has(key)) { | |||
mintedEarly.delete(key); | |||
const count = mintedEarly.get(key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should be using get
and delete
abstraction on the map to treat it as a multiset.
if we don't have a multiset durable store, we can have a utility that performs the multi-set on them.
Description
Ensures the
mintedEarly
store can track multiple settlements for the same amount from the same address.Security Considerations
Ensures state diagram invariants are upheld.
Scaling Considerations
Same considerations as #10729 - the mapStore could grow large if an attacker spams the settlementAccount with uusdc. In these changes we ensure to delete map store entries when the count goes to 0.
Documentation Considerations
Changes should be clear to maintainers.
Testing Considerations
Adds a new test for the scenario not originally considered.
Upgrade Considerations
The
mintedEarly
kind is a Remotable, so changing from aSetStore
to aMapStore
does not seem to affect upgradability.These change should be included in the FUSDC GTM CE.