Skip to content

Commit 78959fa

Browse files
authored
revert: "perf: optimise staking endblocker (#1725)" (#1738)
* Revert "perf: optimise staking endblocker (#1725)" This reverts commit d8ed3ff. * gofumpt
1 parent 6fa6924 commit 78959fa

File tree

25 files changed

+61
-3903
lines changed

25 files changed

+61
-3903
lines changed

CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ Ref: https://keepachangelog.com/en/1.0.0/
4040

4141
### Features
4242

43-
* (x/staking) [#1730](https://github.com/crypto-org-chain/cosmos-sdk/pull/1730) Normalize cache validator queue key to be UTC.
44-
* (x/staking) [#1725](https://github.com/crypto-org-chain/cosmos-sdk/pull/1725) Optimize staking endblocker execution by caching queue entries from iterators.
4543
* (baseapp) [#205](https://github.com/crypto-org-chain/cosmos-sdk/pull/205) Add `TxExecutor` baseapp option, add `TxIndex`/`TxCount`/`MsgIndex`/`BlockGasUsed` fields to `Context, to support tx parallel execution.
4644
* (baseapp) [#206](https://github.com/crypto-org-chain/cosmos-sdk/pull/206) Support mount object store in baseapp, add `ObjectStore` api in context, [#585](https://github.com/crypto-org-chain/cosmos-sdk/pull/585) Skip snapshot for object store.
4745
* (bank) [#237](https://github.com/crypto-org-chain/cosmos-sdk/pull/237) Support virtual accounts in sending coins.

proto/cosmos/staking/v1beta1/query.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,4 +384,4 @@ message QueryParamsRequest {}
384384
message QueryParamsResponse {
385385
// params holds all the parameters of this module.
386386
Params params = 1 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
387-
}
387+
}

server/config/config.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,6 @@ type MempoolConfig struct {
168168
MaxTxs int `mapstructure:"max-txs"`
169169
}
170170

171-
// StakingConfig defines the staking module configuration
172-
type StakingConfig struct {
173-
// CacheSize defines the maximum number of time-based queue entries to cache
174-
// for unbonding validators, unbonding delegations, and redelegations.
175-
// cache-size = 0 means unlimited cache (no size limit).
176-
// cache-size < 0 means the cache is disabled.
177-
// cache-size > 0 sets a size limit for the cache.
178-
CacheSize int `mapstructure:"cache-size"`
179-
}
180-
181171
// State Streaming configuration
182172
type (
183173
// StreamingConfig defines application configuration for external streaming services
@@ -204,7 +194,6 @@ type Config struct {
204194
StateSync StateSyncConfig `mapstructure:"state-sync"`
205195
Streaming StreamingConfig `mapstructure:"streaming"`
206196
Mempool MempoolConfig `mapstructure:"mempool"`
207-
Staking StakingConfig `mapstructure:"staking"`
208197
}
209198

210199
// SetMinGasPrices sets the validator's minimum gas prices.
@@ -276,9 +265,6 @@ func DefaultConfig() *Config {
276265
Mempool: MempoolConfig{
277266
MaxTxs: -1,
278267
},
279-
Staking: StakingConfig{
280-
CacheSize: 0,
281-
},
282268
}
283269
}
284270

server/config/toml.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -246,18 +246,6 @@ stop-node-on-err = {{ .Streaming.ABCI.StopNodeOnErr }}
246246
# Note, this configuration only applies to SDK built-in app-side mempool
247247
# implementations.
248248
max-txs = {{ .Mempool.MaxTxs }}
249-
250-
###############################################################################
251-
### Modules ###
252-
###############################################################################
253-
254-
[staking]
255-
# cache-size defines the maximum number of time-based queue entries to cache
256-
# for unbonding validators, unbonding delegations, and redelegations.
257-
# cache-size = 0 means unlimited cache (no size limit).
258-
# cache-size < 0 means the cache is disabled.
259-
# cache-size > 0 sets a size limit for the cache.
260-
cache-size = {{ .Staking.CacheSize }}
261249
`
262250

263251
var configTemplate *template.Template

server/start.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ const (
100100
// mempool flags
101101
FlagMempoolMaxTxs = "mempool.max-txs"
102102

103-
// staking flags
104-
FlagStakingCacheSize = "staking.cache-size"
105-
106103
// testnet keys
107104
KeyIsTestnet = "is-testnet"
108105
KeyNewChainID = "new-chain-ID"
@@ -1000,7 +997,6 @@ func addStartNodeFlags(cmd *cobra.Command, opts StartCmdOptions) {
1000997
cmd.Flags().Uint32(FlagStateSyncSnapshotKeepRecent, 2, "State sync snapshot to keep")
1001998
cmd.Flags().Bool(FlagDisableIAVLFastNode, false, "Disable fast node for IAVL tree")
1002999
cmd.Flags().Int(FlagMempoolMaxTxs, mempool.DefaultMaxTx, "Sets MaxTx value for the app-side mempool")
1003-
cmd.Flags().Int(FlagStakingCacheSize, 0, "Sets the cache size for staking unbonding queues (0 = unlimited, negative = disabled)")
10041000
cmd.Flags().Duration(FlagShutdownGrace, 0*time.Second, "On Shutdown, duration to wait for resource clean up")
10051001

10061002
// support old flags name for backwards compatibility

simapp/app.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,8 @@ func NewSimApp(
316316
}
317317
app.txConfig = txConfig
318318

319-
stakingCacheSize := cast.ToInt(appOpts.Get(server.FlagStakingCacheSize))
320-
321319
app.StakingKeeper = stakingkeeper.NewKeeper(
322-
appCodec, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), authcodec.NewBech32Codec(sdk.Bech32PrefixValAddr), authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), stakingCacheSize,
320+
appCodec, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), app.AccountKeeper, app.BankKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), authcodec.NewBech32Codec(sdk.Bech32PrefixValAddr), authcodec.NewBech32Codec(sdk.Bech32PrefixConsAddr),
323321
)
324322
app.MintKeeper = mintkeeper.NewKeeper(appCodec, runtime.NewKVStoreService(keys[minttypes.StoreKey]), app.StakingKeeper, app.AccountKeeper, app.BankKeeper, authtypes.FeeCollectorName, authtypes.NewModuleAddress(govtypes.ModuleName).String())
325323

simapp/app_di.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"io"
77

88
dbm "github.com/cosmos/cosmos-db"
9-
"github.com/spf13/cast"
109

1110
clienthelpers "cosmossdk.io/client/v2/helpers"
1211
"cosmossdk.io/depinject"
@@ -97,10 +96,6 @@ func init() {
9796
}
9897
}
9998

100-
func ProvideStakingCacheSize(appOpts servertypes.AppOptions) int {
101-
return cast.ToInt(appOpts.Get(server.FlagStakingCacheSize))
102-
}
103-
10499
// NewSimApp returns a reference to an initialized SimApp.
105100
func NewSimApp(
106101
logger log.Logger,
@@ -163,7 +158,6 @@ func NewSimApp(
163158
// custom function that implements the minttypes.InflationCalculationFn
164159
// interface.
165160
),
166-
depinject.Provide(ProvideStakingCacheSize),
167161
)
168162
)
169163

tests/integration/distribution/keeper/msg_server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func initFixture(t testing.TB) *fixture {
107107
log.NewNopLogger(),
108108
)
109109

110-
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), 0)
110+
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr))
111111

112112
distrKeeper := distrkeeper.NewKeeper(
113113
cdc, runtime.NewKVStoreService(keys[distrtypes.StoreKey]), accountKeeper, bankKeeper, stakingKeeper, distrtypes.ModuleName, authority.String(),

tests/integration/evidence/keeper/infraction_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func initFixture(t testing.TB) *fixture {
124124
log.NewNopLogger(),
125125
)
126126

127-
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), 0)
127+
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr))
128128

129129
slashingKeeper := slashingkeeper.NewKeeper(cdc, codec.NewLegacyAmino(), runtime.NewKVStoreService(keys[slashingtypes.StoreKey]), stakingKeeper, authority.String())
130130

tests/integration/gov/keeper/keeper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func initFixture(t testing.TB) *fixture {
9595
log.NewNopLogger(),
9696
)
9797

98-
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr), 0)
98+
stakingKeeper := stakingkeeper.NewKeeper(cdc, runtime.NewKVStoreService(keys[stakingtypes.StoreKey]), accountKeeper, bankKeeper, authority.String(), addresscodec.NewBech32Codec(sdk.Bech32PrefixValAddr), addresscodec.NewBech32Codec(sdk.Bech32PrefixConsAddr))
9999

100100
// set default staking params
101101
stakingKeeper.SetParams(newCtx, stakingtypes.DefaultParams())

0 commit comments

Comments
 (0)