From f46916b2153a27e6d3d29279de4351c6e691dac5 Mon Sep 17 00:00:00 2001 From: Jaco Date: Fri, 11 Jun 2021 19:09:47 +0300 Subject: [PATCH] djust keys/entries retrieval batch sizes (#3638) --- CHANGELOG.md | 2 ++ packages/api/src/base/Decorate.ts | 4 ++-- packages/types/src/codec/UInt.spec.ts | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 800f356379..e283ecd035 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,9 @@ Changes: - Do strict length checking on `[u8; ]` type inputs +- Adjust keys/entries retrieval batch sizes - Add upgrade block for Kusama 9040 +- Use `BN` imports from `@polkadot/util` ## 4.13.1 Jun 6, 2021 diff --git a/packages/api/src/base/Decorate.ts b/packages/api/src/base/Decorate.ts index 9eb068e6ae..9ba2df20f1 100644 --- a/packages/api/src/base/Decorate.ts +++ b/packages/api/src/base/Decorate.ts @@ -37,8 +37,8 @@ interface MetaDecoration { } // the max amount of keys/values that we will retrieve at once -const PAGE_SIZE_K = 768; // limited since the trie lookups are heavy -const PAGE_SIZE_V = 256; // limited since the data may be very large +const PAGE_SIZE_K = 1000; // limit aligned with the 1k on the node (trie lookups are heavy) +const PAGE_SIZE_V = 250; // limited since the data may be very large (e.g. misfiring elections) const l = logger('api/init'); diff --git a/packages/types/src/codec/UInt.spec.ts b/packages/types/src/codec/UInt.spec.ts index f806ad8f41..1b0a7436e5 100644 --- a/packages/types/src/codec/UInt.spec.ts +++ b/packages/types/src/codec/UInt.spec.ts @@ -1,7 +1,9 @@ // Copyright 2017-2021 @polkadot/types authors & contributors // SPDX-License-Identifier: Apache-2.0 -import { BN } from '@polkadot/util'; +import BNOrig from 'bn.js'; + +import { BN, BN_TWO } from '@polkadot/util'; import { TypeRegistry } from '../create'; import { UInt } from '.'; @@ -9,6 +11,19 @@ import { UInt } from '.'; describe('UInt', (): void => { const registry = new TypeRegistry(); + it('still has the BN interfaces', (): void => { + expect([ + new UInt(registry, 32).mul(BN_TWO).toNumber(), + new UInt(registry, 64).divn(2).toNumber() + ]).toEqual([64, 32]); + }); + + it('is a BN instance', (): void => { + expect( + BNOrig.isBN(new UInt(registry, 16)) + ).toBe(true); + }); + it('fails on a number that is too large for the bits specified', (): void => { expect( (): UInt => new UInt(registry, '12345678901234567890123456789012345678901234567890', 32)