Skip to content

Commit

Permalink
feat: Share cosmos-sdk runtime [viper] configuration with the cosmic-…
Browse files Browse the repository at this point in the history
…swingset VM

Ref #9946
  • Loading branch information
gibson042 committed Aug 30, 2024
1 parent 08b3abb commit f8c6d50
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions golang/cosmos/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import (
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
"github.com/spf13/viper"
abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
Expand Down Expand Up @@ -214,6 +215,7 @@ var (
// capabilities aren't needed for testing.
type GaiaApp struct { // nolint: golint
*baseapp.BaseApp
resolvedConfig map[string]any
legacyAmino *codec.LegacyAmino
appCodec codec.Codec
interfaceRegistry types.InterfaceRegistry
Expand Down Expand Up @@ -359,6 +361,10 @@ func NewAgoricApp(
tkeys: tkeys,
memKeys: memKeys,
}
// The VM is entitled to full awareness of runtime configuration.
if resolvedConfig, ok := appOpts.(*viper.Viper); ok {
app.resolvedConfig = resolvedConfig.AllSettings()
}

app.ParamsKeeper = initParamsKeeper(
appCodec,
Expand Down Expand Up @@ -939,6 +945,7 @@ type cosmosInitAction struct {
ChainID string `json:"chainID"`
IsBootstrap bool `json:"isBootstrap"`
Params swingset.Params `json:"params"`
ResolvedConfig map[string]any `json:"resolvedConfig"`
SupplyCoins sdk.Coins `json:"supplyCoins"`
UpgradeDetails *upgradeDetails `json:"upgradeDetails,omitempty"`
// CAVEAT: Every property ending in "Port" is saved in chain-main.js/portNums
Expand Down Expand Up @@ -976,6 +983,7 @@ func (app *GaiaApp) initController(ctx sdk.Context, bootstrap bool) {
ChainID: ctx.ChainID(),
IsBootstrap: bootstrap,
Params: app.SwingSetKeeper.GetParams(ctx),
ResolvedConfig: app.resolvedConfig,
SupplyCoins: sdk.NewCoins(app.BankKeeper.GetSupply(ctx, "uist")),
UpgradeDetails: app.upgradeDetails,
// See CAVEAT in cosmosInitAction.
Expand Down
1 change: 1 addition & 0 deletions packages/cosmic-swingset/src/chain-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const makeBootMsg = initAction => {
blockHeight,
chainID,
params,
// NB: resolvedConfig is independent of consensus and MUST NOT be included
supplyCoins,
} = initAction;
return {
Expand Down

0 comments on commit f8c6d50

Please sign in to comment.