Skip to content

Commit 47ddd9f

Browse files
committed
fix: address comments
1 parent e1bd37e commit 47ddd9f

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

core/chainio/avs_writer.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,23 +123,19 @@ func NewAvsWriterFromConfig(baseConfig *config.BaseConfig, ecdsaConfig *config.E
123123
// SendAggregatedResponse continuously sends a RespondToTask transaction until it is included in the blockchain.
124124
// This function:
125125
// 1. Simulates the transaction to calculate the nonce and initial gas price without broadcasting it.
126-
// 2. Repeatedly attempts to send the transaction, bumping the gas price after `timeToWaitBeforeBump` has passed.
127-
// 3. Monitors for the receipt of previously sent transactions or checks the state to confirm if the response
128-
// has already been processed (e.g., by another transaction).
129-
// 4. Validates that the aggregator and batcher have sufficient balance to cover transaction costs before sending.
126+
// 2. Validates that the aggregator and batcher have sufficient balance to cover transaction costs before sending.
127+
// 3. Repeatedly attempts to send the transaction via GeometricTxManager, bumping the gas price after `txn_confirmation_timeout` has passed.
130128
//
131129
// Returns:
132130
// - A transaction receipt if the transaction is successfully included in the blockchain.
133-
// - If no receipt is found, but the batch state indicates the response has already been processed, it exits
134-
// without an error (returning `nil, nil`).
135131
// - An error if the process encounters a fatal issue (e.g., permanent failure in verifying balances or state).
136132
func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMerkleRoot [32]byte, senderAddress [20]byte, nonSignerStakesAndSignature servicemanager.IBLSSignatureCheckerNonSignerStakesAndSignature) (*types.Receipt, error) {
137133
txOpts, err := w.TxManager.GetNoSendTxOpts()
138134
if err != nil {
139135
w.logger.Errorf("Failed to get transaction options: %v", err)
140136
return nil, err
141137
}
142-
// This is used to simulate the transaction and get the transaction ready for sending
138+
// Note: txOpts is set to simulate the tx. This is to make sure it won't revert and get the transaction ready for sending.
143139
tx, err := w.RespondToTaskV2Retryable(txOpts, batchMerkleRoot, senderAddress, nonSignerStakesAndSignature, retry.SendToChainRetryParams())
144140
if err != nil {
145141
w.logger.Errorf("Failed to simulate transaction: %v", err)
@@ -164,7 +160,7 @@ func (w *AvsWriter) SendAggregatedResponse(batchIdentifierHash [32]byte, batchMe
164160
return nil, err
165161
}
166162
w.logger.Infof("RespondToTask transaction (%v) sent for MerkleRoot %v. %+v", tx.Hash().Hex(), batchMerkleRootHashString, receipt)
167-
w.updateAggregatorGasCostMetrics(receipt, batchIdentifierHash) // At this point receipt is not nil, so we can safely update the metrics
163+
w.updateAggregatorGasCostMetrics(receipt, batchIdentifierHash)
168164
return receipt, nil
169165
}
170166
return retry.RetryWithData(respondToTaskV2Func, retry.RespondToTaskV2())

core/chainio/retryable.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ import (
1515

1616
// |---AVS_WRITER---|
1717

18+
/*
19+
SendTransactionRetryable
20+
Send a transaction to the Ethereum node.
21+
- All errors are considered Transient Errors
22+
- Retry times (3 retries): 12 sec (1 Blocks), 24 sec (2 Blocks), 48 sec (4 Blocks)
23+
- NOTE: Contract call reverts are not considered `PermanentError`'s as block reorg's may lead to contract call revert in which case the aggregator should retry.
24+
- NOTE: If ()err != nil) receipt is guaranteed to be not nil.
25+
*/
1826
func (w *AvsWriter) SendTransactionRetryable(ctx context.Context, tx *types.Transaction, config *retry.RetryParams) (*types.Receipt, error) {
1927
// Note: waitForReceipt parameter is ignored in GeometricTxManager
2028
sendTransaction_func := func() (*types.Receipt, error) {

0 commit comments

Comments
 (0)