Open trajan0x opened 4 months ago
To address the issue of the submitter needing to resign pending transactions on gas limit change, follow these steps:
SubmitTransaction
in submitter.go
: Add logic to check for gas limit changes before submitting a transaction.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...
}
triggerProcessQueue
in submitter.go
: Ensure it handles the gas limit change appropriately.func (t *txSubmitterImpl) triggerProcessQueue(ctx context.Context) {
select {
case <-ctx.Done():
return
case t.retryNow <- true:
default:
// Handle gas limit change
t.retryNow <- true
}
}
config.go
: Ensure the configuration changes are detected and propagated correctly.// 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.
/ethergo/submitter/submitter.go /ethergo/submitter/config/config.go /ethergo/submitter
To implement the feature where the submitter should bump transactions when the gas limit changes, follow these steps:
Update Configuration Handling:
config.go
to include a method for detecting changes in the gas limit.Modify chain_queue.go
:
chainQueue
struct, add logic to check for gas limit changes and trigger a bump if detected.bumpTX
method to handle gas limit changes.Modify submitter.go
:
SubmitTransaction
method, add logic to check for gas limit changes before submitting a transaction.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...
}
/ethergo/submitter/chain_queue.go /ethergo/submitter/submitter.go /ethergo/submitter/config/config.go
if config gas limit changes, submitter should "bump"