From b271c40783348abeefa123cf112fc1567edc7815 Mon Sep 17 00:00:00 2001 From: Anton Kaliaev Date: Wed, 11 Jul 2018 13:36:48 +0400 Subject: [PATCH] remove deprecated `app_options` field from genesis --- CHANGELOG.md | 5 +++++ consensus/replay.go | 2 +- scripts/wire2amino.go | 9 ++++----- types/genesis.go | 12 +----------- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fcab4b83..d34338a91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## TBD + +IMPROVEMENTS: +- [genesis] removed deprecated `app_options` field. + ## 0.22.2 *July 10th, 2018* diff --git a/consensus/replay.go b/consensus/replay.go index 3035f75d8..dd940998f 100644 --- a/consensus/replay.go +++ b/consensus/replay.go @@ -273,7 +273,7 @@ func (h *Handshaker) ReplayBlocks(state sm.State, appHash []byte, appBlockHeight ChainId: h.genDoc.ChainID, ConsensusParams: csParams, Validators: validators, - AppStateBytes: h.genDoc.AppStateJSON, + AppStateBytes: h.genDoc.AppState, } res, err := proxyApp.Consensus().InitChainSync(req) if err != nil { diff --git a/scripts/wire2amino.go b/scripts/wire2amino.go index 867c5735a..4933260e8 100644 --- a/scripts/wire2amino.go +++ b/scripts/wire2amino.go @@ -29,9 +29,8 @@ type Genesis struct { ConsensusParams *types.ConsensusParams `json:"consensus_params,omitempty"` Validators []GenesisValidator `json:"validators"` AppHash cmn.HexBytes `json:"app_hash"` - AppStateJSON json.RawMessage `json:"app_state,omitempty"` + AppState json.RawMessage `json:"app_state,omitempty"` AppOptions json.RawMessage `json:"app_options,omitempty"` // DEPRECATED - } type NodeKey struct { @@ -112,12 +111,12 @@ func convertGenesis(cdc *amino.Codec, jsonBytes []byte) ([]byte, error) { ChainID: genesis.ChainID, ConsensusParams: genesis.ConsensusParams, // Validators - AppHash: genesis.AppHash, - AppStateJSON: genesis.AppStateJSON, + AppHash: genesis.AppHash, + AppState: genesis.AppState, } if genesis.AppOptions != nil { - genesisNew.AppStateJSON = genesis.AppOptions + genesisNew.AppState = genesis.AppOptions } for _, v := range genesis.Validators { diff --git a/types/genesis.go b/types/genesis.go index 0367c6b2f..220ee0e0e 100644 --- a/types/genesis.go +++ b/types/genesis.go @@ -26,17 +26,7 @@ type GenesisDoc struct { ConsensusParams *ConsensusParams `json:"consensus_params,omitempty"` Validators []GenesisValidator `json:"validators"` AppHash cmn.HexBytes `json:"app_hash"` - AppStateJSON json.RawMessage `json:"app_state,omitempty"` - AppOptions json.RawMessage `json:"app_options,omitempty"` // DEPRECATED -} - -// AppState returns raw application state. -// TODO: replace with AppState field during next breaking release (0.18) -func (genDoc *GenesisDoc) AppState() json.RawMessage { - if len(genDoc.AppOptions) > 0 { - return genDoc.AppOptions - } - return genDoc.AppStateJSON + AppState json.RawMessage `json:"app_state,omitempty"` } // SaveAs is a utility method for saving GenensisDoc as a JSON file.