Worker Integration: Data Availability
This guide provides a comprehensive overview of Crestalβs worker deployment process, including the architecture, smart contract functions, and API integrations.
Roles and Responsibilities
Builder
- Submits a deployment request to the Blueprint contract.
- Retrieves proof of deployment after the process is completed.
Worker
- Listens for deployment request events from the Blueprint.
- Submits a deployment request to the blockchain.
- Performs a real deployment based on the proposal.
- Submits a deployment proof to the Blueprint contract.
Crestal Backend
- Accepts off-chain deployment requests.
- Updates deployment status.
Blueprint Smart Contract
- Accepts deployment requests from Builders or the Crestal frontend.
- Emits deployment request events.
- Decides which Worker can handle a deployment request.
- Emits events for deployment acceptance and proof of deployment submission.
Deployment Workflow
-
Builder (via API or Crestal Frontend) triggers the Blueprint smart contract by requesting a proposal deployment with the following parameters:
solverAddress
: The address of the Solver. If using the Crestal frontend, this is the address that generated the proposal. Otherwise, it can be any address.Base64Proposal
: Encoded proposal in Base64 format with additional attributes. Refer to theproposal.format
chapter for details.serverURL
: The URL for the Crestal backend (default: Crestal backend URL).
-
Blueprint Smart Contract Emits a Deployment Event
The Blueprint Smart Contract processes deployment requests and emits one of two events depending on the proposal type:
RequestDeployment Emitted for general deployment requests. This event includes:
solverAddress
: Address of the Solver (or Builder if submitted directly).Base64Proposal
: Encoded proposal details.serverURL
: Backend server URL.requestID
: Unique deployment request ID.
RequestPrivateDeployment Emitted for private deployments when the proposal specifies a selected Worker. Includes:
privateWorkerAddress
: The explicitly selected Workerβs address.
These events can be detected by running the event listeners included in the SDK:
utils/berachainBartioEventListener
utils/bscTestnetEventListener
utils/polygonAmoyEventListener
-
Worker submits deployment request to the contract:
- Listen for
RequestDeployment
events. - Fetch the associated
requestId
from the event. - Submit a deployment request to the Blueprint contract using the
submitDeploymentToContract
SDK util fromutils/submitDeploymentToContract
- The function takes two parameters,
projectId
andrequestId
, both are extracted from theRequestDeployment
requestThis step is skipped for private worker deployments.
- Listen for
-
Blueprint Contract selects worker:
- Receives multiple Worker requests.
- Selects a Worker to handle the deployment using a first-come, first-serve strategy.
- Emits an
AcceptDeployment
event containing therequestId
and the selected Worker address.This step is skipped for private worker deployments.
-
Selected Worker:
- Listens for
AcceptDeployment
events to verify if they are assigned. - If selected:
-
Performs the real deployment.
-
Sends a POST request to the Crestal backend (
/v1/deployments/worker
) to record the deployment usingsubmitDeployment
fromutils/submitDeployment
following the below format: -
Syncs deployment status via
/v1/deployments/worker/status
usingupdateDeploymentStatus
fromutils/updateDeploymentStatus
. -
Completes the deployment and submits proof to the Blueprint using
submitDeploymentToContract
fromutils/submitDeploymentToContract
following the above format: -
Syncs the proof of deployment with the Crestal backend via
/v1/deployments/worker/status
usingupdateDeploymentStatus
, this time includingDeploymentDetails
:
-
- Listens for
-
The contract receives the proof of deployment:
- Receives the proof of deployment.
- Emits a
GeneratedProofOfDeployment
event containing the Base64-encoded proof.
Event Details
Events Emitted by the Blueprint Smart Contract
RequestDeployment
: Signals a new deployment request.AcceptDeployment
: Indicates a Worker has been selected for deployment.GeneratedProofOfDeployment
: Contains the Base64-encoded proof of deployment.