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

feat(indexer): add to modules and implement proto fields (backport #22544) #22676

Merged
merged 8 commits into from
Nov 28, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Nov 28, 2024

Description

Implement necessary methods and named keys in:

  • x/staking
  • x/mint
  • x/epochs
  • x/distribution
  • x/consensus
  • x/circuit
  • x/bank
  • x/auth

Changed some default key codecs to be NameableKeyCodec (TimeKey, LengthPrefixedBytesKey, LengthPrefixedAddressKey)

Improve error messages in schema
Fixed AsyncListener in schema to avoid hanging on unprocessed packets

In baseapp, check for app.streamingManager.StopNodeOnErr so the indexer can crash the node if needed. Also the call to the store's Commit() was moved to after the streaming listener, so in case that something fails in the indexer we can stop the node before it commits. Otherwise when restarting the indexer would have skipped a block.

In codec:

  • collValue now implements SchemaCodec, which goes through the fields and returns the correct types for each + does the conversion if needed.
  • collInterfaceValue also implements SchemaCodec but always use JSON, as there's no way to know the necessary fields beforehand.

The following is a bit hacky:
In collections, for ModuleCodec, we use the value decoder to obtain an empty message (so this assumes that value decoders will return an empty struct and not a nil when passing an empty byte slice). This is used to optionally get a proto message which is then used to register any existing enums in the used messages.
We also adapt the full enum name to not use periods, otherwise it will fail somewhere else (Name: strings.ReplaceAll(string(enum.FullName()), ".", "_"), // make it compatible with schema).
The goal of this is so then the indexer can register the enum in the DB, which need to be registered before starting to write data.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:

  • confirmed ! in the type prefix if API or client breaking change

  • targeted the correct branch (see PR Targeting)

  • provided a link to the relevant issue or specification

  • reviewed "Files changed" and left comments if necessary

  • included the necessary unit and integration tests

  • added a changelog entry to CHANGELOG.md

  • updated the relevant documentation or specification, including comments for documenting Go code

  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced error handling for streaming listeners and application state management.
    • Introduced new codec functionalities for improved protobuf message handling.
    • Added ModuleCodec methods in multiple modules to support schema management and indexing.
    • New collection types and value codecs introduced in the collections module.
    • Implemented a RouterService for structured message handling in integration tests.
  • Bug Fixes

    • Improved error messages for validation checks in various modules.
  • Dependencies

    • Updated Go version to 1.23.3 across multiple modules.
    • Various dependencies updated to ensure compatibility and functionality.
  • Chores

    • Cleaned up and organized module paths and replace directives in Go module files.

This is an automatic backport of pull request #22544 done by [Mergify](https://mergify.com).

(cherry picked from commit bd76b47)

# Conflicts:
#	collections/CHANGELOG.md
#	collections/go.mod
#	collections/go.sum
#	collections/indexing.go
#	collections/protocodec/collections.go
#	collections/protocodec/collections_test.go
#	indexer/postgres/create_table.go
#	indexer/postgres/enum.go
#	indexer/postgres/listener.go
#	indexer/postgres/tests/testdata/init_schema.txt
#	indexer/postgres/tests/testdata/init_schema_no_retain_delete.txt
#	math/legacy_dec_test.go
#	schema/appdata/async.go
#	schema/field.go
#	schema/field_test.go
#	schema/state_object.go
#	schema/state_object_test.go
#	server/v2/cometbft/go.mod
#	server/v2/cometbft/go.sum
#	simapp/go.mod
#	simapp/go.sum
#	store/cachekv/branch_bench_test.go
#	tests/integration/v2/auth/app_test.go
#	tests/integration/v2/services.go
#	x/bank/keeper/view.go
#	x/circuit/go.mod
#	x/circuit/go.sum
#	x/consensus/go.mod
#	x/consensus/go.sum
#	x/distribution/go.mod
#	x/epochs/go.mod
#	x/epochs/go.sum
#	x/evidence/go.mod
#	x/evidence/go.sum
#	x/mint/go.mod
#	x/mint/go.sum
#	x/nft/go.mod
#	x/nft/go.sum
#	x/params/go.mod
#	x/params/go.sum
#	x/protocolpool/go.mod
#	x/protocolpool/go.sum
#	x/slashing/go.mod
#	x/slashing/go.sum
#	x/staking/go.mod
#	x/upgrade/go.mod
#	x/upgrade/go.sum
@mergify mergify bot requested a review from a team as a code owner November 28, 2024 09:54
Copy link
Contributor Author

mergify bot commented Nov 28, 2024

Cherry-pick of bd76b47 has failed:

On branch mergify/bp/release/v0.52.x/pr-22544
Your branch is up to date with 'origin/release/v0.52.x'.

You are currently cherry-picking commit bd76b47e1.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   baseapp/abci.go
	modified:   client/v2/go.mod
	modified:   codec/collections.go
	modified:   go.mod
	modified:   simapp/v2/go.mod
	modified:   tests/go.mod
	modified:   types/collections.go
	modified:   x/accounts/defaults/base/go.mod
	modified:   x/accounts/defaults/lockup/go.mod
	modified:   x/accounts/defaults/multisig/go.mod
	modified:   x/accounts/go.mod
	modified:   x/auth/module.go
	modified:   x/authz/go.mod
	modified:   x/bank/go.mod
	modified:   x/bank/module.go
	modified:   x/circuit/module.go
	modified:   x/consensus/keeper/keeper.go
	modified:   x/consensus/module.go
	modified:   x/distribution/keeper/keeper.go
	modified:   x/distribution/module.go
	modified:   x/epochs/module.go
	modified:   x/feegrant/go.mod
	modified:   x/gov/go.mod
	modified:   x/group/go.mod
	modified:   x/mint/module.go
	modified:   x/staking/keeper/keeper.go
	modified:   x/staking/module.go

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	deleted by us:   collections/CHANGELOG.md
	deleted by us:   collections/go.mod
	deleted by us:   collections/go.sum
	deleted by us:   collections/indexing.go
	deleted by us:   collections/protocodec/collections.go
	deleted by us:   collections/protocodec/collections_test.go
	deleted by us:   indexer/postgres/create_table.go
	deleted by us:   indexer/postgres/enum.go
	deleted by us:   indexer/postgres/listener.go
	deleted by us:   indexer/postgres/tests/testdata/init_schema.txt
	deleted by us:   indexer/postgres/tests/testdata/init_schema_no_retain_delete.txt
	deleted by us:   math/legacy_dec_test.go
	deleted by us:   schema/appdata/async.go
	deleted by us:   schema/field.go
	deleted by us:   schema/field_test.go
	deleted by us:   schema/state_object.go
	deleted by us:   schema/state_object_test.go
	both modified:   server/v2/cometbft/go.mod
	both modified:   server/v2/cometbft/go.sum
	both modified:   simapp/go.mod
	both modified:   simapp/go.sum
	deleted by us:   store/cachekv/branch_bench_test.go
	deleted by us:   tests/integration/v2/auth/app_test.go
	both modified:   tests/integration/v2/services.go
	both modified:   x/bank/keeper/view.go
	both modified:   x/circuit/go.mod
	both modified:   x/circuit/go.sum
	both modified:   x/consensus/go.mod
	both modified:   x/consensus/go.sum
	both modified:   x/distribution/go.mod
	both modified:   x/epochs/go.mod
	both modified:   x/epochs/go.sum
	both modified:   x/evidence/go.mod
	both modified:   x/evidence/go.sum
	both modified:   x/mint/go.mod
	both modified:   x/mint/go.sum
	both modified:   x/nft/go.mod
	both modified:   x/nft/go.sum
	both modified:   x/params/go.mod
	both modified:   x/params/go.sum
	both modified:   x/protocolpool/go.mod
	both modified:   x/protocolpool/go.sum
	both modified:   x/slashing/go.mod
	both modified:   x/slashing/go.sum
	both modified:   x/staking/go.mod
	both modified:   x/upgrade/go.mod
	both modified:   x/upgrade/go.sum

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify mergify bot added the conflicts label Nov 28, 2024
Copy link
Contributor

coderabbitai bot commented Nov 28, 2024

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment on lines 903 to +911
defer func() {
// call the streaming service hooks with the FinalizeBlock messages
for _, streamingListener := range app.streamingManager.ABCIListeners {
if err := streamingListener.ListenFinalizeBlock(app.finalizeBlockState.Context(), *req, *res); err != nil {
if streamErr := streamingListener.ListenFinalizeBlock(app.finalizeBlockState.Context(), *req, *res); streamErr != nil {
app.logger.Error("ListenFinalizeBlock listening hook failed", "height", req.Height, "err", err)
if app.streamingManager.StopNodeOnErr {
// if StopNodeOnErr is set, we should return the streamErr in order to stop the node
err = streamErr
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Change potentially affects state.

Call sequence:

(*github.com/cosmos/cosmos-sdk/baseapp.BaseApp).FinalizeBlock (baseapp/abci.go:902)

@facundomedica
Copy link
Member

DNM, will fix replaces in main

schema/appdata/async.go Fixed Show fixed Hide fixed
@julienrbrt
Copy link
Member

julienrbrt commented Nov 28, 2024

#22677 should be cherry-picked in here too before the conflict resolution

Copy link
Contributor

@facundomedica your pull request is missing a changelog!

tests/integration/v2/auth/app_test.go Outdated Show resolved Hide resolved
store/cachekv/branch_bench_test.go Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the C:Store label Nov 28, 2024
@julienrbrt julienrbrt merged commit 61691b5 into release/v0.52.x Nov 28, 2024
87 of 90 checks passed
@julienrbrt julienrbrt deleted the mergify/bp/release/v0.52.x/pr-22544 branch November 28, 2024 13:12
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.

2 participants