Skip to content

Commit 6f85dda

Browse files
committed
docs: SendAggregatedResponse and gas price calc
1 parent 5abc31e commit 6f85dda

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

core/chainio/avs_writer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ func NewAvsWriterFromConfig(baseConfig *config.BaseConfig, ecdsaConfig *config.E
7676
}, nil
7777
}
7878

79-
func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMerkleRoot [32]byte, senderAddress [20]byte, nonSignerStakesAndSignature servicemanager.IBLSSignatureCheckerNonSignerStakesAndSignature) (*types.Receipt, error) {
79+
// Sends AggregatedResponse and waits for the receipt for three blocks, if not received
80+
// it will try again bumping the last tx gas price based on `CalculateGasPriceBump`
81+
// This process happens indefinitely until the transaction is included.
82+
func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMerkleRoot [32]byte, senderAddress [20]byte, nonSignerStakesAndSignature servicemanager.IBLSSignatureCheckerNonSignerStakesAndSignature, onRetry func()) (*types.Receipt, error) {
8083
txOpts := *w.Signer.GetTxOpts()
8184
txOpts.NoSend = true // simulate the transaction
8285
tx, err := w.AvsContractBindings.ServiceManager.RespondToTaskV2(&txOpts, batchMerkleRoot, senderAddress, nonSignerStakesAndSignature)
@@ -99,9 +102,6 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe
99102
txOpts.NoSend = false
100103
txOpts.Nonce = txNonce
101104

102-
// Sends a transaction and waits for the receipt for three blocks, if not received
103-
// it will try again bumping the gas price based on `CalculateGasPriceBumpBasedOnRetry`
104-
// This process happens indefinitely until we sendTransaction does not return err.
105105
lastTxGasPrice := tx.GasPrice()
106106
sendTransaction := func() (*types.Receipt, error) {
107107
bumpedGasPrice := utils.CalculateGasPriceBump(lastTxGasPrice, gasBumpPercentage)

core/utils/eth_client_utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ func BytesToQuorumThresholdPercentages(quorumThresholdPercentagesBytes []byte) e
4848
return quorumThresholdPercentages
4949
}
5050

51-
// Very basic algorithm to calculate the gasPrice bump based on the currentGasPrice and retry iteration.
52-
// It adds a i/10 percentage to the current prices, where i represents the iteration.
51+
// Very basic algorithm to calculate the gasPrice bump based on the currentGasPrice and percentage.
52+
// It adds a the percentage to the current gas price.
5353
func CalculateGasPriceBump(currentGasPrice *big.Int, percentage int) *big.Int {
5454
percentageBump := new(big.Int).Div(big.NewInt(int64(percentage)), big.NewInt(100))
5555
bumpAmount := new(big.Int).Mul(currentGasPrice, percentageBump)

0 commit comments

Comments
 (0)