Skip to content

Swarm accounting #18050

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

Merged
merged 7 commits into from
Nov 15, 2018
Merged

Swarm accounting #18050

merged 7 commits into from
Nov 15, 2018

Conversation

holisticode
Copy link
Contributor

@holisticode holisticode commented Nov 7, 2018

Building on p2p accounting, this PR introduces swarm accounting.

This is basically an implementation of the required interfaces of p2p accounting for swarm.
This is a further step in adding swap accounting to swarm.

The last PR will be adding the pricing interface to the streamer package.

@@ -353,7 +359,7 @@ func (self *Swarm) Start(srv *p2p.Server) error {
newaddr := self.bzz.UpdateLocalAddr([]byte(srv.Self().String()))
log.Info("Updated bzz local addr", "oaddr", fmt.Sprintf("%x", newaddr.OAddr), "uaddr", fmt.Sprintf("%s", newaddr.UAddr))
// set chequebook
if self.config.SwapEnabled {
if self.config.SwapEnabled && self.config.SwapAPI != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

where does swapAPI this come from and what is it supposed to be?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the chequebook contract as far as I remember. Currently, if swapEnabled, then the code will try to access the contract and it will fail.

This is probably only a temporary fix until we have the last phase of Swap working, which is a working contract.

Copy link
Contributor

Choose a reason for hiding this comment

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

but is it safe to keep it?

Copy link
Contributor Author

@holisticode holisticode Nov 12, 2018

Choose a reason for hiding this comment

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

I believe it needs to be revisited at the time when we integrate chequebook contracts again, and probably we will need a different strategy.

But currently it would not be possible to run any tests with swap as if swap is enabled and no chequebook contract (or a fake one) is provided, then the node would just crash.

I'll add a comment accordingly here (TODO).

Copy link
Member

Choose a reason for hiding this comment

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

maybe let's disable the chequebook altogether and revisit that once we reach the point in which it is relevant again?

@ethereum ethereum deleted a comment from AttackerBero Nov 10, 2018
Copy link
Contributor

@zelig zelig left a comment

Choose a reason for hiding this comment

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

I rebased to kick off travis properly

@@ -353,7 +359,7 @@ func (self *Swarm) Start(srv *p2p.Server) error {
newaddr := self.bzz.UpdateLocalAddr([]byte(srv.Self().String()))
log.Info("Updated bzz local addr", "oaddr", fmt.Sprintf("%x", newaddr.OAddr), "uaddr", fmt.Sprintf("%s", newaddr.UAddr))
// set chequebook
if self.config.SwapEnabled {
if self.config.SwapEnabled && self.config.SwapAPI != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

but is it safe to keep it?

@zelig zelig force-pushed the swarm-accounting branch 2 times, most recently from ed8d7af to d2a3830 Compare November 10, 2018 06:38
@zelig
Copy link
Contributor

zelig commented Nov 13, 2018

@holisticode we seem to have lost @janos changes that correct the travis issues

@@ -228,6 +235,17 @@ func NewRegistry(localID enode.ID, delivery *Delivery, syncChunkStore storage.Sy
return streamer
}

//we need to construct a spec instance per node instance
func (r *Registry) setupSpec() {
Copy link
Member

Choose a reason for hiding this comment

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

can we please have this as setupProtocolSpec? and the corresponding createSpec as createProtocolSpec? these function names are over-generalised

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any specific reason for that? I have had many "obvious" wording in previous PRs required to be edited away, The variable was called Spec before and in p2p/protocols/protocol.go it is still just called Spec. So I don't see a over-generalization here?

@@ -353,7 +359,7 @@ func (self *Swarm) Start(srv *p2p.Server) error {
newaddr := self.bzz.UpdateLocalAddr([]byte(srv.Self().String()))
log.Info("Updated bzz local addr", "oaddr", fmt.Sprintf("%x", newaddr.OAddr), "uaddr", fmt.Sprintf("%s", newaddr.UAddr))
// set chequebook
if self.config.SwapEnabled {
if self.config.SwapEnabled && self.config.SwapAPI != "" {
Copy link
Member

Choose a reason for hiding this comment

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

maybe let's disable the chequebook altogether and revisit that once we reach the point in which it is relevant again?

@zelig zelig merged commit ffe2fc3 into ethereum:master Nov 15, 2018
zsfelfoldi pushed a commit to zsfelfoldi/go-ethereum that referenced this pull request Nov 28, 2018
* swarm: completed 1st phase of swap accounting

* swarm: swap accounting for swarm with p2p accounting

* swarm/swap: addressed PR comments

* swarm/swap: ignore ErrNotFound on stateStore.Get()

* swarm/swap: GetPeerBalance test; add TODO for chequebook API check

* swarm/network/stream: fix NewRegistry calls with new arguments

* swarm/swap: address @justelad's PR comments
@frncmx frncmx deleted the swarm-accounting branch January 23, 2019 11:19
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