-
Notifications
You must be signed in to change notification settings - Fork 160
Description
Asset Hub Migration: Remaining Tasks for Single Instance Multi Chain Support
Overview
Complete the remaining work for Asset Hub Migration support in substrate-api-sidecar. The goal is to ensure everything is reachable from a single instance of sidecar. Currently, everything works with the exception of staking progress when using 2 instances. These tasks address historical data access and cross-chain query capabilities needed for a seamless transition to single-instance operation.
Tasks
1. Add Historical Support for Staking Progress Endpoint (#1695)
Endpoint: /pallets/staking/progress?at={height}
Problem: Currently lacks historical support for querying staking progress at specific block heights.
Solution:
- Hardcode BABE information for epochs and sessions
- Eliminate the need for multi-chain queries by using static configuration
- Enable historical lookups without cross-chain dependencies
Acceptance Criteria:
- Endpoint supports
at={height}
parameter for historical queries - BABE epoch and session data is hardcoded and accessible
- No multi-chain queries required for historical staking progress (with the exception of skippedEpochs)
2. Implement useRcBlock Query Parameter Support
Goal: Enable cross-chain state queries by allowing Asset Hub endpoints to query state at specific relay chain block heights using the useRcBlock
parameter in conjunction with the existing at
parameter.
Implementation:
- Add
useRcBlock
parameter support across all relevant endpoints - When
useRcBlock=true
, treat theat
parameter as a relay chain block identifier - Ensure responses include additional metadata (
rcBlockNumber
,ahTimestamp
) - Maintain backward compatibility with existing functionality
Acceptance Criteria:
-
useRcBlock
parameter implemented across all applicable endpoints - Responses include relay chain block number and Asset Hub timestamp metadata
- Smart block mapping handles 2:1 RC-to-AH block ratio
- Multi-block scenarios handled when Asset Hub produces multiple blocks per RC block
- Documentation updated with parameter usage and examples
3. Implement useRcBlock Query Parameter Support for Block Endpoints
Goal: Enable block endpoints to accept relay chain block identifiers instead of Asset Hub block identifiers.
Implementation:
- Add
useRcBlock
parameter to all block-related endpoints - Implement relay chain to Asset Hub block mapping
- Include enhanced response metadata when parameter is used
Acceptance Criteria:
-
useRcBlock
parameter implemented on all block endpoints - Block identifier mapping from relay chain to Asset Hub blocks
- Range endpoints skip RC blocks without corresponding AH blocks
- Enhanced responses include
rcBlockNumber
andahTimestamp
fields - Backward compatibility maintained (defaults to
false
) - OpenAPI specifications updated with new parameter
4. Cross-Chain Historical Data Handling
Problem: When endpoints require era
fields or need to retrieve historical data that spans the migration boundary (Asset Hub → Relay Chain), sidecar needs intelligent handling.
Requirements:
- Determine migration start and end points
- Map relay chain blocks to corresponding parachain block numbers
- Handle historical queries that cross the migration boundary
Implementation Strategy:
- Identify the exact migration start/end blocks
- Create a mapping system between relay chain and parachain block numbers
- Implement logic to route historical queries to the appropriate chain
Acceptance Criteria:
- Migration start/end blocks are identified and stored
- Block number mapping between relay chain and parachain is implemented
- Historical queries automatically route to correct chain based on block height
- Era-based queries work seamlessly across migration boundary
5. Create Mirrored Relay Chain Endpoints
Goal: Enable a single Asset Hub sidecar instance to access both Asset Hub and Relay Chain historical data.
Implementation:
- Create mirrored endpoints that proxy relay chain requests
- Allow Asset Hub sidecar to serve historical relay chain data
- Maintain API consistency while supporting dual-chain access
Acceptance Criteria:
- Asset Hub sidecar instance can serve relay chain historical data
- Mirrored endpoints maintain consistent API structure
- Single sidecar deployment supports both chains
- Documentation updated with new endpoint capabilities
Substrate API Sidecar Endpoints
Accounts Endpoints (#1701)
-
/accounts/{accountId}/asset-balances
-
useRcBlock
parameter
-
-
/accounts/{accountId}/asset-approvals
-
useRcBlock
parameter
-
-
/accounts/{accountId}/balance-info
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/accounts/{accountId}/pool-asset-balances
-
useRcBlock
parameter
-
-
/accounts/{accountId}/pool-asset-approvals
-
useRcBlock
parameter
-
-
/accounts/{accountId}/proxy-info
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/accounts/{accountId}/staking-info
-
useRcBlock
parameter
-
-
/accounts/{accountId}/staking-payouts
-
useRcBlock
parameter
-
-
/accounts/{accountId}/vesting-info
-
useRcBlock
parameter
-
Blocks Endpoints (#1702)
-
/blocks
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/blocks/{blockId}
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/blocks/{blockId}/header
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/blocks/{blockId}/extrinsics/{extrinsicIndex}
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/blocks/head
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/blocks/head/header
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/blocks/{blockId}/extrinsics-raw
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
Node Endpoints
-
/node/network
- Mirrored
/rc
endpoint
- Mirrored
-
/node/transaction-pool
- Mirrored
/rc
endpoint
- Mirrored
-
/node/version
- Mirrored
/rc
endpoint
- Mirrored
Runtime Endpoints
-
/runtime/metadata
- Mirrored
/rc
endpoint
- Mirrored
-
/runtime/metadata/{metadataVersion}
- Mirrored
/rc
endpoint
- Mirrored
-
/runtime/metadata/versions
- Mirrored
/rc
endpoint
- Mirrored
-
/runtime/spec
- Mirrored
/rc
endpoint
- Mirrored
-
/runtime/code
- Mirrored
/rc
endpoint
- Mirrored
Pallets Endpoints
-
/pallets/assets/{assetId}/asset-info
-
useRcBlock
parameter
-
-
/pallets/asset-conversion/liquidity-pools
-
useRcBlock
parameter
-
-
/pallets/asset-conversion/next-available-id
-
useRcBlock
parameter
-
-
/pallets/foreign-assets
-
useRcBlock
parameter
-
-
/pallets/nomination-pools/info
-
useRcBlock
parameter
-
-
/pallets/nomination-pools/{poolId}
-
useRcBlock
parameter
-
-
/pallets/on-going-referenda
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/pallets/{palletId}/consts
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/pallets/{palletId}/consts/{constantItemId}
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/pallets/{palletId}/dispatchables
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/pallets/{palletId}/dispatchables/{dispatchableItemId}
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/pallets/{palletId}/errors
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/pallets/{palletId}/errors/{errorItemId}
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/pallets/{palletId}/events
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/pallets/{palletId}/events/{eventItemId}
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/pallets/{palletId}/storage
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/pallets/{palletId}/storage/{storageItemId}
- Mirrored
/rc
endpoint -
useRcBlock
parameter
- Mirrored
-
/pallets/pool-assets/{assetId}/asset-info
-
useRcBlock
parameter
-
-
/pallets/staking/progress
-
useRcBlock
parameter (#1700)
-
-
/pallets/staking/validators
-
useRcBlock
parameter
-