Fix: Update TXM gasBump max and error resetting on retries - #481
Conversation
|
👋 faisal-chainlink, thanks for creating this pull request! To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team. Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks! |
There was a problem hiding this comment.
Pull request overview
This PR updates the Sui transaction manager’s retry behavior around gas bumping by ensuring the bumped gas budget is actually serialized into the rebuilt transaction payload, tightening the gas-bump max behavior, and preventing repeated retry scheduling for the same stored broadcast failure.
Changes:
- Sync
tx.GasBudgetwithMetadata.GasLimitduringUpdateTransactionGassoUpdateBSCPayloadrebuilds with the bumped budget. - Simplify/adjust
GasBumpmax-budget capping behavior and honor the configured percentage increase value. - Acknowledge scheduled retries by clearing
BroadcastError, and release reserved gas coins when a gas bump cannot be performed.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| relayer/txm/store.go | Synces serialized GasBudget with metadata before rebuilding the BCS payload. |
| relayer/txm/gas_manager.go | Adjusts gas bump computation (configured percent) and max-budget handling; removes math dependency. |
| relayer/txm/gas_manager_test.go | Updates gas bump expectations and adds tests for gas update serialization + invalid inputs. |
| relayer/txm/confirmer.go | Clears BroadcastError when scheduling retries and releases coins on gas-bump failure-at-max. |
| relayer/txm/confirmer_test.go | Adds regression coverage for retry acknowledgment and coin release at max budget. |
| relayer/client/suierrors/errors.go | Removes ErrGasBudgetTooHigh from gas-bump retryable errors with rationale. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if gasBudget == nil || !gasBudget.IsUint64() { | ||
| return fmt.Errorf("invalid gas budget: %v", gasBudget) | ||
| } | ||
|
|
||
| tx.Metadata.GasLimit = gasBudget |
| func (s *SuiGasManager) GasBump(ctx context.Context, tx *SuiTx) (big.Int, error) { | ||
| // gas budget should be the minimum value between the transaction and the gas manager config | ||
|
|
||
| // The max amount of the gas that the Gas manager will allow | ||
| gasManagerMaxGasBudget := big.NewInt(int64(s.maxGasBudget.Uint64())) | ||
|
|
||
| // Check if tx.GasBudget exceeds int64 max value to prevent overflow | ||
| if tx.GasBudget > math.MaxInt64 { | ||
| return *big.NewInt(0), fmt.Errorf("tx.GasBudget %d exceeds maximum int64 value", tx.GasBudget) | ||
| } | ||
|
|
||
| // the max amount of the gas that the transaction will allow | ||
| txGasBudget := big.NewInt(int64(tx.GasBudget)) | ||
|
|
||
| var maxGasLimit *big.Int | ||
|
|
||
| // Determine the maximum gas limit to use for bumping. | ||
| // The maximum is the lesser of the transaction's gas budget and the gas manager's configured maximum. | ||
| // This ensures we do not exceed either the transaction's intended limit or the system's allowed maximum. | ||
| if txGasBudget.Cmp(gasManagerMaxGasBudget) < 0 { | ||
| maxGasLimit = txGasBudget | ||
| } else { | ||
| maxGasLimit = gasManagerMaxGasBudget | ||
| } | ||
|
|
||
| txGasLimit := tx.Metadata.GasLimit | ||
| maxGasLimit := &s.maxGasBudget | ||
|
|
| func NewSuiGasManager(lggr logger.Logger, ptbClient client.SuiPTBClient, maxGasBudget big.Int, percentualIncrase int64) *SuiGasManager { | ||
| if percentualIncrase == 0 { | ||
| if percentualIncrase <= percentualNormalization { | ||
| percentualIncrase = gasLimitPercentualIncrease | ||
| } | ||
|
|
Describe your changes
Issue ticket number and link
Describe highly relevant files or code snippets that are critical in the review
Are there other PRs that should be merged first?