@typeberry/lib 0.0.5 → 0.1.0-3c30204
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configs/index.d.ts +30 -28
- package/index.cjs +17540 -0
- package/index.d.ts +585 -461
- package/index.js +941 -868
- package/package.json +9 -2
package/index.d.ts
CHANGED
|
@@ -369,7 +369,7 @@ type Result$2<Ok, Error> = OkResult<Ok> | ErrorResult<Error>;
|
|
|
369
369
|
/** An indication of two possible outcomes returned from a function. */
|
|
370
370
|
declare const Result$2 = {
|
|
371
371
|
/** Create new [`Result`] with `Ok` status. */
|
|
372
|
-
ok: <Ok
|
|
372
|
+
ok: <Ok>(ok: Ok): OkResult<Ok> => {
|
|
373
373
|
check(ok !== undefined, "`Ok` type cannot be undefined.");
|
|
374
374
|
return {
|
|
375
375
|
isOk: true,
|
|
@@ -379,7 +379,7 @@ declare const Result$2 = {
|
|
|
379
379
|
},
|
|
380
380
|
|
|
381
381
|
/** Create new [`Result`] with `Error` status. */
|
|
382
|
-
error: <
|
|
382
|
+
error: <Error>(error: Error, details = ""): ErrorResult<Error> => {
|
|
383
383
|
check(error !== undefined, "`Error` type cannot be undefined.");
|
|
384
384
|
return {
|
|
385
385
|
isOk: false,
|
|
@@ -3447,6 +3447,8 @@ type KeccakHash = Bytes<HASH_SIZE>;
|
|
|
3447
3447
|
/** Truncated hash. */
|
|
3448
3448
|
type TruncatedHash = Bytes<TRUNCATED_HASH_SIZE>;
|
|
3449
3449
|
|
|
3450
|
+
declare const ZERO_HASH = Bytes.zero(HASH_SIZE);
|
|
3451
|
+
|
|
3450
3452
|
/**
|
|
3451
3453
|
* Container for some object with a hash that is related to this object.
|
|
3452
3454
|
*
|
|
@@ -3655,11 +3657,12 @@ type index$n_WithHash<THash extends OpaqueHash, TData> = WithHash<THash, TData>;
|
|
|
3655
3657
|
declare const index$n_WithHash: typeof WithHash;
|
|
3656
3658
|
type index$n_WithHashAndBytes<THash extends OpaqueHash, TData> = WithHashAndBytes<THash, TData>;
|
|
3657
3659
|
declare const index$n_WithHashAndBytes: typeof WithHashAndBytes;
|
|
3660
|
+
declare const index$n_ZERO_HASH: typeof ZERO_HASH;
|
|
3658
3661
|
declare const index$n_blake2b: typeof blake2b;
|
|
3659
3662
|
declare const index$n_defaultAllocator: typeof defaultAllocator;
|
|
3660
3663
|
declare const index$n_keccak: typeof keccak;
|
|
3661
3664
|
declare namespace index$n {
|
|
3662
|
-
export { index$n_PageAllocator as PageAllocator, index$n_SimpleAllocator as SimpleAllocator, index$n_WithHash as WithHash, index$n_WithHashAndBytes as WithHashAndBytes, index$n_blake2b as blake2b, index$n_defaultAllocator as defaultAllocator, index$n_keccak as keccak };
|
|
3665
|
+
export { index$n_PageAllocator as PageAllocator, index$n_SimpleAllocator as SimpleAllocator, index$n_WithHash as WithHash, index$n_WithHashAndBytes as WithHashAndBytes, index$n_ZERO_HASH as ZERO_HASH, index$n_blake2b as blake2b, index$n_defaultAllocator as defaultAllocator, index$n_keccak as keccak };
|
|
3663
3666
|
export type { index$n_Blake2bHash as Blake2bHash, index$n_HASH_SIZE as HASH_SIZE, index$n_HashAllocator as HashAllocator, index$n_KeccakHash as KeccakHash, index$n_OpaqueHash as OpaqueHash, index$n_TRUNCATED_HASH_SIZE as TRUNCATED_HASH_SIZE, index$n_TruncatedHash as TruncatedHash };
|
|
3664
3667
|
}
|
|
3665
3668
|
|
|
@@ -4474,6 +4477,9 @@ declare namespace bandersnatch_d_exports {
|
|
|
4474
4477
|
}
|
|
4475
4478
|
/* tslint:disable */
|
|
4476
4479
|
/* eslint-disable */
|
|
4480
|
+
/**
|
|
4481
|
+
* Generate ring commitment given concatenation of ring keys.
|
|
4482
|
+
*/
|
|
4477
4483
|
declare function ring_commitment(keys: Uint8Array): Uint8Array;
|
|
4478
4484
|
/**
|
|
4479
4485
|
* Derive Private and Public Key from Seed
|
|
@@ -4487,21 +4493,21 @@ declare function derive_public_key(seed: Uint8Array): Uint8Array;
|
|
|
4487
4493
|
* or
|
|
4488
4494
|
* https://graypaper.fluffylabs.dev/#/68eaa1f/0e54010e5401?v=0.6.4
|
|
4489
4495
|
*/
|
|
4490
|
-
declare function verify_seal(
|
|
4496
|
+
declare function verify_seal(signer_key: Uint8Array, seal_data: Uint8Array, payload: Uint8Array, aux_data: Uint8Array): Uint8Array;
|
|
4491
4497
|
/**
|
|
4492
4498
|
* Verify multiple tickets at once as defined in:
|
|
4493
4499
|
* https://graypaper.fluffylabs.dev/#/68eaa1f/0f3e000f3e00?v=0.6.4
|
|
4494
4500
|
*
|
|
4495
4501
|
* NOTE: the aux_data of VRF function is empty!
|
|
4496
4502
|
*/
|
|
4497
|
-
declare function batch_verify_tickets(
|
|
4503
|
+
declare function batch_verify_tickets(ring_size: number, commitment: Uint8Array, tickets_data: Uint8Array, vrf_input_data_len: number): Uint8Array;
|
|
4498
4504
|
type InitInput$2 = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
4499
4505
|
interface InitOutput$2 {
|
|
4500
4506
|
readonly memory: WebAssembly.Memory;
|
|
4501
4507
|
readonly ring_commitment: (a: number, b: number) => [number, number];
|
|
4502
4508
|
readonly derive_public_key: (a: number, b: number) => [number, number];
|
|
4503
|
-
readonly verify_seal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number
|
|
4504
|
-
readonly batch_verify_tickets: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
4509
|
+
readonly verify_seal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
|
|
4510
|
+
readonly batch_verify_tickets: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
4505
4511
|
readonly __wbindgen_export_0: WebAssembly.Table;
|
|
4506
4512
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
4507
4513
|
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
@@ -7852,6 +7858,173 @@ declare class JipChainSpec extends WithDebug {
|
|
|
7852
7858
|
}
|
|
7853
7859
|
}
|
|
7854
7860
|
|
|
7861
|
+
declare enum Level {
|
|
7862
|
+
INSANE = 1,
|
|
7863
|
+
TRACE = 2,
|
|
7864
|
+
LOG = 3,
|
|
7865
|
+
INFO = 4,
|
|
7866
|
+
WARN = 5,
|
|
7867
|
+
ERROR = 6,
|
|
7868
|
+
}
|
|
7869
|
+
|
|
7870
|
+
type Options = {
|
|
7871
|
+
defaultLevel: Level;
|
|
7872
|
+
workingDir: string;
|
|
7873
|
+
modules: Map<string, Level>;
|
|
7874
|
+
};
|
|
7875
|
+
|
|
7876
|
+
/**
|
|
7877
|
+
* A function to parse logger definition (including modules) given as a string.
|
|
7878
|
+
*
|
|
7879
|
+
* Examples
|
|
7880
|
+
* - `info` - setup default logging level to `info`.
|
|
7881
|
+
* - `trace` - default logging level set to `trace`.
|
|
7882
|
+
* - `debug;consensus=trace` - default level is set to `debug/log`, but consensus is in trace mode.
|
|
7883
|
+
*/
|
|
7884
|
+
declare function parseLoggerOptions(input: string, defaultLevel: Level, workingDir?: string): Options {
|
|
7885
|
+
const modules = new Map<string, Level>();
|
|
7886
|
+
const parts = input.toLowerCase().split(",");
|
|
7887
|
+
let defLevel = defaultLevel;
|
|
7888
|
+
|
|
7889
|
+
for (const p of parts) {
|
|
7890
|
+
const clean = p.trim();
|
|
7891
|
+
// skip empty objects (forgotten `,` removed)
|
|
7892
|
+
if (clean.length === 0) {
|
|
7893
|
+
continue;
|
|
7894
|
+
}
|
|
7895
|
+
// we just have the default level
|
|
7896
|
+
if (clean.includes("=")) {
|
|
7897
|
+
const [mod, lvl] = clean.split("=");
|
|
7898
|
+
modules.set(mod.trim(), parseLevel(lvl.trim()));
|
|
7899
|
+
} else {
|
|
7900
|
+
defLevel = parseLevel(clean);
|
|
7901
|
+
}
|
|
7902
|
+
}
|
|
7903
|
+
|
|
7904
|
+
// TODO [ToDr] Fix dirname for workers.
|
|
7905
|
+
const myDir = (import.meta.dirname ?? "").split("/");
|
|
7906
|
+
myDir.pop();
|
|
7907
|
+
myDir.pop();
|
|
7908
|
+
return {
|
|
7909
|
+
defaultLevel: defLevel,
|
|
7910
|
+
modules,
|
|
7911
|
+
workingDir: workingDir ?? myDir.join("/"),
|
|
7912
|
+
};
|
|
7913
|
+
}
|
|
7914
|
+
|
|
7915
|
+
declare const GLOBAL_CONFIG = {
|
|
7916
|
+
options: DEFAULT_OPTIONS,
|
|
7917
|
+
transport: ConsoleTransport.create(DEFAULT_OPTIONS.defaultLevel, DEFAULT_OPTIONS),
|
|
7918
|
+
};
|
|
7919
|
+
|
|
7920
|
+
/**
|
|
7921
|
+
* A logger instance.
|
|
7922
|
+
*/
|
|
7923
|
+
declare class Logger {
|
|
7924
|
+
/**
|
|
7925
|
+
* Create a new logger instance given filename and an optional module name.
|
|
7926
|
+
*
|
|
7927
|
+
* If the module name is not given, `fileName` becomes the module name.
|
|
7928
|
+
* The module name can be composed from multiple parts separated with `/`.
|
|
7929
|
+
*
|
|
7930
|
+
* The logger will use a global configuration which can be changed using
|
|
7931
|
+
* [`configureLogger`] function.
|
|
7932
|
+
*/
|
|
7933
|
+
static new(fileName?: string, moduleName?: string) {
|
|
7934
|
+
const fName = fileName ?? "unknown";
|
|
7935
|
+
const module = moduleName ?? fName;
|
|
7936
|
+
return new Logger(module.padStart(8, " "), GLOBAL_CONFIG);
|
|
7937
|
+
}
|
|
7938
|
+
|
|
7939
|
+
/**
|
|
7940
|
+
* Return currently configured level for given module. */
|
|
7941
|
+
static getLevel(moduleName: string): Level {
|
|
7942
|
+
return findLevel(GLOBAL_CONFIG.options, moduleName);
|
|
7943
|
+
}
|
|
7944
|
+
|
|
7945
|
+
/**
|
|
7946
|
+
* Global configuration of all loggers.
|
|
7947
|
+
*
|
|
7948
|
+
* One can specify a default logging level (only logs with level >= default will be printed).
|
|
7949
|
+
* It's also possible to configure per-module logging level that takes precedence
|
|
7950
|
+
* over the default one.
|
|
7951
|
+
*
|
|
7952
|
+
* Changing the options affects all previously created loggers.
|
|
7953
|
+
*/
|
|
7954
|
+
static configureAllFromOptions(options: Options) {
|
|
7955
|
+
// find minimal level to optimise logging in case
|
|
7956
|
+
// we don't care about low-level logs.
|
|
7957
|
+
const minimalLevel = Array.from(options.modules.values()).reduce((level, modLevel) => {
|
|
7958
|
+
return level < modLevel ? level : modLevel;
|
|
7959
|
+
}, options.defaultLevel);
|
|
7960
|
+
|
|
7961
|
+
const transport = ConsoleTransport.create(minimalLevel, options);
|
|
7962
|
+
|
|
7963
|
+
// set the global config
|
|
7964
|
+
GLOBAL_CONFIG.options = options;
|
|
7965
|
+
GLOBAL_CONFIG.transport = transport;
|
|
7966
|
+
}
|
|
7967
|
+
|
|
7968
|
+
/**
|
|
7969
|
+
* Global configuration of all loggers.
|
|
7970
|
+
*
|
|
7971
|
+
* Parse configuration options from an input string typically obtained
|
|
7972
|
+
* from environment variable `JAM_LOG`.
|
|
7973
|
+
*/
|
|
7974
|
+
static configureAll(input: string, defaultLevel: Level, workingDir?: string) {
|
|
7975
|
+
const options = parseLoggerOptions(input, defaultLevel, workingDir);
|
|
7976
|
+
Logger.configureAllFromOptions(options);
|
|
7977
|
+
}
|
|
7978
|
+
|
|
7979
|
+
private constructor(
|
|
7980
|
+
private readonly moduleName: string,
|
|
7981
|
+
private readonly config: typeof GLOBAL_CONFIG,
|
|
7982
|
+
) {}
|
|
7983
|
+
|
|
7984
|
+
/** Log a message with `INSANE` level. */
|
|
7985
|
+
insane(val: string) {
|
|
7986
|
+
this.config.transport.insane(this.moduleName, val);
|
|
7987
|
+
}
|
|
7988
|
+
|
|
7989
|
+
/** Log a message with `TRACE` level. */
|
|
7990
|
+
trace(val: string) {
|
|
7991
|
+
this.config.transport.trace(this.moduleName, val);
|
|
7992
|
+
}
|
|
7993
|
+
|
|
7994
|
+
/** Log a message with `DEBUG`/`LOG` level. */
|
|
7995
|
+
log(val: string) {
|
|
7996
|
+
this.config.transport.log(this.moduleName, val);
|
|
7997
|
+
}
|
|
7998
|
+
|
|
7999
|
+
/** Log a message with `INFO` level. */
|
|
8000
|
+
info(val: string) {
|
|
8001
|
+
this.config.transport.info(this.moduleName, val);
|
|
8002
|
+
}
|
|
8003
|
+
|
|
8004
|
+
/** Log a message with `WARN` level. */
|
|
8005
|
+
warn(val: string) {
|
|
8006
|
+
this.config.transport.warn(this.moduleName, val);
|
|
8007
|
+
}
|
|
8008
|
+
|
|
8009
|
+
/** Log a message with `ERROR` level. */
|
|
8010
|
+
error(val: string) {
|
|
8011
|
+
this.config.transport.error(this.moduleName, val);
|
|
8012
|
+
}
|
|
8013
|
+
}
|
|
8014
|
+
|
|
8015
|
+
type index$g_Level = Level;
|
|
8016
|
+
declare const index$g_Level: typeof Level;
|
|
8017
|
+
type index$g_Logger = Logger;
|
|
8018
|
+
declare const index$g_Logger: typeof Logger;
|
|
8019
|
+
declare const index$g_parseLoggerOptions: typeof parseLoggerOptions;
|
|
8020
|
+
declare namespace index$g {
|
|
8021
|
+
export {
|
|
8022
|
+
index$g_Level as Level,
|
|
8023
|
+
index$g_Logger as Logger,
|
|
8024
|
+
index$g_parseLoggerOptions as parseLoggerOptions,
|
|
8025
|
+
};
|
|
8026
|
+
}
|
|
8027
|
+
|
|
7855
8028
|
/** Block authorship options. */
|
|
7856
8029
|
declare class AuthorshipOptions {
|
|
7857
8030
|
static fromJson = json.object<JsonObject<AuthorshipOptions>, AuthorshipOptions>(
|
|
@@ -7871,6 +8044,8 @@ declare class AuthorshipOptions {
|
|
|
7871
8044
|
) {}
|
|
7872
8045
|
}
|
|
7873
8046
|
|
|
8047
|
+
declare const logger$1 = Logger.new(import.meta.filename, "config");
|
|
8048
|
+
|
|
7874
8049
|
/** Development config. Will accept unsealed blocks for now. */
|
|
7875
8050
|
declare const DEV_CONFIG = "dev";
|
|
7876
8051
|
/** Default config file. */
|
|
@@ -7932,14 +8107,17 @@ declare class NodeConfiguration {
|
|
|
7932
8107
|
|
|
7933
8108
|
declare function loadConfig(configPath: string): NodeConfiguration {
|
|
7934
8109
|
if (configPath === DEFAULT_CONFIG) {
|
|
8110
|
+
logger.log("🔧 Loading DEFAULT config");
|
|
7935
8111
|
return parseFromJson(configs.default, NodeConfiguration.fromJson);
|
|
7936
8112
|
}
|
|
7937
8113
|
|
|
7938
8114
|
if (configPath === DEV_CONFIG) {
|
|
8115
|
+
logger.log("🔧 Loading DEV config");
|
|
7939
8116
|
return parseFromJson(configs.dev, NodeConfiguration.fromJson);
|
|
7940
8117
|
}
|
|
7941
8118
|
|
|
7942
8119
|
try {
|
|
8120
|
+
logger.log(`🔧 Loading config from ${configPath}`);
|
|
7943
8121
|
const configFile = fs.readFileSync(configPath, "utf8");
|
|
7944
8122
|
const parsed = JSON.parse(configFile);
|
|
7945
8123
|
return parseFromJson(parsed, NodeConfiguration.fromJson);
|
|
@@ -7948,29 +8126,30 @@ declare function loadConfig(configPath: string): NodeConfiguration {
|
|
|
7948
8126
|
}
|
|
7949
8127
|
}
|
|
7950
8128
|
|
|
7951
|
-
declare const index$
|
|
7952
|
-
declare const index$
|
|
7953
|
-
type index$
|
|
7954
|
-
declare const index$
|
|
7955
|
-
type index$
|
|
7956
|
-
declare const index$
|
|
7957
|
-
declare const index$
|
|
7958
|
-
type index$
|
|
7959
|
-
declare const index$
|
|
7960
|
-
declare const index$
|
|
7961
|
-
declare const index$
|
|
7962
|
-
declare const index$
|
|
7963
|
-
declare namespace index$
|
|
8129
|
+
declare const index$f_DEFAULT_CONFIG: typeof DEFAULT_CONFIG;
|
|
8130
|
+
declare const index$f_DEV_CONFIG: typeof DEV_CONFIG;
|
|
8131
|
+
type index$f_JipChainSpec = JipChainSpec;
|
|
8132
|
+
declare const index$f_JipChainSpec: typeof JipChainSpec;
|
|
8133
|
+
type index$f_KnownChainSpec = KnownChainSpec;
|
|
8134
|
+
declare const index$f_KnownChainSpec: typeof KnownChainSpec;
|
|
8135
|
+
declare const index$f_NODE_DEFAULTS: typeof NODE_DEFAULTS;
|
|
8136
|
+
type index$f_NodeConfiguration = NodeConfiguration;
|
|
8137
|
+
declare const index$f_NodeConfiguration: typeof NodeConfiguration;
|
|
8138
|
+
declare const index$f_knownChainSpecFromJson: typeof knownChainSpecFromJson;
|
|
8139
|
+
declare const index$f_loadConfig: typeof loadConfig;
|
|
8140
|
+
declare const index$f_parseBootnode: typeof parseBootnode;
|
|
8141
|
+
declare namespace index$f {
|
|
7964
8142
|
export {
|
|
7965
|
-
index$
|
|
7966
|
-
index$
|
|
7967
|
-
index$
|
|
7968
|
-
index$
|
|
7969
|
-
index$
|
|
7970
|
-
index$
|
|
7971
|
-
index$
|
|
7972
|
-
index$
|
|
7973
|
-
|
|
8143
|
+
index$f_DEFAULT_CONFIG as DEFAULT_CONFIG,
|
|
8144
|
+
index$f_DEV_CONFIG as DEV_CONFIG,
|
|
8145
|
+
index$f_JipChainSpec as JipChainSpec,
|
|
8146
|
+
index$f_KnownChainSpec as KnownChainSpec,
|
|
8147
|
+
index$f_NODE_DEFAULTS as NODE_DEFAULTS,
|
|
8148
|
+
index$f_NodeConfiguration as NodeConfiguration,
|
|
8149
|
+
index$f_knownChainSpecFromJson as knownChainSpecFromJson,
|
|
8150
|
+
index$f_loadConfig as loadConfig,
|
|
8151
|
+
logger$1 as logger,
|
|
8152
|
+
index$f_parseBootnode as parseBootnode,
|
|
7974
8153
|
};
|
|
7975
8154
|
}
|
|
7976
8155
|
|
|
@@ -8357,7 +8536,9 @@ declare class WriteableNodesDb extends NodesDb {
|
|
|
8357
8536
|
}
|
|
8358
8537
|
}
|
|
8359
8538
|
|
|
8360
|
-
|
|
8539
|
+
/** Compare two trie `LeafNode`s only by their key. */
|
|
8540
|
+
declare const leafComparator = (x: LeafNode, y: LeafNode) => x.getKey().compare(y.getKey());
|
|
8541
|
+
declare const zero = Bytes.zero(HASH_SIZE).asOpaque();
|
|
8361
8542
|
|
|
8362
8543
|
declare class InMemoryTrie {
|
|
8363
8544
|
/** Create an empty in-memory trie. */
|
|
@@ -8366,10 +8547,87 @@ declare class InMemoryTrie {
|
|
|
8366
8547
|
}
|
|
8367
8548
|
|
|
8368
8549
|
/** Given a collection of leaves, compute the state root. */
|
|
8369
|
-
static computeStateRoot(hasher: TrieHasher, leaves:
|
|
8370
|
-
|
|
8371
|
-
|
|
8372
|
-
|
|
8550
|
+
static computeStateRoot(hasher: TrieHasher, leaves: SortedSet<LeafNode>): TrieNodeHash {
|
|
8551
|
+
const sorted = leaves.slice();
|
|
8552
|
+
const firstSorted = sorted.shift();
|
|
8553
|
+
if (firstSorted === undefined) {
|
|
8554
|
+
return zero;
|
|
8555
|
+
}
|
|
8556
|
+
|
|
8557
|
+
const nodes = [
|
|
8558
|
+
{
|
|
8559
|
+
leaf: firstSorted,
|
|
8560
|
+
sharedBitsWithPrev: 0,
|
|
8561
|
+
},
|
|
8562
|
+
];
|
|
8563
|
+
let last = nodes[0];
|
|
8564
|
+
// first we go through all of the sorted leaves and figure out how much in common
|
|
8565
|
+
// they have with the previous node.
|
|
8566
|
+
// If the shared-prefix drops, it means we are going up in depth (i.e. we are in different branch).
|
|
8567
|
+
for (const leaf of sorted) {
|
|
8568
|
+
const sharedBitsCount = findSharedPrefix(leaf.getKey(), last.leaf.getKey());
|
|
8569
|
+
last = {
|
|
8570
|
+
leaf,
|
|
8571
|
+
sharedBitsWithPrev: sharedBitsCount,
|
|
8572
|
+
};
|
|
8573
|
+
nodes.push(last);
|
|
8574
|
+
}
|
|
8575
|
+
// Now we will go backwards and hash them together (or create branch nodes).
|
|
8576
|
+
nodes.reverse();
|
|
8577
|
+
const stack: TrieNodeHash[] = [];
|
|
8578
|
+
let currentDepth = 0;
|
|
8579
|
+
const lastNode = nodes.length === 1 ? undefined : nodes[nodes.length - 1];
|
|
8580
|
+
for (const node of nodes) {
|
|
8581
|
+
const isLastNode = node === lastNode;
|
|
8582
|
+
const key = node.leaf.getKey();
|
|
8583
|
+
const prevDepth = currentDepth;
|
|
8584
|
+
currentDepth = node.sharedBitsWithPrev;
|
|
8585
|
+
|
|
8586
|
+
// first push all missing right-hand zero nodes.
|
|
8587
|
+
// Handle the case if all nodes are on the left side and we need one more top-level
|
|
8588
|
+
// extra.
|
|
8589
|
+
const startDepth = isLastNode ? prevDepth : prevDepth + 1;
|
|
8590
|
+
for (let i = startDepth; i <= currentDepth; i++) {
|
|
8591
|
+
if (getBit(key, i) === false) {
|
|
8592
|
+
stack.push(zero);
|
|
8593
|
+
}
|
|
8594
|
+
}
|
|
8595
|
+
|
|
8596
|
+
// now let's push the hash of the current leaf
|
|
8597
|
+
const hash = hasher.hashConcat(node.leaf.node.raw);
|
|
8598
|
+
stack.push(hash);
|
|
8599
|
+
// we are going further down, so no need to merge anything
|
|
8600
|
+
if (prevDepth < currentDepth) {
|
|
8601
|
+
continue;
|
|
8602
|
+
}
|
|
8603
|
+
// jumping back to some lower depth, we need to merge what we have on the stack.
|
|
8604
|
+
// we need to handle a case where we have no nodes on the top-most left side.
|
|
8605
|
+
// in such case we just add extra zero on the left.
|
|
8606
|
+
const endDepth = isLastNode ? currentDepth - 1 : currentDepth;
|
|
8607
|
+
for (let i = prevDepth; i > endDepth; i--) {
|
|
8608
|
+
if (getBit(key, i) === true) {
|
|
8609
|
+
stack.push(zero);
|
|
8610
|
+
}
|
|
8611
|
+
const current = stack.pop() ?? zero;
|
|
8612
|
+
const next = stack.pop() ?? zero;
|
|
8613
|
+
const branchNode = BranchNode.fromSubNodes(current, next);
|
|
8614
|
+
const hash = hasher.hashConcat(branchNode.node.raw);
|
|
8615
|
+
stack.push(hash);
|
|
8616
|
+
}
|
|
8617
|
+
}
|
|
8618
|
+
|
|
8619
|
+
return stack.pop() ?? zero;
|
|
8620
|
+
}
|
|
8621
|
+
|
|
8622
|
+
/**
|
|
8623
|
+
* Construct a `LeafNode` from given `key` and `value`.
|
|
8624
|
+
*
|
|
8625
|
+
* NOTE: for large value it WILL NOT be embedded in the leaf node,
|
|
8626
|
+
* and should rather be stored separately.
|
|
8627
|
+
*/
|
|
8628
|
+
static constructLeaf(hasher: TrieHasher, key: InputKey, value: BytesBlob, maybeValueHash?: ValueHash) {
|
|
8629
|
+
const valueHash = () => maybeValueHash ?? hasher.hashConcat(value.raw).asOpaque();
|
|
8630
|
+
return LeafNode.fromValue(key, value, valueHash);
|
|
8373
8631
|
}
|
|
8374
8632
|
|
|
8375
8633
|
/**
|
|
@@ -8387,11 +8645,6 @@ declare class InMemoryTrie {
|
|
|
8387
8645
|
return new InMemoryTrie(nodes, root);
|
|
8388
8646
|
}
|
|
8389
8647
|
|
|
8390
|
-
static constructLeaf(hasher: TrieHasher, key: InputKey, value: BytesBlob, maybeValueHash?: ValueHash) {
|
|
8391
|
-
const valueHash = () => maybeValueHash ?? hasher.hashConcat(value.raw).asOpaque();
|
|
8392
|
-
return LeafNode.fromValue(key, value, valueHash);
|
|
8393
|
-
}
|
|
8394
|
-
|
|
8395
8648
|
private constructor(
|
|
8396
8649
|
// Exposed for trie-visualiser
|
|
8397
8650
|
public readonly nodes: WriteableNodesDb,
|
|
@@ -8518,7 +8771,7 @@ declare function findNodeToReplace(root: TrieNode, nodes: NodesDb, key: Truncate
|
|
|
8518
8771
|
|
|
8519
8772
|
const nextNode = nodes.get(nextHash);
|
|
8520
8773
|
if (nextNode === null) {
|
|
8521
|
-
if (nextHash.isEqualTo(
|
|
8774
|
+
if (nextHash.isEqualTo(zero)) {
|
|
8522
8775
|
return traversedPath;
|
|
8523
8776
|
}
|
|
8524
8777
|
|
|
@@ -8654,40 +8907,72 @@ declare function trieStringify(root: TrieNode | null, nodes: NodesDb): string {
|
|
|
8654
8907
|
return `\nLeaf('${leaf.getKey().toString()}',${value})`;
|
|
8655
8908
|
}
|
|
8656
8909
|
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
declare const index$
|
|
8688
|
-
|
|
8689
|
-
|
|
8690
|
-
|
|
8910
|
+
declare function findSharedPrefix(a: TruncatedStateKey, b: TruncatedStateKey) {
|
|
8911
|
+
for (let i = 0; i < TRUNCATED_HASH_SIZE; i++) {
|
|
8912
|
+
const diff = a.raw[i] ^ b.raw[i];
|
|
8913
|
+
if (diff === 0) {
|
|
8914
|
+
continue;
|
|
8915
|
+
}
|
|
8916
|
+
// check how many bits match
|
|
8917
|
+
for (const [mask, matchingBits] of bitLookup) {
|
|
8918
|
+
if ((mask & diff) !== 0) {
|
|
8919
|
+
return i * 8 + matchingBits;
|
|
8920
|
+
}
|
|
8921
|
+
}
|
|
8922
|
+
return i;
|
|
8923
|
+
}
|
|
8924
|
+
return TRUNCATED_HASH_SIZE * 8;
|
|
8925
|
+
}
|
|
8926
|
+
|
|
8927
|
+
declare const bitLookup = [
|
|
8928
|
+
[0b10000000, 0],
|
|
8929
|
+
[0b01000000, 1],
|
|
8930
|
+
[0b00100000, 2],
|
|
8931
|
+
[0b00010000, 3],
|
|
8932
|
+
[0b00001000, 4],
|
|
8933
|
+
[0b00000100, 5],
|
|
8934
|
+
[0b00000010, 6],
|
|
8935
|
+
[0b00000001, 7],
|
|
8936
|
+
[0b00000000, 8],
|
|
8937
|
+
];
|
|
8938
|
+
|
|
8939
|
+
type index$e_BranchNode = BranchNode;
|
|
8940
|
+
declare const index$e_BranchNode: typeof BranchNode;
|
|
8941
|
+
type index$e_InMemoryTrie = InMemoryTrie;
|
|
8942
|
+
declare const index$e_InMemoryTrie: typeof InMemoryTrie;
|
|
8943
|
+
type index$e_InputKey = InputKey;
|
|
8944
|
+
type index$e_LeafNode = LeafNode;
|
|
8945
|
+
declare const index$e_LeafNode: typeof LeafNode;
|
|
8946
|
+
type index$e_NodeType = NodeType;
|
|
8947
|
+
declare const index$e_NodeType: typeof NodeType;
|
|
8948
|
+
type index$e_NodesDb = NodesDb;
|
|
8949
|
+
declare const index$e_NodesDb: typeof NodesDb;
|
|
8950
|
+
declare const index$e_TRIE_NODE_BYTES: typeof TRIE_NODE_BYTES;
|
|
8951
|
+
declare const index$e_TRUNCATED_KEY_BITS: typeof TRUNCATED_KEY_BITS;
|
|
8952
|
+
type index$e_TRUNCATED_KEY_BYTES = TRUNCATED_KEY_BYTES;
|
|
8953
|
+
type index$e_TraversedPath = TraversedPath;
|
|
8954
|
+
declare const index$e_TraversedPath: typeof TraversedPath;
|
|
8955
|
+
type index$e_TrieHasher = TrieHasher;
|
|
8956
|
+
type index$e_TrieNode = TrieNode;
|
|
8957
|
+
declare const index$e_TrieNode: typeof TrieNode;
|
|
8958
|
+
type index$e_TrieNodeHash = TrieNodeHash;
|
|
8959
|
+
type index$e_TruncatedStateKey = TruncatedStateKey;
|
|
8960
|
+
type index$e_ValueHash = ValueHash;
|
|
8961
|
+
type index$e_WriteableNodesDb = WriteableNodesDb;
|
|
8962
|
+
declare const index$e_WriteableNodesDb: typeof WriteableNodesDb;
|
|
8963
|
+
declare const index$e_bitLookup: typeof bitLookup;
|
|
8964
|
+
declare const index$e_createSubtreeForBothLeaves: typeof createSubtreeForBothLeaves;
|
|
8965
|
+
declare const index$e_findNodeToReplace: typeof findNodeToReplace;
|
|
8966
|
+
declare const index$e_findSharedPrefix: typeof findSharedPrefix;
|
|
8967
|
+
declare const index$e_getBit: typeof getBit;
|
|
8968
|
+
declare const index$e_leafComparator: typeof leafComparator;
|
|
8969
|
+
declare const index$e_parseInputKey: typeof parseInputKey;
|
|
8970
|
+
declare const index$e_trieInsert: typeof trieInsert;
|
|
8971
|
+
declare const index$e_trieStringify: typeof trieStringify;
|
|
8972
|
+
declare const index$e_zero: typeof zero;
|
|
8973
|
+
declare namespace index$e {
|
|
8974
|
+
export { index$e_BranchNode as BranchNode, index$e_InMemoryTrie as InMemoryTrie, index$e_LeafNode as LeafNode, index$e_NodeType as NodeType, index$e_NodesDb as NodesDb, index$e_TRIE_NODE_BYTES as TRIE_NODE_BYTES, index$e_TRUNCATED_KEY_BITS as TRUNCATED_KEY_BITS, index$e_TraversedPath as TraversedPath, index$e_TrieNode as TrieNode, index$e_WriteableNodesDb as WriteableNodesDb, index$e_bitLookup as bitLookup, index$e_createSubtreeForBothLeaves as createSubtreeForBothLeaves, index$e_findNodeToReplace as findNodeToReplace, index$e_findSharedPrefix as findSharedPrefix, index$e_getBit as getBit, index$e_leafComparator as leafComparator, index$e_parseInputKey as parseInputKey, index$e_trieInsert as trieInsert, index$e_trieStringify as trieStringify, index$e_zero as zero };
|
|
8975
|
+
export type { index$e_InputKey as InputKey, StateKey$1 as StateKey, index$e_TRUNCATED_KEY_BYTES as TRUNCATED_KEY_BYTES, index$e_TrieHasher as TrieHasher, index$e_TrieNodeHash as TrieNodeHash, index$e_TruncatedStateKey as TruncatedStateKey, index$e_ValueHash as ValueHash };
|
|
8691
8976
|
}
|
|
8692
8977
|
|
|
8693
8978
|
/**
|
|
@@ -8743,6 +9028,20 @@ declare class AccumulationOutput {
|
|
|
8743
9028
|
) {}
|
|
8744
9029
|
}
|
|
8745
9030
|
|
|
9031
|
+
declare function accumulationOutputComparator(a: AccumulationOutput, b: AccumulationOutput) {
|
|
9032
|
+
const result = a.serviceId - b.serviceId;
|
|
9033
|
+
|
|
9034
|
+
if (result < 0) {
|
|
9035
|
+
return Ordering.Less;
|
|
9036
|
+
}
|
|
9037
|
+
|
|
9038
|
+
if (result > 0) {
|
|
9039
|
+
return Ordering.Greater;
|
|
9040
|
+
}
|
|
9041
|
+
|
|
9042
|
+
return Ordering.Equal;
|
|
9043
|
+
}
|
|
9044
|
+
|
|
8746
9045
|
declare const codecWithHash = <T, V, H extends OpaqueHash>(val: Descriptor<T, V>): Descriptor<WithHash<H, T>, V> =>
|
|
8747
9046
|
Descriptor.withView(
|
|
8748
9047
|
val.name,
|
|
@@ -9115,16 +9414,16 @@ declare class Mountain<H extends OpaqueHash> {
|
|
|
9115
9414
|
}
|
|
9116
9415
|
}
|
|
9117
9416
|
|
|
9118
|
-
type index$
|
|
9119
|
-
declare const index$
|
|
9120
|
-
type index$
|
|
9121
|
-
type index$
|
|
9122
|
-
type index$
|
|
9123
|
-
declare const index$
|
|
9124
|
-
declare const index$
|
|
9125
|
-
declare namespace index$
|
|
9126
|
-
export { index$
|
|
9127
|
-
export type { index$
|
|
9417
|
+
type index$d_MerkleMountainRange<H extends OpaqueHash> = MerkleMountainRange<H>;
|
|
9418
|
+
declare const index$d_MerkleMountainRange: typeof MerkleMountainRange;
|
|
9419
|
+
type index$d_MmrHasher<H extends OpaqueHash> = MmrHasher<H>;
|
|
9420
|
+
type index$d_MmrPeaks<H extends OpaqueHash> = MmrPeaks<H>;
|
|
9421
|
+
type index$d_Mountain<H extends OpaqueHash> = Mountain<H>;
|
|
9422
|
+
declare const index$d_Mountain: typeof Mountain;
|
|
9423
|
+
declare const index$d_SUPER_PEAK_STRING: typeof SUPER_PEAK_STRING;
|
|
9424
|
+
declare namespace index$d {
|
|
9425
|
+
export { index$d_MerkleMountainRange as MerkleMountainRange, index$d_Mountain as Mountain, index$d_SUPER_PEAK_STRING as SUPER_PEAK_STRING };
|
|
9426
|
+
export type { index$d_MmrHasher as MmrHasher, index$d_MmrPeaks as MmrPeaks };
|
|
9128
9427
|
}
|
|
9129
9428
|
|
|
9130
9429
|
/**
|
|
@@ -10043,7 +10342,7 @@ type State = {
|
|
|
10043
10342
|
*
|
|
10044
10343
|
* NOTE Maximum size of this array is unspecified in GP
|
|
10045
10344
|
*/
|
|
10046
|
-
readonly accumulationOutputLog: AccumulationOutput
|
|
10345
|
+
readonly accumulationOutputLog: SortedArray<AccumulationOutput>;
|
|
10047
10346
|
|
|
10048
10347
|
/**
|
|
10049
10348
|
* Retrieve details about single service.
|
|
@@ -10631,7 +10930,7 @@ declare class InMemoryState extends WithDebug implements State, EnumerableState
|
|
|
10631
10930
|
sealingKeySeries: SafroleSealingKeys;
|
|
10632
10931
|
epochRoot: BandersnatchRingRoot;
|
|
10633
10932
|
privilegedServices: PrivilegedServices;
|
|
10634
|
-
accumulationOutputLog: AccumulationOutput
|
|
10933
|
+
accumulationOutputLog: SortedArray<AccumulationOutput>;
|
|
10635
10934
|
services: Map<ServiceId, InMemoryService>;
|
|
10636
10935
|
|
|
10637
10936
|
recentServiceIds(): readonly ServiceId[] {
|
|
@@ -10775,7 +11074,7 @@ declare class InMemoryState extends WithDebug implements State, EnumerableState
|
|
|
10775
11074
|
validatorsManager: tryAsServiceId(0),
|
|
10776
11075
|
autoAccumulateServices: [],
|
|
10777
11076
|
}),
|
|
10778
|
-
accumulationOutputLog: [],
|
|
11077
|
+
accumulationOutputLog: SortedArray.fromArray(accumulationOutputComparator, []),
|
|
10779
11078
|
services: new Map(),
|
|
10780
11079
|
});
|
|
10781
11080
|
}
|
|
@@ -10822,102 +11121,103 @@ type FieldNames<T> = {
|
|
|
10822
11121
|
[K in keyof T]: T[K] extends Function ? never : K;
|
|
10823
11122
|
}[keyof T];
|
|
10824
11123
|
|
|
10825
|
-
type index$
|
|
10826
|
-
declare const index$
|
|
10827
|
-
type index$
|
|
10828
|
-
declare const index$
|
|
10829
|
-
type index$
|
|
10830
|
-
declare const index$
|
|
10831
|
-
declare const index$
|
|
10832
|
-
type index$
|
|
10833
|
-
declare const index$
|
|
10834
|
-
type index$
|
|
10835
|
-
type index$
|
|
10836
|
-
declare const index$
|
|
10837
|
-
type index$
|
|
10838
|
-
declare const index$
|
|
10839
|
-
declare const index$
|
|
10840
|
-
declare const index$
|
|
10841
|
-
type index$
|
|
10842
|
-
type index$
|
|
10843
|
-
type index$
|
|
10844
|
-
type index$
|
|
10845
|
-
declare const index$
|
|
10846
|
-
type index$
|
|
10847
|
-
declare const index$
|
|
10848
|
-
type index$
|
|
10849
|
-
type index$
|
|
10850
|
-
declare const index$
|
|
10851
|
-
type index$
|
|
10852
|
-
declare const index$
|
|
10853
|
-
type index$
|
|
10854
|
-
type index$
|
|
10855
|
-
type index$
|
|
10856
|
-
declare const index$
|
|
10857
|
-
type index$
|
|
10858
|
-
declare const index$
|
|
10859
|
-
type index$
|
|
10860
|
-
declare const index$
|
|
10861
|
-
type index$
|
|
10862
|
-
declare const index$
|
|
10863
|
-
type index$
|
|
10864
|
-
declare const index$
|
|
10865
|
-
type index$
|
|
10866
|
-
type index$
|
|
10867
|
-
declare const index$
|
|
10868
|
-
type index$
|
|
10869
|
-
declare const index$
|
|
10870
|
-
type index$
|
|
10871
|
-
type index$
|
|
10872
|
-
declare const index$
|
|
10873
|
-
type index$
|
|
10874
|
-
type index$
|
|
10875
|
-
type index$
|
|
10876
|
-
declare const index$
|
|
10877
|
-
type index$
|
|
10878
|
-
type index$
|
|
10879
|
-
type index$
|
|
10880
|
-
declare const index$
|
|
10881
|
-
type index$
|
|
10882
|
-
declare const index$
|
|
10883
|
-
type index$
|
|
10884
|
-
type index$
|
|
10885
|
-
declare const index$
|
|
10886
|
-
type index$
|
|
10887
|
-
declare const index$
|
|
10888
|
-
type index$
|
|
10889
|
-
declare const index$
|
|
10890
|
-
type index$
|
|
10891
|
-
declare const index$
|
|
10892
|
-
type index$
|
|
10893
|
-
declare const index$
|
|
10894
|
-
type index$
|
|
10895
|
-
declare const index$
|
|
10896
|
-
type index$
|
|
10897
|
-
declare const index$
|
|
10898
|
-
type index$
|
|
10899
|
-
type index$
|
|
10900
|
-
declare const index$
|
|
10901
|
-
type index$
|
|
10902
|
-
declare const index$
|
|
10903
|
-
declare const index$
|
|
10904
|
-
declare const index$
|
|
10905
|
-
declare const index$
|
|
10906
|
-
declare const index$
|
|
10907
|
-
declare const index$
|
|
10908
|
-
declare const index$
|
|
10909
|
-
declare const index$
|
|
10910
|
-
declare const index$
|
|
10911
|
-
declare const index$
|
|
10912
|
-
declare const index$
|
|
10913
|
-
declare const index$
|
|
10914
|
-
declare const index$
|
|
10915
|
-
declare const index$
|
|
10916
|
-
declare const index$
|
|
10917
|
-
declare const index$
|
|
10918
|
-
declare
|
|
10919
|
-
|
|
10920
|
-
export
|
|
11124
|
+
type index$c_AccumulationOutput = AccumulationOutput;
|
|
11125
|
+
declare const index$c_AccumulationOutput: typeof AccumulationOutput;
|
|
11126
|
+
type index$c_AutoAccumulate = AutoAccumulate;
|
|
11127
|
+
declare const index$c_AutoAccumulate: typeof AutoAccumulate;
|
|
11128
|
+
type index$c_AvailabilityAssignment = AvailabilityAssignment;
|
|
11129
|
+
declare const index$c_AvailabilityAssignment: typeof AvailabilityAssignment;
|
|
11130
|
+
declare const index$c_BASE_SERVICE_BALANCE: typeof BASE_SERVICE_BALANCE;
|
|
11131
|
+
type index$c_BlockState = BlockState;
|
|
11132
|
+
declare const index$c_BlockState: typeof BlockState;
|
|
11133
|
+
type index$c_BlocksState = BlocksState;
|
|
11134
|
+
type index$c_CoreStatistics = CoreStatistics;
|
|
11135
|
+
declare const index$c_CoreStatistics: typeof CoreStatistics;
|
|
11136
|
+
type index$c_DisputesRecords = DisputesRecords;
|
|
11137
|
+
declare const index$c_DisputesRecords: typeof DisputesRecords;
|
|
11138
|
+
declare const index$c_ELECTIVE_BYTE_BALANCE: typeof ELECTIVE_BYTE_BALANCE;
|
|
11139
|
+
declare const index$c_ELECTIVE_ITEM_BALANCE: typeof ELECTIVE_ITEM_BALANCE;
|
|
11140
|
+
type index$c_ENTROPY_ENTRIES = ENTROPY_ENTRIES;
|
|
11141
|
+
type index$c_EnumerableState = EnumerableState;
|
|
11142
|
+
type index$c_FieldNames<T> = FieldNames<T>;
|
|
11143
|
+
type index$c_InMemoryService = InMemoryService;
|
|
11144
|
+
declare const index$c_InMemoryService: typeof InMemoryService;
|
|
11145
|
+
type index$c_InMemoryState = InMemoryState;
|
|
11146
|
+
declare const index$c_InMemoryState: typeof InMemoryState;
|
|
11147
|
+
type index$c_InMemoryStateFields = InMemoryStateFields;
|
|
11148
|
+
type index$c_LookupHistoryItem = LookupHistoryItem;
|
|
11149
|
+
declare const index$c_LookupHistoryItem: typeof LookupHistoryItem;
|
|
11150
|
+
type index$c_LookupHistorySlots = LookupHistorySlots;
|
|
11151
|
+
declare const index$c_MAX_LOOKUP_HISTORY_SLOTS: typeof MAX_LOOKUP_HISTORY_SLOTS;
|
|
11152
|
+
type index$c_MAX_RECENT_HISTORY = MAX_RECENT_HISTORY;
|
|
11153
|
+
type index$c_PerCore<T> = PerCore<T>;
|
|
11154
|
+
type index$c_PreimageItem = PreimageItem;
|
|
11155
|
+
declare const index$c_PreimageItem: typeof PreimageItem;
|
|
11156
|
+
type index$c_PrivilegedServices = PrivilegedServices;
|
|
11157
|
+
declare const index$c_PrivilegedServices: typeof PrivilegedServices;
|
|
11158
|
+
type index$c_RecentBlocks = RecentBlocks;
|
|
11159
|
+
declare const index$c_RecentBlocks: typeof RecentBlocks;
|
|
11160
|
+
type index$c_RecentBlocksHistory = RecentBlocksHistory;
|
|
11161
|
+
declare const index$c_RecentBlocksHistory: typeof RecentBlocksHistory;
|
|
11162
|
+
type index$c_SafroleData = SafroleData;
|
|
11163
|
+
declare const index$c_SafroleData: typeof SafroleData;
|
|
11164
|
+
type index$c_SafroleSealingKeys = SafroleSealingKeys;
|
|
11165
|
+
type index$c_SafroleSealingKeysData = SafroleSealingKeysData;
|
|
11166
|
+
declare const index$c_SafroleSealingKeysData: typeof SafroleSealingKeysData;
|
|
11167
|
+
type index$c_SafroleSealingKeysKind = SafroleSealingKeysKind;
|
|
11168
|
+
declare const index$c_SafroleSealingKeysKind: typeof SafroleSealingKeysKind;
|
|
11169
|
+
type index$c_Service = Service;
|
|
11170
|
+
type index$c_ServiceAccountInfo = ServiceAccountInfo;
|
|
11171
|
+
declare const index$c_ServiceAccountInfo: typeof ServiceAccountInfo;
|
|
11172
|
+
type index$c_ServiceData = ServiceData;
|
|
11173
|
+
type index$c_ServiceEntries = ServiceEntries;
|
|
11174
|
+
type index$c_ServiceStatistics = ServiceStatistics;
|
|
11175
|
+
declare const index$c_ServiceStatistics: typeof ServiceStatistics;
|
|
11176
|
+
type index$c_ServicesUpdate = ServicesUpdate;
|
|
11177
|
+
type index$c_State = State;
|
|
11178
|
+
type index$c_StatisticsData = StatisticsData;
|
|
11179
|
+
declare const index$c_StatisticsData: typeof StatisticsData;
|
|
11180
|
+
type index$c_StorageItem = StorageItem;
|
|
11181
|
+
declare const index$c_StorageItem: typeof StorageItem;
|
|
11182
|
+
type index$c_StorageKey = StorageKey;
|
|
11183
|
+
type index$c_UpdateError = UpdateError;
|
|
11184
|
+
declare const index$c_UpdateError: typeof UpdateError;
|
|
11185
|
+
type index$c_UpdatePreimage = UpdatePreimage;
|
|
11186
|
+
declare const index$c_UpdatePreimage: typeof UpdatePreimage;
|
|
11187
|
+
type index$c_UpdatePreimageKind = UpdatePreimageKind;
|
|
11188
|
+
declare const index$c_UpdatePreimageKind: typeof UpdatePreimageKind;
|
|
11189
|
+
type index$c_UpdateService = UpdateService;
|
|
11190
|
+
declare const index$c_UpdateService: typeof UpdateService;
|
|
11191
|
+
type index$c_UpdateServiceKind = UpdateServiceKind;
|
|
11192
|
+
declare const index$c_UpdateServiceKind: typeof UpdateServiceKind;
|
|
11193
|
+
type index$c_UpdateStorage = UpdateStorage;
|
|
11194
|
+
declare const index$c_UpdateStorage: typeof UpdateStorage;
|
|
11195
|
+
type index$c_UpdateStorageKind = UpdateStorageKind;
|
|
11196
|
+
declare const index$c_UpdateStorageKind: typeof UpdateStorageKind;
|
|
11197
|
+
type index$c_VALIDATOR_META_BYTES = VALIDATOR_META_BYTES;
|
|
11198
|
+
type index$c_ValidatorData = ValidatorData;
|
|
11199
|
+
declare const index$c_ValidatorData: typeof ValidatorData;
|
|
11200
|
+
type index$c_ValidatorStatistics = ValidatorStatistics;
|
|
11201
|
+
declare const index$c_ValidatorStatistics: typeof ValidatorStatistics;
|
|
11202
|
+
declare const index$c_accumulationOutputComparator: typeof accumulationOutputComparator;
|
|
11203
|
+
declare const index$c_codecBandersnatchKey: typeof codecBandersnatchKey;
|
|
11204
|
+
declare const index$c_codecPerCore: typeof codecPerCore;
|
|
11205
|
+
declare const index$c_codecServiceId: typeof codecServiceId;
|
|
11206
|
+
declare const index$c_codecVarGas: typeof codecVarGas;
|
|
11207
|
+
declare const index$c_codecVarU16: typeof codecVarU16;
|
|
11208
|
+
declare const index$c_codecWithHash: typeof codecWithHash;
|
|
11209
|
+
declare const index$c_hashComparator: typeof hashComparator;
|
|
11210
|
+
declare const index$c_ignoreValueWithDefault: typeof ignoreValueWithDefault;
|
|
11211
|
+
declare const index$c_serviceDataCodec: typeof serviceDataCodec;
|
|
11212
|
+
declare const index$c_serviceEntriesCodec: typeof serviceEntriesCodec;
|
|
11213
|
+
declare const index$c_sortedSetCodec: typeof sortedSetCodec;
|
|
11214
|
+
declare const index$c_tryAsLookupHistorySlots: typeof tryAsLookupHistorySlots;
|
|
11215
|
+
declare const index$c_tryAsPerCore: typeof tryAsPerCore;
|
|
11216
|
+
declare const index$c_workReportsSortedSetCodec: typeof workReportsSortedSetCodec;
|
|
11217
|
+
declare const index$c_zeroSizeHint: typeof zeroSizeHint;
|
|
11218
|
+
declare namespace index$c {
|
|
11219
|
+
export { index$c_AccumulationOutput as AccumulationOutput, index$c_AutoAccumulate as AutoAccumulate, index$c_AvailabilityAssignment as AvailabilityAssignment, index$c_BASE_SERVICE_BALANCE as BASE_SERVICE_BALANCE, index$c_BlockState as BlockState, index$c_CoreStatistics as CoreStatistics, index$c_DisputesRecords as DisputesRecords, index$c_ELECTIVE_BYTE_BALANCE as ELECTIVE_BYTE_BALANCE, index$c_ELECTIVE_ITEM_BALANCE as ELECTIVE_ITEM_BALANCE, index$c_InMemoryService as InMemoryService, index$c_InMemoryState as InMemoryState, index$c_LookupHistoryItem as LookupHistoryItem, index$c_MAX_LOOKUP_HISTORY_SLOTS as MAX_LOOKUP_HISTORY_SLOTS, index$c_PreimageItem as PreimageItem, index$c_PrivilegedServices as PrivilegedServices, index$c_RecentBlocks as RecentBlocks, index$c_RecentBlocksHistory as RecentBlocksHistory, index$c_SafroleData as SafroleData, index$c_SafroleSealingKeysData as SafroleSealingKeysData, index$c_SafroleSealingKeysKind as SafroleSealingKeysKind, index$c_ServiceAccountInfo as ServiceAccountInfo, index$c_ServiceStatistics as ServiceStatistics, index$c_StatisticsData as StatisticsData, index$c_StorageItem as StorageItem, index$c_UpdateError as UpdateError, index$c_UpdatePreimage as UpdatePreimage, index$c_UpdatePreimageKind as UpdatePreimageKind, index$c_UpdateService as UpdateService, index$c_UpdateServiceKind as UpdateServiceKind, index$c_UpdateStorage as UpdateStorage, index$c_UpdateStorageKind as UpdateStorageKind, index$c_ValidatorData as ValidatorData, index$c_ValidatorStatistics as ValidatorStatistics, index$c_accumulationOutputComparator as accumulationOutputComparator, index$c_codecBandersnatchKey as codecBandersnatchKey, index$c_codecPerCore as codecPerCore, index$c_codecServiceId as codecServiceId, index$c_codecVarGas as codecVarGas, index$c_codecVarU16 as codecVarU16, index$c_codecWithHash as codecWithHash, index$c_hashComparator as hashComparator, index$c_ignoreValueWithDefault as ignoreValueWithDefault, index$c_serviceDataCodec as serviceDataCodec, index$c_serviceEntriesCodec as serviceEntriesCodec, index$c_sortedSetCodec as sortedSetCodec, index$c_tryAsLookupHistorySlots as tryAsLookupHistorySlots, index$c_tryAsPerCore as tryAsPerCore, index$c_workReportsSortedSetCodec as workReportsSortedSetCodec, index$c_zeroSizeHint as zeroSizeHint };
|
|
11220
|
+
export type { index$c_BlocksState as BlocksState, index$c_ENTROPY_ENTRIES as ENTROPY_ENTRIES, index$c_EnumerableState as EnumerableState, index$c_FieldNames as FieldNames, index$c_InMemoryStateFields as InMemoryStateFields, index$c_LookupHistorySlots as LookupHistorySlots, index$c_MAX_RECENT_HISTORY as MAX_RECENT_HISTORY, index$c_PerCore as PerCore, index$c_SafroleSealingKeys as SafroleSealingKeys, index$c_Service as Service, index$c_ServiceData as ServiceData, index$c_ServiceEntries as ServiceEntries, index$c_ServicesUpdate as ServicesUpdate, index$c_State as State, index$c_StorageKey as StorageKey, index$c_VALIDATOR_META_BYTES as VALIDATOR_META_BYTES };
|
|
10921
11221
|
}
|
|
10922
11222
|
|
|
10923
11223
|
type StateKey = Opaque<OpaqueHash, "stateKey">;
|
|
@@ -11191,7 +11491,10 @@ declare namespace serialize {
|
|
|
11191
11491
|
/** C(16): https://graypaper.fluffylabs.dev/#/38c4e62/3b46033b4603?v=0.7.0 */
|
|
11192
11492
|
export const accumulationOutputLog: StateCodec<State["accumulationOutputLog"]> = {
|
|
11193
11493
|
key: stateKeys.index(StateKeyIdx.Theta),
|
|
11194
|
-
Codec: codec.sequenceVarLen(AccumulationOutput.Codec)
|
|
11494
|
+
Codec: codec.sequenceVarLen(AccumulationOutput.Codec).convert(
|
|
11495
|
+
(i) => i.array,
|
|
11496
|
+
(o) => SortedArray.fromSortedArray(accumulationOutputComparator, o),
|
|
11497
|
+
),
|
|
11195
11498
|
extract: (s) => s.accumulationOutputLog,
|
|
11196
11499
|
};
|
|
11197
11500
|
|
|
@@ -11503,8 +11806,6 @@ declare class StateEntries {
|
|
|
11503
11806
|
return new StateEntries(TruncatedHashDictionary.fromEntries(entries));
|
|
11504
11807
|
}
|
|
11505
11808
|
|
|
11506
|
-
private trieCache: InMemoryTrie | null = null;
|
|
11507
|
-
|
|
11508
11809
|
private constructor(private readonly entries: TruncatedHashDictionary<StateKey, BytesBlob>) {}
|
|
11509
11810
|
|
|
11510
11811
|
/** When comparing, we can safely ignore `trieCache` and just use entries. */
|
|
@@ -11516,18 +11817,6 @@ declare class StateEntries {
|
|
|
11516
11817
|
return this.entries[Symbol.iterator]();
|
|
11517
11818
|
}
|
|
11518
11819
|
|
|
11519
|
-
/** Construct the trie from given set of state entries. */
|
|
11520
|
-
public getTrie(): InMemoryTrie {
|
|
11521
|
-
if (this.trieCache === null) {
|
|
11522
|
-
const trie = InMemoryTrie.empty(blake2bTrieHasher);
|
|
11523
|
-
for (const [key, value] of this.entries) {
|
|
11524
|
-
trie.set(key.asOpaque(), value);
|
|
11525
|
-
}
|
|
11526
|
-
this.trieCache = trie;
|
|
11527
|
-
}
|
|
11528
|
-
return this.trieCache;
|
|
11529
|
-
}
|
|
11530
|
-
|
|
11531
11820
|
/** Retrieve value of some serialized key (if present). */
|
|
11532
11821
|
get(key: StateKey): BytesBlob | null {
|
|
11533
11822
|
return this.entries.get(key) ?? null;
|
|
@@ -11535,8 +11824,6 @@ declare class StateEntries {
|
|
|
11535
11824
|
|
|
11536
11825
|
/** Modify underlying entries dictionary with given update. */
|
|
11537
11826
|
applyUpdate(stateEntriesUpdate: Iterable<StateEntryUpdate>) {
|
|
11538
|
-
// NOTE since we are altering the structure, we need to reset the cache.
|
|
11539
|
-
this.trieCache = null;
|
|
11540
11827
|
for (const [action, key, value] of stateEntriesUpdate) {
|
|
11541
11828
|
if (action === StateEntryUpdateAction.Insert) {
|
|
11542
11829
|
this.entries.set(key, value);
|
|
@@ -11550,10 +11837,12 @@ declare class StateEntries {
|
|
|
11550
11837
|
|
|
11551
11838
|
/** https://graypaper.fluffylabs.dev/#/68eaa1f/391600391600?v=0.6.4 */
|
|
11552
11839
|
getRootHash(): StateRootHash {
|
|
11553
|
-
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
11840
|
+
const leaves: SortedSet<LeafNode> = SortedSet.fromArray(leafComparator);
|
|
11841
|
+
for (const [key, value] of this) {
|
|
11842
|
+
leaves.insert(InMemoryTrie.constructLeaf(blake2bTrieHasher, key.asOpaque(), value));
|
|
11843
|
+
}
|
|
11844
|
+
|
|
11845
|
+
return InMemoryTrie.computeStateRoot(blake2bTrieHasher, leaves).asOpaque();
|
|
11557
11846
|
}
|
|
11558
11847
|
}
|
|
11559
11848
|
|
|
@@ -11866,44 +12155,44 @@ declare function loadState(spec: ChainSpec, entries: Iterable<[StateKey | Trunca
|
|
|
11866
12155
|
* hashmap of `key -> value` entries.
|
|
11867
12156
|
*/
|
|
11868
12157
|
|
|
11869
|
-
declare const index$
|
|
11870
|
-
type index$
|
|
11871
|
-
type index$
|
|
11872
|
-
type index$
|
|
11873
|
-
declare const index$
|
|
11874
|
-
type index$
|
|
11875
|
-
declare const index$
|
|
11876
|
-
type index$
|
|
11877
|
-
type index$
|
|
11878
|
-
type index$
|
|
11879
|
-
declare const index$
|
|
11880
|
-
type index$
|
|
11881
|
-
type index$
|
|
11882
|
-
declare const index$
|
|
11883
|
-
type index$
|
|
11884
|
-
type index$
|
|
11885
|
-
declare const index$
|
|
11886
|
-
declare const index$
|
|
11887
|
-
declare const index$
|
|
11888
|
-
declare const index$
|
|
11889
|
-
declare const index$
|
|
11890
|
-
declare const index$
|
|
11891
|
-
declare const index$
|
|
11892
|
-
declare const index$
|
|
11893
|
-
declare const index$
|
|
11894
|
-
declare const index$
|
|
11895
|
-
import index$
|
|
11896
|
-
declare const index$
|
|
11897
|
-
declare const index$
|
|
11898
|
-
declare const index$
|
|
11899
|
-
declare const index$
|
|
11900
|
-
declare const index$
|
|
11901
|
-
declare const index$
|
|
11902
|
-
declare const index$
|
|
11903
|
-
import index$
|
|
11904
|
-
declare namespace index$
|
|
11905
|
-
export { index$
|
|
11906
|
-
export type { index$
|
|
12158
|
+
declare const index$b_EMPTY_BLOB: typeof EMPTY_BLOB;
|
|
12159
|
+
type index$b_EncodeFun = EncodeFun;
|
|
12160
|
+
type index$b_KeyAndCodec<T> = KeyAndCodec<T>;
|
|
12161
|
+
type index$b_SerializedService = SerializedService;
|
|
12162
|
+
declare const index$b_SerializedService: typeof SerializedService;
|
|
12163
|
+
type index$b_SerializedState<T extends SerializedStateBackend = SerializedStateBackend> = SerializedState<T>;
|
|
12164
|
+
declare const index$b_SerializedState: typeof SerializedState;
|
|
12165
|
+
type index$b_SerializedStateBackend = SerializedStateBackend;
|
|
12166
|
+
type index$b_StateCodec<T> = StateCodec<T>;
|
|
12167
|
+
type index$b_StateEntries = StateEntries;
|
|
12168
|
+
declare const index$b_StateEntries: typeof StateEntries;
|
|
12169
|
+
type index$b_StateEntryUpdate = StateEntryUpdate;
|
|
12170
|
+
type index$b_StateEntryUpdateAction = StateEntryUpdateAction;
|
|
12171
|
+
declare const index$b_StateEntryUpdateAction: typeof StateEntryUpdateAction;
|
|
12172
|
+
type index$b_StateKey = StateKey;
|
|
12173
|
+
type index$b_StateKeyIdx = StateKeyIdx;
|
|
12174
|
+
declare const index$b_StateKeyIdx: typeof StateKeyIdx;
|
|
12175
|
+
declare const index$b_TYPICAL_STATE_ITEMS: typeof TYPICAL_STATE_ITEMS;
|
|
12176
|
+
declare const index$b_TYPICAL_STATE_ITEM_LEN: typeof TYPICAL_STATE_ITEM_LEN;
|
|
12177
|
+
declare const index$b_U32_BYTES: typeof U32_BYTES;
|
|
12178
|
+
declare const index$b_binaryMerkleization: typeof binaryMerkleization;
|
|
12179
|
+
declare const index$b_convertInMemoryStateToDictionary: typeof convertInMemoryStateToDictionary;
|
|
12180
|
+
declare const index$b_dumpCodec: typeof dumpCodec;
|
|
12181
|
+
declare const index$b_getSafroleData: typeof getSafroleData;
|
|
12182
|
+
declare const index$b_legacyServiceNested: typeof legacyServiceNested;
|
|
12183
|
+
declare const index$b_loadState: typeof loadState;
|
|
12184
|
+
import index$b_serialize = serialize;
|
|
12185
|
+
declare const index$b_serializeBasicKeys: typeof serializeBasicKeys;
|
|
12186
|
+
declare const index$b_serializePreimages: typeof serializePreimages;
|
|
12187
|
+
declare const index$b_serializeRemovedServices: typeof serializeRemovedServices;
|
|
12188
|
+
declare const index$b_serializeServiceUpdates: typeof serializeServiceUpdates;
|
|
12189
|
+
declare const index$b_serializeStateUpdate: typeof serializeStateUpdate;
|
|
12190
|
+
declare const index$b_serializeStorage: typeof serializeStorage;
|
|
12191
|
+
declare const index$b_stateEntriesSequenceCodec: typeof stateEntriesSequenceCodec;
|
|
12192
|
+
import index$b_stateKeys = stateKeys;
|
|
12193
|
+
declare namespace index$b {
|
|
12194
|
+
export { index$b_EMPTY_BLOB as EMPTY_BLOB, index$b_SerializedService as SerializedService, index$b_SerializedState as SerializedState, index$b_StateEntries as StateEntries, index$b_StateEntryUpdateAction as StateEntryUpdateAction, index$b_StateKeyIdx as StateKeyIdx, index$b_TYPICAL_STATE_ITEMS as TYPICAL_STATE_ITEMS, index$b_TYPICAL_STATE_ITEM_LEN as TYPICAL_STATE_ITEM_LEN, index$b_U32_BYTES as U32_BYTES, index$b_binaryMerkleization as binaryMerkleization, index$b_convertInMemoryStateToDictionary as convertInMemoryStateToDictionary, index$b_dumpCodec as dumpCodec, index$b_getSafroleData as getSafroleData, index$b_legacyServiceNested as legacyServiceNested, index$b_loadState as loadState, index$b_serialize as serialize, index$b_serializeBasicKeys as serializeBasicKeys, index$b_serializePreimages as serializePreimages, index$b_serializeRemovedServices as serializeRemovedServices, index$b_serializeServiceUpdates as serializeServiceUpdates, index$b_serializeStateUpdate as serializeStateUpdate, index$b_serializeStorage as serializeStorage, index$b_stateEntriesSequenceCodec as stateEntriesSequenceCodec, index$b_stateKeys as stateKeys };
|
|
12195
|
+
export type { index$b_EncodeFun as EncodeFun, index$b_KeyAndCodec as KeyAndCodec, index$b_SerializedStateBackend as SerializedStateBackend, index$b_StateCodec as StateCodec, index$b_StateEntryUpdate as StateEntryUpdate, index$b_StateKey as StateKey };
|
|
11907
12196
|
}
|
|
11908
12197
|
|
|
11909
12198
|
/** Error during `LeafDb` creation. */
|
|
@@ -11940,13 +12229,13 @@ declare class LeafDb implements SerializedStateBackend {
|
|
|
11940
12229
|
);
|
|
11941
12230
|
}
|
|
11942
12231
|
|
|
11943
|
-
const leaves
|
|
12232
|
+
const leaves = SortedSet.fromArray(leafComparator, []);
|
|
11944
12233
|
for (const nodeData of blob.chunks(TRIE_NODE_BYTES)) {
|
|
11945
12234
|
const node = new TrieNode(nodeData.raw);
|
|
11946
12235
|
if (node.getNodeType() === NodeType.Branch) {
|
|
11947
12236
|
return Result.error(LeafDbError.InvalidLeafData, `Branch node detected: ${nodeData}`);
|
|
11948
12237
|
}
|
|
11949
|
-
leaves.
|
|
12238
|
+
leaves.insert(node.asLeafNode());
|
|
11950
12239
|
}
|
|
11951
12240
|
|
|
11952
12241
|
return Result.ok(new LeafDb(leaves, db));
|
|
@@ -11956,11 +12245,11 @@ declare class LeafDb implements SerializedStateBackend {
|
|
|
11956
12245
|
private readonly lookup: TruncatedHashDictionary<StateKey, Lookup>;
|
|
11957
12246
|
|
|
11958
12247
|
private constructor(
|
|
11959
|
-
public readonly leaves:
|
|
12248
|
+
public readonly leaves: SortedSet<LeafNode>,
|
|
11960
12249
|
public readonly db: ValuesDb,
|
|
11961
12250
|
) {
|
|
11962
12251
|
this.lookup = TruncatedHashDictionary.fromEntries(
|
|
11963
|
-
leaves.map((leaf) => {
|
|
12252
|
+
leaves.array.map((leaf) => {
|
|
11964
12253
|
const key: StateKey = leaf.getKey().asOpaque();
|
|
11965
12254
|
const value: Lookup = leaf.hasEmbeddedValue()
|
|
11966
12255
|
? {
|
|
@@ -12111,25 +12400,25 @@ declare class InMemoryStates implements StatesDb<InMemoryState> {
|
|
|
12111
12400
|
}
|
|
12112
12401
|
}
|
|
12113
12402
|
|
|
12114
|
-
type index$
|
|
12115
|
-
type index$
|
|
12116
|
-
declare const index$
|
|
12117
|
-
type index$
|
|
12118
|
-
declare const index$
|
|
12119
|
-
type index$
|
|
12120
|
-
declare const index$
|
|
12121
|
-
type index$
|
|
12122
|
-
declare const index$
|
|
12123
|
-
type index$
|
|
12124
|
-
type index$
|
|
12125
|
-
declare const index$
|
|
12126
|
-
type index$
|
|
12127
|
-
declare const index$
|
|
12128
|
-
type index$
|
|
12129
|
-
type index$
|
|
12130
|
-
declare namespace index$
|
|
12131
|
-
export { index$
|
|
12132
|
-
export type { index$
|
|
12403
|
+
type index$a_BlocksDb = BlocksDb;
|
|
12404
|
+
type index$a_InMemoryBlocks = InMemoryBlocks;
|
|
12405
|
+
declare const index$a_InMemoryBlocks: typeof InMemoryBlocks;
|
|
12406
|
+
type index$a_InMemoryStates = InMemoryStates;
|
|
12407
|
+
declare const index$a_InMemoryStates: typeof InMemoryStates;
|
|
12408
|
+
type index$a_LeafDb = LeafDb;
|
|
12409
|
+
declare const index$a_LeafDb: typeof LeafDb;
|
|
12410
|
+
type index$a_LeafDbError = LeafDbError;
|
|
12411
|
+
declare const index$a_LeafDbError: typeof LeafDbError;
|
|
12412
|
+
type index$a_Lookup = Lookup;
|
|
12413
|
+
type index$a_LookupKind = LookupKind;
|
|
12414
|
+
declare const index$a_LookupKind: typeof LookupKind;
|
|
12415
|
+
type index$a_StateUpdateError = StateUpdateError;
|
|
12416
|
+
declare const index$a_StateUpdateError: typeof StateUpdateError;
|
|
12417
|
+
type index$a_StatesDb<T extends State = State> = StatesDb<T>;
|
|
12418
|
+
type index$a_ValuesDb = ValuesDb;
|
|
12419
|
+
declare namespace index$a {
|
|
12420
|
+
export { index$a_InMemoryBlocks as InMemoryBlocks, index$a_InMemoryStates as InMemoryStates, index$a_LeafDb as LeafDb, index$a_LeafDbError as LeafDbError, index$a_LookupKind as LookupKind, index$a_StateUpdateError as StateUpdateError };
|
|
12421
|
+
export type { index$a_BlocksDb as BlocksDb, index$a_Lookup as Lookup, index$a_StatesDb as StatesDb, index$a_ValuesDb as ValuesDb };
|
|
12133
12422
|
}
|
|
12134
12423
|
|
|
12135
12424
|
/**
|
|
@@ -12548,30 +12837,30 @@ declare const initEc = async () => {
|
|
|
12548
12837
|
await init.reedSolomon();
|
|
12549
12838
|
};
|
|
12550
12839
|
|
|
12551
|
-
declare const index$
|
|
12552
|
-
declare const index$
|
|
12553
|
-
type index$
|
|
12554
|
-
type index$
|
|
12555
|
-
type index$
|
|
12556
|
-
declare const index$
|
|
12557
|
-
type index$
|
|
12558
|
-
declare const index$
|
|
12559
|
-
declare const index$
|
|
12560
|
-
declare const index$
|
|
12561
|
-
declare const index$
|
|
12562
|
-
declare const index$
|
|
12563
|
-
declare const index$
|
|
12564
|
-
declare const index$
|
|
12565
|
-
declare const index$
|
|
12566
|
-
declare const index$
|
|
12567
|
-
declare const index$
|
|
12568
|
-
declare const index$
|
|
12569
|
-
declare const index$
|
|
12570
|
-
declare const index$
|
|
12571
|
-
declare const index$
|
|
12572
|
-
declare namespace index$
|
|
12573
|
-
export { index$
|
|
12574
|
-
export type { index$
|
|
12840
|
+
declare const index$9_HALF_POINT_SIZE: typeof HALF_POINT_SIZE;
|
|
12841
|
+
declare const index$9_N_CHUNKS_REDUNDANCY: typeof N_CHUNKS_REDUNDANCY;
|
|
12842
|
+
type index$9_N_CHUNKS_REQUIRED = N_CHUNKS_REQUIRED;
|
|
12843
|
+
type index$9_N_CHUNKS_TOTAL = N_CHUNKS_TOTAL;
|
|
12844
|
+
type index$9_PIECE_SIZE = PIECE_SIZE;
|
|
12845
|
+
declare const index$9_POINT_ALIGNMENT: typeof POINT_ALIGNMENT;
|
|
12846
|
+
type index$9_POINT_LENGTH = POINT_LENGTH;
|
|
12847
|
+
declare const index$9_chunkingFunction: typeof chunkingFunction;
|
|
12848
|
+
declare const index$9_chunksToShards: typeof chunksToShards;
|
|
12849
|
+
declare const index$9_decodeData: typeof decodeData;
|
|
12850
|
+
declare const index$9_decodeDataAndTrim: typeof decodeDataAndTrim;
|
|
12851
|
+
declare const index$9_decodePiece: typeof decodePiece;
|
|
12852
|
+
declare const index$9_encodePoints: typeof encodePoints;
|
|
12853
|
+
declare const index$9_initEc: typeof initEc;
|
|
12854
|
+
declare const index$9_join: typeof join;
|
|
12855
|
+
declare const index$9_lace: typeof lace;
|
|
12856
|
+
declare const index$9_padAndEncodeData: typeof padAndEncodeData;
|
|
12857
|
+
declare const index$9_shardsToChunks: typeof shardsToChunks;
|
|
12858
|
+
declare const index$9_split: typeof split;
|
|
12859
|
+
declare const index$9_transpose: typeof transpose;
|
|
12860
|
+
declare const index$9_unzip: typeof unzip;
|
|
12861
|
+
declare namespace index$9 {
|
|
12862
|
+
export { index$9_HALF_POINT_SIZE as HALF_POINT_SIZE, index$9_N_CHUNKS_REDUNDANCY as N_CHUNKS_REDUNDANCY, index$9_POINT_ALIGNMENT as POINT_ALIGNMENT, index$9_chunkingFunction as chunkingFunction, index$9_chunksToShards as chunksToShards, index$9_decodeData as decodeData, index$9_decodeDataAndTrim as decodeDataAndTrim, index$9_decodePiece as decodePiece, index$9_encodePoints as encodePoints, index$9_initEc as initEc, index$9_join as join, index$9_lace as lace, index$9_padAndEncodeData as padAndEncodeData, index$9_shardsToChunks as shardsToChunks, index$9_split as split, index$9_transpose as transpose, index$9_unzip as unzip };
|
|
12863
|
+
export type { index$9_N_CHUNKS_REQUIRED as N_CHUNKS_REQUIRED, index$9_N_CHUNKS_TOTAL as N_CHUNKS_TOTAL, index$9_PIECE_SIZE as PIECE_SIZE, index$9_POINT_LENGTH as POINT_LENGTH };
|
|
12575
12864
|
}
|
|
12576
12865
|
|
|
12577
12866
|
/** Size of the transfer memo. */
|
|
@@ -12914,173 +13203,6 @@ interface GasCounter {
|
|
|
12914
13203
|
sub(g: Gas): boolean;
|
|
12915
13204
|
}
|
|
12916
13205
|
|
|
12917
|
-
declare enum Level {
|
|
12918
|
-
INSANE = 1,
|
|
12919
|
-
TRACE = 2,
|
|
12920
|
-
LOG = 3,
|
|
12921
|
-
INFO = 4,
|
|
12922
|
-
WARN = 5,
|
|
12923
|
-
ERROR = 6,
|
|
12924
|
-
}
|
|
12925
|
-
|
|
12926
|
-
type Options = {
|
|
12927
|
-
defaultLevel: Level;
|
|
12928
|
-
workingDir: string;
|
|
12929
|
-
modules: Map<string, Level>;
|
|
12930
|
-
};
|
|
12931
|
-
|
|
12932
|
-
/**
|
|
12933
|
-
* A function to parse logger definition (including modules) given as a string.
|
|
12934
|
-
*
|
|
12935
|
-
* Examples
|
|
12936
|
-
* - `info` - setup default logging level to `info`.
|
|
12937
|
-
* - `trace` - default logging level set to `trace`.
|
|
12938
|
-
* - `debug;consensus=trace` - default level is set to `debug/log`, but consensus is in trace mode.
|
|
12939
|
-
*/
|
|
12940
|
-
declare function parseLoggerOptions(input: string, defaultLevel: Level, workingDir?: string): Options {
|
|
12941
|
-
const modules = new Map<string, Level>();
|
|
12942
|
-
const parts = input.toLowerCase().split(",");
|
|
12943
|
-
let defLevel = defaultLevel;
|
|
12944
|
-
|
|
12945
|
-
for (const p of parts) {
|
|
12946
|
-
const clean = p.trim();
|
|
12947
|
-
// skip empty objects (forgotten `,` removed)
|
|
12948
|
-
if (clean.length === 0) {
|
|
12949
|
-
continue;
|
|
12950
|
-
}
|
|
12951
|
-
// we just have the default level
|
|
12952
|
-
if (clean.includes("=")) {
|
|
12953
|
-
const [mod, lvl] = clean.split("=");
|
|
12954
|
-
modules.set(mod.trim(), parseLevel(lvl.trim()));
|
|
12955
|
-
} else {
|
|
12956
|
-
defLevel = parseLevel(clean);
|
|
12957
|
-
}
|
|
12958
|
-
}
|
|
12959
|
-
|
|
12960
|
-
// TODO [ToDr] Fix dirname for workers.
|
|
12961
|
-
const myDir = (import.meta.dirname ?? "").split("/");
|
|
12962
|
-
myDir.pop();
|
|
12963
|
-
myDir.pop();
|
|
12964
|
-
return {
|
|
12965
|
-
defaultLevel: defLevel,
|
|
12966
|
-
modules,
|
|
12967
|
-
workingDir: workingDir ?? myDir.join("/"),
|
|
12968
|
-
};
|
|
12969
|
-
}
|
|
12970
|
-
|
|
12971
|
-
declare const GLOBAL_CONFIG = {
|
|
12972
|
-
options: DEFAULT_OPTIONS,
|
|
12973
|
-
transport: ConsoleTransport.create(DEFAULT_OPTIONS.defaultLevel, DEFAULT_OPTIONS),
|
|
12974
|
-
};
|
|
12975
|
-
|
|
12976
|
-
/**
|
|
12977
|
-
* A logger instance.
|
|
12978
|
-
*/
|
|
12979
|
-
declare class Logger {
|
|
12980
|
-
/**
|
|
12981
|
-
* Create a new logger instance given filename and an optional module name.
|
|
12982
|
-
*
|
|
12983
|
-
* If the module name is not given, `fileName` becomes the module name.
|
|
12984
|
-
* The module name can be composed from multiple parts separated with `/`.
|
|
12985
|
-
*
|
|
12986
|
-
* The logger will use a global configuration which can be changed using
|
|
12987
|
-
* [`configureLogger`] function.
|
|
12988
|
-
*/
|
|
12989
|
-
static new(fileName?: string, moduleName?: string) {
|
|
12990
|
-
const fName = fileName ?? "unknown";
|
|
12991
|
-
return new Logger(moduleName ?? fName, fName, GLOBAL_CONFIG);
|
|
12992
|
-
}
|
|
12993
|
-
|
|
12994
|
-
/**
|
|
12995
|
-
* Return currently configured level for given module. */
|
|
12996
|
-
static getLevel(moduleName: string): Level {
|
|
12997
|
-
return findLevel(GLOBAL_CONFIG.options, moduleName);
|
|
12998
|
-
}
|
|
12999
|
-
|
|
13000
|
-
/**
|
|
13001
|
-
* Global configuration of all loggers.
|
|
13002
|
-
*
|
|
13003
|
-
* One can specify a default logging level (only logs with level >= default will be printed).
|
|
13004
|
-
* It's also possible to configure per-module logging level that takes precedence
|
|
13005
|
-
* over the default one.
|
|
13006
|
-
*
|
|
13007
|
-
* Changing the options affects all previously created loggers.
|
|
13008
|
-
*/
|
|
13009
|
-
static configureAllFromOptions(options: Options) {
|
|
13010
|
-
// find minimal level to optimise logging in case
|
|
13011
|
-
// we don't care about low-level logs.
|
|
13012
|
-
const minimalLevel = Array.from(options.modules.values()).reduce((level, modLevel) => {
|
|
13013
|
-
return level < modLevel ? level : modLevel;
|
|
13014
|
-
}, options.defaultLevel);
|
|
13015
|
-
|
|
13016
|
-
const transport = ConsoleTransport.create(minimalLevel, options);
|
|
13017
|
-
|
|
13018
|
-
// set the global config
|
|
13019
|
-
GLOBAL_CONFIG.options = options;
|
|
13020
|
-
GLOBAL_CONFIG.transport = transport;
|
|
13021
|
-
}
|
|
13022
|
-
|
|
13023
|
-
/**
|
|
13024
|
-
* Global configuration of all loggers.
|
|
13025
|
-
*
|
|
13026
|
-
* Parse configuration options from an input string typically obtained
|
|
13027
|
-
* from environment variable `JAM_LOG`.
|
|
13028
|
-
*/
|
|
13029
|
-
static configureAll(input: string, defaultLevel: Level, workingDir?: string) {
|
|
13030
|
-
const options = parseLoggerOptions(input, defaultLevel, workingDir);
|
|
13031
|
-
Logger.configureAllFromOptions(options);
|
|
13032
|
-
}
|
|
13033
|
-
|
|
13034
|
-
constructor(
|
|
13035
|
-
private readonly moduleName: string,
|
|
13036
|
-
private readonly fileName: string,
|
|
13037
|
-
private readonly config: typeof GLOBAL_CONFIG,
|
|
13038
|
-
) {}
|
|
13039
|
-
|
|
13040
|
-
/** Log a message with `INSANE` level. */
|
|
13041
|
-
insane(val: string) {
|
|
13042
|
-
this.config.transport.insane(this.moduleName, val);
|
|
13043
|
-
}
|
|
13044
|
-
|
|
13045
|
-
/** Log a message with `TRACE` level. */
|
|
13046
|
-
trace(val: string) {
|
|
13047
|
-
this.config.transport.trace(this.moduleName, val);
|
|
13048
|
-
}
|
|
13049
|
-
|
|
13050
|
-
/** Log a message with `DEBUG`/`LOG` level. */
|
|
13051
|
-
log(val: string) {
|
|
13052
|
-
this.config.transport.log(this.moduleName, val);
|
|
13053
|
-
}
|
|
13054
|
-
|
|
13055
|
-
/** Log a message with `INFO` level. */
|
|
13056
|
-
info(val: string) {
|
|
13057
|
-
this.config.transport.info(this.moduleName, val);
|
|
13058
|
-
}
|
|
13059
|
-
|
|
13060
|
-
/** Log a message with `WARN` level. */
|
|
13061
|
-
warn(val: string) {
|
|
13062
|
-
this.config.transport.warn(this.moduleName, val);
|
|
13063
|
-
}
|
|
13064
|
-
|
|
13065
|
-
/** Log a message with `ERROR` level. */
|
|
13066
|
-
error(val: string) {
|
|
13067
|
-
this.config.transport.error(this.moduleName, val);
|
|
13068
|
-
}
|
|
13069
|
-
}
|
|
13070
|
-
|
|
13071
|
-
type index$9_Level = Level;
|
|
13072
|
-
declare const index$9_Level: typeof Level;
|
|
13073
|
-
type index$9_Logger = Logger;
|
|
13074
|
-
declare const index$9_Logger: typeof Logger;
|
|
13075
|
-
declare const index$9_parseLoggerOptions: typeof parseLoggerOptions;
|
|
13076
|
-
declare namespace index$9 {
|
|
13077
|
-
export {
|
|
13078
|
-
index$9_Level as Level,
|
|
13079
|
-
index$9_Logger as Logger,
|
|
13080
|
-
index$9_parseLoggerOptions as parseLoggerOptions,
|
|
13081
|
-
};
|
|
13082
|
-
}
|
|
13083
|
-
|
|
13084
13206
|
/**
|
|
13085
13207
|
* Mask class is an implementation of skip function defined in GP.
|
|
13086
13208
|
*
|
|
@@ -14324,6 +14446,8 @@ declare enum AccessType {
|
|
|
14324
14446
|
WRITE = 1,
|
|
14325
14447
|
}
|
|
14326
14448
|
|
|
14449
|
+
// const logger = Logger.new(import.meta.filename, "pvm:mem");
|
|
14450
|
+
|
|
14327
14451
|
declare class Memory {
|
|
14328
14452
|
static fromInitialMemory(initialMemoryState: InitialMemoryState) {
|
|
14329
14453
|
return new Memory(
|
|
@@ -14360,7 +14484,7 @@ declare class Memory {
|
|
|
14360
14484
|
return Result.ok(OK);
|
|
14361
14485
|
}
|
|
14362
14486
|
|
|
14363
|
-
logger.insane(`MEM[${address}] <- ${BytesBlob.blobFrom(bytes)}`);
|
|
14487
|
+
// logger.insane(`MEM[${address}] <- ${BytesBlob.blobFrom(bytes)}`);
|
|
14364
14488
|
const pagesResult = this.getPages(address, bytes.length, AccessType.WRITE);
|
|
14365
14489
|
|
|
14366
14490
|
if (pagesResult.isError) {
|
|
@@ -14449,7 +14573,7 @@ declare class Memory {
|
|
|
14449
14573
|
bytesLeft -= bytesToRead;
|
|
14450
14574
|
}
|
|
14451
14575
|
|
|
14452
|
-
logger.insane(`MEM[${startAddress}] => ${BytesBlob.blobFrom(result)}`);
|
|
14576
|
+
// logger.insane(`MEM[${startAddress}] => ${BytesBlob.blobFrom(result)}`);
|
|
14453
14577
|
return Result.ok(OK);
|
|
14454
14578
|
}
|
|
14455
14579
|
|
|
@@ -18630,7 +18754,7 @@ type JsonStateDump = {
|
|
|
18630
18754
|
pi: JsonStatisticsData;
|
|
18631
18755
|
omega: State["accumulationQueue"];
|
|
18632
18756
|
xi: PerEpochBlock<WorkPackageHash[]>;
|
|
18633
|
-
theta:
|
|
18757
|
+
theta: AccumulationOutput[] | null;
|
|
18634
18758
|
accounts: InMemoryService[];
|
|
18635
18759
|
};
|
|
18636
18760
|
|
|
@@ -18732,7 +18856,7 @@ declare const fullStateDumpFromJson = (spec: ChainSpec) =>
|
|
|
18732
18856
|
xi.map((x) => HashSet.from(x)),
|
|
18733
18857
|
spec,
|
|
18734
18858
|
),
|
|
18735
|
-
accumulationOutputLog: theta ?? [],
|
|
18859
|
+
accumulationOutputLog: SortedArray.fromArray(accumulationOutputComparator, theta ?? []),
|
|
18736
18860
|
services: new Map(accounts.map((x) => [x.serviceId, x])),
|
|
18737
18861
|
});
|
|
18738
18862
|
},
|
|
@@ -19090,4 +19214,4 @@ declare namespace index {
|
|
|
19090
19214
|
export type { index_PreimagesInput as PreimagesInput, index_PreimagesState as PreimagesState, index_PreimagesStateUpdate as PreimagesStateUpdate };
|
|
19091
19215
|
}
|
|
19092
19216
|
|
|
19093
|
-
export { index$j as block, index$h as block_json, index$q as bytes, index$o as codec, index$m as collections, index$k as config, index$
|
|
19217
|
+
export { index$j as block, index$h as block_json, index$q as bytes, index$o as codec, index$m as collections, index$k as config, index$f as config_node, index$l as crypto, index$a as database, index$9 as erasure_coding, index$n as hash, index$6 as jam_host_calls, index$i as json_parser, index$g as logger, index$d as mmr, index$p as numbers, index$r as ordering, index$3 as pvm, index$7 as pvm_host_calls, index$8 as pvm_interpreter, index$4 as pvm_program, index$5 as pvm_spi_decoder, index$2 as shuffling, index$c as state, index$1 as state_json, index$b as state_merkleization, index as transition, index$e as trie, index$s as utils };
|