This repository was archived by the owner on Jan 20, 2026. It is now read-only.
Add deferred withdrawals for module accounts#61
Merged
BrandonWeng merged 7 commits intomainfrom Oct 24, 2022
Merged
Conversation
bd1304c to
aeb5caa
Compare
BrandonWeng
commented
Oct 20, 2022
Comment on lines
-63
to
-69
|
|
||
| // Mapping of Module Account to the amount of tokens that have been deducted from | ||
| // Sender accounts but not yet deposited into module accounts. Use this to remove | ||
| // bottle neck for concurrent transacation processing and perform batch deposit | ||
| // in the end block | ||
| moduleAccountDepositMapping map[string]sdk.Coins | ||
| moduleAccountDepositMappingLock *sync.Mutex |
philipsu522
approved these changes
Oct 21, 2022
types/context_cache.go
Outdated
| apply(recipientModule, c.deferredSends[recipientModule]) | ||
| } | ||
| func (c *ContextMemCache) UpsertDeferredWithdrawals(moduleAccount string, amount Coins) { | ||
| // Separate locks needed for all mappings - atmoic transaction needed |
Merged
BrandonWeng
added a commit
that referenced
this pull request
Oct 27, 2022
## Describe your changes and provide context Refactors the code a bit and add necessary helpers for Tokenfactory mint and burn message types. * They both will deposit and withdraw from module accounts as they're used as intermediaries for storage For context, module accounts are a single source of the bottom neck when it comes to concurrency, so to remove this bottle neck, we avoid declaring them in the access ops, instead, we store an in-memory value protected by mutex locks and flush it to the AVL tree at the very end. This will ensure deterministic updates Follow-up PRs, still need to test concurrency: sei-protocol/sei-chain#331 #63 ## Testing performed to validate your change Mainly unit tests - will need to do some E2E testing once it's integrated with the sei-chain level chains. Will follow up with two more PRs Sanity check that bank sends aren't affected with the follow up PRs: 
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Describe your changes and provide context
Refactors the code a bit and add necessary helpers for Tokenfactory mint and burn message types.
For context, module accounts are a single source of the bottom neck when it comes to concurrency, so to remove this bottle neck, we avoid declaring them in the access ops, instead, we store an in-memory value protected by mutex locks and flush it to the AVL tree at the very end. This will ensure deterministic updates
Follow-up PRs, still need to test concurrency:
sei-protocol/sei-chain#331
#63
Testing performed to validate your change
Mainly unit tests - will need to do some E2E testing once it's integrated with the sei-chain level chains. Will follow up with two more PRs
Sanity check that bank sends aren't affected with the follow up PRs:
