@@ -11,7 +11,7 @@ import (
1111 "syscall"
1212 "time"
1313
14- "github.com/cosmos/gogoproto /proto"
14+ "github.com/gogo/protobuf /proto"
1515 abci "github.com/tendermint/tendermint/abci/types"
1616 tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
1717 "google.golang.org/grpc/codes"
@@ -44,8 +44,6 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC
4444 // req.InitialHeight is 1 by default.
4545 initHeader := tmproto.Header {ChainID : req .ChainId , Time : req .Time }
4646
47- app .logger .Info ("InitChain" , "initialHeight" , req .InitialHeight , "chainID" , req .ChainId )
48-
4947 // If req.InitialHeight is > 1, then we set the initial version in the
5048 // stores.
5149 if req .InitialHeight > 1 {
@@ -57,11 +55,9 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC
5755 }
5856 }
5957
60- // initialize states with a correct header
58+ // initialize the deliver state and check state with a correct header
6159 app .setDeliverState (initHeader )
6260 app .setCheckState (initHeader )
63- app .setPrepareProposalState (initHeader )
64- app .setProcessProposalState (initHeader )
6561
6662 if err := app .SetAppVersion (initialAppVersion ); err != nil {
6763 panic (err )
@@ -71,10 +67,10 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC
7167 // done after the deliver state and context have been set as it's persisted
7268 // to state.
7369 if req .ConsensusParams != nil {
74- // When InitChain is called, the app version should either be absent and
75- // determined by the application or set to 0. Panic if it's not.
76- if req .ConsensusParams .Version != nil && req .ConsensusParams .Version .App != initialAppVersion {
77- panic (AppVersionError {Actual : req .ConsensusParams .Version .App , Initial : initialAppVersion })
70+ // When InitChain is called, the app version should either be absent and determined by the application
71+ // or set to 0. Panic if it's not.
72+ if req .ConsensusParams .Version != nil && req .ConsensusParams .Version .AppVersion != initialAppVersion {
73+ panic (AppVersionError {Actual : req .ConsensusParams .Version .AppVersion , Initial : initialAppVersion })
7874 }
7975
8076 app .StoreConsensusParams (app .deliverState .ctx , req .ConsensusParams )
@@ -152,6 +148,12 @@ func (app *BaseApp) Info(req abci.RequestInfo) abci.ResponseInfo {
152148 }
153149}
154150
151+ // SetOption implements the ABCI interface.
152+ func (app * BaseApp ) SetOption (req abci.RequestSetOption ) (res abci.ResponseSetOption ) {
153+ // TODO: Implement!
154+ return
155+ }
156+
155157// FilterPeerByAddrPort filters peers by address/port.
156158func (app * BaseApp ) FilterPeerByAddrPort (info string ) abci.ResponseQuery {
157159 if app .addrPeerFilter != nil {
@@ -199,20 +201,21 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg
199201
200202 // add block gas meter
201203 var gasMeter sdk.GasMeter
202- if maxGas := app .GetMaximumBlockGas (app .deliverState .ctx ); maxGas > 0 {
204+ if maxGas := app .getMaximumBlockGas (app .deliverState .ctx ); maxGas > 0 {
203205 gasMeter = sdk .NewGasMeter (maxGas )
204206 } else {
205207 gasMeter = sdk .NewInfiniteGasMeter ()
206208 }
207209
208210 // NOTE: header hash is not set in NewContext, so we manually set it here
211+
209212 app .deliverState .ctx = app .deliverState .ctx .
210213 WithBlockGasMeter (gasMeter ).
211214 WithHeaderHash (req .Hash ).
212215 WithConsensusParams (app .GetConsensusParams (app .deliverState .ctx ))
213216
214- // We also set block gas meter to checkState in case the application needs to
215- // verify gas consumption during (Re)CheckTx.
217+ // we also set block gas meter to checkState in case the application needs to
218+ // verify gas consumption during (Re)CheckTx
216219 if app .checkState != nil {
217220 app .checkState .ctx = app .checkState .ctx .
218221 WithBlockGasMeter (gasMeter ).
@@ -248,59 +251,6 @@ func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBloc
248251 return res
249252}
250253
251- // PrepareProposal implements the PrepareProposal ABCI method and returns a
252- // ResponsePrepareProposal object to the client. The PrepareProposal method is
253- // responsible for allowing the block proposer to perform application-dependent
254- // work in a block before proposing it.
255- //
256- // Transactions can be modified, removed, or added by the application. Since the
257- // application maintains its own local mempool, it will ignore the transactions
258- // provided to it in RequestPrepareProposal. Instead, it will determine which
259- // transactions to return based on the mempool's semantics and the MaxTxBytes
260- // provided by the client's request.
261- //
262- // Note, there is no need to execute the transactions for validity as they have
263- // already passed CheckTx.
264- //
265- // Ref: https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-060-abci-1.0.md
266- // Ref: https://github.com/tendermint/tendermint/blob/main/spec/abci/abci%2B%2B_basic_concepts.md
267- func (app * BaseApp ) PrepareProposal (req abci.RequestPrepareProposal ) abci.ResponsePrepareProposal {
268- ctx := app .getContextForTx (runTxPrepareProposal , []byte {})
269- if app .prepareProposal == nil {
270- panic ("PrepareProposal method not set" )
271- }
272-
273- return app .prepareProposal (ctx , req )
274- }
275-
276- // ProcessProposal implements the ProcessProposal ABCI method and returns a
277- // ResponseProcessProposal object to the client. The ProcessProposal method is
278- // responsible for allowing execution of application-dependent work in a proposed
279- // block. Note, the application defines the exact implementation details of
280- // ProcessProposal. In general, the application must at the very least ensure
281- // that all transactions are valid. If all transactions are valid, then we inform
282- // Tendermint that the Status is ACCEPT. However, the application is also able
283- // to implement optimizations such as executing the entire proposed block
284- // immediately. It may even execute the block in parallel.
285- //
286- // Ref: https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-060-abci-1.0.md
287- // Ref: https://github.com/tendermint/tendermint/blob/main/spec/abci/abci%2B%2B_basic_concepts.md
288- func (app * BaseApp ) ProcessProposal (req abci.RequestProcessProposal ) abci.ResponseProcessProposal {
289- if app .processProposal == nil {
290- panic ("app.ProcessProposal is not set" )
291- }
292-
293- ctx := app .processProposalState .ctx .
294- WithVoteInfos (app .voteInfos ).
295- WithBlockHeight (req .Height ).
296- WithBlockTime (req .Time ).
297- WithHeaderHash (req .Hash ).
298- WithProposer (req .ProposerAddress ).
299- WithConsensusParams (app .GetConsensusParams (app .processProposalState .ctx ))
300-
301- return app .processProposal (ctx , req )
302- }
303-
304254// CheckTx implements the ABCI interface and executes a tx in CheckTx mode. In
305255// CheckTx mode, messages are not executed. This means messages are only validated
306256// and only the AnteHandler is executed. State is persisted to the BaseApp's
@@ -394,8 +344,6 @@ func (app *BaseApp) Commit() (res abci.ResponseCommit) {
394344 // NOTE: This is safe because Tendermint holds a lock on the mempool for
395345 // Commit. Use the header from this latest block.
396346 app .setCheckState (header )
397- app .setPrepareProposalState (header )
398- app .setProcessProposalState (header )
399347
400348 // empty/reset the deliver state
401349 app .deliverState = nil
@@ -638,7 +586,7 @@ func queryListContainsReq(req abci.RequestQuery) bool {
638586}
639587
640588func (app * BaseApp ) handleQueryGRPC (handler GRPCQueryHandler , req abci.RequestQuery ) abci.ResponseQuery {
641- ctx , err := app .CreateQueryContext (req .Height , req .Prove )
589+ ctx , err := app .createQueryContext (req .Height , req .Prove )
642590 if err != nil {
643591 return sdkerrors .QueryResultWithDebug (err , app .trace )
644592 }
@@ -689,9 +637,9 @@ func checkNegativeHeight(height int64) error {
689637 return nil
690638}
691639
692- // CreateQueryContext creates a new sdk.Context for a query, taking as args
640+ // createQueryContext creates a new sdk.Context for a query, taking as args
693641// the block height and whether the query needs a proof or not.
694- func (app * BaseApp ) CreateQueryContext (height int64 , prove bool ) (sdk.Context , error ) {
642+ func (app * BaseApp ) createQueryContext (height int64 , prove bool ) (sdk.Context , error ) {
695643 if err := checkNegativeHeight (height ); err != nil {
696644 return sdk.Context {}, err
697645 }
@@ -988,7 +936,7 @@ func handleQueryCustom(app *BaseApp, path []string, req abci.RequestQuery) abci.
988936 return sdkerrors .QueryResultWithDebug (sdkerrors .Wrapf (sdkerrors .ErrUnknownRequest , "no custom querier found for route %s" , path [1 ]), app .trace )
989937 }
990938
991- ctx , err := app .CreateQueryContext (req .Height , req .Prove )
939+ ctx , err := app .createQueryContext (req .Height , req .Prove )
992940 if err != nil {
993941 return sdkerrors .QueryResultWithDebug (err , app .trace )
994942 }
0 commit comments