@typeberry/lib 0.5.2 → 0.5.3-aa4626d
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/package.json +9 -5
- package/packages/core/collections/blob-dictionary.d.ts.map +1 -1
- package/packages/core/collections/blob-dictionary.js +3 -3
- package/packages/core/crypto/bandersnatch.d.ts +2 -1
- package/packages/core/crypto/bandersnatch.d.ts.map +1 -1
- package/packages/core/crypto/bandersnatch.js +9 -2
- package/packages/core/crypto/key-derivation.test.js +8 -7
- package/packages/core/hash/hash.d.ts.map +1 -1
- package/packages/core/hash/hash.js +1 -0
- package/packages/core/networking/package.json +1 -1
- package/packages/core/numbers/index.d.ts +4 -0
- package/packages/core/numbers/index.d.ts.map +1 -1
- package/packages/core/numbers/index.js +4 -4
- package/packages/core/pvm-host-calls/bin.js +6 -6
- package/packages/core/pvm-host-calls/ecalli-io-tracker.d.ts +32 -0
- package/packages/core/pvm-host-calls/ecalli-io-tracker.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/ecalli-io-tracker.js +14 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.d.ts +139 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.js +209 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.test.d.ts +2 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.test.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.test.js +231 -0
- package/packages/core/pvm-host-calls/host-call-memory.d.ts +2 -0
- package/packages/core/pvm-host-calls/host-call-memory.d.ts.map +1 -1
- package/packages/core/pvm-host-calls/host-call-memory.js +12 -2
- package/packages/core/pvm-host-calls/host-call-registers.d.ts +6 -0
- package/packages/core/pvm-host-calls/host-call-registers.d.ts.map +1 -1
- package/packages/core/pvm-host-calls/host-call-registers.js +24 -0
- package/packages/core/pvm-host-calls/host-calls-executor.d.ts +37 -0
- package/packages/core/pvm-host-calls/host-calls-executor.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/host-calls-executor.js +129 -0
- package/packages/core/pvm-host-calls/host-calls.d.ts +20 -26
- package/packages/core/pvm-host-calls/host-calls.d.ts.map +1 -1
- package/packages/core/pvm-host-calls/host-calls.js +40 -112
- package/packages/core/pvm-host-calls/index.d.ts +7 -6
- package/packages/core/pvm-host-calls/index.d.ts.map +1 -1
- package/packages/core/pvm-host-calls/index.js +7 -6
- package/packages/core/pvm-host-calls/{interpreter-instance-manager.d.ts → pvm-instance-manager.d.ts} +3 -3
- package/packages/core/pvm-host-calls/pvm-instance-manager.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/{interpreter-instance-manager.js → pvm-instance-manager.js} +2 -2
- package/packages/core/pvm-interpreter/ops/math-consts.d.ts +2 -3
- package/packages/core/pvm-interpreter/ops/math-consts.d.ts.map +1 -1
- package/packages/core/pvm-interpreter/ops/math-consts.js +2 -3
- package/packages/core/pvm-interpreter/ops/math-ops.js +3 -3
- package/packages/core/pvm-interpreter/ops/math-utils.js +13 -13
- package/packages/core/pvm-interpreter/ops/math-utils.test.js +17 -16
- package/packages/core/telemetry/package.json +1 -1
- package/packages/jam/block/work-item.d.ts +13 -4
- package/packages/jam/block/work-item.d.ts.map +1 -1
- package/packages/jam/block/work-result.d.ts +3 -5
- package/packages/jam/block/work-result.d.ts.map +1 -1
- package/packages/jam/block/work-result.js +6 -0
- package/packages/jam/block-json/work-result.d.ts.map +1 -1
- package/packages/jam/block-json/work-result.js +6 -6
- package/packages/jam/database-lmdb/states.test.js +4 -3
- package/packages/jam/executor/index.d.ts +4 -0
- package/packages/jam/executor/index.d.ts.map +1 -0
- package/packages/jam/executor/index.js +2 -0
- package/packages/jam/{transition/accumulate → executor}/pvm-executor.d.ts +19 -16
- package/packages/jam/executor/pvm-executor.d.ts.map +1 -0
- package/packages/jam/{transition/accumulate → executor}/pvm-executor.js +48 -5
- package/packages/jam/in-core/externalities/refine.d.ts +24 -0
- package/packages/jam/in-core/externalities/refine.d.ts.map +1 -0
- package/packages/jam/in-core/externalities/refine.js +36 -0
- package/packages/jam/in-core/in-core.d.ts +60 -0
- package/packages/jam/in-core/in-core.d.ts.map +1 -0
- package/packages/jam/in-core/in-core.js +294 -0
- package/packages/jam/in-core/in-core.test.d.ts +2 -0
- package/packages/jam/in-core/in-core.test.d.ts.map +1 -0
- package/packages/jam/in-core/in-core.test.js +81 -0
- package/packages/jam/in-core/index.d.ts +2 -0
- package/packages/jam/in-core/index.d.ts.map +1 -0
- package/packages/jam/in-core/index.js +1 -0
- package/packages/jam/jam-host-calls/accumulate/bless.test.js +4 -5
- package/packages/jam/jamnp-s/protocol/ce-133-work-package-submission.d.ts +3 -3
- package/packages/jam/jamnp-s/protocol/ce-133-work-package-submission.d.ts.map +1 -1
- package/packages/jam/jamnp-s/protocol/ce-135-work-report-distribution.test.js +2 -2
- package/packages/jam/node/main-importer.d.ts.map +1 -1
- package/packages/jam/node/main-importer.js +3 -1
- package/packages/jam/node/package.json +1 -1
- package/packages/jam/rpc-validation/types.d.ts +7 -3
- package/packages/jam/rpc-validation/types.d.ts.map +1 -1
- package/packages/jam/rpc-validation/validation.d.ts +254 -36
- package/packages/jam/rpc-validation/validation.d.ts.map +1 -1
- package/packages/jam/rpc-validation/validation.js +20 -2
- package/packages/jam/safrole/bandersnatch-vrf.d.ts +2 -0
- package/packages/jam/safrole/bandersnatch-vrf.d.ts.map +1 -1
- package/packages/jam/safrole/bandersnatch-vrf.js +11 -0
- package/packages/jam/safrole/bandersnatch-vrf.test.js +3 -3
- package/packages/jam/safrole/bandersnatch-wasm.d.ts +1 -0
- package/packages/jam/safrole/bandersnatch-wasm.d.ts.map +1 -1
- package/packages/jam/safrole/bandersnatch-wasm.js +8 -5
- package/packages/jam/safrole/safrole-seal.d.ts +1 -3
- package/packages/jam/safrole/safrole-seal.d.ts.map +1 -1
- package/packages/jam/safrole/safrole-seal.js +14 -25
- package/packages/jam/safrole/safrole-seal.test.js +4 -10
- package/packages/jam/state/in-memory-state.d.ts.map +1 -1
- package/packages/jam/state/in-memory-state.js +2 -3
- package/packages/jam/state/test.utils.d.ts.map +1 -1
- package/packages/jam/state/test.utils.js +2 -3
- package/packages/jam/transition/accumulate/accumulate-data.d.ts.map +1 -1
- package/packages/jam/transition/accumulate/accumulate-data.js +1 -2
- package/packages/jam/transition/accumulate/accumulate-queue.test.js +2 -2
- package/packages/jam/transition/accumulate/accumulate-utils.test.js +2 -2
- package/packages/jam/transition/accumulate/accumulate.d.ts.map +1 -1
- package/packages/jam/transition/accumulate/accumulate.js +8 -13
- package/packages/jam/transition/accumulate/accumulate.test.js +2 -2
- package/packages/jam/transition/accumulate/accumulation-result-merge-utils.d.ts.map +1 -1
- package/packages/jam/transition/accumulate/accumulation-result-merge-utils.js +1 -2
- package/packages/jam/transition/accumulate/accumulation-result-merge-utils.test.js +1 -2
- package/packages/jam/transition/accumulate/deferred-transfers.d.ts +1 -1
- package/packages/jam/transition/accumulate/deferred-transfers.d.ts.map +1 -1
- package/packages/jam/transition/accumulate/deferred-transfers.js +6 -7
- package/packages/jam/transition/disputes/disputes.d.ts.map +1 -1
- package/packages/jam/transition/disputes/disputes.js +5 -4
- package/packages/jam/transition/disputes/disputes.test.data2.js +2 -2
- package/packages/jam/transition/externalities/fetch-externalities.d.ts +7 -1
- package/packages/jam/transition/externalities/fetch-externalities.d.ts.map +1 -1
- package/packages/jam/transition/externalities/fetch-externalities.js +4 -0
- package/packages/jam/transition/externalities/fetch-externalities.test.js +2 -2
- package/packages/jam/transition/hasher.test.js +2 -2
- package/packages/jam/transition/reports/test.utils.d.ts.map +1 -1
- package/packages/jam/transition/reports/test.utils.js +2 -2
- package/packages/workers/block-authorship/package.json +1 -1
- package/packages/workers/importer/package.json +1 -1
- package/packages/core/pvm-host-calls/host-calls-manager.d.ts +0 -23
- package/packages/core/pvm-host-calls/host-calls-manager.d.ts.map +0 -1
- package/packages/core/pvm-host-calls/host-calls-manager.js +0 -44
- package/packages/core/pvm-host-calls/interpreter-instance-manager.d.ts.map +0 -1
- package/packages/jam/transition/accumulate/pvm-executor.d.ts.map +0 -1
|
@@ -12,7 +12,6 @@ export var SafroleSealError;
|
|
|
12
12
|
SafroleSealError[SafroleSealError["InvalidValidator"] = 1] = "InvalidValidator";
|
|
13
13
|
SafroleSealError[SafroleSealError["InvalidTicket"] = 2] = "InvalidTicket";
|
|
14
14
|
SafroleSealError[SafroleSealError["IncorrectSeal"] = 3] = "IncorrectSeal";
|
|
15
|
-
SafroleSealError[SafroleSealError["IncorrectEntropySource"] = 4] = "IncorrectEntropySource";
|
|
16
15
|
})(SafroleSealError || (SafroleSealError = {}));
|
|
17
16
|
const BANDERSNATCH_ZERO_KEY = Bytes.zero(BANDERSNATCH_KEY_BYTES).asOpaque();
|
|
18
17
|
export class SafroleSeal {
|
|
@@ -25,21 +24,6 @@ export class SafroleSeal {
|
|
|
25
24
|
* hence the state is passed as an argument for more control.
|
|
26
25
|
*/
|
|
27
26
|
async verifyHeaderSeal(headerView, state) {
|
|
28
|
-
const sealResult = await this.verifySeal(headerView, state);
|
|
29
|
-
if (sealResult.isError) {
|
|
30
|
-
return sealResult;
|
|
31
|
-
}
|
|
32
|
-
// verify entropySource
|
|
33
|
-
const payload = BytesBlob.blobFromParts(JAM_ENTROPY, sealResult.ok.raw);
|
|
34
|
-
const blockAuthorIndex = headerView.bandersnatchBlockAuthorIndex.materialize();
|
|
35
|
-
const blockAuthorKey = state.currentValidatorData.at(blockAuthorIndex)?.bandersnatch;
|
|
36
|
-
const entropySourceResult = await bandersnatchVrf.verifySeal(await this.bandersnatch, blockAuthorKey ?? BANDERSNATCH_ZERO_KEY, headerView.entropySource.materialize(), payload, BytesBlob.blobFromNumbers([]));
|
|
37
|
-
if (entropySourceResult.isError) {
|
|
38
|
-
return Result.error(SafroleSealError.IncorrectEntropySource, () => "Safrole: incorrect entropy source in header seal");
|
|
39
|
-
}
|
|
40
|
-
return Result.ok(entropySourceResult.ok);
|
|
41
|
-
}
|
|
42
|
-
async verifySeal(headerView, state) {
|
|
43
27
|
// we use transitioned keys already
|
|
44
28
|
const validatorIndex = headerView.bandersnatchBlockAuthorIndex.materialize();
|
|
45
29
|
const authorKeys = state.currentValidatorData.at(validatorIndex);
|
|
@@ -58,17 +42,21 @@ export class SafroleSeal {
|
|
|
58
42
|
async verifySealWithTicket(tickets, timeSlot, entropy, validatorData, headerView) {
|
|
59
43
|
const index = timeSlot % tickets.length;
|
|
60
44
|
const ticket = tickets.at(index);
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
if (ticket === undefined) {
|
|
46
|
+
return Result.error(SafroleSealError.IncorrectSeal, () => "Safrole: missing ticket");
|
|
47
|
+
}
|
|
48
|
+
const payload = BytesBlob.blobFromParts(JAM_TICKET_SEAL, entropy.raw, new Uint8Array([ticket.attempt]));
|
|
49
|
+
// verify seal and entropy source correctness
|
|
63
50
|
const authorKey = validatorData.bandersnatch;
|
|
64
|
-
const result = await bandersnatchVrf.
|
|
51
|
+
const result = await bandersnatchVrf.verifyHeaderSeals(await this.bandersnatch, authorKey ?? BANDERSNATCH_ZERO_KEY, headerView.seal.materialize(), payload, encodeUnsealedHeader(headerView), headerView.entropySource.materialize(), BytesBlob.blobFrom(JAM_ENTROPY));
|
|
65
52
|
if (result.isError) {
|
|
66
53
|
return Result.error(SafroleSealError.IncorrectSeal, () => "Safrole: incorrect seal with ticket");
|
|
67
54
|
}
|
|
68
|
-
|
|
69
|
-
|
|
55
|
+
const [sealOutput, entropyOutput] = result.ok;
|
|
56
|
+
if (!ticket.id.isEqualTo(sealOutput)) {
|
|
57
|
+
return Result.error(SafroleSealError.InvalidTicket, () => `Safrole: invalid ticket, expected ${ticket.id} got ${sealOutput}`);
|
|
70
58
|
}
|
|
71
|
-
return Result.ok(
|
|
59
|
+
return Result.ok(entropyOutput);
|
|
72
60
|
}
|
|
73
61
|
/** Fallback mode of Safrole. */
|
|
74
62
|
async verifySealWithKeys(keys, timeSlot, entropy, authorKey, headerView) {
|
|
@@ -78,12 +66,13 @@ export class SafroleSeal {
|
|
|
78
66
|
if (sealingKey === undefined || !sealingKey.isEqualTo(authorBandersnatchKey)) {
|
|
79
67
|
return Result.error(SafroleSealError.InvalidValidator, () => `Invalid Validator. Expected: ${sealingKey}, got: ${authorKey.bandersnatch}`);
|
|
80
68
|
}
|
|
81
|
-
// verify seal correctness
|
|
69
|
+
// verify seal and entropy source correctness
|
|
82
70
|
const payload = BytesBlob.blobFromParts(JAM_FALLBACK_SEAL, entropy.raw);
|
|
83
|
-
const result = await bandersnatchVrf.
|
|
71
|
+
const result = await bandersnatchVrf.verifyHeaderSeals(await this.bandersnatch, authorBandersnatchKey, headerView.seal.materialize(), payload, encodeUnsealedHeader(headerView), headerView.entropySource.materialize(), BytesBlob.blobFrom(JAM_ENTROPY));
|
|
84
72
|
if (result.isError) {
|
|
85
73
|
return Result.error(SafroleSealError.IncorrectSeal, () => "Safrole: incorrect seal with keys");
|
|
86
74
|
}
|
|
87
|
-
|
|
75
|
+
const [_, entropyOutput] = result.ok;
|
|
76
|
+
return Result.ok(entropyOutput);
|
|
88
77
|
}
|
|
89
78
|
}
|
|
@@ -35,11 +35,8 @@ describe("Safrole Seal verification", () => {
|
|
|
35
35
|
sealingKeySeries: SEALING_KEYS,
|
|
36
36
|
currentEntropy: Bytes.parseBytes("0x405c80c1f6a2d5a0f8dbc56996f04230221100d9500244648f02a795d7850eac", HASH_SIZE).asOpaque(),
|
|
37
37
|
});
|
|
38
|
-
assert.
|
|
39
|
-
|
|
40
|
-
isOk: true,
|
|
41
|
-
ok: Bytes.parseBytes("0xc13af3d0cbdb7174590f34518e3beb05708935ceaee242e7ba11a94ca87bd007", HASH_SIZE).asOpaque(),
|
|
42
|
-
});
|
|
38
|
+
assert.strictEqual(result.isOk, true);
|
|
39
|
+
assert.strictEqual(result.ok.toString(), "0xc13af3d0cbdb7174590f34518e3beb05708935ceaee242e7ba11a94ca87bd007");
|
|
43
40
|
});
|
|
44
41
|
it("should verify a valid ticket seal and entropySource", async () => {
|
|
45
42
|
// based on test-vectors/w3f-davxy_070/traces/safrole/00000002.json
|
|
@@ -63,11 +60,8 @@ describe("Safrole Seal verification", () => {
|
|
|
63
60
|
sealingKeySeries: SEALING_KEYS,
|
|
64
61
|
currentEntropy: Bytes.parseBytes("0x405c80c1f6a2d5a0f8dbc56996f04230221100d9500244648f02a795d7850eac", HASH_SIZE).asOpaque(),
|
|
65
62
|
});
|
|
66
|
-
assert.
|
|
67
|
-
|
|
68
|
-
isOk: true,
|
|
69
|
-
ok: Bytes.parseBytes("0xc13af3d0cbdb7174590f34518e3beb05708935ceaee242e7ba11a94ca87bd007", HASH_SIZE).asOpaque(),
|
|
70
|
-
});
|
|
63
|
+
assert.strictEqual(result.isOk, true);
|
|
64
|
+
assert.strictEqual(result.ok.toString(), "0xc13af3d0cbdb7174590f34518e3beb05708935ceaee242e7ba11a94ca87bd007");
|
|
71
65
|
});
|
|
72
66
|
});
|
|
73
67
|
const TEST_VALIDATOR_KEYS = tryAsPerValidator([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory-state.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/state/in-memory-state.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,QAAQ,EAMd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAS,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EAEL,cAAc,EACd,cAAc,EAEd,KAAK,cAAc,EACnB,WAAW,EAEZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAgC,KAAK,oB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E,eAAe,CAAC,CAAC;IAE1C,gBAAgB,IAAI,SAAS,SAAS,EAAE;IAIxC,UAAU,CAAC,EAAE,EAAE,SAAS,GAAG,OAAO,GAAG,IAAI;IAIzC,SAAS,aACU,SAAS,EAAE,SAAS,EACrC,CAAC,EAAE,mBAAmB;IAyBxB,IAAI,IAAI,SAAS;IAIjB;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS;CA+G7B;AAED,+CAA+C;AAC/C,MAAM,MAAM,cAAc,GAAG;IAC3B,4BAA4B;IAC5B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,yBAAyB;IACzB,SAAS,EAAE,YAAY,EAAE,CAAC;IAC1B,8BAA8B;IAC9B,aAAa,EAAE;QAAE,IAAI,EAAE,YAAY,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAE,EAAE,CAAC;CACtD,CAAC;AAEF,eAAO,MAAM,mBAAmB,6KAc9B,CAAC;AAEH,2DAA2D;AAC3D,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;AAEzD,eAAO,MAAM,gBAAgB,+aAE3B,CAAC;AAEH,0DAA0D;AAC1D,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;AAEjF,KAAK,UAAU,CAAC,CAAC,IAAI;KAElB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,KAAK,GAAG,CAAC;CAClD,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -5,8 +5,7 @@ import { asKnownSize, FixedSizeArray, HashDictionary, HashSet, SortedArray, Sort
|
|
|
5
5
|
import { BANDERSNATCH_KEY_BYTES, BLS_KEY_BYTES, ED25519_KEY_BYTES } from "#@typeberry/crypto";
|
|
6
6
|
import { BANDERSNATCH_RING_ROOT_BYTES } from "#@typeberry/crypto/bandersnatch.js";
|
|
7
7
|
import { HASH_SIZE } from "#@typeberry/hash";
|
|
8
|
-
import { tryAsU32 } from "#@typeberry/numbers";
|
|
9
|
-
import { MAX_VALUE } from "#@typeberry/pvm-interpreter/ops/math-consts.js";
|
|
8
|
+
import { MAX_VALUE_U32, tryAsU32 } from "#@typeberry/numbers";
|
|
10
9
|
import { asOpaqueType, assertNever, check, OK, Result, WithDebug } from "#@typeberry/utils";
|
|
11
10
|
import { accumulationOutputComparator } from "./accumulation-output.js";
|
|
12
11
|
import { AUTHORIZATION_QUEUE_SIZE } from "./auth.js";
|
|
@@ -451,7 +450,7 @@ export class InMemoryState extends WithDebug {
|
|
|
451
450
|
manager: tryAsServiceId(0),
|
|
452
451
|
assigners: tryAsPerCore(new Array(spec.coresCount).fill(tryAsServiceId(0)), spec),
|
|
453
452
|
delegator: tryAsServiceId(0),
|
|
454
|
-
registrar: tryAsServiceId(
|
|
453
|
+
registrar: tryAsServiceId(MAX_VALUE_U32),
|
|
455
454
|
autoAccumulateServices: new Map(),
|
|
456
455
|
}),
|
|
457
456
|
accumulationOutputLog: SortedArray.fromArray(accumulationOutputComparator, []),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.utils.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/state/test.utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test.utils.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/state/test.utils.ts"],"names":[],"mappings":"AAoBA,OAAO,EAUL,aAAa,EAYd,MAAM,YAAY,CAAC;AAKpB,eAAO,MAAM,SAAS,QAAO,aAyT5B,CAAC;AAqCF,eAAO,MAAM,eAAe,QAK1B,CAAC;AAEH,eAAO,MAAM,UAAU,YAkHtB,CAAC"}
|
|
@@ -6,8 +6,7 @@ import { asKnownSize, FixedSizeArray, HashDictionary, HashSet, SortedArray, Sort
|
|
|
6
6
|
import { tinyChainSpec } from "#@typeberry/config";
|
|
7
7
|
import { BANDERSNATCH_RING_ROOT_BYTES } from "#@typeberry/crypto/bandersnatch.js";
|
|
8
8
|
import { HASH_SIZE } from "#@typeberry/hash";
|
|
9
|
-
import { tryAsU16, tryAsU32, tryAsU64 } from "#@typeberry/numbers";
|
|
10
|
-
import { MAX_VALUE } from "#@typeberry/pvm-interpreter/ops/math-consts.js";
|
|
9
|
+
import { MAX_VALUE_U32, tryAsU16, tryAsU32, tryAsU64 } from "#@typeberry/numbers";
|
|
11
10
|
import { Compatibility, GpVersion } from "#@typeberry/utils";
|
|
12
11
|
import { AUTHORIZATION_QUEUE_SIZE, AvailabilityAssignment, accumulationOutputComparator, BlockState, CoreStatistics, DisputesRecords, ENTROPY_ENTRIES, hashComparator, InMemoryService, InMemoryState, LookupHistoryItem, PreimageItem, PrivilegedServices, RecentBlocks, SafroleSealingKeysData, ServiceAccountInfo, ServiceStatistics, StatisticsData, tryAsPerCore, ValidatorData, ValidatorStatistics, } from "./index.js";
|
|
13
12
|
const spec = tinyChainSpec;
|
|
@@ -271,7 +270,7 @@ export const testState = () => {
|
|
|
271
270
|
manager: tryAsServiceId(0),
|
|
272
271
|
assigners: tryAsPerCore(new Array(spec.coresCount).fill(tryAsServiceId(0)), spec),
|
|
273
272
|
delegator: tryAsServiceId(0),
|
|
274
|
-
registrar: tryAsServiceId(
|
|
273
|
+
registrar: tryAsServiceId(MAX_VALUE_U32),
|
|
275
274
|
autoAccumulateServices: new Map(),
|
|
276
275
|
}),
|
|
277
276
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accumulate-data.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/accumulate-data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAmB,MAAM,kBAAkB,CAAC;AACpF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KA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AS,EAAE,SAAS,GAAG,GAAG;IAI3C,mDAAmD;IACnD,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU;IAI7C;;;;OAIG;IACH,aAAa,IAAI,SAAS,EAAE;CAG7B"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { tryAsServiceGas } from "#@typeberry/block";
|
|
2
|
-
import { sumU64, tryAsU32 } from "#@typeberry/numbers";
|
|
3
|
-
import { MAX_VALUE_U64 } from "#@typeberry/pvm-interpreter/ops/math-consts.js";
|
|
2
|
+
import { MAX_VALUE_U64, sumU64, tryAsU32 } from "#@typeberry/numbers";
|
|
4
3
|
import { Operand } from "./operand.js";
|
|
5
4
|
class AccumulateDataItem {
|
|
6
5
|
operands;
|
|
@@ -3,7 +3,7 @@ import { tryAsCoreIndex, tryAsPerEpochBlock, tryAsServiceGas, tryAsServiceId, tr
|
|
|
3
3
|
import { RefineContext, WorkPackageInfo } from "#@typeberry/block/refine-context.js";
|
|
4
4
|
import { tryAsWorkItemsCount } from "#@typeberry/block/work-package.js";
|
|
5
5
|
import { WorkPackageSpec, WorkReport } from "#@typeberry/block/work-report.js";
|
|
6
|
-
import { WorkExecResult,
|
|
6
|
+
import { WorkExecResult, WorkRefineLoad, WorkResult } from "#@typeberry/block/work-result.js";
|
|
7
7
|
import { Bytes, BytesBlob } from "#@typeberry/bytes";
|
|
8
8
|
import { asKnownSize, FixedSizeArray, HashSet } from "#@typeberry/collections";
|
|
9
9
|
import { tinyChainSpec } from "#@typeberry/config";
|
|
@@ -43,7 +43,7 @@ describe("accumulate-queue", () => {
|
|
|
43
43
|
importedSegments: tryAsU32(0),
|
|
44
44
|
}),
|
|
45
45
|
payloadHash: Bytes.zero(HASH_SIZE).asOpaque(),
|
|
46
|
-
result:
|
|
46
|
+
result: WorkExecResult.ok(BytesBlob.empty()),
|
|
47
47
|
serviceId: tryAsServiceId(0),
|
|
48
48
|
}),
|
|
49
49
|
], tryAsWorkItemsCount(1)),
|
|
@@ -4,7 +4,7 @@ import { tryAsCoreIndex, tryAsServiceGas, tryAsServiceId, tryAsTimeSlot } from "
|
|
|
4
4
|
import { RefineContext } from "#@typeberry/block/refine-context.js";
|
|
5
5
|
import { tryAsWorkItemsCount } from "#@typeberry/block/work-package.js";
|
|
6
6
|
import { WorkPackageSpec, WorkReport } from "#@typeberry/block/work-report.js";
|
|
7
|
-
import { WorkExecResult,
|
|
7
|
+
import { WorkExecResult, WorkRefineLoad, WorkResult } from "#@typeberry/block/work-result.js";
|
|
8
8
|
import { Bytes, BytesBlob } from "#@typeberry/bytes";
|
|
9
9
|
import { FixedSizeArray, HashSet } from "#@typeberry/collections";
|
|
10
10
|
import { tinyChainSpec } from "#@typeberry/config";
|
|
@@ -52,7 +52,7 @@ describe("accumulate-utils", () => {
|
|
|
52
52
|
importedSegments: tryAsU32(0),
|
|
53
53
|
}),
|
|
54
54
|
payloadHash: Bytes.zero(HASH_SIZE).asOpaque(),
|
|
55
|
-
result:
|
|
55
|
+
result: WorkExecResult.ok(BytesBlob.empty()),
|
|
56
56
|
serviceId: tryAsServiceId(0),
|
|
57
57
|
}),
|
|
58
58
|
], tryAsWorkItemsCount(1)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accumulate.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/accumulate.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EAIf,MAAM,kBAAkB,CAAC;AAM1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"accumulate.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/accumulate.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EAIf,MAAM,kBAAkB,CAAC;AAM1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,KAAK,OAAO,EAA8B,MAAM,iBAAiB,CAA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ry/codec";
|
|
5
5
|
import { ArrayView, HashSet, SortedArray } from "#@typeberry/collections";
|
|
6
|
+
import { PvmExecutor, ReturnStatus } from "#@typeberry/executor";
|
|
6
7
|
import { HASH_SIZE } from "#@typeberry/hash";
|
|
7
8
|
import { AccumulationStateUpdate, PartiallyUpdatedState, } from "#@typeberry/jam-host-calls/externalities/state-update.js";
|
|
8
9
|
import { Logger } from "#@typeberry/logger";
|
|
9
|
-
import { sumU64, tryAsU32 } from "#@typeberry/numbers";
|
|
10
|
-
import { Status, tryAsGas } from "#@typeberry/pvm-interface";
|
|
11
|
-
import { MAX_VALUE_U64 } from "#@typeberry/pvm-interpreter/ops/math-consts.js";
|
|
10
|
+
import { MAX_VALUE_U64, sumU64, tryAsU32 } from "#@typeberry/numbers";
|
|
12
11
|
import { accumulationOutputComparator, hashComparator, ServiceAccountInfo, tryAsPerCore, } from "#@typeberry/state";
|
|
13
12
|
import { assertEmpty, Compatibility, GpVersion, Result, TestSuite } from "#@typeberry/utils";
|
|
14
13
|
import { AccumulateExternalities } from "../externalities/accumulate-externalities.js";
|
|
@@ -18,7 +17,6 @@ import { AccumulateQueue, pruneQueue } from "./accumulate-queue.js";
|
|
|
18
17
|
import { GAS_TO_INVOKE_WORK_REPORT, } from "./accumulate-state.js";
|
|
19
18
|
import { generateNextServiceId, getWorkPackageHashes } from "./accumulate-utils.js";
|
|
20
19
|
import { mergePerallelAccumulationResults, } from "./accumulation-result-merge-utils.js";
|
|
21
|
-
import { PvmExecutor } from "./pvm-executor.js";
|
|
22
20
|
export const ACCUMULATION_ERROR = "duplicate service created";
|
|
23
21
|
var PvmInvocationError;
|
|
24
22
|
(function (PvmInvocationError) {
|
|
@@ -102,28 +100,25 @@ export class Accumulate {
|
|
|
102
100
|
serviceId,
|
|
103
101
|
argsLength: tryAsU32(transfers.length + operands.length),
|
|
104
102
|
});
|
|
105
|
-
const result = await executor.run(invocationArgs,
|
|
103
|
+
const result = await executor.run(invocationArgs, gas);
|
|
106
104
|
const [newState, checkpoint] = partialState.getStateUpdates();
|
|
107
105
|
/**
|
|
108
106
|
* PVM invocation returned and error so we return the checkpoint
|
|
109
107
|
*
|
|
110
108
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/300002300002?v=0.6.7
|
|
111
109
|
*/
|
|
112
|
-
if (result.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
logger.trace `[${serviceId}] accumulate finished with ${Status[status]} reverting to checkpoint.`;
|
|
116
|
-
return Result.ok({ stateUpdate: checkpoint, consumedGas: tryAsServiceGas(result.consumedGas) });
|
|
117
|
-
}
|
|
118
|
-
logger.trace `[${serviceId}] accumulate finished with ${Status[status]}`;
|
|
110
|
+
if (result.status !== ReturnStatus.OK) {
|
|
111
|
+
logger.trace `[${serviceId}] accumulate finished with ${ReturnStatus[result.status]} reverting to checkpoint.`;
|
|
112
|
+
return Result.ok({ stateUpdate: checkpoint, consumedGas: tryAsServiceGas(result.consumedGas) });
|
|
119
113
|
}
|
|
114
|
+
logger.trace `[${serviceId}] accumulate finished with ${ReturnStatus[result.status]}`;
|
|
120
115
|
/**
|
|
121
116
|
* PVM invocation returned a hash so we override whatever `yield` host call
|
|
122
117
|
* provided.
|
|
123
118
|
*
|
|
124
119
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/301202301202?v=0.6.7
|
|
125
120
|
*/
|
|
126
|
-
if (result.
|
|
121
|
+
if (result.memorySlice.length === HASH_SIZE) {
|
|
127
122
|
const memorySlice = Bytes.fromBlob(result.memorySlice, HASH_SIZE);
|
|
128
123
|
newState.yieldedRoot = memorySlice.asOpaque();
|
|
129
124
|
}
|
|
@@ -5,7 +5,7 @@ import { MIN_PUBLIC_SERVICE_INDEX } from "#@typeberry/block/gp-constants.js";
|
|
|
5
5
|
import { RefineContext } from "#@typeberry/block/refine-context.js";
|
|
6
6
|
import { tryAsWorkItemsCount } from "#@typeberry/block/work-package.js";
|
|
7
7
|
import { WorkPackageSpec, WorkReport } from "#@typeberry/block/work-report.js";
|
|
8
|
-
import { WorkExecResult,
|
|
8
|
+
import { WorkExecResult, WorkRefineLoad, WorkResult } from "#@typeberry/block/work-result.js";
|
|
9
9
|
import { Bytes, BytesBlob } from "#@typeberry/bytes";
|
|
10
10
|
import { asKnownSize, FixedSizeArray, HashDictionary, HashSet } from "#@typeberry/collections";
|
|
11
11
|
import { PvmBackend, PvmBackendNames, tinyChainSpec } from "#@typeberry/config";
|
|
@@ -266,7 +266,7 @@ const createWorkReport = (workPackageHash, prerequisites = [], serviceId = tryAs
|
|
|
266
266
|
importedSegments: tryAsU32(0),
|
|
267
267
|
}),
|
|
268
268
|
payloadHash: Bytes.zero(HASH_SIZE).asOpaque(),
|
|
269
|
-
result:
|
|
269
|
+
result: WorkExecResult.ok(BytesBlob.empty()),
|
|
270
270
|
serviceId,
|
|
271
271
|
}),
|
|
272
272
|
], tryAsWorkItemsCount(1)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accumulation-result-merge-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/accumulation-result-merge-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAmB,MAAM,kBAAkB,CAAC;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"accumulation-result-merge-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/accumulation-result-merge-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAmB,MAAM,kBAAkB,CAAC;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,uBAAuB,EACnC,OAAO,EAAE,0BAA0B,GAClC,WAAW,CAab;AAED,KAAK,SAAS,GAAG,SAAS,CAAC;AAC3B,KAAK,WAAW,GAAG;IAAE,WAAW,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,uBAAuB,CAAA;CAAE,CAAC;AAGrF,MAAM,MAAM,0BAA0B,GAAG,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAErE,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,YAAY,EAAE,UAAU,CAAC;IACzB,KAAK,EAAE,uBAAuB,CAAC;CAChC,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { tryAsServiceGas } from "#@typeberry/block";
|
|
2
2
|
import { AccumulationStateUpdate } from "#@typeberry/jam-host-calls";
|
|
3
|
-
import { sumU64 } from "#@typeberry/numbers";
|
|
4
|
-
import { MAX_VALUE_U64 } from "#@typeberry/pvm-interpreter/ops/math-consts.js";
|
|
3
|
+
import { MAX_VALUE_U64, sumU64 } from "#@typeberry/numbers";
|
|
5
4
|
import { PrivilegedServices, tryAsPerCore, UpdatePreimageKind } from "#@typeberry/state";
|
|
6
5
|
export function mergePerallelAccumulationResults(chainSpec, state, inputState, results) {
|
|
7
6
|
const mergeContext = createMergeContext(chainSpec, state, inputState, results);
|
|
@@ -7,8 +7,7 @@ import { BANDERSNATCH_KEY_BYTES, BLS_KEY_BYTES, ED25519_KEY_BYTES } from "#@type
|
|
|
7
7
|
import { HASH_SIZE } from "#@typeberry/hash";
|
|
8
8
|
import { AccumulationStateUpdate, PendingTransfer } from "#@typeberry/jam-host-calls";
|
|
9
9
|
import { TRANSFER_MEMO_BYTES } from "#@typeberry/jam-host-calls/externalities/partial-state.js";
|
|
10
|
-
import { tryAsU32, tryAsU64 } from "#@typeberry/numbers";
|
|
11
|
-
import { MAX_VALUE_U64 } from "#@typeberry/pvm-interpreter/ops/math-consts.js";
|
|
10
|
+
import { MAX_VALUE_U64, tryAsU32, tryAsU64 } from "#@typeberry/numbers";
|
|
12
11
|
import { AUTHORIZATION_QUEUE_SIZE, InMemoryState, PreimageItem, PrivilegedServices, ServiceAccountInfo, StorageItem, tryAsPerCore, UpdatePreimage, UpdateService, UpdateStorage, VALIDATOR_META_BYTES, ValidatorData, } from "#@typeberry/state";
|
|
13
12
|
import { deepEqual } from "#@typeberry/utils";
|
|
14
13
|
import { mergePerallelAccumulationResults } from "./accumulation-result-merge-utils.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type EntropyHash, type ServiceId, type TimeSlot } from "#@typeberry/block";
|
|
2
2
|
import type { ChainSpec, PvmBackend } from "#@typeberry/config";
|
|
3
3
|
import type { Blake2b } from "#@typeberry/hash";
|
|
4
|
-
import type { PendingTransfer } from "#@typeberry/jam-host-calls
|
|
4
|
+
import type { PendingTransfer } from "#@typeberry/jam-host-calls";
|
|
5
5
|
import { type ServicesUpdate, type State } from "#@typeberry/state";
|
|
6
6
|
import { Result } from "#@typeberry/utils";
|
|
7
7
|
import type { CountAndGasUsed } from "../statistics.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deferred-transfers.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/deferred-transfers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAmB,MAAM,kBAAkB,CAAC;AAGpG,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"deferred-transfers.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/deferred-transfers.ts"],"names":[],"mappings":"AAAA,OAAO,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f,gBAAgB,EAChB,QAAQ,EACR,cAAc,EAAE,mBAAmB,EACnC,OAAO,GACR,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC,uBAAuB,EAAE,0BAA0B,CAAC,CAAC;CAuFjG"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { tryAsServiceGas } from "#@typeberry/block";
|
|
2
2
|
import { W_C } from "#@typeberry/block/gp-constants.js";
|
|
3
3
|
import { codec, Encoder } from "#@typeberry/codec";
|
|
4
|
-
import {
|
|
4
|
+
import { PvmExecutor } from "#@typeberry/executor";
|
|
5
|
+
import { AccumulationStateUpdate, PartiallyUpdatedState } from "#@typeberry/jam-host-calls";
|
|
5
6
|
import { Logger } from "#@typeberry/logger";
|
|
6
7
|
import { sumU64, tryAsU32 } from "#@typeberry/numbers";
|
|
7
|
-
import { tryAsGas } from "#@typeberry/pvm-interface";
|
|
8
8
|
import { ServiceAccountInfo } from "#@typeberry/state";
|
|
9
9
|
import { Result } from "#@typeberry/utils";
|
|
10
10
|
import { AccumulateExternalities } from "../externalities/accumulate-externalities.js";
|
|
11
11
|
import { FetchExternalities } from "../externalities/fetch-externalities.js";
|
|
12
12
|
import { uniquePreserveOrder } from "./accumulate-utils.js";
|
|
13
|
-
import { PvmExecutor } from "./pvm-executor.js";
|
|
14
13
|
const ARGS_CODEC = codec.object({
|
|
15
14
|
timeslot: codec.varU32.asOpaque(),
|
|
16
15
|
serviceId: codec.varU32.asOpaque(),
|
|
@@ -61,7 +60,7 @@ export class DeferredTransfers {
|
|
|
61
60
|
partiallyUpdatedState.updateServiceInfo(serviceId, newInfo);
|
|
62
61
|
const partialState = new AccumulateExternalities(this.chainSpec, this.blake2b, partiallyUpdatedState, serviceId, serviceId, timeslot);
|
|
63
62
|
const fetchExternalities = FetchExternalities.createForOnTransfer({ entropy, transfers }, this.chainSpec);
|
|
64
|
-
let consumedGas =
|
|
63
|
+
let consumedGas = tryAsServiceGas(0);
|
|
65
64
|
const hasTransfers = transfers.length > 0;
|
|
66
65
|
const isCodeCorrect = code !== null && code.length <= W_C;
|
|
67
66
|
if (!hasTransfers || !isCodeCorrect) {
|
|
@@ -78,10 +77,10 @@ export class DeferredTransfers {
|
|
|
78
77
|
else {
|
|
79
78
|
const executor = await PvmExecutor.createOnTransferExecutor(serviceId, code, { partialState, fetchExternalities }, this.pvm);
|
|
80
79
|
const args = Encoder.encodeObject(ARGS_CODEC, { timeslot, serviceId, transfersLength: tryAsU32(transfers.length) }, this.chainSpec);
|
|
81
|
-
const gas = transfers.reduce((acc, item) => acc + item.gas, 0n);
|
|
82
|
-
consumedGas = (await executor.run(args,
|
|
80
|
+
const gas = tryAsServiceGas(transfers.reduce((acc, item) => acc + item.gas, 0n));
|
|
81
|
+
consumedGas = (await executor.run(args, gas)).consumedGas;
|
|
83
82
|
}
|
|
84
|
-
transferStatistics.set(serviceId, { count: tryAsU32(transfers.length), gasUsed:
|
|
83
|
+
transferStatistics.set(serviceId, { count: tryAsU32(transfers.length), gasUsed: consumedGas });
|
|
85
84
|
const [updatedState] = partialState.getStateUpdates();
|
|
86
85
|
currentStateUpdate = updatedState;
|
|
87
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"disputes.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/disputes/disputes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGtE,OAAO,EAAkB,OAAO,EAA0B,MAAM,wBAAwB,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAQ/C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO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O,CAAC,QAAQ,CAAC,OAAO;aACR,KAAK,EAAE,aAAa;gBAFnB,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EACjB,KAAK,EAAE,aAAa;IAGtC,OAAO,CAAC,cAAc;IAoDtB,OAAO,CAAC,YAAY;IA8DpB,OAAO,CAAC,cAAc;IA6DtB,OAAO,CAAC,qBAAqB;IAoB7B,OAAO,CAAC,4BAA4B;IAsBpC,OAAO,CAAC,yBAAyB;IAoCjC,OAAO,CAAC,0BAA0B;IA0BlC;;;;OAIG;IACH,OAAO,CAAC,wBAAwB;IAuBhC,OAAO,CAAC,YAAY;IAepB,OAAO,CAAC,yBAAyB;IAWjC,OAAO,CAAC,+BAA+B;IAoCvC,OAAO,CAAC,gBAAgB;IAaxB;;OAEG;IACG,UAAU,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CACpD,MAAM,CACJ;QACE,aAAa,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QACnC,WAAW,EAAE,mBAAmB,CAAC;KAClC,EACD,iBAAiB,CAClB,CACF;CAwCF"}
|
|
@@ -291,10 +291,11 @@ export class Disputes {
|
|
|
291
291
|
const punishSetKeys = this.state.disputesRecords.punishSet;
|
|
292
292
|
const currentValidatorKeys = this.state.currentValidatorData.map((v) => v.ed25519);
|
|
293
293
|
const previousValidatorKeys = this.state.previousValidatorData.map((v) => v.ed25519);
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
.
|
|
297
|
-
|
|
294
|
+
const allValidatorKeysSet = HashSet.from(currentValidatorKeys.concat(previousValidatorKeys));
|
|
295
|
+
for (const key of punishSetKeys) {
|
|
296
|
+
allValidatorKeysSet.delete(key);
|
|
297
|
+
}
|
|
298
|
+
return allValidatorKeysSet;
|
|
298
299
|
}
|
|
299
300
|
/**
|
|
300
301
|
* Transition the disputes and return a list of offenders.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { tryAsCoreIndex, tryAsPerValidator, tryAsServiceGas, tryAsServiceId, tryAsTimeSlot } from "#@typeberry/block";
|
|
3
3
|
import { RefineContext } from "#@typeberry/block/refine-context.js";
|
|
4
4
|
import { WorkPackageSpec, WorkReport } from "#@typeberry/block/work-report.js";
|
|
5
|
-
import { WorkExecResult,
|
|
5
|
+
import { WorkExecResult, WorkRefineLoad, WorkResult } from "#@typeberry/block/work-result.js";
|
|
6
6
|
import { Bytes, BytesBlob } from "#@typeberry/bytes";
|
|
7
7
|
import { FixedSizeArray } from "#@typeberry/collections";
|
|
8
8
|
import { tinyChainSpec } from "#@typeberry/config";
|
|
@@ -174,7 +174,7 @@ export function workReport(packageHash, coreIndex) {
|
|
|
174
174
|
codeHash: Bytes.zero(HASH_SIZE).asOpaque(),
|
|
175
175
|
payloadHash: Bytes.zero(HASH_SIZE).asOpaque(),
|
|
176
176
|
gas: tryAsServiceGas(42),
|
|
177
|
-
result:
|
|
177
|
+
result: WorkExecResult.ok(BytesBlob.parseBlob("0x010203")),
|
|
178
178
|
load: WorkRefineLoad.create({
|
|
179
179
|
gasUsed: tryAsServiceGas(0),
|
|
180
180
|
importedSegments: tryAsU32(0),
|
|
@@ -20,7 +20,8 @@ declare enum FetchContext {
|
|
|
20
20
|
/** @deprecated since 0.7.1 */
|
|
21
21
|
LegacyAccumulate = 1,
|
|
22
22
|
/** @deprecated since 0.7.1 */
|
|
23
|
-
LegacyOnTransfer = 2
|
|
23
|
+
LegacyOnTransfer = 2,
|
|
24
|
+
Refine = 3
|
|
24
25
|
}
|
|
25
26
|
type LegacyAccumulateFetchData = {
|
|
26
27
|
context: FetchContext.LegacyAccumulate;
|
|
@@ -38,6 +39,10 @@ type AccumulateFetchData = {
|
|
|
38
39
|
transfers: PendingTransfer[];
|
|
39
40
|
operands: Operand[];
|
|
40
41
|
};
|
|
42
|
+
type RefineFetchData = {
|
|
43
|
+
context: FetchContext.Refine;
|
|
44
|
+
entropy: undefined;
|
|
45
|
+
};
|
|
41
46
|
export declare class FetchExternalities implements general.IFetchExternalities {
|
|
42
47
|
private fetchData;
|
|
43
48
|
private chainSpec;
|
|
@@ -45,6 +50,7 @@ export declare class FetchExternalities implements general.IFetchExternalities {
|
|
|
45
50
|
static createForPre071Accumulate(fetchData: Omit<LegacyAccumulateFetchData, "context">, chainSpec: ChainSpec): FetchExternalities;
|
|
46
51
|
static createForAccumulate(fetchData: Omit<AccumulateFetchData, "context">, chainSpec: ChainSpec): FetchExternalities;
|
|
47
52
|
static createForOnTransfer(fetchData: Omit<LegacyOnTransferFetchData, "context">, chainSpec: ChainSpec): FetchExternalities;
|
|
53
|
+
static createForRefine(fetchData: Omit<RefineFetchData, "context">, chainSpec: ChainSpec): FetchExternalities;
|
|
48
54
|
constants(): BytesBlob;
|
|
49
55
|
entropy(): BytesBlob | null;
|
|
50
56
|
authorizerTrace(): BytesBlob | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-externalities.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/externalities/fetch-externalities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAgC,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAQ5E,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAInD,aAAK,mBAAmB;IACtB,OAAO,IAAI;IACX,QAAQ,IAAI;CACb;AAED,MAAM,MAAM,iBAAiB,GACzB;IACE,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC;IAClC,KAAK,EAAE,OAAO,CAAC;CAChB,GACD;IACE,IAAI,EAAE,mBAAmB,CAAC,QAAQ,CAAC;IACnC,KAAK,EAAE,eAAe,CAAC;CACxB,CAAC;AAgGN,aAAK,YAAY;IACf,UAAU,IAAI;IACd,8BAA8B;IAC9B,gBAAgB,IAAI;IACpB,8BAA8B;IAC9B,gBAAgB,IAAI;
|
|
1
|
+
{"version":3,"file":"fetch-externalities.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/externalities/fetch-externalities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAgC,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAQ5E,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAInD,aAAK,mBAAmB;IACtB,OAAO,IAAI;IACX,QAAQ,IAAI;CACb;AAED,MAAM,MAAM,iBAAiB,GACzB;IACE,IAAI,EAAE,mBAAmB,CAAC,OAAO,CAAC;IAClC,KAAK,EAAE,OAAO,CAAC;CAChB,GACD;IACE,IAAI,EAAE,mBAAmB,CAAC,QAAQ,CAAC;IACnC,KAAK,EAAE,eAAe,CAAC;CACxB,CAAC;AAgGN,aAAK,YAAY;IACf,UAAU,IAAI;IACd,8BAA8B;IAC9B,gBAAgB,IAAI;IACpB,8BAA8B;IAC9B,gBAAgB,IAAI;IACpB,MAAM,IAAI;CACX;AAED,KAAK,yBAAyB,GAAG;IAC/B,OAAO,EAAE,YAAY,CAAC,gBAAgB,CAAC;IACvC,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,OAAO,EAAE,YAAY,CAAC,gBAAgB,CAAC;IACvC,OAAO,EAAE,WAAW,CAAC;IACrB,S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pE,WAAW,IAAI,SAAS,GAAG,IAAI;IAI/B,UAAU,IAAI,SAAS,GAAG,IAAI;IAI9B,kBAAkB,IAAI,SAAS,GAAG,IAAI;IAItC,aAAa,IAAI,SAAS,GAAG,IAAI;IAIjC,YAAY,IAAI,SAAS,GAAG,IAAI;IAIhC,WAAW,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI;IAI7C,eAAe,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI;IAIjD,WAAW,IAAI,SAAS,GAAG,IAAI;IAU/B,UAAU,CAAC,YAAY,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI;IAoB/C,YAAY,IAAI,SAAS,GAAG,IAAI;IAUhC,WAAW,CAAC,aAAa,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI;IAoBjD,uBAAuB,IAAI,SAAS,GAAG,IAAI;IAa3C,oBAAoB,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI;CAuBnD"}
|
|
@@ -106,6 +106,7 @@ var FetchContext;
|
|
|
106
106
|
FetchContext[FetchContext["LegacyAccumulate"] = 1] = "LegacyAccumulate";
|
|
107
107
|
/** @deprecated since 0.7.1 */
|
|
108
108
|
FetchContext[FetchContext["LegacyOnTransfer"] = 2] = "LegacyOnTransfer";
|
|
109
|
+
FetchContext[FetchContext["Refine"] = 3] = "Refine";
|
|
109
110
|
})(FetchContext || (FetchContext = {}));
|
|
110
111
|
export class FetchExternalities {
|
|
111
112
|
fetchData;
|
|
@@ -123,6 +124,9 @@ export class FetchExternalities {
|
|
|
123
124
|
static createForOnTransfer(fetchData, chainSpec) {
|
|
124
125
|
return new FetchExternalities({ context: FetchContext.LegacyOnTransfer, ...fetchData }, chainSpec);
|
|
125
126
|
}
|
|
127
|
+
static createForRefine(fetchData, chainSpec) {
|
|
128
|
+
return new FetchExternalities({ context: FetchContext.Refine, ...fetchData }, chainSpec);
|
|
129
|
+
}
|
|
126
130
|
constants() {
|
|
127
131
|
return getEncodedConstants(this.chainSpec);
|
|
128
132
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert";
|
|
2
2
|
import { describe, it } from "node:test";
|
|
3
3
|
import { tryAsServiceGas, tryAsServiceId } from "#@typeberry/block";
|
|
4
|
-
import { WorkExecResult
|
|
4
|
+
import { WorkExecResult } from "#@typeberry/block/work-result.js";
|
|
5
5
|
import { Bytes, BytesBlob } from "#@typeberry/bytes";
|
|
6
6
|
import { codec, Encoder } from "#@typeberry/codec";
|
|
7
7
|
import { fullChainSpec, tinyChainSpec } from "#@typeberry/config";
|
|
@@ -21,7 +21,7 @@ describe("fetch-externalities", () => {
|
|
|
21
21
|
exportsRoot: Bytes.fill(HASH_SIZE, i + 2).asOpaque(),
|
|
22
22
|
hash: Bytes.fill(HASH_SIZE, i + 4).asOpaque(),
|
|
23
23
|
payloadHash: Bytes.fill(HASH_SIZE, i + 5).asOpaque(),
|
|
24
|
-
result:
|
|
24
|
+
result: WorkExecResult.ok(BytesBlob.empty()),
|
|
25
25
|
gas: tryAsServiceGas(1_000),
|
|
26
26
|
}));
|
|
27
27
|
}
|
|
@@ -4,7 +4,7 @@ import { Credential, ReportGuarantee } from "#@typeberry/block/guarantees.js";
|
|
|
4
4
|
import { RefineContext, WorkPackageInfo } from "#@typeberry/block/refine-context.js";
|
|
5
5
|
import { SignedTicket, tryAsTicketAttempt } from "#@typeberry/block/tickets.js";
|
|
6
6
|
import { WorkPackageSpec, WorkReport } from "#@typeberry/block/work-report.js";
|
|
7
|
-
import { WorkExecResult,
|
|
7
|
+
import { WorkExecResult, WorkRefineLoad, WorkResult } from "#@typeberry/block/work-result.js";
|
|
8
8
|
import { Bytes, BytesBlob } from "#@typeberry/bytes";
|
|
9
9
|
import { Decoder, Encoder } from "#@typeberry/codec";
|
|
10
10
|
import { asKnownSize } from "#@typeberry/collections";
|
|
@@ -77,7 +77,7 @@ describe("TransitionHasher", () => {
|
|
|
77
77
|
importedSegments: tryAsU32(result.refine_load.imports),
|
|
78
78
|
}),
|
|
79
79
|
payloadHash: Bytes.parseBytes(result.payload_hash, HASH_SIZE).asOpaque(),
|
|
80
|
-
result:
|
|
80
|
+
result: WorkExecResult.ok(BytesBlob.parseBlob(result.result.ok)),
|
|
81
81
|
serviceId: tryAsServiceId(result.service_id),
|
|
82
82
|
}))),
|
|
83
83
|
segmentRootLookup: report.segment_root_lookup.map((l) => WorkPackageInfo.create(l)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/reports/test.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,QAAQ,EAOd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,UAAU,EAEV,KAAK,uBAAuB,EAE5B,eAAe,EAChB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAiB,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE/G,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAI7D,OAAO,EAAe,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,KAAK,EAAqB,uBAAuB,EAAW,MAAM,kBAAkB,CAAC;AAC5F,OAAO,EACL,sBAAsB,EAEtB,eAAe,EACf,aAAa,EAIb,aAAa,EACd,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE1D,eAAO,MAAM,OAAO,iHAAyB,CAAC;AAE9C,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,WAAW,CAAC,EAAE,UAAU,CAAC;IACzB,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,gBAAgB,CAAC,EAAE,QAAQ,CAAC;IAC5B,YAAY,CAAC,EAAE,UAAU,CAAC;IAC1B,aAAa,CAAC,EAAE,UAAU,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,UAAU,EACV,WAAW,EACX,SAAS,EACT,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,UAAU,GACX,EAAE,iBAAiB,GAAG,UAAU,
|
|
1
|
+
{"version":3,"file":"test.utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/reports/test.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,SAAS,EACd,KAAK,QAAQ,EAOd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,UAAU,EAEV,KAAK,uBAAuB,EAE5B,eAAe,EAChB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAiB,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAE/G,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAI7D,OAAO,EAAe,cAAc,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAAE,KAAK,SAAS,EAAiB,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEtE,OAAO,KAAK,EA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AAC,UAAU,CAAC,CAAC;IACrC,iBAAiB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAC9C,mBAAmB,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;IAC/C,sBAAsB,CAAC,EAAE,cAAc,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;IAC1E,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC,CAAC;AAEF,iBAAS,eAAe,CAAC,EACvB,kBAA0B,EAC1B,QAAoB,EACpB,iBAAsB,EACtB,mBAAmC,EACnC,sBAA6C,EAC7C,uBAA+B,GAChC,GAAE,kBAAuB,GAAG,YAAY,CAqExC;AAsCD,eAAO,MAAM,iBAAiB,QAAO,sBAAsB,EAG1D,CAAC;AAEF,eAAO,MAAM,iBAAiB,QAAO,aAAa,EA0BxB,CAAC;AAE3B,eAAO,MAAM,eAAe,GAAI;;CAAkC,KAAG,GAAG,CAAC,SAAS,EAAE,eAAe,CA6BlG,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { Credential, GuaranteesExtrinsicBounds, guaranteesExtrinsicCodec, Report
|
|
|
4
4
|
import { RefineContext } from "#@typeberry/block/refine-context.js";
|
|
5
5
|
import { testWorkReportHex } from "#@typeberry/block/test-helpers.js";
|
|
6
6
|
import { WorkReport } from "#@typeberry/block/work-report.js";
|
|
7
|
-
import { WorkExecResult,
|
|
7
|
+
import { WorkExecResult, WorkRefineLoad, WorkResult } from "#@typeberry/block/work-result.js";
|
|
8
8
|
import { Bytes, BytesBlob } from "#@typeberry/bytes";
|
|
9
9
|
import { codec, Decoder } from "#@typeberry/codec";
|
|
10
10
|
import { asKnownSize, FixedSizeArray, HashDictionary } from "#@typeberry/collections";
|
|
@@ -41,7 +41,7 @@ export function newWorkReport({ core, authorizer, anchorBlock, stateRoot, beefyR
|
|
|
41
41
|
codeHash: x.codeHash,
|
|
42
42
|
payloadHash: x.payloadHash,
|
|
43
43
|
gas: x.gas,
|
|
44
|
-
result: resultSize !== undefined ?
|
|
44
|
+
result: resultSize !== undefined ? WorkExecResult.ok(Bytes.fill(resultSize, 0)) : x.result,
|
|
45
45
|
load: WorkRefineLoad.create({
|
|
46
46
|
gasUsed: tryAsServiceGas(5),
|
|
47
47
|
importedSegments: tryAsU32(0),
|