@midnightntwrk/wallet-sdk-capabilities 4.0.0-rc.0 → 4.0.0-rc.2
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 +10 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/liveness/index.d.ts +2 -0
- package/dist/liveness/index.js +14 -0
- package/dist/liveness/livenessReads.d.ts +73 -0
- package/dist/liveness/livenessReads.js +229 -0
- package/dist/liveness/livenessService.d.ts +137 -0
- package/dist/liveness/livenessService.js +200 -0
- package/dist/proving/index.d.ts +1 -0
- package/dist/proving/index.js +1 -0
- package/dist/proving/provingService.d.ts +15 -48
- package/dist/proving/provingService.js +1 -89
- package/dist/proving/v8ProvingService.d.ts +33 -6
- package/dist/proving/v8ProvingService.js +35 -5
- package/dist/proving/v9ProvingService.d.ts +108 -0
- package/dist/proving/v9ProvingService.js +146 -0
- package/dist/proving/versionedProving.d.ts +22 -4
- package/dist/proving/versionedProving.js +27 -1
- package/dist/simulation/index.d.ts +4 -6
- package/dist/simulation/index.js +4 -7
- package/dist/simulation/v8/Simulator.d.ts +0 -2
- package/dist/simulation/v8/Simulator.js +0 -2
- package/dist/simulation/v8/SimulatorState.d.ts +0 -9
- package/dist/simulation/v8/SimulatorState.js +0 -8
- package/dist/simulation/v8/index.d.ts +1 -1
- package/dist/simulation/v8/index.js +1 -1
- package/dist/simulation/v9/Simulator.d.ts +0 -2
- package/dist/simulation/v9/Simulator.js +0 -2
- package/dist/simulation/v9/SimulatorState.d.ts +0 -9
- package/dist/simulation/v9/SimulatorState.js +0 -8
- package/dist/simulation/v9/index.d.ts +1 -1
- package/dist/simulation/v9/index.js +1 -1
- package/dist/submission/submissionService.d.ts +57 -9
- package/dist/submission/submissionService.js +61 -15
- package/dist/transactionLifecycle/SnapshotFormat.d.ts +51 -0
- package/dist/transactionLifecycle/SnapshotFormat.js +120 -0
- package/dist/transactionLifecycle/index.d.ts +4 -0
- package/dist/{pendingTransactions → transactionLifecycle}/index.js +4 -2
- package/dist/transactionLifecycle/lifecycle.d.ts +402 -0
- package/dist/transactionLifecycle/lifecycle.js +407 -0
- package/dist/transactionLifecycle/lifecycleService.d.ts +448 -0
- package/dist/transactionLifecycle/lifecycleService.js +350 -0
- package/dist/transactionLifecycle/transactionTraits.d.ts +106 -0
- package/dist/transactionLifecycle/transactionTraits.js +53 -0
- package/dist/validation/blockData.d.ts +23 -4
- package/dist/validation/blockData.js +34 -10
- package/dist/validation/index.d.ts +1 -0
- package/dist/validation/index.js +1 -0
- package/dist/validation/promiseBoundary.d.ts +10 -0
- package/dist/validation/promiseBoundary.js +30 -0
- package/dist/validation/v8ValidationService.d.ts +5 -4
- package/dist/validation/v8ValidationService.js +10 -3
- package/dist/validation/v9ValidationService.d.ts +30 -0
- package/dist/validation/v9ValidationService.js +61 -0
- package/dist/validation/validationService.d.ts +53 -31
- package/dist/validation/validationService.js +29 -49
- package/dist/validation/versionedValidation.d.ts +5 -3
- package/dist/validation/versionedValidation.js +5 -3
- package/package.json +13 -13
- package/dist/pendingTransactions/index.d.ts +0 -2
- package/dist/pendingTransactions/pendingTransactions.d.ts +0 -165
- package/dist/pendingTransactions/pendingTransactions.js +0 -202
- package/dist/pendingTransactions/pendingTransactionsService.d.ts +0 -68
- package/dist/pendingTransactions/pendingTransactionsService.js +0 -158
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
+
// Copyright (C) Midnight Foundation
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// You may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { IndexerLiveness } from '@midnightntwrk/wallet-sdk-abstractions';
|
|
14
|
+
import { Cause, Data, Deferred, Duration, Effect, identity, Option, Stream, SubscriptionRef } from 'effect';
|
|
15
|
+
/**
|
|
16
|
+
* A block height could not be read.
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* The indexer and the node fail in their own vocabularies — a GraphQL error and a `NodeClientError` respectively. Each
|
|
20
|
+
* caller adapts its failure into this one type, so the service depends on neither and needs only what it actually
|
|
21
|
+
* uses: a message to report on an {@link IndexerLiveness.Unavailable} verdict.
|
|
22
|
+
*/
|
|
23
|
+
export class LivenessReadError extends Data.TaggedError('LivenessReadError') {
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The default bound on a single poll.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* Comfortably above the node read's own ten-second connection bound, and below the default poll interval, so an
|
|
30
|
+
* abandoned poll never delays the tick that follows it.
|
|
31
|
+
*/
|
|
32
|
+
export const DEFAULT_POLL_TIMEOUT = Duration.seconds(20);
|
|
33
|
+
/**
|
|
34
|
+
* Tolerances sized against Midnight's 6-second block slots (the indexer pins `SLOT_DURATION` at 6000 ms).
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* `maxBehindBlocks` is a staleness allowance: ten blocks is about a minute of chain time, generous enough that an
|
|
38
|
+
* indexer briefly catching up is not reported as stale. `maxAheadBlocks` absorbs read skew — the two heights are read
|
|
39
|
+
* at different moments — while staying far below the thousands of blocks that separate two different networks.
|
|
40
|
+
*/
|
|
41
|
+
export const DEFAULT_LIVENESS_CONFIGURATION = {
|
|
42
|
+
maxBehindBlocks: 10n,
|
|
43
|
+
maxAheadBlocks: 10n,
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* How often to compare the indexer against the node, by default.
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* Deliberately unhurried. Each poll costs a request to a node the wallet does not own, a stalled indexer is a
|
|
50
|
+
* slow-developing condition, and polling faster than blocks are produced only re-reads the same block. At Midnight's
|
|
51
|
+
* 6-second slots, half a minute is about five blocks, and it surfaces a stalled indexer well within the time any
|
|
52
|
+
* caller would notice.
|
|
53
|
+
*/
|
|
54
|
+
export const DEFAULT_POLL_INTERVAL = Duration.seconds(30);
|
|
55
|
+
/**
|
|
56
|
+
* Reduces a failed poll to one line for {@link IndexerLiveness.Unavailable}'s `lastError`.
|
|
57
|
+
*
|
|
58
|
+
* @remarks
|
|
59
|
+
* That string is shown to whoever is diagnosing a stalled wallet, so it stays a message rather than a rendered cause: a
|
|
60
|
+
* stack trace is noise at that surface. Defects are labelled as unexpected, because unlike a read failure they
|
|
61
|
+
* indicate a bug rather than an unreachable node.
|
|
62
|
+
*/
|
|
63
|
+
const describeFailure = (cause) => Option.match(Cause.failureOption(cause), {
|
|
64
|
+
onSome: (error) => error.message,
|
|
65
|
+
onNone: () => Option.match(Cause.dieOption(cause), {
|
|
66
|
+
onSome: (defect) => `Unexpected failure while reading: ${defect instanceof Error ? defect.message : String(defect)}`,
|
|
67
|
+
onNone: () => 'Unexpected failure while reading',
|
|
68
|
+
}),
|
|
69
|
+
});
|
|
70
|
+
const GenesisCheck = Data.taggedEnum();
|
|
71
|
+
export class LivenessServiceImpl {
|
|
72
|
+
#state;
|
|
73
|
+
#reads;
|
|
74
|
+
#configuration;
|
|
75
|
+
// The check settles once and is never rewritten. A `Deferred` enforces that where a `Ref` would only promise it: a
|
|
76
|
+
// second completion is a no-op, and "not yet settled" is the empty `Deferred` rather than a sentinel value.
|
|
77
|
+
#genesisCheck;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a service whose verdict starts as {@link IndexerLiveness.Unknown} — a check exists but has not yet run.
|
|
80
|
+
*
|
|
81
|
+
* @param reads - Where the two heights come from.
|
|
82
|
+
* @param configuration - The tolerances to apply, and the bound on a single poll.
|
|
83
|
+
* @param initialVerdict - The verdict to start from. Callers that rebuild the service mid-session pass the verdict
|
|
84
|
+
* they already hold, so a reconnect does not erase a `Behind` the check had already reached — starting afresh at
|
|
85
|
+
* `Unknown` would hand back a stale-view answer the moment the gate re-opened.
|
|
86
|
+
* @returns An effect yielding the service.
|
|
87
|
+
*/
|
|
88
|
+
static make(reads, configuration = DEFAULT_LIVENESS_CONFIGURATION, initialVerdict = IndexerLiveness.Unknown()) {
|
|
89
|
+
return Effect.all([
|
|
90
|
+
SubscriptionRef.make(initialVerdict),
|
|
91
|
+
Deferred.make(),
|
|
92
|
+
]).pipe(Effect.map(([state, genesisCheck]) => new LivenessServiceImpl(state, reads, configuration, genesisCheck)));
|
|
93
|
+
}
|
|
94
|
+
constructor(state, reads, configuration, genesisCheck) {
|
|
95
|
+
this.#state = state;
|
|
96
|
+
this.#reads = reads;
|
|
97
|
+
this.#configuration = configuration;
|
|
98
|
+
this.#genesisCheck = genesisCheck;
|
|
99
|
+
}
|
|
100
|
+
state() {
|
|
101
|
+
// `changes` already replays the current value before subsequent ones, under the ref's own semaphore. Prepending a
|
|
102
|
+
// separate `get` would emit the first verdict twice — and read it outside that semaphore.
|
|
103
|
+
//
|
|
104
|
+
// `changesWith` then drops a verdict that says nothing new. Every poll writes unconditionally, and each write fans
|
|
105
|
+
// out into the wallet's full state stream — without this, a healthy idle wallet re-notified every subscriber once
|
|
106
|
+
// per poll, forever. Structural equality would not do: the heights on `InSync`, `Behind` and `Ahead` advance with
|
|
107
|
+
// the chain every poll, so consecutive verdicts are never structurally equal. `equivalent` compares what a caller
|
|
108
|
+
// acts on — the kind, a `Behind`'s lag, `Unavailable`'s climbing count — so a lengthening outage or a growing lag
|
|
109
|
+
// still reports, and a healthy idle wallet stays quiet.
|
|
110
|
+
return this.#state.changes.pipe(Stream.changesWith(IndexerLiveness.equivalent));
|
|
111
|
+
}
|
|
112
|
+
startPolling(ticks) {
|
|
113
|
+
return Stream.runForEach(ticks, () => this.#poll());
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Compares the two heights once and publishes the result.
|
|
117
|
+
*
|
|
118
|
+
* @remarks
|
|
119
|
+
* The whole poll is folded into the verdict: `catchAllCause` hands a failed read to `afterFailedPoll`, so the
|
|
120
|
+
* returned effect has no error channel and the polling loop survives an unreachable node. `SubscriptionRef.update`
|
|
121
|
+
* reads the previous verdict inside the callback, which is what lets `afterFailedPoll` continue a run of failures —
|
|
122
|
+
* or keep a `Behind` that a failed poll cannot disprove — without a separate get-then-write race.
|
|
123
|
+
*/
|
|
124
|
+
#poll() {
|
|
125
|
+
return this.#compareOnce().pipe(Effect.map((verdict) => () => verdict),
|
|
126
|
+
// `disconnect` makes the deadline below a hard one. A timeout interrupts its loser and then waits for it, and a
|
|
127
|
+
// node read that has connected defers the interrupt until its close and cache write finish, up to the connection
|
|
128
|
+
// bound. Disconnected, the read is interrupted in the background instead: the verdict lands on time, a handshake
|
|
129
|
+
// still in progress is abandoned with its provider disconnected, and a connected build still caches its client.
|
|
130
|
+
Effect.disconnect,
|
|
131
|
+
// A bound on the whole poll, not only on the reads' own deadlines: polls run one at a time, so a read that hangs
|
|
132
|
+
// — an endpoint that accepts a connection and never answers — would otherwise stop the loop forever, freezing
|
|
133
|
+
// the verdict at whatever was published last. A hung read must not be able to switch the check off.
|
|
134
|
+
Effect.timeoutFail({
|
|
135
|
+
duration: this.#configuration.pollTimeout ?? DEFAULT_POLL_TIMEOUT,
|
|
136
|
+
onTimeout: () => new LivenessReadError({ message: 'Poll abandoned: a read did not complete in time' }),
|
|
137
|
+
}),
|
|
138
|
+
// `catchAllCause`, not `catchAll`: a read can die as well as fail — an unparsed URL, a payload that is not the
|
|
139
|
+
// shape it claims — and a defect would kill the poll fibre outright. The verdict would then freeze at whatever
|
|
140
|
+
// was written last, which at start-up is `Unknown` and never gates, leaving an indexer able to switch off the
|
|
141
|
+
// check simply by answering badly.
|
|
142
|
+
Effect.catchAllCause((cause) => Effect.succeed((previous) => IndexerLiveness.afterFailedPoll(previous, describeFailure(cause)))), Effect.flatMap((nextVerdict) => SubscriptionRef.update(this.#state, nextVerdict)));
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Runs one comparison: the chain identity first, then the heights.
|
|
146
|
+
*
|
|
147
|
+
* @remarks
|
|
148
|
+
* Height comparison is meaningful only between endpoints on the same chain, so no height verdict is published until
|
|
149
|
+
* the genesis hashes have been read once and found to match. A mismatch pins {@link IndexerLiveness.WrongNetwork}
|
|
150
|
+
* for the service's lifetime — neither endpoint changes chain until reconfigured, and reconfiguring builds a new
|
|
151
|
+
* wallet — while a match is cached so the hashes are read exactly once. A _failed_ hash read proves nothing about
|
|
152
|
+
* which chain anyone is on, so it caches nothing: it surfaces through the ordinary `Unavailable` path and the next
|
|
153
|
+
* poll tries the hashes again.
|
|
154
|
+
*/
|
|
155
|
+
#compareOnce() {
|
|
156
|
+
// `poll` reads without waiting: an empty `Deferred` means the hashes have not yet been compared, so compare them now.
|
|
157
|
+
return Deferred.poll(this.#genesisCheck).pipe(Effect.flatMap(Option.match({ onNone: () => this.#verifyGenesis(), onSome: identity })), Effect.flatMap(GenesisCheck.$match({
|
|
158
|
+
Mismatch: ({ verdict }) => Effect.succeed(verdict),
|
|
159
|
+
SameChain: () => this.#compareTips(),
|
|
160
|
+
})));
|
|
161
|
+
}
|
|
162
|
+
/** Reads both genesis hashes, settles the check, and caches the outcome. */
|
|
163
|
+
#verifyGenesis() {
|
|
164
|
+
return Effect.all([this.#reads.indexerGenesisHash(), this.#reads.nodeGenesisHash()], { concurrency: 2 }).pipe(Effect.map(([indexerGenesisHash, nodeGenesisHash]) => IndexerLiveness.sameBlockHash(indexerGenesisHash, nodeGenesisHash)
|
|
165
|
+
? GenesisCheck.SameChain()
|
|
166
|
+
: GenesisCheck.Mismatch({
|
|
167
|
+
// The genesis comparison is the height-zero case of the same block comparison every poll runs.
|
|
168
|
+
verdict: IndexerLiveness.WrongNetwork({
|
|
169
|
+
height: 0n,
|
|
170
|
+
indexerBlockHash: Option.some(indexerGenesisHash),
|
|
171
|
+
nodeBlockHash: Option.some(nodeGenesisHash),
|
|
172
|
+
}),
|
|
173
|
+
})), Effect.tap((check) => Deferred.succeed(this.#genesisCheck, check)));
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Reads both tips, confirms they name the same block where they overlap, and reduces the heights to a verdict.
|
|
177
|
+
*
|
|
178
|
+
* @remarks
|
|
179
|
+
* Only one extra block is read per poll, and none at all when the two tips are already at the same height: the
|
|
180
|
+
* endpoint that trails is reporting the shared block as its own tip, so the only open question is what the endpoint
|
|
181
|
+
* that leads names there. Asking both would be a second round trip for an answer already in hand.
|
|
182
|
+
*/
|
|
183
|
+
#compareTips() {
|
|
184
|
+
return Effect.all([this.#reads.indexerTip(), this.#reads.finalizedBlock()], { concurrency: 2 }).pipe(Effect.flatMap(([indexer, finalized]) => this.#sharedBlockHash(indexer, finalized).pipe(Effect.map((sharedHash) => IndexerLiveness.evaluateTips({
|
|
185
|
+
indexer,
|
|
186
|
+
finalized,
|
|
187
|
+
sharedHash,
|
|
188
|
+
maxBehindBlocks: this.#configuration.maxBehindBlocks,
|
|
189
|
+
maxAheadBlocks: this.#configuration.maxAheadBlocks,
|
|
190
|
+
})))));
|
|
191
|
+
}
|
|
192
|
+
/** Asks whichever endpoint is ahead what it names at the other's height; neither, when the two are level. */
|
|
193
|
+
#sharedBlockHash(indexer, finalized) {
|
|
194
|
+
return indexer.height === finalized.height
|
|
195
|
+
? Effect.succeed(Option.none())
|
|
196
|
+
: indexer.height > finalized.height
|
|
197
|
+
? this.#reads.indexerBlockHashAt(finalized.height)
|
|
198
|
+
: this.#reads.nodeBlockHashAt(indexer.height);
|
|
199
|
+
}
|
|
200
|
+
}
|
package/dist/proving/index.d.ts
CHANGED
package/dist/proving/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import * as ledger from '@midnightntwrk/ledger-v9';
|
|
2
1
|
import type { KeyMaterialProvider } from '@midnight-ntwrk/zkir-v2';
|
|
3
2
|
import { ProtocolVersion } from '@midnightntwrk/wallet-sdk-abstractions';
|
|
4
|
-
import { type InvalidProtocolSchemeError } from '@midnightntwrk/wallet-sdk-utilities/networking';
|
|
5
3
|
import { Effect, Either } from 'effect';
|
|
6
4
|
declare const ProvingError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
7
5
|
readonly _tag: "Wallet.Proving";
|
|
@@ -35,16 +33,19 @@ export type ProvingFailure = ProvingError | ProvingEpochMismatchError;
|
|
|
35
33
|
/**
|
|
36
34
|
* Turns an unproven transaction into a proven one.
|
|
37
35
|
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* `prove` is a property rather than a method so that the transaction is checked contravariantly: a backend over one
|
|
38
|
+
* ledger version is then no backend over both, which is what keeps a ledger-v8 transaction from reaching ledger-v9.
|
|
38
39
|
* @typeParam TProven The proven transaction this backend produces.
|
|
39
|
-
* @typeParam TUnproven The unproven transaction it accepts
|
|
40
|
-
*
|
|
41
|
-
* {@link VersionedProvingServiceEffect}'s job
|
|
40
|
+
* @typeParam TUnproven The unproven transaction it accepts, and so the one ledger version it is written against. It has
|
|
41
|
+
* no default: a backend that left it out would be ledger-v9's without saying so. Choosing between backends for
|
|
42
|
+
* different ledger versions is {@link VersionedProvingServiceEffect}'s job, not this interface's.
|
|
42
43
|
*/
|
|
43
|
-
export interface ProvingServiceEffect<TProven, TUnproven
|
|
44
|
-
prove(transaction: TUnproven)
|
|
44
|
+
export interface ProvingServiceEffect<TProven, TUnproven> {
|
|
45
|
+
readonly prove: (transaction: TUnproven) => Effect.Effect<TProven, ProvingFailure>;
|
|
45
46
|
}
|
|
46
|
-
export interface ProvingService<TProven, TUnproven
|
|
47
|
-
prove(transaction: TUnproven)
|
|
47
|
+
export interface ProvingService<TProven, TUnproven> {
|
|
48
|
+
readonly prove: (transaction: TUnproven) => Promise<TProven>;
|
|
48
49
|
}
|
|
49
50
|
declare const UnsupportedProvingVersionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
50
51
|
readonly _tag: "@midnightntwrk/wallet-sdk-capabilities/proving/provingService/UnsupportedProvingVersionError";
|
|
@@ -64,14 +65,14 @@ export declare class UnsupportedProvingVersionError extends UnsupportedProvingVe
|
|
|
64
65
|
* the time proving happens. A fork can land between balancing and proving; the bytes the prover has to read were
|
|
65
66
|
* fixed before it did.
|
|
66
67
|
*/
|
|
67
|
-
export interface VersionedProvingServiceEffect<TProven, TUnproven
|
|
68
|
-
prove(transaction: TUnproven, protocolVersion: ProtocolVersion.ProtocolVersion)
|
|
68
|
+
export interface VersionedProvingServiceEffect<TProven, TUnproven> {
|
|
69
|
+
readonly prove: (transaction: TUnproven, protocolVersion: ProtocolVersion.ProtocolVersion) => Effect.Effect<TProven, ProvingFailure | UnsupportedProvingVersionError>;
|
|
69
70
|
}
|
|
70
|
-
export interface VersionedProvingService<TProven, TUnproven
|
|
71
|
-
prove(transaction: TUnproven, protocolVersion: ProtocolVersion.ProtocolVersion)
|
|
71
|
+
export interface VersionedProvingService<TProven, TUnproven> {
|
|
72
|
+
readonly prove: (transaction: TUnproven, protocolVersion: ProtocolVersion.ProtocolVersion) => Promise<TProven>;
|
|
72
73
|
}
|
|
73
74
|
/** The proving backends a wallet can use, keyed by the protocol version range each one serves. */
|
|
74
|
-
export type ProvingServices<TProven, TUnproven
|
|
75
|
+
export type ProvingServices<TProven, TUnproven> = ProtocolVersion.Registry<ProvingServiceEffect<TProven, TUnproven>>;
|
|
75
76
|
/**
|
|
76
77
|
* Builds a proving service that routes on the version a transaction was built for.
|
|
77
78
|
*
|
|
@@ -90,11 +91,8 @@ export declare const makeVersionedProvingServiceEffect: <TProven, TUnproven>(ser
|
|
|
90
91
|
* @returns The same backend, addressed by version.
|
|
91
92
|
*/
|
|
92
93
|
export declare const singleVersionProvingServiceEffect: <TProven, TUnproven>(service: ProvingServiceEffect<TProven, TUnproven>) => VersionedProvingServiceEffect<TProven, TUnproven>;
|
|
93
|
-
export type V9UnboundTransaction = ledger.Transaction<ledger.SignatureEnabled, ledger.Proof, ledger.PreBinding>;
|
|
94
94
|
/** Adapts a version-routed proving service to the promise-facing surface the facade exposes. */
|
|
95
95
|
export declare const wrapVersionedEffectService: <TProven, TUnproven>(effectService: VersionedProvingServiceEffect<TProven, TUnproven>) => VersionedProvingService<TProven, TUnproven>;
|
|
96
|
-
export declare const fromV9ProvingProviderEffect: (provider: Effect.Effect<ledger.ProvingProvider, InvalidProtocolSchemeError>) => ProvingServiceEffect<V9UnboundTransaction>;
|
|
97
|
-
export declare const fromV9ProvingProvider: (provider: ledger.ProvingProvider) => ProvingServiceEffect<V9UnboundTransaction>;
|
|
98
96
|
export type ServerProvingConfiguration = {
|
|
99
97
|
provingServerUrl: URL;
|
|
100
98
|
};
|
|
@@ -172,35 +170,4 @@ export declare class ProvingConfigurationError extends ProvingConfigurationError
|
|
|
172
170
|
* @returns The backend per ledger version, or the reason the configuration names none.
|
|
173
171
|
*/
|
|
174
172
|
export declare const resolveProvingBackends: (configuration: DefaultProvingConfiguration) => Either.Either<ProvingBackends, ProvingConfigurationError>;
|
|
175
|
-
/**
|
|
176
|
-
* Registers the in-process WASM prover, driven by ledger-v9, from a given protocol version upwards.
|
|
177
|
-
*
|
|
178
|
-
* @remarks
|
|
179
|
-
* Every entry here is ledger-v9's backend, so `sinceVersion` should not be below a protocol boundary: what a version
|
|
180
|
-
* below it needs is the ledger-v8 driver, which `makeDefaultProvingServices` registers for the epoch the fork
|
|
181
|
-
* schedule it is given places below `forks.v9`. Registering nothing below is what turns that into an
|
|
182
|
-
* {@link UnsupportedProvingVersionError} naming the version, rather than a ledger-v8 transaction handed to a ledger
|
|
183
|
-
* that cannot read it.
|
|
184
|
-
* @param sinceVersion The first protocol version to register the bundled prover for.
|
|
185
|
-
* @param configuration Optional key material override.
|
|
186
|
-
* @returns The proving backends, keyed by version.
|
|
187
|
-
*/
|
|
188
|
-
export declare const makeWasmProvingServices: (sinceVersion: ProtocolVersion.ProtocolVersion, configuration?: WasmProvingConfiguration) => ProvingServices<V9UnboundTransaction>;
|
|
189
|
-
export declare const makeV9ServerProvingServiceEffect: (configuration: ServerProvingConfiguration) => ProvingServiceEffect<V9UnboundTransaction>;
|
|
190
|
-
/**
|
|
191
|
-
* Proves ledger-v9 transactions in this process.
|
|
192
|
-
*
|
|
193
|
-
* @remarks
|
|
194
|
-
* The ledger-v9 twin of `makeV8WasmProvingServiceEffect`: the same bundled prover, with ledger-v9's key material —
|
|
195
|
-
* circuit generation 10 ({@link WasmProver.makeV9KeyMaterialProvider}) — unless it is given key material of its own.
|
|
196
|
-
* @param configuration Optional key material override.
|
|
197
|
-
* @returns A backend that proves ledger-v9 transactions in-process.
|
|
198
|
-
*/
|
|
199
|
-
export declare const makeV9WasmProvingServiceEffect: (configuration?: WasmProvingConfiguration) => ProvingServiceEffect<V9UnboundTransaction>;
|
|
200
|
-
export declare const makeSimulatorProvingServiceEffect: () => ProvingServiceEffect<ledger.ProofErasedTransaction>;
|
|
201
|
-
export declare const makeDefaultProvingServiceEffect: (configuration: ServerProvingConfiguration) => ProvingServiceEffect<V9UnboundTransaction>;
|
|
202
|
-
export declare const makeDefaultProvingService: (configuration: ServerProvingConfiguration) => ProvingService<V9UnboundTransaction>;
|
|
203
|
-
export declare const makeV9ServerProvingService: (configuration: ServerProvingConfiguration) => ProvingService<V9UnboundTransaction>;
|
|
204
|
-
export declare const makeV9WasmProvingService: (configuration?: WasmProvingConfiguration) => ProvingService<V9UnboundTransaction>;
|
|
205
|
-
export declare const makeSimulatorProvingService: () => ProvingService<ledger.ProofErasedTransaction>;
|
|
206
173
|
export {};
|
|
@@ -1,20 +1,5 @@
|
|
|
1
|
-
// This file is part of MIDNIGHT-WALLET-SDK.
|
|
2
|
-
// Copyright (C) Midnight Foundation
|
|
3
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
-
// You may not use this file except in compliance with the License.
|
|
6
|
-
// You may obtain a copy of the License at
|
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
import * as ledger from '@midnightntwrk/ledger-v9';
|
|
14
1
|
import { ProtocolVersion } from '@midnightntwrk/wallet-sdk-abstractions';
|
|
15
|
-
import {
|
|
16
|
-
import { ClientError, ServerError, } from '@midnightntwrk/wallet-sdk-utilities/networking';
|
|
17
|
-
import { Data, Effect, Either, Option, pipe } from 'effect';
|
|
2
|
+
import { Data, Effect, Either, Option } from 'effect';
|
|
18
3
|
export class ProvingError extends Data.TaggedError('Wallet.Proving') {
|
|
19
4
|
}
|
|
20
5
|
/**
|
|
@@ -60,31 +45,10 @@ export const makeVersionedProvingServiceEffect = (services) => ({
|
|
|
60
45
|
export const singleVersionProvingServiceEffect = (service) => ({
|
|
61
46
|
prove: (transaction) => service.prove(transaction),
|
|
62
47
|
});
|
|
63
|
-
const wrapEffectService = (effectService) => ({
|
|
64
|
-
prove: (transaction) => Effect.runPromise(effectService.prove(transaction)),
|
|
65
|
-
});
|
|
66
48
|
/** Adapts a version-routed proving service to the promise-facing surface the facade exposes. */
|
|
67
49
|
export const wrapVersionedEffectService = (effectService) => ({
|
|
68
50
|
prove: (transaction, protocolVersion) => Effect.runPromise(effectService.prove(transaction, protocolVersion)),
|
|
69
51
|
});
|
|
70
|
-
export const fromV9ProvingProviderEffect = (provider) => {
|
|
71
|
-
return {
|
|
72
|
-
prove(transaction) {
|
|
73
|
-
return pipe(provider, Effect.flatMap((provider) => Effect.tryPromise({
|
|
74
|
-
try: () => transaction.prove(provider, ledger.CostModel.initialCostModel()),
|
|
75
|
-
catch: (error) => error instanceof ClientError || error instanceof ServerError
|
|
76
|
-
? error
|
|
77
|
-
: new ClientError({ message: 'Failed to prove transaction', cause: error }),
|
|
78
|
-
})), Effect.catchAll((error) => Effect.fail(new ProvingError({
|
|
79
|
-
message: error.message,
|
|
80
|
-
cause: error,
|
|
81
|
-
}))));
|
|
82
|
-
},
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
export const fromV9ProvingProvider = (provider) => {
|
|
86
|
-
return fromV9ProvingProviderEffect(Effect.succeed(provider));
|
|
87
|
-
};
|
|
88
52
|
/** Raised when the proving configuration names no backend at all. */
|
|
89
53
|
export class ProvingConfigurationError extends Data.TaggedError('@midnightntwrk/wallet-sdk-capabilities/proving/provingService/ProvingConfigurationError') {
|
|
90
54
|
}
|
|
@@ -109,55 +73,3 @@ export const resolveProvingBackends = (configuration) => configuration.provers !
|
|
|
109
73
|
v9: { kind: 'server', url: configuration.provingServerUrl },
|
|
110
74
|
})
|
|
111
75
|
: Either.left(noBackendNamed());
|
|
112
|
-
/**
|
|
113
|
-
* Registers the in-process WASM prover, driven by ledger-v9, from a given protocol version upwards.
|
|
114
|
-
*
|
|
115
|
-
* @remarks
|
|
116
|
-
* Every entry here is ledger-v9's backend, so `sinceVersion` should not be below a protocol boundary: what a version
|
|
117
|
-
* below it needs is the ledger-v8 driver, which `makeDefaultProvingServices` registers for the epoch the fork
|
|
118
|
-
* schedule it is given places below `forks.v9`. Registering nothing below is what turns that into an
|
|
119
|
-
* {@link UnsupportedProvingVersionError} naming the version, rather than a ledger-v8 transaction handed to a ledger
|
|
120
|
-
* that cannot read it.
|
|
121
|
-
* @param sinceVersion The first protocol version to register the bundled prover for.
|
|
122
|
-
* @param configuration Optional key material override.
|
|
123
|
-
* @returns The proving backends, keyed by version.
|
|
124
|
-
*/
|
|
125
|
-
export const makeWasmProvingServices = (sinceVersion, configuration) => ({
|
|
126
|
-
entries: [
|
|
127
|
-
{
|
|
128
|
-
range: ProtocolVersion.makeRange(sinceVersion, ProtocolVersion.MaxSupportedVersion),
|
|
129
|
-
value: makeV9WasmProvingServiceEffect(configuration),
|
|
130
|
-
},
|
|
131
|
-
],
|
|
132
|
-
});
|
|
133
|
-
export const makeV9ServerProvingServiceEffect = (configuration) => {
|
|
134
|
-
return pipe(HttpProverClient.create({
|
|
135
|
-
url: configuration.provingServerUrl,
|
|
136
|
-
}), Effect.map((client) => client.asProvingProvider()), fromV9ProvingProviderEffect);
|
|
137
|
-
};
|
|
138
|
-
/**
|
|
139
|
-
* Proves ledger-v9 transactions in this process.
|
|
140
|
-
*
|
|
141
|
-
* @remarks
|
|
142
|
-
* The ledger-v9 twin of `makeV8WasmProvingServiceEffect`: the same bundled prover, with ledger-v9's key material —
|
|
143
|
-
* circuit generation 10 ({@link WasmProver.makeV9KeyMaterialProvider}) — unless it is given key material of its own.
|
|
144
|
-
* @param configuration Optional key material override.
|
|
145
|
-
* @returns A backend that proves ledger-v9 transactions in-process.
|
|
146
|
-
*/
|
|
147
|
-
export const makeV9WasmProvingServiceEffect = (configuration) => {
|
|
148
|
-
return pipe(WasmProver.create({
|
|
149
|
-
keyMaterialProvider: configuration?.keyMaterialProvider ?? WasmProver.makeV9KeyMaterialProvider(),
|
|
150
|
-
}), Effect.map((prover) => prover.asProvingProvider()), fromV9ProvingProviderEffect);
|
|
151
|
-
};
|
|
152
|
-
export const makeSimulatorProvingServiceEffect = () => {
|
|
153
|
-
return {
|
|
154
|
-
prove(transaction) {
|
|
155
|
-
return Effect.succeed(transaction.eraseProofs());
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
};
|
|
159
|
-
export const makeDefaultProvingServiceEffect = (configuration) => makeV9ServerProvingServiceEffect(configuration);
|
|
160
|
-
export const makeDefaultProvingService = (configuration) => wrapEffectService(makeDefaultProvingServiceEffect(configuration));
|
|
161
|
-
export const makeV9ServerProvingService = (configuration) => wrapEffectService(makeV9ServerProvingServiceEffect(configuration));
|
|
162
|
-
export const makeV9WasmProvingService = (configuration) => wrapEffectService(makeV9WasmProvingServiceEffect(configuration));
|
|
163
|
-
export const makeSimulatorProvingService = () => wrapEffectService(makeSimulatorProvingServiceEffect());
|
|
@@ -2,22 +2,24 @@
|
|
|
2
2
|
* Proving on ledger-v8.
|
|
3
3
|
*
|
|
4
4
|
* @remarks
|
|
5
|
-
* The ledger-v8 twin of
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* The ledger-v8 twin of `v9ProvingService.ts`: structurally the same three steps — obtain a proving provider, drive the
|
|
6
|
+
* transaction's own `prove` with that ledger version's cost model, report failures as a {@link ProvingError} — against
|
|
7
|
+
* a different ledger version's classes. It is the classes that make this a separate module: a ledger-v8 transaction
|
|
8
|
+
* handed ledger-v9's cost model fails at the wasm-bindgen boundary, and a proof-server request framed by ledger-v9 is
|
|
9
|
+
* not the request ledger-v8 would have sent.
|
|
10
10
|
*/
|
|
11
11
|
import * as ledger from '@midnight-ntwrk/ledger-v8';
|
|
12
12
|
import { type InvalidProtocolSchemeError } from '@midnightntwrk/wallet-sdk-utilities/networking';
|
|
13
13
|
import { Effect } from 'effect';
|
|
14
|
-
import { type ProvingServiceEffect, type ServerProvingConfiguration, type WasmProvingConfiguration } from './provingService.js';
|
|
14
|
+
import { type ProvingService, type ProvingServiceEffect, type ServerProvingConfiguration, type WasmProvingConfiguration } from './provingService.js';
|
|
15
15
|
/** A ledger-v8 transaction that has not been proved yet. */
|
|
16
16
|
export type V8UnprovenTransaction = ledger.UnprovenTransaction;
|
|
17
17
|
/** A ledger-v8 transaction that has been proved but not yet bound. */
|
|
18
18
|
export type V8UnboundTransaction = ledger.Transaction<ledger.SignatureEnabled, ledger.Proof, ledger.PreBinding>;
|
|
19
19
|
/** A proving backend written against ledger-v8. */
|
|
20
20
|
export type V8ProvingServiceEffect = ProvingServiceEffect<V8UnboundTransaction, V8UnprovenTransaction>;
|
|
21
|
+
/** The promise-facing surface of a {@link V8ProvingServiceEffect}. */
|
|
22
|
+
export type V8ProvingService = ProvingService<V8UnboundTransaction, V8UnprovenTransaction>;
|
|
21
23
|
/**
|
|
22
24
|
* Drives a ledger-v8 transaction's proving with a low-level proving provider.
|
|
23
25
|
*
|
|
@@ -51,3 +53,28 @@ export declare const makeV8ServerProvingServiceEffect: (configuration: ServerPro
|
|
|
51
53
|
* @returns A backend that proves ledger-v8 transactions in-process.
|
|
52
54
|
*/
|
|
53
55
|
export declare const makeV8WasmProvingServiceEffect: (configuration?: WasmProvingConfiguration) => V8ProvingServiceEffect;
|
|
56
|
+
/**
|
|
57
|
+
* Erases the proofs of ledger-v8 transactions instead of proving them, for the in-memory simulator.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const proving = makeV8SimulatorProvingServiceEffect();
|
|
62
|
+
* const proofErased = yield* proving.prove(unprovenTransaction);
|
|
63
|
+
* yield* simulator.submitTransaction(proofErased);
|
|
64
|
+
* ```;
|
|
65
|
+
*
|
|
66
|
+
* @returns A backend that hands back each ledger-v8 transaction proof-erased, which the simulator accepts.
|
|
67
|
+
*/
|
|
68
|
+
export declare const makeV8SimulatorProvingServiceEffect: () => ProvingServiceEffect<ledger.ProofErasedTransaction, V8UnprovenTransaction>;
|
|
69
|
+
/**
|
|
70
|
+
* The promise-facing surface of {@link makeV8SimulatorProvingServiceEffect}.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const proving = makeV8SimulatorProvingService();
|
|
75
|
+
* const proofErased = await proving.prove(unprovenTransaction);
|
|
76
|
+
* ```;
|
|
77
|
+
*
|
|
78
|
+
* @returns A backend that hands back each ledger-v8 transaction proof-erased, which the simulator accepts.
|
|
79
|
+
*/
|
|
80
|
+
export declare const makeV8SimulatorProvingService: () => ProvingService<ledger.ProofErasedTransaction, V8UnprovenTransaction>;
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
* Proving on ledger-v8.
|
|
15
15
|
*
|
|
16
16
|
* @remarks
|
|
17
|
-
* The ledger-v8 twin of
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
17
|
+
* The ledger-v8 twin of `v9ProvingService.ts`: structurally the same three steps — obtain a proving provider, drive the
|
|
18
|
+
* transaction's own `prove` with that ledger version's cost model, report failures as a {@link ProvingError} — against
|
|
19
|
+
* a different ledger version's classes. It is the classes that make this a separate module: a ledger-v8 transaction
|
|
20
|
+
* handed ledger-v9's cost model fails at the wasm-bindgen boundary, and a proof-server request framed by ledger-v9 is
|
|
21
|
+
* not the request ledger-v8 would have sent.
|
|
22
22
|
*/
|
|
23
23
|
import * as ledger from '@midnight-ntwrk/ledger-v8';
|
|
24
24
|
import { HttpProverClient, WasmProver } from '@midnightntwrk/wallet-sdk-prover-client/effect';
|
|
@@ -69,3 +69,33 @@ export const makeV8ServerProvingServiceEffect = (configuration) => pipe(HttpProv
|
|
|
69
69
|
export const makeV8WasmProvingServiceEffect = (configuration) => pipe(WasmProver.create({
|
|
70
70
|
keyMaterialProvider: configuration?.keyMaterialProvider ?? WasmProver.makeV8KeyMaterialProvider(),
|
|
71
71
|
}), Effect.map((prover) => prover.asProvingProvider()), fromV8ProvingProviderEffect);
|
|
72
|
+
/**
|
|
73
|
+
* Erases the proofs of ledger-v8 transactions instead of proving them, for the in-memory simulator.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const proving = makeV8SimulatorProvingServiceEffect();
|
|
78
|
+
* const proofErased = yield* proving.prove(unprovenTransaction);
|
|
79
|
+
* yield* simulator.submitTransaction(proofErased);
|
|
80
|
+
* ```;
|
|
81
|
+
*
|
|
82
|
+
* @returns A backend that hands back each ledger-v8 transaction proof-erased, which the simulator accepts.
|
|
83
|
+
*/
|
|
84
|
+
export const makeV8SimulatorProvingServiceEffect = () => ({
|
|
85
|
+
prove: (transaction) => Effect.succeed(transaction.eraseProofs()),
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* The promise-facing surface of {@link makeV8SimulatorProvingServiceEffect}.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const proving = makeV8SimulatorProvingService();
|
|
93
|
+
* const proofErased = await proving.prove(unprovenTransaction);
|
|
94
|
+
* ```;
|
|
95
|
+
*
|
|
96
|
+
* @returns A backend that hands back each ledger-v8 transaction proof-erased, which the simulator accepts.
|
|
97
|
+
*/
|
|
98
|
+
export const makeV8SimulatorProvingService = () => {
|
|
99
|
+
const effectService = makeV8SimulatorProvingServiceEffect();
|
|
100
|
+
return { prove: (transaction) => Effect.runPromise(effectService.prove(transaction)) };
|
|
101
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Proving on ledger-v9.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* The ledger-v9 twin of `v8ProvingService.ts`, built on the version-neutral contracts in `provingService.ts`: obtain a
|
|
6
|
+
* proving provider, drive the transaction's own `prove` with ledger-v9's cost model, report failures as a
|
|
7
|
+
* {@link ProvingError}.
|
|
8
|
+
*/
|
|
9
|
+
import * as ledger from '@midnightntwrk/ledger-v9';
|
|
10
|
+
import { type InvalidProtocolSchemeError } from '@midnightntwrk/wallet-sdk-utilities/networking';
|
|
11
|
+
import { Effect } from 'effect';
|
|
12
|
+
import { type ProvingService, type ProvingServiceEffect, type ServerProvingConfiguration, type WasmProvingConfiguration } from './provingService.js';
|
|
13
|
+
/** A ledger-v9 transaction that has not been proved yet. */
|
|
14
|
+
export type V9UnprovenTransaction = ledger.UnprovenTransaction;
|
|
15
|
+
/** A ledger-v9 transaction that has been proved but not yet bound. */
|
|
16
|
+
export type V9UnboundTransaction = ledger.Transaction<ledger.SignatureEnabled, ledger.Proof, ledger.PreBinding>;
|
|
17
|
+
/** A proving backend written against ledger-v9. */
|
|
18
|
+
export type V9ProvingServiceEffect = ProvingServiceEffect<V9UnboundTransaction, V9UnprovenTransaction>;
|
|
19
|
+
/** The promise-facing surface of a {@link V9ProvingServiceEffect}. */
|
|
20
|
+
export type V9ProvingService = ProvingService<V9UnboundTransaction, V9UnprovenTransaction>;
|
|
21
|
+
/**
|
|
22
|
+
* Drives a ledger-v9 transaction's proving with a low-level proving provider.
|
|
23
|
+
*
|
|
24
|
+
* @param provider The proving provider, or the reason one could not be built.
|
|
25
|
+
* @returns A backend that proves ledger-v9 transactions.
|
|
26
|
+
*/
|
|
27
|
+
export declare const fromV9ProvingProviderEffect: (provider: Effect.Effect<ledger.ProvingProvider, InvalidProtocolSchemeError>) => V9ProvingServiceEffect;
|
|
28
|
+
/**
|
|
29
|
+
* Drives a ledger-v9 transaction's proving with a low-level proving provider.
|
|
30
|
+
*
|
|
31
|
+
* @param provider The proving provider.
|
|
32
|
+
* @returns A backend that proves ledger-v9 transactions.
|
|
33
|
+
*/
|
|
34
|
+
export declare const fromV9ProvingProvider: (provider: ledger.ProvingProvider) => V9ProvingServiceEffect;
|
|
35
|
+
/**
|
|
36
|
+
* Proves ledger-v9 transactions at a proof server.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const proving = makeV9ServerProvingServiceEffect({ provingServerUrl: new URL('http://localhost:6300') });
|
|
41
|
+
* const unbound = yield* proving.prove(unprovenTransaction);
|
|
42
|
+
* ```;
|
|
43
|
+
*
|
|
44
|
+
* @param configuration The proof server to send ledger-v9 proving requests to.
|
|
45
|
+
* @returns A backend that proves ledger-v9 transactions over HTTP.
|
|
46
|
+
*/
|
|
47
|
+
export declare const makeV9ServerProvingServiceEffect: (configuration: ServerProvingConfiguration) => V9ProvingServiceEffect;
|
|
48
|
+
/**
|
|
49
|
+
* Proves ledger-v9 transactions in this process.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* The ledger-v9 twin of `makeV8WasmProvingServiceEffect`: the same bundled prover, with ledger-v9's key material —
|
|
53
|
+
* circuit generation 10 ({@link WasmProver.makeV9KeyMaterialProvider}) — unless it is given key material of its own.
|
|
54
|
+
* @param configuration Optional key material override.
|
|
55
|
+
* @returns A backend that proves ledger-v9 transactions in-process.
|
|
56
|
+
*/
|
|
57
|
+
export declare const makeV9WasmProvingServiceEffect: (configuration?: WasmProvingConfiguration) => V9ProvingServiceEffect;
|
|
58
|
+
/**
|
|
59
|
+
* Erases the proofs of ledger-v9 transactions instead of proving them, for the in-memory simulator.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const proving = makeV9SimulatorProvingServiceEffect();
|
|
64
|
+
* const proofErased = yield* proving.prove(unprovenTransaction);
|
|
65
|
+
* yield* simulator.submitTransaction(proofErased);
|
|
66
|
+
* ```;
|
|
67
|
+
*
|
|
68
|
+
* @returns A backend that hands back each ledger-v9 transaction proof-erased, which the simulator accepts.
|
|
69
|
+
*/
|
|
70
|
+
export declare const makeV9SimulatorProvingServiceEffect: () => ProvingServiceEffect<ledger.ProofErasedTransaction, V9UnprovenTransaction>;
|
|
71
|
+
/**
|
|
72
|
+
* The promise-facing surface of {@link makeV9ServerProvingServiceEffect}.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* const proving = makeV9ServerProvingService({ provingServerUrl: new URL('http://localhost:6300') });
|
|
77
|
+
* const unbound = await proving.prove(unprovenTransaction);
|
|
78
|
+
* ```;
|
|
79
|
+
*
|
|
80
|
+
* @param configuration The proof server to send ledger-v9 proving requests to.
|
|
81
|
+
* @returns A backend that proves ledger-v9 transactions over HTTP.
|
|
82
|
+
*/
|
|
83
|
+
export declare const makeV9ServerProvingService: (configuration: ServerProvingConfiguration) => V9ProvingService;
|
|
84
|
+
/**
|
|
85
|
+
* The promise-facing surface of {@link makeV9WasmProvingServiceEffect}.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const proving = makeV9WasmProvingService();
|
|
90
|
+
* const unbound = await proving.prove(unprovenTransaction);
|
|
91
|
+
* ```;
|
|
92
|
+
*
|
|
93
|
+
* @param configuration Optional key material override.
|
|
94
|
+
* @returns A backend that proves ledger-v9 transactions in-process.
|
|
95
|
+
*/
|
|
96
|
+
export declare const makeV9WasmProvingService: (configuration?: WasmProvingConfiguration) => V9ProvingService;
|
|
97
|
+
/**
|
|
98
|
+
* The promise-facing surface of {@link makeV9SimulatorProvingServiceEffect}.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const proving = makeV9SimulatorProvingService();
|
|
103
|
+
* const proofErased = await proving.prove(unprovenTransaction);
|
|
104
|
+
* ```;
|
|
105
|
+
*
|
|
106
|
+
* @returns A backend that hands back each ledger-v9 transaction proof-erased, which the simulator accepts.
|
|
107
|
+
*/
|
|
108
|
+
export declare const makeV9SimulatorProvingService: () => ProvingService<ledger.ProofErasedTransaction, V9UnprovenTransaction>;
|