Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update deps #335

Merged
merged 3 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,22 @@
"*.{js,ts,css,md}": "prettier --write"
},
"devDependencies": {
"@swc/core": "^1.3.67",
"@types/node": "^20.3.3",
"@swc/core": "^1.3.68",
"@types/node": "^20.4.2",
"@types/prettier": "^2.7.3",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.0",
"eslint": "^8.43.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-sort-imports-es6-autofix": "^0.6.0",
"husky": "^8.0.3",
"prettier": "^2.8.8",
"prettier": "^3.0.0",
"typescript": "^5.1.6",
"unplugin-swc": "^1.3.2",
"vite-tsconfig-paths": "^4.2.0",
"vitest": "^0.32.2",
"vitest": "^0.33.0",
"wasm-pack": "^0.12.1"
},
"exports": {
Expand Down
4 changes: 2 additions & 2 deletions packages/chopsticks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"jsondiffpatch": "^0.4.1",
"lodash": "^4.17.21",
"pino": "^8.14.1",
"pino-pretty": "^10.0.0",
"pino-pretty": "^10.0.1",
"reflect-metadata": "^0.1.13",
"sqlite3": "^5.1.6",
"typeorm": "^0.3.17",
Expand All @@ -34,7 +34,7 @@
"devDependencies": {
"@types/js-yaml": "^4.0.5",
"@types/lodash": "^4.14.195",
"@types/node": "^20.3.3",
"@types/node": "^20.4.2",
"@types/ws": "^8.5.5",
"@types/yargs": "^17.0.24",
"ts-node": "^10.9.1",
Expand Down
16 changes: 8 additions & 8 deletions packages/chopsticks/src/blockchain/block-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const buildBlock = async (
inherents: HexString[],
extrinsics: HexString[],
ump: Record<number, HexString[]>,
onApplyExtrinsicError: (extrinsic: HexString, error: TransactionValidityError) => void
onApplyExtrinsicError: (extrinsic: HexString, error: TransactionValidityError) => void,
): Promise<[Block, HexString[]]> => {
const registry = await head.registry
const header = await newHeader(head)
Expand All @@ -157,7 +157,7 @@ export const buildBlock = async (
extrinsicsCount: extrinsics.length,
umpCount: Object.keys(ump).length,
},
`Try building block #${(head.number + 1).toLocaleString()}`
`Try building block #${(head.number + 1).toLocaleString()}`,
)

let layer: StorageLayer | undefined
Expand Down Expand Up @@ -278,7 +278,7 @@ export const buildBlock = async (
const storageDiff = await newBlock.storageDiff()
logger.trace(
Object.entries(storageDiff).map(([key, value]) => [key, truncate(value)]),
'Final block'
'Final block',
)
const finalBlock = new Block(head.chain, newBlock.number, blockData.hash.toHex(), head, {
header,
Expand All @@ -295,7 +295,7 @@ export const buildBlock = async (
pendingExtrinsicsCount: pendingExtrinsics.length,
ump: truncate(ump),
},
'Block built'
'Block built',
)

return [finalBlock, pendingExtrinsics]
Expand All @@ -304,7 +304,7 @@ export const buildBlock = async (
export const dryRunExtrinsic = async (
head: Block,
inherents: HexString[],
extrinsic: HexString | { call: HexString; address: string }
extrinsic: HexString | { call: HexString; address: string },
): Promise<TaskCallResponse> => {
const registry = await head.registry
const header = await newHeader(head)
Expand All @@ -313,7 +313,7 @@ export const dryRunExtrinsic = async (
if (typeof extrinsic !== 'string') {
if (!head.chain.mockSignatureHost) {
throw new Error(
'Cannot fake signature because mock signature host is not enabled. Start chain with `mockSignatureHost: true`'
'Cannot fake signature because mock signature host is not enabled. Start chain with `mockSignatureHost: true`',
)
}

Expand Down Expand Up @@ -343,14 +343,14 @@ export const dryRunExtrinsic = async (

defaultLogger.info(
{ call: registry.createType('GenericExtrinsic', hexToU8a(extrinsic)).toHuman() },
'dry_run_extrinsic'
'dry_run_extrinsic',
)
return newBlock.call('BlockBuilder_apply_extrinsic', [extrinsic])
}

export const dryRunInherents = async (
head: Block,
inherents: HexString[]
inherents: HexString[],
): Promise<[HexString, HexString | null][]> => {
const header = await newHeader(head)
const { layers } = await initNewBlock(head, header, inherents)
Expand Down
10 changes: 5 additions & 5 deletions packages/chopsticks/src/blockchain/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Block {
extrinsics: HexString[]
storage?: StorageLayerProvider
storageDiff?: Record<string, StorageValue | null>
}
},
) {
this.#chain = chain
this.#parentBlock = parentBlock
Expand Down Expand Up @@ -78,7 +78,7 @@ export class Block {
get header(): Header | Promise<Header> {
if (!this.#header) {
this.#header = Promise.all([this.registry, this.#chain.api.getHeader(this.hash)]).then(([registry, header]) =>
registry.createType<Header>('Header', header)
registry.createType<Header>('Header', header),
)
}
return this.#header
Expand Down Expand Up @@ -190,8 +190,8 @@ export class Block {
objectSpread<ExtDef>(
{},
getSpecExtensions(registry, chain, version.specName),
this.#chain.api.signedExtensions
)
this.#chain.api.signedExtensions,
),
)
return registry
})
Expand Down Expand Up @@ -233,7 +233,7 @@ export class Block {
allowUnresolvedImports: this.#chain.allowUnresolvedImports,
runtimeLogLevel: this.#chain.runtimeLogLevel,
},
taskHandler(this)
taskHandler(this),
)
if (response.Call) {
for (const log of response.Call.runtimeLogs) {
Expand Down
8 changes: 4 additions & 4 deletions packages/chopsticks/src/blockchain/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export class Blockchain {
number: block.number,
hash: block.hash,
},
'setHead'
'setHead',
)
this.#head = block
this.#registerBlock(block)
Expand All @@ -178,7 +178,7 @@ export class Blockchain {

async validateExtrinsic(
extrinsic: HexString,
source: '0x00' | '0x01' | '0x02' = '0x02' /** External */
source: '0x00' | '0x01' | '0x02' = '0x02' /** External */,
): Promise<TransactionValidity> {
const args = u8aToHex(u8aConcat(source, extrinsic, this.head.hash))
const res = await this.head.call('TaggedTransactionQueue_validate_transaction', [args])
Expand Down Expand Up @@ -220,7 +220,7 @@ export class Blockchain {

async dryRunExtrinsic(
extrinsic: HexString | { call: HexString; address: string },
at?: HexString
at?: HexString,
): Promise<{ outcome: ApplyExtrinsicResult; storageDiff: [HexString, HexString | null][] }> {
await this.api.isReady
const head = at ? await this.getBlock(at) : this.head
Expand All @@ -241,7 +241,7 @@ export class Blockchain {

async dryRunHrmp(
hrmp: Record<number, HorizontalMessage[]>,
at?: HexString
at?: HexString,
): Promise<[HexString, HexString | null][]> {
await this.api.isReady
const head = at ? await this.getBlock(at) : this.head
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class SetValidationData implements CreateInherents {
const decoded = await decodeProof(
extrinsic.validationData.relayParentStorageRoot,
[...Object.values(WELL_KNOWN_KEYS), dmqMqcHeadKey, hrmpIngressChannelIndexKey, hrmpEgressChannelIndexKey],
extrinsic.relayChainState.trieNodes
extrinsic.relayChainState.trieNodes,
)

for (const key of Object.values(WELL_KNOWN_KEYS)) {
Expand All @@ -115,9 +115,9 @@ export class SetValidationData implements CreateInherents {
u8aConcat(
meta.registry.createType('Hash', dmqMqcHeadHash).toU8a(),
meta.registry.createType('BlockNumber', sentAt).toU8a(),
blake2AsU8a(meta.registry.createType('Bytes', msg).toU8a(), 256)
blake2AsU8a(meta.registry.createType('Bytes', msg).toU8a(), 256),
),
256
256,
)

downwardMessages.push({
Expand Down Expand Up @@ -155,7 +155,7 @@ export class SetValidationData implements CreateInherents {
const decoded = await decodeProof(
extrinsic.validationData.relayParentStorageRoot,
[hrmpChannelKey],
extrinsic.relayChainState.trieNodes
extrinsic.relayChainState.trieNodes,
)
const abridgedHrmpRaw = decoded[hrmpChannelKey]
if (!abridgedHrmpRaw) throw new Error('Canoot find hrmp channels from validation data')
Expand All @@ -172,9 +172,9 @@ export class SetValidationData implements CreateInherents {
u8aConcat(
meta.registry.createType('Hash', abridgedHrmp.mqcHead).toU8a(),
meta.registry.createType('BlockNumber', sentAt).toU8a(),
blake2AsU8a(bytes.toU8a(), 256)
blake2AsU8a(bytes.toU8a(), 256),
),
256
256,
)
abridgedHrmp.msgCount = (abridgedHrmp.msgCount as number) + 1
abridgedHrmp.totalSize = (abridgedHrmp.totalSize as number) + bytes.length
Expand Down Expand Up @@ -203,7 +203,7 @@ export class SetValidationData implements CreateInherents {
const decoded = await decodeProof(
extrinsic.validationData.relayParentStorageRoot,
[hrmpChannelKey],
extrinsic.relayChainState.trieNodes
extrinsic.relayChainState.trieNodes,
)
newEntries.push([hrmpChannelKey, decoded[hrmpChannelKey]])
}
Expand Down
2 changes: 1 addition & 1 deletion packages/chopsticks/src/blockchain/txpool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class TxPool {
params.upwardMessages,
(extrinsic, error) => {
this.event.emit(APPLY_EXTRINSIC_ERROR, [extrinsic, error])
}
},
)
for (const extrinsic of pendingExtrinsics) {
this.#pool.push({ extrinsic, signer: await this.#getSigner(extrinsic) })
Expand Down
20 changes: 10 additions & 10 deletions packages/chopsticks/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { HexString } from '@polkadot/util/types'
import { basename, extname } from 'node:path'
import { config as dotenvConfig } from 'dotenv'
import { hideBin } from 'yargs/helpers'
import { readFileSync } from 'node:fs'
import _ from 'lodash'
import axios from 'axios'
import dotenv from 'dotenv'
import yaml from 'js-yaml'
import yargs from 'yargs'

Expand All @@ -18,7 +18,7 @@ import { logger } from './rpc/shared'
import { runBlock } from './run-block'
import { tryRuntime } from './try-runtime'

dotenv.config()
dotenvConfig()

const CONFIGS_BASE_URL = 'https://raw.githubusercontent.com/AcalaNetwork/chopsticks/master/configs/'

Expand Down Expand Up @@ -120,7 +120,7 @@ yargs(hideBin(process.argv))
}),
async (argv) => {
await setupWithServer(await processArgv(argv))
}
},
)
.command(
'run-block',
Expand All @@ -142,7 +142,7 @@ yargs(hideBin(process.argv))
}),
async (argv) => {
await runBlock(await processArgv(argv))
}
},
)
.command(
'try-runtime',
Expand All @@ -168,7 +168,7 @@ yargs(hideBin(process.argv))
}),
async (argv) => {
await tryRuntime(await processArgv(argv))
}
},
)
.command(
'dry-run',
Expand Down Expand Up @@ -210,7 +210,7 @@ yargs(hideBin(process.argv))
} else {
await dryRun(config)
}
}
},
)
.command(
'decode-key <key>',
Expand All @@ -229,18 +229,18 @@ yargs(hideBin(process.argv))
const { storage, decodedKey } = decodeKey(
await context.chain.head.meta,
context.chain.head,
argv.key as HexString
argv.key as HexString,
)
if (storage && decodedKey) {
console.log(
`${storage.section}.${storage.method}`,
decodedKey.args.map((x) => JSON.stringify(x.toHuman())).join(', ')
decodedKey.args.map((x) => JSON.stringify(x.toHuman())).join(', '),
)
} else {
console.log('Unknown')
}
process.exit(0)
}
},
)
.command(
'xcm',
Expand Down Expand Up @@ -278,7 +278,7 @@ yargs(hideBin(process.argv))
await connectVertical(relaychain, parachain)
}
}
}
},
)
.strict()
.help()
Expand Down
4 changes: 2 additions & 2 deletions packages/chopsticks/src/dry-run-preimage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const dryRunPreimage = async (argv: Config) => {
allowUnresolvedImports: false,
runtimeLogLevel: argv['runtime-log-level'] || 0,
},
taskHandler(block)
taskHandler(block),
)

if (result.Error) {
Expand Down Expand Up @@ -112,7 +112,7 @@ export const dryRunPreimage = async (argv: Config) => {
const filePath = await generateHtmlDiffPreviewFile(
context.chain.head,
storageDiff,
blake2AsHex(argv['extrinsic'], 256)
blake2AsHex(argv['extrinsic'], 256),
)
console.log(`Generated preview ${filePath}`)
if (argv['open']) {
Expand Down
2 changes: 1 addition & 1 deletion packages/chopsticks/src/dry-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const dryRun = async (argv: Config) => {
const filePath = await generateHtmlDiffPreviewFile(
context.chain.head,
storageDiff,
blake2AsHex(argv['extrinsic'], 256)
blake2AsHex(argv['extrinsic'], 256),
)
console.log(`Generated preview ${filePath}`)
if (argv['open']) {
Expand Down
8 changes: 4 additions & 4 deletions packages/chopsticks/src/executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ describe('wasm', () => {
it.each([0, 1])('calculate state root', async (trie_version) => {
const a = await calculateStateRoot(
[['0x5301bf5ff0298f5c7b93a446709f8e885f772afdd0d8ba3d4d559a06f0742f12', '0x01']],
trie_version
trie_version,
)
const b = await calculateStateRoot(
[['0x5301bf5ff0298f5c7b93a446709f8e885f772afdd0d8ba3d4d559a06f0742f12', '0x02']],
trie_version
trie_version,
)
expect(a).to.not.eq(b)
})
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('wasm', () => {
const originalDecoded = await decodeProof(
ROOT_TRIE_HASH,
[headKey, upgradeKey, ingressChannelIndexKey, egressChannelIndexKey, ...Object.values(WELL_KNOWN_KEYS)],
NODES
NODES,
)
expect(originalDecoded).toMatchSnapshot()
expect(originalDecoded[upgradeKey]).toBeUndefined()
Expand All @@ -137,7 +137,7 @@ describe('wasm', () => {
const decoded = await decodeProof(
trieRootHash,
[headKey, upgradeKey, ingressChannelIndexKey, egressChannelIndexKey, ...Object.values(WELL_KNOWN_KEYS)],
nodes
nodes,
)
expect(decoded).toMatchSnapshot()
expect(decoded[upgradeKey]).toBe('0x01')
Expand Down
Loading