A get() hit on the entry currently at the internal list tail ran the generic unlink in #toHead without retargeting #tail, leaving #tail pointing at the node just moved to the head. From that point keys()/entries() truncate, capacity eviction removes the most-recently- used entry instead of the least, and the maps and the list diverge: entries whose nodes have fallen off the walkable list can never become the tail, so neither capacity nor TTL eviction can ever remove them, while nodes for already-evicted keys stay pinned through the stale next/prev chains of retained nodes. Both populations accumulate for the lifetime of the provider, pinning their (potentially large) stringified-params keys. #toHead now handles the tail case explicitly: retarget #tail to ref.prev and close the list behind the moved node, never dereferencing the tail's own next pointer (which is not guaranteed valid - the first node inserted keeps its constructor self-referential pointers).
@polkadot/rpc-provider
Generic transport providers to handle the transport of method calls to and from Polkadot clients from applications interacting with it. It provides an interface to making RPC calls and is generally, unless you are operating at a low-level and taking care of encoding and decoding of parameters/results, it won't be directly used, rather only passed to a higher-level interface.
Provider Selection
There are three flavours of the providers provided, one allowing for using HTTP as a transport mechanism, the other using WebSockets, and the third one uses substrate light-client through @substrate/connect. It is generally recommended to use the WsProvider since in addition to standard calls, it allows for subscriptions where all changes to state can be pushed from the node to the client.
All providers are usable (as is the API), in both browser-based and Node.js environments. Polyfills for unsupported functionality are automatically applied based on feature-detection.
Usage
Installation -
yarn add @polkadot/rpc-provider
WebSocket Initialization -
import { WsProvider } from '@polkadot/rpc-provider';
// this is the actual default endpoint
const provider = new WsProvider('ws://127.0.0.1:9944');
const version = await provider.send('client_version', []);
console.log('client version', version);
HTTP Initialization -
import { HttpProvider } from '@polkadot/rpc-provider';
// this is the actual default endpoint
const provider = new HttpProvider('http://127.0.0.1:9933');
const version = await provider.send('chain_getBlockHash', []);
console.log('latest block Hash', hash);
@substrate/connect Initialization -
Instantiating a Provider for the Polkadot Relay Chain:
import { ScProvider } from '@polkadot/rpc-provider';
import * as Sc from '@substrate/connect';
const provider = new ScProvider(Sc, Sc.WellKnownChain.polkadot);
await provider.connect();
const version = await provider.send('chain_getBlockHash', []);
Instantiating a Provider for a Polkadot parachain:
import { ScProvider } from '@polkadot/rpc-provider';
import * as Sc from '@substrate/connect';
const polkadotProvider = new ScProvider(Sc, Sc.WellKnownChain.polkadot);
const parachainProvider = new ScProvider(Sc, parachainSpec, polkadotProvider);
await parachainProvider.connect();
const version = await parachainProvider.send('chain_getBlockHash', []);