diff --git a/Makefile b/Makefile index ac1a805e0b..51f45977a9 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ CAT := $(if $(filter $(OS),Windows_NT),type,cat) GithubTop=github.com -Version=v0.12.2 +Version=v0.12.3 CosmosSDK=v0.37.9 Tendermint=v0.32.10 Iavl=v0.12.4 diff --git a/app/genesis/genesis.json b/app/genesis/genesis.json index 883084a971..8fccd0c9de 100644 --- a/app/genesis/genesis.json +++ b/app/genesis/genesis.json @@ -25,7 +25,7 @@ "coins": [ { "amount": "9000000.00000000", - "denom": "okt" + "denom": "tokt" } ], "delegated_free": [], @@ -60,7 +60,7 @@ "crisis": { "constant_fee": { "amount": "1000.00000000", - "denom": "okt" + "denom": "tokt" } }, "debug": null, @@ -72,21 +72,21 @@ "delist_min_deposit": [ { "amount": "100.00000000", - "denom": "okt" + "denom": "tokt" } ], "delist_voting_period": "259200000000000", "list_fee": { "amount": "20000.00000000", - "denom": "okt" + "denom": "tokt" }, "register_operator_fee": { "amount": "0.00000000", - "denom": "okt" + "denom": "tokt" }, "transfer_ownership_fee": { "amount": "10.00000000", - "denom": "okt" + "denom": "tokt" }, "withdraw_period": "259200000000000" }, @@ -115,7 +115,7 @@ "amount": [], "gas": "0" }, - "memo": "ab6f676c5d6b4e7c8233ff4ba63d1b5d0d203b56@127.0.0.1:26656", + "memo": "cd8415810b97c447751f5d959b89c99e7b792937@127.0.0.1:26656", "msg": [ { "type": "okexchain/staking/MsgCreateValidator", @@ -129,9 +129,9 @@ }, "min_self_delegation": { "amount": "0.00100000", - "denom": "okt" + "denom": "tokt" }, - "pubkey": "okexchainvalconspub1zcjduepq83e8r6lrt44sxvg66vhh8l4yhpsr825m97yc7qxu06zhpxezuhhsmalm87", + "pubkey": "okexchainvalconspub1zcjduepqwwmh848ta3zk87lc4xcrdqwtfzry9ucq7m4dhd0nn0f5vyjnn3nsqlf09g", "validator_address": "okexchainvaloper10q0rk5qnyag7wfvvt7rtphlw589m7frshchly8" } } @@ -142,7 +142,7 @@ "type": "tendermint/PubKeySecp256k1", "value": "AgYaL1tZ7ekqvweQhKojG8sDHUfN23qJWviAsTDIWvYU" }, - "signature": "42XTaFLh5Z2Aor2kpY5H32ReUUT6Wa5IZhkGSLMas/gvaPY4Pg5XsFPwUuFJpcj36L+E9BQOjxXhM0VF1rKV7A==" + "signature": "MQ+/q0m26lmj+9l/W4Oo8U8Ukaks3eXwYkPn1sDrtOZXfz8d02dTphT+xs9g3pq+YlJOd87gcO8no2wOttqdWg==" } ] } @@ -155,7 +155,7 @@ "min_deposit": [ { "amount": "100.00000000", - "denom": "okt" + "denom": "tokt" } ] }, @@ -179,7 +179,7 @@ "minted_per_block": [ { "amount": "0.00000000", - "denom": "okt" + "denom": "tokt" } ], "next_block_to_update": "0" @@ -189,7 +189,7 @@ "blocks_per_year": "10519200", "deflation_rate": "0.50000000", "inflation_epoch": "3", - "mint_denom": "okt" + "mint_denom": "tokt" } }, "order": { @@ -198,7 +198,7 @@ "cancel_order_msg_gas_unit": "30000", "fee_per_block": { "amount": "0.00000000", - "denom": "okt" + "denom": "tokt" }, "max_deals_per_block": "1000", "new_order_msg_gas_unit": "40000", @@ -213,7 +213,7 @@ "min_deposit": [ { "amount": "100.00000000", - "denom": "okt" + "denom": "tokt" } ], "voting_period": "259200000000000" @@ -238,7 +238,7 @@ "last_total_power": "0", "last_validator_powers": null, "params": { - "bond_denom": "okt", + "bond_denom": "tokt", "epoch": 252, "max_bonded_validators": 21, "max_validators_to_add_shares": 30, @@ -260,34 +260,34 @@ "params": { "burn_fee": { "amount": "10.00000000", - "denom": "okt" + "denom": "tokt" }, "issue_fee": { "amount": "2500.00000000", - "denom": "okt" + "denom": "tokt" }, "mint_fee": { "amount": "10.00000000", - "denom": "okt" + "denom": "tokt" }, "modify_fee": { "amount": "0.00000000", - "denom": "okt" + "denom": "tokt" }, "ownership_confirm_window": "86400000000000", "transfer_ownership_fee": { "amount": "10.00000000", - "denom": "okt" + "denom": "tokt" } }, "tokens": [ { "description": "OK Group Global Utility Token", "mintable": true, - "original_symbol": "okt", + "original_symbol": "tokt", "original_total_supply": "1000000000.00000000", "owner": "okexchain10q0rk5qnyag7wfvvt7rtphlw589m7frsku8qc9", - "symbol": "okt", + "symbol": "tokt", "type": "0", "whole_name": "OKT" } @@ -311,7 +311,7 @@ "app_upgrade_min_deposit": [ { "amount": "100.00000000", - "denom": "okt" + "denom": "tokt" } ], "app_upgrade_voting_period": "259200000000000" diff --git a/go.mod b/go.mod index 438b7f3655..dd075cc85a 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/okex/cosmos-sdk v0.37.9-okexchain4 + github.com/cosmos/cosmos-sdk => github.com/okex/cosmos-sdk v0.37.9-okexchain4-tokt github.com/tendermint/iavl => github.com/okex/iavl v0.12.4-okexchain github.com/tendermint/tendermint => github.com/okex/tendermint v0.32.10-okexchain ) diff --git a/go.sum b/go.sum index da2c30e9d4..db14b16b84 100644 --- a/go.sum +++ b/go.sum @@ -242,6 +242,8 @@ github.com/nacos-group/nacos-sdk-go v1.0.0 h1:CufUF7DZca2ZzIrJtMMCDih1sA58BWCglA github.com/nacos-group/nacos-sdk-go v1.0.0/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= github.com/okex/cosmos-sdk v0.37.9-okexchain4 h1:q1YCAUIvHYNd+aVcPOkMOcvRcQUwGkFhKaIgmaVQ5TY= github.com/okex/cosmos-sdk v0.37.9-okexchain4/go.mod h1:HjW0+Q5rWWm+4CaK8f5CIN/xf38vkPA2xue1PB5Nk3A= +github.com/okex/cosmos-sdk v0.37.9-okexchain4-tokt h1:GRXnqEVmzvHYfkCZFquIJOEOEKzypihb2S0G1nZlM8g= +github.com/okex/cosmos-sdk v0.37.9-okexchain4-tokt/go.mod h1:HjW0+Q5rWWm+4CaK8f5CIN/xf38vkPA2xue1PB5Nk3A= github.com/okex/iavl v0.12.4-okexchain h1:fHH/ax1CABQSNiISXIMba3V76qvNZ4HIILaewsMaMbc= github.com/okex/iavl v0.12.4-okexchain/go.mod h1:8LHakzt8/0G3/I8FUU0ReNx98S/EP6eyPJkAUvEXT/o= github.com/okex/tendermint v0.32.10-okexchain h1:fYrmdPNH5e1QGr0lzI4yuBZ6QLv52t4enfoBVAoe5rg= diff --git a/x/backend/orm/backend.db b/x/backend/orm/backend.db index fc09cd0137..a743933f25 100644 Binary files a/x/backend/orm/backend.db and b/x/backend/orm/backend.db differ diff --git a/x/order/keeper/keeper.go b/x/order/keeper/keeper.go index de6c18524a..838568fd6e 100644 --- a/x/order/keeper/keeper.go +++ b/x/order/keeper/keeper.go @@ -452,14 +452,23 @@ func (k Keeper) AddCollectedFees(ctx sdk.Context, coins sdk.DecCoins, from sdk.A // GetParams gets inflation params from the global param store func (k Keeper) GetParams(ctx sdk.Context) *types.Params { + // get params from cache + cacheParams := k.cache.GetParams() + if cacheParams != nil { + return cacheParams + } + + // if param not stored in cache, get param from KVStore and cache it var param types.Params k.paramSpace.GetParamSet(ctx, ¶m) + k.cache.SetParams(¶m) return ¶m } // SetParams sets inflation params from the global param store func (k Keeper) SetParams(ctx sdk.Context, params *types.Params) { k.paramSpace.SetParamSet(ctx, params) + k.cache.SetParams(params) } // nolint diff --git a/x/order/keeper/keeper_test.go b/x/order/keeper/keeper_test.go index 32c4bf0512..76833093f0 100644 --- a/x/order/keeper/keeper_test.go +++ b/x/order/keeper/keeper_test.go @@ -67,7 +67,7 @@ func TestCache(t *testing.T) { order.Sender = testInput.TestAddrs[0] err = keeper.PlaceOrder(ctx, order) require.Nil(t, err) - require.EqualValues(t, 1, keeper.GetParams(ctx).OrderExpireBlocks) + require.EqualValues(t, 1, keeper.GetCache().params.OrderExpireBlocks) require.EqualValues(t, 1, keeper.GetOperationMetric().OpenNum) // current cache diff --git a/x/order/keeper/memory_cache.go b/x/order/keeper/memory_cache.go index d71d5e5547..7617b09ebf 100644 --- a/x/order/keeper/memory_cache.go +++ b/x/order/keeper/memory_cache.go @@ -12,6 +12,8 @@ type Cache struct { blockMatchResult *types.BlockMatchResult handlerTxMsgResult []bitset.BitSet + params *types.Params + // for statistic cancelNum int64 // canceled orders num in this block expireNum int64 // expired orders num in this block @@ -24,6 +26,7 @@ func NewCache() *Cache { return &Cache{ updatedOrderIDs: []string{}, blockMatchResult: nil, + params: nil, } } @@ -32,6 +35,7 @@ func (c *Cache) reset() { c.updatedOrderIDs = []string{} c.blockMatchResult = &types.BlockMatchResult{} c.handlerTxMsgResult = []bitset.BitSet{} + c.params = nil c.cancelNum = 0 c.expireNum = 0 @@ -99,6 +103,16 @@ func (c *Cache) getBlockMatchResult() *types.BlockMatchResult { return c.blockMatchResult } +// nolint +func (c *Cache) SetParams(params *types.Params) { + c.params = params +} + +// nolint +func (c *Cache) GetParams() *types.Params { + return c.params +} + func (c *Cache) getUpdatedOrderIDs() []string { return c.updatedOrderIDs } diff --git a/x/order/keeper/memory_cache_test.go b/x/order/keeper/memory_cache_test.go index 7848c47cf5..2f81c73fef 100644 --- a/x/order/keeper/memory_cache_test.go +++ b/x/order/keeper/memory_cache_test.go @@ -30,6 +30,11 @@ func TestCache_GetCancelNum(t *testing.T) { require.EqualValues(t, 0, cache.GetFullFillNum()) require.EqualValues(t, 0, cache.GetPartialFillNum()) + feeParams := types.DefaultTestParams() + cache.SetParams(&feeParams) + + require.EqualValues(t, types.DefaultOrderExpireBlocks, cache.params.OrderExpireBlocks) + res := types.BlockMatchResult{ BlockHeight: 0, ResultMap: nil, @@ -38,4 +43,8 @@ func TestCache_GetCancelNum(t *testing.T) { cache.setBlockMatchResult(&res) require.NotEqual(t, 0, cache.getBlockMatchResult().TimeStamp) + + cache.reset() + require.Nil(t, cache.GetParams()) + }