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

XBRMarket ("per-market payment/paying channels") #48

Closed
oberstet opened this issue Sep 6, 2019 · 3 comments
Closed

XBRMarket ("per-market payment/paying channels") #48

oberstet opened this issue Sep 6, 2019 · 3 comments

Comments

@oberstet
Copy link
Member

oberstet commented Sep 6, 2019

Currently, every payment/paying channel runs on its own deployed contract instance. IOW, opening a payment/paying channel leads to a new contract instance being deployed, which is expensive in gas cost.

  Gas price (Gwei / unit gas)   8  
  ETH price (EUR / ETH)   175,00 €  
         
         
  Deploy XBRToken   812.557 1,14 €
  Deploy XBRNetwork   6.664.891 9,33 €
         
  Send ETH   21.000 0,03 €
  Send XBR   51.852 0,07 €
         
all users XBRNetwork.register   138.393 0,19 €
market operators XBRNetwork.createMarket   175.167 0,25 €
buyers + sellers XBRNetwork.joinMarket   80.330 0,11 €
buyers XBRNetwork.openPaymentChannel Tx 1: approve tokens 45.913 0,06 €
    Tx 2: open channel 1.266.775 1,77 €
sellers XBRNetwork.requestPayingChannel Tx 1: approve tokens 33.758 0,05 €
market makers XBRNetwork.openPayingChannel Tx 2: open channel 30.913  
      1.266.854  

An alternative design would only deploy 1 XBRChannel contract instance per market.

Doing so would lead to ~ 0.20-0.30 USD (20-30 cents) gas cost per channel open.

@oberstet
Copy link
Member Author

Here is a design for above:

  • we drop the existing XBRChannel and move the code to a new contract XBRMarket
  • an instance of XBRMarket is created in XBRNetwork.createMarket
  • XBRMarket internally maintains a mapping from channel address to the attributes of a channel (the stuff currently in XBRChannel)

the functions

  • XBRNetwork.getMarketActor
  • XBRNetwork.updateMarket
  • XBRNetwork.closeMarket
  • XBRNetwork.joinMarket
  • XBRNetwork.leaveMarket
  • XBRNetwork.openPaymentChannel
  • XBRNetwork.requestPayingChannel
  • XBRNetwork.openPayingChannel
  • XBRNetwork.getAllPaymentChannels
  • XBRNetwork.getAllPayingChannels
  • XBRNetwork.currentPaymentChannelByDelegate
  • XBRNetwork.currentPayingChannelByDelegate

are moved to XBRMarket

@oberstet oberstet changed the title Per-market payment/paying channels XBRMarket ("per-market payment/paying channels") Sep 27, 2019
@oberstet oberstet added this to the Mark-II milestone Sep 27, 2019
@oberstet oberstet removed the Mark-II label Sep 27, 2019
@oberstet oberstet mentioned this issue Oct 14, 2019
@oberstet
Copy link
Member Author

oberstet commented Mar 11, 2020

  • we now have a new XBRMarket contract, which hols all markets (hence, there is only 1 instance, and no instances are created dynamically).
  • creating a new channel should just call into XBRChannel and create a record in an internal mapping

@oberstet
Copy link
Member Author

landed via #90

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant