refactor: remove header type from NewContext (#17426)
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
This commit is contained in:
+5
-7
@@ -549,9 +549,8 @@ func (app *BaseApp) ProcessProposal(req *abci.RequestProcessProposal) (resp *abc
|
||||
func (app *BaseApp) ExtendVote(_ context.Context, req *abci.RequestExtendVote) (resp *abci.ResponseExtendVote, err error) {
|
||||
// Always reset state given that ExtendVote and VerifyVoteExtension can timeout
|
||||
// and be called again in a subsequent round.
|
||||
emptyHeader := cmtproto.Header{ChainID: app.chainID, Height: req.Height}
|
||||
ms := app.cms.CacheMultiStore()
|
||||
ctx := sdk.NewContext(ms, emptyHeader, false, app.logger).WithStreamingManager(app.streamingManager)
|
||||
ctx := sdk.NewContext(ms, false, app.logger).WithStreamingManager(app.streamingManager).WithChainID(app.chainID).WithBlockHeight(req.Height)
|
||||
|
||||
if app.extendVote == nil {
|
||||
return nil, errors.New("application ExtendVote handler not set")
|
||||
@@ -611,9 +610,8 @@ func (app *BaseApp) VerifyVoteExtension(req *abci.RequestVerifyVoteExtension) (r
|
||||
return nil, errors.New("application VerifyVoteExtension handler not set")
|
||||
}
|
||||
|
||||
emptyHeader := cmtproto.Header{ChainID: app.chainID, Height: req.Height}
|
||||
ms := app.cms.CacheMultiStore()
|
||||
ctx := sdk.NewContext(ms, emptyHeader, false, app.logger).WithStreamingManager(app.streamingManager)
|
||||
ctx := sdk.NewContext(ms, false, app.logger).WithStreamingManager(app.streamingManager).WithChainID(app.chainID).WithBlockHeight(req.Height)
|
||||
|
||||
// If vote extensions are not enabled, as a safety precaution, we return an
|
||||
// error.
|
||||
@@ -1016,7 +1014,7 @@ func (app *BaseApp) getContextForProposal(ctx sdk.Context, height int64) sdk.Con
|
||||
ctx, _ = app.finalizeBlockState.ctx.CacheContext()
|
||||
|
||||
// clear all context data set during InitChain to avoid inconsistent behavior
|
||||
ctx = ctx.WithBlockHeader(cmtproto.Header{}).WithHeaderInfo(coreheader.Info{})
|
||||
ctx = ctx.WithHeaderInfo(coreheader.Info{}).WithBlockHeader(cmtproto.Header{})
|
||||
return ctx
|
||||
}
|
||||
|
||||
@@ -1120,10 +1118,10 @@ func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, e
|
||||
}
|
||||
|
||||
// branch the commit multi-store for safety
|
||||
ctx := sdk.NewContext(cacheMS, app.checkState.ctx.BlockHeader(), true, app.logger).
|
||||
ctx := sdk.NewContext(cacheMS, true, app.logger).
|
||||
WithMinGasPrices(app.minGasPrices).
|
||||
WithBlockHeight(height).
|
||||
WithGasMeter(storetypes.NewGasMeter(app.queryGasLimit))
|
||||
WithGasMeter(storetypes.NewGasMeter(app.queryGasLimit)).WithBlockHeader(app.checkState.ctx.BlockHeader())
|
||||
|
||||
if height != lastBlockHeight {
|
||||
rms, ok := app.cms.(*rootmulti.Store)
|
||||
|
||||
+1
-1
@@ -474,7 +474,7 @@ func (app *BaseApp) setState(mode execMode, header cmtproto.Header) {
|
||||
ms := app.cms.CacheMultiStore()
|
||||
baseState := &state{
|
||||
ms: ms,
|
||||
ctx: sdk.NewContext(ms, header, false, app.logger).WithStreamingManager(app.streamingManager),
|
||||
ctx: sdk.NewContext(ms, false, app.logger).WithStreamingManager(app.streamingManager).WithBlockHeader(header),
|
||||
}
|
||||
|
||||
switch mode {
|
||||
|
||||
@@ -53,11 +53,11 @@ func (app *BaseApp) SimTxFinalizeBlock(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.
|
||||
// NewContextLegacy returns a new sdk.Context with the provided header
|
||||
func (app *BaseApp) NewContextLegacy(isCheckTx bool, header cmtproto.Header) sdk.Context {
|
||||
if isCheckTx {
|
||||
return sdk.NewContext(app.checkState.ms, header, true, app.logger).
|
||||
WithMinGasPrices(app.minGasPrices)
|
||||
return sdk.NewContext(app.checkState.ms, true, app.logger).
|
||||
WithMinGasPrices(app.minGasPrices).WithBlockHeader(header)
|
||||
}
|
||||
|
||||
return sdk.NewContext(app.finalizeBlockState.ms, header, false, app.logger)
|
||||
return sdk.NewContext(app.finalizeBlockState.ms, false, app.logger).WithBlockHeader(header)
|
||||
}
|
||||
|
||||
// NewContext returns a new sdk.Context with a empty header
|
||||
@@ -66,7 +66,7 @@ func (app *BaseApp) NewContext(isCheckTx bool) sdk.Context {
|
||||
}
|
||||
|
||||
func (app *BaseApp) NewUncachedContext(isCheckTx bool, header cmtproto.Header) sdk.Context {
|
||||
return sdk.NewContext(app.cms, header, isCheckTx, app.logger)
|
||||
return sdk.NewContext(app.cms, isCheckTx, app.logger).WithBlockHeader(header)
|
||||
}
|
||||
|
||||
func (app *BaseApp) GetContextForFinalizeBlock(txBytes []byte) sdk.Context {
|
||||
|
||||
Reference in New Issue
Block a user