-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
generalized fee estimation interface #8561
Changes from all commits
5edd3ba
dd078be
68f7dad
ce243aa
e543b43
e32bfec
69ce9a2
afc7859
94c99d8
839ee60
21043ff
24e105d
2f69803
ced4a24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,32 @@ | ||||
package types | ||||
|
||||
import "context" | ||||
|
||||
// Opt is an option for a gas estimator | ||||
type Opt int | ||||
|
||||
const ( | ||||
// OptForceRefetch forces the estimator to bust a cache if necessary | ||||
OptForceRefetch Opt = iota | ||||
) | ||||
|
||||
// PriorAttempt provides a generic interface for reading tx data to be used in the fee esimators | ||||
type PriorAttempt[FEE any, HASH any] interface { | ||||
Fee() FEE | ||||
GetChainSpecificGasLimit() uint32 | ||||
GetBroadcastBeforeBlockNum() *int64 | ||||
GetHash() HASH | ||||
GetTxType() int | ||||
} | ||||
|
||||
// FeeEstimator provides a generic interface for fee estimation | ||||
// | ||||
//go:generate mockery --quiet --name FeeEstimator --output ./mocks/ --case=underscore | ||||
type FeeEstimator[HEAD any, FEE any, MAXPRICE any, HASH any] interface { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The MAXPRICE actually is also never needed to be passed in to estimator by the generic txmgr. I would say, create a sub-task or ticket, to remove it from generic interface here later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How would it be fetched directly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is used on a job-specific basis There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would agree with Sam, I think it's still needed as it's a different config variable then the global chain configs and can be different for each tx There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This value is a keySpecfic config currently. GasEstimator can directly fetch that from config, if it has the Key available.. Here is a place where TxMgr currently fetches it:
Doing this just makes it clear that the interface between coreTxm <--> GasEstimator doesn't require this value to be passed in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but then each gas estimator would need knowledge of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should be passed in. It is used in keepers I think, specifically (or used to be) |
||||
OnNewLongestChain(context.Context, HEAD) | ||||
Start(context.Context) error | ||||
Close() error | ||||
|
||||
GetFee(ctx context.Context, calldata []byte, feeLimit uint32, maxFeePrice MAXPRICE, opts ...Opt) (fee FEE, chainSpecificFeeLimit uint32, err error) | ||||
BumpFee(ctx context.Context, originalFee FEE, feeLimit uint32, maxFeePrice MAXPRICE, attempts []PriorAttempt[FEE, HASH]) (bumpedFee FEE, chainSpecificFeeLimit uint32, err error) | ||||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, I don't think there is any reason for the common TxMgr components to use PriorAttempt interface.
It already doesn't use it, except to pass it to Estimator.BumpGas().
I believe we could always just pass in previous Attempts in the form of a generic TxAttempt. And the chain specific code should know what to extract from it, to bump gas correctly.
Not for this PR, but for later, let us aim to completely do away with this interface, and just reuse TxAttempt.
If you want, create a separate subtask or ticket for this, for later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼 I will take a look at this part when I'm working with the TxBuilder