diff --git a/relayer/pkg/chainlink/ocr2/medianreport/report.go b/relayer/pkg/chainlink/ocr2/medianreport/report.go index 845bb4e7..ffb7364b 100644 --- a/relayer/pkg/chainlink/ocr2/medianreport/report.go +++ b/relayer/pkg/chainlink/ocr2/medianreport/report.go @@ -76,12 +76,12 @@ func (c ReportCodec) BuildReport(oo []median.ParsedAttributedObservation) (types var observers = make([]byte, starknet.FeltLength) var observations []*felt.Felt + observers[0] = uint8(1) for i, o := range oo { - // encoding scheme is offset by 1 byte to avoid felt overflow - // [0x0, <1_ID>, <2_ID>, ..., , 0x0, 0x0, ..., 0x0] + // encoding scheme is offset by 0x01-padded to avoid felt overflow + // [0x01, <1_ID>, <2_ID>, ..., , 0x0, 0x0, ..., 0x0] // note: this does not alter Starknet's MAX_ORACLES (31) - // to differentiate this encoding scheme from the original encoding scheme, check if, within the first N + 1 bytes, 0 occurs twice - // where N is the number of oracles in the DON + // where N is the length of the observations array observers[i+1] = byte(o.Observer) f := starknetutils.BigIntToFelt(o.Value) diff --git a/relayer/pkg/chainlink/ocr2/medianreport/report_test.go b/relayer/pkg/chainlink/ocr2/medianreport/report_test.go index 8f0dfa89..3bf83701 100644 --- a/relayer/pkg/chainlink/ocr2/medianreport/report_test.go +++ b/relayer/pkg/chainlink/ocr2/medianreport/report_test.go @@ -63,6 +63,8 @@ func TestBuildReport(t *testing.T) { v := big.NewInt(0) v.SetString("1000000000000000000", 10) + // 0x01 pad the first byte + observers[0] = uint8(1) for i := 0; i < n; i++ { oo = append(oo, median.ParsedAttributedObservation{ Timestamp: uint32(time.Now().Unix()),