Skip to content

Conversation

@0xMimir
Copy link
Contributor

@0xMimir 0xMimir commented Nov 25, 2024

Added abstraction over channels service (P2pChannelsService), main reason is to simplify channels layer and reduce number of actions that perform same thing, before this each channel had its effectful counterpart which would interact with service, now each channel interacts with new actions that are abstraction over methods on P2pChannelsService.

Mental model of channels shouldn't change, only chain of actions from:

[Channel]Action -> [Channel]EffectfulAction -> Service call

to:

[Channel]Action -> Service call action -> Service call

Every channel still has its own ID and messages

Changes:

  • Removed effectful action that send response/request, instead of sending message on channel like following:
dispatcher.push(P2pChannelsBestTipEffectfulAction::RequestSend { ... });
// or
dispatcher.push(P2pChannelsBestTipEffectfulAction::ResponseSend { ... });

Request/Response would be sent like following:

dispatcher.push(P2pChannelsEffectfulAction::RequestSend {
    msg: ChannelMsg::BestTipPropagation(BestTipPropagationChannelMsg::RequestMessage),
    ...
});
// or
dispatcher.push(P2pChannelsEffectfulAction::RequestSend {
    msg: ChannelMsg::BestTipPropagation(BestTipPropagationChannelMsg::ResponseMessage),
    ...
});
  • Moved actions to initialize channels to single action with a callback, so instead of every channel having its own initialization action, channel id and callback should be passed to P2pChannelsEffectfulAction::InitChannel action.

Benefits:

  • Easier to follow actions, only one action to open channel and one to send message, instead of every channel having its own effectful action to open channel, and instead of every message having its own action there is only one.
  • Less code and less actions

@0xMimir 0xMimir force-pushed the feat/reducer-porting-clenup branch 2 times, most recently from 9b7e3ac to f9ad784 Compare November 26, 2024 11:25
@tizoc
Copy link
Collaborator

tizoc commented Nov 26, 2024

@0xMimir when you are done please add a description on the summary of this PR explaining the change. Skimming through it I am still not sure I understand the benefits, and it seems to be changing the mental model of how channels work (we used to have one channel per kind of message, and each channel had one specific message, now it is one channel per peer with multiple types of messages?). It is important that the difference is clear so that we can properly evaluate it.

@tizoc
Copy link
Collaborator

tizoc commented Nov 26, 2024

when you are done please add a description on the summary
or maybe even before depending on how much work is left (seems to be close to ready but I may be wrong).

@0xMimir 0xMimir force-pushed the feat/reducer-porting-clenup branch from f9ad784 to bbcfc4d Compare November 26, 2024 13:34
@0xMimir 0xMimir marked this pull request as ready for review November 26, 2024 14:45
@0xMimir 0xMimir requested review from dkuehr and tizoc November 26, 2024 14:46
@0xMimir 0xMimir changed the title Cleanup after reducer porting Updated channels to reuse logic Nov 26, 2024
Copy link
Contributor

@dkuehr dkuehr left a comment

Choose a reason for hiding this comment

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

Could you provide a detailed list of the benefits of the channel reuse logic?

I'm not fully convinced about the extra level of wrapping that is required for pushing actions.

@tizoc
Copy link
Collaborator

tizoc commented Nov 26, 2024

@binier if you have time, it would be useful to get your feedback on this one

@0xMimir 0xMimir force-pushed the feat/reducer-porting-clenup branch 2 times, most recently from 892eb07 to 4a132fe Compare November 26, 2024 16:14
Copy link
Contributor

@binier binier left a comment

Choose a reason for hiding this comment

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

Looks good. Needs just some minor cosmetic changes.

@0xMimir 0xMimir force-pushed the feat/reducer-porting-clenup branch 2 times, most recently from e08b45e to 883b592 Compare November 26, 2024 17:04
Copy link
Collaborator

@tizoc tizoc left a comment

Choose a reason for hiding this comment

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

left a few more comments, but overall it LGTM now + it reduces the service interaction surface which is a big plus

@0xMimir 0xMimir force-pushed the feat/reducer-porting-clenup branch from 883b592 to 74386ab Compare November 26, 2024 17:27
@0xMimir 0xMimir merged commit 858c2a9 into o1-labs:develop Nov 28, 2024
23 of 27 checks passed
@0xMimir 0xMimir deleted the feat/reducer-porting-clenup branch December 18, 2024 10:31
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.

4 participants