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(v1): Vote Extension Auction #106

Merged
merged 20 commits into from
May 9, 2023
Merged

Conversation

davidterpay
Copy link
Contributor

@davidterpay davidterpay commented May 2, 2023

Overview

Hosting the top of block auction using vote extensions.

Base automatically changed from terpay/vote-handlers to main May 4, 2023 18:31
@davidterpay davidterpay marked this pull request as ready for review May 8, 2023 18:12
Comment on lines 19 to 24
// VoteExtensionInfo wraps all vote extension data into a registry which allows applications to define
// multiple different vote extensions that can be applied to state.
message VoteExtensionInfo {
// registry is the data of the vote extension.
map<string, bytes> registry = 2;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm digging this idea of generalized VoteExtension handling, but I still think POB isn't where something like this belongs. It belongs in the SDK IMO. We could use it if/when it's included (feel free to open an issue and PR!)

But in the meantime, I think we should use a more concrete and domain-specific type instead.

abci/auction.go Outdated
// the highest bidding valid transaction along with all the bundled transactions.
func (h *ProposalHandler) BuildTOB(ctx sdk.Context, voteExtensionInfo abci.ExtendedCommitInfo, maxBytes int64) TopOfBlock {
// Get the bid transactions from the vote extensions.
bidTxs := h.GetBidsFromVoteExtensions(voteExtensionInfo.Votes)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
bidTxs := h.GetBidsFromVoteExtensions(voteExtensionInfo.Votes)
sortedBidTxs := h.GetBidsFromVoteExtensions(voteExtensionInfo.Votes)

abci/auction.go Outdated

// VerifyTOB verifies that the set of vote extensions used in prepare proposal deterministically
// produce the same top of block proposal.
func (h *ProposalHandler) VerifyTOB(ctx sdk.Context, proposal [][]byte) (*AuctionInfo, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
func (h *ProposalHandler) VerifyTOB(ctx sdk.Context, proposal [][]byte) (*AuctionInfo, error) {
func (h *ProposalHandler) VerifyTOB(ctx sdk.Context, proposalTxs [][]byte) (*AuctionInfo, error) {

abci/auction.go Outdated
Comment on lines 96 to 97
auctionInfo := AuctionInfo{}
if err := auctionInfo.Unmarshal(proposal[AuctionInfoIndex]); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

auctionInfo doesn't need to be a pointer?

abci/auction.go Outdated
return nil, fmt.Errorf("expected top of block txs does not match top of block proposal")
}

return &auctionInfo, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to return a pointer? Maybe just have the type creation be a pointer instead of taking its address here?

Comment on lines 171 to 182
tx, err := h.ProcessProposalVerifyTx(ctx, txBz)
if err != nil {
return abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}

// If the transaction is nil, it was unable to be decoded and thus is invalid.
if tx == nil {
invalidProposal = true
continue
}

bidInfo, err := h.mempool.GetAuctionBidInfo(tx)
if err != nil {
return abci.ResponseProcessProposal{Status: abci.ResponseProcessProposal_REJECT}
invalidProposal = true
txsToRemove[tx] = struct{}{}
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

I would condense this:

if tx == nil || err != nil {
  invalidProposal = true
  if tx != nil {
    xsToRemove[tx] = struct{}{}
  }

  continue
}

const (
// MinProposalSize is the minimum size of a proposal. Each proposal must contain
// at least the auction info.
MinProposalSize = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

I found myself tripping up over this variable name and its use a few times. I would maybe consider renaming this to something a bit more intuitive or descriptive.

It seems this variable is primarily used to keep a cursor or know the number of "fake" txs injected into a proposal. Perhaps NumInjectedTxs? or something like...

@davidterpay davidterpay merged commit 7797110 into main May 9, 2023
6 checks passed
@davidterpay davidterpay deleted the terpay/vote-extension-auction branch May 9, 2023 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants