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

chore(sims): Complete sims integration for app v2 #23478

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

alpe
Copy link
Contributor

@alpe alpe commented Jan 22, 2025

Description

Closes: #23265

  • Remove genesis sims targets . Background: they are not going to work without the private account keys for signing
  • Remove streaming sims targets. Background: there are 2 models of streaming support in the SDK which integrate on the v2/cometbft level. Sims are one layer above on the appmanager. While I added support to the v2 sims runner, I don't see much value in providing a setup for the listener side already. There are unit tests in place for the streaming logic.
  • Address todos and minor cleanup
  • Changelogs

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

Summary by CodeRabbit

  • Simulation Improvements

    • Added support for memDB in simulations
    • Introduced new entry points for simulations: TransactionFuzzer and DeliverSims
  • Code Cleanup

    • Removed commented-out simulation test targets from build scripts
    • Simplified event handling in block finalization process
  • Streaming Enhancements

    • Updated streaming functionality with improved event processing
    • Added new methods for managing block changes and listener interactions
  • Dependency Updates

    • Updated module requirements to include cosmossdk.io/schema as a direct dependency

Copy link
Contributor

coderabbitai bot commented Jan 22, 2025

📝 Walkthrough

Walkthrough

This pull request involves the removal of commented-out simulation test targets and associated documentation in the scripts/build/simulations.mk file. It also updates changelogs across multiple packages to reflect the introduction of new simulation-related features such as TransactionFuzzer and DeliverSims. Additionally, modifications in event handling and streaming capabilities are introduced in the server/v2/cometbft package, enhancing the simulation framework's functionality and organization.

Changes

File Change Summary
scripts/build/simulations.mk Removed commented-out simulation test targets and associated documentation
server/v2/appmanager/CHANGELOG.md Added changelog entry for TransactionFuzzer as a simulation entry point
server/v2/cometbft/abci.go Simplified event handling by removing events slice construction
server/v2/cometbft/streaming.go Introduced new methods for streaming block changes and improved error handling
server/v2/stf/CHANGELOG.md Added changelog entry for DeliverSims simulation interface
simapp/v2/sim_runner.go Enhanced simulation runner with new types, streaming support, and improved parameter handling
store/CHANGELOG.md Added entry for memDB simulation support
simapp/v2/go.mod Updated dependency for cosmossdk.io/schema to direct requirement

Assessment against linked issues

Objective Addressed Explanation
Support CLI params
Cleanup simsx package Partial progress, more work might be needed
Address/remove todos Removed commented-out code
Support previous simulation scenarios Some targets removed, unclear full coverage
Add changelog entries Changelogs updated for multiple packages

Possibly related PRs

  • feat(sims): Integration with app v2 #23013: The main PR involves the removal of commented-out code related to simulation tests in scripts/build/simulations.mk, while this retrieved PR introduces the TransactionFuzzer interface for processing state transitions, which is relevant to simulation tests.
  • test: Add more sims test scenarios #23278: The main PR's changes to simulation test commands in scripts/build/simulations.mk align with the additional simulation test scenarios introduced in this retrieved PR, which also modifies the testing framework.
  • test: add more sims tests #23421: The main PR's updates to simulation test commands in scripts/build/simulations.mk are related to the additional simulation tests proposed in this retrieved PR, which aims to enhance the testing framework.

Suggested labels

C:Simulations, backport/v0.52.x

Suggested reviewers

  • julienrbrt
  • tac0turtle
  • aljo242
  • kocubinski

📜 Recent review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c5dc493 and d452dc2.

📒 Files selected for processing (5)
  • server/v2/appmanager/CHANGELOG.md (1 hunks)
  • server/v2/stf/CHANGELOG.md (1 hunks)
  • simapp/v2/sim_runner.go (8 hunks)
  • store/CHANGELOG.md (1 hunks)
  • store/v2/CHANGELOG.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • store/CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • server/v2/stf/CHANGELOG.md
  • server/v2/appmanager/CHANGELOG.md
🧰 Additional context used
📓 Path-based instructions (2)
store/v2/CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

simapp/v2/sim_runner.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: tests (00)
  • GitHub Check: test-system-v2
  • GitHub Check: Analyze
  • GitHub Check: golangci-lint
  • GitHub Check: Summary
🔇 Additional comments (6)
store/v2/CHANGELOG.md (1)

28-32: LGTM! The changelog entry follows the Keep a Changelog format.

The entry is properly placed under the "Improvements" section and includes the correct PR reference format.

simapp/v2/sim_runner.go (5)

124-125: LGTM! The streaming fields are properly added to TestInstance.

The addition of StreamManager and StreamHook fields enables streaming support in the simulation framework.


292-297: LGTM! Custom factory parameters are properly handled.

The code correctly reads and unmarshals custom factory parameters from the specified file.


456-459: Improved validator selection for block proposer.

The change from selecting the first validator to randomly selecting from the top 10 validators improves the simulation's realism.


524-543: Verify streaming implementation.

The streaming implementation looks correct, but we should verify the handling of raw transactions.

#!/bin/bash
# Description: Verify the implementation of StreamOut and its usage of rawTxs
# Look for other usages of StreamOut to understand the expected behavior

rg -U "func StreamOut.*?\{.*?\}" -A 50 server/v2/cometbft/streaming.go

551-564: LGTM! Proper handling of legacy proposal messages.

