From c2882c7dd7f76b582808b7b4b5b818971be4d115 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Mon, 2 Dec 2024 19:09:43 -0300 Subject: [PATCH 1/5] fix: aggregator bump --- core/chainio/avs_writer.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/chainio/avs_writer.go b/core/chainio/avs_writer.go index 7ed6aa71eb..be9a5d3b3c 100644 --- a/core/chainio/avs_writer.go +++ b/core/chainio/avs_writer.go @@ -100,7 +100,6 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe // Set the nonce, as we might have to replace the transaction with a higher gas price txNonce := big.NewInt(int64(simTx.Nonce())) txOpts.Nonce = txNonce - txOpts.GasPrice = simTx.GasPrice() txOpts.NoSend = false i := 0 @@ -113,7 +112,9 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe if err != nil { return nil, err } - previousTxGasPrice := txOpts.GasPrice + // if txOpts.GasPrice wasn't previously set use the fetched gasPrice + // this should happen only in the first iteration + previousTxGasPrice := txOpts.GasPrice.Or(txOpts.GasPrice, gasPrice) // in order to avoid replacement transaction underpriced // the bumped gas price has to be at least 10% higher than the previous one. minimumGasPriceBump := utils.CalculateGasPriceBumpBasedOnRetry(previousTxGasPrice, 10, 0, gasBumpPercentageLimit, 0) From 3e45a557e3f4d8a54f55f85dc6c0be241a7e4307 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Mon, 2 Dec 2024 19:20:52 -0300 Subject: [PATCH 2/5] fix: set initial gas price to 0 to use fetched gasPrice --- core/chainio/avs_writer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/chainio/avs_writer.go b/core/chainio/avs_writer.go index be9a5d3b3c..dd8a5e280a 100644 --- a/core/chainio/avs_writer.go +++ b/core/chainio/avs_writer.go @@ -100,6 +100,9 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe // Set the nonce, as we might have to replace the transaction with a higher gas price txNonce := big.NewInt(int64(simTx.Nonce())) txOpts.Nonce = txNonce + // set it to zero + // so we use the fetched gas price in the first iteration + txOpts.GasPrice = big.NewInt(int64(0)) txOpts.NoSend = false i := 0 @@ -113,7 +116,6 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe return nil, err } // if txOpts.GasPrice wasn't previously set use the fetched gasPrice - // this should happen only in the first iteration previousTxGasPrice := txOpts.GasPrice.Or(txOpts.GasPrice, gasPrice) // in order to avoid replacement transaction underpriced // the bumped gas price has to be at least 10% higher than the previous one. From e3138976367952295fedfff62b05012a5e3e0684 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Mon, 2 Dec 2024 19:21:54 -0300 Subject: [PATCH 3/5] docs: comments --- core/chainio/avs_writer.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/chainio/avs_writer.go b/core/chainio/avs_writer.go index dd8a5e280a..9ecd1bf409 100644 --- a/core/chainio/avs_writer.go +++ b/core/chainio/avs_writer.go @@ -100,8 +100,7 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe // Set the nonce, as we might have to replace the transaction with a higher gas price txNonce := big.NewInt(int64(simTx.Nonce())) txOpts.Nonce = txNonce - // set it to zero - // so we use the fetched gas price in the first iteration + // set it to zero so we use the fetched gas price in the first iteration txOpts.GasPrice = big.NewInt(int64(0)) txOpts.NoSend = false i := 0 From 72323083d0a7d72053c57273ac3d234f02c8667c Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Mon, 2 Dec 2024 19:36:26 -0300 Subject: [PATCH 4/5] refactor: check tx with nil insted of bigInt.or --- core/chainio/avs_writer.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core/chainio/avs_writer.go b/core/chainio/avs_writer.go index 9ecd1bf409..6550b4261c 100644 --- a/core/chainio/avs_writer.go +++ b/core/chainio/avs_writer.go @@ -100,8 +100,7 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe // Set the nonce, as we might have to replace the transaction with a higher gas price txNonce := big.NewInt(int64(simTx.Nonce())) txOpts.Nonce = txNonce - // set it to zero so we use the fetched gas price in the first iteration - txOpts.GasPrice = big.NewInt(int64(0)) + txOpts.GasPrice = nil txOpts.NoSend = false i := 0 @@ -114,8 +113,16 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe if err != nil { return nil, err } + // if txOpts.GasPrice wasn't previously set use the fetched gasPrice - previousTxGasPrice := txOpts.GasPrice.Or(txOpts.GasPrice, gasPrice) + // this should happen on the first iteration only + var previousTxGasPrice *big.Int + if txOpts.GasPrice == nil { + previousTxGasPrice = gasPrice + } else { + previousTxGasPrice = gasPrice + } + // in order to avoid replacement transaction underpriced // the bumped gas price has to be at least 10% higher than the previous one. minimumGasPriceBump := utils.CalculateGasPriceBumpBasedOnRetry(previousTxGasPrice, 10, 0, gasBumpPercentageLimit, 0) From 4a6cdec6249399a88893f0af1075df2edee220a1 Mon Sep 17 00:00:00 2001 From: Marcos Nicolau Date: Mon, 2 Dec 2024 19:51:51 -0300 Subject: [PATCH 5/5] fix: set previousGasPrice --- core/chainio/avs_writer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/chainio/avs_writer.go b/core/chainio/avs_writer.go index 6550b4261c..cd379ee236 100644 --- a/core/chainio/avs_writer.go +++ b/core/chainio/avs_writer.go @@ -120,7 +120,7 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe if txOpts.GasPrice == nil { previousTxGasPrice = gasPrice } else { - previousTxGasPrice = gasPrice + previousTxGasPrice = txOpts.GasPrice } // in order to avoid replacement transaction underpriced