Skip to content

r0gue-io/coretime-scripts

Repository files navigation

TypeScript Core Detector

A TypeScript implementation for detecting multiple core assignments using Polkadot API (PAPI).

Features

  • Core-to-Task Mapping: Shows which tasks are assigned to each core (ordered by core ID)
  • Duplicate Detection: Identifies tasks assigned to multiple cores
  • Current & Future Workloads: Analyzes both current and upcoming core assignments
  • Lease Information: Displays current lease data from the coretime chain

Installation

npm install

Usage

Development (with ts-node)

npm run dev

Production

npm run build
npm start

Output Format

Core-to-Task Mapping

=== CORE TO TASK MAPPING (Current Workload) ===
Core 0: [4509]
Core 1: No tasks
Core 2: [4605]
...

Duplicate Analysis

=== DUPLICATE ANALYSIS (Current Workload) ===
Task 1111: [14, 51]
Task 2034: [30, 31]
Task 2043: [35, 47]
...

Configuration

The script connects to:

  • Relay Chain: wss://rpc.ibp.network/paseo
  • Coretime Chain: wss://sys.ibp.network/coretime-paseo

You can modify these URLs in src/index.ts if needed.

Key Improvements over Python Version

  1. Proper Core ID Querying: Uses PAPI's getValue(coreId) method to query individual cores by actual ID
  2. Type Safety: Full TypeScript typing for better development experience
  3. Modern Async/Await: Clean promise-based API calls
  4. Lightweight: Uses PAPI's efficient light client approach
  5. Better Error Handling: Graceful handling of failed queries per core

Technical Details

The script:

  1. Connects to the Paseo relay chain
  2. Gets the total number of cores from CoreDescriptors.getEntries()
  3. Queries each core individually by ID (0 to numCores-1)
  4. Extracts task assignments from each core's current_work.assignments
  5. Creates both core→task and task→core mappings
  6. Identifies and displays duplicate task assignments

About

Scripts related to Polakdot's coretime.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published