-
Notifications
You must be signed in to change notification settings - Fork 33
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
[submitter] should resign pending on gas limit change #2771
Comments
To address the issue of the submitter needing to resign pending transactions on gas limit change, follow these steps:
func (t *txSubmitterImpl) SubmitTransaction(parentCtx context.Context, chainID *big.Int, call ContractCallType) (nonce uint64, err error) {
ctx, span := t.metrics.Tracer().Start(parentCtx, "submitter.SubmitTransaction", trace.WithAttributes(
attribute.Stringer("chainID", chainID),
attribute.String("caller", runtime.FuncForPC(reflect.ValueOf(call).Pointer()).Name()),
))
defer func() {
metrics.EndSpanWithErr(span, err)
}()
// Check for gas limit changes
if t.config.GetGasEstimate(int(chainID.Uint64())) != transactor.GasLimit {
t.triggerProcessQueue(ctx)
}
// Existing logic...
}
func (t *txSubmitterImpl) triggerProcessQueue(ctx context.Context) {
select {
case <-ctx.Done():
return
case t.retryNow <- true:
default:
// Handle gas limit change
t.retryNow <- true
}
}
// Add a method to detect gas limit changes
func (c *Config) HasGasLimitChanged(chainID int, currentGasLimit uint64) bool {
return c.GetGasEstimate(chainID) != currentGasLimit
} These changes ensure that the submitter will reprocess transactions if the gas limit configuration changes. References/ethergo/submitter/submitter.go |
To implement the feature where the submitter should bump transactions when the gas limit changes, follow these steps:
Example code snippets: config.go: func (c *Config) HasGasLimitChanged(chainID int, newGasLimit uint64) bool {
currentGasLimit := c.GetGasEstimate(chainID)
return currentGasLimit != newGasLimit
} chain_queue.go: func (c *chainQueue) bumpTX(parentCtx context.Context, ogTx db.TX) (err error) {
// Existing logic...
newGasEstimate, err := c.getGasEstimate(ctx, c.client, c.chainIDInt(), tx)
if err != nil {
return fmt.Errorf("could not get gas estimate: %w", err)
}
if c.config.HasGasLimitChanged(c.chainIDInt(), newGasEstimate) {
// Logic to bump transaction due to gas limit change
}
// Existing logic...
} submitter.go: func (t *txSubmitterImpl) SubmitTransaction(parentCtx context.Context, chainID *big.Int, call ContractCallType) (nonce uint64, err error) {
// Existing logic...
gasEstimate := t.config.GetGasEstimate(int(chainID.Uint64()))
if t.config.HasGasLimitChanged(int(chainID.Uint64()), gasEstimate) {
// Logic to handle gas limit change
}
// Existing logic...
} References/ethergo/submitter/chain_queue.go |
if config gas limit changes, submitter should "bump"
The text was updated successfully, but these errors were encountered: