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: create importer online component #1541

Merged
merged 59 commits into from
Jul 31, 2024
Merged

Conversation

gabriel-aranha-cw
Copy link
Contributor

@gabriel-aranha-cw gabriel-aranha-cw commented Jul 25, 2024

PR Type

Enhancement, Tests


Description

  • Introduced a new Raft consensus module with leader election, peer discovery, and log entry handling.
  • Added a SimpleConsensus module for basic consensus operations.
  • Implemented an Importer module for syncing blocks with external RPC, including block and receipt fetching and execution.
  • Updated the configuration to support leader and follower modes, integrating ImporterConfig.
  • Refactored the main function to initialize Raft and SimpleConsensus, and integrated Importer initialization for follower mode.
  • Updated the RPC server to use a dynamic Consensus trait and refactored version and transaction forwarding methods.
  • Added and updated tests to validate the new Raft consensus and Importer functionalities.

Changes walkthrough 📝

Relevant files
Enhancement
11 files
mod.rs
Introduce Raft consensus module with leader election and peer
discovery

src/eth/consensus/raft/mod.rs

  • Added new Raft consensus module with various submodules and
    functionalities.
  • Implemented peer discovery, election process, and leader-follower
    roles.
  • Added tests for peer address parsing and validation.
  • +683/-0 
    mod.rs
    Refactor consensus module to include Raft and SimpleConsensus

    src/eth/consensus/mod.rs

  • Removed old consensus implementation.
  • Added new Raft and SimpleConsensus modules.
  • Updated imports and module structure.
  • +9/-660 
    importer.rs
    Add Importer module for syncing blocks with external RPC 

    src/eth/importer/importer.rs

  • Added new Importer module for syncing blocks with external RPC.
  • Implemented block and receipt fetching, and block execution.
  • Added support for online importer mode.
  • +437/-0 
    config.rs
    Update configuration to support leader and follower modes

    src/config.rs

  • Added new configuration options for leader and follower modes.
  • Integrated ImporterConfig into StratusConfig.
  • +12/-120
    propagation.rs
    Update propagation logic for Raft consensus                           

    src/eth/consensus/raft/propagation.rs

  • Updated propagation logic to use Raft consensus.
  • Refactored functions to handle log entries and peer propagation.
  • +18/-18 
    log_entry.rs
    Add LogEntry structures for Raft log entries                         

    src/eth/consensus/raft/log_entry.rs

  • Added LogEntry and LogEntryData structures for Raft log entries.
  • Implemented encoding and decoding for log entries.
  • +136/-1 
    server.rs
    Implement Raft server for handling append entries and votes

    src/eth/consensus/raft/server.rs

  • Implemented Raft server for handling append entries and vote requests.
  • Added tests for server functionalities.
  • +17/-17 
    main.rs
    Update main function to initialize Raft and Importer         

    src/main.rs

  • Updated main function to initialize Raft and SimpleConsensus.
  • Integrated Importer initialization for follower mode.
  • +46/-16 
    mod.rs
    Add SimpleConsensus module for basic consensus operations

    src/eth/consensus/simple_consensus/mod.rs

  • Added SimpleConsensus module for basic consensus operations.
  • Implemented should_serve and forward methods.
  • +75/-0   
    importer_config.rs
    Add ImporterConfig for configuring importer settings         

    src/eth/importer/importer_config.rs

  • Added ImporterConfig structure for configuring importer settings.
  • Implemented initialization of Importer with provided configuration.
  • +67/-0   
    rpc_server.rs
    Update RPC server to use dynamic Consensus trait                 

    src/eth/rpc/rpc_server.rs

  • Updated RPC server to use dynamic Consensus trait.
  • Refactored version and transaction forwarding methods.
  • +4/-7     
    Tests
    3 files
    factories.rs
    Add factory functions for Raft consensus tests                     

    src/eth/consensus/raft/tests/factories.rs

  • Added factory functions for creating mock Raft consensus and peers.
  • Updated tests to use new Raft structures.
  • +19/-19 
    importer.test.ts
    Update integration tests for Importer functionality           

    e2e/cloudwalk-contracts/integration/test/importer.test.ts

  • Updated integration tests to validate Importer functionality.
  • Refactored test descriptions and provider URLs.
  • +27/-27 
    e2e-importer.yml
    Rename and update E2E Importer workflow                                   

    .github/workflows/e2e-importer.yml

  • Renamed workflow to E2E Importer.
  • Updated job names and descriptions.
  • +3/-3     
    Additional files (token-limit)
    1 files
    justfile
    ...                                                                                                           

    justfile

    ...

    +16/-52 

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Copy link

    github-actions bot commented Jul 25, 2024

    PR Reviewer Guide 🔍

    (Review updated until commit 9d121b8)

    ⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Task Naming
    The tokio::spawn calls should be replaced with spawn_named to ensure tasks are properly named for better monitoring and debugging.

    Tracing Fields
    The tracing::instrument macro should record identifiers as span fields for better traceability.

    Error Logging
    When logging errors, ensure the original error is logged in a field called reason.

    Dynamic Fields in Tracing
    Avoid formatting dynamic fields in tracing messages. Instead, add them as tracing fields.

    Initialization Logging
    Ensure that the initialization of core components or services is logged with all relevant configurations.

    Task Naming
    The tokio::spawn calls should be replaced with spawn_named to ensure tasks are properly named for better monitoring and debugging.

    Error Logging
    When logging errors, ensure the original error is logged in a field called reason.

    Dynamic Fields in Tracing
    Avoid formatting dynamic fields in tracing messages. Instead, add them as tracing fields.

    Tracing Fields
    The tracing::instrument macro should record identifiers as span fields for better traceability.

    src/config.rs Outdated Show resolved Hide resolved
    Copy link
    Contributor

    @renancloudwalk renancloudwalk left a comment

    Choose a reason for hiding this comment

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

    I HIGHLY sugest removing ENTIRELY the leader/follower logic so we can only have a miner/importer logic

    @dinhani-cw
    Copy link
    Contributor

    /describe

    Copy link

    PR Description updated to latest commit (02aa0cc)

    src/config.rs Outdated Show resolved Hide resolved
    @gabriel-aranha-cw
    Copy link
    Contributor Author

    /describe

    Copy link

    PR Description updated to latest commit (b8bf98f)

    @gabriel-aranha-cw gabriel-aranha-cw dismissed renancloudwalk’s stale review July 31, 2024 19:55

    Approved after review and new considerations

    @gabriel-aranha-cw gabriel-aranha-cw merged commit 64daad0 into main Jul 31, 2024
    31 checks passed
    @gabriel-aranha-cw gabriel-aranha-cw deleted the importer-component branch July 31, 2024 19:55
    mayconamaroCW added a commit that referenced this pull request Jul 31, 2024
    @mayconamaroCW mayconamaroCW restored the importer-component branch July 31, 2024 20:41
    mayconamaroCW added a commit that referenced this pull request Jul 31, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    5 participants