index.ts

Overview

This file serves as the Pulumi deployment entrypoint for the **Gnosis** blockchain coinstack within the Unchained multi-blockchain infrastructure. It orchestrates the deployment of blockchain node services—specifically daemon nodes, beacon nodes, and indexers—into a Kubernetes cluster by preparing service-specific configuration and passing them to a shared deployment utility (`deployCoinstack`).

The primary functionality includes:

This file abstracts the specifics of the Gnosis blockchain node deployment while leveraging shared Pulumi libraries for consistency across all coinstacks.


Detailed Explanation

Imports


Exported Async Function (Default Export)

export = async (): Promise<Outputs> => { ... }

This is the Pulumi entrypoint function, returning a Promise resolving to `Outputs` which encapsulates deployment results.

Execution Steps:

  1. Define Deployment Context Variables

    const appName = 'unchained'
    const coinstack = 'gnosis'
    

    These identify the application and blockchain coinstack.

  2. Read Sample Environment File

    const sampleEnv = readFileSync('../sample.env')
    

    Loads environment variable definitions for deployment.

  3. Load Kubernetes Config and Namespace

    const { kubeconfig, config, namespace } = await getConfig()
    

    Retrieves cluster access credentials, deployment configuration, and namespace.

  4. Map Stateful Services to Deployment Arguments

    const coinServiceArgs = config.statefulService?.services?.map((service): CoinServiceArgs => {
      switch (service.name) {
        ...
      }
    })
    

    For each service listed in the coinstack’s statefulService.services configuration, the code builds a CoinServiceArgs object customized by service name. This object includes ports, commands, volume mounts, config maps, Kubernetes probes, and any special flags.

    Supported service names and their configurations:

    • daemon

      • Ports:

        • daemon-http: TCP 8545 (HTTP RPC)

        • daemon-ws: TCP 8546 (WebSocket RPC) with path prefix /websocket and stripping enabled

        • daemon-auth: TCP 8551 (authentication endpoint), with ingress routing disabled

      • ConfigMap Data:

        • Loads jwt.hex file contents for authentication tokens

      • Kubernetes Probes:

        • Startup, liveness, and readiness probes configured with specific timeouts and thresholds

      • Volume Mounts:

        • Mounts the jwt.hex file at /jwt.hex inside the container

    • daemon-beacon

      • Command:

        • Runs Lighthouse beacon node with specific flags for Gnosis network, disabling UPnP, setting data directories, enabling HTTP endpoint, linking to the execution endpoint and JWT token, and specifying a checkpoint sync URL

      • ConfigMap Data:

        • Same jwt.hex file for JWT authentication

      • Volume Mounts:

        • Mounts jwt.hex at /jwt.hex

      • Flags:

        • useMonitorContainer: true enables monitoring container sidecar (for health/metrics)

      • Readiness Probe:

        • Configured with period and failure threshold

    • indexer

      • Extends defaultBlockbookServiceArgs to inherit default indexer settings

      • Conditional configuration based on environment:

        • For development (config.environment === 'dev'), disables processing of ERC-1155 tokens by adding -processerc1155=false flag to the command

        • Otherwise, disables readiness probe (presumably due to a known patch or behavior on Gnosis)

      • ConfigMap Data:

        • Loads indexer-config.json for indexer-specific configuration

    • Default Case
      Throws an error if an unsupported service name is encountered, preventing deployment of unrecognized services.

  5. Invoke Deployment

    return deployCoinstack({
      appName,
      coinServiceArgs,
      coinstack,
      coinstackType: 'node',
      config,
      kubeconfig,
      namespace,
      sampleEnv,
    })
    

    Calls the shared deployment function with the constructed arguments, triggering provisioning of all Kubernetes resources required for the coinstack.


Parameters and Return Types

Parameters

The exported async function takes no explicit parameters. It relies on:

Return Value


Usage Example

This file is typically invoked by the Pulumi CLI during deployment, e.g.:

pulumi up --cwd path/to/coinstacks/gnosis/pulumi

No direct function calls or parameters are needed; Pulumi loads and executes this entrypoint asynchronously.


Important Implementation Details


Interaction with Other System Components


Mermaid Diagram: Flowchart of Service Configuration & Deployment Flow

flowchart TD
  A[Start: Pulumi Deployment Entry] --> B[Read sample.env]
  B --> C[Get Kubernetes Config & Namespace]
  C --> D{Map stateful services}
  D --> E[Service: daemon]
  D --> F[Service: daemon-beacon]
  D --> G[Service: indexer]
  D --> H[Unsupported Service -> Throw Error]

  E --> I[Set ports, probes, mounts, jwt config]
  F --> J[Set command (lighthouse), mounts, probes, monitor container]
  G --> K[Extend defaultBlockbookServiceArgs, set config, conditional flags]
  
  I --> L[Aggregate service args]
  J --> L
  K --> L
  L --> M[Call deployCoinstack with args]
  M --> N[Provision Kubernetes resources]
  N --> O[Pods start & run probes]
  O --> P[Deployment complete]

Summary

This [index.ts](/projects/291/68798) file is the Gnosis blockchain coinstack Pulumi deployment script that:

It fits into the multi-blockchain Unchained architecture by providing a modular, declarative deployment of Gnosis blockchain infrastructure components, enabling scalable and maintainable multi-chain operation within Kubernetes.


If you need more details on the shared `deployCoinstack` function or the `CoinServiceArgs` interface, please refer to the Pulumi core library documentation.