@typeberry/lib 0.4.0-fcdfbb1 → 0.4.1-dae2283
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/index.cjs +200 -254
- package/index.d.ts +910 -1369
- package/index.js +175 -228
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -16,7 +16,11 @@ var TestSuite;
|
|
|
16
16
|
})(TestSuite || (TestSuite = {}));
|
|
17
17
|
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
18
18
|
const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Current version is set to track the jam-conformance testing.
|
|
21
|
+
* Since we are currently at 0.7.1 not 0.7.2, we set our default version accordingly.
|
|
22
|
+
*/
|
|
23
|
+
const DEFAULT_VERSION = GpVersion.V0_7_1;
|
|
20
24
|
const env$1 = typeof process === "undefined" ? {} : process.env;
|
|
21
25
|
let CURRENT_VERSION = parseCurrentVersion(env$1.GP_VERSION) ?? DEFAULT_VERSION;
|
|
22
26
|
let CURRENT_SUITE = parseCurrentSuite(env$1.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
@@ -75,8 +79,8 @@ class Compatibility {
|
|
|
75
79
|
/**
|
|
76
80
|
* Allows selecting different values for different Gray Paper versions from one record.
|
|
77
81
|
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
82
|
+
* fallback The default value to return if no value is found for the current.
|
|
83
|
+
* versions A record mapping versions to values, checking if the version is greater or equal to the current version.
|
|
80
84
|
* @returns The value for the current version, or the default value.
|
|
81
85
|
*/
|
|
82
86
|
static selectIfGreaterOrEqual({ fallback, versions, }) {
|
|
@@ -236,7 +240,7 @@ const workspacePathFix = env.NODE_ENV === "development"
|
|
|
236
240
|
: () => (p) => p;
|
|
237
241
|
|
|
238
242
|
/**
|
|
239
|
-
*
|
|
243
|
+
* `Opaque<Type, Token>` constructs a unique type which is a subset of Type with a
|
|
240
244
|
* specified unique token Token. It means that base type cannot be assigned to unique type by accident.
|
|
241
245
|
* Good examples of opaque types include:
|
|
242
246
|
* - JWTs or other tokens - these are special kinds of string used for authorization purposes.
|
|
@@ -579,7 +583,7 @@ function isResult(x) {
|
|
|
579
583
|
* as an afterthought.
|
|
580
584
|
*/
|
|
581
585
|
|
|
582
|
-
var index$
|
|
586
|
+
var index$u = /*#__PURE__*/Object.freeze({
|
|
583
587
|
__proto__: null,
|
|
584
588
|
get CURRENT_SUITE () { return CURRENT_SUITE; },
|
|
585
589
|
get CURRENT_VERSION () { return CURRENT_VERSION; },
|
|
@@ -736,7 +740,7 @@ class Ordering {
|
|
|
736
740
|
}
|
|
737
741
|
}
|
|
738
742
|
|
|
739
|
-
var index$
|
|
743
|
+
var index$t = /*#__PURE__*/Object.freeze({
|
|
740
744
|
__proto__: null,
|
|
741
745
|
Ordering: Ordering
|
|
742
746
|
});
|
|
@@ -988,7 +992,7 @@ function u8ArraySameLengthEqual(self, other) {
|
|
|
988
992
|
}
|
|
989
993
|
const bytesBlobComparator = (a, b) => a.compare(b);
|
|
990
994
|
|
|
991
|
-
var index$
|
|
995
|
+
var index$s = /*#__PURE__*/Object.freeze({
|
|
992
996
|
__proto__: null,
|
|
993
997
|
BitVec: BitVec,
|
|
994
998
|
Bytes: Bytes,
|
|
@@ -1090,7 +1094,7 @@ const minU64 = (a, ...values) => values.reduce((min, value) => (value > min ? mi
|
|
|
1090
1094
|
/** Get the biggest value between U64 a and values given as input parameters. */
|
|
1091
1095
|
const maxU64 = (a, ...values) => values.reduce((max, value) => (value < max ? max : value), a);
|
|
1092
1096
|
|
|
1093
|
-
var index$
|
|
1097
|
+
var index$r = /*#__PURE__*/Object.freeze({
|
|
1094
1098
|
__proto__: null,
|
|
1095
1099
|
isU16: isU16,
|
|
1096
1100
|
isU32: isU32,
|
|
@@ -2529,7 +2533,7 @@ function sequenceViewFixLen(type, { fixedLength }) {
|
|
|
2529
2533
|
}, skipper);
|
|
2530
2534
|
}
|
|
2531
2535
|
|
|
2532
|
-
var index$
|
|
2536
|
+
var index$q = /*#__PURE__*/Object.freeze({
|
|
2533
2537
|
__proto__: null,
|
|
2534
2538
|
Decoder: Decoder,
|
|
2535
2539
|
Descriptor: Descriptor,
|
|
@@ -3730,7 +3734,7 @@ var keyDerivation = /*#__PURE__*/Object.freeze({
|
|
|
3730
3734
|
trivialSeed: trivialSeed
|
|
3731
3735
|
});
|
|
3732
3736
|
|
|
3733
|
-
var index$
|
|
3737
|
+
var index$p = /*#__PURE__*/Object.freeze({
|
|
3734
3738
|
__proto__: null,
|
|
3735
3739
|
BANDERSNATCH_KEY_BYTES: BANDERSNATCH_KEY_BYTES,
|
|
3736
3740
|
BANDERSNATCH_PROOF_BYTES: BANDERSNATCH_PROOF_BYTES,
|
|
@@ -4368,7 +4372,7 @@ var keccak = /*#__PURE__*/Object.freeze({
|
|
|
4368
4372
|
// TODO [ToDr] (#213) this should most likely be moved to a separate
|
|
4369
4373
|
// package to avoid pulling in unnecessary deps.
|
|
4370
4374
|
|
|
4371
|
-
var index$
|
|
4375
|
+
var index$o = /*#__PURE__*/Object.freeze({
|
|
4372
4376
|
__proto__: null,
|
|
4373
4377
|
Blake2b: Blake2b,
|
|
4374
4378
|
HASH_SIZE: HASH_SIZE,
|
|
@@ -5005,7 +5009,7 @@ class TruncatedHashDictionary {
|
|
|
5005
5009
|
}
|
|
5006
5010
|
}
|
|
5007
5011
|
|
|
5008
|
-
var index$
|
|
5012
|
+
var index$n = /*#__PURE__*/Object.freeze({
|
|
5009
5013
|
__proto__: null,
|
|
5010
5014
|
ArrayView: ArrayView,
|
|
5011
5015
|
FixedSizeArray: FixedSizeArray,
|
|
@@ -5192,7 +5196,7 @@ var PvmBackend;
|
|
|
5192
5196
|
PvmBackend[PvmBackend["Ananas"] = 1] = "Ananas";
|
|
5193
5197
|
})(PvmBackend || (PvmBackend = {}));
|
|
5194
5198
|
|
|
5195
|
-
var index$
|
|
5199
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
5196
5200
|
__proto__: null,
|
|
5197
5201
|
Bootnode: Bootnode,
|
|
5198
5202
|
ChainSpec: ChainSpec,
|
|
@@ -6699,7 +6703,7 @@ function reencodeAsView(codec, object, chainSpec) {
|
|
|
6699
6703
|
return Decoder.decodeObject(codec.View, encoded, chainSpec);
|
|
6700
6704
|
}
|
|
6701
6705
|
|
|
6702
|
-
var index$
|
|
6706
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
6703
6707
|
__proto__: null,
|
|
6704
6708
|
Block: Block,
|
|
6705
6709
|
EpochMarker: EpochMarker,
|
|
@@ -6709,6 +6713,8 @@ var index$m = /*#__PURE__*/Object.freeze({
|
|
|
6709
6713
|
SEGMENT_BYTES: SEGMENT_BYTES,
|
|
6710
6714
|
TicketsMarker: TicketsMarker,
|
|
6711
6715
|
ValidatorKeys: ValidatorKeys,
|
|
6716
|
+
W_E: W_E,
|
|
6717
|
+
W_S: W_S,
|
|
6712
6718
|
assurances: assurances,
|
|
6713
6719
|
codecPerEpochBlock: codecPerEpochBlock,
|
|
6714
6720
|
codecPerValidator: codecPerValidator,
|
|
@@ -6969,7 +6975,7 @@ var json;
|
|
|
6969
6975
|
json.object = object;
|
|
6970
6976
|
})(json || (json = {}));
|
|
6971
6977
|
|
|
6972
|
-
var index$
|
|
6978
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
6973
6979
|
__proto__: null,
|
|
6974
6980
|
get json () { return json; },
|
|
6975
6981
|
parseFromJson: parseFromJson
|
|
@@ -7239,7 +7245,7 @@ const blockFromJson = (spec) => json.object({
|
|
|
7239
7245
|
extrinsic: getExtrinsicFromJson(spec),
|
|
7240
7246
|
}, ({ header, extrinsic }) => Block.create({ header, extrinsic }));
|
|
7241
7247
|
|
|
7242
|
-
var index$
|
|
7248
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
7243
7249
|
__proto__: null,
|
|
7244
7250
|
blockFromJson: blockFromJson,
|
|
7245
7251
|
disputesExtrinsicFromJson: disputesExtrinsicFromJson,
|
|
@@ -7733,7 +7739,7 @@ class Logger {
|
|
|
7733
7739
|
}
|
|
7734
7740
|
}
|
|
7735
7741
|
|
|
7736
|
-
var index$
|
|
7742
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
7737
7743
|
__proto__: null,
|
|
7738
7744
|
get Level () { return Level; },
|
|
7739
7745
|
Logger: Logger,
|
|
@@ -7948,7 +7954,7 @@ function isJsonObject(value) {
|
|
|
7948
7954
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7949
7955
|
}
|
|
7950
7956
|
|
|
7951
|
-
var index$
|
|
7957
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
7952
7958
|
__proto__: null,
|
|
7953
7959
|
DEFAULT_CONFIG: DEFAULT_CONFIG,
|
|
7954
7960
|
DEV_CONFIG: DEV_CONFIG,
|
|
@@ -9157,11 +9163,32 @@ const ENTROPY_ENTRIES = 4;
|
|
|
9157
9163
|
|
|
9158
9164
|
var UpdatePreimageKind;
|
|
9159
9165
|
(function (UpdatePreimageKind) {
|
|
9160
|
-
/**
|
|
9166
|
+
/**
|
|
9167
|
+
* Insert new preimage and optionally update it's lookup history.
|
|
9168
|
+
*
|
|
9169
|
+
* Used in: `provide`
|
|
9170
|
+
*
|
|
9171
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/383904383904?v=0.7.2
|
|
9172
|
+
*/
|
|
9161
9173
|
UpdatePreimageKind[UpdatePreimageKind["Provide"] = 0] = "Provide";
|
|
9162
|
-
/**
|
|
9174
|
+
/**
|
|
9175
|
+
* Remove a preimage and it's lookup history.
|
|
9176
|
+
*
|
|
9177
|
+
* Used in: `forget` and `eject`
|
|
9178
|
+
*
|
|
9179
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/38c701380202?v=0.7.2
|
|
9180
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/379102379302?v=0.7.2
|
|
9181
|
+
*/
|
|
9163
9182
|
UpdatePreimageKind[UpdatePreimageKind["Remove"] = 1] = "Remove";
|
|
9164
|
-
/**
|
|
9183
|
+
/**
|
|
9184
|
+
* Update or add lookup history for preimage hash/len to given value.
|
|
9185
|
+
*
|
|
9186
|
+
* Used in: `solicit` and `forget`
|
|
9187
|
+
*
|
|
9188
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/382802382802?v=0.7.2
|
|
9189
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/384002384b02?v=0.7.2
|
|
9190
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/38c60038ea00?v=0.7.2
|
|
9191
|
+
*/
|
|
9165
9192
|
UpdatePreimageKind[UpdatePreimageKind["UpdateOrAdd"] = 2] = "UpdateOrAdd";
|
|
9166
9193
|
})(UpdatePreimageKind || (UpdatePreimageKind = {}));
|
|
9167
9194
|
/**
|
|
@@ -9169,7 +9196,7 @@ var UpdatePreimageKind;
|
|
|
9169
9196
|
*
|
|
9170
9197
|
* Can be one of the following cases:
|
|
9171
9198
|
* 1. Provide a new preimage blob and set the lookup history to available at `slot`.
|
|
9172
|
-
* 2. Remove (
|
|
9199
|
+
* 2. Remove (forget) a preimage and it's lookup history.
|
|
9173
9200
|
* 3. Update `LookupHistory` with given value.
|
|
9174
9201
|
*/
|
|
9175
9202
|
class UpdatePreimage {
|
|
@@ -9742,7 +9769,7 @@ const serviceDataCodec = codec$1.dictionary(codec$1.u32.asOpaque(), serviceEntri
|
|
|
9742
9769
|
sortKeys: (a, b) => a - b,
|
|
9743
9770
|
});
|
|
9744
9771
|
|
|
9745
|
-
var index$
|
|
9772
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
9746
9773
|
__proto__: null,
|
|
9747
9774
|
AUTHORIZATION_QUEUE_SIZE: AUTHORIZATION_QUEUE_SIZE,
|
|
9748
9775
|
AccumulationOutput: AccumulationOutput,
|
|
@@ -10373,7 +10400,6 @@ class LeafNode {
|
|
|
10373
10400
|
/**
|
|
10374
10401
|
* Get the byte length of embedded value.
|
|
10375
10402
|
*
|
|
10376
|
-
* @remark
|
|
10377
10403
|
* Note in case this node only contains hash this is going to be 0.
|
|
10378
10404
|
*/
|
|
10379
10405
|
getValueLength() {
|
|
@@ -10384,7 +10410,6 @@ class LeafNode {
|
|
|
10384
10410
|
/**
|
|
10385
10411
|
* Returns the embedded value.
|
|
10386
10412
|
*
|
|
10387
|
-
* @remark
|
|
10388
10413
|
* Note that this is going to be empty for a regular leaf node (i.e. containing a hash).
|
|
10389
10414
|
*/
|
|
10390
10415
|
getValue() {
|
|
@@ -10394,7 +10419,6 @@ class LeafNode {
|
|
|
10394
10419
|
/**
|
|
10395
10420
|
* Returns contained value hash.
|
|
10396
10421
|
*
|
|
10397
|
-
* @remark
|
|
10398
10422
|
* Note that for embedded value this is going to be full 0-padded 32 bytes.
|
|
10399
10423
|
*/
|
|
10400
10424
|
getValueHash() {
|
|
@@ -10816,7 +10840,7 @@ const bitLookup = [
|
|
|
10816
10840
|
[0b00000000, 8],
|
|
10817
10841
|
];
|
|
10818
10842
|
|
|
10819
|
-
var index$
|
|
10843
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
10820
10844
|
__proto__: null,
|
|
10821
10845
|
BranchNode: BranchNode,
|
|
10822
10846
|
InMemoryTrie: InMemoryTrie,
|
|
@@ -11183,7 +11207,7 @@ function loadState(spec, blake2b, entries) {
|
|
|
11183
11207
|
* hashmap of `key -> value` entries.
|
|
11184
11208
|
*/
|
|
11185
11209
|
|
|
11186
|
-
var index$
|
|
11210
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
11187
11211
|
__proto__: null,
|
|
11188
11212
|
SerializedService: SerializedService,
|
|
11189
11213
|
SerializedState: SerializedState,
|
|
@@ -11432,7 +11456,7 @@ class InMemoryStates {
|
|
|
11432
11456
|
async close() { }
|
|
11433
11457
|
}
|
|
11434
11458
|
|
|
11435
|
-
var index$
|
|
11459
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
11436
11460
|
__proto__: null,
|
|
11437
11461
|
InMemoryBlocks: InMemoryBlocks,
|
|
11438
11462
|
InMemorySerializedStates: InMemorySerializedStates,
|
|
@@ -11796,7 +11820,7 @@ const initEc = async () => {
|
|
|
11796
11820
|
await init.reedSolomon();
|
|
11797
11821
|
};
|
|
11798
11822
|
|
|
11799
|
-
var index$
|
|
11823
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
11800
11824
|
__proto__: null,
|
|
11801
11825
|
N_CHUNKS_REDUNDANCY: N_CHUNKS_REDUNDANCY,
|
|
11802
11826
|
N_CHUNKS_REQUIRED: N_CHUNKS_REQUIRED,
|
|
@@ -12230,7 +12254,7 @@ class FuzzTarget {
|
|
|
12230
12254
|
}
|
|
12231
12255
|
}
|
|
12232
12256
|
|
|
12233
|
-
var index$
|
|
12257
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
12234
12258
|
__proto__: null,
|
|
12235
12259
|
AncestryItem: AncestryItem,
|
|
12236
12260
|
ErrorMessage: ErrorMessage,
|
|
@@ -12248,9 +12272,9 @@ var index$c = /*#__PURE__*/Object.freeze({
|
|
|
12248
12272
|
stateRootCodec: stateRootCodec
|
|
12249
12273
|
});
|
|
12250
12274
|
|
|
12251
|
-
var index$
|
|
12275
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
12252
12276
|
__proto__: null,
|
|
12253
|
-
v1: index$
|
|
12277
|
+
v1: index$b
|
|
12254
12278
|
});
|
|
12255
12279
|
|
|
12256
12280
|
/** Size of the transfer memo. */
|
|
@@ -12679,7 +12703,11 @@ class PartiallyUpdatedState {
|
|
|
12679
12703
|
const service = this.state.getService(serviceId);
|
|
12680
12704
|
return service?.getPreimage(hash) ?? null;
|
|
12681
12705
|
}
|
|
12682
|
-
/**
|
|
12706
|
+
/**
|
|
12707
|
+
* Get status of a preimage of current service taking into account any updates.
|
|
12708
|
+
*
|
|
12709
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/110201110201?v=0.7.2
|
|
12710
|
+
*/
|
|
12683
12711
|
getLookupHistory(currentTimeslot, serviceId, hash, length) {
|
|
12684
12712
|
const updatedService = this.stateUpdate.services.updated.get(serviceId);
|
|
12685
12713
|
/** Return lookup history item for newly created service */
|
|
@@ -12716,12 +12744,7 @@ class PartiallyUpdatedState {
|
|
|
12716
12744
|
return new LookupHistoryItem(hash, updatedPreimage.length, tryAsLookupHistorySlots([currentTimeslot]));
|
|
12717
12745
|
}
|
|
12718
12746
|
case UpdatePreimageKind.Remove: {
|
|
12719
|
-
|
|
12720
|
-
// kinda impossible, since we know it's there because it's removed.
|
|
12721
|
-
if (state === null) {
|
|
12722
|
-
return null;
|
|
12723
|
-
}
|
|
12724
|
-
return new LookupHistoryItem(hash, state.length, tryAsLookupHistorySlots([...state.slots, currentTimeslot]));
|
|
12747
|
+
return null;
|
|
12725
12748
|
}
|
|
12726
12749
|
case UpdatePreimageKind.UpdateOrAdd: {
|
|
12727
12750
|
return action.item;
|
|
@@ -13113,42 +13136,6 @@ class HostCallsManager {
|
|
|
13113
13136
|
}
|
|
13114
13137
|
}
|
|
13115
13138
|
|
|
13116
|
-
/** Create a new gas counter instance depending on the gas value. */
|
|
13117
|
-
function gasCounter(gas) {
|
|
13118
|
-
return new GasCounterU64(tryAsU64(gas));
|
|
13119
|
-
}
|
|
13120
|
-
class GasCounterU64 {
|
|
13121
|
-
gas;
|
|
13122
|
-
initialGas;
|
|
13123
|
-
constructor(gas) {
|
|
13124
|
-
this.gas = gas;
|
|
13125
|
-
this.initialGas = tryAsGas(gas);
|
|
13126
|
-
}
|
|
13127
|
-
set(g) {
|
|
13128
|
-
this.gas = tryAsU64(g);
|
|
13129
|
-
}
|
|
13130
|
-
get() {
|
|
13131
|
-
return tryAsGas(this.gas);
|
|
13132
|
-
}
|
|
13133
|
-
sub(g) {
|
|
13134
|
-
const result = this.gas - tryAsU64(g);
|
|
13135
|
-
if (result >= 0n) {
|
|
13136
|
-
this.gas = tryAsU64(result);
|
|
13137
|
-
return false;
|
|
13138
|
-
}
|
|
13139
|
-
this.gas = tryAsU64(0n);
|
|
13140
|
-
return true;
|
|
13141
|
-
}
|
|
13142
|
-
used() {
|
|
13143
|
-
const gasConsumed = tryAsU64(this.initialGas) - this.gas;
|
|
13144
|
-
// In we have less than zero left we assume that all gas has been consumed.
|
|
13145
|
-
if (gasConsumed < 0) {
|
|
13146
|
-
return this.initialGas;
|
|
13147
|
-
}
|
|
13148
|
-
return tryAsGas(gasConsumed);
|
|
13149
|
-
}
|
|
13150
|
-
}
|
|
13151
|
-
|
|
13152
13139
|
const tryAsMemoryIndex = (index) => {
|
|
13153
13140
|
check `${index >= 0 && index <= MAX_MEMORY_INDEX} Incorrect memory index: ${index}!`;
|
|
13154
13141
|
return asOpaqueType(index);
|
|
@@ -13871,7 +13858,7 @@ function getRegisters(argsLength) {
|
|
|
13871
13858
|
return regs;
|
|
13872
13859
|
}
|
|
13873
13860
|
|
|
13874
|
-
var index$
|
|
13861
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
13875
13862
|
__proto__: null,
|
|
13876
13863
|
MemorySegment: MemorySegment,
|
|
13877
13864
|
SpiMemory: SpiMemory,
|
|
@@ -13930,7 +13917,7 @@ function extractCodeAndMetadata(blobWithMetadata) {
|
|
|
13930
13917
|
return { metadata, code };
|
|
13931
13918
|
}
|
|
13932
13919
|
|
|
13933
|
-
var index$
|
|
13920
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
13934
13921
|
__proto__: null,
|
|
13935
13922
|
Program: Program,
|
|
13936
13923
|
extractCodeAndMetadata: extractCodeAndMetadata
|
|
@@ -14894,6 +14881,42 @@ class BasicBlocks {
|
|
|
14894
14881
|
}
|
|
14895
14882
|
}
|
|
14896
14883
|
|
|
14884
|
+
/** Create a new gas counter instance depending on the gas value. */
|
|
14885
|
+
function gasCounter(gas) {
|
|
14886
|
+
return new GasCounterU64(tryAsU64(gas));
|
|
14887
|
+
}
|
|
14888
|
+
class GasCounterU64 {
|
|
14889
|
+
gas;
|
|
14890
|
+
initialGas;
|
|
14891
|
+
constructor(gas) {
|
|
14892
|
+
this.gas = gas;
|
|
14893
|
+
this.initialGas = tryAsGas(gas);
|
|
14894
|
+
}
|
|
14895
|
+
set(g) {
|
|
14896
|
+
this.gas = tryAsU64(g);
|
|
14897
|
+
}
|
|
14898
|
+
get() {
|
|
14899
|
+
return tryAsGas(this.gas);
|
|
14900
|
+
}
|
|
14901
|
+
sub(g) {
|
|
14902
|
+
const result = this.gas - tryAsU64(g);
|
|
14903
|
+
if (result >= 0n) {
|
|
14904
|
+
this.gas = tryAsU64(result);
|
|
14905
|
+
return false;
|
|
14906
|
+
}
|
|
14907
|
+
this.gas = tryAsU64(0n);
|
|
14908
|
+
return true;
|
|
14909
|
+
}
|
|
14910
|
+
used() {
|
|
14911
|
+
const gasConsumed = tryAsU64(this.initialGas) - this.gas;
|
|
14912
|
+
// In we have less than zero left we assume that all gas has been consumed.
|
|
14913
|
+
if (gasConsumed < 0) {
|
|
14914
|
+
return this.initialGas;
|
|
14915
|
+
}
|
|
14916
|
+
return tryAsGas(gasConsumed);
|
|
14917
|
+
}
|
|
14918
|
+
}
|
|
14919
|
+
|
|
14897
14920
|
const instructionGasMap = (() => {
|
|
14898
14921
|
const instructionGasMap = new Array(HIGHEST_INSTRUCTION_NUMBER + 1);
|
|
14899
14922
|
for (let i = 0; i < HIGHEST_INSTRUCTION_NUMBER + 1; i++) {
|
|
@@ -16802,8 +16825,77 @@ class Interpreter {
|
|
|
16802
16825
|
}
|
|
16803
16826
|
}
|
|
16804
16827
|
|
|
16805
|
-
|
|
16828
|
+
class DebuggerAdapter {
|
|
16829
|
+
pvm;
|
|
16830
|
+
constructor(useSbrkGas = false) {
|
|
16831
|
+
this.pvm = new Interpreter({ useSbrkGas });
|
|
16832
|
+
}
|
|
16833
|
+
resetGeneric(rawProgram, flatRegisters, initialGas) {
|
|
16834
|
+
this.pvm.resetGeneric(rawProgram, 0, tryAsGas(initialGas), new Registers(flatRegisters));
|
|
16835
|
+
}
|
|
16836
|
+
reset(rawProgram, pc, gas, maybeRegisters, maybeMemory) {
|
|
16837
|
+
this.pvm.resetGeneric(rawProgram, pc, tryAsGas(gas), maybeRegisters, maybeMemory);
|
|
16838
|
+
}
|
|
16839
|
+
getPageDump(pageNumber) {
|
|
16840
|
+
const page = this.pvm.getMemoryPage(pageNumber);
|
|
16841
|
+
if (page === null) {
|
|
16842
|
+
// page wasn't allocated so we return an empty page
|
|
16843
|
+
return safeAllocUint8Array(PAGE_SIZE$1);
|
|
16844
|
+
}
|
|
16845
|
+
if (page.length === PAGE_SIZE$1) {
|
|
16846
|
+
// page was allocated and has a proper size so we can simply return it
|
|
16847
|
+
return page;
|
|
16848
|
+
}
|
|
16849
|
+
// page was allocated but it is shorter than PAGE_SIZE so we have to extend it
|
|
16850
|
+
const fullPage = safeAllocUint8Array(PAGE_SIZE$1);
|
|
16851
|
+
fullPage.set(page);
|
|
16852
|
+
return fullPage;
|
|
16853
|
+
}
|
|
16854
|
+
setMemory(address, value) {
|
|
16855
|
+
this.pvm.memory.storeFrom(tryAsMemoryIndex(address), value);
|
|
16856
|
+
}
|
|
16857
|
+
getExitArg() {
|
|
16858
|
+
return this.pvm.getExitParam() ?? 0;
|
|
16859
|
+
}
|
|
16860
|
+
getStatus() {
|
|
16861
|
+
return this.pvm.getStatus();
|
|
16862
|
+
}
|
|
16863
|
+
nextStep() {
|
|
16864
|
+
return this.pvm.nextStep() === Status.OK;
|
|
16865
|
+
}
|
|
16866
|
+
nSteps(steps) {
|
|
16867
|
+
check `${steps >>> 0 > 0} Expected a positive integer got ${steps}`;
|
|
16868
|
+
for (let i = 0; i < steps; i++) {
|
|
16869
|
+
const isOk = this.nextStep();
|
|
16870
|
+
if (!isOk) {
|
|
16871
|
+
return false;
|
|
16872
|
+
}
|
|
16873
|
+
}
|
|
16874
|
+
return true;
|
|
16875
|
+
}
|
|
16876
|
+
getRegisters() {
|
|
16877
|
+
return this.pvm.registers.getAllU64();
|
|
16878
|
+
}
|
|
16879
|
+
setRegisters(registers) {
|
|
16880
|
+
this.pvm.registers.copyFrom(new Registers(registers));
|
|
16881
|
+
}
|
|
16882
|
+
getProgramCounter() {
|
|
16883
|
+
return this.pvm.getPC();
|
|
16884
|
+
}
|
|
16885
|
+
setNextProgramCounter(nextPc) {
|
|
16886
|
+
this.pvm.setNextPC(nextPc);
|
|
16887
|
+
}
|
|
16888
|
+
getGasLeft() {
|
|
16889
|
+
return BigInt(this.pvm.gas.get());
|
|
16890
|
+
}
|
|
16891
|
+
setGasLeft(gas) {
|
|
16892
|
+
this.pvm.gas.set(tryAsGas(gas));
|
|
16893
|
+
}
|
|
16894
|
+
}
|
|
16895
|
+
|
|
16896
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
16806
16897
|
__proto__: null,
|
|
16898
|
+
DebuggerAdapter: DebuggerAdapter,
|
|
16807
16899
|
Interpreter: Interpreter,
|
|
16808
16900
|
Memory: Memory,
|
|
16809
16901
|
MemoryBuilder: MemoryBuilder,
|
|
@@ -17393,7 +17485,7 @@ class InterpreterInstanceManager {
|
|
|
17393
17485
|
}
|
|
17394
17486
|
}
|
|
17395
17487
|
|
|
17396
|
-
var index$
|
|
17488
|
+
var index$6 = /*#__PURE__*/Object.freeze({
|
|
17397
17489
|
__proto__: null,
|
|
17398
17490
|
HostCallMemory: HostCallMemory,
|
|
17399
17491
|
HostCallRegisters: HostCallRegisters,
|
|
@@ -17486,7 +17578,7 @@ const codecServiceAccountInfoWithThresholdBalance = codec$1.object({
|
|
|
17486
17578
|
parentService: codec$1.u32.convert((x) => x, tryAsServiceId),
|
|
17487
17579
|
}, "ServiceAccountInfoWithThresholdBalance");
|
|
17488
17580
|
|
|
17489
|
-
var index$
|
|
17581
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
17490
17582
|
__proto__: null,
|
|
17491
17583
|
AccumulationStateUpdate: AccumulationStateUpdate,
|
|
17492
17584
|
CURRENT_SERVICE_ID: CURRENT_SERVICE_ID,
|
|
@@ -17641,154 +17733,9 @@ class Mountain {
|
|
|
17641
17733
|
}
|
|
17642
17734
|
}
|
|
17643
17735
|
|
|
17644
|
-
var index$5 = /*#__PURE__*/Object.freeze({
|
|
17645
|
-
__proto__: null,
|
|
17646
|
-
MerkleMountainRange: MerkleMountainRange
|
|
17647
|
-
});
|
|
17648
|
-
|
|
17649
|
-
class DebuggerAdapter {
|
|
17650
|
-
pvm;
|
|
17651
|
-
constructor(useSbrkGas = false) {
|
|
17652
|
-
this.pvm = new Interpreter({ useSbrkGas });
|
|
17653
|
-
}
|
|
17654
|
-
resetGeneric(rawProgram, flatRegisters, initialGas) {
|
|
17655
|
-
this.pvm.resetGeneric(rawProgram, 0, tryAsGas(initialGas), new Registers(flatRegisters));
|
|
17656
|
-
}
|
|
17657
|
-
reset(rawProgram, pc, gas, maybeRegisters, maybeMemory) {
|
|
17658
|
-
this.pvm.resetGeneric(rawProgram, pc, tryAsGas(gas), maybeRegisters, maybeMemory);
|
|
17659
|
-
}
|
|
17660
|
-
getPageDump(pageNumber) {
|
|
17661
|
-
const page = this.pvm.getMemoryPage(pageNumber);
|
|
17662
|
-
if (page === null) {
|
|
17663
|
-
// page wasn't allocated so we return an empty page
|
|
17664
|
-
return safeAllocUint8Array(PAGE_SIZE$1);
|
|
17665
|
-
}
|
|
17666
|
-
if (page.length === PAGE_SIZE$1) {
|
|
17667
|
-
// page was allocated and has a proper size so we can simply return it
|
|
17668
|
-
return page;
|
|
17669
|
-
}
|
|
17670
|
-
// page was allocated but it is shorter than PAGE_SIZE so we have to extend it
|
|
17671
|
-
const fullPage = safeAllocUint8Array(PAGE_SIZE$1);
|
|
17672
|
-
fullPage.set(page);
|
|
17673
|
-
return fullPage;
|
|
17674
|
-
}
|
|
17675
|
-
setMemory(address, value) {
|
|
17676
|
-
this.pvm.memory.storeFrom(tryAsMemoryIndex(address), value);
|
|
17677
|
-
}
|
|
17678
|
-
getExitArg() {
|
|
17679
|
-
return this.pvm.getExitParam() ?? 0;
|
|
17680
|
-
}
|
|
17681
|
-
getStatus() {
|
|
17682
|
-
return this.pvm.getStatus();
|
|
17683
|
-
}
|
|
17684
|
-
nextStep() {
|
|
17685
|
-
return this.pvm.nextStep() === Status.OK;
|
|
17686
|
-
}
|
|
17687
|
-
nSteps(steps) {
|
|
17688
|
-
check `${steps >>> 0 > 0} Expected a positive integer got ${steps}`;
|
|
17689
|
-
for (let i = 0; i < steps; i++) {
|
|
17690
|
-
const isOk = this.nextStep();
|
|
17691
|
-
if (!isOk) {
|
|
17692
|
-
return false;
|
|
17693
|
-
}
|
|
17694
|
-
}
|
|
17695
|
-
return true;
|
|
17696
|
-
}
|
|
17697
|
-
getRegisters() {
|
|
17698
|
-
return this.pvm.registers.getAllU64();
|
|
17699
|
-
}
|
|
17700
|
-
setRegisters(registers) {
|
|
17701
|
-
this.pvm.registers.copyFrom(new Registers(registers));
|
|
17702
|
-
}
|
|
17703
|
-
getProgramCounter() {
|
|
17704
|
-
return this.pvm.getPC();
|
|
17705
|
-
}
|
|
17706
|
-
setNextProgramCounter(nextPc) {
|
|
17707
|
-
this.pvm.setNextPC(nextPc);
|
|
17708
|
-
}
|
|
17709
|
-
getGasLeft() {
|
|
17710
|
-
return BigInt(this.pvm.gas.get());
|
|
17711
|
-
}
|
|
17712
|
-
setGasLeft(gas) {
|
|
17713
|
-
this.pvm.gas.set(tryAsGas(gas));
|
|
17714
|
-
}
|
|
17715
|
-
}
|
|
17716
|
-
|
|
17717
17736
|
var index$4 = /*#__PURE__*/Object.freeze({
|
|
17718
17737
|
__proto__: null,
|
|
17719
|
-
|
|
17720
|
-
ArgsDecoder: ArgsDecoder,
|
|
17721
|
-
get ArgumentType () { return ArgumentType; },
|
|
17722
|
-
BasicBlocks: BasicBlocks,
|
|
17723
|
-
CURRENT_SERVICE_ID: CURRENT_SERVICE_ID,
|
|
17724
|
-
get EjectError () { return EjectError; },
|
|
17725
|
-
ExtendedWitdthImmediateDecoder: ExtendedWitdthImmediateDecoder,
|
|
17726
|
-
get ForgetPreimageError () { return ForgetPreimageError; },
|
|
17727
|
-
HostCallMemory: HostCallMemory,
|
|
17728
|
-
HostCallRegisters: HostCallRegisters,
|
|
17729
|
-
HostCallResult: HostCallResult,
|
|
17730
|
-
ImmediateDecoder: ImmediateDecoder,
|
|
17731
|
-
InsufficientFundsError: InsufficientFundsError,
|
|
17732
|
-
MachineInstance: MachineInstance,
|
|
17733
|
-
Mask: Mask,
|
|
17734
|
-
get MemoryOperation () { return MemoryOperation; },
|
|
17735
|
-
MemorySegment: MemorySegment,
|
|
17736
|
-
NO_OF_REGISTERS: NO_OF_REGISTERS$1,
|
|
17737
|
-
get NewServiceError () { return NewServiceError; },
|
|
17738
|
-
NibblesDecoder: NibblesDecoder,
|
|
17739
|
-
NoMachineError: NoMachineError,
|
|
17740
|
-
OK: OK,
|
|
17741
|
-
get PagesError () { return PagesError; },
|
|
17742
|
-
PartiallyUpdatedState: PartiallyUpdatedState,
|
|
17743
|
-
get PeekPokeError () { return PeekPokeError; },
|
|
17744
|
-
PendingTransfer: PendingTransfer,
|
|
17745
|
-
get PreimageStatusKind () { return PreimageStatusKind; },
|
|
17746
|
-
Program: Program,
|
|
17747
|
-
ProgramDecoder: ProgramDecoder,
|
|
17748
|
-
get ProvidePreimageError () { return ProvidePreimageError; },
|
|
17749
|
-
Pvm: DebuggerAdapter,
|
|
17750
|
-
Registers: Registers,
|
|
17751
|
-
get RequestPreimageError () { return RequestPreimageError; },
|
|
17752
|
-
Result: Result$1,
|
|
17753
|
-
SERVICE_ID_BYTES: SERVICE_ID_BYTES,
|
|
17754
|
-
SegmentExportError: SegmentExportError,
|
|
17755
|
-
SpiMemory: SpiMemory,
|
|
17756
|
-
SpiProgram: SpiProgram,
|
|
17757
|
-
TRANSFER_MEMO_BYTES: TRANSFER_MEMO_BYTES,
|
|
17758
|
-
get TransferError () { return TransferError; },
|
|
17759
|
-
UnprivilegedError: UnprivilegedError,
|
|
17760
|
-
get UpdatePrivilegesError () { return UpdatePrivilegesError; },
|
|
17761
|
-
WithDebug: WithDebug,
|
|
17762
|
-
get ZeroVoidError () { return ZeroVoidError; },
|
|
17763
|
-
asOpaqueType: asOpaqueType,
|
|
17764
|
-
assertEmpty: assertEmpty,
|
|
17765
|
-
assertNever: assertNever,
|
|
17766
|
-
block: index$m,
|
|
17767
|
-
bytes: index$t,
|
|
17768
|
-
check: check,
|
|
17769
|
-
clampU64ToU32: clampU64ToU32,
|
|
17770
|
-
createResults: createResults,
|
|
17771
|
-
decodeStandardProgram: decodeStandardProgram,
|
|
17772
|
-
emptyRegistersBuffer: emptyRegistersBuffer,
|
|
17773
|
-
extractCodeAndMetadata: extractCodeAndMetadata,
|
|
17774
|
-
getServiceId: getServiceId,
|
|
17775
|
-
getServiceIdOrCurrent: getServiceIdOrCurrent,
|
|
17776
|
-
hash: index$p,
|
|
17777
|
-
hostCallInfoAccount: codecServiceAccountInfoWithThresholdBalance,
|
|
17778
|
-
inspect: inspect,
|
|
17779
|
-
instructionArgumentTypeMap: instructionArgumentTypeMap,
|
|
17780
|
-
interpreter: index$8,
|
|
17781
|
-
isBrowser: isBrowser,
|
|
17782
|
-
lazyInspect: lazyInspect,
|
|
17783
|
-
measure: measure,
|
|
17784
|
-
numbers: index$s,
|
|
17785
|
-
resultToString: resultToString,
|
|
17786
|
-
seeThrough: seeThrough,
|
|
17787
|
-
slotsToPreimageStatus: slotsToPreimageStatus,
|
|
17788
|
-
toMemoryOperation: toMemoryOperation,
|
|
17789
|
-
tryAsMachineId: tryAsMachineId,
|
|
17790
|
-
tryAsProgramCounter: tryAsProgramCounter,
|
|
17791
|
-
writeServiceIdAsLeBytes: writeServiceIdAsLeBytes
|
|
17738
|
+
MerkleMountainRange: MerkleMountainRange
|
|
17792
17739
|
});
|
|
17793
17740
|
|
|
17794
17741
|
const ENTROPY_BYTES = 32;
|
|
@@ -18430,4 +18377,4 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
18430
18377
|
TransitionHasher: TransitionHasher
|
|
18431
18378
|
});
|
|
18432
18379
|
|
|
18433
|
-
export { index$
|
|
18380
|
+
export { index$l as block, index$j as block_json, index$s as bytes, index$q as codec, index$n as collections, index$m as config, index$h as config_node, index$p as crypto, index$d as database, index$c as erasure_coding, index$a as fuzz_proto, index$o as hash, index$5 as jam_host_calls, index$k as json_parser, index$i as logger, index$4 as mmr, index$r as numbers, index$t as ordering, index$7 as pvm, index$6 as pvm_host_calls, index$8 as pvm_program, index$9 as pvm_spi_decoder, index$3 as shuffling, index$g as state, index$2 as state_json, index$e as state_merkleization, index$1 as state_vectors, index as transition, index$f as trie, index$u as utils };
|