Skip to content

Commit

Permalink
chore(deps): update polkadot-js deps (#1090)
Browse files Browse the repository at this point in the history
* chore(deps): update polkadot-js deps
  • Loading branch information
marshacb committed Oct 18, 2022
1 parent 9284bd1 commit e6a70a3
Show file tree
Hide file tree
Showing 11 changed files with 53,453 additions and 258 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
"update-pjs-deps": "substrate-update-pjs-deps && yarn"
},
"dependencies": {
"@polkadot/api": "^9.4.2",
"@polkadot/util-crypto": "^10.1.9",
"@polkadot/api": "^9.5.2",
"@polkadot/util-crypto": "^10.1.11",
"@substrate/calc": "^0.3.0",
"argparse": "^2.0.1",
"confmgr": "1.0.9",
Expand Down
10 changes: 5 additions & 5 deletions src/services/node/NodeTransactionPoolService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { sanitizeNumbers } from '../../sanitize/sanitizeNumbers';
import { polkadotRegistryV9190 } from '../../test-helpers/registries';
import { polkadotRegistryV9300 } from '../../test-helpers/registries';
import {
// blockHash789629,
defaultMockApi,
Expand Down Expand Up @@ -70,11 +70,11 @@ describe('NodeTransactionPoolService', () => {
it('works when query param `includeFee` is set to true for normal extrinsics', async () => {
// This test does not use the same metadata in defaultMockApi. It changes it to v9190,
// and sets it back to the default value after.
const normalExt = polkadotRegistryV9190.createType(
const normalExt = polkadotRegistryV9300.createType(
'Extrinsic',
'0x4d028400d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d0196a6cd1652fc83c449884f67e8f444587b69c5874512f1d746ff6f062a097b2acedfe8d2e07915b4c93cc1c3b48a16ebccc1db8eb810146373ba53c9f42ab48e4500000284d717050300e281b7ec09fb8420ca7ba3fbd627fbe203ff04b2ba0777ae1d8a6942257af0230700e8764817'
);
const pool = polkadotRegistryV9190.createType('Vec<Extrinsic>', [
const pool = polkadotRegistryV9300.createType('Vec<Extrinsic>', [
normalExt,
]);
(defaultMockApi.rpc.author as any).pendingExtrinsics = () =>
Expand All @@ -90,11 +90,11 @@ describe('NodeTransactionPoolService', () => {
});

it('works when query param `includeFee` is set to true for operational extrinsics', async () => {
const operationalExt = polkadotRegistryV9190.createType(
const operationalExt = polkadotRegistryV9300.createType(
'Extrinsic',
'0x350284004adf51a47b72795366d52285e329229c836ea7bbfe139dbe8fa0700c4f86fc5601fc44dcd1994c111671b3577b02e391be8aff10f7ccf766f3189859ea343db041779a67f9357cba0ba051f83d63e45e7a88b5e2ca642181592052acd9f4ccc8821501c107000f03f2af187bbc8a4a2b5a28c2a3c2d85bf7e5b1700cbf1207a8e4c1eb7d8e7e4037350301'
);
const pool = polkadotRegistryV9190.createType('Vec<Extrinsic>', [
const pool = polkadotRegistryV9300.createType('Vec<Extrinsic>', [
operationalExt,
]);
(defaultMockApi.rpc.author as any).pendingExtrinsics = () =>
Expand Down
15 changes: 10 additions & 5 deletions src/services/node/NodeTransactionPoolService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import { DispatchClass, Extrinsic, Weight } from '@polkadot/types/interfaces';
import { u32 } from '@polkadot/types-codec';
import BN from 'bn.js';

import { INodeTransactionPool } from '../../types/responses';
Expand Down Expand Up @@ -103,11 +102,14 @@ export class NodeTransactionPoolService extends AbstractService {
const BN_ONE = new BN(1);
const sanitizedClass = this.defineDispatchClassType(dispatchClass);

const maxBlockWeight = api.consts.system.blockWeights.maxBlock;
const maxLength: u32 = api.consts.system.blockLength.max[sanitizedClass];
const maxBlockWeight =
api.consts.system.blockWeights.maxBlock.refTime.unwrap();
const maxLength: BN = new BN(
api.consts.system.blockLength.max[sanitizedClass]
);
const boundedWeight = BN.min(BN.max(weight.toBn(), BN_ONE), maxBlockWeight);
const boundedLength = BN.min(BN.max(new BN(len), BN_ONE), maxLength);
const maxTxPerBlockWeight = maxBlockWeight.div(boundedWeight);
const maxTxPerBlockWeight = maxBlockWeight.toBn().div(boundedWeight);
const maxTxPerBlockLength = maxLength.div(boundedLength);

const maxTxPerBlock = BN.min(maxTxPerBlockWeight, maxTxPerBlockLength);
Expand Down Expand Up @@ -137,7 +139,10 @@ export class NodeTransactionPoolService extends AbstractService {
}

const { baseFee, lenFee, adjustedWeightFee } = inclusionFee.unwrap();
const computedInclusionFee = baseFee.add(lenFee).add(adjustedWeightFee);
const computedInclusionFee = baseFee
.toBn()
.add(lenFee)
.add(adjustedWeightFee);
const finalFee = computedInclusionFee.add(tip.toBn());
const virtualTip = finalFee.mul(operationalFeeMultiplier);
const scaledVirtualTip = this.maxReward(virtualTip, maxTxPerBlock);
Expand Down
4 changes: 3 additions & 1 deletion src/services/test-helpers/mock/mockApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ export const defaultMockApi = {
},
blockWeights: {
baseBlock: new BN(5481991000),
maxBlock: new BN(2000000000000),
maxBlock: {
refTime: polkadotRegistry.createType('Compact<u64>', 15),
},
perClass: {
normal: {
baseExtrinsic: new BN(85212000),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"encodedExtrinsic": "0x4d028400d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d0196a6cd1652fc83c449884f67e8f444587b69c5874512f1d746ff6f062a097b2acedfe8d2e07915b4c93cc1c3b48a16ebccc1db8eb810146373ba53c9f42ab48e4500000284d717050300e281b7ec09fb8420ca7ba3fbd627fbe203ff04b2ba0777ae1d8a6942257af0230700e8764817",
"hash": "0x2982aabb402ecd86ae7660956f073f96502950e4394dbd92a2fe15055ec041e2",
"tip": "100000000",
"priority": "1025600010256",
"priority": "100000001",
"partialFee": "149000000"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"encodedExtrinsic": "0x350284004adf51a47b72795366d52285e329229c836ea7bbfe139dbe8fa0700c4f86fc5601fc44dcd1994c111671b3577b02e391be8aff10f7ccf766f3189859ea343db041779a67f9357cba0ba051f83d63e45e7a88b5e2ca642181592052acd9f4ccc8821501c107000f03f2af187bbc8a4a2b5a28c2a3c2d85bf7e5b1700cbf1207a8e4c1eb7d8e7e4037350301",
"hash": "0x3275363a9fda2dd41f03689bd47bba64e01fa3e5b558d8b4bbeb0df70cdceb73",
"tip": "0",
"priority": "9663481275832",
"priority": "765000101",
"partialFee": "153000018"
}
]
Expand Down
11 changes: 10 additions & 1 deletion src/test-helpers/metadata/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import { kusamaRegistry } from '../registries/kusamaRegistry';
import {
polkadotRegistry,
polkadotRegistryV29,
polkadotRegistryV9300,
} from '../registries/polkadotRegistry';
import { kusamaMetadataV2008 } from './kusamaV2008Metadata';
import { polkadotMetadataRpcV16 } from './polkadotV16Metadata';
import { polkadotMetadataRpcV29 } from './polkadotV29Metadata';

import { polkadotMetadataRpcV9300 } from './polkadotV9300Metadata';
/**
* Metadata of the polkadotRegistry (v16).
*/
Expand All @@ -45,3 +46,11 @@ export const polkadotMetadataV29 = new Metadata(
polkadotRegistryV29,
polkadotMetadataRpcV29
);

/**
* Metadata of polkadotRegistry (v9300)
*/
export const polkadotMetadataV9300 = new Metadata(
polkadotRegistryV9300,
polkadotMetadataRpcV9300
);
Loading

0 comments on commit e6a70a3

Please sign in to comment.