Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NONEVM-916] logpoller log processing & decoding #1002

Open
wants to merge 44 commits into
base: develop
Choose a base branch
from

Conversation

reductionista
Copy link
Contributor

@reductionista reductionista commented Jan 7, 2025

JIRA: LINK-916

This adds the implementation of lp.Process(), and also initializes LogPoller with a client that gets passed along to initialize the EncodedLogCollector.

In order, the main 3 tasks performed by lp.Process are:

  1. Filter out any logs not matching registered filters
  2. Decode each matching log, and extract the subkeys
  3. Save matching logs along with their subkey values to the db

@reductionista reductionista force-pushed the NONEVM-916-logpoller-process-decode branch from c208014 to e49250f Compare January 7, 2025 04:28
@reductionista reductionista force-pushed the NONEVM-916-logpoller-process-decode branch from e49250f to 580d1af Compare January 8, 2025 03:06
Also: keep retrying if LogCollector fails to start

const DiscriminatorLength = 8

func Discriminator(namespace, name string) [DiscriminatorLength]byte {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilija42 has a PR that also adds a discriminator: here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that PR will go in after this one... this will use his discriminator once that gets merged.

EasterTheBunny
EasterTheBunny previously approved these changes Jan 16, 2025
fl.loadedFilters.Store(true)

return nil
}

func (fl *filters) DecodeSubKey(ctx context.Context, raw []byte, ID int64, subKeyPath []string) (any, error) {
filter, ok := fl.filtersByID[ID]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we might want to mark this method as unsafe to signal that it should only be called from locked context of matching filters

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, I should add that to this as well as IncrementSeqNums

// this will be called on every new event that happens on the blockchain, so it's important it returns immediately if it
// doesn't match any registered filters.
func (fl *filters) MatchingFiltersForEncodedEvent(event ProgramEvent) iter.Seq[Filter] {
if _, ok := fl.knownPrograms[event.Program]; !ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concurrent read & write to the map leads to panic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

// Value implements valuer for database/sql.
func (s EventSignature) Value() (driver.Value, error) {
return s[:], nil
func NewIndexedValue(typedVal any) (iVal IndexedValue, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! I thought we'd have to build something super complex to support < > operators.

Also: add warnings to methods which are not intended to be called concurrently
@cl-sonarqube-production
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 75%)

See analysis details on SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants