Skip to content

Conversation

@kstroobants
Copy link
Contributor

@kstroobants kstroobants commented Jul 25, 2025

Fixes #DXP-442

What

  • Removed VITE_MAX_ROTATIONS from .env.example.
  • Added timeout parameter to NodeFactory.
  • Modified Node and GenVMHost classes to include timeout handling.
  • Removed rotation_count from TransactionContext in backend/consensus/base.py because transaction receipt needs access to it.
  • Removed config_rotation_rounds.
  • Added fees_distribution and appeal_count to the Transactions model in backend/database_handler/models.py.
  • Created a new Alembic migration d30f826417f1_add_fees_distribution.py to add fees_distribution and appeal_count columns and remove config_rotation_rounds.
  • Updated SnapshotManager and TransactionsProcessor to handle new fields and logic.

Why

  • To add fees distribution to the backend.
  • To remove unused or redundant configurations and fields.

Testing done

  • Updated the consensus tests so they pass.
  • Executed a transaction in the studio to check all 4 fee parameters.

Decisions made

  • Decided to set the timeout inside the node.
  • Decided to remove VITE_MAX_ROTATIONS as it was no longer needed.

Checks

  • I have tested this code
  • I have reviewed my own PR
  • I have created an issue for this PR
  • I have set a descriptive PR title compliant with conventional commits

Reviewing tips

Focus on the changes.

Depends

It needs genlayer-js implementation of the fees to know how to decode the parameters. For now they are hardcoded in endpoints.py.

User facing release notes

Added support for fees distribution.

Summary by CodeRabbit

  • New Features

    • Introduced dynamic transaction fee distribution and rotation/appeal limits via a new fees_distribution structure.
    • Added support for tracking and limiting appeal counts per transaction.
    • Enabled custom timeout settings for contract execution on nodes.
  • Improvements

    • Enhanced transaction processing and snapshot management to handle new fee distribution and appeal count fields.
    • Refined consensus and rotation logic to use fees distribution data instead of fixed rotation rounds.
    • Updated appeal button visibility logic in the frontend to consider fees distribution appeal rounds.
  • Bug Fixes

    • Adjusted appeal and rotation enforcement logic to align with updated fee distribution parameters.
  • Chores

    • Updated tests to accommodate new transaction attributes and logic.
    • Removed deprecated environment variables and configuration options.

@kstroobants kstroobants self-assigned this Jul 25, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 25, 2025

Walkthrough

This set of changes replaces the static config_rotation_rounds transaction field with a dynamic fees_distribution dictionary and an appeal_count field across the backend and test code. The consensus, transaction processing, node, and migration logic are updated to use these new structures, enabling more granular control over rotations, appeals, and timeouts. Tests and helper utilities are adapted accordingly.

Changes

File(s) Change Summary
.env.example Removed VITE_MAX_ROTATIONS environment variable.
backend/consensus/base.py Added timeout to node factory; replaced rotation/appeal logic with fees_distribution and appeal_count.
backend/database_handler/migration/versions/d30f826417f1_add_fees_distribution.py Migration: add fees_distribution (JSONB) and appeal_count columns; remove config_rotation_rounds.
backend/database_handler/models.py Removed config_rotation_rounds; added fees_distribution and appeal_count to Transactions model.
backend/database_handler/snapshot_manager.py Snapshots now handle fees_distribution and appeal_count; removed config_rotation_rounds.
backend/database_handler/transactions_processor.py All logic now uses fees_distribution/appeal_count for rotations/appeals; added related methods.
backend/domain/types.py Transaction dataclass: removed config_rotation_rounds, added fees_distribution and appeal_count.
backend/node/base.py Node class now accepts and stores an optional timeout parameter.
backend/node/genvm/base.py Propagated timeout parameter through contract execution and schema retrieval interfaces.
backend/protocol_rpc/endpoints.py send_raw_transaction now passes hardcoded fees_distribution; removed max_rotations argument.
backend/protocol_rpc/server.py Transaction state resets for appeals/rotations moved to restoration flow; added reset for appeal/rotation.
tests/db-sqlalchemy/chain_snapshot_test.py Test transactions now use fees_distribution and appeal_count; removed config_rotation_rounds.
tests/unit/consensus/test_base.py Tests now use helper to set fees_distribution; removed direct config_rotation_rounds usage.
tests/unit/consensus/test_helpers.py Helpers updated for new fields; added/updated methods for appeals, rotations, and fees distribution.
tests/db-sqlalchemy/transactions_processor_test.py Removed config_rotation_rounds argument from transaction insertions in test.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ProtocolRPC
    participant TransactionsProcessor
    participant Database
    participant Consensus
    participant Node

    Client->>ProtocolRPC: send_raw_transaction(data, ...)
    ProtocolRPC->>TransactionsProcessor: insert_transaction(..., fees_distribution, ...)
    TransactionsProcessor->>Database: Store transaction with fees_distribution, appeal_count=0
    loop Consensus process
        Consensus->>Node: Create Node(timeout from fees_distribution)
        Node->>Node: run_contract(..., timeout)
    end
    TransactionsProcessor->>Consensus: Use fees_distribution/appeal_count for rotations/appeals
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Poem

In the warren where code does spin and twirl,
Rotations and appeals now gracefully unfurl.
Fees distribute, appeals count anew,
Snapshots and nodes with fresh logic to chew.
The rabbits rejoice, their whiskers a-twitch—
For change is afoot, and the code is quite rich!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dxp-442-fees-parameters-backend

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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.

CodeRabbit Configuration 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.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
16.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

- transaction_data["rotation_count"]
)

if transaction_data["fees_distribution"] is None:
Copy link
Member

Choose a reason for hiding this comment

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

@kstroobants these two if statements withing 10 lines seems weird.

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.

3 participants