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

[submitter] should resign pending on gas limit change #2771

Open
trajan0x opened this issue Jun 22, 2024 · 2 comments
Open

[submitter] should resign pending on gas limit change #2771

trajan0x opened this issue Jun 22, 2024 · 2 comments
Assignees

Comments

@trajan0x
Copy link
Contributor

if config gas limit changes, submitter should "bump"

Copy link

greptile-apps bot commented Jun 22, 2024

To address the issue of the submitter needing to resign pending transactions on gas limit change, follow these steps:

  1. Modify 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...
}
  1. Update 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
    }
}
  1. Update 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.

References

/ethergo/submitter/submitter.go
/ethergo/submitter/config/config.go
/ethergo/submitter

Ask Greptile

@trajan0x trajan0x added the small label Jun 24, 2024
@trajan0x trajan0x reopened this Jun 24, 2024
@trajan0x trajan0x removed the small label Jun 24, 2024
Copy link

greptile-apps bot commented Jun 24, 2024

To implement the feature where the submitter should bump transactions when the gas limit changes, follow these steps:

  1. Update Configuration Handling:

    • Modify config.go to include a method for detecting changes in the gas limit.
  2. Modify chain_queue.go:

    • In the chainQueue struct, add logic to check for gas limit changes and trigger a bump if detected.
    • Update the bumpTX method to handle gas limit changes.
  3. Modify submitter.go:

    • In the 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...
}

References

/ethergo/submitter/chain_queue.go
/ethergo/submitter/submitter.go
/ethergo/submitter/config/config.go

Ask Greptile

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

No branches or pull requests

2 participants