Skip to content

Migrate sei-cosmos into sei-chain as mono repo#2408

Merged
masih merged 527 commits into
mainfrom
masih/mono-ish-cosmos
Sep 30, 2025
Merged

Migrate sei-cosmos into sei-chain as mono repo#2408
masih merged 527 commits into
mainfrom
masih/mono-ish-cosmos

Conversation

@masih
Copy link
Copy Markdown
Collaborator

@masih masih commented Sep 29, 2025

Merge git commit history from sei-cosmos into sei-chain and update the replace directive in root of sei-chain to use relative path.

Note

The merged commits from sei-cosmos point to v0.3.66. Therefore, the changes leave behind additional 8 commits introduced as part of the following PRs which will be bubbled up to sei-chain separately:

Of those PRs, the following 2 PRs introduce changes that would need additional review to mitigate the risk of breaking changes in sei-chain main:

Separately, the out of date code in sei-ibc-go blocks bubbling up the fixes to go vet, which needs upgrading sei-ibc-go first.

The reminder of changes done here are mechanical to fix CI runs and update the replace directive in go.mod to use relative path.

udpatil and others added 30 commits June 1, 2023 09:25
## 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


![image](https://github.com/sei-protocol/sei-cosmos/assets/18161326/d2d5d34a-5c86-494e-9619-a3e72080c753)
## 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

![image](https://github.com/sei-protocol/sei-cosmos/assets/18161326/5d6b0606-aba5-4556-b2c9-6417572eee26)
## 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
udpatil and others added 2 commits July 28, 2025 08:39
## 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
Copy link
Copy Markdown

@github-advanced-security github-advanced-security AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@masih masih force-pushed the masih/mono-ish-cosmos branch from 40fcc93 to f9cedeb Compare September 30, 2025 08:05
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 30, 2025

Codecov Report

❌ Patch coverage is 34.43023% with 2152 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.64%. Comparing base (615f464) to head (b13b19a).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sei-cosmos/baseapp/abci.go 26.03% 637 Missing and 25 partials ⚠️
sei-cosmos/baseapp/baseapp.go 60.89% 252 Missing and 37 partials ⚠️
sei-cosmos/client/grpc/tmservice/service.go 1.41% 139 Missing ⚠️
sei-cosmos/baseapp/options.go 22.85% 118 Missing and 17 partials ⚠️
sei-cosmos/client/context.go 38.79% 111 Missing and 1 partial ⚠️
sei-cosmos/client/broadcast.go 0.00% 104 Missing ⚠️
sei-cosmos/baseapp/params.go 0.00% 95 Missing ⚠️
sei-cosmos/client/cmd.go 57.22% 68 Missing and 6 partials ⚠️
sei-cosmos/client/grpc_query.go 0.00% 63 Missing ⚠️
sei-cosmos/client/input/input.go 0.00% 59 Missing ⚠️
... and 18 more

❌ 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.
❌ Your project status has failed because the head coverage (36.64%) is below the target coverage (60.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@             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     
Files with missing lines Coverage Δ
sei-cosmos/client/docs/statik/statik.go 100.00% <ø> (ø)
sei-cosmos/client/query.go 2.38% <ø> (ø)
sei-cosmos/client/rpc/block.go 2.38% <ø> (ø)
sei-cosmos/client/rpc/routes.go 100.00% <ø> (ø)
sei-cosmos/client/rpc/status.go 3.12% <ø> (ø)
sei-cosmos/client/rpc/validators.go 1.53% <ø> (ø)
sei-cosmos/client/test_helpers.go 0.00% <ø> (ø)
sei-cosmos/client/tx/factory.go 23.80% <ø> (ø)
sei-cosmos/client/tx/legacy.go 0.00% <ø> (ø)
sei-cosmos/client/tx/tx.go 6.49% <ø> (ø)
... and 58 more

... and 649 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@masih masih force-pushed the masih/mono-ish-cosmos branch from f9cedeb to 49c8b00 Compare September 30, 2025 08:33
@masih masih marked this pull request as ready for review September 30, 2025 10:06
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
@masih masih merged commit 06a4e24 into main Sep 30, 2025
79 of 84 checks passed
@masih masih deleted the masih/mono-ish-cosmos branch September 30, 2025 13:56
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.