@@ -21,7 +21,7 @@ import (
2121)
2222
2323const (
24- gasBumpPercentage int = 10
24+ gasBumpPercentage int = 20
2525)
2626
2727type AvsWriter struct {
@@ -79,6 +79,7 @@ func NewAvsWriterFromConfig(baseConfig *config.BaseConfig, ecdsaConfig *config.E
7979// Sends AggregatedResponse and waits for the receipt for three blocks, if not received
8080// it will try again bumping the last tx gas price based on `CalculateGasPriceBump`
8181// This process happens indefinitely until the transaction is included.
82+ // Note: If the rpc endpoints fail, the retry will stop, as it will infinitely try
8283func (w * AvsWriter ) SendAggregatedResponse (batchIdentifierHash [32 ]byte , batchMerkleRoot [32 ]byte , senderAddress [20 ]byte , nonSignerStakesAndSignature servicemanager.IBLSSignatureCheckerNonSignerStakesAndSignature , onRetry func ()) (* types.Receipt , error ) {
8384 txOpts := * w .Signer .GetTxOpts ()
8485 txOpts .NoSend = true // simulate the transaction
@@ -102,17 +103,23 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe
102103 txOpts .NoSend = false
103104 txOpts .Nonce = txNonce
104105
105- lastTxGasPrice := tx .GasPrice ()
106106 i := 0
107107 sendTransaction := func () (* types.Receipt , error ) {
108108 if i > 0 {
109109 onRetry ()
110110 }
111111 i ++
112112
113- bumpedGasPrice := utils .CalculateGasPriceBump (lastTxGasPrice , gasBumpPercentage )
114- lastTxGasPrice = bumpedGasPrice
115- txOpts .GasPrice = bumpedGasPrice
113+ // get gas price
114+ gasPrice , err := w .Client .SuggestGasPrice (context .Background ())
115+ if err != nil {
116+ // Retry with fallback
117+ gasPrice , err = w .ClientFallback .SuggestGasPrice (context .Background ())
118+ if err != nil {
119+ return nil , fmt .Errorf ("transaction simulation failed: %v" , err )
120+ }
121+ }
122+ txOpts .GasPrice = utils .CalculateGasPriceBumpBasedOnRetry (gasPrice , gasBumpPercentage , i )
116123
117124 w .logger .Infof ("Sending ResponseToTask transaction with a gas price of %v" , txOpts .GasPrice )
118125 err = w .checkRespondToTaskFeeLimit (tx , txOpts , batchIdentifierHash , senderAddress )
0 commit comments