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

fix(Config): Simplifying config interface #104

Merged
merged 8 commits into from
May 4, 2023

Conversation

davidterpay
Copy link
Contributor

No description provided.

GetAuctionBidInfo(tx sdk.Tx) (mempool.AuctionBidInfo, error)
GetBundleSigners(txs [][]byte) ([]map[string]struct{}, error)
GetAuctionBidInfo(tx sdk.Tx) (*mempool.AuctionBidInfo, error)
GetTransactionSigners(tx []byte) (map[string]struct{}, error)

Choose a reason for hiding this comment

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

I would put GetTransactionSigners() as a function on the AuctionBidInfo

// We only need to verify the auction bid relative to the local validator's mempool if the mode
// is checkTx or recheckTx. Otherwise, the ABCI handlers (VerifyVoteExtension, ExtendVoteExtension, etc.)
// will always compare the auction bid to the highest bidding transaction in the mempool leading to
// poor liveness guarantees.
topBid := sdk.Coin{}

Choose a reason for hiding this comment

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

by forcing bid to be an sdk.Coins() we get less generalizability. For instance in the polaris implementation, this forces us to pass evmDenom around, whereas if topBid could be just an uint64 for instance, then we could get rid of this simplifiying the integration.

Really the only thing that bids are required to be are comparable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Using sdk.Coin would make more sense in a world where we have multiple fee tokens. Opening an issue for this.

@@ -327,3 +327,18 @@ func (suite *KeeperTestSuite) TestValidateBundle() {
})
}
}

func (suite *KeeperTestSuite) getBundleSigners(bundle [][]byte) ([]map[string]struct{}, error) {

Choose a reason for hiding this comment

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

as mentioned above, this function should go on the AuctionBidInfo imo.

@@ -1,242 +0,0 @@
package mempool
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved all this code to auction_bid.go

@davidterpay davidterpay marked this pull request as ready for review May 3, 2023 21:44
// AuctionBid defines the interface for processing auction transactions. It is
// a wrapper around all of the functionality that each application chain must implement
// in order for auction processing to work.
AuctionBid interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thought about this some more...what about AuctionFactory?

Choose a reason for hiding this comment

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

Big factory pattern enthusiast.

Decoupling auction bid from mempool also makes sense to me.

Copy link
Contributor Author

@davidterpay davidterpay May 4, 2023

Choose a reason for hiding this comment

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

Down for AuctionFactory. I have some ideas on how we could still use the ExtensionOptions on sdk.Tx to completely decouple the bid from the mempool. If we only have it store the priority and validate that the bid and priority within the tx and extension option match, then the mempool doesn't need to have conception of what the underlying tx is. This might mess with general UX tho since most wallets and users dont add extension options to begin with. We should maybe explore this approach in the BlockBuster refactor.

Choose a reason for hiding this comment

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

Thinking extension over msg interface?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're still evaluating what the best approach is in the context of the refactor we're planning but msg interface is probably going to be our approach. We'll share the RFC of the refactor with you in the coming days (that'll address the coupling concerns you've been discussing).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely going to be curious to hear your thoughts on design and such since the refactor will be a new approach to general mempool design.

}
}

// Insert inserts a transaction into the mempool based on the transaction type (normal or auction).
func (am *AuctionMempool) Insert(ctx context.Context, tx sdk.Tx) error {
isAuctionTx, err := am.IsAuctionTx(tx)
bidInfo, err := am.GetAuctionBidInfo(tx)
if err != nil {
return err
}

// Insert the transactions into the appropriate index.
switch {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think an if/else would be a bit cleaner here IMO. if bidInfo != nil {} else {}

if err != nil {
return err
}

// Remove the transactions from the appropriate index.
switch {
case !isAuctionTx:
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@davidterpay davidterpay merged commit d58b36b into main May 4, 2023
@davidterpay davidterpay deleted the terpay/interface-optimization branch May 4, 2023 19:33
mergify bot pushed a commit that referenced this pull request May 4, 2023
(cherry picked from commit d58b36b)

# Conflicts:
#	abci/abci_test.go
#	abci/vote_extensions.go
#	abci/vote_extensions_test.go
alexanderbez added a commit that referenced this pull request May 5, 2023
Co-authored-by: David Terpay <35130517+davidterpay@users.noreply.github.com>
Co-authored-by: David Terpay <david.terpay@gmail.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
// that is included in the bundle into a sdk.Tx. In the default case, the transaction
// that is included in the bundle will be the raw bytes of an sdk.Tx so we can just
// decode it.
func (config *DefaultAuctionFactory) WrapBundleTransaction(tx []byte) (sdk.Tx, error) {

Choose a reason for hiding this comment

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

config -> factory or daf @davidterpay

txDecoder: txDecoder,
txEncoder: txEncoder,
txIndex: make(map[string]struct{}),
AuctionFactory: config,

Choose a reason for hiding this comment

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

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants