Skip to content

Commit

Permalink
FHE empty slice fix (#14857)
Browse files Browse the repository at this point in the history
* FHE empty slice fix

* Add changeset
  • Loading branch information
dimriou authored and cedric-cordenier committed Oct 24, 2024
1 parent d8ba99d commit 0279a51
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/fifty-squids-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": minor
---

FHE empty reward fix #internal
5 changes: 3 additions & 2 deletions core/chains/evm/gas/fee_history_estimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,10 @@ func (f *FeeHistoryEstimator) RefreshDynamicPrice() error {
priorityFee := big.NewInt(0)
priorityFeeThreshold := big.NewInt(0)
for _, reward := range feeHistory.Reward {
// reward needs to have values for two percentiles
// reward needs to have values for two percentiles. Some chains may return an empty slice instead of 0x0 values, so we use
// continue instead of throwing an error.
if len(reward) < 2 {
return fmt.Errorf("reward size incorrect: %d", len(reward))
continue
}
// We'll calculate the average of non-zero priority fees
if reward[0].Cmp(big.NewInt(0)) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/gas/fee_history_estimator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func TestFeeHistoryEstimatorGetDynamicFee(t *testing.T) {

feeHistoryResult := &ethereum.FeeHistory{
OldestBlock: big.NewInt(1),
Reward: [][]*big.Int{{maxPriorityFeePerGas1, big.NewInt(5)}, {maxPriorityFeePerGas2, big.NewInt(5)}}, // first one represents market price and second one connectivity price
Reward: [][]*big.Int{{maxPriorityFeePerGas1, big.NewInt(5)}, {maxPriorityFeePerGas2, big.NewInt(5)}, {}}, // first one represents market price and second one connectivity price
BaseFee: []*big.Int{baseFee, baseFee},
GasUsedRatio: nil,
}
Expand Down

0 comments on commit 0279a51

Please sign in to comment.