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

Improve the EVA protocol: devos50 edition #6831

Merged
merged 3 commits into from
Apr 19, 2022
Merged

Conversation

drew2a
Copy link
Contributor

@drew2a drew2a commented Mar 24, 2022

During the ultimate stress test of the EVA protocol made by @devos50 we figured out some improvements that could be done to the EVA protocol.

Packet loss

Problem

During massive use of binary transfers provided by EVA protocol, some packets seem to be dropped by a socket.

Solution

EVA protocol has been designed as an abstract protocol, that uses ipv8 as a transport layer. That means EVA doesn't care much about balancing socket load.
However, it seems like a good idea to add a tool to the protocol to have the ability to limit ipv8 and socket load.

This tool will be variable max_simultaneous_transfers and it will be set to 10 by default.

Missed messages resending for WriteRequest

Problem

EVA doesn't support handling lost WriteRequest packets and performs only one attempt to send WriteRequest.

Solution

@devos50 added this support in https://github.com/devos50/accountable-dfl/blob/main/accdfl/util/eva_protocol.py in a similar way as it was implemented for resend_acknowledge. I've merged his changes to this PR.

Future support for EVA protocol

@devos50 requested to add the Future object as a returned parameter to thesend_binary function.
See the example of use: https://github.com/devos50/accountable-dfl/blob/main/accdfl/core/community.py#L230

Shutdown method for EVA protocol

@devos50 requested to add this method because he has a necessity to fast shut down the entire EVA stack:

task: <Task pending name='DFLCommunity:eva_terminate_by_timeout 11587' coro=<delay_runner() running at /home/spandey/venv3/lib/python3.9/site-packages/ipv8/taskmanager.py:23> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f8508a060d0>()]> cb=[TaskManager.register_task.<locals>.done_cb() at /home/spandey/venv3/lib/python3.9/site-packages/ipv8/taskmanager.py:128]>

@drew2a drew2a force-pushed the refactoring/eva_impovements branch 6 times, most recently from 7f0b801 to 033d2ba Compare March 25, 2022 16:46
@drew2a drew2a requested review from devos50 and kozlovsky March 28, 2022 08:33
@drew2a drew2a changed the title WIP Improve the EVA protocol Improve the EVA protocol Mar 28, 2022
@drew2a drew2a marked this pull request as ready for review March 28, 2022 08:34
@drew2a drew2a requested a review from a team March 28, 2022 08:34
devos50
devos50 previously approved these changes Mar 28, 2022
Copy link
Contributor

@devos50 devos50 left a comment

Choose a reason for hiding this comment

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

Tested the changes in my experiment - seems to work great! 👍

kozlovsky
kozlovsky previously approved these changes Apr 4, 2022
@drew2a
Copy link
Contributor Author

drew2a commented Apr 4, 2022

@kozlovsky @devos50 what do you think guys about the latest refactoring (see the most resend commit)?

a04f735

UPD: we've discussed this refactoring with @kozlovsky and decided to rewrite it.

@drew2a drew2a force-pushed the refactoring/eva_impovements branch 2 times, most recently from 5c08872 to a12ce42 Compare April 4, 2022 12:15
@drew2a drew2a changed the title Improve the EVA protocol WIP Improve the EVA protocol Apr 4, 2022
@drew2a drew2a marked this pull request as draft April 4, 2022 12:55
@drew2a drew2a force-pushed the refactoring/eva_impovements branch 5 times, most recently from ea1591f to 6492465 Compare April 5, 2022 14:21
kozlovsky
kozlovsky previously approved these changes Apr 8, 2022
@drew2a
Copy link
Contributor Author

drew2a commented Apr 8, 2022

@devos50 changes are ready to test! 🚀

Please note that in the latest commit d6c09e3 EVA's interface has been slightly changed:

  • All callbacks now should be async
  • Proxy methods have been removed

By a proxy method I mean:

    def eva_send_binary(self, peer: Peer, info: bytes, data: bytes, nonce: int = None) -> Future:
        return self.eva_protocol.send_binary(peer, info, data, nonce)

Here is an example of EVA usage:

     import os
     from ipv8.community import Community
     class MyCommunity(EVAProtocolMixin, Community):
         community_id = os.urandom(20)
    
         def __init__(self, *args, **kwargs):
             super().__init__(*args, **kwargs)
             self.eva_init()
    
             self.eva.register_receive_callback(self.on_receive)
             self.eva.register_send_complete_callback(self.on_send_complete)
             self.eva.register_error_callback(self.on_error)
    
         async def my_function(self, peer):
             await self.eva.send_binary(peer, b'info1', b'data1')
             await self.eva.send_binary(peer, b'info2', b'data2')
             await self.eva.send_binary(peer, b'info3', b'data3')
    
         async def on_receive(self, result):
             self.logger.info(f'Data has been received: {result}')
    
         async def on_send_complete(self, result):
             self.logger.info(f'Transfer has been completed: {result}')
    
         async def on_error(self, peer, exception):
             self.logger.error(f'Error has been occurred: {exception}')

@drew2a drew2a requested a review from devos50 April 8, 2022 16:30
@drew2a drew2a force-pushed the refactoring/eva_impovements branch from 5bfd9a8 to d6c09e3 Compare April 9, 2022 20:29
@drew2a drew2a requested a review from kozlovsky April 9, 2022 20:34
@drew2a drew2a force-pushed the refactoring/eva_impovements branch 3 times, most recently from 2094119 to 4e4f940 Compare April 9, 2022 22:35
kozlovsky
kozlovsky previously approved these changes Apr 11, 2022
@devos50
Copy link
Contributor

devos50 commented Apr 11, 2022

Still haven't been able to test out the changes in an experiment setting - I hope to do so later this afternoon.

@drew2a
Copy link
Contributor Author

drew2a commented Apr 11, 2022

@devos50 thank you in advance for testing!

@drew2a drew2a force-pushed the refactoring/eva_impovements branch 2 times, most recently from b52977e to 99d1072 Compare April 19, 2022 13:02
@drew2a drew2a force-pushed the refactoring/eva_impovements branch from 67ecaad to 944cc7b Compare April 19, 2022 13:40
@drew2a drew2a merged commit a479278 into main Apr 19, 2022
@kozlovsky kozlovsky deleted the refactoring/eva_impovements branch June 3, 2022 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants