-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NONEVM-916] logpoller log processing & decoding (#1002)
* Add client & collector to LogPoller struct Also: - Add GetBlocksWithOpts to Reader - Update loader.RPClient to be consistent with client.Reader interface * Re-generate RPClient & ReaderWriter mocks * Update loader tests for interface * Add ILogpoller interface and call NewLogPoller() from NewChain() Note: this will hopefully be renamed to LogPoller later, once we find a better name for the struct. (logPoller, for consistency with evm?) and the PR's this depends on have been merged, to avoid merge conflicts * fix orm_test.go * Fix lints in log_poller.go & types.go * Fix lints in log_poller.go * Add BlockTime & Program to Event data passed to Process() * WIP * Use EventTypeProvider interface to represent a codec function for retrieving event types from idl * remove unimplemented test * Regenerate mock_orm.go * Fix lints * Add IndexedValue type for converting indexable types to be stored in db * Fill in log.ExpiresAt * Add sequence # tracking, fix floating point encoding, add tests for NewIndexedValue * Fix tests * Remove mock_orm.go * Use UTC time, and fix lints * Add tests - WIP * Refactor to use new codec api, based on review * Add SeqNum test and fix other tests Decoder had to be moved from Filter into a separate filters map, otherwise it caused a lot of issues with assert.Equal for comparing filters. * Don't set ExpireAt unless Retention is set * Move decoder creation before InsertFilter * Remove unused functions in anchor.go, add validation to TestProess test * Fix lints * Remove lp.typeProvider, generate EventIdl for test event * Remove unused Prefix field from ProgramEvent * Fix decoding issues * Add ExtractField function, and fix DecodeSubkeyValues * MatchingFilters -> matchingFilters, and fix rest of expectedLog fields in TestProcess * Fix lint errors, rename err2 & err3 * Fix overflows, lints, use default map vals, & add early return to Process * Remove utils package, add 12-character assertion to Discriminator() This could only fail if someone updates to a new version of encoding/base64 which is buggy or breaks backward compatibility with the current version. Using panic instead of returning an error, since this can only happen during development and would need to be addressed immediately. * Remove TODO, uncomment internal loaders * Remove ILogPoller interface, add LogPoller interface to chain.go Also: add GetBlockWithOpts to MultiClient * Start EncodedLogCollector as soon as filters are loaded Also: - Double check that filters are loaded at beginning of Process() - Add missing return from lp.loadFilters * Add comment explaining < 12 validation * Address 2 more PR comments, and remove accidentally added file * Use ch.multiClient instead of lazy-loader * revert changes to chain.go * logpoller.LogPoller -> logpoller.Service Also: keep retrying if LogCollector fails to start * Make MatchFiltersForEncodedEvent thread safe Also: add warnings to methods which are not intended to be called concurrently --------- Co-authored-by: ilija42 <[email protected]>
- Loading branch information
1 parent
90cd5f2
commit b4f7b8c
Showing
26 changed files
with
1,289 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package logpoller | ||
|
||
import ( | ||
"crypto/sha256" | ||
"fmt" | ||
) | ||
|
||
const DiscriminatorLength = 8 | ||
|
||
func Discriminator(namespace, name string) [DiscriminatorLength]byte { | ||
h := sha256.New() | ||
h.Write([]byte(fmt.Sprintf("%s:%s", namespace, name))) | ||
return [DiscriminatorLength]byte(h.Sum(nil)[:DiscriminatorLength]) | ||
} |
Oops, something went wrong.