@typeberry/lib 0.5.0-3439612 → 0.5.0-5496f08

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.
Files changed (4) hide show
  1. package/index.cjs +578 -1217
  2. package/index.d.ts +49 -35
  3. package/index.js +578 -1217
  4. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1960,6 +1960,8 @@ declare class TruncatedHashDictionary<T extends OpaqueHash, V> {
1960
1960
  set(key: T | TruncatedHash, value: V): void;
1961
1961
  /** Remove a value that matches the key on `TRUNCATED_HASH_SIZE`. */
1962
1962
  delete(key: T | TruncatedHash): void;
1963
+ /** Iterator over keys of the dictionary. */
1964
+ keys(): Iterator<TruncatedHash, any, any> & Iterable<TruncatedHash>;
1963
1965
  /** Iterator over values of the dictionary. */
1964
1966
  values(): Iterator<V, any, any> & Iterable<V>;
1965
1967
  /** Iterator over entries of the dictionary (with truncated keys) */
@@ -2011,12 +2013,26 @@ declare namespace bandersnatch_d_exports {
2011
2013
  /* tslint:disable */
2012
2014
  /* eslint-disable */
2013
2015
  /**
2014
- * Seal verification as defined in:
2015
- * https://graypaper.fluffylabs.dev/#/68eaa1f/0eff000eff00?v=0.6.4
2016
- * or
2017
- * https://graypaper.fluffylabs.dev/#/68eaa1f/0e54010e5401?v=0.6.4
2016
+ * Compute VRF output hash from a secret seed and input data.
2017
+ *
2018
+ * This function derives a deterministic VRF output hash without generating a proof.
2019
+ * Unlike `generate_seal`, this produces only the output hash, not a verifiable signature.
2020
+ *
2021
+ * # Arguments
2022
+ * * `secret_seed` - Seed used to derive the secret key
2023
+ * * `input` - VRF input data to be hashed
2024
+ *
2025
+ * # Returns
2026
+ * A byte vector with the following format:
2027
+ * - On success (33 bytes):
2028
+ * - Byte 0: Status code `0` (RESULT_OK)
2029
+ * - Bytes 1-32: VRF output hash (32 bytes)
2030
+ * - On error (1 byte):
2031
+ * - Byte 0: Status code `1` (RESULT_ERR)
2032
+ *
2033
+ * Returns an error if the input cannot be converted to a valid VRF input point.
2018
2034
  */
2019
- declare function verify_seal(signer_key: Uint8Array, seal_data: Uint8Array, payload: Uint8Array, aux_data: Uint8Array): Uint8Array;
2035
+ declare function vrf_output_hash(secret_seed: Uint8Array, input: Uint8Array): Uint8Array;
2020
2036
  /**
2021
2037
  * Verify multiple tickets at once as defined in:
2022
2038
  * https://graypaper.fluffylabs.dev/#/68eaa1f/0f3e000f3e00?v=0.6.4
@@ -2024,6 +2040,17 @@ declare function verify_seal(signer_key: Uint8Array, seal_data: Uint8Array, payl
2024
2040
  * NOTE: the aux_data of VRF function is empty!
2025
2041
  */
2026
2042
  declare function batch_verify_tickets(ring_size: number, commitment: Uint8Array, tickets_data: Uint8Array, vrf_input_data_len: number): Uint8Array;
2043
+ /**
2044
+ * Generate ring commitment given concatenation of ring keys.
2045
+ */
2046
+ declare function ring_commitment(keys: Uint8Array): Uint8Array;
2047
+ /**
2048
+ * Seal verification as defined in:
2049
+ * https://graypaper.fluffylabs.dev/#/68eaa1f/0eff000eff00?v=0.6.4
2050
+ * or
2051
+ * https://graypaper.fluffylabs.dev/#/68eaa1f/0e54010e5401?v=0.6.4
2052
+ */
2053
+ declare function verify_seal(signer_key: Uint8Array, seal_data: Uint8Array, payload: Uint8Array, aux_data: Uint8Array): Uint8Array;
2027
2054
  /**
2028
2055
  * Generate seal that is verifiable using `verify_seal` function.
2029
2056
  *
@@ -2051,31 +2078,6 @@ declare function generate_seal(secret_seed: Uint8Array, input: Uint8Array, aux_d
2051
2078
  * returns: `Vec<u8>` containing the exit (1 byte) status followed by the (32 bytes) public key
2052
2079
  */
2053
2080
  declare function derive_public_key(seed: Uint8Array): Uint8Array;
2054
- /**
2055
- * Compute VRF output hash from a secret seed and input data.
2056
- *
2057
- * This function derives a deterministic VRF output hash without generating a proof.
2058
- * Unlike `generate_seal`, this produces only the output hash, not a verifiable signature.
2059
- *
2060
- * # Arguments
2061
- * * `secret_seed` - Seed used to derive the secret key
2062
- * * `input` - VRF input data to be hashed
2063
- *
2064
- * # Returns
2065
- * A byte vector with the following format:
2066
- * - On success (33 bytes):
2067
- * - Byte 0: Status code `0` (RESULT_OK)
2068
- * - Bytes 1-32: VRF output hash (32 bytes)
2069
- * - On error (1 byte):
2070
- * - Byte 0: Status code `1` (RESULT_ERR)
2071
- *
2072
- * Returns an error if the input cannot be converted to a valid VRF input point.
2073
- */
2074
- declare function vrf_output_hash(secret_seed: Uint8Array, input: Uint8Array): Uint8Array;
2075
- /**
2076
- * Generate ring commitment given concatenation of ring keys.
2077
- */
2078
- declare function ring_commitment(keys: Uint8Array): Uint8Array;
2079
2081
  type InitInput$2 = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
2080
2082
  interface InitOutput$2 {
2081
2083
  readonly memory: WebAssembly.Memory;
@@ -6237,7 +6239,7 @@ declare function serializeStateUpdate(spec: ChainSpec, blake2b: Blake2b, update:
6237
6239
  * State entries may be wrapped into `SerializedState` to access the contained values.
6238
6240
  */
6239
6241
  declare class StateEntries {
6240
- private readonly entries;
6242
+ private readonly dictionary;
6241
6243
  static Codec: Descriptor<StateEntries, StateEntries>;
6242
6244
  /** Turn in-memory state into it's serialized form. */
6243
6245
  static serializeInMemory(spec: ChainSpec, blake2b: Blake2b, state: InMemoryState): StateEntries;
@@ -6258,6 +6260,12 @@ declare class StateEntries {
6258
6260
  private constructor();
6259
6261
  /** When comparing, we can safely ignore `trieCache` and just use entries. */
6260
6262
  [TEST_COMPARE_USING](): any;
6263
+ /** Iterator over entries */
6264
+ entries(): Generator<[TruncatedHash, BytesBlob]>;
6265
+ /** Iterator over entries keys */
6266
+ keys(): Generator<TruncatedHash>;
6267
+ /** Iterator over entries values */
6268
+ values(): Generator<BytesBlob>;
6261
6269
  /** Dump state entries to JSON string (format compatible with stf vectors). */
6262
6270
  toString(): string;
6263
6271
  [Symbol.iterator](): Generator<[TruncatedHash, BytesBlob], any, any>;
@@ -9273,14 +9281,19 @@ type AccumulateResult = {
9273
9281
  accumulationOutputLog: SortedArray<AccumulationOutput>;
9274
9282
  };
9275
9283
 
9284
+ type AccumulateOptions = {
9285
+ pvm: PvmBackend;
9286
+ accumulateSequentially: boolean;
9287
+ };
9288
+
9276
9289
  declare const ACCUMULATION_ERROR = "duplicate service created";
9277
9290
  type ACCUMULATION_ERROR = typeof ACCUMULATION_ERROR;
9278
9291
  declare class Accumulate {
9279
9292
  readonly chainSpec: ChainSpec;
9280
9293
  readonly blake2b: Blake2b;
9281
9294
  readonly state: AccumulateState;
9282
- readonly pvm: PvmBackend;
9283
- constructor(chainSpec: ChainSpec, blake2b: Blake2b, state: AccumulateState, pvm: PvmBackend);
9295
+ readonly options: AccumulateOptions;
9296
+ constructor(chainSpec: ChainSpec, blake2b: Blake2b, state: AccumulateState, options: AccumulateOptions);
9284
9297
  /**
9285
9298
  * Returns an index that determines how many WorkReports can be processed before exceeding a given gasLimit.
9286
9299
  *
@@ -9842,7 +9855,7 @@ declare class OnChain {
9842
9855
  private readonly authorization;
9843
9856
  private readonly statistics;
9844
9857
  private isReadyForNextEpoch;
9845
- constructor(chainSpec: ChainSpec, state: State & WithStateView, hasher: TransitionHasher, pvm: PvmBackend, headerChain: HeaderChain);
9858
+ constructor(chainSpec: ChainSpec, state: State & WithStateView, hasher: TransitionHasher, options: AccumulateOptions, headerChain: HeaderChain);
9846
9859
  /** Pre-populate things worth caching for the next epoch. */
9847
9860
  prepareForNextEpoch(): Promise<void>;
9848
9861
  private verifySeal;
@@ -10030,6 +10043,7 @@ type index$7_ACCUMULATION_ERROR = ACCUMULATION_ERROR;
10030
10043
  type index$7_Accumulate = Accumulate;
10031
10044
  declare const index$7_Accumulate: typeof Accumulate;
10032
10045
  type index$7_AccumulateInput = AccumulateInput;
10046
+ type index$7_AccumulateOptions = AccumulateOptions;
10033
10047
  type index$7_AccumulateResult = AccumulateResult;
10034
10048
  type index$7_AccumulateRoot = AccumulateRoot;
10035
10049
  type index$7_AccumulateState = AccumulateState;
@@ -10104,7 +10118,7 @@ declare const index$7_copyAndUpdateState: typeof copyAndUpdateState;
10104
10118
  declare const index$7_stfError: typeof stfError;
10105
10119
  declare namespace index$7 {
10106
10120
  export { index$7_Accumulate as Accumulate, index$7_Assurances as Assurances, index$7_AssurancesError as AssurancesError, index$7_Authorization as Authorization, index$7_BlockVerifier as BlockVerifier, index$7_BlockVerifierError as BlockVerifierError, index$7_DbHeaderChain as DbHeaderChain, index$7_DeferredTransfers as DeferredTransfers, index$7_DeferredTransfersErrorCode as DeferredTransfersErrorCode, index$7_Disputes as Disputes, index$7_GAS_TO_INVOKE_WORK_REPORT as GAS_TO_INVOKE_WORK_REPORT, index$7_OnChain as OnChain, index$7_Preimages as Preimages, index$7_PreimagesErrorCode as PreimagesErrorCode, index$7_REPORT_TIMEOUT_GRACE_PERIOD as REPORT_TIMEOUT_GRACE_PERIOD, index$7_RecentHistory as RecentHistory, index$7_Reports as Reports, index$7_ReportsError as ReportsError, index$7_Statistics as Statistics, index$7_StfErrorKind as StfErrorKind, index$7_TransitionHasher as TransitionHasher, index$7_copyAndUpdateState as copyAndUpdateState, index$8 as externalities, index$7_stfError as stfError };
10107
- export type { index$7_ACCUMULATION_ERROR as ACCUMULATION_ERROR, index$7_AccumulateInput as AccumulateInput, index$7_AccumulateResult as AccumulateResult, index$7_AccumulateRoot as AccumulateRoot, index$7_AccumulateState as AccumulateState, index$7_AccumulateStateUpdate as AccumulateStateUpdate, index$7_AssurancesInput as AssurancesInput, index$7_AssurancesState as AssurancesState, index$7_AssurancesStateUpdate as AssurancesStateUpdate, index$7_AuthorizationInput as AuthorizationInput, index$7_AuthorizationState as AuthorizationState, index$7_AuthorizationStateUpdate as AuthorizationStateUpdate, index$7_CountAndGasUsed as CountAndGasUsed, index$7_DeferredTransfersResult as DeferredTransfersResult, index$7_DeferredTransfersState as DeferredTransfersState, index$7_DisputesState as DisputesState, index$7_DisputesStateUpdate as DisputesStateUpdate, index$7_HeaderChain as HeaderChain, index$7_Input as Input, index$7_Ok as Ok, index$7_PreimagesInput as PreimagesInput, index$7_PreimagesState as PreimagesState, index$7_PreimagesStateUpdate as PreimagesStateUpdate, index$7_RecentHistoryInput as RecentHistoryInput, index$7_RecentHistoryPartialInput as RecentHistoryPartialInput, index$7_RecentHistoryState as RecentHistoryState, index$7_RecentHistoryStateUpdate as RecentHistoryStateUpdate, index$7_ReportsInput as ReportsInput, index$7_ReportsOutput as ReportsOutput, index$7_ReportsState as ReportsState, index$7_ReportsStateUpdate as ReportsStateUpdate, index$7_StatisticsState as StatisticsState, index$7_StatisticsStateUpdate as StatisticsStateUpdate, index$7_StfError as StfError };
10121
+ export type { index$7_ACCUMULATION_ERROR as ACCUMULATION_ERROR, index$7_AccumulateInput as AccumulateInput, index$7_AccumulateOptions as AccumulateOptions, index$7_AccumulateResult as AccumulateResult, index$7_AccumulateRoot as AccumulateRoot, index$7_AccumulateState as AccumulateState, index$7_AccumulateStateUpdate as AccumulateStateUpdate, index$7_AssurancesInput as AssurancesInput, index$7_AssurancesState as AssurancesState, index$7_AssurancesStateUpdate as AssurancesStateUpdate, index$7_AuthorizationInput as AuthorizationInput, index$7_AuthorizationState as AuthorizationState, index$7_AuthorizationStateUpdate as AuthorizationStateUpdate, index$7_CountAndGasUsed as CountAndGasUsed, index$7_DeferredTransfersResult as DeferredTransfersResult, index$7_DeferredTransfersState as DeferredTransfersState, index$7_DisputesState as DisputesState, index$7_DisputesStateUpdate as DisputesStateUpdate, index$7_HeaderChain as HeaderChain, index$7_Input as Input, index$7_Ok as Ok, index$7_PreimagesInput as PreimagesInput, index$7_PreimagesState as PreimagesState, index$7_PreimagesStateUpdate as PreimagesStateUpdate, index$7_RecentHistoryInput as RecentHistoryInput, index$7_RecentHistoryPartialInput as RecentHistoryPartialInput, index$7_RecentHistoryState as RecentHistoryState, index$7_RecentHistoryStateUpdate as RecentHistoryStateUpdate, index$7_ReportsInput as ReportsInput, index$7_ReportsOutput as ReportsOutput, index$7_ReportsState as ReportsState, index$7_ReportsStateUpdate as ReportsStateUpdate, index$7_StatisticsState as StatisticsState, index$7_StatisticsStateUpdate as StatisticsStateUpdate, index$7_StfError as StfError };
10108
10122
  }
10109
10123
 
10110
10124
  declare enum ImporterErrorKind {