diff --git a/relayer/pkg/chainlink/ocr2/medianreport/onchainconfig.go b/relayer/pkg/chainlink/ocr2/medianreport/onchainconfig.go index 47a5b0256..bf23529d5 100644 --- a/relayer/pkg/chainlink/ocr2/medianreport/onchainconfig.go +++ b/relayer/pkg/chainlink/ocr2/medianreport/onchainconfig.go @@ -36,10 +36,10 @@ func (codec OnchainConfigCodec) DecodeToFelts(b []byte) ([]*big.Int, error) { return []*big.Int{}, fmt.Errorf("unexpected version of OnchainConfig, expected %v, got %v", OnchainConfigVersion, configVersion.Int64()) } - min := new(big.Int).SetBytes(b[byteWidth : 2*byteWidth]) - max := new(big.Int).SetBytes(b[2*byteWidth:]) + minVal := new(big.Int).SetBytes(b[byteWidth : 2*byteWidth]) + maxVal := new(big.Int).SetBytes(b[2*byteWidth:]) - return []*big.Int{configVersion, min, max}, nil + return []*big.Int{configVersion, minVal, maxVal}, nil } // Decode converts the onchainconfig via the outputs of DecodeToFelts into unsigned big.Ints that libocr expects @@ -49,25 +49,25 @@ func (codec OnchainConfigCodec) Decode(ctx context.Context, b []byte) (median.On return median.OnchainConfig{}, err } - min := felts[1] - max := felts[2] + minVal := felts[1] + maxVal := felts[2] if !(min.Cmp(max) <= 0) { return median.OnchainConfig{}, fmt.Errorf("OnchainConfig min (%v) should not be greater than max(%v)", min, max) } - return median.OnchainConfig{Min: min, Max: max}, nil + return median.OnchainConfig{Min: minVal, Max: maxVal}, nil } // EncodeFromFelt encodes the config where min & max are big.Int representations of a felt // Cairo has no notion of signed values: min and max values will be non-negative -func (codec OnchainConfigCodec) EncodeFromFelt(version, min, max *big.Int) ([]byte, error) { +func (codec OnchainConfigCodec) EncodeFromFelt(version, minVal, maxVal *big.Int) ([]byte, error) { if version.Uint64() != OnchainConfigVersion { return nil, fmt.Errorf("unexpected version of OnchainConfig, expected %v, got %v", OnchainConfigVersion, version.Int64()) } - if min.Sign() == -1 || max.Sign() == -1 { - return nil, fmt.Errorf("starknet does not support negative values: min = (%v) and max = (%v)", min, max) + if minVal.Sign() == -1 || maxVal.Sign() == -1 { + return nil, fmt.Errorf("starknet does not support negative values: min = (%v) and max = (%v)", minVal, maxVal) } result := []byte{} @@ -75,8 +75,8 @@ func (codec OnchainConfigCodec) EncodeFromFelt(version, min, max *big.Int) ([]by minBytes := make([]byte, byteWidth) maxBytes := make([]byte, byteWidth) result = append(result, version.FillBytes(versionBytes)...) - result = append(result, min.FillBytes(minBytes)...) - result = append(result, max.FillBytes(maxBytes)...) + result = append(result, minVal.FillBytes(minBytes)...) + result = append(result, maxVal.FillBytes(maxBytes)...) return result, nil } diff --git a/relayer/pkg/chainlink/ocr2/medianreport/report_test.go b/relayer/pkg/chainlink/ocr2/medianreport/report_test.go index a55c94430..e369f86d0 100644 --- a/relayer/pkg/chainlink/ocr2/medianreport/report_test.go +++ b/relayer/pkg/chainlink/ocr2/medianreport/report_test.go @@ -214,7 +214,6 @@ func TestMedianFromReport(t *testing.T) { } for _, tc := range tt { - tc := tc t.Run(tc.name, func(t *testing.T) { ctx := tests.Context(t) var pos []median.ParsedAttributedObservation @@ -229,9 +228,9 @@ func TestMedianFromReport(t *testing.T) { } report, err := cdc.BuildReport(ctx, pos) require.NoError(t, err) - max, err := cdc.MaxReportLength(ctx, len(tc.obs)) + maxReportLength, err := cdc.MaxReportLength(ctx, len(tc.obs)) require.NoError(t, err) - assert.Equal(t, len(report), max) + assert.Equal(t, len(report), maxReportLength) med, err := cdc.MedianFromReport(ctx, report) require.NoError(t, err) assert.Equal(t, tc.expectedMedian.String(), med.String())