Skip to content

Commit 4590ac0

Browse files
committed
Merge branch 'develop' into fix/inject-df-decoder
2 parents fd1b021 + 21cd5e3 commit 4590ac0

File tree

5 files changed

+50
-16
lines changed

5 files changed

+50
-16
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ require (
2121
github.com/prometheus/client_model v0.6.1
2222
github.com/prometheus/common v0.63.0
2323
github.com/shopspring/decimal v1.4.0
24-
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250606180235-5981ca5ebf20
25-
github.com/smartcontractkit/chainlink-framework/capabilities v0.0.0-20250606184316-1aa3b177e1ed
24+
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250609122728-51de5127f783
25+
github.com/smartcontractkit/chainlink-framework/capabilities v0.0.0-20250609122841-af2e3861cd5b
2626
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20250522110034-65c54665034a
2727
github.com/smartcontractkit/chainlink-framework/metrics v0.0.0-20250522110034-65c54665034a
2828
github.com/smartcontractkit/chainlink-framework/multinode v0.0.0-20250522110034-65c54665034a

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,10 +636,10 @@ github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546/go.mod h1:TrYk7fJV
636636
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
637637
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
638638
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
639-
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250606180235-5981ca5ebf20 h1:S2QoB+l2K1QUH5c/Y/1bfxQO+Qct0eRcyYg8JYuTpK0=
640-
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250606180235-5981ca5ebf20/go.mod h1:H7gOuN4Jzf+DWllfP5Pb7AiCWBMQrDX1D1KYXAEhdnw=
641-
github.com/smartcontractkit/chainlink-framework/capabilities v0.0.0-20250606184316-1aa3b177e1ed h1:RFyeTr0i47HduHjmzQOFdnDIckpaERZ47TpjGxM++IM=
642-
github.com/smartcontractkit/chainlink-framework/capabilities v0.0.0-20250606184316-1aa3b177e1ed/go.mod h1:zT66e+8i4OifSvNqpR6yCB2lbciq35vPGxzFDkMWdnQ=
639+
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250609122728-51de5127f783 h1:59Dqm+KykI4aeuCOl5JlQP3gv1u3ACGScXadakjIPjM=
640+
github.com/smartcontractkit/chainlink-common v0.7.1-0.20250609122728-51de5127f783/go.mod h1:H7gOuN4Jzf+DWllfP5Pb7AiCWBMQrDX1D1KYXAEhdnw=
641+
github.com/smartcontractkit/chainlink-framework/capabilities v0.0.0-20250609122841-af2e3861cd5b h1:nA2SI6TP532lk+cX3YG+XaRhqY9MwpGgOKBpKlbBjsI=
642+
github.com/smartcontractkit/chainlink-framework/capabilities v0.0.0-20250609122841-af2e3861cd5b/go.mod h1:3xH9a4lc4UYUWk/7CTfPgtZCbhEosqme1KOW8Fs0CaE=
643643
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20250522110034-65c54665034a h1:1CrY+turGOYaSEs4efA4zJprX0G2Uk+0dcDO1eCsHhk=
644644
github.com/smartcontractkit/chainlink-framework/chains v0.0.0-20250522110034-65c54665034a/go.mod h1:X+a4k2a+2G2/yeAaRQMCTLmlhNdQYAeN6v+ZpLzRZww=
645645
github.com/smartcontractkit/chainlink-framework/metrics v0.0.0-20250522110034-65c54665034a h1:bFYBcW0cmhq0G8NSjPxSFfL/fVODuhEGluyWOxJTqqk=

pkg/logpoller/log_poller.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,7 @@ func (lp *logPoller) blocksFromFinalizedLogs(ctx context.Context, logs []types.L
879879
for _, log := range logs {
880880
numbers = append(numbers, log.BlockNumber)
881881
}
882-
if numbers[len(numbers)-1] != endBlockNumber {
882+
if len(numbers) == 0 || numbers[len(numbers)-1] != endBlockNumber {
883883
numbers = append(numbers, endBlockNumber)
884884
}
885885
blocks, err = lp.GetBlocksRange(ctx, numbers)
@@ -930,21 +930,19 @@ func (lp *logPoller) backfill(ctx context.Context, start, end int64) error {
930930
continue
931931
}
932932
lp.missingBlocksErrorCount.Store(0) // clear unhealthy node state in case we were missing blocks and just found them
933-
if len(gethLogs) == 0 {
934-
continue
935-
}
933+
936934
blocks, err := lp.blocksFromFinalizedLogs(ctx, gethLogs, uint64(to)) //nolint:gosec // G115
937935
if err != nil {
938936
return err
939937
}
940938

941939
endblock := blocks[len(blocks)-1]
942-
if gethLogs[len(gethLogs)-1].BlockNumber != uint64(to) {
940+
if len(gethLogs) == 0 || gethLogs[len(gethLogs)-1].BlockNumber != uint64(to) { //nolint:gosec // G115
943941
// Pop endblock if there were no logs for it, so that length of blocks & gethLogs are the same to pass to convertLogs
944942
blocks = blocks[:len(blocks)-1]
945943
}
946944

947-
lp.lggr.Debugw("Backfill found logs", "from", from, "to", to, "logs", len(gethLogs), "blocks", blocks)
945+
lp.lggr.Debugw("Inserting backfilled logs with batch endblock", "from", from, "to", to, "logs", len(gethLogs), "blocks", blocks)
948946
err = lp.orm.InsertLogsWithBlock(ctx, convertLogs(gethLogs, blocks, lp.lggr, lp.ec.ConfiguredChainID()), endblock)
949947
if err != nil {
950948
lp.lggr.Warnw("Unable to insert logs, retrying", "err", err, "from", from, "to", to)
@@ -1208,7 +1206,13 @@ func (lp *logPoller) PruneOldBlocks(ctx context.Context) (bool, error) {
12081206
// No blocks saved yet.
12091207
return true, nil
12101208
}
1211-
if latestBlock.FinalizedBlockNumber <= lp.keepFinalizedBlocksDepth {
1209+
1210+
// If the latest block we have in the db was saved during a backfill, then the latest finalized
1211+
// block number stored with it will be larger than its block number. Instead of risking deleting
1212+
// all blocks from the db, we should still keep the latest keepFinalizedBlocksDepth blocks
1213+
referenceBlockNumber := mathutil.Min(latestBlock.FinalizedBlockNumber, latestBlock.BlockNumber)
1214+
1215+
if referenceBlockNumber <= lp.keepFinalizedBlocksDepth {
12121216
// No-op, keep all blocks
12131217
return true, nil
12141218
}

pkg/logpoller/log_poller_test.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/ethereum/go-ethereum/common/hexutil"
1616
"github.com/ethereum/go-ethereum/core/types"
1717
"github.com/ethereum/go-ethereum/ethclient/simulated"
18+
"github.com/ethereum/go-ethereum/rpc"
1819
"github.com/leanovate/gopter"
1920
"github.com/leanovate/gopter/gen"
2021
"github.com/leanovate/gopter/prop"
@@ -1562,15 +1563,42 @@ func TestTooManyLogResults(t *testing.T) {
15621563
if blockNumber == nil {
15631564
require.FailNow(t, "unexpected call to get current head")
15641565
}
1565-
return &evmtypes.Head{Number: blockNumber.Int64()}, nil
1566+
return &evmtypes.Head{Number: blockNumber.Int64(), ParentHash: common.HexToHash(fmt.Sprintf("0x%x", blockNumber.Int64()-1))}, nil
15661567
})
15671568

15681569
t.Run("halves size until small enough, then succeeds", func(t *testing.T) {
1569-
// Simulate currentBlock = 300
1570+
// Simulate latestBlock = 300
15701571
head.Number = 300
1572+
head.Hash = common.HexToHash("0x1234") // needed to satisfy validation in fetchBlocks()
15711573
finalized.Number = head.Number - lpOpts.FinalityDepth
1574+
15721575
headTracker.On("LatestAndFinalizedBlock", mock.Anything).Return(head, finalized, nil).Once()
15731576

1577+
headByHash := ec.On("HeadByHash", mock.Anything, mock.Anything).Return(func(ctx context.Context, blockHash common.Hash) (*evmtypes.Head, error) {
1578+
return &evmtypes.Head{Hash: blockHash}, nil
1579+
})
1580+
1581+
batchCallContext := ec.On("BatchCallContext", mock.Anything, mock.Anything).Return(
1582+
func(ctx context.Context, calls []rpc.BatchElem) error {
1583+
for i := range calls {
1584+
blockNumberHex := calls[i].Args[0].(string)
1585+
if blockNumberHex == "latest" {
1586+
calls[i].Result = head
1587+
continue
1588+
}
1589+
blockNumber, ok := new(big.Int).SetString(blockNumberHex[2:], 16)
1590+
require.True(t, ok, blockNumberHex)
1591+
1592+
calls[i].Result = &evmtypes.Head{
1593+
Number: blockNumber.Int64(),
1594+
Hash: common.HexToHash(fmt.Sprintf("0x%x", blockNumber.Int64())),
1595+
ParentHash: common.HexToHash(fmt.Sprintf("0x%x", blockNumber.Int64()-1)),
1596+
}
1597+
}
1598+
return nil
1599+
},
1600+
)
1601+
15741602
filterLogsCall = ec.On("FilterLogs", mock.Anything, mock.Anything).Return(func(ctx context.Context, fq ethereum.FilterQuery) (logs []types.Log, err error) {
15751603
if fq.BlockHash != nil {
15761604
return []types.Log{}, nil // succeed when single block requested
@@ -1605,6 +1633,8 @@ func TestTooManyLogResults(t *testing.T) {
16051633
assert.Equal(t, s, logs[i].ContextMap()["newBatchSize"])
16061634
}
16071635
filterLogsCall.Unset()
1636+
batchCallContext.Unset()
1637+
headByHash.Unset()
16081638
})
16091639

16101640
t.Run("Halves size until single block, then reports critical error", func(t *testing.T) {

pkg/report/por/processor/processor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func NewPORProcessor(metrics *registry.Metrics, emitter beholder.ProtoEmitter) *
2222

2323
func GetPORSchema() abi.Arguments {
2424
return registry.GetSchema("tuple(bytes32,uint32,bytes)[]", "", []abi.ArgumentMarshaling{
25-
{Name: "dataId", Type: "bytes32"},
25+
{Name: "dataID", Type: "bytes32"},
2626
{Name: "timestamp", Type: "uint32"},
2727
{Name: "bundle", Type: "bytes"},
2828
})

0 commit comments

Comments
 (0)