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

Add LogIndex and TxIndex into logs/event response body #862

Merged
merged 25 commits into from
Nov 8, 2024

Conversation

paologalligit
Copy link
Member

Description

This PR adds logIndex and txIndex fields into logs/event response body.

GH Issue

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

  • Manual test
  • Unit test
  • E2E test

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • New and existing E2E tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have not added any vulnerable dependencies to my code

@paologalligit paologalligit requested a review from a team as a code owner October 11, 2024 08:16
@codecov-commenter
Copy link

codecov-commenter commented Oct 11, 2024

Codecov Report

Attention: Patch coverage is 82.60870% with 16 lines in your changes missing coverage. Please review.

Project coverage is 60.70%. Comparing base (49d9704) to head (a2a74f8).

Files with missing lines Patch % Lines
cmd/thor/sync_logdb.go 0.00% 10 Missing ⚠️
logdb/sequence.go 73.33% 2 Missing and 2 partials ⚠️
logdb/logdb.go 93.10% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #862      +/-   ##
==========================================
+ Coverage   60.62%   60.70%   +0.08%     
==========================================
  Files         215      215              
  Lines       23099    23125      +26     
==========================================
+ Hits        14003    14038      +35     
+ Misses       7947     7935      -12     
- Partials     1149     1152       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

* feat: add thorclient

* refactor: remove roundTripper

* refactor: change null check

* clean: remove commented code

* feat: add account revision and pending tx

* fix: add licence headers and fix linter issue

* refactor: rename package

* refactor: change revision type to string

* refactor: rename GetLogs and GetTransfers to FilterEvents and FilterTransfers

* refactor: change FilterEvents and FilterTransactions request type to EventFilter

* Adding common.EventWrapper to handle channel errors

* tweak

* update rawclient + update account tests

* tidy up names

* update tests

* pr comments

* adding raw tx

* Tidy up method names and calls

* options client

* tweaks

* pr comments

* Update thorclient/common/common.go

Co-authored-by: libotony <[email protected]>

* pr comments

* Adding Subscriptions

* Pr comments

* adjust func orders

* pr comments

* changing subscribe to use the channel close vs multiple channels

* adding go-doc

* no error after unsubscribe

* pr comments

* checking status code is 2xx

* fix: change FilterTransfers argument

---------

Co-authored-by: otherview <[email protected]>
Co-authored-by: libotony <[email protected]>
@paologalligit paologalligit changed the base branch from master to feat/db October 29, 2024 10:37
otherview and others added 2 commits October 30, 2024 11:36
* Show all issues on lint

* fix lint
* fix(docker): using AWS docker repo for trivy

* fix(docker): using AWS docker repo for trivy
thor/params.go Outdated Show resolved Hide resolved
api/events/types.go Outdated Show resolved Hide resolved
logdb/logdb.go Outdated Show resolved Hide resolved
* ehancement: create a cache for block based subscriptions

* minor: change function names for subscriptions

* test: add unit test for message cache

* chore: add license headers

* refactor: fix up error handling

* fix: remove bad test

* fix: PR comments

* fix: PR comments - remove block cache

* refactor(subscriptions): store structs in cache, not bytes

* fix(license): add license header

* chore(subscriptions): revert unit test changes

* enhancement: resolve pr comments to use simplelru

* enhancement: resolve pr comments - use id as key
nullable: true
example: 1
logIndex:
descrption: The index of the log in the receipt's outputs.
Copy link
Member

Choose a reason for hiding this comment

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

Need to highlight it's an overall index among all clauses.

