Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (f *evmReportFormatter) packReport(lggr logger.Logger, report *secureMintRe
map[EVMEncoderKey]any{
DataIDOutputFieldName: f.dataID,
AnswerOutputFieldName: smReportAsAnswer,
TimestampOutputFieldName: uint32(report.Block),
TimestampOutputFieldName: uint32(report.SeqNr),
},
}

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

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

toWrap := []any{
map[SolanaEncoderKey]any{
SolTimestampOutputFieldName: uint32(report.Block), // TODO: Verify with Michael/Geert timestamp should be block number?
SolTimestampOutputFieldName: uint32(report.SeqNr),
SolAnswerOutputFieldName: smReportAsAnswer,
SolDataIDOutputFieldName: f.dataID,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
dataID string
solAccounts [][32]byte
previousOutcome *types.AggregationOutcome
seqNr uint64
observations map[ocrcommon.OracleID][]values.Value
f int
expectedShouldReport bool
Expand Down Expand Up @@ -69,7 +70,7 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
assert.NotNil(t, answer)

timestamp := report[TimestampOutputFieldName].(int64)
assert.Equal(t, int64(1000), timestamp)
assert.Equal(t, int64(tc.seqNr), timestamp)
}

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

timestamp := report[SolTimestampOutputFieldName].(int64)
assert.Equal(t, int64(1000), timestamp)
assert.Equal(t, int64(tc.seqNr), timestamp)
}

tests := []tcase{
{
name: "successful eth report extraction",
chainSelector: "16015286601757825753",
dataID: "0x01c508f42b0201320000000000000000",
seqNr: 10,
observations: createSecureMintObservations(t, []ocrTriggerEventData{
{
chainSelector: ethSepoliaChainSelector,
Expand All @@ -121,10 +123,10 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
},
{
chainSelector: bnbTestnetChainSelector,
seqNr: 11,
seqNr: 10,
report: &secureMintReport{
ConfigDigest: ocr2types.ConfigDigest{0: 2, 31: 3},
SeqNr: 11,
SeqNr: 10,
Block: 1100,
Mintable: big.NewInt(200),
},
Expand All @@ -139,6 +141,7 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
name: "no matching chain selector found",
chainSelector: "16015286601757825753",
dataID: "0x01c508f42b0201320000000000000000",
seqNr: 10,
observations: createSecureMintObservations(t, []ocrTriggerEventData{
{
chainSelector: bnbTestnetChainSelector,
Expand All @@ -160,6 +163,7 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
name: "no observations",
chainSelector: "16015286601757825753",
dataID: "0x01c508f42b0201320000000000000000",
seqNr: 10,
observations: map[ocrcommon.OracleID][]values.Value{},
f: 1,
expectError: true,
Expand All @@ -169,6 +173,7 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
name: "successful sol report extraction",
chainSelector: "16423721717087811551", // solana devnet
dataID: "0x01c508f42b0201320000000000000000",
seqNr: 10,
solAccounts: [][32]byte{acc1, acc2},
observations: createSecureMintObservations(t, []ocrTriggerEventData{
{
Expand All @@ -183,10 +188,10 @@ func TestSecureMintAggregator_Aggregate(t *testing.T) {
},
{
chainSelector: bnbTestnetChainSelector,
seqNr: 11,
seqNr: 10,
report: &secureMintReport{
ConfigDigest: ocr2types.ConfigDigest{0: 2, 31: 3},
SeqNr: 11,
SeqNr: 10,
Block: 1100,
Mintable: big.NewInt(200),
},
Expand Down
Loading