Skip to content

Commit

Permalink
fix: enable sends fast fail in gov proposals execution
Browse files Browse the repository at this point in the history
  • Loading branch information
kakysha committed Jun 12, 2024
1 parent 5cd942f commit b0d018a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const (
execModeVerifyVoteExtension // Verify a vote extension
execModeFinalize // Finalize a block proposal

DoNotFailFastContextKey contextKeyT = "DoNotFailFast"
DoNotFailFastSendContextKey contextKeyT = "DoNotFailFast"
)

var _ servertypes.ABCI = (*BaseApp)(nil)
Expand Down Expand Up @@ -712,7 +712,7 @@ func (app *BaseApp) cacheTxContext(ctx sdk.Context, txBytes []byte) (sdk.Context

func (app *BaseApp) preBlock(req *abci.RequestFinalizeBlock) error {
if app.preBlocker != nil {
ctx := app.finalizeBlockState.Context().WithValue(DoNotFailFastContextKey, struct{}{})
ctx := app.finalizeBlockState.Context().WithValue(DoNotFailFastSendContextKey, struct{}{})
rsp, err := app.preBlocker(ctx, req)
if err != nil {
return err
Expand All @@ -737,7 +737,7 @@ func (app *BaseApp) beginBlock(req *abci.RequestFinalizeBlock) (sdk.BeginBlock,
)

if app.beginBlocker != nil {
ctx := app.finalizeBlockState.Context().WithValue(DoNotFailFastContextKey, struct{}{})
ctx := app.finalizeBlockState.Context().WithValue(DoNotFailFastSendContextKey, struct{}{})
resp, err = app.beginBlocker(ctx)
if err != nil {
return resp, err
Expand Down Expand Up @@ -805,7 +805,7 @@ func (app *BaseApp) endBlock(_ context.Context) (sdk.EndBlock, error) {
var endblock sdk.EndBlock

if app.endBlocker != nil {
ctx := app.finalizeBlockState.Context().WithValue(DoNotFailFastContextKey, struct{}{})
ctx := app.finalizeBlockState.Context().WithValue(DoNotFailFastSendContextKey, struct{}{})
eb, err := app.endBlocker(ctx)
if err != nil {
return endblock, err
Expand Down
3 changes: 2 additions & 1 deletion x/gov/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ func EndBlocker(ctx sdk.Context, keeper *keeper.Keeper) error {
// Messages may mutate state thus we use a cached context. If one of
// the handlers fails, no state mutation is written and the error
// message is logged.
cacheCtx, writeCache := ctx.CacheContext()
execCtx := ctx.WithValue(baseapp.DoNotFailFastSendContextKey, nil) // enable fail fast during msg handling
cacheCtx, writeCache := execCtx.CacheContext()
messages, err := proposal.GetMsgs()
if err != nil {
proposal.Status = v1.StatusFailed
Expand Down

0 comments on commit b0d018a

Please sign in to comment.