@@ -504,7 +507,7 @@ func (w *Writer) Write(b *block.Block, receipts tx.Receipts) error {

if err := w.exec(
query,
newSequence(blockNum, eventCount),
newSequence(blockNum, uint32(txIndex), eventCount),
Copy link
Member

Choose a reason for hiding this comment

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

eventCount and transferCount needs to be reset for every receipt/tx.

Copy link
Member

Choose a reason for hiding this comment

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

And the logic of insert blockID into ref needs to be updated.

Copy link
Member Author

Choose a reason for hiding this comment

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

eventCount and transferCount needs to be reset for every receipt/tx.

Are we changing the indexes logic? Before the count was not reset to 0 every receipt

Copy link
Member

Choose a reason for hiding this comment

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

I think by adding txIndex we are trying to align with ethereum's filter API, so we need to change the concept of logIndex.

Copy link
Member Author

Choose a reason for hiding this comment

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

blockID insertion logic updated

@darrenvechain
Copy link
Member

darrenvechain commented Nov 6, 2024

@paologalligit possible to trigger CI? You may have to rebase with target branch. I think @libotony had issues on his mainDB branch, not sure how he solved

@libotony
Copy link
Member

libotony commented Nov 7, 2024

@paologalligit possible to trigger CI? You may have to rebase with target branch. I think @libotony had issues on his mainDB branch, not sure how he solved

Here, #868 (comment)

Wired that tests won't run with this PR only, might be caused by the on-pull-request.yaml wasn't updated in the master branch, but after PR #871 was opened, CI was trigger for targeting master then with the same commit hash of this PR, the workflow was also linked here.

@paologalligit paologalligit changed the base branch from feat/db to master November 7, 2024 09:33
@libotony
Copy link
Member

libotony commented Nov 7, 2024

@paologalligit I think the logIndex and txIndex also need to be applied to logs/transfers.

otherview and others added 2 commits November 7, 2024 10:57
* Refactor thor node

* thorchain allows insertion of blocks

* remove thorNode, added testchain

* clean up + comments

* adding license headers

* adding templating tests for thorclient

* Remove test event hacks

* remove types

* removed chain_builder + added logdb to testchain

* pr comments

* Update test/testchain/chain.go

Co-authored-by: libotony <[email protected]>

---------

Co-authored-by: libotony <[email protected]>
* chore(docs): update spec for validator nodes

* chore(docs): update cores

* chore(docs): remove public node stuff
@darrenvechain darrenvechain changed the base branch from master to feat/db November 7, 2024 12:06
@darrenvechain darrenvechain changed the base branch from feat/db to master November 7, 2024 12:07
otherview
otherview previously approved these changes Nov 7, 2024
Copy link
Member

@otherview otherview left a comment

Choose a reason for hiding this comment

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

lgtm !

api/events/events.go Show resolved Hide resolved
otherview
otherview previously approved these changes Nov 7, 2024
@libotony
Copy link
Member

libotony commented Nov 8, 2024

@paologalligit Appended a commit a2a74f8

@libotony libotony changed the base branch from master to feat/db November 8, 2024 10:04
@paologalligit paologalligit merged commit 368e5d2 into feat/db Nov 8, 2024
15 checks passed
@paologalligit paologalligit deleted the feat/tx-log-seq branch November 8, 2024 16:01
libotony added a commit that referenced this pull request Nov 12, 2024
* Thor client (#818)

* feat: add thorclient

* refactor: remove roundTripper

* refactor: change null check

* clean: remove commented code

* feat: add account revision and pending tx

* fix: add licence headers and fix linter issue

* refactor: rename package

* refactor: change revision type to string

* refactor: rename GetLogs and GetTransfers to FilterEvents and FilterTransfers

* refactor: change FilterEvents and FilterTransactions request type to EventFilter

* Adding common.EventWrapper to handle channel errors

* tweak

* update rawclient + update account tests

* tidy up names

* update tests

* pr comments

* adding raw tx

* Tidy up method names and calls

* options client

* tweaks

* pr comments

* Update thorclient/common/common.go

Co-authored-by: libotony <[email protected]>

* pr comments

* Adding Subscriptions

* Pr comments

* adjust func orders

* pr comments

* changing subscribe to use the channel close vs multiple channels

* adding go-doc

* no error after unsubscribe

* pr comments

* checking status code is 2xx

* fix: change FilterTransfers argument

---------

Co-authored-by: otherview <[email protected]>
Co-authored-by: libotony <[email protected]>

* Show all issues on lint (#869)

* Show all issues on lint

* fix lint

* fix(docker): using AWS docker repo for trivy (#872)

* fix(docker): using AWS docker repo for trivy

* fix(docker): using AWS docker repo for trivy

* Darren/feat/add subscription cache (#866)

* ehancement: create a cache for block based subscriptions

* minor: change function names for subscriptions

* test: add unit test for message cache

* chore: add license headers

* refactor: fix up error handling

* fix: remove bad test

* fix: PR comments

* fix: PR comments - remove block cache

* refactor(subscriptions): store structs in cache, not bytes

* fix(license): add license header

* chore(subscriptions): revert unit test changes

* enhancement: resolve pr comments to use simplelru

* enhancement: resolve pr comments - use id as key

* Add additional block tests (#863)

* enhancement(logging): leverage trace level (#873)

* Add testchain package (#844)

* Refactor thor node

* thorchain allows insertion of blocks

* remove thorNode, added testchain

* clean up + comments

* adding license headers

* adding templating tests for thorclient

* Remove test event hacks

* remove types

* removed chain_builder + added logdb to testchain

* pr comments

* Update test/testchain/chain.go

Co-authored-by: libotony <[email protected]>

---------

Co-authored-by: libotony <[email protected]>

* chore(docs): update spec for validator nodes (#875)

* chore(docs): update spec for validator nodes

* chore(docs): update cores

* chore(docs): remove public node stuff

* Darren/logdb remove leading zeros (#865)

* feat: add new txIndex column to event meta response

* test: add convert event test

* feat: make txLog and txIndex as optional return params

* chore: update swagger with new event optional data

* feat: save logIndex in sequence

* feat: tweaked bits in sequence

* refactor: rename optional log meta field

* refactor: comments, yaml and txIndex counts

* rebase to master

* fix: remove stale struct

* add txIndex to returned logdb query

* reset to 0 eventCount and transferCount each receipt and write blockId only once

* fix lint

* rephrase logIndex description in yaml file

* refactor: use filter.Option instead of eventFilter.Option

* move includeIndexes to api

---------

Co-authored-by: otherview <[email protected]>
Co-authored-by: libotony <[email protected]>
Co-authored-by: Darren Kelly <[email protected]>
Co-authored-by: Makis Christou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants