@midnightntwrk/testkit-js 0.0.0-stage → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +409 -2
  2. package/dist/fixtures/hf/README.md +781 -0
  3. package/dist/fixtures/hf/coin-receiver-016/coin-receiver.compact +24 -0
  4. package/dist/fixtures/hf/coin-receiver-016/compiled/compiler/contract-info.json +104 -0
  5. package/dist/fixtures/hf/coin-receiver-016/compiled/contract/index.d.ts +47 -0
  6. package/dist/fixtures/hf/coin-receiver-016/compiled/contract/index.js +412 -0
  7. package/dist/fixtures/hf/coin-receiver-016/receive-coin-transcript.recording.json +668 -0
  8. package/dist/fixtures/hf/coin-receiver-016/state-v6-envelope.hex +1 -0
  9. package/dist/fixtures/hf/coin-receiver-016/state-v9.hex +1 -0
  10. package/dist/fixtures/hf/counter-016/compiled/compiler/contract-info.json +31 -0
  11. package/dist/fixtures/hf/counter-016/compiled/contract/index.d.ts +39 -0
  12. package/dist/fixtures/hf/counter-016/compiled/contract/index.js +189 -0
  13. package/dist/fixtures/hf/counter-016/compiled/keys/increment.prover +0 -0
  14. package/dist/fixtures/hf/counter-016/compiled/keys/increment.verifier +0 -0
  15. package/dist/fixtures/hf/counter-016/compiled/zkir/increment.bzkir +0 -0
  16. package/dist/fixtures/hf/counter-016/compiled/zkir/increment.zkir +22 -0
  17. package/dist/fixtures/hf/counter-016/increment-transcript.golden.json +23 -0
  18. package/dist/fixtures/hf/fixtures.json +69 -0
  19. package/dist/fixtures/hf/pre-fork-private-state-store/.gitattributes +8 -0
  20. package/dist/fixtures/hf/pre-fork-private-state-store/ENVELOPE.md +70 -0
  21. package/dist/fixtures/hf/pre-fork-private-state-store/store/000005.ldb +0 -0
  22. package/dist/fixtures/hf/pre-fork-private-state-store/store/000006.log +0 -0
  23. package/dist/fixtures/hf/pre-fork-private-state-store/store/CURRENT +1 -0
  24. package/dist/fixtures/hf/pre-fork-private-state-store/store/MANIFEST-000004 +0 -0
  25. package/dist/fixtures/hf/private-counter-016/README.md +13 -0
  26. package/dist/fixtures/hf/private-counter-016/compiled/compiler/contract-info.json +40 -0
  27. package/dist/fixtures/hf/private-counter-016/compiled/contract/index.d.ts +40 -0
  28. package/dist/fixtures/hf/private-counter-016/compiled/contract/index.js +211 -0
  29. package/dist/fixtures/hf/private-counter-twin/compiled/compiler/contract-info.json +41 -0
  30. package/dist/fixtures/hf/private-counter-twin/compiled/contract/index.js +271 -0
  31. package/dist/fixtures/hf/private-counter-twin/private-counter.compact +27 -0
  32. package/dist/fixtures/hf/state-both-keys.hex +1 -0
  33. package/dist/fixtures/hf/state-co-v2-only-foreign.hex +1 -0
  34. package/dist/fixtures/hf/state-migrated-v9-merkle.hex +1 -0
  35. package/dist/fixtures/hf/state-migrated-v9.hex +1 -0
  36. package/dist/fixtures/hf/state-tampered-bytes.hex +1 -0
  37. package/dist/fixtures/hf/state-tampered-keyset-v8to9.hex +1 -0
  38. package/dist/fixtures/hf/state-tampered-keyset-v9to8.hex +1 -0
  39. package/dist/fixtures/hf/state-v8-v6-envelope.hex +1 -0
  40. package/dist/fixtures/hf/state-v8.hex +1 -0
  41. package/dist/fixtures/hf/twin-contract/compiled/compiler/contract-info.json +31 -0
  42. package/dist/fixtures/hf/twin-contract/compiled/compiler/contract-manifest.json +58 -0
  43. package/dist/fixtures/hf/twin-contract/compiled/contract/index.d.ts +40 -0
  44. package/dist/fixtures/hf/twin-contract/compiled/contract/index.js +196 -0
  45. package/dist/fixtures/hf/twin-contract/compiled/keys/increment.prover +0 -0
  46. package/dist/fixtures/hf/twin-contract/compiled/keys/increment.verifier +0 -0
  47. package/dist/fixtures/hf/twin-contract/compiled/zkir/increment.bzkir +0 -0
  48. package/dist/fixtures/hf/twin-contract/compiled/zkir/increment.zkir +22 -0
  49. package/dist/fixtures/hf/twin-contract/counter.compact +15 -0
  50. package/dist/fixtures-hf.d.ts +70 -0
  51. package/dist/fixtures-hf.js +161 -0
  52. package/dist/fixtures-hf.js.map +1 -0
  53. package/dist/index.d.ts +1067 -0
  54. package/dist/index.js +3459 -0
  55. package/dist/index.js.map +1 -0
  56. package/package.json +82 -3
@@ -0,0 +1,39 @@
1
+ import type * as __compactRuntime from 'compact-runtime-ledger8';
2
+
3
+ export type Witnesses<PS> = {
4
+ }
5
+
6
+ export type ImpureCircuits<PS> = {
7
+ increment(context: __compactRuntime.CircuitContext<PS>): __compactRuntime.CircuitResults<PS, []>;
8
+ }
9
+
10
+ export type ProvableCircuits<PS> = {
11
+ increment(context: __compactRuntime.CircuitContext<PS>): __compactRuntime.CircuitResults<PS, []>;
12
+ }
13
+
14
+ export type PureCircuits = {
15
+ }
16
+
17
+ export type Circuits<PS> = {
18
+ increment(context: __compactRuntime.CircuitContext<PS>): __compactRuntime.CircuitResults<PS, []>;
19
+ }
20
+
21
+ export type Ledger = {
22
+ readonly round: bigint;
23
+ }
24
+
25
+ export type ContractReferenceLocations = any;
26
+
27
+ export declare const contractReferenceLocations : ContractReferenceLocations;
28
+
29
+ export declare class Contract<PS = any, W extends Witnesses<PS> = Witnesses<PS>> {
30
+ witnesses: W;
31
+ circuits: Circuits<PS>;
32
+ impureCircuits: ImpureCircuits<PS>;
33
+ provableCircuits: ProvableCircuits<PS>;
34
+ constructor(witnesses: W);
35
+ initialState(context: __compactRuntime.ConstructorContext<PS>): __compactRuntime.ConstructorResult<PS>;
36
+ }
37
+
38
+ export declare function ledger(state: __compactRuntime.StateValue | __compactRuntime.ChargedState): Ledger;
39
+ export declare const pureCircuits: PureCircuits;
@@ -0,0 +1,189 @@
1
+ import * as __compactRuntime from '@midnight-ntwrk/compact-runtime';
2
+ __compactRuntime.checkRuntimeVersion('0.16.0');
3
+
4
+ const _descriptor_0 = new __compactRuntime.CompactTypeUnsignedInteger(65535n, 2);
5
+
6
+ const _descriptor_1 = new __compactRuntime.CompactTypeUnsignedInteger(18446744073709551615n, 8);
7
+
8
+ const _descriptor_2 = __compactRuntime.CompactTypeBoolean;
9
+
10
+ const _descriptor_3 = new __compactRuntime.CompactTypeBytes(32);
11
+
12
+ class _Either_0 {
13
+ alignment() {
14
+ return _descriptor_2.alignment().concat(_descriptor_3.alignment().concat(_descriptor_3.alignment()));
15
+ }
16
+ fromValue(value_0) {
17
+ return {
18
+ is_left: _descriptor_2.fromValue(value_0),
19
+ left: _descriptor_3.fromValue(value_0),
20
+ right: _descriptor_3.fromValue(value_0)
21
+ }
22
+ }
23
+ toValue(value_0) {
24
+ return _descriptor_2.toValue(value_0.is_left).concat(_descriptor_3.toValue(value_0.left).concat(_descriptor_3.toValue(value_0.right)));
25
+ }
26
+ }
27
+
28
+ const _descriptor_4 = new _Either_0();
29
+
30
+ const _descriptor_5 = new __compactRuntime.CompactTypeUnsignedInteger(340282366920938463463374607431768211455n, 16);
31
+
32
+ class _ContractAddress_0 {
33
+ alignment() {
34
+ return _descriptor_3.alignment();
35
+ }
36
+ fromValue(value_0) {
37
+ return {
38
+ bytes: _descriptor_3.fromValue(value_0)
39
+ }
40
+ }
41
+ toValue(value_0) {
42
+ return _descriptor_3.toValue(value_0.bytes);
43
+ }
44
+ }
45
+
46
+ const _descriptor_6 = new _ContractAddress_0();
47
+
48
+ const _descriptor_7 = new __compactRuntime.CompactTypeUnsignedInteger(255n, 1);
49
+
50
+ export class Contract {
51
+ witnesses;
52
+ constructor(...args_0) {
53
+ if (args_0.length !== 1) {
54
+ throw new __compactRuntime.CompactError(`Contract constructor: expected 1 argument, received ${args_0.length}`);
55
+ }
56
+ const witnesses_0 = args_0[0];
57
+ if (typeof(witnesses_0) !== 'object') {
58
+ throw new __compactRuntime.CompactError('first (witnesses) argument to Contract constructor is not an object');
59
+ }
60
+ this.witnesses = witnesses_0;
61
+ this.circuits = {
62
+ increment: (...args_1) => {
63
+ if (args_1.length !== 1) {
64
+ throw new __compactRuntime.CompactError(`increment: expected 1 argument (as invoked from Typescript), received ${args_1.length}`);
65
+ }
66
+ const contextOrig_0 = args_1[0];
67
+ if (!(typeof(contextOrig_0) === 'object' && contextOrig_0.currentQueryContext != undefined)) {
68
+ __compactRuntime.typeError('increment',
69
+ 'argument 1 (as invoked from Typescript)',
70
+ 'counter.compact line 13 char 1',
71
+ 'CircuitContext',
72
+ contextOrig_0)
73
+ }
74
+ const context = { ...contextOrig_0, gasCost: __compactRuntime.emptyRunningCost() };
75
+ const partialProofData = {
76
+ input: { value: [], alignment: [] },
77
+ output: undefined,
78
+ publicTranscript: [],
79
+ privateTranscriptOutputs: []
80
+ };
81
+ const result_0 = this._increment_0(context, partialProofData);
82
+ partialProofData.output = { value: [], alignment: [] };
83
+ return { result: result_0, context: context, proofData: partialProofData, gasCost: context.gasCost };
84
+ }
85
+ };
86
+ this.impureCircuits = { increment: this.circuits.increment };
87
+ this.provableCircuits = { increment: this.circuits.increment };
88
+ }
89
+ initialState(...args_0) {
90
+ if (args_0.length !== 1) {
91
+ throw new __compactRuntime.CompactError(`Contract state constructor: expected 1 argument (as invoked from Typescript), received ${args_0.length}`);
92
+ }
93
+ const constructorContext_0 = args_0[0];
94
+ if (typeof(constructorContext_0) !== 'object') {
95
+ throw new __compactRuntime.CompactError(`Contract state constructor: expected 'constructorContext' in argument 1 (as invoked from Typescript) to be an object`);
96
+ }
97
+ if (!('initialZswapLocalState' in constructorContext_0)) {
98
+ throw new __compactRuntime.CompactError(`Contract state constructor: expected 'initialZswapLocalState' in argument 1 (as invoked from Typescript)`);
99
+ }
100
+ if (typeof(constructorContext_0.initialZswapLocalState) !== 'object') {
101
+ throw new __compactRuntime.CompactError(`Contract state constructor: expected 'initialZswapLocalState' in argument 1 (as invoked from Typescript) to be an object`);
102
+ }
103
+ const state_0 = new __compactRuntime.ContractState();
104
+ let stateValue_0 = __compactRuntime.StateValue.newArray();
105
+ stateValue_0 = stateValue_0.arrayPush(__compactRuntime.StateValue.newNull());
106
+ state_0.data = new __compactRuntime.ChargedState(stateValue_0);
107
+ state_0.setOperation('increment', new __compactRuntime.ContractOperation());
108
+ const context = __compactRuntime.createCircuitContext(__compactRuntime.dummyContractAddress(), constructorContext_0.initialZswapLocalState.coinPublicKey, state_0.data, constructorContext_0.initialPrivateState);
109
+ const partialProofData = {
110
+ input: { value: [], alignment: [] },
111
+ output: undefined,
112
+ publicTranscript: [],
113
+ privateTranscriptOutputs: []
114
+ };
115
+ __compactRuntime.queryLedgerState(context,
116
+ partialProofData,
117
+ [
118
+ { push: { storage: false,
119
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_7.toValue(0n),
120
+ alignment: _descriptor_7.alignment() }).encode() } },
121
+ { push: { storage: true,
122
+ value: __compactRuntime.StateValue.newCell({ value: _descriptor_1.toValue(0n),
123
+ alignment: _descriptor_1.alignment() }).encode() } },
124
+ { ins: { cached: false, n: 1 } }]);
125
+ state_0.data = new __compactRuntime.ChargedState(context.currentQueryContext.state.state);
126
+ return {
127
+ currentContractState: state_0,
128
+ currentPrivateState: context.currentPrivateState,
129
+ currentZswapLocalState: context.currentZswapLocalState
130
+ }
131
+ }
132
+ _increment_0(context, partialProofData) {
133
+ const tmp_0 = 1n;
134
+ __compactRuntime.queryLedgerState(context,
135
+ partialProofData,
136
+ [
137
+ { idx: { cached: false,
138
+ pushPath: true,
139
+ path: [
140
+ { tag: 'value',
141
+ value: { value: _descriptor_7.toValue(0n),
142
+ alignment: _descriptor_7.alignment() } }] } },
143
+ { addi: { immediate: parseInt(__compactRuntime.valueToBigInt(
144
+ { value: _descriptor_0.toValue(tmp_0),
145
+ alignment: _descriptor_0.alignment() }
146
+ .value
147
+ )) } },
148
+ { ins: { cached: true, n: 1 } }]);
149
+ return [];
150
+ }
151
+ }
152
+ export function ledger(stateOrChargedState) {
153
+ const state = stateOrChargedState instanceof __compactRuntime.StateValue ? stateOrChargedState : stateOrChargedState.state;
154
+ const chargedState = stateOrChargedState instanceof __compactRuntime.StateValue ? new __compactRuntime.ChargedState(stateOrChargedState) : stateOrChargedState;
155
+ const context = {
156
+ currentQueryContext: new __compactRuntime.QueryContext(chargedState, __compactRuntime.dummyContractAddress()),
157
+ costModel: __compactRuntime.CostModel.initialCostModel()
158
+ };
159
+ const partialProofData = {
160
+ input: { value: [], alignment: [] },
161
+ output: undefined,
162
+ publicTranscript: [],
163
+ privateTranscriptOutputs: []
164
+ };
165
+ return {
166
+ get round() {
167
+ return _descriptor_1.fromValue(__compactRuntime.queryLedgerState(context,
168
+ partialProofData,
169
+ [
170
+ { dup: { n: 0 } },
171
+ { idx: { cached: false,
172
+ pushPath: false,
173
+ path: [
174
+ { tag: 'value',
175
+ value: { value: _descriptor_7.toValue(0n),
176
+ alignment: _descriptor_7.alignment() } }] } },
177
+ { popeq: { cached: true,
178
+ result: undefined } }]).value);
179
+ }
180
+ };
181
+ }
182
+ const _emptyContext = {
183
+ currentQueryContext: new __compactRuntime.QueryContext(new __compactRuntime.ContractState().data, __compactRuntime.dummyContractAddress())
184
+ };
185
+ const _dummyContract = new Contract({ });
186
+ export const pureCircuits = {};
187
+ export const contractReferenceLocations =
188
+ { tag: 'publicLedgerArray', indices: { } };
189
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,22 @@
1
+ {
2
+ "version": { "major": 2, "minor": 0 },
3
+ "do_communications_commitment": true,
4
+ "num_inputs": 0,
5
+ "instructions": [
6
+ { "op": "load_imm", "imm": "01" },
7
+ { "op": "load_imm", "imm": "70" },
8
+ { "op": "load_imm", "imm": "00" },
9
+ { "op": "declare_pub_input", "var": 1 },
10
+ { "op": "declare_pub_input", "var": 0 },
11
+ { "op": "declare_pub_input", "var": 0 },
12
+ { "op": "declare_pub_input", "var": 2 },
13
+ { "op": "pi_skip", "guard": 0, "count": 4 },
14
+ { "op": "load_imm", "imm": "0E" },
15
+ { "op": "declare_pub_input", "var": 3 },
16
+ { "op": "declare_pub_input", "var": 0 },
17
+ { "op": "pi_skip", "guard": 0, "count": 2 },
18
+ { "op": "load_imm", "imm": "A1" },
19
+ { "op": "declare_pub_input", "var": 4 },
20
+ { "op": "pi_skip", "guard": 0, "count": 1 }
21
+ ]
22
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "circuitId": "increment",
3
+ "result": [],
4
+ "input": { "value": [], "alignment": [] },
5
+ "output": { "value": [], "alignment": [] },
6
+ "publicTranscript": [
7
+ {
8
+ "idx": {
9
+ "cached": false,
10
+ "pushPath": true,
11
+ "path": [
12
+ {
13
+ "tag": "value",
14
+ "value": { "value": [""], "alignment": [{ "tag": "atom", "value": { "tag": "bytes", "length": 1 } }] }
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ { "addi": { "immediate": 1 } },
20
+ { "ins": { "cached": true, "n": 1 } }
21
+ ],
22
+ "privateTranscriptOutputs": []
23
+ }
@@ -0,0 +1,69 @@
1
+ {
2
+ "protocolVersionScheme": "node-major * 1_000_000 + node-minor * 1_000; v8-era = 1_000_000 (node 1.x), v9-era = 2_000_000 (node 2.x). Mirrors the protocolVersion integer the node and indexer report.",
3
+ "fixtures": {
4
+ "state-v8.hex": {
5
+ "protocolVersion": 1000000,
6
+ "envelopeTag": "midnight:contract-state[v6]:",
7
+ "status": "valid",
8
+ "kind": "golden-bridged",
9
+ "notes": "Byte-identical to state-v8-v6-envelope.hex: Ledger8ContractState.deserialize(...).serialize() is a no-op round-trip on this input (see generators/mint-state-v8.mjs)."
10
+ },
11
+ "state-v8-v6-envelope.hex": {
12
+ "protocolVersion": 1000000,
13
+ "envelopeTag": "midnight:contract-state[v6]:",
14
+ "status": "valid",
15
+ "kind": "golden",
16
+ "notes": "Ported verbatim from spike-dapp-hf/island-3/driver/tests/builder/fixtures/downcast-v8.hex (identical across islands 1/2/3 and ts-downcast). Raw compact-runtime-0.16 ContractState.serialize() output."
17
+ },
18
+ "state-migrated-v9.hex": {
19
+ "protocolVersion": 2000000,
20
+ "envelopeTag": "midnight:contract-state[v8]:",
21
+ "status": "valid",
22
+ "kind": "golden",
23
+ "notes": "Ported verbatim from spike-dapp-hf/island-3/driver/tests/builder/fixtures/migrated-v9.hex (identical across islands 1/2/3 and ts-downcast). A real ledger-8->9 migrated state, produced by the spike's Rust simulator's `migrate-8-to-9`."
24
+ },
25
+ "state-migrated-v9-merkle.hex": {
26
+ "protocolVersion": 2000000,
27
+ "envelopeTag": "midnight:contract-state[v8]:",
28
+ "status": "synthetic",
29
+ "kind": "synthetic",
30
+ "notes": "NOT a real migration output (ledger-v9 exposes no migrate/from_v8 entry point -- mint path (a) failed, and no small tree-bearing golden exists in the spike -- mint path (b) failed for this one fixture only). Hand-built via ledger-v9's public StateBoundedMerkleTree/StateValue API: one rehashed leaf, so it deserializes cleanly with ledger-v9."
31
+ },
32
+ "state-tampered-keyset-v8to9.hex": {
33
+ "protocolVersion": 2000000,
34
+ "claimedEnvelopeTag": "midnight:contract-state[v8]:",
35
+ "actualPayloadEra": 1000000,
36
+ "status": "tampered",
37
+ "kind": "tampered-tag-swap",
38
+ "notes": "state-v8-v6-envelope.hex with only the single ASCII version digit in the tag flipped '6'->'8' (see generators/mint-tampered-and-derived.mjs::swapVersionDigit). Declares v9-era schema, carries v8-era payload. Verified: both v8.ContractState.deserialize and v9.ContractState.deserialize throw."
39
+ },
40
+ "state-tampered-keyset-v9to8.hex": {
41
+ "protocolVersion": 1000000,
42
+ "claimedEnvelopeTag": "midnight:contract-state[v6]:",
43
+ "actualPayloadEra": 2000000,
44
+ "status": "tampered",
45
+ "kind": "tampered-tag-swap",
46
+ "notes": "state-migrated-v9.hex with only the single ASCII version digit in the tag flipped '8'->'6'. Declares v8-era schema, carries v9-era payload. Verified: both v8.ContractState.deserialize and v9.ContractState.deserialize throw."
47
+ },
48
+ "state-tampered-bytes.hex": {
49
+ "protocolVersion": 2000000,
50
+ "envelopeTag": "midnight:contract-state[v8]:",
51
+ "status": "tampered",
52
+ "kind": "tampered-bit-flip",
53
+ "notes": "state-migrated-v9.hex with one payload byte XORed with 0xff at offset (tag-length + 32), tag left intact. Verified: v9.ContractState.deserialize throws ('out of range for u64')."
54
+ },
55
+ "state-both-keys.hex": {
56
+ "protocolVersion": null,
57
+ "status": "tampered",
58
+ "kind": "tampered-concatenation",
59
+ "notes": "state-v8-v6-envelope.hex bytes followed immediately by state-migrated-v9.hex bytes -- both envelope tags present in one blob, so no single protocolVersion applies by construction. Verified: v8.ContractState.deserialize throws 'Not all bytes read...4692 bytes remaining' (full-buffer-consumption check catches the over-read); v9.ContractState.deserialize throws on the tag mismatch at offset 0."
60
+ },
61
+ "state-co-v2-only-foreign.hex": {
62
+ "protocolVersion": 2000000,
63
+ "envelopeTag": "midnight:contract-state[v8]:",
64
+ "status": "foreign-key",
65
+ "kind": "foreign-key-in-valid-state",
66
+ "notes": "Mis-dispatch negative (reworked from a bare foreign ContractOperation, which failed at the envelope-tag check before ever reaching the intended code path). A full, well-formed ContractState (deserializes cleanly on ledger-v9, protocolVersion 2000000 to match) whose 'increment' operation slot carries the REAL 'post' operation borrowed from state-migrated-v9.hex -- a genuinely foreign, migrated op.v2-vintage verifier key, not built from twin-contract/. Fails only later, at execution (a verifier-key mismatch), never at decode. See README.md 'The mis-dispatch fixture'."
67
+ }
68
+ }
69
+ }
@@ -0,0 +1,8 @@
1
+ # This store's whole value is byte stability: the consuming test derives its
2
+ # decryption key from a salt these bytes carry, and compares a digest over them
3
+ # with the generation recorded in ENVELOPE.md. A checkout that rewrote line
4
+ # endings -- `core.autocrlf=true` is enough -- would produce an unopenable
5
+ # LevelDB and a digest mismatch, reported as an envelope break that never
6
+ # happened. Treat every file here as opaque bytes, LevelDB's text-looking
7
+ # `CURRENT` and `MANIFEST-*` included.
8
+ store/** binary
@@ -0,0 +1,70 @@
1
+ # Persistence-envelope generations
2
+
3
+ `store/` is a LevelDB database written by
4
+ `@midnightntwrk/midnight-js-level-private-state-provider` and then **frozen**.
5
+ The suite that reads it (`test/cross-window.ut.test.ts`) is the only test in
6
+ this repo whose *input* bytes were not produced by the same process that reads
7
+ them. Every other private-state round trip writes and reads with one build, so a
8
+ change to the envelope — superjson's encoding, the AES framing, the PBKDF2
9
+ parameters, the salt record — moves both halves together and stays green.
10
+
11
+ ## Regenerating this store is not a fix
12
+
13
+ If the consuming test fails against these bytes, **the finding is that this
14
+ checkout can no longer read private state that an earlier release wrote.** For a
15
+ dApp user that means their own encrypted state is unreadable after upgrading.
16
+
17
+ Re-minting the store makes the test pass and destroys the only evidence that
18
+ this happened. So do not treat `generators/mint-pre-fork-store.mjs` as the
19
+ remedy. Either fix the provider so the frozen bytes decode again, or — if the
20
+ break is intended — accept it explicitly:
21
+
22
+ 1. Decide, and get agreement, that private state written by earlier releases may
23
+ stop being readable.
24
+ 2. Run `node src/fixtures/hf/generators/mint-pre-fork-store.mjs
25
+ --accept-envelope-break` from `testkit-js/testkit-js/`. The flag is
26
+ deliberate: without it the script refuses and changes nothing, so reaching
27
+ for it out of curiosity — or because a test went red — cannot take the
28
+ fixture with it. The script verifies it can read the state back before the
29
+ bytes are treated as a fixture, deletes LevelDB's runtime files (`LOCK`,
30
+ `LOG`, `LOG.old`), and prints the `- digest:` line for step 4.
31
+ 3. Check `git status --short`. Expect the store's `CURRENT`, `MANIFEST-*`, one
32
+ or more `*.ldb` and the numbered `*.log` — and nothing else. **Keep the
33
+ numbered `NNNNNN.log`.** Despite the extension it is LevelDB's write-ahead
34
+ log and, in a store this small, the only file holding the encrypted state; a
35
+ store without it opens fine and finds nothing. `.gitignore`'s blanket `*.log`
36
+ rule excluded it once already, which is why there is a negation for this
37
+ directory, an ignore for the three runtime files, and a `.gitattributes`
38
+ marking every file here binary. How many files there are, and what LevelDB
39
+ numbered them, varies between runs — do not expect the set an earlier
40
+ generation happened to commit.
41
+ 4. Add a generation section immediately below this list and **above** the
42
+ existing `## Generation N` headings — newest first — recording the digest the
43
+ script printed and what changed. The consuming test reads the FIRST
44
+ `- digest:` line in this file, so a section appended at the bottom leaves it
45
+ comparing against a superseded generation and reporting that no section was
46
+ added at all. A regeneration that skips this step fails — the note cannot
47
+ silently fall behind the fixture.
48
+ 5. Say in that section what a user with an older store has to do.
49
+
50
+ The generator is deliberately not wired into `generate-all.mjs` for the same
51
+ reason: nothing should re-mint these bytes as a side effect of regenerating
52
+ something else.
53
+
54
+ ## Nothing in here is real
55
+
56
+ The state is synthetic and the password is the suite's own fixed test constant,
57
+ committed in plain sight beside it. `secretKey` is the bytes `0x00..0x1f` in
58
+ order, the nullifiers are two made-up strings, and the salt was minted for this
59
+ fixture alone. There is no key material here that means anything outside this
60
+ suite, and the store is safe to publish. Do not read it as a captured artifact
61
+ from any real wallet, and do not copy its password into anything.
62
+
63
+ ## Generation 1 — 2026-09-06
64
+
65
+ - digest: f1287f56122cb46823ccaaa8a91e1754a6dd4e0ca9fd42740702f739be01e0fc
66
+ - provider: `@midnightntwrk/midnight-js-level-private-state-provider` 5.0.0-beta.7
67
+ - envelope: superjson, AES-256-GCM, PBKDF2-SHA256 600k iterations, 32-byte salt
68
+ persisted in the store's own metadata record
69
+ - reason: initial freeze. No break accepted; this is the first generation, so
70
+ there is no older store to strand.
@@ -0,0 +1,13 @@
1
+ # `private-counter-016/`
2
+
3
+ Generated code only. **The source lives one directory over**, at
4
+ [`../private-counter-twin/private-counter.compact`](../private-counter-twin/private-counter.compact),
5
+ because both builds are compiled from that one file: this directory is the
6
+ RETAINED-toolchain build of it (compiler 0.31.1, language 0.23.0, runtime
7
+ 0.16.0), and `../private-counter-twin/compiled/` is the current-toolchain build
8
+ of the same source (compiler 0.36.0, runtime 0.21.0).
9
+
10
+ Do not edit anything here by hand, and never recompile one side alone — the
11
+ consuming test asserts that the two builds still agree, and that both still
12
+ match the source's digest. What the pair is for, what is committed, and how to
13
+ regenerate both sides together is in [`../README.md`](../README.md).
@@ -0,0 +1,40 @@
1
+ {
2
+ "compiler-version": "0.31.1",
3
+ "language-version": "0.23.0",
4
+ "runtime-version": "0.16.0",
5
+ "circuits": [
6
+ {
7
+ "name": "increment",
8
+ "pure": false,
9
+ "proof": true,
10
+ "arguments": [
11
+ ],
12
+ "result-type": {
13
+ "type-name": "Tuple",
14
+ "types": [
15
+ ]
16
+ }
17
+ }
18
+ ],
19
+ "witnesses": [
20
+ {
21
+ "name": "localIncrement",
22
+ "arguments": [
23
+ ],
24
+ "result type": {
25
+ "type-name": "Uint",
26
+ "maxval": 65535
27
+ }
28
+ }
29
+ ],
30
+ "contracts": [
31
+ ],
32
+ "ledger": [
33
+ {
34
+ "name": "round",
35
+ "index": 0,
36
+ "exported": true,
37
+ "storage": "Counter"
38
+ }
39
+ ]
40
+ }
@@ -0,0 +1,40 @@
1
+ import type * as __compactRuntime from 'compact-runtime-ledger8';
2
+
3
+ export type Witnesses<PS> = {
4
+ localIncrement(context: __compactRuntime.WitnessContext<Ledger, PS>): [PS, bigint];
5
+ }
6
+
7
+ export type ImpureCircuits<PS> = {
8
+ increment(context: __compactRuntime.CircuitContext<PS>): __compactRuntime.CircuitResults<PS, []>;
9
+ }
10
+
11
+ export type ProvableCircuits<PS> = {
12
+ increment(context: __compactRuntime.CircuitContext<PS>): __compactRuntime.CircuitResults<PS, []>;
13
+ }
14
+
15
+ export type PureCircuits = {
16
+ }
17
+
18
+ export type Circuits<PS> = {
19
+ increment(context: __compactRuntime.CircuitContext<PS>): __compactRuntime.CircuitResults<PS, []>;
20
+ }
21
+
22
+ export type Ledger = {
23
+ readonly round: bigint;
24
+ }
25
+
26
+ export type ContractReferenceLocations = any;
27
+
28
+ export declare const contractReferenceLocations : ContractReferenceLocations;
29
+
30
+ export declare class Contract<PS = any, W extends Witnesses<PS> = Witnesses<PS>> {
31
+ witnesses: W;
32
+ circuits: Circuits<PS>;
33
+ impureCircuits: ImpureCircuits<PS>;
34
+ provableCircuits: ProvableCircuits<PS>;
35
+ constructor(witnesses: W);
36
+ initialState(context: __compactRuntime.ConstructorContext<PS>): __compactRuntime.ConstructorResult<PS>;
37
+ }
38
+
39
+ export declare function ledger(state: __compactRuntime.StateValue | __compactRuntime.ChargedState): Ledger;
40
+ export declare const pureCircuits: PureCircuits;