@typeberry/convert 0.2.0-291a493 → 0.2.0-2ecdea0
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.js +32 -42
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -8413,6 +8413,8 @@ const chain_spec_EC_SEGMENT_SIZE = 4104;
|
|
|
8413
8413
|
* Additional data that has to be passed to the codec to correctly parse incoming bytes.
|
|
8414
8414
|
*/
|
|
8415
8415
|
class ChainSpec extends WithDebug {
|
|
8416
|
+
/** Human-readable name of the chain spec. */
|
|
8417
|
+
name;
|
|
8416
8418
|
/** Number of validators. */
|
|
8417
8419
|
validatorsCount;
|
|
8418
8420
|
/** 1/3 of number of validators */
|
|
@@ -8455,6 +8457,7 @@ class ChainSpec extends WithDebug {
|
|
|
8455
8457
|
maxLookupAnchorAge;
|
|
8456
8458
|
constructor(data) {
|
|
8457
8459
|
super();
|
|
8460
|
+
this.name = data.name;
|
|
8458
8461
|
this.validatorsCount = data.validatorsCount;
|
|
8459
8462
|
this.thirdOfValidators = numbers_tryAsU16(Math.floor(data.validatorsCount / 3));
|
|
8460
8463
|
this.validatorsSuperMajority = numbers_tryAsU16(Math.floor(data.validatorsCount / 3) * 2 + 1);
|
|
@@ -8475,6 +8478,7 @@ class ChainSpec extends WithDebug {
|
|
|
8475
8478
|
}
|
|
8476
8479
|
/** Set of values for "tiny" chain as defined in JAM test vectors. */
|
|
8477
8480
|
const chain_spec_tinyChainSpec = new ChainSpec({
|
|
8481
|
+
name: "tiny",
|
|
8478
8482
|
validatorsCount: numbers_tryAsU16(6),
|
|
8479
8483
|
coresCount: numbers_tryAsU16(2),
|
|
8480
8484
|
epochLength: numbers_tryAsU32(12),
|
|
@@ -8496,6 +8500,7 @@ const chain_spec_tinyChainSpec = new ChainSpec({
|
|
|
8496
8500
|
* Please note that only validatorsCount and epochLength are "full", the rest is copied from "tiny".
|
|
8497
8501
|
*/
|
|
8498
8502
|
const chain_spec_fullChainSpec = new ChainSpec({
|
|
8503
|
+
name: "full",
|
|
8499
8504
|
validatorsCount: numbers_tryAsU16(1023),
|
|
8500
8505
|
coresCount: numbers_tryAsU16(341),
|
|
8501
8506
|
epochLength: numbers_tryAsU32(600),
|
|
@@ -10789,7 +10794,7 @@ const DEFAULT_CONFIG = "default";
|
|
|
10789
10794
|
const NODE_DEFAULTS = {
|
|
10790
10795
|
name: isBrowser() ? "browser" : external_node_os_default().hostname(),
|
|
10791
10796
|
config: [DEFAULT_CONFIG],
|
|
10792
|
-
pvm: pvm_backend_PvmBackend.
|
|
10797
|
+
pvm: pvm_backend_PvmBackend.Ananas,
|
|
10793
10798
|
};
|
|
10794
10799
|
/** Chain spec chooser. */
|
|
10795
10800
|
var KnownChainSpec;
|
|
@@ -12880,6 +12885,15 @@ class InMemoryService extends WithDebug {
|
|
|
12880
12885
|
}),
|
|
12881
12886
|
};
|
|
12882
12887
|
}
|
|
12888
|
+
/** Return identical `InMemoryService` which does not share any references. */
|
|
12889
|
+
clone() {
|
|
12890
|
+
return new InMemoryService(this.serviceId, {
|
|
12891
|
+
info: service_ServiceAccountInfo.create(this.data.info),
|
|
12892
|
+
preimages: hash_dictionary_HashDictionary.fromEntries(Array.from(this.data.preimages.entries())),
|
|
12893
|
+
lookupHistory: hash_dictionary_HashDictionary.fromEntries(Array.from(this.data.lookupHistory.entries()).map(([k, v]) => [k, v.slice()])),
|
|
12894
|
+
storage: new Map(this.data.storage.entries()),
|
|
12895
|
+
});
|
|
12896
|
+
}
|
|
12883
12897
|
/**
|
|
12884
12898
|
* Create a new in-memory service from another state service
|
|
12885
12899
|
* by copying all given entries.
|
|
@@ -15062,7 +15076,6 @@ function* serializeRemovedServices(servicesRemoved) {
|
|
|
15062
15076
|
return;
|
|
15063
15077
|
}
|
|
15064
15078
|
for (const serviceId of servicesRemoved) {
|
|
15065
|
-
// TODO [ToDr] what about all data associated with a service?
|
|
15066
15079
|
const codec = serialize.serviceData(serviceId);
|
|
15067
15080
|
yield [serialize_state_update_StateEntryUpdateAction.Remove, codec.key, EMPTY_BLOB];
|
|
15068
15081
|
}
|
|
@@ -15874,7 +15887,6 @@ class InMemoryStates {
|
|
|
15874
15887
|
|
|
15875
15888
|
|
|
15876
15889
|
|
|
15877
|
-
|
|
15878
15890
|
/** Helper function to create most used hashes in the block */
|
|
15879
15891
|
class hasher_TransitionHasher {
|
|
15880
15892
|
context;
|
|
@@ -15923,15 +15935,6 @@ class hasher_TransitionHasher {
|
|
|
15923
15935
|
const encoded = BytesBlob.blobFromParts([et.raw, ep.raw, eg.raw, ea.raw, ed.raw]);
|
|
15924
15936
|
return new WithHashAndBytes(this.blake2b.hashBytes(encoded).asOpaque(), extrinsicView, encoded);
|
|
15925
15937
|
}
|
|
15926
|
-
/** Creates hash for given WorkPackage */
|
|
15927
|
-
workPackage(workPackage) {
|
|
15928
|
-
return this.encode(WorkPackage.Codec, workPackage);
|
|
15929
|
-
}
|
|
15930
|
-
encode(codec, data) {
|
|
15931
|
-
// TODO [ToDr] Use already allocated encoding destination and hash bytes from some arena.
|
|
15932
|
-
const encoded = Encoder.encodeObject(codec, data, this.context);
|
|
15933
|
-
return new WithHashAndBytes(this.blake2b.hashBytes(encoded).asOpaque(), data, encoded);
|
|
15934
|
-
}
|
|
15935
15938
|
}
|
|
15936
15939
|
|
|
15937
15940
|
;// CONCATENATED MODULE: ./packages/jam/transition/preimages.ts
|
|
@@ -15944,7 +15947,6 @@ var PreimagesErrorCode;
|
|
|
15944
15947
|
PreimagesErrorCode["PreimagesNotSortedUnique"] = "preimages_not_sorted_unique";
|
|
15945
15948
|
PreimagesErrorCode["AccountNotFound"] = "account_not_found";
|
|
15946
15949
|
})(PreimagesErrorCode || (PreimagesErrorCode = {}));
|
|
15947
|
-
// TODO [SeKo] consider whether this module is the right place to remove expired preimages
|
|
15948
15950
|
class preimages_Preimages {
|
|
15949
15951
|
state;
|
|
15950
15952
|
blake2b;
|
|
@@ -16514,7 +16516,7 @@ var ResultValues;
|
|
|
16514
16516
|
* reach the epoch change block.
|
|
16515
16517
|
*/
|
|
16516
16518
|
const ringCommitmentCache = [];
|
|
16517
|
-
//
|
|
16519
|
+
// NOTE [ToDr] We export the entire object to allow mocking in tests.
|
|
16518
16520
|
// Ideally we would just export functions and figure out how to mock
|
|
16519
16521
|
// properly in ESM.
|
|
16520
16522
|
/* harmony default export */ const bandersnatch_vrf = ({
|
|
@@ -17539,13 +17541,6 @@ var partial_state_ForgetPreimageError;
|
|
|
17539
17541
|
})(partial_state_ForgetPreimageError || (partial_state_ForgetPreimageError = {}));
|
|
17540
17542
|
/**
|
|
17541
17543
|
* Errors that may occur when the transfer is invoked.
|
|
17542
|
-
*
|
|
17543
|
-
* TODO [ToDr] Since I don't fully understand yet which of these
|
|
17544
|
-
* could be checked directly in the host call (i.e. if we will
|
|
17545
|
-
* have access to the service account state there) for now I keep
|
|
17546
|
-
* them safely in the `AccumulationPartialState` implementation.
|
|
17547
|
-
* However, if possible, these should be moved directly to the
|
|
17548
|
-
* host call implementation.
|
|
17549
17544
|
*/
|
|
17550
17545
|
var partial_state_TransferError;
|
|
17551
17546
|
(function (TransferError) {
|
|
@@ -17876,7 +17871,7 @@ class accumulate_externalities_AccumulateExternalities {
|
|
|
17876
17871
|
const status = slots === null ? null : slotsToPreimageStatus(slots.slots);
|
|
17877
17872
|
// The previous code needs to be forgotten and expired.
|
|
17878
17873
|
if (status?.status !== PreimageStatusKind.Unavailable) {
|
|
17879
|
-
return [false,
|
|
17874
|
+
return [false, `wrong status: ${status !== null ? PreimageStatusKind[status.status] : null}`];
|
|
17880
17875
|
}
|
|
17881
17876
|
const t = this.currentTimeslot;
|
|
17882
17877
|
const isExpired = status.data[1] < t - this.chainSpec.preimageExpungePeriod;
|
|
@@ -23039,18 +23034,11 @@ class interpreter_Interpreter {
|
|
|
23039
23034
|
|
|
23040
23035
|
|
|
23041
23036
|
|
|
23042
|
-
;// CONCATENATED MODULE: external "node:url"
|
|
23043
|
-
const external_node_url_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:url");
|
|
23044
23037
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter-ananas/index.ts
|
|
23045
23038
|
|
|
23046
23039
|
|
|
23047
23040
|
|
|
23048
23041
|
|
|
23049
|
-
|
|
23050
|
-
|
|
23051
|
-
// TODO [ToDr] Temporary solution. We need to inline WASM files for the final build.
|
|
23052
|
-
const wasmPath = (0,external_node_url_namespaceObject.fileURLToPath)(new URL(import.meta.resolve("@fluffylabs/anan-as/release-mini.wasm"), import.meta.url));
|
|
23053
|
-
const wasmBuffer = (0,external_node_fs_namespaceObject.readFileSync)(wasmPath);
|
|
23054
23042
|
// Max u32 value
|
|
23055
23043
|
const INF_STEPS = (/* unused pure expression or super */ null && (2 ** 32 - 1));
|
|
23056
23044
|
class AnanasRegisters {
|
|
@@ -23136,8 +23124,7 @@ class pvm_interpreter_ananas_AnanasInterpreter {
|
|
|
23136
23124
|
this.gas = new AnanasGasCounter(instance);
|
|
23137
23125
|
}
|
|
23138
23126
|
static async new() {
|
|
23139
|
-
const
|
|
23140
|
-
const instance = await instantiate(wasmModule, {
|
|
23127
|
+
const instance = await instantiate({
|
|
23141
23128
|
env: {
|
|
23142
23129
|
abort: () => {
|
|
23143
23130
|
throw new Error("Abort called from WASM");
|
|
@@ -24842,7 +24829,7 @@ class accumulate_Accumulate {
|
|
|
24842
24829
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/18d70118d701?v=0.6.7
|
|
24843
24830
|
*/
|
|
24844
24831
|
async accumulateSingleService(serviceId, transfers, operands, gasCost, slot, entropy, inputStateUpdate) {
|
|
24845
|
-
accumulate_logger.log `Accumulating service ${serviceId}, transfers: ${transfers.length} operands: ${operands.length} at slot: ${slot}
|
|
24832
|
+
accumulate_logger.log `Accumulating service ${serviceId}, transfers: ${transfers.length} operands: ${operands.length} at slot: ${slot}`;
|
|
24846
24833
|
const updatedState = new PartiallyUpdatedState(this.state, inputStateUpdate);
|
|
24847
24834
|
// update service balance from incoming transfers
|
|
24848
24835
|
if (Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)) {
|
|
@@ -26545,6 +26532,7 @@ class statistics_Statistics {
|
|
|
26545
26532
|
|
|
26546
26533
|
|
|
26547
26534
|
|
|
26535
|
+
|
|
26548
26536
|
class DbHeaderChain {
|
|
26549
26537
|
blocks;
|
|
26550
26538
|
constructor(blocks) {
|
|
@@ -26738,7 +26726,7 @@ class chain_stf_OnChain {
|
|
|
26738
26726
|
}
|
|
26739
26727
|
const { preimages, ...preimagesRest } = preimagesResult.ok;
|
|
26740
26728
|
assertEmpty(preimagesRest);
|
|
26741
|
-
const timerAccumulate = measure(
|
|
26729
|
+
const timerAccumulate = measure(`import:accumulate (${PvmBackend[this.accumulate.pvm]})`);
|
|
26742
26730
|
// accumulate
|
|
26743
26731
|
const accumulateResult = await this.accumulate.transition({
|
|
26744
26732
|
slot: timeSlot,
|
|
@@ -26978,22 +26966,24 @@ function blockAsView(spec, block) {
|
|
|
26978
26966
|
// that were run pre-V1 fuzzer version.
|
|
26979
26967
|
const jamConformance070V0Spec = new ChainSpec({
|
|
26980
26968
|
...chain_spec_tinyChainSpec,
|
|
26969
|
+
name: "jam-conformance-v070v0",
|
|
26981
26970
|
maxLookupAnchorAge: numbers_tryAsU32(14_400),
|
|
26982
26971
|
});
|
|
26983
|
-
async function runStateTransition(testContent,
|
|
26972
|
+
async function runStateTransition(testContent, options, variant) {
|
|
26973
|
+
const pvm = variant === "ananas" ? PvmBackend.Ananas : PvmBackend.BuiltIn;
|
|
26984
26974
|
const blake2b = await Blake2b.createHasher();
|
|
26985
26975
|
// a bit of a hack, but the new value for `maxLookupAnchorAge` was proposed with V1
|
|
26986
26976
|
// version of the fuzzer, yet these tests were still depending on the older value.
|
|
26987
26977
|
// To simplify the chain spec, we just special case this one vector here.
|
|
26988
|
-
const spec =
|
|
26978
|
+
const spec = options.path.includes("fuzz-reports/0.7.0/traces/1756548916/00000082.json")
|
|
26989
26979
|
? jamConformance070V0Spec
|
|
26990
|
-
: chainSpec;
|
|
26980
|
+
: options.chainSpec;
|
|
26991
26981
|
const preState = loadState(spec, blake2b, testContent.pre_state.keyvals);
|
|
26992
26982
|
const postState = loadState(spec, blake2b, testContent.post_state.keyvals);
|
|
26993
26983
|
const preStateRoot = preState.backend.getRootHash(blake2b);
|
|
26994
26984
|
const postStateRoot = postState.backend.getRootHash(blake2b);
|
|
26995
26985
|
const blockView = blockAsView(spec, testContent.block);
|
|
26996
|
-
const allBlocks = loadBlocks(
|
|
26986
|
+
const allBlocks = loadBlocks(options.path, spec);
|
|
26997
26987
|
const myBlockIndex = allBlocks.findIndex(({ header }) => header.timeSlotIndex === testContent.block.header.timeSlotIndex);
|
|
26998
26988
|
const previousBlocks = allBlocks.slice(0, myBlockIndex);
|
|
26999
26989
|
const hasher = new TransitionHasher(spec, await keccakHasher, blake2b);
|
|
@@ -27002,7 +26992,7 @@ async function runStateTransition(testContent, testPath, t, chainSpec) {
|
|
|
27002
26992
|
const headerHash = hasher.header(blockView.header.view());
|
|
27003
26993
|
return new WithHash(headerHash.hash, blockView);
|
|
27004
26994
|
}));
|
|
27005
|
-
const stf = new OnChain(spec, preState, blocksDb, hasher,
|
|
26995
|
+
const stf = new OnChain(spec, preState, blocksDb, hasher, pvm);
|
|
27006
26996
|
// verify that we compute the state root exactly the same.
|
|
27007
26997
|
assert.deepStrictEqual(testContent.pre_state.state_root.toString(), preStateRoot.toString());
|
|
27008
26998
|
assert.deepStrictEqual(testContent.post_state.state_root.toString(), postStateRoot.toString());
|
|
@@ -27027,7 +27017,7 @@ async function runStateTransition(testContent, testPath, t, chainSpec) {
|
|
|
27027
27017
|
preState.backend.applyUpdate(serializeStateUpdate(spec, blake2b, stfResult.ok));
|
|
27028
27018
|
// some conformance test vectors have an empty state, we run them, yet do not perform any assertions.
|
|
27029
27019
|
if (testContent.post_state.keyvals.length === 0) {
|
|
27030
|
-
|
|
27020
|
+
options.test.skip(`Successfuly run a test vector with empty post state!. Please verify: ${options.path}`);
|
|
27031
27021
|
return;
|
|
27032
27022
|
}
|
|
27033
27023
|
// if the stf was successful compare the resulting state and the root (redundant, but double checking).
|
|
@@ -27094,8 +27084,8 @@ const workItemFromJson = json.object({
|
|
|
27094
27084
|
extrinsic,
|
|
27095
27085
|
exportCount: export_count,
|
|
27096
27086
|
}));
|
|
27097
|
-
async function runWorkItemTest(test,
|
|
27098
|
-
runCodecTest(WorkItem.Codec, test,
|
|
27087
|
+
async function runWorkItemTest(test, { path }) {
|
|
27088
|
+
runCodecTest(WorkItem.Codec, test, path);
|
|
27099
27089
|
}
|
|
27100
27090
|
|
|
27101
27091
|
;// CONCATENATED MODULE: ./bin/test-runner/w3f/codec/work-package.ts
|
|
@@ -27141,7 +27131,7 @@ const workPackageFromJson = compatibility_Compatibility.isGreaterOrEqual(compati
|
|
|
27141
27131
|
context,
|
|
27142
27132
|
items: sized_array_FixedSizeArray.new(items, tryAsWorkItemsCount(items.length)),
|
|
27143
27133
|
}));
|
|
27144
|
-
async function runWorkPackageTest(test, file) {
|
|
27134
|
+
async function runWorkPackageTest(test, { path: file }) {
|
|
27145
27135
|
runCodecTest(WorkPackage.Codec, test, file);
|
|
27146
27136
|
}
|
|
27147
27137
|
|