@midnight-ntwrk/midnight-js-protocol 5.0.0-beta.7 → 5.0.0-beta.8
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/README.md +201 -2
- package/dist/engine.d.ts +367 -0
- package/dist/engine.js +519 -0
- package/dist/engine.js.map +1 -0
- package/dist/errors.d.ts +467 -0
- package/dist/errors.js +595 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +1278 -2
- package/dist/index.js +787 -2
- package/dist/index.js.map +1 -1
- package/dist/prove.d.ts +38 -0
- package/dist/prove.js +81 -0
- package/dist/prove.js.map +1 -0
- package/dist/shared/deploy-D6yyn9P7.js +428 -0
- package/dist/shared/deploy-D6yyn9P7.js.map +1 -0
- package/dist/shared/load-C0TZnEd2.js +39 -0
- package/dist/shared/load-C0TZnEd2.js.map +1 -0
- package/dist/v8.d.ts +1 -0
- package/dist/v8.js +3 -0
- package/dist/v8.js.map +1 -0
- package/dist/version.d.ts +121 -0
- package/dist/version.js +132 -0
- package/dist/version.js.map +1 -0
- package/package.json +28 -4
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/lib/shared/contract-state.ts","../src/lib/shared/unshielded.ts","../src/lib/v8/compose.ts","../src/lib/v8/adapt.ts","../src/lib/v9/compose.ts","../src/lib/era/envelope.ts","../src/lib/era/load-era.ts","../src/lib/v8/load-engine.ts"],"sourcesContent":[null,null,null,null,null,null,null,null],"names":["readContractState","readZswapOffer","LedgerContractStateV9"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;AAaG;AAwEH;;;;;;;;;;;;AAYG;AACI,MAAM,gBAAgB,GAAG,CAC9B,GAAe,EACf,OAAsB,EACtB,OAA+C,KAC1B;AACrB,IAAA,IAAI;AACF,QAAA,OA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ntwrk/ledger-v9';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Proves a retained-era transaction, taking serialized bytes and returning
|
|
5
|
+
* serialized bytes.
|
|
6
|
+
*
|
|
7
|
+
* Bytes on both sides is the seam's contract, not an implementation detail: a
|
|
8
|
+
* retained-era transaction cannot cross a provider boundary as a live object,
|
|
9
|
+
* because the runtime that owns it is loaded lazily and its instances are not
|
|
10
|
+
* interchangeable with the current era's.
|
|
11
|
+
*
|
|
12
|
+
* The cost model comes from the same `loadLedger8` result as the transaction
|
|
13
|
+
* class, and that pairing is load-bearing: the retained ledger ships its own
|
|
14
|
+
* `CostModel` and its `prove()` checks the argument against that class across
|
|
15
|
+
* the WASM boundary, so the current era's cost model is rejected with
|
|
16
|
+
* `expected instance of CostModel`.
|
|
17
|
+
*
|
|
18
|
+
* @param txBytes The serialized, unproven retained-era transaction.
|
|
19
|
+
* @param provingProvider The circuit-level proving provider to drive. The
|
|
20
|
+
* current era's `ProvingProvider` shape satisfies the retained runtime's
|
|
21
|
+
* structurally — it declares the same `check` and `prove` and one member
|
|
22
|
+
* more — so the two need no adapter between them.
|
|
23
|
+
* @returns The serialized, proven transaction.
|
|
24
|
+
* @throws PayloadNotATransactionError If `txBytes` is not a serialized
|
|
25
|
+
* transaction.
|
|
26
|
+
* @throws Ledger8RuntimeMissingError If the retained runtime cannot be loaded.
|
|
27
|
+
*
|
|
28
|
+
* @remarks Intended for `ProofProvider` implementations. Application code
|
|
29
|
+
* should call `proveTx` on a provider rather than this directly: the provider
|
|
30
|
+
* is what pairs it with a configured proving provider and answers in the
|
|
31
|
+
* version-tagged shape the rest of the flow expects.
|
|
32
|
+
*
|
|
33
|
+
* @see docs/adr/0006-version-tagged-payloads-at-provider-seams.md
|
|
34
|
+
* @see docs/adr/0010-publish-era-handles-alongside-their-plain-data.md
|
|
35
|
+
*/
|
|
36
|
+
declare const proveV8Transaction: (txBytes: Uint8Array, provingProvider: ProvingProvider) => Promise<Uint8Array>;
|
|
37
|
+
|
|
38
|
+
export { proveV8Transaction };
|
package/dist/prove.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { TRANSACTION_TAG_PREFIX, PayloadNotATransactionError } from './errors.js';
|
|
2
|
+
import { l as loadLedger8 } from './shared/load-C0TZnEd2.js';
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* This file is part of midnight-js.
|
|
6
|
+
* Copyright (C) Midnight Foundation
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* You may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
const TRANSACTION_TAG_PREFIX_BYTES = Uint8Array.from(TRANSACTION_TAG_PREFIX, (character) => character.charCodeAt(0));
|
|
19
|
+
// Establishes that the bytes are a serialized TRANSACTION, and deliberately not
|
|
20
|
+
// which era wrote them: both eras' tags open identically. The era is carried by
|
|
21
|
+
// the `version` discriminant of the payload the seam received, and the runtime
|
|
22
|
+
// re-validates the full tag when it deserializes.
|
|
23
|
+
//
|
|
24
|
+
// Compared byte-wise rather than by decoding a prefix to text: the input is
|
|
25
|
+
// attacker-controlled at this seam.
|
|
26
|
+
const assertSerializedTransaction = (txBytes) => {
|
|
27
|
+
// Checked despite the declared type: this is the seam an untyped caller
|
|
28
|
+
// reaches, and reading `.byteLength` off whatever actually arrived would
|
|
29
|
+
// raise a bare `TypeError` carrying no code.
|
|
30
|
+
if (!(txBytes instanceof Uint8Array)) {
|
|
31
|
+
throw PayloadNotATransactionError.notBytes(txBytes);
|
|
32
|
+
}
|
|
33
|
+
const matchesPrefix = txBytes.byteLength >= TRANSACTION_TAG_PREFIX_BYTES.length &&
|
|
34
|
+
TRANSACTION_TAG_PREFIX_BYTES.every((byte, index) => txBytes[index] === byte);
|
|
35
|
+
if (!matchesPrefix) {
|
|
36
|
+
throw PayloadNotATransactionError.wrongTag(txBytes.byteLength);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Proves a retained-era transaction, taking serialized bytes and returning
|
|
41
|
+
* serialized bytes.
|
|
42
|
+
*
|
|
43
|
+
* Bytes on both sides is the seam's contract, not an implementation detail: a
|
|
44
|
+
* retained-era transaction cannot cross a provider boundary as a live object,
|
|
45
|
+
* because the runtime that owns it is loaded lazily and its instances are not
|
|
46
|
+
* interchangeable with the current era's.
|
|
47
|
+
*
|
|
48
|
+
* The cost model comes from the same `loadLedger8` result as the transaction
|
|
49
|
+
* class, and that pairing is load-bearing: the retained ledger ships its own
|
|
50
|
+
* `CostModel` and its `prove()` checks the argument against that class across
|
|
51
|
+
* the WASM boundary, so the current era's cost model is rejected with
|
|
52
|
+
* `expected instance of CostModel`.
|
|
53
|
+
*
|
|
54
|
+
* @param txBytes The serialized, unproven retained-era transaction.
|
|
55
|
+
* @param provingProvider The circuit-level proving provider to drive. The
|
|
56
|
+
* current era's `ProvingProvider` shape satisfies the retained runtime's
|
|
57
|
+
* structurally — it declares the same `check` and `prove` and one member
|
|
58
|
+
* more — so the two need no adapter between them.
|
|
59
|
+
* @returns The serialized, proven transaction.
|
|
60
|
+
* @throws PayloadNotATransactionError If `txBytes` is not a serialized
|
|
61
|
+
* transaction.
|
|
62
|
+
* @throws Ledger8RuntimeMissingError If the retained runtime cannot be loaded.
|
|
63
|
+
*
|
|
64
|
+
* @remarks Intended for `ProofProvider` implementations. Application code
|
|
65
|
+
* should call `proveTx` on a provider rather than this directly: the provider
|
|
66
|
+
* is what pairs it with a configured proving provider and answers in the
|
|
67
|
+
* version-tagged shape the rest of the flow expects.
|
|
68
|
+
*
|
|
69
|
+
* @see docs/adr/0006-version-tagged-payloads-at-provider-seams.md
|
|
70
|
+
* @see docs/adr/0010-publish-era-handles-alongside-their-plain-data.md
|
|
71
|
+
*/
|
|
72
|
+
const proveV8Transaction = async (txBytes, provingProvider) => {
|
|
73
|
+
assertSerializedTransaction(txBytes);
|
|
74
|
+
const v8 = await loadLedger8();
|
|
75
|
+
const unproven = v8.Transaction.deserialize('signature', 'pre-proof', 'pre-binding', txBytes);
|
|
76
|
+
const proven = await unproven.prove(provingProvider, v8.CostModel.initialCostModel());
|
|
77
|
+
return proven.serialize();
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export { proveV8Transaction };
|
|
81
|
+
//# sourceMappingURL=prove.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prove.js","sources":["../src/lib/v8/prove.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;AAaG;AAOH,MAAM,4BAA4B,GAAG,UAAU,CAAC,IAAI,CAAC,sBAAsB,EAAE,CAAC,SAAS,KACrF,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CACxB;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,2BAA2B,GAAG,CAAC,OAAmB,KAAU;;;;AAIhE,IAAA,IAAI,EAAE,OAAO,YAAY,UAAU,CAAC,EAAE;AACpC,QAAA,MAAM,2BAA2B,CAAC,QAAQ,CAAC,OAAO,CAAC;IACrD;IACA,MAAM,aAAa,GACjB,OAAO,CAAC,UAAU,IAAI,4BAA4B,CAAC,MAAM;AACzD,QAAA,4BAA4B,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC9E,IAAI,CAAC,aAAa,EAAE;QAClB,MAAM,2BAA2B,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;IAChE;AACF,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCG;AACI,MAAM,kBAAkB,GAAG,OAChC,OAAmB,EACnB,eAAgC,KACT;IACvB,2BAA2B,CAAC,OAAO,CAAC;AACpC,IAAA,MAAM,EAAE,GAAG,MAAM,WAAW,EAAE;AAC9B,IAAA,MAAM,QAAQ,GAAG,EAAE,CAAC,WAAW,CAAC,WAAW,CAAC,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,CAAC;AAC7F,IAAA,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,CAAC,SAAS,CAAC,gBAAgB,EAAE,CAAC;AACrF,IAAA,OAAO,MAAM,CAAC,SAAS,EAAE;AAC3B;;;;"}
|
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import { encodeContractKeyLocation, hashVerifierKey } from '@midnight-ntwrk/compact-js';
|
|
2
|
+
import { ComposeFailedError, ComposeOptionError } from '../errors.js';
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* This file is part of midnight-js.
|
|
6
|
+
* Copyright (C) Midnight Foundation
|
|
7
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* You may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* The sentinel that asks for the ledger's own INITIAL cost model instead of the chain's.
|
|
20
|
+
*
|
|
21
|
+
* Spelled out as a value a caller has to name, because the thing it selects is wrong for any chain
|
|
22
|
+
* that has been running: the initial parameters are the model the chain started with, and prices
|
|
23
|
+
* adjust per block. Partitioning against them draws the guaranteed/fallible boundary in the wrong
|
|
24
|
+
* place and the node then refuses the guaranteed segment with `Transcript(Execution(OutOfGas))` --
|
|
25
|
+
* after the caller has already paid to prove it.
|
|
26
|
+
*/
|
|
27
|
+
const INITIAL_LEDGER_PARAMETERS = 'initial';
|
|
28
|
+
|
|
29
|
+
/*
|
|
30
|
+
* This file is part of midnight-js.
|
|
31
|
+
* Copyright (C) Midnight Foundation
|
|
32
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
33
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
34
|
+
* You may not use this file except in compliance with the License.
|
|
35
|
+
* You may obtain a copy of the License at
|
|
36
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
37
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
38
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
39
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
40
|
+
* See the License for the specific language governing permissions and
|
|
41
|
+
* limitations under the License.
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* Writes the context a call recorded onto the query context its transcript is
|
|
45
|
+
* about to be partitioned against. Returns the folded context, never the one
|
|
46
|
+
* it started from.
|
|
47
|
+
*
|
|
48
|
+
* @see {@link ComposeRefusalOrder}
|
|
49
|
+
*/
|
|
50
|
+
const bridgePartitionContext = (queryContext, partitionContext) => {
|
|
51
|
+
queryContext.block = partitionContext.block;
|
|
52
|
+
queryContext.effects = partitionContext.effects;
|
|
53
|
+
let bridged = queryContext;
|
|
54
|
+
for (const [commitment, index] of partitionContext.comIndices) {
|
|
55
|
+
bridged = bridged.insertCommitment(commitment, index);
|
|
56
|
+
}
|
|
57
|
+
return bridged;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Resolves a call's guaranteed/fallible transcript pair: a partitioned source
|
|
61
|
+
* is passed through untouched, an unpartitioned one is bridged into the
|
|
62
|
+
* module's own `QueryContext` ({@link bridgePartitionContext}) and split there.
|
|
63
|
+
*
|
|
64
|
+
* @see {@link ComposeRefusalOrder}
|
|
65
|
+
*/
|
|
66
|
+
const resolvePartition = (ledger, options) => {
|
|
67
|
+
const { transcript, contractAddress, circuitId, version } = options;
|
|
68
|
+
if (transcript.kind === 'partitioned') {
|
|
69
|
+
// Only the CALLER-supplied pair is checked for emptiness, never the
|
|
70
|
+
// partitioner's own answer below -- see ComposeRefusalOrder.
|
|
71
|
+
if (transcript.guaranteed === undefined && transcript.fallible === undefined) {
|
|
72
|
+
throw new ComposeFailedError(version, 'call-transcript-empty', circuitId);
|
|
73
|
+
}
|
|
74
|
+
return [transcript.guaranteed, transcript.fallible];
|
|
75
|
+
}
|
|
76
|
+
let queryContext;
|
|
77
|
+
try {
|
|
78
|
+
const stateValue = ledger.StateValue.decode(transcript.preState);
|
|
79
|
+
queryContext = new ledger.QueryContext(new ledger.ChargedState(stateValue), contractAddress);
|
|
80
|
+
}
|
|
81
|
+
catch (cause) {
|
|
82
|
+
throw new ComposeFailedError(version, 'call-contract-state', circuitId, cause);
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
queryContext = bridgePartitionContext(queryContext, transcript.partitionContext);
|
|
86
|
+
}
|
|
87
|
+
catch (cause) {
|
|
88
|
+
throw new ComposeFailedError(version, 'call-partition-context', circuitId, cause);
|
|
89
|
+
}
|
|
90
|
+
// The partitioner rejects caller data with a raw error from inside wasm, so
|
|
91
|
+
// it is coded here -- see ComposeRefusalOrder.
|
|
92
|
+
let partitioned;
|
|
93
|
+
// Read BEFORE the partitioner runs and reported separately, because a rejected parameter blob is
|
|
94
|
+
// a bad option and not a failed partition -- reporting it as the latter sends a reader after the
|
|
95
|
+
// transcript when the fault is in the bytes they passed. See ComposeRefusalOrder.
|
|
96
|
+
let parameters;
|
|
97
|
+
try {
|
|
98
|
+
parameters =
|
|
99
|
+
options.ledgerParameters === INITIAL_LEDGER_PARAMETERS
|
|
100
|
+
? // The ledger's INITIAL parameters: a compatibility path for a caller with no read
|
|
101
|
+
// surface, and not a correct substitute. They are the model the chain started with, not
|
|
102
|
+
// the one it is running -- prices adjust per block -- so partitioning against them draws
|
|
103
|
+
// the guaranteed/fallible boundary in the wrong place and the node refuses the guaranteed
|
|
104
|
+
// segment for running out of gas. Reachable only by naming the sentinel, never by
|
|
105
|
+
// omission -- see LedgerParametersOption.
|
|
106
|
+
ledger.LedgerParameters.initialParameters()
|
|
107
|
+
: // Deserialized with THIS era's reader, which is right because the bytes came from a block
|
|
108
|
+
// this era's call is being built against.
|
|
109
|
+
ledger.LedgerParameters.deserialize(options.ledgerParameters);
|
|
110
|
+
}
|
|
111
|
+
catch (cause) {
|
|
112
|
+
throw new ComposeOptionError(version, 'ledgerParameters', cause);
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
partitioned = ledger.partitionTranscripts([new ledger.PreTranscript(queryContext, transcript.publicTranscript)], parameters);
|
|
116
|
+
}
|
|
117
|
+
catch (cause) {
|
|
118
|
+
throw new ComposeFailedError(version, 'call-partition', circuitId, cause);
|
|
119
|
+
}
|
|
120
|
+
const first = partitioned[0];
|
|
121
|
+
if (first === undefined) {
|
|
122
|
+
throw new Error('partitionTranscripts returned no result for the call transcript.');
|
|
123
|
+
}
|
|
124
|
+
return first;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Assembles one call prototype against the given ledger module — the sequence
|
|
128
|
+
* every composition leg shares: resolve the circuit's registered operation,
|
|
129
|
+
* resolve the call's guaranteed/fallible transcript pair (see
|
|
130
|
+
* {@link resolvePartition}), and construct the module's
|
|
131
|
+
* `ContractCallPrototype`.
|
|
132
|
+
*
|
|
133
|
+
* @typeParam TQueryContext The module's own `QueryContext`. Every other type
|
|
134
|
+
* parameter is inferred from the module namespace, so callers pass the module
|
|
135
|
+
* and never spell out type arguments.
|
|
136
|
+
* @typeParam TOperation The resolved operation, constrained to
|
|
137
|
+
* {@link VerifiableOperation}.
|
|
138
|
+
* @param ledger The ledger module (ledger-v8 or ledger-v9) to assemble
|
|
139
|
+
* against.
|
|
140
|
+
* @param options The call's own inputs, the operation registry to resolve
|
|
141
|
+
* `circuitId` against, and the era to name in a failure.
|
|
142
|
+
* @returns The module's own `ContractCallPrototype` for this call.
|
|
143
|
+
* @throws ComposeFailedError naming `version` and `circuitId`, at
|
|
144
|
+
* `options.stage` when `operations` has no registered operation for
|
|
145
|
+
* `circuitId`; at `'call-verifier-key'` when the resolved operation carries no
|
|
146
|
+
* verifier key; at `'call-transcript-empty'`, `'call-contract-state'`,
|
|
147
|
+
* `'call-partition-context'` or `'call-partition'` from resolving the
|
|
148
|
+
* transcript pair; at `'call-prototype'` when the module rejects the call's
|
|
149
|
+
* own inputs.
|
|
150
|
+
* @throws Error, deliberately carrying no protocol error code, when the
|
|
151
|
+
* module's own partitioner returns no result — its invariant, not a caller
|
|
152
|
+
* fault.
|
|
153
|
+
* @see {@link ComposeRefusalOrder}
|
|
154
|
+
*/
|
|
155
|
+
const assembleCallPrototype = (ledger, options) => {
|
|
156
|
+
const { circuitId, contractAddress, operations, stage, version } = options;
|
|
157
|
+
const op = operations.operation(circuitId);
|
|
158
|
+
if (op === undefined) {
|
|
159
|
+
throw new ComposeFailedError(version, stage, circuitId);
|
|
160
|
+
}
|
|
161
|
+
if (op.verifierKey === undefined) {
|
|
162
|
+
throw new ComposeFailedError(version, 'call-verifier-key', circuitId);
|
|
163
|
+
}
|
|
164
|
+
const [guaranteed, fallible] = resolvePartition(ledger, options);
|
|
165
|
+
// Wrapped as one step rather than per argument -- see ComposeRefusalOrder.
|
|
166
|
+
try {
|
|
167
|
+
return new ledger.ContractCallPrototype(contractAddress, circuitId, op, guaranteed, fallible, options.privateTranscriptOutputs, options.input, options.output, options.communicationCommitmentRandomness ?? ledger.communicationCommitmentRandomness(),
|
|
168
|
+
// The canonical, contract-qualified key location this framework's
|
|
169
|
+
// provers resolve artifacts by -- see ComposeRefusalOrder.
|
|
170
|
+
encodeContractKeyLocation({
|
|
171
|
+
contractAddress,
|
|
172
|
+
circuitId,
|
|
173
|
+
verifierKeyHash: hashVerifierKey(op.verifierKey)
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
176
|
+
catch (cause) {
|
|
177
|
+
throw new ComposeFailedError(version, 'call-prototype', circuitId, cause);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Resolves a call's guaranteed/fallible transcript pair against a ledger
|
|
182
|
+
* module, without assembling the call.
|
|
183
|
+
*
|
|
184
|
+
* PROTOTYPE SEAM. It exists because the retained-era pipeline has to know the
|
|
185
|
+
* partition BEFORE it builds the call's Zswap offer, and until now the only way
|
|
186
|
+
* to obtain one was to compose the whole transaction -- by which point the
|
|
187
|
+
* offer has already been handed over as an option. Routing a coin against a
|
|
188
|
+
* partition that does not exist yet places every movement in the guaranteed
|
|
189
|
+
* segment, which the wallet then cannot balance.
|
|
190
|
+
*
|
|
191
|
+
* Same inputs, same failures and same order as the partition step inside
|
|
192
|
+
* {@link assembleCallPrototype}; that function now delegates here rather than
|
|
193
|
+
* keeping a second copy.
|
|
194
|
+
*
|
|
195
|
+
* @param ledger The ledger module (ledger-v8 or ledger-v9) to partition against.
|
|
196
|
+
* @param options The call's transcript source, address, circuit and the
|
|
197
|
+
* chain's own serialized ledger parameters.
|
|
198
|
+
* @returns The `[guaranteed, fallible]` pair, either member possibly absent.
|
|
199
|
+
* @throws ComposeFailedError at `'call-transcript-empty'`,
|
|
200
|
+
* `'call-contract-state'`, `'call-partition-context'` or `'call-partition'`.
|
|
201
|
+
* @throws ComposeOptionError at `'ledgerParameters'` for a parameter blob this
|
|
202
|
+
* era cannot read.
|
|
203
|
+
* @see {@link ComposeRefusalOrder}
|
|
204
|
+
*/
|
|
205
|
+
const partitionCallTranscript = (ledger, options) => resolvePartition(ledger, options);
|
|
206
|
+
|
|
207
|
+
/*
|
|
208
|
+
* This file is part of midnight-js.
|
|
209
|
+
* Copyright (C) Midnight Foundation
|
|
210
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
211
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
212
|
+
* You may not use this file except in compliance with the License.
|
|
213
|
+
* You may obtain a copy of the License at
|
|
214
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
215
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
216
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
217
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
218
|
+
* See the License for the specific language governing permissions and
|
|
219
|
+
* limitations under the License.
|
|
220
|
+
*/
|
|
221
|
+
/**
|
|
222
|
+
* Resolves a ledger entry-point key to its name.
|
|
223
|
+
*
|
|
224
|
+
* @param id The entry point as the state declares it — already a string, or
|
|
225
|
+
* the bytes a byte-declared entry point carries.
|
|
226
|
+
* @returns `id` itself when it is a string, otherwise its UTF-8 decoding.
|
|
227
|
+
* @see {@link VerifierKeys}
|
|
228
|
+
*/
|
|
229
|
+
const entryPointName = (id) => typeof id === 'string' ? id : new TextDecoder().decode(id);
|
|
230
|
+
/**
|
|
231
|
+
* Pairs each supplied verifier key with the entry point the state declares for
|
|
232
|
+
* it, after validating the map against those entry points in BOTH directions:
|
|
233
|
+
* every key must name a declared entry point, and every declared entry point
|
|
234
|
+
* must have a key.
|
|
235
|
+
*
|
|
236
|
+
* @param entryPoints The entry points the state declares, as `operations()`
|
|
237
|
+
* returns them.
|
|
238
|
+
* @param verifierKeys Entry-point name -> raw, tagged verifier key bytes.
|
|
239
|
+
* @param version The era every failure raised here names.
|
|
240
|
+
* @returns One registration per supplied key, in the map's own order, each
|
|
241
|
+
* carrying the DECLARED entry point rather than its resolved name — which is
|
|
242
|
+
* what `setOperation` must be handed.
|
|
243
|
+
* @throws ComposeFailedError at stage `'deploy-ambiguous-circuit'` when two
|
|
244
|
+
* declared entry points resolve to the same name. Checked before either
|
|
245
|
+
* direction below.
|
|
246
|
+
* @throws ComposeFailedError at stage `'deploy-unknown-circuit'` when a key
|
|
247
|
+
* names an entry point the state does not declare.
|
|
248
|
+
* @throws ComposeFailedError at stage `'deploy-verifier-key'` when a declared
|
|
249
|
+
* entry point has no key in the map.
|
|
250
|
+
* @see {@link VerifierKeys}
|
|
251
|
+
*/
|
|
252
|
+
const resolveVerifierKeyRegistrations = (entryPoints, verifierKeys, version) => {
|
|
253
|
+
const declared = new Map();
|
|
254
|
+
for (const entryPoint of entryPoints) {
|
|
255
|
+
const circuitId = entryPointName(entryPoint);
|
|
256
|
+
if (declared.has(circuitId)) {
|
|
257
|
+
throw new ComposeFailedError(version, 'deploy-ambiguous-circuit', circuitId);
|
|
258
|
+
}
|
|
259
|
+
declared.set(circuitId, entryPoint);
|
|
260
|
+
}
|
|
261
|
+
const registrations = [];
|
|
262
|
+
for (const [circuitId, verifierKey] of verifierKeys) {
|
|
263
|
+
const entryPoint = declared.get(circuitId);
|
|
264
|
+
if (entryPoint === undefined) {
|
|
265
|
+
throw new ComposeFailedError(version, 'deploy-unknown-circuit', circuitId);
|
|
266
|
+
}
|
|
267
|
+
registrations.push({ entryPoint, circuitId, verifierKey });
|
|
268
|
+
}
|
|
269
|
+
for (const circuitId of declared.keys()) {
|
|
270
|
+
if (!verifierKeys.has(circuitId)) {
|
|
271
|
+
throw new ComposeFailedError(version, 'deploy-verifier-key', circuitId);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return registrations;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
/*
|
|
278
|
+
* This file is part of midnight-js.
|
|
279
|
+
* Copyright (C) Midnight Foundation
|
|
280
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
281
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
282
|
+
* You may not use this file except in compliance with the License.
|
|
283
|
+
* You may obtain a copy of the License at
|
|
284
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
285
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
286
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
287
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
288
|
+
* See the License for the specific language governing permissions and
|
|
289
|
+
* limitations under the License.
|
|
290
|
+
*/
|
|
291
|
+
/**
|
|
292
|
+
* Rejects the two envelope options the ledger accepts but should not: an
|
|
293
|
+
* empty `networkId`, and a `ttl` that is not a valid instant.
|
|
294
|
+
*
|
|
295
|
+
* @param options The transaction-envelope options to check.
|
|
296
|
+
* @param version The era every failure raised here names.
|
|
297
|
+
* @throws ComposeOptionError naming option `'networkId'` for an empty network
|
|
298
|
+
* id, or `'ttl'` for a `ttl` that is not a valid instant.
|
|
299
|
+
* @see {@link ComposeRefusalOrder}
|
|
300
|
+
*/
|
|
301
|
+
const assertComposeEnvelope = (options, version) => {
|
|
302
|
+
if (options.networkId.length === 0) {
|
|
303
|
+
throw new ComposeOptionError(version, 'networkId');
|
|
304
|
+
}
|
|
305
|
+
if (Number.isNaN(options.ttl.getTime())) {
|
|
306
|
+
throw new ComposeOptionError(version, 'ttl');
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
/*
|
|
311
|
+
* This file is part of midnight-js.
|
|
312
|
+
* Copyright (C) Midnight Foundation
|
|
313
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
314
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
315
|
+
* You may not use this file except in compliance with the License.
|
|
316
|
+
* You may obtain a copy of the License at
|
|
317
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
318
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
319
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
320
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
321
|
+
* See the License for the specific language governing permissions and
|
|
322
|
+
* limitations under the License.
|
|
323
|
+
*/
|
|
324
|
+
/**
|
|
325
|
+
* Runs a pre-fork (`compact-runtime@0.16`) contract's constructor
|
|
326
|
+
* (`initialState`) and packages the result into a
|
|
327
|
+
* {@link ConstructorResultPojo}.
|
|
328
|
+
*
|
|
329
|
+
* @param options The compiled contract module, constructor arguments, private
|
|
330
|
+
* state and coin public key.
|
|
331
|
+
* @param runtime The injected pre-fork glue slice used to build the
|
|
332
|
+
* constructor context.
|
|
333
|
+
* @returns The freshly built contract state and the resulting private state.
|
|
334
|
+
* The state is a pre-fork HANDLE, so it does not go straight into a deploy:
|
|
335
|
+
* both {@link composeV8DeployTx} and the era facade's `composeDeployTx` take
|
|
336
|
+
* it as BYTES, which is what `.serialize()` on that handle produces.
|
|
337
|
+
* @see {@link RetainedEraExecution}
|
|
338
|
+
*/
|
|
339
|
+
const executeConstructor = (options, runtime) => {
|
|
340
|
+
const { contract, args, privateState, coinPk } = options;
|
|
341
|
+
const constructorContext = runtime.createConstructorContext(privateState, coinPk);
|
|
342
|
+
const result = contract.initialState(constructorContext, ...args);
|
|
343
|
+
return {
|
|
344
|
+
contractState: result.currentContractState,
|
|
345
|
+
privateState: result.currentPrivateState,
|
|
346
|
+
zswapLocalState: runtime.decodeZswapLocalState(result.currentZswapLocalState)
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
/**
|
|
350
|
+
* Bridges a pre-fork contract state into the v8 era by bytes, reporting a
|
|
351
|
+
* rejected envelope as {@link ComposeOptionError} rather than letting a raw
|
|
352
|
+
* decoder failure escape.
|
|
353
|
+
*/
|
|
354
|
+
const bridgeContractState = (contractState, v8) => {
|
|
355
|
+
try {
|
|
356
|
+
return v8.ContractState.deserialize(contractState);
|
|
357
|
+
}
|
|
358
|
+
catch (error) {
|
|
359
|
+
throw new ComposeOptionError('v8', 'contractState', error);
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
/**
|
|
363
|
+
* Registers one verifier key, reporting bytes the ledger rejects as
|
|
364
|
+
* {@link ComposeFailedError} (stage `'deploy-verifier-key-blob'`) so the
|
|
365
|
+
* failure names the entry point it belongs to.
|
|
366
|
+
*/
|
|
367
|
+
const registerVerifierKey = (ledgerContractState, entryPoint, circuitId, verifierKey, v8) => {
|
|
368
|
+
const operation = new v8.ContractOperation();
|
|
369
|
+
try {
|
|
370
|
+
operation.verifierKey = verifierKey;
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
throw new ComposeFailedError('v8', 'deploy-verifier-key-blob', circuitId, error);
|
|
374
|
+
}
|
|
375
|
+
ledgerContractState.setOperation(entryPoint, operation);
|
|
376
|
+
};
|
|
377
|
+
/**
|
|
378
|
+
* Composes a v8-native deploy transaction from a {@link ConstructorResultPojo}'s
|
|
379
|
+
* `contractState` and immediately serializes it: bridge the constructor's
|
|
380
|
+
* pre-fork state into a v8-native one, register a verifier key for every entry
|
|
381
|
+
* point it declares, then wrap it in a `ContractDeploy` / `Intent` /
|
|
382
|
+
* `Transaction`.
|
|
383
|
+
*
|
|
384
|
+
* The verifier-key map is validated against the state's declared entry points
|
|
385
|
+
* BEFORE anything is registered, by {@link resolveVerifierKeyRegistrations} —
|
|
386
|
+
* the resolver both eras' deploy legs share.
|
|
387
|
+
*
|
|
388
|
+
* Never proves the transaction: the returned bytes are an UNPROVEN,
|
|
389
|
+
* tag-prefixed serialization, exactly what `Transaction.serialize()` produces
|
|
390
|
+
* before `.prove()` is ever called.
|
|
391
|
+
*
|
|
392
|
+
* @param options The state bytes, the verifier-key map, the envelope options
|
|
393
|
+
* and an optional Zswap offer.
|
|
394
|
+
* @param v8 The v8 ledger module, as handed over by `loadLedger8`
|
|
395
|
+
* (`./load.ts`).
|
|
396
|
+
* @returns The UNPROVEN, serialized transaction, the address the deployment
|
|
397
|
+
* will have, and the registered initial state. A deploy mints a fresh nonce,
|
|
398
|
+
* so the address is not a function of the state a caller passed in and cannot
|
|
399
|
+
* be recomputed from it — and the state the address was derived from is the
|
|
400
|
+
* one a caller stores and later dispatches calls against.
|
|
401
|
+
* @throws ComposeOptionError If `networkId` is empty or `ttl` is not a valid
|
|
402
|
+
* instant, or the state bytes cannot be read.
|
|
403
|
+
* @throws ComposeFailedError If the map and the state's declared entry points
|
|
404
|
+
* do not agree (stages `'deploy-ambiguous-circuit'`,
|
|
405
|
+
* `'deploy-unknown-circuit'`, `'deploy-verifier-key'`), or the ledger itself
|
|
406
|
+
* rejects a key blob (stage `'deploy-verifier-key-blob'`, with the ledger's
|
|
407
|
+
* own failure on `cause`).
|
|
408
|
+
* @see {@link VerifierKeys}
|
|
409
|
+
* @see {@link ComposeRefusalOrder}
|
|
410
|
+
*/
|
|
411
|
+
const composeV8DeployTx = (options, v8) => {
|
|
412
|
+
const { contractState, verifierKeys, networkId, ttl, guaranteedZswapOffer } = options;
|
|
413
|
+
assertComposeEnvelope(options, 'v8');
|
|
414
|
+
const ledgerContractState = bridgeContractState(contractState, v8);
|
|
415
|
+
for (const { entryPoint, circuitId, verifierKey } of resolveVerifierKeyRegistrations(ledgerContractState.operations(), verifierKeys, 'v8')) {
|
|
416
|
+
registerVerifierKey(ledgerContractState, entryPoint, circuitId, verifierKey, v8);
|
|
417
|
+
}
|
|
418
|
+
const deploy = new v8.ContractDeploy(ledgerContractState);
|
|
419
|
+
const intent = v8.Intent.new(ttl).addDeploy(deploy);
|
|
420
|
+
return {
|
|
421
|
+
transaction: v8.Transaction.fromParts(networkId, guaranteedZswapOffer, undefined, intent).serialize(),
|
|
422
|
+
contractAddress: deploy.address,
|
|
423
|
+
initialState: deploy.initialState.serialize()
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
export { INITIAL_LEDGER_PARAMETERS as I, assembleCallPrototype as a, entryPointName as b, assertComposeEnvelope as c, composeV8DeployTx as d, executeConstructor as e, partitionCallTranscript as p, resolveVerifierKeyRegistrations as r };
|
|
428
|
+
//# sourceMappingURL=deploy-D6yyn9P7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy-D6yyn9P7.js","sources":["../../src/lib/shared/compose-types.ts","../../src/lib/shared/assemble-call.ts","../../src/lib/shared/verifier-keys.ts","../../src/lib/shared/compose-options.ts","../../src/lib/v8/deploy.ts"],"sourcesContent":[null,null,null,null,null],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;AAaG;AAiEH;;;;;;;;AAQG;AACI,MAAM,yBAAyB,GAAG;;ACvFzC;;;;;;;;;;;;;AAaG;AAqKH;;;;;;AAMG;AACH,MAAM,sBAAsB,GAAG,CAC7B,YAA2B,EAC3B,gBAAkC,KACjB;AACjB,IAAA,YAAY,CAAC,KAAK,GAAG,gBAAgB,CAAC,KAAK;AAC3C,IAAA,YAAY,CAAC,OAAO,GAAG,gBAAgB,CAAC,OAAO;IAC/C,IAAI,OAAO,GAAG,YAAY;IAC1B,KAAK,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,gBAAgB,CAAC,UAAU,EAAE;QAC7D,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC;IACvD;AACA,IAAA,OAAO,OAAO;AAChB,CAAC;AAED;;;;;;AAMG;AACH,MAAM,gBAAgB,GAAG,CASvB,MAAsH,EACtH,OAA6B,KAC4D;IACzF,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO;AACnE,IAAA,IAAI,UAAU,CAAC,IAAI,KAAK,aAAa,EAAE;;;AAGrC,QAAA,IAAI,UAAU,CAAC,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,QAAQ,KAAK,SAAS,EAAE;YAC5E,MAAM,IAAI,kBAAkB,CAAC,OAAO,EAAE,uBAAuB,EAAE,SAAS,CAAC;QAC3E;QACA,OAAO,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,CAAC,QAAQ,CAAC;IACrD;AAEA,IAAA,IAAI,YAA2B;AAC/B,IAAA,IAAI;AACF,QAAA,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAA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AAC,SAAS,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,SAAS,EAAE;QACrG,eAAe,EAAE,MAAM,CAAC,OAAO;AAC/B,QAAA,YAAY,EAAE,MAAM,CAAC,YAAY,CAAC,SAAS;KAC5C;AACH;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Ledger8RuntimeMissingError } from '../errors.js';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* This file is part of midnight-js.
|
|
5
|
+
* Copyright (C) Midnight Foundation
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* You may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
let v8ModulePromise;
|
|
18
|
+
/**
|
|
19
|
+
* The only sanctioned runtime path to the v8 ledger era.
|
|
20
|
+
*
|
|
21
|
+
* The v8 WASM loads on the first call and not before.
|
|
22
|
+
*
|
|
23
|
+
* A failed load is not memoised: the rejection propagates as
|
|
24
|
+
* {@link Ledger8RuntimeMissingError} and the next call retries the import.
|
|
25
|
+
*
|
|
26
|
+
* @returns The v8 ledger module, memoised after the first successful load.
|
|
27
|
+
* @throws Ledger8RuntimeMissingError If the `./v8` chunk cannot be imported.
|
|
28
|
+
* The returned promise rejects with it, carrying the underlying failure on
|
|
29
|
+
* `cause`.
|
|
30
|
+
* @see {@link ModuleGraphAndLazyLoading}
|
|
31
|
+
* @see {@link EraSeam}
|
|
32
|
+
*/
|
|
33
|
+
const loadLedger8 = () => (v8ModulePromise ??= import('../v8.js').catch((error) => {
|
|
34
|
+
v8ModulePromise = undefined;
|
|
35
|
+
throw new Ledger8RuntimeMissingError('/v8', error);
|
|
36
|
+
}));
|
|
37
|
+
|
|
38
|
+
export { loadLedger8 as l };
|
|
39
|
+
//# sourceMappingURL=load-C0TZnEd2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-C0TZnEd2.js","sources":["../../src/lib/v8/load.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;AAaG;AAOH,IAAI,eAAgD;AAEpD;;;;;;;;;;;;;;AAcG;MACU,WAAW,GAAG,OACxB,eAAe,KAAK,OAAO,UAAa,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,KAAI;IAClE,eAAe,GAAG,SAAS;AAC3B,IAAA,MAAM,IAAI,0BAA0B,CAAC,KAAK,EAAE,KAAK,CAAC;AACpD,CAAC,CAAC;;;;"}
|
package/dist/v8.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@midnightntwrk/ledger-v8';
|
package/dist/v8.js
ADDED
package/dist/v8.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v8.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|