Migrate sei-cosmos into sei-chain as mono repo#2408
Merged
Conversation
## Describe your changes and provide context This replaces the original Upsert in the deferred send from module to account with one that doesn't perform a subtraction against the deferred sends. The callsites were also modified to ensure this deferred withdrawal would ONLY be called IFF we've already tried subtracting from the deferred sends with insuffucient balance AND there is sufficient bank balance. ## Testing performed to validate your change Tests in sei-chain verifying this behavior for known problematic scenarios.
## Describe your changes and provide context adding more tests. cases for global fee param for multiple denoms ## Testing performed to validate your change
## Describe your changes and provide context This changes amount of for dec coins to be iterative too it dangerously assumes that the coins are in sorted order and returns 0 often if it's not. ## Testing performed to validate your change Added a unit test for this, it would fail with the old logic 
## Describe your changes and provide context Closing leveldb while committing may lead to data corruption since a version might be partially written by the commit. This change makes it such that closing DB and commit are mutually exclusive. ## Testing performed to validate your change tested in atlantic-2's db sync node, which restarts a lot
## Describe your changes and provide context This adds the invalid concurrent metric emissions ## Testing performed to validate your change
## Describe your changes and provide context This does several things: 1. Removes the deferred withdrawals and deferred mints/burns. 2. Adds a saturating sub as an alternative to safesub. We can use this and pass ing the subUnlockedCoins to atomically perform a saturating sub against the deferred balance first and then against the underlying balance using subUnlockedCoins. 3. Added a partition function for the coins to separate positive and negative values to separate remainders for the saturating sub 4. refactors the bank keepers to perform saturating subtraction instead of safesub ## Testing performed to validate your change Unit tests... LOTS of unit tests
## Describe your changes and provide context This function is a duplicate of the one above. Remove the Legacy version ## Testing performed to validate your change Unit tests
## Describe your changes and provide context ## Testing performed to validate your change
## Describe your changes and provide context Iterators are already closed with a defer statement above. ## Testing performed to validate your change Unit tests
## Describe your changes and provide context The patch doesn't really apply to our existing chains since our vesting accounts can only be created before Genesis: cosmos/cosmos-sdk@666c345 However we can also just patch the genesis vesting account validation to also have these checks ## Testing performed to validate your change Unit test
## Describe your changes and provide context This data is already queried, so use the in-memroy variable rather than re-query it ## Testing performed to validate your change
## Describe your changes and provide context Removes unnecessary data copy ## Testing performed to validate your change
## Describe your changes and provide context The code incorrectly checks padding for address. 3 should be outside the int cast ## Testing performed to validate your change
#276) ## Describe your changes and provide context This change is mainly for: 1. Sanity check and enhance existing unit tests coverage 2. Add more documentations for how slashing works and what customizations we have made on top of open source ## Testing performed to validate your change --------- Co-authored-by: Yiming Zang <yzang@twitter.com>
## Describe your changes and provide context Improve the unit test coverage of bank keeper functional logic. (Omitted some coverage for things like querier which simply call tested functionality in keeper under the hood) ## Testing performed to validate your change ``` github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:74: GetPaginatedTotalSupply 84.6% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:105: NewBaseKeeper 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:133: WithMintCoinsRestriction 90.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:154: DelegateCoins 81.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:202: UndelegateCoins 78.6% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:230: GetSupply 90.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:255: HasSupply 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:263: GetDenomMetaData 87.5% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:279: GetAllDenomMetaData 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:292: IterateAllDenomMetaData 88.9% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:310: SetDenomMetaData 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:321: SendCoinsFromModuleToAccount 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:353: SendCoinsFromModuleToModule 93.8% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:389: SendCoinsFromAccountToModule 75.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:404: DeferredSendCoinsFromAccountToModule 71.4% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:421: WriteDeferredOperations 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:426: WriteDeferredDepositsToModuleAccounts 90.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:447: DelegateCoinsFromAccountToModule 66.7% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:466: UndelegateCoinsFromModuleToAccount 66.7% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:482: createCoins 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:520: MintCoins 88.9% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:536: destroyCoins 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:569: BurnCoins 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:588: setSupply 87.5% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:606: trackDelegation 87.5% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:623: trackUndelegation 87.5% github.com/cosmos/cosmos-sdk/x/bank/keeper/keeper.go:642: IterateTotalSupply 83.3% github.com/cosmos/cosmos-sdk/x/bank/keeper/send.go:45: NewBaseSendKeeper 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/send.go:60: GetParams 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/send.go:66: SetParams 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/send.go:73: InputOutputCoins 87.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/send.go:133: SendCoins 91.7% github.com/cosmos/cosmos-sdk/x/bank/keeper/send.go:173: subUnlockedCoins 87.5% github.com/cosmos/cosmos-sdk/x/bank/keeper/send.go:207: addCoins 90.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/send.go:232: initBalances 88.9% github.com/cosmos/cosmos-sdk/x/bank/keeper/send.go:251: setBalance 87.5% github.com/cosmos/cosmos-sdk/x/bank/keeper/send.go:272: IsSendEnabledCoins 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/send.go:282: IsSendEnabledCoin 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/send.go:288: BlockedAddr 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/view.go:43: NewBaseViewKeeper 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/view.go:52: Logger 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/view.go:57: HasBalance 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/view.go:62: GetAllBalances 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/view.go:73: GetAccountsBalances 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/view.go:100: GetBalance 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/view.go:117: IterateAccountBalances 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/view.go:136: IterateAllBalances 76.9% github.com/cosmos/cosmos-sdk/x/bank/keeper/view.go:165: LockedCoins 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/view.go:180: SpendableCoins 100.0% github.com/cosmos/cosmos-sdk/x/bank/keeper/view.go:187: spendableCoins 71.4% github.com/cosmos/cosmos-sdk/x/bank/keeper/view.go:207: ValidateBalance 91.7% github.com/cosmos/cosmos-sdk/x/bank/keeper/view.go:230: getAccountStore 100.0% ```
## Describe your changes and provide context ## Testing performed to validate your change
## Describe your changes and provide context Per audit details, we're missing coverage for validation logic in staking and gov ## Testing performed to validate your change unit tests
## Describe your changes and provide context Doesn't seem to be absolutely necessary since it would just fail when broadcasting, more of an UI improvement. We can wait until 3.0.4 is out and then merging Copying from: cosmos/cosmos-sdk#12548 ## Testing performed to validate your change unit tests
## Describe your changes and provide context Similar changes to here: cosmos/cosmos-sdk#15487 Our fork of cosmos-sdk has a custom integration to get ABCI++ working so I'd like @codchen to take a second look ## Testing performed to validate your change Unit tests
## Describe your changes and provide context This PR does the following: - refactors the deferred logic to use a memKV store instead of an in memory map (allows us to avoid committing the changes when we discard other changes upon antehandler failure) - refactors the feecollectors / deferred balance usage to key on module-txIndex-denom -> sdk.Coin - when writing the deferred balances, it first adds up all of the tx specific balances, then writes them in sorted order of the module addresses - refactors the anteDependencyGenerator to take in a txIndex to allow for generating the dependencies appropriately for feecollector resources - adds in a txIndex to sdk.Context to contain the currently executing TX index throughout delivertx context in order to allow for writing to the partitioned KV store to avoid resource overlap - Adds a new instantiation function for BankKeeper to instantiate with the deferredCache initialized (deferred usages panic if not set up with this new function) (have to keep old one because wasmd breaks otherwise) - Introduces the resource types specific to the deferredCache Store Key (because this is a separate KV store from bank store it has its own resource type and isn't under the Bank resource type Still in progress: - removing the context cache usages + deferred bank ops in memory structure - adding unit tests for the memKV deferredCache that is part of bank keeper ## Testing performed to validate your change local sei testing + adding more unit tests
## Describe your changes and provide context This properly adds the ante deps message access ops (with index -1) to the map used for comparator validation. Prior to this, we were regenerating the antedeps, but this is a more correct fix. ## Testing performed to validate your change localsei verification
## Describe your changes and provide context Tighten access to lastCommitInfo ## Testing performed to validate your change local sei Co-authored-by: Philip Su <philip.su.522@gmail.com>
This reverts commit c6acf9c. ## Describe your changes and provide context With optimistic processing this is not applicable on our side ## Testing performed to validate your change Launched a cluster with 3.0.3, with only this change applied and see that it app hashes 
## Describe your changes and provide context Updated the invariant total supply calculation to include deferred balance, since otherwise it would ALWAYS fail because of the fees that are deferred for the broken invariant tx itself. ## Testing performed to validate your change verified invariant error no longer exists on localsei updated unit tests for deferred iterator in bankkeeper
## Describe your changes and provide context Changes: - Add more coverage for gov CLI, cherry pick some changes from open source ## Testing performed to validate your change --------- Co-authored-by: Yiming Zang <yzang@twitter.com>
## Describe your changes and provide context This disables the handler behavior for verify invariant. It will be fairly straightforward to undo in the future if/when we would like to re-enable ## Testing performed to validate your change localsei testing
## Describe your changes and provide context ``` The pointed locations provide a misleading naming for code elements. In particular: The Sei blockchain supports transactions signed according to the SR25519 scheme. However, the code at the pointed location accounts, for the verification cost, the constant parameter meant for signatures based on the ED25519 scheme. Since costs between the two schemes could actually be different, such constant may be misleading when configuring the parameter as it is meant for a different algorithm. Moreover it can create confusion if ED25519 needs to be supported in the future. The handleQueryApp function handles queries to the /app endpoint and expects the second element of the path to be one among "simulate", "version" or "snapshot". However the message included in the error in the case the path does not hit one of the allowed keys only cites "simulate" and "version" as expected values, omitting the "snapshot" one, which is also supported. The getter1 interface is used as a handy tool to call the GetAmount method on the sdk.Msg interface by casting its type. However the getter1 name is not meaningful in respect to its usage. ``` ## Testing performed to validate your change Unit tests
## Describe your changes and provide context This updates unknown field decoding behavior to reject deeply nested fields past a depth of 100. This matches up with Google's imposed nesting limits ([link](https://protobuf.dev/reference/cpp/api-docs/google.protobuf.io.coded_stream/#:~:text=Sets%20the%20maximum%20recursion%20depth.%20The%20default%20is%20100.)) and exceeds what we would expect to see in nested fields in normal paths. ## Testing performed to validate your change Added unit tests to verify recursion protected behavior
## Describe your changes and provide context Add helper & context field to explicitly set upgrade at the beginning of tracer calls, to allow for versioned behaviors ## Testing performed to validate your change unit test
masih
added a commit
to sei-protocol/sei-cosmos
that referenced
this pull request
Sep 29, 2025
Update readme with notice of archive/move to sei-chain. Relates to: * sei-protocol/sei-chain#2408
There was a problem hiding this comment.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
40fcc93 to
f9cedeb
Compare
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (34.43%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #2408 +/- ##
===========================================
- Coverage 52.19% 36.64% -15.55%
===========================================
Files 464 1165 +701
Lines 45389 104350 +58961
===========================================
+ Hits 23690 38244 +14554
- Misses 19869 62849 +42980
- Partials 1830 3257 +1427
🚀 New features to boost your workflow:
|
f9cedeb to
49c8b00
Compare
masih
added a commit
to sei-protocol/sei-cosmos
that referenced
this pull request
Sep 30, 2025
Update readme with notice of archive/move to sei-chain. Relates to: * sei-protocol/sei-chain#2408
udpatil
approved these changes
Sep 30, 2025
sei-will
approved these changes
Sep 30, 2025
masih
added a commit
that referenced
this pull request
Sep 30, 2025
Ports over the work originally done in sei-protocol/sei-cosmos#594. Relates to: * #2408 Co-authored-by: yirenz <blindchaser@users.noreply.github.com>
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 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.
Merge git commit history from
sei-cosmosintosei-chainand update the replace directive in root ofsei-chainto use relative path.Note
The merged commits from
sei-cosmospoint tov0.3.66. Therefore, the changes leave behind additional 8 commits introduced as part of the following PRs which will be bubbled up tosei-chainseparately:Of those PRs, the following 2 PRs introduce changes that would need additional review to mitigate the risk of breaking changes in
sei-chainmain:Separately, the out of date code in
sei-ibc-goblocks bubbling up the fixes togo vet, which needs upgradingsei-ibc-gofirst.The reminder of changes done here are mechanical to fix CI runs and update the
replacedirective ingo.modto use relative path.