diff --git a/pkg/solana/logpoller/loader.go b/pkg/solana/logpoller/loader.go index 000d5f140..ea22a0655 100644 --- a/pkg/solana/logpoller/loader.go +++ b/pkg/solana/logpoller/loader.go @@ -95,7 +95,7 @@ func (c *EncodedLogCollector) BackfillForAddress(ctx context.Context, address st lowestSlotSig solana.Signature ) - for lowestSlotRead > fromSlot { + for lowestSlotRead > fromSlot || lowestSlotRead == 0 { opts := rpc.GetSignaturesForAddressOpts{ Commitment: rpc.CommitmentFinalized, MinContextSlot: &fromSlot, @@ -115,7 +115,7 @@ func (c *EncodedLogCollector) BackfillForAddress(ctx context.Context, address st var newSigsFound bool for _, sig := range sigs { - if sig.Slot < lowestSlotRead { + if sig.Slot < lowestSlotRead || lowestSlotRead == 0 { lowestSlotRead = sig.Slot lowestSlotSig = sig.Signature } diff --git a/pkg/solana/logpoller/loader_test.go b/pkg/solana/logpoller/loader_test.go index ee1d23a72..7c8c5dcfb 100644 --- a/pkg/solana/logpoller/loader_test.go +++ b/pkg/solana/logpoller/loader_test.go @@ -2,7 +2,7 @@ package logpoller_test import ( "context" - "math/rand/v2" + "crypto/rand" "sync" "sync/atomic" "testing" @@ -103,8 +103,7 @@ func TestEncodedLogCollector_BackfillForAddress(t *testing.T) { pubKey := solana.PublicKey{2, 1, 4, 2} slots := []uint64{42, 43, 44} - blockHeights := []uint64{21, 22, 23} - sig := solana.Signature{2, 1, 4, 2} + blockHeights := []uint64{21, 22, 23, 50} client.EXPECT().GetSignaturesForAddressWithOpts(mock.Anything, pubKey, mock.Anything).Return([]*rpc.TransactionSignature{ {Slot: slots[0]}, @@ -113,6 +112,14 @@ func TestEncodedLogCollector_BackfillForAddress(t *testing.T) { }, nil) for idx := range len(slots) { + var ( + sig1 solana.Signature + sig2 solana.Signature + ) + + _, _ = rand.Read(sig1[:]) + _, _ = rand.Read(sig2[:]) + client.EXPECT().GetBlockWithOpts(mock.Anything, slots[idx], mock.Anything).Return(&rpc.GetBlockResult{ Transactions: []rpc.TransactionWithMeta{ { @@ -126,7 +133,7 @@ func TestEncodedLogCollector_BackfillForAddress(t *testing.T) { }, }, }, - Signatures: []solana.Signature{sig, sig}, + Signatures: []solana.Signature{sig1, sig2}, BlockHeight: &blockHeights[idx], }, nil).Twice() } @@ -206,7 +213,9 @@ func (p *testBlockProducer) makeEvent() { p.mu.Lock() defer p.mu.Unlock() - sig := solana.Signature{byte(rand.Int64())} + var sig solana.Signature + + _, _ = rand.Read(sig[:]) p.blockSigs[p.nextSlot] = append(p.blockSigs[p.nextSlot], sig) p.sigs[sig.String()] = true