Skip to content

Commit

Permalink
VRF-367 Fix use of getRoundRobinAddress in VRF listener
Browse files Browse the repository at this point in the history
  • Loading branch information
vreff committed Mar 8, 2023
1 parent 9c3f5d5 commit 5db7a84
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
27 changes: 10 additions & 17 deletions core/services/vrf/listener_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,12 +571,7 @@ func (lsn *listenerV2) processRequestsPerSubBatch(
}

fromAddresses := lsn.fromAddresses()
fromAddress, err := lsn.gethks.GetRoundRobinAddress(lsn.chainID, fromAddresses...)
if err != nil {
l.Errorw("Couldn't get next from address", "err", err)
continue
}
maxGasPriceWei := lsn.cfg.KeySpecificMaxGasPriceWei(fromAddress)
maxGasPriceWei := lsn.cfg.KeySpecificMaxGasPriceWei(fromAddresses[0])

// Cases:
// 1. Never simulated: in this case, we want to observe the time until simulated
Expand All @@ -593,7 +588,6 @@ func (lsn *listenerV2) processRequestsPerSubBatch(
ll := l.With("reqID", p.req.req.RequestId.String(),
"txHash", p.req.req.Raw.TxHash,
"maxGasPrice", maxGasPriceWei.String(),
"fromAddress", fromAddress,
"juelsNeeded", p.juelsNeeded.String(),
"maxLink", p.maxLink.String(),
"gasLimit", p.gasLimit,
Expand Down Expand Up @@ -647,7 +641,7 @@ func (lsn *listenerV2) processRequestsPerSubBatch(
var processedRequestIDs []string
for _, batch := range batches.fulfillments {
l.Debugw("Processing batch", "batchSize", len(batch.proofs))
p := lsn.processBatch(l, subID, fromAddress, startBalanceNoReserveLink, batchMaxGas, batch)
p := lsn.processBatch(l, subID, startBalanceNoReserveLink, batchMaxGas, batch)
processedRequestIDs = append(processedRequestIDs, p...)
}

Expand Down Expand Up @@ -753,21 +747,13 @@ func (lsn *listenerV2) processRequestsPerSub(
}

fromAddresses := lsn.fromAddresses()
fromAddress, err := lsn.gethks.GetRoundRobinAddress(lsn.chainID, fromAddresses...)
if err != nil {
l.Errorw("Couldn't get next from address", "err", err)
continue
}
maxGasPriceWei := lsn.cfg.KeySpecificMaxGasPriceWei(fromAddress)

maxGasPriceWei := lsn.cfg.KeySpecificMaxGasPriceWei(fromAddresses[0])
observeRequestSimDuration(lsn.job.Name.ValueOrZero(), lsn.job.ExternalJobID, v2, unfulfilled)

pipelines := lsn.runPipelines(ctx, l, maxGasPriceWei, unfulfilled)
for _, p := range pipelines {
ll := l.With("reqID", p.req.req.RequestId.String(),
"txHash", p.req.req.Raw.TxHash,
"maxGasPrice", maxGasPriceWei.String(),
"fromAddress", fromAddress,
"juelsNeeded", p.juelsNeeded.String(),
"maxLink", p.maxLink.String(),
"gasLimit", p.gasLimit,
Expand Down Expand Up @@ -809,6 +795,13 @@ func (lsn *listenerV2) processRequestsPerSub(
return processed
}

fromAddress, err := lsn.gethks.GetRoundRobinAddress(lsn.chainID, fromAddresses...)
if err != nil {
l.Errorw("Couldn't get next from address", "err", err)
continue
}
ll = ll.With("fromAddress", fromAddress)

ll.Infow("Enqueuing fulfillment")
var ethTX txmgr.EthTx
err = lsn.q.Transaction(func(tx pg.Queryer) error {
Expand Down
10 changes: 9 additions & 1 deletion core/services/vrf/listener_v2_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func (b *batchFulfillments) addRun(result vrfPipelineResult) {
func (lsn *listenerV2) processBatch(
l logger.Logger,
subID uint64,
fromAddress common.Address,
startBalanceNoReserveLink *big.Int,
maxCallbackGasLimit uint32,
batch *batchFulfillment,
Expand All @@ -125,9 +124,18 @@ func (lsn *listenerV2) processBatch(
maxCallbackGasLimit,
float64(lsn.job.VRFSpec.BatchFulfillmentGasMultiplier),
)

fromAddresses := lsn.fromAddresses()
fromAddress, err := lsn.gethks.GetRoundRobinAddress(lsn.chainID, fromAddresses...)
if err != nil {
l.Errorw("Couldn't get next from address", "err", err)
return
}

ll := l.With("numRequestsInBatch", len(batch.reqIDs),
"requestIDs", batch.reqIDs,
"batchSumGasLimit", batch.totalGasLimit,
"fromAddress", fromAddresses,
"linkBalance", startBalanceNoReserveLink,
"totalGasLimitBumped", totalGasLimitBumped,
"gasMultiplier", lsn.job.VRFSpec.BatchFulfillmentGasMultiplier,
Expand Down

0 comments on commit 5db7a84

Please sign in to comment.