@@ -16,21 +16,16 @@ import (
1616 "github.com/cosmos/cosmos-sdk/wire"
1717 "github.com/cosmos/cosmos-sdk/x/auth"
1818 "github.com/cosmos/cosmos-sdk/x/bank"
19- "github.com/cosmos/cosmos-sdk/x/gov"
20- "github.com/cosmos/cosmos-sdk/x/ibc"
19+ "github.com/irisnet/irishub/modules/gov"
2120 "github.com/cosmos/cosmos-sdk/x/params"
2221 "github.com/cosmos/cosmos-sdk/x/slashing"
2322 "github.com/cosmos/cosmos-sdk/x/stake"
24- "github.com/irisnet/irishub/modules/upgrade"
25-
2623 "errors"
27- "fmt"
2824 "github.com/cosmos/cosmos-sdk/server"
2925 "github.com/spf13/viper"
3026 tmcli "github.com/tendermint/tendermint/libs/cli"
3127 "github.com/tendermint/tendermint/node"
3228 sm "github.com/tendermint/tendermint/state"
33- "strings"
3429)
3530
3631const (
@@ -52,24 +47,20 @@ type IrisApp struct {
5247 // keys to access the substores
5348 keyMain * sdk.KVStoreKey
5449 keyAccount * sdk.KVStoreKey
55- keyIBC * sdk.KVStoreKey
5650 keyStake * sdk.KVStoreKey
5751 keySlashing * sdk.KVStoreKey
5852 keyGov * sdk.KVStoreKey
5953 keyFeeCollection * sdk.KVStoreKey
6054 keyParams * sdk.KVStoreKey
61- keyUpgrade * sdk.KVStoreKey
6255
6356 // Manage getting and setting accounts
6457 accountMapper auth.AccountMapper
6558 feeCollectionKeeper auth.FeeCollectionKeeper
6659 coinKeeper bank.Keeper
67- ibcMapper ibc.Mapper
6860 stakeKeeper stake.Keeper
6961 slashingKeeper slashing.Keeper
7062 govKeeper gov.Keeper
7163 paramsKeeper params.Keeper
72- upgradeKeeper upgrade.Keeper
7364}
7465
7566func NewIrisApp (logger log.Logger , db dbm.DB , traceStore io.Writer , baseAppOptions ... func (* bam.BaseApp )) * IrisApp {
@@ -84,18 +75,11 @@ func NewIrisApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
8475 cdc : cdc ,
8576 keyMain : sdk .NewKVStoreKey ("main" ),
8677 keyAccount : sdk .NewKVStoreKey ("acc" ),
87- keyIBC : sdk .NewKVStoreKey ("ibc" ),
8878 keyStake : sdk .NewKVStoreKey ("stake" ),
8979 keySlashing : sdk .NewKVStoreKey ("slashing" ),
9080 keyGov : sdk .NewKVStoreKey ("gov" ),
9181 keyFeeCollection : sdk .NewKVStoreKey ("fee" ),
9282 keyParams : sdk .NewKVStoreKey ("params" ),
93- keyUpgrade : sdk .NewKVStoreKey ("upgrade" ),
94- }
95-
96- var lastHeight int64
97- if viper .GetBool (FlagReplay ) {
98- lastHeight = app .replay ()
9983 }
10084
10185 // define the accountMapper
@@ -108,57 +92,44 @@ func NewIrisApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
10892 // add handlers
10993 app .paramsKeeper = params .NewKeeper (app .cdc , app .keyParams )
11094 app .coinKeeper = bank .NewKeeper (app .accountMapper )
111- app .ibcMapper = ibc .NewMapper (app .cdc , app .keyIBC , app .RegisterCodespace (ibc .DefaultCodespace ))
11295 app .stakeKeeper = stake .NewKeeper (app .cdc , app .keyStake , app .coinKeeper , app .RegisterCodespace (stake .DefaultCodespace ))
11396 app .slashingKeeper = slashing .NewKeeper (app .cdc , app .keySlashing , app .stakeKeeper , app .RegisterCodespace (slashing .DefaultCodespace ))
11497 app .feeCollectionKeeper = auth .NewFeeCollectionKeeper (app .cdc , app .keyFeeCollection , app .paramsKeeper .Getter ())
115- app .upgradeKeeper = upgrade .NewKeeper (app .cdc , app .keyUpgrade , app .stakeKeeper , app .paramsKeeper .Setter ())
11698 app .govKeeper = gov .NewKeeper (app .cdc , app .keyGov , app .paramsKeeper .Setter (), app .coinKeeper , app .stakeKeeper , app .RegisterCodespace (gov .DefaultCodespace ))
11799 //app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.paramsKeeper.Setter(), app.coinKeeper, app.stakeKeeper, app.RegisterCodespace(gov.DefaultCodespace))
118100
119101 // register message routes
120102 // need to update each module's msg type
121103 app .Router ().
122104 AddRoute ("bank" , []* sdk.KVStoreKey {app .keyAccount }, bank .NewHandler (app .coinKeeper )).
123- AddRoute ("ibc" , []* sdk.KVStoreKey {app .keyIBC , app .keyAccount }, ibc .NewHandler (app .ibcMapper , app .coinKeeper )).
124105 AddRoute ("stake" , []* sdk.KVStoreKey {app .keyStake , app .keyAccount }, stake .NewHandler (app .stakeKeeper )).
125106 AddRoute ("slashing" , []* sdk.KVStoreKey {app .keySlashing , app .keyStake }, slashing .NewHandler (app .slashingKeeper )).
126- AddRoute ("gov" , []* sdk.KVStoreKey {app .keyGov , app .keyAccount , app .keyStake , app .keyParams }, gov .NewHandler (app .govKeeper )).
127- AddRoute ("upgrade" , []* sdk.KVStoreKey {app .keyUpgrade , app .keyStake }, upgrade .NewHandler (app .upgradeKeeper ))
107+ AddRoute ("gov" , []* sdk.KVStoreKey {app .keyGov , app .keyAccount , app .keyStake , app .keyParams }, gov .NewHandler (app .govKeeper ))
128108
129109 // initialize BaseApp
130110 app .SetInitChainer (app .initChainer )
131111 app .SetBeginBlocker (app .BeginBlocker )
132112 app .SetEndBlocker (app .EndBlocker )
133113 app .SetAnteHandler (auth .NewAnteHandler (app .accountMapper , app .feeCollectionKeeper ))
134114 app .SetFeeRefundHandler (auth .NewFeeRefundHandler (app .accountMapper , app .feeCollectionKeeper ))
135- app .MountStoresIAVL (app .keyMain , app .keyAccount , app .keyIBC , app .keyStake , app .keySlashing , app .keyGov , app .keyFeeCollection , app .keyParams , app .keyUpgrade )
136- app .SetRunMsg (app .runMsgs )
115+ app .MountStoresIAVL (app .keyMain , app .keyAccount , app .keyStake , app .keySlashing , app .keyGov , app .keyFeeCollection , app .keyParams )
137116 var err error
138- if viper .GetBool (FlagReplay ) {
139- err = app .LoadVersion (lastHeight , app .keyMain )
140- } else {
141- err = app .LoadLatestVersion (app .keyMain )
142- }
117+ err = app .LoadLatestVersion (app .keyMain )
143118 if err != nil {
144119 cmn .Exit (err .Error ())
145120 }
146121
147- upgrade .RegisterModuleList (app .Router ())
148-
149122 return app
150123}
151124
152125// custom tx codec
153126func MakeCodec () * wire.Codec {
154127 var cdc = wire .NewCodec ()
155- ibc .RegisterWire (cdc )
156128 bank .RegisterWire (cdc )
157129 stake .RegisterWire (cdc )
158130 slashing .RegisterWire (cdc )
159131 gov .RegisterWire (cdc )
160132 auth .RegisterWire (cdc )
161- upgrade .RegisterWire (cdc )
162133 sdk .RegisterWire (cdc )
163134 wire .RegisterCrypto (cdc )
164135 return cdc
@@ -177,9 +148,7 @@ func (app *IrisApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) ab
177148func (app * IrisApp ) EndBlocker (ctx sdk.Context , req abci.RequestEndBlock ) abci.ResponseEndBlock {
178149 validatorUpdates := stake .EndBlocker (ctx , app .stakeKeeper )
179150
180- tags , _ := gov .EndBlocker (ctx , app .govKeeper )
181- tags .AppendTags (upgrade .EndBlocker (ctx , app .upgradeKeeper ))
182-
151+ tags ,_ := gov .EndBlocker (ctx , app .govKeeper )
183152 return abci.ResponseEndBlock {
184153 ValidatorUpdates : validatorUpdates ,
185154 Tags : tags ,
@@ -214,10 +183,10 @@ func (app *IrisApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci
214183 StartingProposalID : 1 ,
215184 DepositProcedure : gov.DepositProcedure {
216185 MinDeposit : sdk.Coins {sdk.Coin {Denom : "iris" , Amount : sdk .NewInt (int64 (10 )).Mul (gov .Pow10 (18 ))}},
217- MaxDepositPeriod : 1440 ,
186+ MaxDepositPeriod : 40 ,
218187 },
219188 VotingProcedure : gov.VotingProcedure {
220- VotingPeriod : 30 ,
189+ VotingPeriod : 40 ,
221190 },
222191 TallyingProcedure : gov.TallyingProcedure {
223192 Threshold : sdk .NewRat (1 , 2 ),
@@ -233,7 +202,6 @@ func (app *IrisApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci
233202
234203 auth .InitGenesis (ctx , app .paramsKeeper .Setter (), feeTokenGensisConfig )
235204
236- upgrade .InitGenesis (ctx , app .upgradeKeeper , app .Router ())
237205
238206 return abci.ResponseInitChain {}
239207}
@@ -263,58 +231,6 @@ func (app *IrisApp) ExportAppStateAndValidators() (appState json.RawMessage, val
263231 return appState , validators , nil
264232}
265233
266- // Iterates through msgs and executes them
267- func (app * IrisApp ) runMsgs (ctx sdk.Context , msgs []sdk.Msg ) (result sdk.Result ) {
268- // accumulate results
269- logs := make ([]string , 0 , len (msgs ))
270- var data []byte // NOTE: we just append them all (?!)
271- var tags sdk.Tags // also just append them all
272- var code sdk.ABCICodeType
273- for msgIdx , msg := range msgs {
274- // Match route.
275- msgType , err := app .upgradeKeeper .GetMsgTypeInCurrentVersion (ctx , msg )
276- if err != nil {
277- return err .Result ()
278- }
279-
280- handler := app .Router ().Route (msgType )
281- if handler == nil {
282- return sdk .ErrUnknownRequest ("Unrecognized Msg type: " + msgType ).Result ()
283- }
284-
285- msgResult := handler (ctx , msg )
286-
287- // NOTE: GasWanted is determined by ante handler and
288- // GasUsed by the GasMeter
289-
290- // Append Data and Tags
291- data = append (data , msgResult .Data ... )
292- tags = append (tags , msgResult .Tags ... )
293-
294- // Stop execution and return on first failed message.
295- if ! msgResult .IsOK () {
296- logs = append (logs , fmt .Sprintf ("Msg %d failed: %s" , msgIdx , msgResult .Log ))
297- code = msgResult .Code
298- break
299- }
300-
301- // Construct usable logs in multi-message transactions.
302- logs = append (logs , fmt .Sprintf ("Msg %d: %s" , msgIdx , msgResult .Log ))
303- }
304-
305- // Set the final gas values.
306- result = sdk.Result {
307- Code : code ,
308- Data : data ,
309- Log : strings .Join (logs , "\n " ),
310- GasUsed : ctx .GasMeter ().GasConsumed (),
311- // TODO: FeeAmount/FeeDenom
312- Tags : tags ,
313- }
314-
315- return result
316- }
317-
318234func (app * IrisApp ) replay () int64 {
319235 ctx := server .NewDefaultContext ()
320236 ctx .Config .RootDir = viper .GetString (tmcli .HomeFlag )
0 commit comments