Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: deprecate Voteinfo in favour of Cometinfo on Context #17670

Merged
merged 19 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion testutil/integration/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,17 @@ func (app *App) RunMsg(msg sdk.Msg, option ...Option) (*codectypes.Any, error) {
}()
}

app.ctx = app.ctx.WithCometInfo(sdk.CometInfo{})

if cfg.AutomaticFinalizeBlock {
height := app.LastBlockHeight() + 1
if _, err := app.FinalizeBlock(&cmtabcitypes.RequestFinalizeBlock{Height: height}); err != nil {
if _, err := app.FinalizeBlock(&cmtabcitypes.RequestFinalizeBlock{Height: height, DecidedLastCommit: cmtabcitypes.CommitInfo{Votes: []cmtabcitypes.VoteInfo{{}}}}); err != nil {
return nil, fmt.Errorf("failed to run finalize block: %w", err)
}
}

fmt.Println(app.ctx.CometInfo(), "runmsg")

app.logger.Info("Running msg", "msg", msg.String())

handler := app.MsgServiceRouter().Handler(msg)
Expand Down
4 changes: 4 additions & 0 deletions x/slashing/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func BeginBlocker(ctx context.Context, k keeper.Keeper) error {
// store whether or not they have actually signed it and slash/unbond any
// which have missed too many blocks in a row (downtime slashing)
sdkCtx := sdk.UnwrapSDKContext(ctx)
// in testing cometInfo is nil
if sdkCtx.CometInfo() == nil {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we change cometinfo to be a struct otherwise we need to do defensive checks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another advantage of a struct is that adding new fields is non breaking and everything is optional

return nil
}
for i := 0; i < sdkCtx.CometInfo().GetLastCommit().Votes().Len(); i++ {
vote := sdkCtx.CometInfo().GetLastCommit().Votes().Get(i)
err := k.HandleValidatorSignature(ctx, vote.Validator().Address(), vote.Validator().Power(), vote.GetBlockIDFlag())
Fixed Show fixed Hide fixed
Expand Down