Skip to content

Commit 0532369

Browse files
authored
Merge pull request #697 from smartcontractkit/fix/stom-proxy-round-id-decode
fix(ocr2): restore low-bit round ID decode for STOM proxy feeds
2 parents 5e4c5d9 + e8b0191 commit 0532369

2 files changed

Lines changed: 47 additions & 4 deletions

File tree

relayer/pkg/chainlink/ocr2/types.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,7 @@ func NewRoundData(felts []*felt.Felt) (data RoundData, err error) {
6060
return data, fmt.Errorf("expected number of felts to be 5 but got %d", len(felts))
6161
}
6262
roundID := felts[0].BigInt(big.NewInt(0))
63-
if !roundID.IsUint64() {
64-
return data, fmt.Errorf("aggregator round id does not fit in a uint64 '%s'", felts[0].String())
65-
}
66-
roundID64 := felts[0].BigInt(big.NewInt(0)).Uint64()
63+
roundID64 := roundID.Uint64()
6764
if roundID64 > math.MaxUint32 {
6865
return data, fmt.Errorf("aggregator round id does not fit in a uint32 '%s'", felts[0].String())
6966
}

relayer/pkg/chainlink/ocr2/types_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,52 @@ func TestNewRoundData(t *testing.T) {
3232
require.Equal(t, expectedRound, actualRound)
3333
}
3434

35+
func TestNewRoundData_ProxyPhasePrefixedRoundID(t *testing.T) {
36+
t.Parallel()
37+
38+
testCases := []struct {
39+
name string
40+
roundIDHex string
41+
expectedRound uint32
42+
}{
43+
{
44+
name: "DAI/USD phase 1",
45+
roundIDHex: "0x100000000000000000000000000010c80",
46+
expectedRound: 0x10c80,
47+
},
48+
{
49+
name: "USDC/USD phase 1",
50+
roundIDHex: "0x10000000000000000000000000001192e",
51+
expectedRound: 0x1192e,
52+
},
53+
{
54+
name: "ETH/USD phase 1",
55+
roundIDHex: "0x10000000000000000000000000001664b",
56+
expectedRound: 0x1664b,
57+
},
58+
}
59+
60+
for _, tc := range testCases {
61+
t.Run(tc.name, func(t *testing.T) {
62+
t.Parallel()
63+
64+
raw := []string{
65+
tc.roundIDHex,
66+
"0x5f5e100",
67+
"0x1087",
68+
"0x633344a3",
69+
"0x633344a5",
70+
}
71+
felts, err := starknetutils.HexArrToFelt(raw)
72+
require.NoError(t, err)
73+
74+
actualRound, err := NewRoundData(felts)
75+
require.NoError(t, err)
76+
require.Equal(t, tc.expectedRound, actualRound.RoundID)
77+
})
78+
}
79+
}
80+
3581
// Helpers
3682

3783
func bigIntFromString(s string) *big.Int {

0 commit comments

Comments
 (0)