@sig-net/midnight 0.22.0-rc.3 → 0.22.0-rc.4
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 +1 -1
- package/dist/constants.d.ts +12 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +28 -0
- package/dist/constants.js.map +1 -1
- package/dist/mpc-output-cache.d.ts +6 -2
- package/dist/mpc-output-cache.d.ts.map +1 -1
- package/dist/mpc-output-cache.js +23 -1
- package/dist/mpc-output-cache.js.map +1 -1
- package/package.json +1 -1
- package/src/Signet.compact +4 -4
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ What clients import from `@sig-net/midnight`:
|
|
|
72
72
|
| Compose expected calldata words off chain (UIs, expected-record builders, tests) | The builders `numericAbiWord`, `evmAddressAbiWord` and `boolAbiWord`, and the readers `abiWordToUint128` and `abiWordToBool`: TS twins of the circuits under identical names. |
|
|
73
73
|
| Convert a foreign execution output into respond bytes | `deserializeEvmOutput` (raw EVM return data to named values) and `serializeRespondOutput` (named values to the packed respond payload the MPC attests): together they rebuild the `serializedOutput` of steps 4 and 5. |
|
|
74
74
|
| Recognise a failed remote execution | `MPC_FAILURE_OUTPUT` and `isMpcFailureOutput`: the MPC's fixed 5-byte failure payload for reverted or replaced transactions (see [Handling Failure](https://github.com/sig-net/midnight-integration/blob/main/README.md#handling-failure)). |
|
|
75
|
-
| Read the attested output bytes from the MPC's output cache | `MpcOutputCacheReader`: one reader per network and Signet singleton pair, over the public bucket an MPC configured with output storage writes each request's exact attested bytes to before posting. `fetchSerializedOutput` yields the bytes step 5 verifies, `undefined` while the object is not written yet. |
|
|
75
|
+
| Read the attested output bytes from the MPC's output cache | `MpcOutputCacheReader`: one reader per network and Signet singleton pair, over the public bucket an MPC configured with output storage writes each request's exact attested bytes to before posting, defaulting to the bucket `getMpcOutputCacheUrl` publishes for the network. `fetchSerializedOutput` yields the bytes step 5 verifies, `undefined` while the object is not written yet. |
|
|
76
76
|
| Verify attestations without the reader | `verifyRespondBidirectionalSignature`: the check the reader runs internally, exposed for custom pipelines. |
|
|
77
77
|
| Mint attestations in your contract's unit tests | The `@sig-net/midnight/testing` entry point, see [Testing entry point](#testing-entry-point). |
|
|
78
78
|
| Discover requests MPC-side (responders, background workers) | The discovery primitives: decode the signet contract's emitted notification events with `decodeSignBidirectionalEventNotificationPayload` and `decodeSignBidirectionalNotification`, then resolve each pointer against the named caller's own request map with `lookupSignetRequestAt` (the authenticated read). The polling loop belongs to the responder. |
|
package/dist/constants.d.ts
CHANGED
|
@@ -86,4 +86,16 @@ export declare function getMpcRootPublicKey(networkId: DeployedNetwork): string;
|
|
|
86
86
|
* package.
|
|
87
87
|
*/
|
|
88
88
|
export declare function getSignetContractAddress(networkId: DeployedNetwork): string;
|
|
89
|
+
/**
|
|
90
|
+
* The public URL of the MPC's output cache on a deployed Midnight network,
|
|
91
|
+
* down to the MPC's object prefix: the `cacheUrl` an `MpcOutputCacheReader`
|
|
92
|
+
* defaults to. A local standalone stack has no published cache: its
|
|
93
|
+
* responder serves its own.
|
|
94
|
+
*
|
|
95
|
+
* @param networkId - The deployed network to look up.
|
|
96
|
+
* @returns The network's output cache URL.
|
|
97
|
+
* @throws {Error} When no cache is published for the network in this
|
|
98
|
+
* package.
|
|
99
|
+
*/
|
|
100
|
+
export declare function getMpcOutputCacheUrl(networkId: DeployedNetwork): string;
|
|
89
101
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AASA,+DAA+D;AAC/D,eAAO,MAAM,cAAc,KAAK,CAAC;AAEjC,8DAA8D;AAC9D,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAEnC,wFAAwF;AACxF,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,y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MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAUpE;AAED;;;GAGG;AACH,oBAAY,eAAe;IACzB,mFAAmF;IACnF,UAAU,eAAe;IACzB,2CAA2C;IAC3C,QAAQ,aAAa;IACrB,iFAAiF;IACjF,OAAO,YAAY;IACnB,+EAA+E;IAC/E,OAAO,YAAY;IACnB,6CAA6C;IAC7C,OAAO,YAAY;CACpB;AAED;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;AAgBnF;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAMtE;AAYD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAM3E;AAcD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAMvE"}
|
package/dist/constants.js
CHANGED
|
@@ -133,4 +133,32 @@ export function getSignetContractAddress(networkId) {
|
|
|
133
133
|
}
|
|
134
134
|
return contractAddress;
|
|
135
135
|
}
|
|
136
|
+
// The public URL of each network's MPC output cache down to the MPC's
|
|
137
|
+
// configured object prefix (`publisher.output_storage.prefix`). An empty
|
|
138
|
+
// string means "no cache published" and makes getMpcOutputCacheUrl throw for
|
|
139
|
+
// that network.
|
|
140
|
+
const mpcOutputCacheUrls = {
|
|
141
|
+
[MidnightNetwork.Stagenet]: "https://storage.googleapis.com/midnight-cache-storage-dev/v1/stagenet",
|
|
142
|
+
[MidnightNetwork.Preview]: "",
|
|
143
|
+
[MidnightNetwork.Preprod]: "",
|
|
144
|
+
[MidnightNetwork.Mainnet]: "",
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* The public URL of the MPC's output cache on a deployed Midnight network,
|
|
148
|
+
* down to the MPC's object prefix: the `cacheUrl` an `MpcOutputCacheReader`
|
|
149
|
+
* defaults to. A local standalone stack has no published cache: its
|
|
150
|
+
* responder serves its own.
|
|
151
|
+
*
|
|
152
|
+
* @param networkId - The deployed network to look up.
|
|
153
|
+
* @returns The network's output cache URL.
|
|
154
|
+
* @throws {Error} When no cache is published for the network in this
|
|
155
|
+
* package.
|
|
156
|
+
*/
|
|
157
|
+
export function getMpcOutputCacheUrl(networkId) {
|
|
158
|
+
const cacheUrl = mpcOutputCacheUrls[networkId];
|
|
159
|
+
if (!cacheUrl) {
|
|
160
|
+
throw new Error(`no MPC output cache URL published for the '${networkId}' network yet`);
|
|
161
|
+
}
|
|
162
|
+
return cacheUrl;
|
|
163
|
+
}
|
|
136
164
|
//# sourceMappingURL=constants.js.map
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,2EAA2E;AAC3E,mEAAmE;AACnE,qEAAqE;AACrE,sDAAsD;AACtD,EAAE;AACF,0EAA0E;AAC1E,oBAAoB;AAEpB,+DAA+D;AAC/D,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC;AAEjC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAEnC,wFAAwF;AACxF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,UAAU,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEjF;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,gBAA4B;IAC7D,OAAO,CACL,gBAAgB,CAAC,MAAM,KAAK,kBAAkB,CAAC,MAAM;QACrD,kBAAkB,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,gBAAgB,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AAC,eAAe,CAAC,QAAQ,CAAC,EACxB,uEAAuE;IACzE,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,EAAE;IAC7B,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,EAAE;IAC7B,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,EAAE;CAC9B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAA0B;IAC7D,MAAM,QAAQ,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC/C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,8CAA8C,SAAS,eAAe,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -4,9 +4,11 @@ export interface MpcOutputCacheConfig {
|
|
|
4
4
|
/**
|
|
5
5
|
* The cache's public URL down to the MPC's configured object prefix, e.g.
|
|
6
6
|
* `https://storage.googleapis.com/<bucket>/<prefix>`. A trailing slash is
|
|
7
|
-
* tolerated.
|
|
7
|
+
* tolerated. Defaults to the cache this package publishes for `networkId`
|
|
8
|
+
* ({@link getMpcOutputCacheUrl}), so a network with none (the local
|
|
9
|
+
* standalone stack) must pass it.
|
|
8
10
|
*/
|
|
9
|
-
readonly cacheUrl
|
|
11
|
+
readonly cacheUrl?: string;
|
|
10
12
|
/** The Midnight network id the MPC serves: the path segment after the prefix. */
|
|
11
13
|
readonly networkId: string;
|
|
12
14
|
/** The signet singleton the MPC publishes through, 64 hex chars: the segment after the network. */
|
|
@@ -24,6 +26,8 @@ export declare class MpcOutputCacheReader {
|
|
|
24
26
|
private readonly namespaceUrl;
|
|
25
27
|
/**
|
|
26
28
|
* @param config - The cache location and the namespace to read.
|
|
29
|
+
* @throws {Error} When `cacheUrl` is omitted for a network this package
|
|
30
|
+
* publishes no cache for.
|
|
27
31
|
*/
|
|
28
32
|
constructor(config: MpcOutputCacheConfig);
|
|
29
33
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mpc-output-cache.d.ts","sourceRoot":"","sources":["../src/mpc-output-cache.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mpc-output-cache.d.ts","sourceRoot":"","sources":["../src/mpc-output-cache.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,8EAA8E;AAC9E,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,iFAAiF;IACjF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,mGAAmG;IACnG,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;CACxC;AAwBD;;;;;;;GAOG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IAEtC;;;;OAIG;IACH,YAAY,MAAM,EAAE,oBAAoB,EAMvC;IAED;;;;;OAKG;IACH,SAAS,CAAC,SAAS,EAAE,YAAY,GAAG,MAAM,CAEzC;IAED;;;;;;;;;OASG;IACG,qBAAqB,CAAC,SAAS,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAYpF;CACF"}
|
package/dist/mpc-output-cache.js
CHANGED
|
@@ -6,6 +6,23 @@
|
|
|
6
6
|
// signature alone and the cache carries the bytes. An object holds nothing
|
|
7
7
|
// but the packed output, and is UNTRUSTED until the attestation signature
|
|
8
8
|
// verifies over it (`verifyRespondBidirectionalSignature`).
|
|
9
|
+
import { getMpcOutputCacheUrl, MidnightNetwork } from "./constants.js";
|
|
10
|
+
/** The networks this package may publish an output cache for: every named one but the local stack. */
|
|
11
|
+
const DEPLOYED_NETWORKS = Object.values(MidnightNetwork).filter((network) => network !== MidnightNetwork.Undeployed);
|
|
12
|
+
/**
|
|
13
|
+
* The cache URL this package publishes for `networkId`.
|
|
14
|
+
*
|
|
15
|
+
* @param networkId - The Midnight network id the MPC serves.
|
|
16
|
+
* @returns The published cache URL.
|
|
17
|
+
* @throws {Error} When `networkId` is not a deployed network, or is one with
|
|
18
|
+
* no cache published yet.
|
|
19
|
+
*/
|
|
20
|
+
function publishedCacheUrl(networkId) {
|
|
21
|
+
if (!DEPLOYED_NETWORKS.includes(networkId)) {
|
|
22
|
+
throw new Error(`no MPC output cache is published for the '${networkId}' network: pass cacheUrl`);
|
|
23
|
+
}
|
|
24
|
+
return getMpcOutputCacheUrl(networkId);
|
|
25
|
+
}
|
|
9
26
|
/**
|
|
10
27
|
* Reads attested serialised outputs out of the MPC's output cache. The MPC
|
|
11
28
|
* writes a request's bytes to
|
|
@@ -18,9 +35,14 @@ export class MpcOutputCacheReader {
|
|
|
18
35
|
namespaceUrl;
|
|
19
36
|
/**
|
|
20
37
|
* @param config - The cache location and the namespace to read.
|
|
38
|
+
* @throws {Error} When `cacheUrl` is omitted for a network this package
|
|
39
|
+
* publishes no cache for.
|
|
21
40
|
*/
|
|
22
41
|
constructor(config) {
|
|
23
|
-
|
|
42
|
+
let prefixUrl = config.cacheUrl ?? publishedCacheUrl(config.networkId);
|
|
43
|
+
while (prefixUrl.endsWith("/")) {
|
|
44
|
+
prefixUrl = prefixUrl.slice(0, -1);
|
|
45
|
+
}
|
|
24
46
|
this.namespaceUrl = `${prefixUrl}/${config.networkId}/${config.signetContractAddress}`;
|
|
25
47
|
}
|
|
26
48
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mpc-output-cache.js","sourceRoot":"","sources":["../src/mpc-output-cache.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,4EAA4E;AAC5E,6EAA6E;AAC7E,wEAAwE;AACxE,2EAA2E;AAC3E,2EAA2E;AAC3E,0EAA0E;AAC1E,4DAA4D;
|
|
1
|
+
{"version":3,"file":"mpc-output-cache.js","sourceRoot":"","sources":["../src/mpc-output-cache.ts"],"names":[],"mappings":"AAAA,4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SAAuB;QACjD,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,kCAAkC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,GAAG,KAAK,MAAM,QAAQ,CAAC,IAAI,EAAE,EAAE,CACjG,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,UAAU,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IACtD,CAAC;CACF"}
|
package/package.json
CHANGED
package/src/Signet.compact
CHANGED
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
// 4. MPC observes txn execution on destination chain and posts a RespondBidirectionalEvent attestation
|
|
44
44
|
// through the Signet singleton, which emits it as a contract event beside the request id.
|
|
45
45
|
// The client polls its request's posts and takes the first one that verifies over the request id
|
|
46
|
-
// and output. The client
|
|
47
|
-
// call's return data via debug_traceTransaction,
|
|
48
|
-
//
|
|
49
|
-
//
|
|
46
|
+
// and output. The client obtains the execution output off chain (for EVM: the mined
|
|
47
|
+
// call's return data via debug_traceTransaction, or the exact attested bytes from the
|
|
48
|
+
// MPC's output cache) and hands output plus attestation to its verify circuit. See
|
|
49
|
+
// "Output Recovery" in the repository README.
|
|
50
50
|
//
|
|
51
51
|
// Read more:
|
|
52
52
|
// - The sign bidirectional flow and key derivation: this package's README
|