Skip to content

Swarm swap accounting phase 1 #17901

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

Closed
wants to merge 30 commits into from
Closed

Conversation

holisticode
Copy link
Contributor

This PR introduces the first phase of swap accounting for swarm message exchange.

This current implementation only does the accounting part, no cryptoeconomic features are implemented yet (price negotiation, claim settling, etc.). This means this implementation just keeps track of how many units are exchanged between nodes and maintains a balance with them.

The currently only accounted protocol is swarm's streaming protocol (swarm/network/stream). The prices defined in that protocol are totally arbitrary and will require monitoring, simulations and analysis before they can be seriously taken into account.

Basic design:

p2p/protocols/accounting.go defines the basic interfaces:

Balance defines the actual accounting interface. It only has an Add function. This function will be called with a peer instance and an amount. If the amount is negative, then the local node is being debited, if it is positive, the local node is being credited.

Prices is an interface that defines how prices are being expected. Every accounted protocol should provide an implementation, and return a Price structure for every message for which it requires accounting. This struct contains a Value int64 field; negative means receiver pays, positive means the sender pays for the message.

An accounted protocol needs to provide a Hook inside its Spec, where it defines its messages. The Hook contains a Balance and a Prices interfaces, which allows the messaging infrastructure to transparently do the accounting.

@holisticode holisticode requested a review from fjl as a code owner October 12, 2018 16:44
@holisticode holisticode requested review from nolash and nonsense and removed request for fjl, gbalint and zsfelfoldi October 12, 2018 16:44
@holisticode holisticode self-assigned this Oct 12, 2018
@holisticode
Copy link
Contributor Author

To introduce some metrics for this implementation, a new NewCounterForced as been added.
cc @fjl @nonsense

@holisticode
Copy link
Contributor Author

Opened too early. Superseded by ethersphere/swarm#962

@frncmx frncmx deleted the sw3-p2p branch January 22, 2019 09:32
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.

1 participant