diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index ef3bbc3c79..12dbf85d39 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -64,9 +64,10 @@ type BaseApp struct { // See methods setCheckState and setDeliverState. // .valUpdates accumulate in DeliverTx and are reset in BeginBlock. // QUESTION: should we put valUpdates in the deliverState.ctx? - checkState *state // for CheckTx - deliverState *state // for DeliverTx - valUpdates []abci.Validator // cached validator changes from DeliverTx + checkState *state // for CheckTx + deliverState *state // for DeliverTx + valUpdates []abci.Validator // cached validator changes from DeliverTx + absentValidators []int32 // absent validators from begin block } var _ abci.Application = (*BaseApp)(nil) @@ -383,6 +384,8 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg if app.beginBlocker != nil { res = app.beginBlocker(app.deliverState.ctx, req) } + // set the absent validators for addition to context in deliverTx + app.absentValidators = req.AbsentValidators return } @@ -492,6 +495,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte, tx sdk.Tx) (result sdk ctx = app.checkState.ctx.WithTxBytes(txBytes) } else { ctx = app.deliverState.ctx.WithTxBytes(txBytes) + ctx = ctx.WithAbsentValidators(app.absentValidators) } // Simulate a DeliverTx for gas calculation diff --git a/types/context.go b/types/context.go index 4ab0a5d093..cde4ce194e 100644 --- a/types/context.go +++ b/types/context.go @@ -129,6 +129,7 @@ const ( contextKeyTxBytes contextKeyLogger contextKeyGasMeter + contextKeyAbsentValidators ) // NOTE: Do not expose MultiStore. @@ -160,6 +161,9 @@ func (c Context) Logger() log.Logger { func (c Context) GasMeter() GasMeter { return c.Value(contextKeyGasMeter).(GasMeter) } +func (c Context) AbsentValidators() []int32 { + return c.Value(contextKeyAbsentValidators).([]int32) +} func (c Context) WithMultiStore(ms MultiStore) Context { return c.withValue(contextKeyMultiStore, ms) } @@ -185,6 +189,9 @@ func (c Context) WithLogger(logger log.Logger) Context { func (c Context) WithGasMeter(meter GasMeter) Context { return c.withValue(contextKeyGasMeter, meter) } +func (c Context) WithAbsentValidators(AbsentValidators []int32) Context { + return c.withValue(contextKeyAbsentValidators, AbsentValidators) +} // Cache the multistore and return a new cached context. The cached context is // written to the context when writeCache is called.