Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix when contract reader fails on latestRoundData call #1476

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/services/ocr2/plugins/ccip/internal/pricegetter/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,23 +203,23 @@ func (d *DynamicPriceGetter) performBatchCall(ctx context.Context, chainID uint6
contractName := fmt.Sprintf("%v_%v", OFFCHAIN_AGGREGATOR, j)
offchainAggregatorRespSlice := result[contractName]

for i, read := range offchainAggregatorRespSlice {
for _, read := range offchainAggregatorRespSlice {
val, readErr := read.GetResult()
if readErr != nil {
respErr = multierr.Append(respErr, fmt.Errorf("error with method call %v: %w", batchCalls.decimalCalls[i].MethodName(), readErr))
respErr = multierr.Append(respErr, fmt.Errorf("error with contract reader readName %v: %w", read.ReadName, readErr))
continue
}
if read.ReadName == DECIMALS_METHOD_NAME {
decimal, ok := val.(*uint8)
if !ok {
return fmt.Errorf("expected type uint8 for method call %v on contract %v: %w", batchCalls.decimalCalls[i].MethodName(), batchCalls.decimalCalls[i].ContractAddress(), readErr)
return fmt.Errorf("expected type uint8 for method call %v on contract %v: %w", batchCalls.decimalCalls[j].MethodName(), batchCalls.decimalCalls[j].ContractAddress(), readErr)
}

decimalsCR = append(decimalsCR, *decimal)
} else if read.ReadName == LATEST_ROUND_DATA_METHOD_NAME {
latestRoundDataRes, ok := val.(*aggregator_v3_interface.LatestRoundData)
if !ok {
return fmt.Errorf("expected type latestRoundDataConfig for method call %v on contract %v: %w", batchCalls.latestRoundDataCalls[i/2].MethodName(), batchCalls.latestRoundDataCalls[i/2].ContractAddress(), readErr)
return fmt.Errorf("expected type latestRoundDataConfig for method call %v on contract %v: %w", batchCalls.latestRoundDataCalls[j].MethodName(), batchCalls.latestRoundDataCalls[j].ContractAddress(), readErr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also add an assertion to the top that len(batchCalls.decimalCalls) == len(batchCalls.latestRoundDataCalls)

}

latestRoundCR = append(latestRoundCR, *latestRoundDataRes)
Expand Down
Loading