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

refactor/test(ingest): more common ingester abstractions for pushing pool data #8475

Merged
merged 5 commits into from
Jul 4, 2024

Conversation

p0mvn
Copy link
Member

@p0mvn p0mvn commented Jul 3, 2024

Closes: #XXX

What is the purpose of the change

Separates the remaining ingest abstractions to be used and shared between indexer and sqs.

Namely,

  • BlockProcessStrategyManager - determines whether to push all blocks or only changed
  • PoolExtracter - extracts pools - either all or only changed

Moved sqs_pool_tracker.go into memory_pool_tracker.go

See #8470 for usage of the abstractions

Drive By

Renamed "extracter" to "extractor" due to linter

@p0mvn p0mvn added V:state/compatible/backport State machine compatible PR, should be backported A:no-changelog A:backport/v25.x backport patches to v25.x branch labels Jul 3, 2024
@github-actions github-actions bot added the C:app-wiring Changes to the app folder label Jul 3, 2024
@p0mvn p0mvn marked this pull request as ready for review July 3, 2024 23:01
Copy link
Contributor

coderabbitai bot commented Jul 3, 2024

Walkthrough

The updates encompass improvements to the pool-extraction and tracking mechanism within the application. Key changes include the introduction of new interfaces and structures for pool management, renaming several variables and functions for clarity, and transitioning to the new memory-based pool tracker. Testing functions were also modified to reflect these updates.

Changes

File(s) Change Summary
app/app.go Added import for pooltracker, renamed SQS-related variables for consistency.
ingest/common/domain/block_process_strategy_manager.go Introduced BlockProcessStrategyManager interface for block processing strategy.
ingest/common/domain/keepers.go, ingest/sqs/ingester.go, ingest/sqs/pools/transformer/pool_transformer.go, ingest/sqs/pools/transformer/pool_transformer_test.go, ingest/sqs/sqs_config.go Renamed PoolExtracterKeepers to PoolExtractorKeepers.
ingest/common/domain/mocks/pools_extracter_mock.go Added mock implementation for PoolExtractor interface for testing.
ingest/common/domain/pools.go Introduced PoolExtractor interface for pool extraction functionality.
ingest/common/domain/process_strategy.go Introduced BlockProcessor interface to handle block processing.
ingest/common/poolextractor/pool_extractor_test.go Added test suite for verifying pool extraction functionality.
ingest/common/poolextractor/pool_extractor.go Introduced poolExtractor struct and methods for pool extraction.
ingest/common/pooltracker/memory_pool_tracker.go, ingest/common/pooltracker/memory_pool_tracker_test.go, ingest/common/writelistener/cfmm_write_listener_test.go, ingest/common/writelistener/concentrated_write_listener_test.go, ingest/common/writelistener/cosmwasmpool_write_listener_test.go, ingest/sqs/service/sqs_streaming_service_test.go Renamed service.NewPoolTracker to pooltracker.NewMemory.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (7)
ingest/common/domain/pools.go (1)

1-1: Add method documentation for ExtractAll and ExtractChanged.

The comments for the methods in the PoolExtractor interface should be more descriptive to clarify their purpose and usage.

-	// ExtractAll extracts all the pools available within the height associated
-	// with the context.
+	// ExtractAll extracts all the pools available within the block height
+	// associated with the context. This method is typically used for initial
+	// data ingestion or full data synchronization.

-	// ExtractChanged extracts the pools that were changed in the block height associated
-	// with the context.
+	// ExtractChanged extracts the pools that were changed in the block height
+	// associated with the context. This method is typically used for incremental
+	// data updates.
ingest/common/domain/mocks/pools_extracter_mock.go (4)

1-1: Fix package import formatting.

The import statements should be grouped and ordered for better readability.

import (
	"github.com/cosmos/cosmos-sdk/types"

	commondomain "github.com/osmosis-labs/osmosis/v25/ingest/common/domain"
)

9-9: Add comments for struct fields.

The fields in the PoolsExtractorMock struct should have comments explaining their purpose.

type PoolsExtractorMock struct {
	// AllBlockDataError is the error to return when ExtractAll is called.
	AllBlockDataError error
	// ChangedBlockDataError is the error to return when ExtractChanged is called.
	ChangedBlockDataError error
	// IsProcessAllBlockDataCalled is a flag indicating if ExtractAll was called.
	IsProcessAllBlockDataCalled bool
	// IsProcessAllChangedDataCalled is a flag indicating if ExtractChanged was called.
	IsProcessAllChangedDataCalled bool
	// ProcessAllBlockDataPanicMsg is the message to panic with when ExtractAll is called.
	ProcessAllBlockDataPanicMsg string
	// BlockPools is the data to return when ExtractAll or ExtractChanged is called.
	BlockPools commondomain.BlockPools
}

26-26: Add method documentation for ExtractAll.

The ExtractAll method should have a comment explaining its purpose and behavior.

// ExtractAll implements commondomain.PoolExtractor.
// It returns the BlockPools and any error set in the mock.

36-36: Add method documentation for ExtractChanged.

The ExtractChanged method should have a comment explaining its purpose and behavior.

// ExtractChanged implements commondomain.PoolExtractor.
// It returns the BlockPools and any error set in the mock.
ingest/common/domain/block_process_strategy_manager.go (1)

1-1: Add method documentation for BlockProcessStrategyManager.

The interface methods should have comments explaining their purpose and behavior.

type BlockProcessStrategyManager interface {
	// ShouldPushAllData returns true if all data should be pushed.
	ShouldPushAllData() bool

	// MarkInitialDataIngested marks the initial data as ingested.
	// After calling this function, ShouldPushAllData should return false.
	MarkInitialDataIngested()

	// MarkErrorObserved marks that an error has been observed.
	// After calling this function, ShouldPushAllData should return true.
	MarkErrorObserved()
}
ingest/common/domain/block_process_strategy_manager_test.go (1)

20-20: Fix typo in the comment.

There is a typo in the comment. "Invariant" should be "invariant".

// Validates the invariant that the block process strategy manager.

Copy link
Contributor

@cryptomatictrader cryptomatictrader left a comment

Choose a reason for hiding this comment

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

Nice work! Thank you!

@cryptomatictrader cryptomatictrader merged commit dcef8c7 into main Jul 4, 2024
1 check passed
@cryptomatictrader cryptomatictrader deleted the roman/more-ingest-abstr branch July 4, 2024 00:32
mergify bot pushed a commit that referenced this pull request Jul 4, 2024
…pool data (#8475)

* refactor/test: more common ingester abstractions

* lint

* remove sqs pool tracker

* renames

* lint

(cherry picked from commit dcef8c7)

# Conflicts:
#	ingest/sqs/service/sqs_streaming_service_test.go
p0mvn added a commit that referenced this pull request Jul 4, 2024
p0mvn added a commit that referenced this pull request Jul 4, 2024
…pool data (backport #8475) (#8476)

Co-authored-by: Roman <roman@osmosis.team>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:backport/v25.x backport patches to v25.x branch A:no-changelog C:app-wiring Changes to the app folder V:state/compatible/backport State machine compatible PR, should be backported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants