index.ts


Overview

This file defines the Pulumi deployment entrypoint for the **Base Ethereum Layer 1 coinstack** within the ShapeShift Unchained multi-blockchain infrastructure. It orchestrates the configuration and deployment of blockchain node services—specifically the daemon node, the optimistic rollup node (`op-node`), and the indexer service—by preparing service-specific deployment parameters and invoking the shared `deployCoinstack` function.

Key aspects include:

This file facilitates automated, reproducible Kubernetes deployment of the Ethereum base chain node stack as part of the ShapeShift Unchained platform.


Detailed Explanation

Exported Function (Default Export)

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

Internal Workflow Steps

  1. Constants Initialization

const appName = 'unchained'
const coinstack = 'base'
  1. Read Environment Sample

const sampleEnv = readFileSync('../sample.env')
  1. Fetch Kubernetes Configuration

const { kubeconfig, config, namespace } = await getConfig()
  1. Map Stateful Services to Deployment Arguments

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

Service-Specific Argument Construction

1. daemon Service

2. op-node Service

3. indexer Service

Unsupported Service Handling


Final Deployment Invocation

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

Parameters and Types

Identifier

Type

Description

`appName`

`string`

Application name, here 'unchained'

`coinstack`

`string`

Identifier for the blockchain coinstack, here 'base'

`sampleEnv`

`Buffer`

Contents of `sample.env` file, for environment variables

`kubeconfig`

`string`

Kubernetes cluster config used for deployment

`config`

`object`

Deployment config, including stateful service definitions

`namespace`

`string`

Kubernetes namespace to deploy into

`coinServiceArgs`

`CoinServiceArgs[]`

Array of service deployment argument objects

`deployCoinstack`

`function`

Pulumi helper that deploys the coinstack

`Outputs`

`type`

Pulumi deployment outputs, including resource info


Usage Example

This file is typically executed by the Pulumi CLI during deployment:

pulumi up

Pulumi will:


Implementation Details and Algorithms


Interaction with Other Parts of the System


Mermaid Flowchart: Deployment Workflow in index.ts

flowchart TD
  A[Start Deployment] --> B[Read sample.env File]
  B --> C[Fetch kubeconfig, config, namespace]
  C --> D[Map statefulService.services to CoinServiceArgs]
  D --> E{Service Name}
  E -->|daemon| F[Configure daemon service args]
  E -->|op-node| G[Configure op-node service args]
  E -->|indexer| H[Configure indexer service args]
  E -->|unsupported| I[Throw Error]
  F --> J[Aggregate all service args]
  G --> J
  H --> J
  J --> K[Call deployCoinstack with args]
  K --> L[Provision Kubernetes Resources]
  L --> M[Deployment Complete]

Summary

This `index.ts` Pulumi program file automates deploying the Ethereum Base Layer 1 coinstack by:

It is a critical piece in the modular multi-blockchain infrastructure, enabling reliable, repeatable, and scalable deployment of Ethereum base chain node services on Kubernetes.


Appendix: Key Imported Entities

Import

From

Description

`readFileSync`

`'fs'`

Node.js filesystem synchronous file read

`deployCoinstack`

'../../../../pulumi/src/coinstack'

Core Pulumi deployment function for coinstacks

`Outputs`

'../../../../pulumi/src'

Pulumi deployment output type

`CoinServiceArgs`

'../../../../pulumi/src'

Type for service deployment arguments

`getConfig`

'../../../../pulumi/src'

Async helper to fetch Kubernetes and deployment config

`defaultBlockbookServiceArgs`

'../../../packages/blockbook/src/constants'

Default Blockbook indexer service args


End of Documentation for index.ts