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
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ linters-settings:
require-explanation: true
issues:
max-same-issues: 0
# Trimmed copy of the klauspost/compress zstd encoder. Kept as upstream wrote
# it so it stays diffable against the release it came from.
exclude-dirs:
- llo/internal/zstdenc
exclude-rules:
- path: test
text: "^G404:"
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/smartcontractkit/chainlink-data-streams
go 1.27.1

require (
github.com/cespare/xxhash/v2 v2.3.0
github.com/esote/minmaxheap v1.0.0
github.com/ethereum/go-ethereum v1.17.4
github.com/expr-lang/expr v1.17.8
Expand All @@ -11,12 +12,13 @@ require (
github.com/hashicorp/go-plugin v1.8.0
github.com/jmoiron/sqlx v1.4.0
github.com/jpillora/backoff v1.0.0
github.com/klauspost/compress v1.18.6
github.com/klauspost/compress v1.20.3
github.com/leanovate/gopter v0.2.11
github.com/lib/pq v1.12.3
github.com/pelletier/go-toml/v2 v2.3.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.23.2
github.com/prometheus/client_model v0.6.2
github.com/shopspring/decimal v1.4.0
github.com/smartcontractkit/chainlink-common v0.11.2-0.20260918171610-2b348aaadc86
github.com/smartcontractkit/chainlink-common/keystore v1.1.0
Expand Down Expand Up @@ -45,7 +47,6 @@ require (
github.com/buger/jsonparser v1.2.0 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudevents/sdk-go/binding/format/protobuf/v2 v2.16.2 // indirect
github.com/cloudevents/sdk-go/v2 v2.16.2 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
Expand Down Expand Up @@ -132,7 +133,6 @@ require (
github.com/pion/logging v0.2.4 // indirect
github.com/pion/stun/v3 v3.1.5 // indirect
github.com/pion/transport/v4 v4.0.2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.67.5 // indirect
github.com/prometheus/procfs v0.20.1 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,8 @@ github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/X
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.18.6 h1:2jupLlAwFm95+YDR+NwD2MEfFO9d4z4Prjl1XXDjuao=
github.com/klauspost/compress v1.18.6/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
github.com/klauspost/compress v1.20.3 h1:zWNoFqq/lSuYQRim3dUXlXeA0IqwuZGicdG5ZTfY5j4=
github.com/klauspost/compress v1.20.3/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
Expand Down
163 changes: 0 additions & 163 deletions llo/dev/v31/blobcompress.go

This file was deleted.

4 changes: 3 additions & 1 deletion llo/dev/v31/blobmemo.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const maxMemoizedPayloads = ocrtypes.MaxOracles * maxObservationBlobHandles
// while StateTransition still runs, each round call discards the other's
// entries and the superseded handle misses on every get and drops every put.
// That degrades to running without the memo and bound in the observation
// decompression budget in decodeObservation, not the memo.
// decompression budget in fetchBlobsAndDecodeObservation, not the memo.
type blobPayloadCache struct {
mu sync.Mutex
seqNr uint64
Expand All @@ -64,6 +64,8 @@ type blobPayloadCache struct {
type blobPayloadEntry struct {
values protocol.StreamValues
size int
// cycleStartSeqNr is the blob's own, see LLOBlobPayloadProto.
cycleStartSeqNr uint64
}

func newBlobPayloadCache() *blobPayloadCache {
Expand Down
26 changes: 13 additions & 13 deletions llo/dev/v31/blobmemo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import (
// referencing the resulting handle.
func blobObservation(t *testing.T, bc *llotest.BlobBroadcastFetcher, sv protocol.StreamValues) ocrtypes.Observation {
t.Helper()
payload, err := marshalStreamValues(sv)
payload, err := marshalStreamValues(sv, 1)
require.NoError(t, err)
handle, err := bc.BroadcastBlob(tests.Context(t), payload, ocr3_1types.BlobExpirationHintSequenceNumber{SeqNr: 100})
require.NoError(t, err)
handleBytes, err := handle.MarshalBinary()
require.NoError(t, err)
enc, err := encodeObservation(Observation{UnixTimestampNanoseconds: 1}, [][]byte{handleBytes})
enc, err := encodeObservation(Observation{ObservationTimestampNanoseconds: 1}, [][]byte{handleBytes})
require.NoError(t, err)
return enc
}
Expand All @@ -49,11 +49,11 @@ func Test_BlobPayloadCache_SkipsSecondFetch(t *testing.T) {

cache := newBlobPayloadCache()

first, err := decodeObservation(ctx, enc, bc, cache.round(7))
first, err := fetchBlobsAndDecodeObservation(ctx, enc, bc, cache.round(7))
require.NoError(t, err)
require.Equal(t, 1, bc.Fetches())

second, err := decodeObservation(ctx, enc, bc, cache.round(7))
second, err := fetchBlobsAndDecodeObservation(ctx, enc, bc, cache.round(7))
require.NoError(t, err)
require.Equal(t, 1, bc.Fetches(), "the second decode of the round must be served from the memo")

Expand All @@ -65,7 +65,7 @@ func Test_BlobPayloadCache_SkipsSecondFetch(t *testing.T) {
}

// Without a memo the fetch happens again, which is what the memo replaces.
_, err = decodeObservation(ctx, enc, bc, nil)
_, err = fetchBlobsAndDecodeObservation(ctx, enc, bc, nil)
require.NoError(t, err)
require.Equal(t, 2, bc.Fetches())
}
Expand All @@ -79,11 +79,11 @@ func Test_BlobPayloadCache_ScopedToSeqNr(t *testing.T) {
enc := blobObservation(t, bc, testStreamValues(10))

cache := newBlobPayloadCache()
_, err := decodeObservation(ctx, enc, bc, cache.round(7))
_, err := fetchBlobsAndDecodeObservation(ctx, enc, bc, cache.round(7))
require.NoError(t, err)
require.Equal(t, 1, bc.Fetches())

_, err = decodeObservation(ctx, enc, bc, cache.round(8))
_, err = fetchBlobsAndDecodeObservation(ctx, enc, bc, cache.round(8))
require.NoError(t, err)
require.Equal(t, 2, bc.Fetches(), "a later round must not be served the previous round's payload")

Expand All @@ -108,11 +108,11 @@ func Test_BlobPayloadCache_FailuresNotMemoized(t *testing.T) {

// No fetcher: a reference that could not be resolved must not be cached as
// an absence, so a later decode in the same round still fetches.
_, err := decodeObservation(ctx, enc, nil, cache.round(7))
_, err := fetchBlobsAndDecodeObservation(ctx, enc, nil, cache.round(7))
var bfErr *blobFetchError
require.ErrorAs(t, err, &bfErr)

_, err = decodeObservation(ctx, enc, bc, cache.round(7))
_, err = fetchBlobsAndDecodeObservation(ctx, enc, bc, cache.round(7))
require.NoError(t, err)
require.Equal(t, 1, bc.Fetches())
}
Expand All @@ -124,20 +124,20 @@ func Test_BlobPayloadCache_BudgetChargedOnHit(t *testing.T) {
ctx := tests.Context(t)
bc := newFakeBroadcaster()
sv := testStreamValues(20)
payload, err := marshalStreamValues(sv)
payload, err := marshalStreamValues(sv, 1)
require.NoError(t, err)
handle, err := bc.BroadcastBlob(ctx, payload, ocr3_1types.BlobExpirationHintSequenceNumber{SeqNr: 100})
require.NoError(t, err)
handleBytes, err := handle.MarshalBinary()
require.NoError(t, err)

// The same handle four times, so the budget is charged four times.
enc, err := encodeObservation(Observation{UnixTimestampNanoseconds: 1}, [][]byte{handleBytes, handleBytes, handleBytes, handleBytes})
enc, err := encodeObservation(Observation{ObservationTimestampNanoseconds: 1}, [][]byte{handleBytes, handleBytes, handleBytes, handleBytes})
require.NoError(t, err)

withMemo, memoErr := decodeObservation(ctx, enc, bc, newBlobPayloadCache().round(7))
withMemo, memoErr := fetchBlobsAndDecodeObservation(ctx, enc, bc, newBlobPayloadCache().round(7))
require.Equal(t, 1, bc.Fetches(), "repeats within one observation are memo hits")
withoutMemo, plainErr := decodeObservation(ctx, enc, bc, nil)
withoutMemo, plainErr := fetchBlobsAndDecodeObservation(ctx, enc, bc, nil)

// Whatever the budget verdict is, it must be the same with and without the
// memo; the payloads here are small, so both are expected to succeed.
Expand Down
Loading
Loading