Skip to content

WIP: RPC Payment

Peter-Jan Brone requested to merge rpc-payment into master

MERGE REQUEST

NOTE: This WIP MR uses a SiaMuxMock, which is to be completely ignored for now. It will get replaced when SiaMux is finished.

NOTE: This MR is based on !4076 (merged) - wait until that is merged before reviewing this.

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

This comes with a couple of new concepts:

  • PaymentProvider interface
  • RPC price table
  • RPC client (renter side)

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

Merge request reports