Skip to content

Commit c9c8d81

Browse files
committed
fix(cosmos): don't twiddle the genesis params, set them explicitly
1 parent 71f8101 commit c9c8d81

File tree

2 files changed

+18
-29
lines changed

2 files changed

+18
-29
lines changed

golang/cosmos/app/app.go

+2-29
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/rakyll/statik/fs"
1818

1919
abci "github.com/tendermint/tendermint/abci/types"
20+
tmjson "github.com/tendermint/tendermint/libs/json"
2021
"github.com/tendermint/tendermint/libs/log"
2122
tmos "github.com/tendermint/tendermint/libs/os"
2223
dbm "github.com/tendermint/tm-db"
@@ -610,43 +611,15 @@ func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.R
610611
return app.mm.EndBlock(ctx, req)
611612
}
612613

613-
func updateTransferPort(gs GenesisState, reservedPort, newPort string) error {
614-
var transferGenesis ibctransfertypes.GenesisState
615-
if err := json.Unmarshal(gs[ibctransfertypes.ModuleName], &transferGenesis); err != nil {
616-
return err
617-
}
618-
if len(transferGenesis.PortId) > 0 && transferGenesis.PortId != reservedPort {
619-
// Already not the reserved port name.
620-
return nil
621-
}
622-
// Change the listening IBC port to avoid conflict.
623-
transferGenesis.PortId = newPort
624-
transferGenesisBytes, err := json.Marshal(transferGenesis)
625-
if err != nil {
626-
return err
627-
}
628-
gs[ibctransfertypes.ModuleName] = transferGenesisBytes
629-
return nil
630-
}
631-
632614
// InitChainer application update at chain initialization
633615
func (app *GaiaApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
634616
var genesisState GenesisState
635-
if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
636-
panic(err)
637-
}
638-
if err := updateTransferPort(genesisState, "transfer", "cosmos-transfer"); err != nil {
617+
if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
639618
panic(err)
640619
}
641620
app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
642621
res := app.mm.InitGenesis(ctx, app.appCodec, genesisState)
643622

644-
// Set Historical infos in InitChain to ignore genesis params
645-
// This is needed for IBC connections not to time out easily
646-
stakingParams := app.StakingKeeper.GetParams(ctx)
647-
stakingParams.HistoricalEntries = 10000
648-
app.StakingKeeper.SetParams(ctx, stakingParams)
649-
650623
// Agoric: report the genesis time explicitly.
651624
genTime := req.GetTime()
652625
if genTime.After(time.Now()) {

packages/agoric-cli/src/chain-config.js

+16
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ export const CENTRAL_DENOM = 'urun';
55
export const MINT_DENOM = 'ubld';
66
export const STAKING_DENOM = 'ubld';
77
export const STAKING_MAX_VALIDATORS = 150;
8+
// Required for IBC connections not to time out.
9+
export const STAKING_MIN_HISTORICAL_ENTRIES = 10000;
10+
11+
// We reserve the default `transfer` IBC port for Pegasus (JS-level ERTP
12+
// assets). The `cosmos-transfer` IBC port is used for ibc-go (Cosmos-level
13+
// prefixed string token denominations).
14+
export const COSMOS_TRANSFER_PORT_ID = 'cosmos-transfer';
815

916
export const DENOM_METADATA = [
1017
{
@@ -178,6 +185,15 @@ export function finishCosmosGenesis({ genesisJson, exportedGenesisJson }) {
178185

179186
genesis.app_state.staking.params.bond_denom = STAKING_DENOM;
180187
genesis.app_state.staking.params.max_validators = STAKING_MAX_VALIDATORS;
188+
const {
189+
historical_entries: existingHistoricalEntries = 0,
190+
} = genesis.app_state.staking.params;
191+
genesis.app_state.staking.params.historical_entries = Math.max(
192+
existingHistoricalEntries,
193+
STAKING_MIN_HISTORICAL_ENTRIES,
194+
);
195+
196+
genesis.app_state.transfer.port_id = COSMOS_TRANSFER_PORT_ID;
181197

182198
// We scale this parameter according to our own block cadence, so
183199
// that we tolerate the same downtime as the old genesis.

0 commit comments

Comments
 (0)