Skip to content

Commit 2aedee8

Browse files
committed
fix: staking optimization, add integration tests for staking cache, reject staking related messages
1 parent 4003261 commit 2aedee8

File tree

10 files changed

+1353
-53
lines changed

10 files changed

+1353
-53
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
timeout-minutes: 240
2020
strategy:
2121
matrix:
22-
tests: [unmarked, ibc, ibc_rly_evm, ibc_rly_gas, ibc_timeout, ibc_update_client, ica, gov, upgrade, slow, gas, mint, evm]
22+
tests: [unmarked, ibc, ibc_rly_evm, ibc_rly_gas, ibc_timeout, ibc_update_client, ica, gov, upgrade, slow, gas, mint, evm, staking]
2323
env:
2424
TESTS_TO_RUN: ${{ matrix.tests }}
2525
steps:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## UNRELEASED
44

5+
* [#1910](https://github.com/crypto-org-chain/cronos/pull/1910) fix: Optimize staking endblocker with an in-memory KV store and standardize gas consumption for staking related messages. Temporary patch to not allow staking messages.
6+
7+
*Jan 13, 2026*
8+
9+
## v1.7.0
10+
511
### Improvements
612

713
* [#1895](https://github.com/crypto-org-chain/cronos/pull/1895) feat: use cronos store.

app/app.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ func StoreKeys() (
234234
map[string]*storetypes.KVStoreKey,
235235
map[string]*storetypes.TransientStoreKey,
236236
map[string]*storetypes.ObjectStoreKey,
237+
map[string]*storetypes.MemoryStoreKey,
237238
) {
238239
storeKeys := []string{
239240
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
@@ -255,9 +256,10 @@ func StoreKeys() (
255256
}
256257
keys := storetypes.NewKVStoreKeys(storeKeys...)
257258
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
259+
memKeys := storetypes.NewMemoryStoreKeys(stakingtypes.CacheStoreKey, cronostypes.MemStoreKey)
258260
okeys := storetypes.NewObjectStoreKeys(banktypes.ObjectStoreKey, evmtypes.ObjectStoreKey)
259261

260-
return keys, tkeys, okeys
262+
return keys, tkeys, okeys, memKeys
261263
}
262264

263265
var (
@@ -285,10 +287,10 @@ type App struct {
285287
pendingTxListeners []evmante.PendingTxListener
286288

287289
// keys to access the substores
288-
keys map[string]*storetypes.KVStoreKey
289-
tkeys map[string]*storetypes.TransientStoreKey
290-
okeys map[string]*storetypes.ObjectStoreKey
291-
290+
keys map[string]*storetypes.KVStoreKey
291+
tkeys map[string]*storetypes.TransientStoreKey
292+
okeys map[string]*storetypes.ObjectStoreKey
293+
memKeys map[string]*storetypes.MemoryStoreKey
292294
// keepers
293295
AccountKeeper authkeeper.AccountKeeper
294296
BankKeeper bankkeeper.Keeper
@@ -448,7 +450,7 @@ func New(
448450
bApp.SetInterfaceRegistry(interfaceRegistry)
449451
bApp.SetTxEncoder(txConfig.TxEncoder())
450452

451-
keys, tkeys, okeys := StoreKeys()
453+
keys, tkeys, okeys, memKeys := StoreKeys()
452454

453455
invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod))
454456
app := &App{
@@ -462,6 +464,7 @@ func New(
462464
keys: keys,
463465
tkeys: tkeys,
464466
okeys: okeys,
467+
memKeys: memKeys,
465468
blockProposalHandler: blockProposalHandler,
466469
dummyCheckTx: cast.ToBool(appOpts.Get(FlagUnsafeDummyCheckTx)),
467470
}
@@ -517,14 +520,17 @@ func New(
517520
panic(err)
518521
}
519522
app.txConfig = txConfig
523+
stakingCacheSize := cast.ToInt(appOpts.Get(server.FlagStakingCacheSize))
520524
app.StakingKeeper = stakingkeeper.NewKeeper(
521525
appCodec,
522526
runtime.NewKVStoreService(keys[stakingtypes.StoreKey]),
527+
runtime.NewMemStoreService(memKeys[stakingtypes.CacheStoreKey]),
523528
app.AccountKeeper,
524529
app.BankKeeper,
525530
authAddr,
526531
address.NewBech32Codec(sdk.GetConfig().GetBech32ValidatorAddrPrefix()),
527532
address.NewBech32Codec(sdk.GetConfig().GetBech32ConsensusAddrPrefix()),
533+
stakingCacheSize,
528534
)
529535
app.MintKeeper = mintkeeper.NewKeeper(
530536
appCodec,
@@ -667,7 +673,7 @@ func New(
667673
app.CronosKeeper = *cronoskeeper.NewKeeper(
668674
appCodec,
669675
keys[cronostypes.StoreKey],
670-
keys[cronostypes.MemStoreKey],
676+
memKeys[cronostypes.MemStoreKey],
671677
app.BankKeeper,
672678
app.TransferKeeper,
673679
app.EvmKeeper,
@@ -976,7 +982,7 @@ func New(
976982
app.MountKVStores(keys)
977983
app.MountTransientStores(tkeys)
978984
app.MountObjectStores(okeys)
979-
985+
app.MountMemoryStores(memKeys)
980986
// initialize BaseApp
981987
app.SetInitChainer(app.InitChainer)
982988
app.SetPreBlocker(app.PreBlocker)

cmd/cronosd/cmd/versiondb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
func ChangeSetCmd() *cobra.Command {
16-
keys, _, _ := app.StoreKeys()
16+
keys, _, _, _ := app.StoreKeys()
1717
storeNames := make([]string, 0, len(keys))
1818
for name := range keys {
1919
storeNames = append(storeNames, name)

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ require (
280280
replace (
281281
cosmossdk.io/store => github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241217090828-cfbca9fe8254
282282
cosmossdk.io/x/tx => github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20241217090828-cfbca9fe8254
283-
github.com/cosmos/cosmos-sdk => github.com/crypto-org-chain/cosmos-sdk v0.50.6-0.20251119062431-8d0a31ef043d
283+
// release/v0.50-cronosv1.6.x
284+
github.com/cosmos/cosmos-sdk => github.com/crypto-org-chain/cosmos-sdk v0.50.6-0.20251121110054-d5e74b9954c1
284285
)
285286

286287
replace (
@@ -301,8 +302,8 @@ replace (
301302
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
302303
// release/v1.15
303304
github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20250815065500-a4fbafcae0dd
304-
// develop
305-
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.22.1-0.20260126081129-9e97913655b0
305+
// release/v0.23.x-cronosv1.7-optstaking
306+
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.22.1-0.20260128090714-564553927d5f
306307
// Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities.
307308
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
308309
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -905,8 +905,8 @@ github.com/crypto-org-chain/btree v0.0.0-20240406140148-2687063b042c h1:MOgfS4+F
905905
github.com/crypto-org-chain/btree v0.0.0-20240406140148-2687063b042c/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
906906
github.com/crypto-org-chain/cometbft v0.0.0-20260126040959-178ea8502144 h1:z0YilxbNefKWly63vdJYTUHX62I1iNvQ3P42x5WMSlE=
907907
github.com/crypto-org-chain/cometbft v0.0.0-20260126040959-178ea8502144/go.mod h1:khbgmtxbgwJfMqDmnGY4rl2sQpTdzpPb1f9nqnfpy1o=
908-
github.com/crypto-org-chain/cosmos-sdk v0.50.6-0.20251119062431-8d0a31ef043d h1:ffzsdKbhbSSBIMBAGJGjezjEr60A/JgpznOJhMUMbfE=
909-
github.com/crypto-org-chain/cosmos-sdk v0.50.6-0.20251119062431-8d0a31ef043d/go.mod h1:8/AdT5lF3ILCCl/sDQXyBgzWGtcmD1tInWyhYeREVPA=
908+
github.com/crypto-org-chain/cosmos-sdk v0.50.6-0.20251121110054-d5e74b9954c1 h1:avJ9ZWgOmLtAng88daxHgmkJhoqNqjOW6kIeJs+jMIw=
909+
github.com/crypto-org-chain/cosmos-sdk v0.50.6-0.20251121110054-d5e74b9954c1/go.mod h1:8/AdT5lF3ILCCl/sDQXyBgzWGtcmD1tInWyhYeREVPA=
910910
github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241217090828-cfbca9fe8254 h1:NEgy0r3otU/O+0OAjMdEhbn4VotQlg+98hHbD7M23wU=
911911
github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20241217090828-cfbca9fe8254/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
912912
github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20241217090828-cfbca9fe8254 h1:JzLOFRiKsDtLJt5h0M0jkEIPDKvFFyja7VEp7gG6O9U=
@@ -917,8 +917,8 @@ github.com/crypto-org-chain/cronos-store/store v0.0.0-20251203075505-0670ff683f0
917917
github.com/crypto-org-chain/cronos-store/store v0.0.0-20251203075505-0670ff683f07/go.mod h1:QtmMmgHYQqioX/U2OfucmqDgXMmrL3N8/QXom4UWeKg=
918918
github.com/crypto-org-chain/cronos-store/versiondb v0.0.0-20251203075505-0670ff683f07 h1:eMuGwzyL4ond46wHHIybHT9fBoFxfWzkeX87IannqG4=
919919
github.com/crypto-org-chain/cronos-store/versiondb v0.0.0-20251203075505-0670ff683f07/go.mod h1:6sg+tT7xMKDS8HL9Rxq1QsLJHApMuh+vnr2HVl3utl0=
920-
github.com/crypto-org-chain/ethermint v0.22.1-0.20260126081129-9e97913655b0 h1:307HUUXZ0qyBkkIic4pHlDN24J9/mEetTxJcK1dcmzI=
921-
github.com/crypto-org-chain/ethermint v0.22.1-0.20260126081129-9e97913655b0/go.mod h1:FrMBOJjJFGiWDQUDmwZNKsw2Gz5tvl9AYEfUuD7lvSQ=
920+
github.com/crypto-org-chain/ethermint v0.22.1-0.20260128090714-564553927d5f h1:Ew5roNKfUwaKUu206CxzbI2w6rJi0EWSLD7gINvtzu4=
921+
github.com/crypto-org-chain/ethermint v0.22.1-0.20260128090714-564553927d5f/go.mod h1:2FOHyqyc/efUblQOLwy63p7uDKIeGdzeKH50kY5p/Bg=
922922
github.com/crypto-org-chain/go-block-stm v0.0.0-20241213061541-7afe924fb4a6 h1:6KPEi8dWkDSBddQb4NAvEXmNnTXymF3yVeTaT4Hz1iU=
923923
github.com/crypto-org-chain/go-block-stm v0.0.0-20241213061541-7afe924fb4a6/go.mod h1:iwQTX9xMX8NV9k3o2BiWXA0SswpsZrDk5q3gA7nWYiE=
924924
github.com/crypto-org-chain/go-ethereum v1.10.20-0.20250815065500-a4fbafcae0dd h1:ebSnzvM9yKVGFjvoGly7LFQQCS2HuOWMCvQyByJ52Gs=

gomod2nix.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ schema = 3
213213
version = "v1.0.0-beta.5"
214214
hash = "sha256-Fy/PbsOsd6iq0Njy3DVWK6HqWsogI+MkE8QslHGWyVg="
215215
[mod."github.com/cosmos/cosmos-sdk"]
216-
version = "v0.50.6-0.20251119062431-8d0a31ef043d"
217-
hash = "sha256-VxQus9ynUK8nAZh3ubNXRcxJsITzgndjd7UYYgMt6C0="
216+
version = "v0.50.6-0.20251121110054-d5e74b9954c1"
217+
hash = "sha256-XzBX/BIFpKZWMBqyGML0RpSBHMnQu1QVY9+dMi85mws="
218218
replaced = "github.com/crypto-org-chain/cosmos-sdk"
219219
[mod."github.com/cosmos/go-bip39"]
220220
version = "v1.0.0"
@@ -324,8 +324,8 @@ schema = 3
324324
version = "v0.2.2"
325325
hash = "sha256-0MLfSJKdeK3Z7tWAXTdzwB4091dmyxIX38S5SKH5QAw="
326326
[mod."github.com/evmos/ethermint"]
327-
version = "v0.22.1-0.20260126081129-9e97913655b0"
328-
hash = "sha256-DLXavEyX/Usz0rW1a6H1tHMzk690WJSoeCI5xZntN1I="
327+
version = "v0.22.1-0.20260128090714-564553927d5f"
328+
hash = "sha256-5JTQFwhPAaTQsTq3nNMI/stPB8h2hl+qUqp6W6rcCWU="
329329
replaced = "github.com/crypto-org-chain/ethermint"
330330
[mod."github.com/fatih/color"]
331331
version = "v1.17.0"

0 commit comments

Comments
 (0)