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

feat: add header and comet info service #15850

Merged
merged 38 commits into from
May 3, 2023
Merged

feat: add header and comet info service #15850

merged 38 commits into from
May 3, 2023

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented Apr 15, 2023

Description

ref #14683

this pr adds block info service as an interface and passes it to evidence.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

baseapp/abci.go Outdated Show resolved Hide resolved
@tac0turtle
Copy link
Member Author

im thinking of defining the comet abci types for validatorUpdates and misbehaviour in golang so we can move it to core. how does this sound to others?

baseapp/abci.go Outdated Show resolved Hide resolved
GetDecidedLastCommit() CommitInfo // GetDecidedLastCommit returns the last commit info
}

// MisbehaviorType is the type of misbehavior for a validator
Copy link
Member Author

Choose a reason for hiding this comment

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

would love feedback on defining our own types like this

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems reasonable to me.

@tac0turtle tac0turtle marked this pull request as ready for review April 16, 2023 13:41
@tac0turtle tac0turtle requested a review from a team as a code owner April 16, 2023 13:41
@github-actions
Copy link
Contributor

@tac0turtle your pull request is missing a changelog!

@github-prbot github-prbot requested review from a team, samricotta and atheeshp and removed request for a team April 16, 2023 13:41
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

I'm confused as to where the evidence module actually uses the BlockInfo service. The keeper has a field but it's never used from what I can see.

x/evidence/keeper/abci.go Outdated Show resolved Hide resolved
GetDecidedLastCommit() CommitInfo // GetDecidedLastCommit returns the last commit info
}

// MisbehaviorType is the type of misbehavior for a validator
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems reasonable to me.

types/block_info.go Outdated Show resolved Hide resolved
types/block_info.go Outdated Show resolved Hide resolved
types/block_info.go Outdated Show resolved Hide resolved
types/block_info.go Outdated Show resolved Hide resolved
x/evidence/keeper/abci.go Outdated Show resolved Hide resolved
// CommitInfo is the commit information of ABCI
type CommitInfo interface {
Round() int32
Votes() []VoteInfo
Copy link
Member

@aaronc aaronc Apr 25, 2023

Choose a reason for hiding this comment

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

It would probably be better to avoid returning an array (which is actually mutable) and use a wrapper interface like the official protobuf does: https://pkg.go.dev/google.golang.org/protobuf/reflect/protoreflect#MessageDescriptors. Ex:

type VoteInfos interface {
  Len() int
  Get(int) VoteInfo
}

This has the added performance benefit that we avoid allocating and copying an array when wrapping all the request types

Copy link
Member Author

Choose a reason for hiding this comment

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

added good call

@tac0turtle tac0turtle requested a review from aaronc April 27, 2023 15:34
@@ -194,12 +194,14 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg
WithBlockGasMeter(gasMeter).
WithHeaderHash(req.Hash).
WithConsensusParams(app.GetConsensusParams(app.deliverState.ctx)).
WithVoteInfos(req.LastCommitInfo.GetVotes())
WithVoteInfos(req.LastCommitInfo.GetVotes()).
WithCometInfo(cometInfo{Misbehavior: req.ByzantineValidators, ValidatorsHash: req.Header.ValidatorsHash, ProposerAddress: req.Header.ProposerAddress, LastCommit: req.LastCommitInfo})
Copy link
Member

Choose a reason for hiding this comment

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

why cometInfo vs a begin block request wrapper?

Copy link
Member Author

Choose a reason for hiding this comment

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

because in the next pr integrating comet we drop the beginblock type, i was thinking might as well do this here

core/comet/service.go Outdated Show resolved Hide resolved
Copy link
Member

@mark-rushakoff mark-rushakoff left a comment

Choose a reason for hiding this comment

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

I left a few style comments. I mostly followed what's going on here, and I think it seems fine, but I am missing context on the bigger picture here. Soft +1 from me, deferring to others more familiar with this than I am.

baseapp/info.go Outdated Show resolved Hide resolved
core/comet/service.go Outdated Show resolved Hide resolved
types/context.go Outdated Show resolved Hide resolved
tests/integration/evidence/keeper/infraction_test.go Outdated Show resolved Hide resolved
types/module/module.go Outdated Show resolved Hide resolved
tests/integration/evidence/keeper/infraction_test.go Outdated Show resolved Hide resolved
@github-actions github-actions bot added the C:Rosetta Issues and PR related to Rosetta label Apr 30, 2023
core/comet/service.go Outdated Show resolved Hide resolved
core/comet/service.go Outdated Show resolved Hide resolved
Comment on lines 10 to 11
GetCometInfo(context.Context) BlockInfo
}
Copy link
Member

Choose a reason for hiding this comment

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

How about we do a Misbehaviors wrapper like we did for VoteInfos instead of an array

Copy link
Member Author

Choose a reason for hiding this comment

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

modified thanks

@tac0turtle tac0turtle added this pull request to the merge queue May 3, 2023
Merged via the queue into main with commit 1705615 May 3, 2023
@tac0turtle tac0turtle deleted the marko/block_info branch May 3, 2023 13:35
WithTxBytes(txBytes).
WithVoteInfos(app.voteInfos)
WithTxBytes(txBytes)
// WithVoteInfos(app.voteInfos) // TODO: identify if this is needed
Copy link
Member

Choose a reason for hiding this comment

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

Was this left commented intentionally?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, its still unclear why this is needed, we can add it back via cometinfo to not cause such a large breaking change.

larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
@coderabbitai coderabbitai bot mentioned this pull request May 3, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants