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

fix getNextKey #143

Merged
merged 3 commits into from
Jan 16, 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
222 changes: 62 additions & 160 deletions e2e/__snapshots__/dev.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ exports[`dev rpc > dryRun 1`] = `
],
},
"cdpEngine": {
"debitExchangeRate": {
"{\\"stableAssetPoolToken\\":0}": [
"485,048,213,257,347,904",
"485,048,232,352,119,611",
],
"{\\"token\\":\\"DOT\\"}": [
"509,204,261,826,024,749",
"509,204,282,170,944,255",
],
"{\\"token\\":\\"LDOT\\"}": [
"507,950,484,094,994,129",
"507,950,504,389,819,775",
],
},
"lastAccumulationSecs": [
"1,666,942,752",
"1,666,942,794",
Expand Down Expand Up @@ -201,6 +215,14 @@ exports[`dev rpc > dryRun 1`] = `
],
},
"system": {
"account": {
"5EYCAe5fiQJsnopDHfvJYerPqVF1pvpnwJUGmUUrV5Kzp5MZ": {
"providers": [
"5",
"6",
],
},
},
"allExtrinsicsLen": [
null,
"1,527",
Expand All @@ -214,7 +236,7 @@ exports[`dev rpc > dryRun 1`] = `
"blockWeight": {
"mandatory": [
"500,000,000,000",
"10,909,625,000",
"11,331,935,000",
],
},
"digest": {
Expand All @@ -237,189 +259,49 @@ exports[`dev rpc > dryRun 1`] = `
},
"eventCount": [
"7",
"2",
"6",
],
"events": {
"0": {
"event": {
"data": {
"amount": [
"2,429,299",
0,
0,
],
"currencyId": [
{
"Token": "AUSD",
},
0,
0,
],
"dispatchInfo": [
{
"class": "Mandatory",
"paysFee": "Yes",
"weight": "158,080,000",
},
],
"who": [
"5EYCAe5fiQJsnopDHfvJYerPqVF1pvpnwJUGmUUrV5Kzp5MZ",
0,
0,
"1,821,974",
],
},
"index": [
"0x0b0a",
"0x0000",
],
"method": [
"Deposited",
"ExtrinsicSuccess",
],
"section": [
"tokens",
"system",
],
},
"phase": [
"Initialization",
{
"ApplyExtrinsic": "0",
},
],
},
"1": {
"event": {
"data": {
"amount": [
"2,429,299",
0,
0,
],
"currencyId": [
{
"Token": "AUSD",
},
0,
0,
],
"dispatchInfo": [
{
"class": "Mandatory",
"paysFee": "Yes",
"weight": "0",
},
],
"who": [
"5EYCAe5fiQJsnopDHfvJYerPqVF1pvpnwJUGmUUrV5Kzp5MZ",
0,
0,
"1,821,974",
],
},
"index": [
"0x0b00",
"0x0000",
],
"method": [
"Endowed",
"ExtrinsicSuccess",
],
"section": [
"tokens",
"system",
],
},
"phase": [
"Initialization",
{
"ApplyExtrinsic": "1",
},
],
},
"_2": [
{
"event": {
"data": {
"amount": "44,234,034",
"currencyId": {
"Token": "AUSD",
},
"who": "5EYCAe5fiQJsnopDHfvJYerPqVF1pvpnwJUGmUUrV5Kzp5MZ",
},
"index": "0x0b0a",
"method": "Deposited",
"section": "tokens",
},
"phase": "Initialization",
"topics": [],
},
0,
0,
],
"_3": [
{
"event": {
"data": {
"amount": "365,959,255",
"currencyId": {
"Token": "AUSD",
},
"who": "5EYCAe5fiQJsnopDHfvJYerPqVF1pvpnwJUGmUUrV5Kzp5MZ",
},
"index": "0x0b0a",
"method": "Deposited",
"section": "tokens",
},
"phase": "Initialization",
"topics": [],
},
0,
0,
],
"_4": [
{
"event": {
"data": {
"dispatchInfo": {
"class": "Mandatory",
"paysFee": "Yes",
"weight": "158,080,000",
},
},
"index": "0x0000",
"method": "ExtrinsicSuccess",
"section": "system",
},
"phase": {
"ApplyExtrinsic": "0",
"2": {
"event": {
"data": {
"amount": [
"44,234,034",
"33,175,527",
],
},
"topics": [],
},
0,
0,
],
"_5": [
{
"event": {
"data": {
"dispatchInfo": {
"class": "Mandatory",
"paysFee": "Yes",
"weight": "0",
},
},
"index": "0x0000",
"method": "ExtrinsicSuccess",
"section": "system",
},
"phase": {
"ApplyExtrinsic": "1",
},
"3": {
"event": {
"data": {
"amount": [
"365,959,255",
"274,469,453",
],
},
"topics": [],
},
0,
0,
],
},
"_6": [
{
"event": {
Expand Down Expand Up @@ -477,6 +359,26 @@ exports[`dev rpc > dryRun 1`] = `
"1,666,942,806,031",
],
},
"tokens": {
"accounts": {
"5EYCAe5fiQJsnopDHfvJYerPqVF1pvpnwJUGmUUrV5Kzp5MZ": {
"{\\"token\\":\\"AUSD\\"}": [
null,
{
"free": "309,466,954",
"frozen": "0",
"reserved": "0",
},
],
},
},
"totalIssuance": {
"{\\"token\\":\\"AUSD\\"}": [
"395,953,866,361,320,454,436",
"395,953,866,361,629,921,390",
],
},
},
}
`;

Expand Down
12 changes: 6 additions & 6 deletions e2e/__snapshots__/dry-run-extrinsic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exports[`dry-run-extrinsic > dry run extrinsic 2`] = `
[
[
"0x26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850",
"0x09000000",
"0x0d000000",
],
[
"0x3a7472616e73616374696f6e5f6c6576656c3a",
Expand Down Expand Up @@ -40,7 +40,7 @@ exports[`dry-run-extrinsic > dry run extrinsic 2`] = `
],
[
"0x26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7",
"0x2400000000000000001c6c090000000002000000010000000000000000000000000002000000020000000a0888dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0eef9f9b6a20300000000000000000000000000020000000a0288dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0eed17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae690010a5d4e800000000000000000000000000020000000a076d6f646c6163612f747273790000000000000000000000000000000000000000946192e80200000000000000000000000000020000001406946192e80200000000000000000000000000020000000a076d6f646c6163612f63706f740000000000000000000000000000000000000000659824ba0000000000000000000000000000020000000e0388dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0eef9f9b6a203000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000e014f20900000000000000",
"0x34020b0a00016d6f646c6163612f63647074000000000000000000000000000000000000000016cd1b0000000000000000000000000000020b0000016d6f646c6163612f63647074000000000000000000000000000000000000000016cd1b0000000000000000000000000000020b0a00016d6f646c6163612f636470740000000000000000000000000000000000000000e737fa0100000000000000000000000000020b0a00016d6f646c6163612f6364707400000000000000000000000000000000000000004d125c100000000000000000000000000000000000000000001c6c090000000002000000010000000000000000000000000002000000020000000a0888dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0eef9f9b6a20300000000000000000000000000020000000a0288dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0eed17c2d7823ebf260fd138f2d7e27d114c0145d968b5ff5006125f2414fadae690010a5d4e800000000000000000000000000020000000a076d6f646c6163612f747273790000000000000000000000000000000000000000946192e80200000000000000000000000000020000001406946192e80200000000000000000000000000020000000a076d6f646c6163612f63706f740000000000000000000000000000000000000000659824ba0000000000000000000000000000020000000e0388dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0eef9f9b6a203000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000e014f20900000000000000",
],
[
"0x26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9ae10bf9cd0e372c142b2ca90219666906d6f646c6163612f747273790000000000000000000000000000000000000000",
Expand All @@ -52,7 +52,7 @@ exports[`dry-run-extrinsic > dry run extrinsic 2`] = `
],
[
"0x26aa394eea5630e07c48ae0c9558cef734abf5cb34d6244378cddbf18e849d96",
"0x70e2160f000000000000000000000000a8aa438a02000000",
"0x70e2160f000000000000000000000000189b6fa302000000",
],
[
"0x26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a",
Expand All @@ -77,7 +77,7 @@ exports[`dry-run-extrinsic > dry run extrinsic with fake signature 2`] = `
[
[
"0x26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850",
"0x07000000",
"0x0b000000",
],
[
"0x3a7472616e73616374696f6e5f6c6576656c3a",
Expand All @@ -101,15 +101,15 @@ exports[`dry-run-extrinsic > dry run extrinsic with fake signature 2`] = `
],
[
"0x26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7",
"0x1c00000000000000001c6c090000000002000000010000000000000000000000000002000000020000000a0888dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0eee3669df1020000000000000000000000000002000000ff00000000020000000a0788dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0eee3669df10200000000000000000000000000020000000e0388dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000001019062a01000000000000",
"0x2c020b0a00016d6f646c6163612f63647074000000000000000000000000000000000000000016cd1b0000000000000000000000000000020b0000016d6f646c6163612f63647074000000000000000000000000000000000000000016cd1b0000000000000000000000000000020b0a00016d6f646c6163612f636470740000000000000000000000000000000000000000e737fa0100000000000000000000000000020b0a00016d6f646c6163612f6364707400000000000000000000000000000000000000004d125c100000000000000000000000000000000000000000001c6c090000000002000000010000000000000000000000000002000000020000000a0888dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0eee3669df1020000000000000000000000000002000000ff00000000020000000a0788dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0eee3669df10200000000000000000000000000020000000e0388dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000001019062a01000000000000",
],
[
"0x26aa394eea5630e07c48ae0c9558cef7df1daeb8986837f21cc5d17596bb78d19eb2dcce60f37a2702000000",
"0xc101b901840088dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee01deadbeefcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd000000ff00000080969800",
],
[
"0x26aa394eea5630e07c48ae0c9558cef734abf5cb34d6244378cddbf18e849d96",
"0xa0e62a2f010000000000000000000000a8aa438a02000000",
"0xa0e62a2f010000000000000000000000189b6fa302000000",
],
[
"0xc2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80",
Expand Down
10 changes: 5 additions & 5 deletions src/blockchain/block-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { HexString } from '@polkadot/util/types'
import { StorageValueKind } from './storage-layer'
import { compactAddLength, hexToU8a, stringToHex } from '@polkadot/util'
import { compactHex } from '../utils'
import { defaultLogger, truncate, truncateStorageDiff } from '../logger'
import { defaultLogger, truncate } from '../logger'
import { getCurrentSlot } from '../utils/time-travel'

const logger = defaultLogger.child({ name: 'block-builder' })
Expand Down Expand Up @@ -101,15 +101,15 @@ const initNewBlock = async (head: Block, header: Header, inherents: HexString[])
// initialize block
const { storageDiff } = await newBlock.call('Core_initialize_block', header.toHex())
newBlock.pushStorageLayer().setAll(storageDiff)
logger.trace(truncateStorageDiff(storageDiff), 'Initialize block')
logger.trace(truncate(storageDiff), 'Initialize block')
}

// apply inherents
for (const extrinsic of inherents) {
try {
const { storageDiff } = await newBlock.call('BlockBuilder_apply_extrinsic', extrinsic)
newBlock.pushStorageLayer().setAll(storageDiff)
logger.trace(truncateStorageDiff(storageDiff), 'Applied inherent')
logger.trace(truncate(storageDiff), 'Applied inherent')
} catch (e) {
logger.warn('Failed to apply inherents %o %s', e, e)
throw new Error('Failed to apply inherents')
Expand Down Expand Up @@ -144,7 +144,7 @@ export const buildBlock = async (
try {
const { storageDiff } = await newBlock.call('BlockBuilder_apply_extrinsic', extrinsic)
newBlock.pushStorageLayer().setAll(storageDiff)
logger.trace(truncateStorageDiff(storageDiff), 'Applied extrinsic')
logger.trace(truncate(storageDiff), 'Applied extrinsic')
} catch (e) {
logger.info('Failed to apply extrinsic %o %s', e, e)
pendingExtrinsics.push(extrinsic)
Expand All @@ -156,7 +156,7 @@ export const buildBlock = async (
const { storageDiff } = await newBlock.call('BlockBuilder_finalize_block', '0x')

newBlock.pushStorageLayer().setAll(storageDiff)
logger.trace(truncateStorageDiff(storageDiff), 'Finalize block')
logger.trace(truncate(storageDiff), 'Finalize block')
}

const blockData = registry.createType('Block', {
Expand Down
Loading