Skip to content

Commit 99c1fc5

Browse files
authored
DF-21815 Use seqNr as timestamp in the secure mint report (#1509)
1 parent fcae05e commit 99c1fc5

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

pkg/capabilities/consensus/ocr3/datafeeds/securemint_aggregator.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func (f *evmReportFormatter) packReport(lggr logger.Logger, report *secureMintRe
126126
map[EVMEncoderKey]any{
127127
DataIDOutputFieldName: f.dataID,
128128
AnswerOutputFieldName: smReportAsAnswer,
129-
TimestampOutputFieldName: uint32(report.Block),
129+
TimestampOutputFieldName: uint32(report.SeqNr),
130130
},
131131
}
132132

@@ -166,13 +166,13 @@ func (f *solanaReportFormatter) packReport(lggr logger.Logger, report *secureMin
166166
accountContextHash := sha256.Sum256(accounts)
167167
lggr.Debugw("calculated account context hash", "accountContextHash", accountContextHash)
168168

169-
if report.Block > (1<<32 - 1) { // timestamp must fit in u32 in solana
170-
return nil, fmt.Errorf("timestamp exceeds u32 bounds: %v", report.Block)
169+
if report.SeqNr > (1<<32 - 1) { // timestamp must fit in u32 in solana
170+
return nil, fmt.Errorf("timestamp exceeds u32 bounds: %v", report.SeqNr)
171171
}
172172

173173
toWrap := []any{
174174
map[SolanaEncoderKey]any{
175-
SolTimestampOutputFieldName: uint32(report.Block), // TODO: Verify with Michael/Geert timestamp should be block number?
175+
SolTimestampOutputFieldName: uint32(report.SeqNr),
176176
SolAnswerOutputFieldName: smReportAsAnswer,
177177
SolDataIDOutputFieldName: f.dataID,
178178
},

pkg/capabilities/consensus/ocr3/datafeeds/securemint_aggregator_test.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
3737
dataID string
3838
solAccounts [][32]byte
3939
previousOutcome *types.AggregationOutcome
40+
seqNr uint64
4041
observations map[ocrcommon.OracleID][]values.Value
4142
f int
4243
expectedShouldReport bool
@@ -69,7 +70,7 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
6970
assert.NotNil(t, answer)
7071

7172
timestamp := report[TimestampOutputFieldName].(int64)
72-
assert.Equal(t, int64(1000), timestamp)
73+
assert.Equal(t, int64(tc.seqNr), timestamp)
7374
}
7475

7576
solReportAssertFn := func(t *testing.T, tc tcase, topLevelMap map[string]any) {
@@ -100,14 +101,15 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
100101
assert.NotNil(t, answer)
101102

102103
timestamp := report[SolTimestampOutputFieldName].(int64)
103-
assert.Equal(t, int64(1000), timestamp)
104+
assert.Equal(t, int64(tc.seqNr), timestamp)
104105
}
105106

106107
tests := []tcase{
107108
{
108109
name: "successful eth report extraction",
109110
chainSelector: "16015286601757825753",
110111
dataID: "0x01c508f42b0201320000000000000000",
112+
seqNr: 10,
111113
observations: createSecureMintObservations(t, []ocrTriggerEventData{
112114
{
113115
chainSelector: ethSepoliaChainSelector,
@@ -121,10 +123,10 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
121123
},
122124
{
123125
chainSelector: bnbTestnetChainSelector,
124-
seqNr: 11,
126+
seqNr: 10,
125127
report: &secureMintReport{
126128
ConfigDigest: ocr2types.ConfigDigest{0: 2, 31: 3},
127-
SeqNr: 11,
129+
SeqNr: 10,
128130
Block: 1100,
129131
Mintable: big.NewInt(200),
130132
},
@@ -139,6 +141,7 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
139141
name: "no matching chain selector found",
140142
chainSelector: "16015286601757825753",
141143
dataID: "0x01c508f42b0201320000000000000000",
144+
seqNr: 10,
142145
observations: createSecureMintObservations(t, []ocrTriggerEventData{
143146
{
144147
chainSelector: bnbTestnetChainSelector,
@@ -160,6 +163,7 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
160163
name: "no observations",
161164
chainSelector: "16015286601757825753",
162165
dataID: "0x01c508f42b0201320000000000000000",
166+
seqNr: 10,
163167
observations: map[ocrcommon.OracleID][]values.Value{},
164168
f: 1,
165169
expectError: true,
@@ -169,6 +173,7 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
169173
name: "successful sol report extraction",
170174
chainSelector: "16423721717087811551", // solana devnet
171175
dataID: "0x01c508f42b0201320000000000000000",
176+
seqNr: 10,
172177
solAccounts: [][32]byte{acc1, acc2},
173178
observations: createSecureMintObservations(t, []ocrTriggerEventData{
174179
{
@@ -183,10 +188,10 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
183188
},
184189
{
185190
chainSelector: bnbTestnetChainSelector,
186-
seqNr: 11,
191+
seqNr: 10,
187192
report: &secureMintReport{
188193
ConfigDigest: ocr2types.ConfigDigest{0: 2, 31: 3},
189-
SeqNr: 11,
194+
SeqNr: 10,
190195
Block: 1100,
191196
Mintable: big.NewInt(200),
192197
},

0 commit comments

Comments
 (0)