Skip to content

WIP: RPC Payment

Peter-Jan Brone requested to merge account-filler into master

MERGE REQUEST

NOTE:
This MR is going to be split into 4 separate MRs!
Keeping it here to easily check the diff.
Will cleanup soon.

NOTE: This WIP MR uses mock version of the siamux and has a file modules/siamux.go that is to be completely ignored.
It's merely a collection of "stuff" required to avoid riddling the MR with TODOs everywhere.
Once the siamux package is finished, it should be (almost) a drop-in replacement.

Overview

The goal of this MR is to introduce the ability to:

  • provide payment for an RPC on the renter side
  • process payment for an RPC on the host side
  • EA refill worker (-> probably extract this into separate MR)

This comes with a couple of new concepts:

  • PaymentProvider interface
  • RPC price table
  • RPC client (renter side)
  • account object (renter side, mirrors an EA on the host)

For now, only two RPCs are supported by the host:

  • fundEphemeralAccountRPC
  • updatePriceTableRPC

Eventually though, the RPC client should be capable of handling all of the RPCs offerend by a host.

Design

Renter Side

On the renter side the biggest change is the introduction of an RPC client. The RPC clients are distinct to a host, and is kept on the renter object.

I imagine the workers having access to these RPC clients and just calling the RPC they want. RPC clients have an account object, which abstracts payment. The account adheres to the PaymentProvider interface, which means you can simply call ProvidePaymentForRPC and be totally oblivious to how payment will be made (from EA or file contract).

Host Side

On the host side the biggest change is listening for incoming streams. Seeing as this is not yet implemented in the siamux package, this is subject to change.

Aside from handling streams, the host keeps an RPC price table. The renter "sessions" (which are just the handlers that handle incoming streams) have a snapshot of the RPC price table they've communicated to the renter. This way they can verify costs and refuse an RPC should the renter have outdated pricing.

Example for Visual changes (ie Screenshot)

N/A

Issues Closed

N/A

Checklist

Review and complete the checklist to ensure that the MR is complete before assigned to an approver.

  • All new methods, or updating methods have clear docstrings
  • Testing added or updated for new methods
  • Any new packages are added to Makefile and .gitlab-ci.yml
  • API documentation updated for API updates
  • Module README.md updated for changes to work flow
  • Issue added to Sia-UI repo for new supporting features
Edited by Peter-Jan Brone

Merge request reports