From c8b662b11132aa2043c2f34ded85b4c12c716cd7 Mon Sep 17 00:00:00 2001 From: Sergej Date: Sun, 22 Jun 2025 19:48:09 +0200 Subject: [PATCH 1/5] use chopstick for e2e testing --- chopsticks/configs/coretime-kusama.yml | 32 ++++ chopsticks/configs/regionx-local.yml | 11 ++ chopsticks/tests/coretime.utils.ts | 38 ++++ .../tests/ismp.utils.ts | 10 +- chopsticks/tests/region-transfer.ts | 120 ++++++++++++ {e2e_tests => chopsticks/tests}/types.ts | 0 chopsticks/tests/utils.ts | 75 ++++++++ e2e_tests/common.ts | 175 ------------------ e2e_tests/consts.ts | 19 -- e2e_tests/coretime.common.ts | 51 ----- e2e_tests/fee-payment/index.ts | 59 ------ e2e_tests/governance/delegated.ts | 52 ------ e2e_tests/governance/native.ts | 36 ---- e2e_tests/order/processing.ts | 107 ----------- e2e_tests/xc-regions.common.ts | 170 ----------------- e2e_tests/xc-transfer/asset-transfer.ts | 99 ---------- e2e_tests/xc-transfer/region-transfer.ts | 60 ------ network.toml | 26 +++ package.json | 3 +- 19 files changed, 308 insertions(+), 835 deletions(-) create mode 100644 chopsticks/configs/coretime-kusama.yml create mode 100644 chopsticks/configs/regionx-local.yml create mode 100644 chopsticks/tests/coretime.utils.ts rename e2e_tests/ismp.common.ts => chopsticks/tests/ismp.utils.ts (91%) create mode 100644 chopsticks/tests/region-transfer.ts rename {e2e_tests => chopsticks/tests}/types.ts (100%) create mode 100644 chopsticks/tests/utils.ts delete mode 100644 e2e_tests/common.ts delete mode 100644 e2e_tests/consts.ts delete mode 100644 e2e_tests/coretime.common.ts delete mode 100644 e2e_tests/fee-payment/index.ts delete mode 100644 e2e_tests/governance/delegated.ts delete mode 100644 e2e_tests/governance/native.ts delete mode 100644 e2e_tests/order/processing.ts delete mode 100644 e2e_tests/xc-regions.common.ts delete mode 100644 e2e_tests/xc-transfer/asset-transfer.ts delete mode 100644 e2e_tests/xc-transfer/region-transfer.ts create mode 100644 network.toml diff --git a/chopsticks/configs/coretime-kusama.yml b/chopsticks/configs/coretime-kusama.yml new file mode 100644 index 00000000..4273ebcf --- /dev/null +++ b/chopsticks/configs/coretime-kusama.yml @@ -0,0 +1,32 @@ +endpoint: wss://sys.ibp.network/coretime-kusama +mock-signature-host: true +db: ./db.sqlite + +import-storage: + System: + Account: + - - - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY + - providers: 1 + data: + free: 1000000000000000 + Broker: + Configuration: + advance_notice: 20 + interlude_length: 10 + leadin_length: 10 + ideal_bulk_proportion: 0 + limit_cores_offered: 50 + region_length: 30 + renewal_bump: 10 + contribution_timeout: 5 + SaleInfo: + saleStart: 2831089 + leadinLength: 50400 + endPrice: 93489341 + regionBegin: 361368 + regionEnd: 366408 + idealCoresSold: 38 + coresOffered: 94 + firstCore: 6 + selloutPrice: 962940212 + coresSold: 42 diff --git a/chopsticks/configs/regionx-local.yml b/chopsticks/configs/regionx-local.yml new file mode 100644 index 00000000..05c0af9b --- /dev/null +++ b/chopsticks/configs/regionx-local.yml @@ -0,0 +1,11 @@ +endpoint: ws://127.0.0.1:9955 +mock-signature-host: true +db: ./db.sqlite + +import-storage: + System: + Account: + - - - 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY + - providers: 1 + data: + free: 1000000000000000 diff --git a/chopsticks/tests/coretime.utils.ts b/chopsticks/tests/coretime.utils.ts new file mode 100644 index 00000000..c7a6c25b --- /dev/null +++ b/chopsticks/tests/coretime.utils.ts @@ -0,0 +1,38 @@ +import { ApiPromise } from "@polkadot/api"; +import { KeyringPair } from "@polkadot/keyring/types"; +import { RegionId } from "coretime-utils"; + +const UNIT = 10n ** 12n; // KSM has 12 decimals +const INITIAL_PRICE = 1n * UNIT; + +export async function purchaseRegion( + coretimeApi: ApiPromise, + buyer: KeyringPair +): Promise { + const callTx = async (resolve: (regionId: RegionId | null) => void) => { + const purchase = coretimeApi.tx.broker.purchase(INITIAL_PRICE * 10n); + const unsub = await purchase.signAndSend(buyer, async (result: any) => { + if (result.status.isInBlock) { + const regionId = await getRegionId(coretimeApi); + unsub(); + resolve(regionId); + } + }); + }; + + return new Promise(callTx); +} + +async function getRegionId(coretimeApi: ApiPromise): Promise { + const events: any = await coretimeApi.query.system.events(); + + for (const record of events) { + const { event } = record; + if (event.section === 'broker' && event.method === 'Purchased') { + const data = event.data[1].toHuman(); + return data; + } + } + + return null; +} diff --git a/e2e_tests/ismp.common.ts b/chopsticks/tests/ismp.utils.ts similarity index 91% rename from e2e_tests/ismp.common.ts rename to chopsticks/tests/ismp.utils.ts index 4c96763f..fcee40c9 100644 --- a/e2e_tests/ismp.common.ts +++ b/chopsticks/tests/ismp.utils.ts @@ -1,10 +1,10 @@ import { ApiPromise } from '@polkadot/api'; import { KeyringPair } from '@polkadot/keyring/types'; -import { submitExtrinsic, submitUnsigned } from './common'; +import { submitExtrinsic, submitUnsigned } from './utils'; import { Get, IsmpRequest } from './types'; async function ismpAddParachain(signer: KeyringPair, regionXApi: ApiPromise) { - const addParaCall = regionXApi.tx.ismpParachain.addParachain([1005]); + const addParaCall = regionXApi.tx.ismpParachain.addParachain([{ id: 1005, slotDuration: 6000 }]); const sudoCall = regionXApi.tx.sudo.sudo(addParaCall); return submitExtrinsic(signer, sudoCall, {}); } @@ -45,10 +45,8 @@ async function makeIsmpResponse( proof: { height: { id: { - stateId: { - Kusama: 1005, - }, - consensusStateId: 'PARA', + stateId: 1005, + consensusStateId: 'PAS0', }, height: request.get.height.toString(), }, diff --git a/chopsticks/tests/region-transfer.ts b/chopsticks/tests/region-transfer.ts new file mode 100644 index 00000000..2283ce43 --- /dev/null +++ b/chopsticks/tests/region-transfer.ts @@ -0,0 +1,120 @@ +import { ApiPromise, Keyring, WsProvider } from "@polkadot/api"; +import { cryptoWaitReady } from "@polkadot/util-crypto"; +import { sleep, submitExtrinsic, submitUnsigned } from "./utils"; +import { KeyringPair } from "@polkadot/keyring/types"; +import { getEncodedRegionId, RegionId } from "coretime-utils"; +import { makeIsmpResponse, queryRequest } from "./ismp.utils"; +import { purchaseRegion } from "./coretime.utils"; + +const RELAY_ENDPOINT = "ws://127.0.0.1:8002"; +const CORETIME_ENDPOINT = "ws://127.0.0.1:8000"; +const REGIONX_ENDPOINT = "ws://127.0.0.1:8001"; + +export const keyring = new Keyring({ type: "sr25519" }); + +async function run() { + await cryptoWaitReady(); + + const coretimeWsProvider = new WsProvider(CORETIME_ENDPOINT); + const coretimeApi = await ApiPromise.create({ provider: coretimeWsProvider }); + + const regionxWsProvider = new WsProvider(REGIONX_ENDPOINT); + const regionxApi = await ApiPromise.create({ provider: regionxWsProvider }); + + const alice = keyring.addFromUri("//Alice"); + + const regionId = await purchaseRegion(coretimeApi, alice); + if (!regionId) throw new Error('RegionId not found'); + + await transferRegionToRegionX(coretimeApi, regionxApi, alice, regionId); +} + +async function transferRegionToRegionX( + coretimeApi: ApiPromise, + regionXApi: ApiPromise, + sender: KeyringPair, + regionId: RegionId +) { + const receiverKeypair = new Keyring(); + receiverKeypair.addFromAddress(sender.address); + + const feeAssetItem = 0; + const weightLimit = 'Unlimited'; + const reserveTransferToRegionX = coretimeApi.tx.polkadotXcm.limitedReserveTransferAssets( + { V3: { parents: 1, interior: { X1: { Parachain: 2000 } } } }, //dest + { + V3: { + parents: 0, + interior: { + X1: { + AccountId32: { + chain: 'Any', + id: receiverKeypair.pairs[0].publicKey, + }, + }, + }, + }, + }, //beneficiary + { + V3: [ + { + id: { + Concrete: { + parents: 1, + interior: 'Here', + }, + }, + fun: { + Fungible: 10n ** 10n, + }, + }, // ^^ fee payment asset + { + id: { + Concrete: { + parents: 0, + interior: { X1: { PalletInstance: 50 } }, + }, + }, + fun: { + NonFungible: { + Index: getEncodedRegionId(regionId, coretimeApi).toString(), + }, + }, + }, + ], + }, //asset + feeAssetItem, + weightLimit + ); + await submitExtrinsic(sender, reserveTransferToRegionX, {}); + + await sleep(5000); + + const requestRecord = regionXApi.tx.regions.requestRegionRecord(regionId); + await submitUnsigned(requestRecord); + + let regions = await regionXApi.query.regions.regions.entries(); + // assert.equal(regions.length, 1); + // assert.deepStrictEqual(regions[0][0].toHuman(), [regionId]); + + let region = regions[0][1].toHuman() as any; + // assert(region.owner == sender.address); + // assert(typeof region.record.Pending === 'string'); + + // Check the data on the Coretime chain: + regions = await coretimeApi.query.broker.regions.entries(); + // assert.equal(regions.length, 1); + // assert.deepStrictEqual(regions[0][0].toHuman(), [regionId]); + // assert.equal((regions[0][1].toHuman() as any).owner, REGIONX_SOVEREIGN_ACCOUNT); + + // Respond to the ISMP get request: + const request = await queryRequest(regionXApi, region.record.Pending); + await makeIsmpResponse(regionXApi, coretimeApi, request, sender.address); + + // The record should be set after ISMP response: + regions = await regionXApi.query.regions.regions.entries(); + region = regions[0][1].toHuman() as any; + // assert(region.owner == sender.address); +} + +run().then(() => process.exit(0)); diff --git a/e2e_tests/types.ts b/chopsticks/tests/types.ts similarity index 100% rename from e2e_tests/types.ts rename to chopsticks/tests/types.ts diff --git a/chopsticks/tests/utils.ts b/chopsticks/tests/utils.ts new file mode 100644 index 00000000..d7d48a21 --- /dev/null +++ b/chopsticks/tests/utils.ts @@ -0,0 +1,75 @@ +import { ApiPromise, Keyring } from "@polkadot/api"; +import { SignerOptions, SubmittableExtrinsic } from "@polkadot/api/types"; +import { KeyringPair } from "@polkadot/keyring/types"; + +export const keyring = new Keyring({ type: "sr25519" }); + +export function log(message: string) { + // Green log. + console.log("\x1b[32m%s\x1b[0m", message); +} + +export async function setBalance(api: ApiPromise, who: string, balance: string) { + log(`Setting balance of ${who} to ${balance}`); + + const setBalanceCall = api.tx.balances.forceSetBalance(who, balance); + return force(api, setBalanceCall); +} + +export async function submitExtrinsic( + signer: KeyringPair, + call: SubmittableExtrinsic<"promise">, + options: Partial +): Promise { + try { + return new Promise((resolve, _reject) => { + const unsub = call.signAndSend(signer, options, (result) => { + console.log(`Current status is ${result.status}`); + if (result.status.isInBlock) { + console.log(`Transaction included at blockHash ${result.status.asInBlock}`); + } else if (result.status.isFinalized) { + console.log(`Transaction finalized at blockHash ${result.status.asFinalized}`); + unsub.then(); + return resolve(); + } else if (result.isError) { + console.log("Transaction error"); + unsub.then(); + return resolve(); + } + }); + }); + } catch (e) { + console.log(e); + } +} + +export async function submitUnsigned(call: SubmittableExtrinsic<'promise'>): Promise { + return new Promise((resolve, reject) => { + const unsub = call.send(({ status, isError }) => { + console.log(`Current status is ${status}`); + if (status.isInBlock) { + console.log(`Transaction included at blockHash ${status.asInBlock}`); + } else if (status.isFinalized) { + console.log(`Transaction finalized at blockHash ${status.asFinalized}`); + unsub.then(); + return resolve(); + } else if (isError) { + console.log('Transaction error'); + unsub.then(); + return reject(); + } + }); + }); +} + +export async function force(api: ApiPromise, call: SubmittableExtrinsic<"promise">): Promise { + const sudoCall = api.tx.sudo.sudo(call); + + const alice = keyring.addFromUri("//Alice"); + + await submitExtrinsic(alice, sudoCall, {}); +} + +export async function sleep(milliseconds: number) { + return new Promise((resolve) => setTimeout(resolve, milliseconds)); +} diff --git a/e2e_tests/common.ts b/e2e_tests/common.ts deleted file mode 100644 index 9ca51cd3..00000000 --- a/e2e_tests/common.ts +++ /dev/null @@ -1,175 +0,0 @@ -import { ApiPromise, Keyring } from '@polkadot/api'; -import { SignerOptions, SubmittableExtrinsic } from '@polkadot/api/types'; -import { KeyringPair } from '@polkadot/keyring/types'; -import { stringToU8a } from '@polkadot/util'; -import { encodeAddress } from '@polkadot/util-crypto'; - -const RELAY_ASSET_ID = 1; - -async function submitExtrinsic( - signer: KeyringPair, - call: SubmittableExtrinsic<'promise'>, - options: Partial -): Promise { - return new Promise((resolve, reject) => { - const unsub = call.signAndSend(signer, options, ({ status, isError }) => { - console.log(`Current status is ${status}`); - if (status.isInBlock) { - console.log(`Transaction included at blockHash ${status.asInBlock}`); - } else if (status.isFinalized) { - console.log(`Transaction finalized at blockHash ${status.asFinalized}`); - unsub.then(); - return resolve(); - } else if (isError) { - console.log('Transaction error'); - unsub.then(); - return reject(); - } - }); - }); -} - -async function submitUnsigned( - call: SubmittableExtrinsic<'promise'>, -): Promise { - return new Promise((resolve, reject) => { - const unsub = call.send(({ status, isError }) => { - console.log(`Current status is ${status}`); - if (status.isInBlock) { - console.log(`Transaction included at blockHash ${status.asInBlock}`); - } else if (status.isFinalized) { - console.log(`Transaction finalized at blockHash ${status.asFinalized}`); - unsub.then(); - return resolve(); - } else if (isError) { - console.log('Transaction error'); - unsub.then(); - return reject(); - } - }); - }); -} - -async function setupRelayAsset(api: ApiPromise, signer: KeyringPair, initialBalance = 0n) { - // The relay asset is registered in the genesis block. - - const assetSetupCalls = [ - api.tx.assetRate.create(RELAY_ASSET_ID, 1_000_000_000_000_000_000n), // 1 on 1 - ]; - - if (initialBalance > BigInt(0)) { - assetSetupCalls.push( - api.tx.tokens.setBalance(signer.address, RELAY_ASSET_ID, initialBalance, 0) - ); - } - - const batchCall = api.tx.utility.batch(assetSetupCalls); - const sudoCall = api.tx.sudo.sudo(batchCall); - - await submitExtrinsic(signer, sudoCall, {}); -} - -// Transfer the relay chain asset to the parachain specified by paraId. -// Receiver address is same as the sender's. -async function transferRelayAssetToPara( - relayApi: ApiPromise, - signer: KeyringPair, - paraId: number, - receiver: string, - amount: bigint -) { - const receiverKeypair = new Keyring(); - receiverKeypair.addFromAddress(receiver); - - // If system parachain we use teleportation, otherwise we do a reserve transfer. - const transferKind = paraId < 2000 ? 'limitedTeleportAssets' : 'limitedReserveTransferAssets'; - - const feeAssetItem = 0; - const weightLimit = 'Unlimited'; - const reserveTransfer = relayApi.tx.xcmPallet[transferKind]( - { V3: { parents: 0, interior: { X1: { Parachain: paraId } } } }, //dest - { - V3: { - parents: 0, - interior: { - X1: { - AccountId32: { - chain: 'Any', - id: receiverKeypair.pairs[0].publicKey, - }, - }, - }, - }, - }, //beneficiary - { - V3: [ - { - id: { - Concrete: { parents: 0, interior: 'Here' }, - }, - fun: { - Fungible: amount, - }, - }, - ], - }, //asset - feeAssetItem, - weightLimit - ); - await submitExtrinsic(signer, reserveTransfer, {}); -} - -async function openHrmpChannel( - signer: KeyringPair, - relayApi: ApiPromise, - senderParaId: number, - recipientParaId: number -) { - const openHrmp = relayApi.tx.parasSudoWrapper.sudoEstablishHrmpChannel( - senderParaId, // sender - recipientParaId, // recipient - 8, // Max capacity - 102400 // Max message size - ); - const sudoCall = relayApi.tx.sudo.sudo(openHrmp); - - return submitExtrinsic(signer, sudoCall, {}); -} - -async function sleep(milliseconds: number) { - return new Promise((resolve) => setTimeout(resolve, milliseconds)); -} - -const getAddressFromModuleId = (moduleId: string): string => { - if (moduleId.length !== 8) { - console.log('Module Id must be 8 characters (i.e. `py/trsry`)'); - return ''; - } - const address = stringToU8a(('modl' + moduleId).padEnd(32, '\0')); - return encodeAddress(address); -}; - -const getFreeBalance = async (api: ApiPromise, address: string): Promise => { - const { - data: { free }, - } = (await api.query.system.account(address)).toJSON() as any; - return BigInt(free); -}; - -function log(message: string) { - // Green log. - console.log('\x1b[32m%s\x1b[0m', message); -} - -export { - RELAY_ASSET_ID, - log, - setupRelayAsset, - sleep, - openHrmpChannel, - submitExtrinsic, - submitUnsigned, - transferRelayAssetToPara, - getAddressFromModuleId, - getFreeBalance, -}; diff --git a/e2e_tests/consts.ts b/e2e_tests/consts.ts deleted file mode 100644 index 8861504f..00000000 --- a/e2e_tests/consts.ts +++ /dev/null @@ -1,19 +0,0 @@ -const UNIT = 10n ** 12n; // ROC has 12 decimals - -const INITIAL_PRICE = 1n * UNIT; -const CORE_COUNT = 10; -const TIMESLICE_PERIOD = 80; -const IDEAL_CORES_SOLD = 5; - -const CONFIG = { - advance_notice: 20, - interlude_length: 0, - leadin_length: 10, - ideal_bulk_proportion: 0, - limit_cores_offered: 50, - region_length: 30, - renewal_bump: 10, - contribution_timeout: 5, -}; - -export { CONFIG, CORE_COUNT, IDEAL_CORES_SOLD, INITIAL_PRICE, TIMESLICE_PERIOD, UNIT }; diff --git a/e2e_tests/coretime.common.ts b/e2e_tests/coretime.common.ts deleted file mode 100644 index 41f68a13..00000000 --- a/e2e_tests/coretime.common.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { ApiPromise } from '@polkadot/api'; -import { KeyringPair } from '@polkadot/keyring/types'; -import { RegionId } from 'coretime-utils'; -import { submitExtrinsic } from './common'; -import { CONFIG, CORE_COUNT, INITIAL_PRICE } from './consts'; - -async function configureBroker(coretimeApi: ApiPromise, signer: KeyringPair): Promise { - const configCall = coretimeApi.tx.broker.configure(CONFIG); - const sudo = coretimeApi.tx.sudo.sudo(configCall); - return submitExtrinsic(signer, sudo, {}); -} - -async function startSales(coretimeApi: ApiPromise, signer: KeyringPair): Promise { - const startSaleCall = coretimeApi.tx.broker.startSales(INITIAL_PRICE, CORE_COUNT); - const sudo = coretimeApi.tx.sudo.sudo(startSaleCall); - return submitExtrinsic(signer, sudo, {}); -} - -async function purchaseRegion( - coretimeApi: ApiPromise, - buyer: KeyringPair -): Promise { - const callTx = async (resolve: (regionId: RegionId | null) => void) => { - const purchase = coretimeApi.tx.broker.purchase(INITIAL_PRICE * 10n); - const unsub = await purchase.signAndSend(buyer, async (result: any) => { - if (result.status.isInBlock) { - const regionId = await getRegionId(coretimeApi); - unsub(); - resolve(regionId); - } - }); - }; - - return new Promise(callTx); -} - -async function getRegionId(coretimeApi: ApiPromise): Promise { - const events: any = await coretimeApi.query.system.events(); - - for (const record of events) { - const { event } = record; - if (event.section === 'broker' && event.method === 'Purchased') { - const data = event.data[1].toHuman(); - return data; - } - } - - return null; -} - -export { configureBroker, startSales, purchaseRegion }; diff --git a/e2e_tests/fee-payment/index.ts b/e2e_tests/fee-payment/index.ts deleted file mode 100644 index 1bc32168..00000000 --- a/e2e_tests/fee-payment/index.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { ApiPromise, Keyring, WsProvider } from '@polkadot/api'; -import assert from 'node:assert'; -import { getAddressFromModuleId, getFreeBalance } from '../common'; - -async function run(nodeName: string, networkInfo: any, _jsArgs: any) { - const { wsUri: regionXUri } = networkInfo.nodesByName[nodeName]; - const regionXApi = await ApiPromise.create({ provider: new WsProvider(regionXUri) }); - - // account to submit tx - const keyring = new Keyring({ type: 'sr25519' }); - const alice = keyring.addFromUri('//Alice'); - - const podId = 'PotStake'; // FIXME: remove this hard-coded constant and fetch the on-chain value. - const potAccount = getAddressFromModuleId(podId); - - const potBalanceOld = await getFreeBalance(regionXApi, potAccount); - - const call = regionXApi.tx.system.remark('0x44'); - - let fee = BigInt(0), - tips = BigInt(0); - - const promise: Promise = new Promise((resolve, reject) => { - const unsub = call.signAndSend(alice, { tip: 1_000_000_000 }, ({ status, isError, events }) => { - console.log(`Current status is ${status}`); - if (status.isInBlock) { - console.log(`Transaction included at blockHash ${status.asInBlock}`); - } else if (status.isFinalized) { - console.log(`Transaction finalized at blockHash ${status.asFinalized}`); - for (const event of events) { - const { - event: { data, method, section }, - } = event; - if (section === 'transactionPayment' && method === 'TransactionFeePaid') { - const args = data.toJSON() as [string, number, number]; - tips = BigInt(args[2]); - fee = BigInt(args[1]) - tips; - } - } - - unsub.then(); - return resolve(); - } else if (isError) { - console.log('Transaction error'); - unsub.then(); - return reject(); - } - }); - }); - await promise; - const potBalanceNew = await getFreeBalance(regionXApi, potAccount); - - const fee2Treasury = (fee * 60n) / 100n; - const fee2Collators = fee - fee2Treasury + tips; - - assert.equal(potBalanceNew - potBalanceOld, fee2Collators); -} - -export { run }; diff --git a/e2e_tests/governance/delegated.ts b/e2e_tests/governance/delegated.ts deleted file mode 100644 index 14f0f2b9..00000000 --- a/e2e_tests/governance/delegated.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { ApiPromise, Keyring, WsProvider } from '@polkadot/api'; -import { RELAY_ASSET_ID, setupRelayAsset, submitExtrinsic } from '../common'; - -const PREIMAGE_HASH = '0xb8375f7ca0c64a384f2dd643a0d520977f3aae06e64afb8c960891eee5147bd1'; - -async function run(nodeName: string, networkInfo: any, _jsArgs: any) { - const { wsUri } = networkInfo.nodesByName[nodeName]; - const api = await ApiPromise.create({ - provider: new WsProvider(wsUri), - signedExtensions: { - ChargeAssetTxPayment: { - extrinsic: { - tip: 'Compact', - assetId: 'Option', - }, - payload: {}, - }, - }, - }); - - // account to submit tx - const keyring = new Keyring({ type: 'sr25519' }); - const alice = keyring.addFromUri('//Alice'); - const anna = keyring.addFromUri('//Anna'); - - await setupRelayAsset(api, alice); - - const giveBalanceCall = api.tx.tokens.setBalance(anna.address, RELAY_ASSET_ID, 10n ** 18n, 0); - await submitExtrinsic(alice, api.tx.sudo.sudo(giveBalanceCall), {}); - - const remarkCallBytes = api.tx.system.remark('hey').toU8a(); - await submitExtrinsic(alice, api.tx.preimage.notePreimage(remarkCallBytes), {}); - - const submitProposal = api.tx.delegatedReferenda.submit( - { system: 'Root' }, - { Lookup: { hash: PREIMAGE_HASH, len: remarkCallBytes.length } }, - { After: 5 } - ); - await submitExtrinsic(anna, submitProposal, { assetId: RELAY_ASSET_ID }); - - const placeDeposit = api.tx.delegatedReferenda.placeDecisionDeposit(0); - await submitExtrinsic(anna, placeDeposit, { assetId: RELAY_ASSET_ID }); - - const voteCall = api.tx.delegatedConvictionVoting.vote(0, { - // Voting with relay chain tokens. We know this is true; otherwise, this call - // would fail, given that Anna doesn't have 10^16 RegionX tokens. - Standard: { vote: { aye: true, conviction: 'None' }, balance: 10n ** 16n }, - }); - await submitExtrinsic(anna, voteCall, { assetId: RELAY_ASSET_ID }); -} - -export { run }; diff --git a/e2e_tests/governance/native.ts b/e2e_tests/governance/native.ts deleted file mode 100644 index 2e0a7053..00000000 --- a/e2e_tests/governance/native.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { ApiPromise, Keyring, WsProvider } from '@polkadot/api'; -import { setupRelayAsset, submitExtrinsic } from '../common'; - -const PREIMAGE_HASH = '0x0ccf4369e9a9f88f035828ba0dd5da645d5c0fa7baa86bdc8d7a80c183ab84c9'; - -async function run(nodeName: string, networkInfo: any, _jsArgs: any) { - const { wsUri } = networkInfo.nodesByName[nodeName]; - const api = await ApiPromise.create({ provider: new WsProvider(wsUri) }); - - // account to submit tx - const keyring = new Keyring({ type: 'sr25519' }); - const alice = keyring.addFromUri('//Alice'); - - // relay asset is needed for storing the preimage. - await setupRelayAsset(api, alice); - - const spendCallBytes = api.tx.treasury.spendLocal(10n ** 6n, alice.address).toU8a(); - await submitExtrinsic(alice, api.tx.preimage.notePreimage(spendCallBytes), {}); - - const submitProposal = api.tx.nativeReferenda.submit( - { Origins: 'SmallTipper' }, - { Lookup: { hash: PREIMAGE_HASH, len: spendCallBytes.length } }, - { After: 5 } - ); - await submitExtrinsic(alice, submitProposal, {}); - - const placeDeposit = api.tx.nativeReferenda.placeDecisionDeposit(0); - await submitExtrinsic(alice, placeDeposit, {}); - - const voteCall = api.tx.nativeConvictionVoting.vote(0, { - Standard: { vote: { aye: true, conviction: 'None' }, balance: 10n ** 16n }, - }); - await submitExtrinsic(alice, voteCall, {}); -} - -export { run }; diff --git a/e2e_tests/order/processing.ts b/e2e_tests/order/processing.ts deleted file mode 100644 index ac98fedc..00000000 --- a/e2e_tests/order/processing.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { ApiPromise, Keyring, WsProvider } from '@polkadot/api'; -import assert from 'node:assert'; -import { - log, - openHrmpChannel, - RELAY_ASSET_ID, - setupRelayAsset, - sleep, - submitExtrinsic, - transferRelayAssetToPara, -} from '../common'; -import { UNIT } from '../consts'; -import { configureBroker, purchaseRegion, startSales } from '../coretime.common'; -import { ismpAddParachain } from '../ismp.common'; -import { REGIONX_API_TYPES, REGIONX_CUSTOM_RPC } from '../types'; -import { transferRegionToRegionX } from '../xc-regions.common'; - -async function run(_nodeName: string, networkInfo: any, _jsArgs: any) { - const { wsUri: regionXUri } = networkInfo.nodesByName['regionx-collator01']; - const { wsUri: coretimeUri } = networkInfo.nodesByName['coretime-collator01']; - const { wsUri: rococoUri } = networkInfo.nodesByName['rococo-validator01']; - - const regionXApi = await ApiPromise.create({ - provider: new WsProvider(regionXUri), - types: { ...REGIONX_API_TYPES }, - rpc: REGIONX_CUSTOM_RPC, - }); - const rococoApi = await ApiPromise.create({ provider: new WsProvider(rococoUri) }); - const coretimeApi = await ApiPromise.create({ provider: new WsProvider(coretimeUri) }); - - // account to submit tx - const keyring = new Keyring({ type: 'sr25519' }); - const alice = keyring.addFromUri('//Alice'); - const bob = keyring.addFromUri('//Bob'); - - const txSetRelayXcmVersion = rococoApi.tx.xcmPallet.forceDefaultXcmVersion([3]); - const txSetCoretimeXcmVersion = coretimeApi.tx.polkadotXcm.forceDefaultXcmVersion([3]); - log('Setting XCM version: '); - await submitExtrinsic(alice, rococoApi.tx.sudo.sudo(txSetRelayXcmVersion), {}); - await submitExtrinsic(alice, coretimeApi.tx.sudo.sudo(txSetCoretimeXcmVersion), {}); - - log('Setting up relay asset: '); - await setupRelayAsset(regionXApi, alice, 500n * UNIT); - - log('Opening HRMP: '); - await openHrmpChannel(alice, rococoApi, 1005, 2000); - await openHrmpChannel(alice, rococoApi, 2000, 1005); - log('Adding ISMP: '); - await ismpAddParachain(alice, regionXApi); - - log('Transfering rc token to RegionX:'); - await transferRelayAssetToPara(rococoApi, alice, 1005, alice.address, 100n * UNIT); - await transferRelayAssetToPara(rococoApi, alice, 2000, alice.address, 100n * UNIT); - - log('Configuring coretime chain:'); - await configureBroker(coretimeApi, alice); - log('Starting sales:'); - await startSales(coretimeApi, alice); - - const regionId = await purchaseRegion(coretimeApi, alice); - if (!regionId) throw new Error('RegionId not found'); - - log('Transferring region to RegionX'); - await transferRegionToRegionX(coretimeApi, regionXApi, alice, regionId); - - const paraId = 2000; - const orderRequirements = { - begin: 40, - end: 45, - coreOccupancy: 57600, // full core - }; - - log('Creating order'); - const createOrderCall = regionXApi.tx.orders.createOrder(paraId, orderRequirements); - await submitExtrinsic(alice, createOrderCall, {}); - - const order = (await regionXApi.query.orders.orders(0)).toJSON(); - assert.deepStrictEqual(order, { - creator: alice.address, - paraId: 2000, - requirements: orderRequirements, - }); - - log('Giving Bob tokens'); - const transferToBobCall = regionXApi.tx.tokens.transfer(bob.address, RELAY_ASSET_ID, 30n * UNIT); - await submitExtrinsic(alice, regionXApi.tx.sudo.sudo(transferToBobCall), {}); - - log('Bob making a contribution'); - const contributeCall = regionXApi.tx.orders.contribute(0, 10n * UNIT); - await submitExtrinsic(bob, contributeCall, {}); - - log('Alice fulfilling the order'); - const fulfillCall = regionXApi.tx.processor.fulfillOrder(0, regionId); - await submitExtrinsic(alice, fulfillCall, {}); - // Region should be removed after making the assignment call: - const regions = await regionXApi.query.regions.regions.entries(); - assert.equal(regions.length, 0); - - // `fulfillOrder` will make a cross-chain call to the Coretime chain to make the assignment. - // We will wait a bit since it will take some time. - await sleep(5000); - - const workplan = await coretimeApi.query.broker.workplan.entries(); - assert.equal(workplan.length, 1); -} - -export { run }; diff --git a/e2e_tests/xc-regions.common.ts b/e2e_tests/xc-regions.common.ts deleted file mode 100644 index fbc81d4f..00000000 --- a/e2e_tests/xc-regions.common.ts +++ /dev/null @@ -1,170 +0,0 @@ -import { ApiPromise, Keyring } from '@polkadot/api'; -import { KeyringPair } from '@polkadot/keyring/types'; -import { getEncodedRegionId, RegionId } from 'coretime-utils'; -import assert from 'node:assert'; -import { sleep, submitExtrinsic, submitUnsigned } from './common'; -import { makeIsmpResponse, queryRequest } from './ismp.common'; - -const REGIONX_SOVEREIGN_ACCOUNT = '5Eg2fntJ27qsari4FGrGhrMqKFDRnkNSR6UshkZYBGXmSuC8'; - -async function transferRegionToRegionX( - coretimeApi: ApiPromise, - regionXApi: ApiPromise, - sender: KeyringPair, - regionId: RegionId -) { - const receiverKeypair = new Keyring(); - receiverKeypair.addFromAddress(sender.address); - - const feeAssetItem = 0; - const weightLimit = 'Unlimited'; - const reserveTransferToRegionX = coretimeApi.tx.polkadotXcm.limitedReserveTransferAssets( - { V3: { parents: 1, interior: { X1: { Parachain: 2000 } } } }, //dest - { - V3: { - parents: 0, - interior: { - X1: { - AccountId32: { - chain: 'Any', - id: receiverKeypair.pairs[0].publicKey, - }, - }, - }, - }, - }, //beneficiary - { - V3: [ - { - id: { - Concrete: { - parents: 1, - interior: 'Here', - }, - }, - fun: { - Fungible: 10n ** 10n, - }, - }, // ^^ fee payment asset - { - id: { - Concrete: { - parents: 0, - interior: { X1: { PalletInstance: 50 } }, - }, - }, - fun: { - NonFungible: { - Index: getEncodedRegionId(regionId, coretimeApi).toString(), - }, - }, - }, - ], - }, //asset - feeAssetItem, - weightLimit - ); - await submitExtrinsic(sender, reserveTransferToRegionX, {}); - - await sleep(5000); - - const requestRecord = regionXApi.tx.regions.requestRegionRecord(regionId); - await submitUnsigned(requestRecord); - - let regions = await regionXApi.query.regions.regions.entries(); - assert.equal(regions.length, 1); - assert.deepStrictEqual(regions[0][0].toHuman(), [regionId]); - - let region = regions[0][1].toHuman() as any; - assert(region.owner == sender.address); - assert(typeof region.record.Pending === 'string'); - - // Check the data on the Coretime chain: - regions = await coretimeApi.query.broker.regions.entries(); - assert.equal(regions.length, 1); - assert.deepStrictEqual(regions[0][0].toHuman(), [regionId]); - assert.equal((regions[0][1].toHuman() as any).owner, REGIONX_SOVEREIGN_ACCOUNT); - - // Respond to the ISMP get request: - const request = await queryRequest(regionXApi, region.record.Pending); - await makeIsmpResponse(regionXApi, coretimeApi, request, sender.address); - - // The record should be set after ISMP response: - regions = await regionXApi.query.regions.regions.entries(); - region = regions[0][1].toHuman() as any; - assert(region.owner == sender.address); -} - -async function transferRegionToCoretimeChain( - coretimeApi: ApiPromise, - regionXApi: ApiPromise, - sender: KeyringPair, - regionId: RegionId -) { - const receiverKeypair = new Keyring(); - receiverKeypair.addFromAddress(sender.address); - - const feeAssetItem = 0; - const weightLimit = 'Unlimited'; - - // Transfer the region back to the Coretime chain: - const reserveTransferToCoretime = regionXApi.tx.polkadotXcm.limitedReserveTransferAssets( - { V3: { parents: 1, interior: { X1: { Parachain: 1005 } } } }, // dest - { - V3: { - parents: 0, - interior: { - X1: { - AccountId32: { - chain: 'Any', - id: receiverKeypair.pairs[0].publicKey, - }, - }, - }, - }, - }, // ^^ beneficiary - { - V3: [ - { - id: { - Concrete: { - parents: 1, - interior: 'Here', - }, - }, - fun: { - Fungible: 10n ** 10n, - }, - }, // ^^ fee payment asset - { - id: { - Concrete: { - parents: 1, - // chain: Rococo-Coretime, pallet: pallet_broker - interior: { X2: [{ Parachain: 1005 }, { PalletInstance: 50 }] }, - }, - }, - fun: { - NonFungible: { - Index: getEncodedRegionId(regionId, regionXApi).toString(), - }, - }, - }, - ], - }, // ^^ asset - feeAssetItem, - weightLimit - ); - await submitExtrinsic(sender, reserveTransferToCoretime, {}); - await sleep(5000); - - let regions = await regionXApi.query.regions.regions.entries(); - assert.equal(regions.length, 0); - - regions = await coretimeApi.query.broker.regions.entries(); - assert.equal(regions.length, 1); - assert.deepStrictEqual(regions[0][0].toHuman(), [regionId]); - assert.equal((regions[0][1].toHuman() as any).owner, sender.address); -} - -export { transferRegionToRegionX, transferRegionToCoretimeChain }; diff --git a/e2e_tests/xc-transfer/asset-transfer.ts b/e2e_tests/xc-transfer/asset-transfer.ts deleted file mode 100644 index ec295d86..00000000 --- a/e2e_tests/xc-transfer/asset-transfer.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { ApiPromise, Keyring, WsProvider } from '@polkadot/api'; -import { - RELAY_ASSET_ID, - setupRelayAsset, - sleep, - submitExtrinsic, - transferRelayAssetToPara, -} from '../common'; - -import assert from 'node:assert'; - -const TOLERANCE = 10n ** 10n; - -async function run(nodeName: string, networkInfo: any, _jsArgs: any) { - const { wsUri: regionXUri } = networkInfo.nodesByName[nodeName]; - const { wsUri: rococoUri } = networkInfo.nodesByName['rococo-validator01']; - - const rococoApi = await ApiPromise.create({ provider: new WsProvider(rococoUri) }); - const regionXApi = await ApiPromise.create({ provider: new WsProvider(regionXUri) }); - - // account to submit tx - const keyring = new Keyring({ type: 'sr25519' }); - const alice = keyring.addFromUri('//Alice'); - - const setXcmVersion = rococoApi.tx.xcmPallet.forceDefaultXcmVersion([3]); - await submitExtrinsic(alice, rococoApi.tx.sudo.sudo(setXcmVersion), {}); - - await setupRelayAsset(regionXApi, alice); - - const receiverKeypair = new Keyring(); - receiverKeypair.addFromAddress(alice.address); - - const assertRegionXBalance = async (address: string, balance: bigint) => { - const { free } = ( - await regionXApi.query.tokens.accounts(address, RELAY_ASSET_ID) - ).toJSON() as any; - - console.log(`RegionX: ${BigInt(free).toString()} | Expected: ${balance}`); - assert(balance - BigInt(free) < TOLERANCE); - }; - - const assertRococoBalance = async (address: string, balance: bigint) => { - const { - data: { free }, - } = (await rococoApi.query.system.account(address)).toJSON() as any; - - console.log(`Rococo: ${BigInt(free).toString()} | Expected: ${balance}`); - assert(balance - BigInt(free) < TOLERANCE); - }; - - await assertRegionXBalance(alice.address, 0n); - await assertRococoBalance(alice.address, 10n ** 18n); - - await transferRelayAssetToPara(rococoApi, alice, 2000, alice.address, 3n * 10n ** 12n); - await sleep(5 * 1000); - - await assertRegionXBalance(alice.address, 3n * 10n ** 12n); - await assertRococoBalance(alice.address, 10n ** 18n - 3n * 10n ** 12n); - - const regionXReserveTransfer = regionXApi.tx.polkadotXcm.limitedReserveTransferAssets( - { V3: { parents: 1, interior: 'Here' } }, //dest - { - V3: { - parents: 0, - interior: { - X1: { - AccountId32: { - chain: 'Any', - id: receiverKeypair.pairs[0].publicKey, - }, - }, - }, - }, - }, //beneficiary - { - V3: [ - { - id: { - Concrete: { parents: 1, interior: 'Here' }, - }, - fun: { - Fungible: 10n ** 12n, - }, - }, - ], - }, //asset - 0, - 'Unlimited' - ); - - await submitExtrinsic(alice, regionXReserveTransfer, {}); - - await sleep(5 * 1000); - - await assertRegionXBalance(alice.address, 2n * 10n ** 12n); - await assertRococoBalance(alice.address, 10n ** 18n - 3n * 10n ** 12n); -} - -export { run }; diff --git a/e2e_tests/xc-transfer/region-transfer.ts b/e2e_tests/xc-transfer/region-transfer.ts deleted file mode 100644 index ac659c2f..00000000 --- a/e2e_tests/xc-transfer/region-transfer.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { ApiPromise, Keyring, WsProvider } from '@polkadot/api'; -import { - openHrmpChannel, - setupRelayAsset, - submitExtrinsic, - transferRelayAssetToPara, -} from '../common'; -import { UNIT } from '../consts'; -import { configureBroker, purchaseRegion, startSales } from '../coretime.common'; -import { ismpAddParachain } from '../ismp.common'; -import { REGIONX_API_TYPES, REGIONX_CUSTOM_RPC } from '../types'; -import { transferRegionToCoretimeChain, transferRegionToRegionX } from '../xc-regions.common'; - -async function run(_nodeName: any, networkInfo: any, _jsArgs: any) { - const { wsUri: regionXUri } = networkInfo.nodesByName['regionx-collator01']; - const { wsUri: coretimeUri } = networkInfo.nodesByName['coretime-collator01']; - const { wsUri: rococoUri } = networkInfo.nodesByName['rococo-validator01']; - - const regionXApi = await ApiPromise.create({ - provider: new WsProvider(regionXUri), - types: { ...REGIONX_API_TYPES }, - rpc: REGIONX_CUSTOM_RPC, - }); - const rococoApi = await ApiPromise.create({ provider: new WsProvider(rococoUri) }); - const coretimeApi = await ApiPromise.create({ provider: new WsProvider(coretimeUri) }); - - // account to submit tx - const keyring = new Keyring({ type: 'sr25519' }); - const alice = keyring.addFromUri('//Alice'); - - const txSetCoretimeXcmVersion = coretimeApi.tx.polkadotXcm.forceDefaultXcmVersion([3]); - const txSetRelayXcmVersion = rococoApi.tx.xcmPallet.forceDefaultXcmVersion([3]); - await submitExtrinsic(alice, coretimeApi.tx.sudo.sudo(txSetCoretimeXcmVersion), {}); - await submitExtrinsic(alice, rococoApi.tx.sudo.sudo(txSetRelayXcmVersion), {}); - - await setupRelayAsset(regionXApi, alice); - - await openHrmpChannel(alice, rococoApi, 1005, 2000); - await openHrmpChannel(alice, rococoApi, 2000, 1005); - await ismpAddParachain(alice, regionXApi); - - await transferRelayAssetToPara(rococoApi, alice, 1005, alice.address, 1000n * UNIT); - await transferRelayAssetToPara(rococoApi, alice, 2000, alice.address, 1000n * UNIT); - - await configureBroker(coretimeApi, alice); - await startSales(coretimeApi, alice); - - const regionId = await purchaseRegion(coretimeApi, alice); - if (!regionId) throw new Error('RegionId not found'); - - // Transferring to the RegionX chain should work: - // NOTE: the function contains checks, and if any of them fail, the test will fail. - await transferRegionToRegionX(coretimeApi, regionXApi, alice, regionId); - - // Transferring back to the Coretime chain should work: - // NOTE: the function contains checks, and if any of them fail, the test will fail. - await transferRegionToCoretimeChain(coretimeApi, regionXApi, alice, regionId); -} - -export { run }; diff --git a/network.toml b/network.toml new file mode 100644 index 00000000..b8f40676 --- /dev/null +++ b/network.toml @@ -0,0 +1,26 @@ +[settings] +timeout = 1000 + +[relaychain] +chain = "kusama-local" +chain_spec_command = "chain-spec-generator {% raw %} {{chainName}} {% endraw %}" +command = "polkadot" + + [[relaychain.nodes]] + name = "kusama-validator01" + validator = true + + [[relaychain.nodes]] + name = "kusama-validator02" + validator = true + +[[parachains]] +id = 2000 +chain = "regionx-kusama-dev" +addToGenesis = false + + [parachains.collator] + name = "regionx-collator01" + command = "regionx-node" + ws_port = 9955 + args = [ "--enable-offchain-indexing true --log=xcm=trace,regions=trace" ] diff --git a/package.json b/package.json index 6a1b15bc..0233ca75 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "keywords": [], "author": "", "license": "ISC", - "dependencies": { + "dependencies": { + "@acala-network/chopsticks": "1.1.0", "@polkadot/api": "^16.2.1", "@polkadot/keyring": "^13.5.2", "@polkadot/util": "^13.5.2", From d4f8256c5a97c3c433dd85706eebcd934a6706b1 Mon Sep 17 00:00:00 2001 From: Sergej Date: Mon, 23 Jun 2025 11:45:54 +0200 Subject: [PATCH 2/5] fix invalid region id --- chopsticks/tests/coretime.utils.ts | 2 +- chopsticks/tests/region-transfer.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/chopsticks/tests/coretime.utils.ts b/chopsticks/tests/coretime.utils.ts index c7a6c25b..6ec27780 100644 --- a/chopsticks/tests/coretime.utils.ts +++ b/chopsticks/tests/coretime.utils.ts @@ -29,7 +29,7 @@ async function getRegionId(coretimeApi: ApiPromise): Promise { for (const record of events) { const { event } = record; if (event.section === 'broker' && event.method === 'Purchased') { - const data = event.data[1].toHuman(); + const data = event.data[1].toJSON(); return data; } } diff --git a/chopsticks/tests/region-transfer.ts b/chopsticks/tests/region-transfer.ts index 2283ce43..ff398022 100644 --- a/chopsticks/tests/region-transfer.ts +++ b/chopsticks/tests/region-transfer.ts @@ -26,6 +26,7 @@ async function run() { const regionId = await purchaseRegion(coretimeApi, alice); if (!regionId) throw new Error('RegionId not found'); + console.log(regionId); await transferRegionToRegionX(coretimeApi, regionxApi, alice, regionId); } From 876008094b258a9e194bacf747b63ca80e85d727 Mon Sep 17 00:00:00 2001 From: Sergej Date: Fri, 27 Jun 2025 12:33:24 +0200 Subject: [PATCH 3/5] small fix --- runtime/kusama/src/weights/block_weights.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/runtime/kusama/src/weights/block_weights.rs b/runtime/kusama/src/weights/block_weights.rs index 7ed13698..c1d9d199 100644 --- a/runtime/kusama/src/weights/block_weights.rs +++ b/runtime/kusama/src/weights/block_weights.rs @@ -46,6 +46,7 @@ pub mod constants { #[cfg(test)] mod test_weights { + use polkadot_sdk::*; use frame_support::weights::constants; /// Checks that the weight exists and is sane. From e8a38a25a591c06a3c52faf125dd9565eeaee7bc Mon Sep 17 00:00:00 2001 From: Sergej Date: Sat, 28 Jun 2025 12:25:25 +0200 Subject: [PATCH 4/5] initial regionx state --- chopsticks/configs/regionx-local.yml | 55 ++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/chopsticks/configs/regionx-local.yml b/chopsticks/configs/regionx-local.yml index 05c0af9b..f701a7d2 100644 --- a/chopsticks/configs/regionx-local.yml +++ b/chopsticks/configs/regionx-local.yml @@ -9,3 +9,58 @@ import-storage: - providers: 1 data: free: 1000000000000000 + Regions: + Regions: + [ + [ + [{ core: 0, begin: 366408, mask: "0xffffffffffffffffffff" }], + { + owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY, + locked: true, + record: + { + Available: + { + end: 371448, + owner: "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + paid: null, + }, + }, + }, + ], + [ + [{ core: 1, begin: 366408, mask: "0xffffffffffffffffffff" }], + { + owner: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY, + locked: true, + record: + { + Available: + { + end: 371448, + owner: "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", + paid: null, + }, + }, + }, + ], + ] + Market: + Listings: [ + [ + [{ core: 0, begin: 366408, mask: "0xffffffffffffffffffff" }], + { + seller: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY, + timeslice_price: 1000000000, # 0.001 KSM / timeslice + sale_recipient: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY, + }, + ], + [ + [{ core: 1, begin: 366408, mask: "0xffffffffffffffffffff" }], + { + seller: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY, + timeslice_price: 15000000000, # 0.0015 KSM / timeslice + sale_recipient: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY, + }, + ], + ] From 3f71253880d96ee81f160b3ce4c64318c244dfba Mon Sep 17 00:00:00 2001 From: Sergej Date: Sat, 28 Jun 2025 12:26:05 +0200 Subject: [PATCH 5/5] change para id --- chopsticks/tests/region-transfer.ts | 5 ++++- network.toml | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/chopsticks/tests/region-transfer.ts b/chopsticks/tests/region-transfer.ts index ff398022..f013bb54 100644 --- a/chopsticks/tests/region-transfer.ts +++ b/chopsticks/tests/region-transfer.ts @@ -10,6 +10,8 @@ const RELAY_ENDPOINT = "ws://127.0.0.1:8002"; const CORETIME_ENDPOINT = "ws://127.0.0.1:8000"; const REGIONX_ENDPOINT = "ws://127.0.0.1:8001"; +const REGIONX_PARA_ID = 4242; + export const keyring = new Keyring({ type: "sr25519" }); async function run() { @@ -27,6 +29,7 @@ async function run() { if (!regionId) throw new Error('RegionId not found'); console.log(regionId); + console.log(getEncodedRegionId(regionId, coretimeApi).toString()); await transferRegionToRegionX(coretimeApi, regionxApi, alice, regionId); } @@ -42,7 +45,7 @@ async function transferRegionToRegionX( const feeAssetItem = 0; const weightLimit = 'Unlimited'; const reserveTransferToRegionX = coretimeApi.tx.polkadotXcm.limitedReserveTransferAssets( - { V3: { parents: 1, interior: { X1: { Parachain: 2000 } } } }, //dest + { V3: { parents: 1, interior: { X1: { Parachain: REGIONX_PARA_ID } } } }, //dest { V3: { parents: 0, diff --git a/network.toml b/network.toml index b8f40676..921db434 100644 --- a/network.toml +++ b/network.toml @@ -15,7 +15,7 @@ command = "polkadot" validator = true [[parachains]] -id = 2000 +id = 4242 chain = "regionx-kusama-dev" addToGenesis = false diff --git a/package.json b/package.json index 0233ca75..c90f8308 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "license": "ISC", "dependencies": { "@acala-network/chopsticks": "1.1.0", - "@polkadot/api": "^16.2.1", + "@polkadot/api": "^16.2.2", "@polkadot/keyring": "^13.5.2", "@polkadot/util": "^13.5.2", "@polkadot/util-crypto": "^13.5.2",