masa-finance / roadmap

The protocol
0 stars 0 forks source link

feat: Replace actor framework with our own protocol over libp2p #69

Closed mudler closed 2 months ago

mudler commented 3 months ago

Problem

To have the oracle functional, a user must:

These limitations are introduced because we currently use the actor framework to dispatch jobs to the workers, and as an overlay for implementing protocol logics.

This is problematic as well in terms of security, where authentication with workers should be gated somehow to avoid abuse of the workers in the network.

From a code perspective, this is quite limiting too as it basically requires to dial workers directly without libp2p, undermining the user experience of the oracle by having strict requirements in terms of connections.

Proposed solution

We can use libp2p to dial directly workers, and implement the protocol as a set of stream handlers on top of libp2p.

Acceptance criteria

teslashibe commented 2 months ago

@restevens402 I moved this here for branch: https://github.com/masa-finance/masa-oracle/pull/504

Objective:

The goal of this spike is to replace the existing actor framework for work distribution with a more streamlined and efficient libp2p-based worker distribution system. This transition aims to simplify the codebase, reduce overhead, and leverage the capabilities of libp2p for peer-to-peer communication.

High-Level Description:

The current system uses an actor framework to manage and distribute work among various workers. This approach, while functional, introduces complexity and overhead that can be mitigated by using libp2p for direct peer-to-peer communication. The new system will utilize the worker_manager.go file to handle work distribution, execution, and response collection.

Key Components:

1. WorkHandlerManager:

3. Libp2p Integration:

Implementation Details:

4. Libp2p Communication:

Next Steps for Testing Remote Node Distribution

1. Setup Local Network for Testing

Steps:

1. Configure Multiple Nodes Locally:

- Set up multiple instances of your application on different ports or machines within your local network.

- Ensure each node is configured to recognize the others as peers.

2. Distribute Work:

- Use the DistributeWork function to send work requests from one node to another.

- Verify that the work is correctly received, processed, and the response is sent back.
mudler commented 2 months ago

This card is going to be closed by https://github.com/masa-finance/masa-oracle/pull/504

mudler commented 2 months ago

https://github.com/masa-finance/masa-oracle/pull/504 is merged - closing this one