Skip to content

Commit

Permalink
change to 0x01 pad instead of 0x00 pad
Browse files Browse the repository at this point in the history
  • Loading branch information
augustbleeds committed Jul 17, 2024
1 parent 3689e4b commit fd11697
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions relayer/pkg/chainlink/ocr2/medianreport/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -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>, ..., <N_ID>, 0x0, 0x0, ..., 0x0]
// encoding scheme is offset by 0x01-padded to avoid felt overflow
// [0x01, <1_ID>, <2_ID>, ..., <N_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)
Expand Down
2 changes: 2 additions & 0 deletions relayer/pkg/chainlink/ocr2/medianreport/report_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit fd11697

Please sign in to comment.