Skip to main content

Workflows

The protocol has the following workflows associated with it:

  • Executor setup
  • Gateway setup
  • Code provisioning
  • Request-response lifecycle
  • Billing

Executor setup

1. Run executor enclave

The executor sets up an enclave using the serverless executor enclave image where compute can be executed verifiably.

2. Register with gateways

The executor registers the enclave with the gateways with the following parameters:

  • Total vcpus
  • Total memory

Based on the above parameters, the gateway computes an executor slice count which acts as capacity for the executor.

Gateway setup

1. Run gateway enclave

The gateway sets up an enclave using the serverless gateway enclave image to act as a TLS terminator and load balancer.

2. Register with gateway contract

The gateway registers the enclave with the gateway contract with its IP address. The gateway is automatically added as an option to the *.oyster.run DNS records.

Code provisioning

1. Developer provisions the code

The developer provisions the code to be executed by uploading the code in the calldata of a transaction on the Arbitrum Sepolia chain. The transaction hash effectively becomes the identity of the code and can be executed by sending requests to <txhash in base32>.oyster.run.

2. Developer provides funds for execution

The developer locks some funds in the billing contract that can be used to pay the gateways and executors on successful executions.

Request-response lifecycle

1. User initiates a HTTP request to a gateway

The user initiates a HTTP request to the subdomain corresponding to the code to be executed with any parameters needed by the request. A gateway is automatically assigned through the DNS protocol to handle the request from the user.

2. Gateway forwards request to an executor

The gateway picks a executor that has spare capacity to perform the compute and forwards the request to the executor. If the corresponding tx hash does not have enough balance in the billing contract, the request is simply dropped.

3. Executor performs compute

The executor performs the required compute with the global timeout. The compute ends on or before the timeout with two possible responses - either the compute finishes before the timeout with an output or it times out with a timeout error. The enclave prepares a signed receipt with the request fields and the response. The signature is added to the response as a HTTP header for future verification and the response is sent back to the gateway. The executor enclave records the time taken for execution and adds it to an internal record of billing information.

4. Gateway forwards response

The gateway forwards the response back to the user. The gateway records a successful request being served and adds it to an internal record of billing information.

Billing

Gateways and executors maintain billing information secured by enclaves. They generate a billing receipt periodically that is signed by the enclave and submit it to the billing contract. The billing contract transfers the payments after verifying the enclave signature.