The code correctly identifies and logs when legacy proposal messages are encountered, maintaining backward compatibility while encouraging migration to the new system.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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>, 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@github-actions github-actions bot added C:server/v2 Issues related to server/v2 C:server/v2 cometbft labels Jan 22, 2025
@alpe alpe force-pushed the alex/simsv2_stream branch from c813deb to be40c91 Compare January 23, 2025 08:11
@alpe alpe changed the title WIP: Complete 23265 chore(sims): Complete sims integration for app v2 Jan 23, 2025
@alpe alpe marked this pull request as ready for review January 23, 2025 08:21
@alpe alpe requested review from julienrbrt, tac0turtle and a team as code owners January 23, 2025 08:21
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: 2

🧹 Nitpick comments (2)
server/v2/appmanager/CHANGELOG.md (1)

Line range hint 29-31: Fix typo in beta.2 entry.

There's a typo in the interface description: "generated" should be "generating".

-* [#23013](https://github.com/cosmos/cosmos-sdk/pull/23013) Introduce `TransactionFuzzer`, an interface for processing and generated state transitions.
+* [#23013](https://github.com/cosmos/cosmos-sdk/pull/23013) Introduce `TransactionFuzzer`, an interface for processing and generating state transitions.
store/CHANGELOG.md (1)

34-38: Enhance the changelog entry with more details.

While the entry is correctly formatted, it would be more helpful to provide additional context about memDB's role in simulations, similar to the level of detail in other entries.

Consider expanding the entry like this:

-* [#23013](https://github.com/cosmos/cosmos-sdk/pull/23013) Support memDB for sims
+* [#23013](https://github.com/cosmos/cosmos-sdk/pull/23013) Add support for in-memory database (memDB) in simulation environments to improve testing performance and reliability
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3860b2b and be40c91.

📒 Files selected for processing (7)
  • scripts/build/simulations.mk (0 hunks)
  • server/v2/appmanager/CHANGELOG.md (1 hunks)
  • server/v2/cometbft/abci.go (1 hunks)
  • server/v2/cometbft/streaming.go (4 hunks)
  • server/v2/stf/CHANGELOG.md (1 hunks)
  • simapp/v2/sim_runner.go (8 hunks)
  • store/CHANGELOG.md (1 hunks)
💤 Files with no reviewable changes (1)
  • scripts/build/simulations.mk
🧰 Additional context used
📓 Path-based instructions (6)
store/CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

server/v2/appmanager/CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

server/v2/stf/CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

server/v2/cometbft/abci.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

simapp/v2/sim_runner.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

server/v2/cometbft/streaming.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze
  • GitHub Check: Summary
🔇 Additional comments (9)
server/v2/cometbft/streaming.go (2)

23-27: Delegation to StreamOut Improves Modularity

The streamDeliverBlockChanges method now delegates to the new StreamOut function, enhancing code modularity and simplifying maintenance.


29-67: Introduction of Generic StreamOut Function

The addition of the StreamOut function consolidates streaming logic into a single, generic method, improving code reuse and readability. It correctly aggregates events and handles streaming to listeners.

simapp/v2/sim_runner.go (3)

124-125: Addition of Streaming Fields to TestInstance

The TestInstance struct now includes StreamManager and StreamHook fields to support streaming capabilities in simulations. This extension enhances the test instance's functionality.


292-297: Reading Custom Parameters from File

The code now reads custom simulation parameters from a file when tCfg.ParamsFile is specified. This allows for more flexible and configurable simulation runs.


547-559: Appropriate Handling of Legacy Proposal Messages

In the prepareSimsMsgFactories function, modules implementing HasLegacyProposalMsgs are appropriately handled:

case HasLegacyProposalMsgs:
    tb.Logf("Ignoring legacy proposal messages for module: %s", n)

By logging and skipping these modules, the code ensures compatibility and focuses on modules supporting the current proposal message interface.

server/v2/cometbft/abci.go (2)

513-516: Stream Changes After Committing State

The FinalizeBlock function streams block changes after committing the state:

// listen to state streaming changes in accordance with the block
err = c.streamDeliverBlockChanges(ctx, req.Height, req.Txs, decodedTxs, *resp, stateChanges)
if err != nil {
    return nil, err
}

This ensures that the streaming of events and state changes reflects the committed state, maintaining consistency between the application state and streamed data.


Line range hint 513-539: Simplification of Event Handling in FinalizeBlock

By removing redundant event aggregation and passing the blockResp and stateChanges directly to streamDeliverBlockChanges, the code simplifies event handling and improves maintainability.

server/v2/stf/CHANGELOG.md (1)

25-27: LGTM! Changelog entry is well-formatted and accurate.

The entry correctly documents the addition of DeliverSims entrypoint for simulations, with proper PR reference and formatting.

server/v2/appmanager/CHANGELOG.md (1)

25-27: LGTM! Changelog entry is well-formatted and accurate.

The entry correctly documents the addition of TransactionFuzzer as an entrypoint for simulations, with proper PR reference and formatting.

server/v2/cometbft/streaming.go Show resolved Hide resolved
simapp/v2/sim_runner.go Outdated Show resolved Hide resolved
server/v2/appmanager/CHANGELOG.md Outdated Show resolved Hide resolved
server/v2/stf/CHANGELOG.md Outdated Show resolved Hide resolved
store/CHANGELOG.md Outdated Show resolved Hide resolved
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.

Follow up on sims v2 integration
3 participants