@ocap/chain-node 0.0.0-stage → 1.32.0
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 +234 -2
- package/esm/access-log.d.mts +34 -0
- package/esm/access-log.mjs +71 -0
- package/esm/env.d.mts +32 -0
- package/esm/env.mjs +218 -0
- package/esm/index.d.mts +5 -0
- package/esm/index.mjs +5 -0
- package/esm/standalone-env.d.mts +39 -0
- package/esm/standalone-env.mjs +71 -0
- package/esm/start-chain-node.d.mts +14 -0
- package/esm/start-chain-node.mjs +1102 -0
- package/esm/test-hooks-token.d.mts +12 -0
- package/esm/test-hooks-token.mjs +21 -0
- package/esm/testing.d.mts +13 -0
- package/esm/testing.mjs +23 -0
- package/esm/types.d.mts +293 -0
- package/esm/types.mjs +1 -0
- package/lib/_virtual/rolldown_runtime.cjs +29 -0
- package/lib/access-log.cjs +73 -0
- package/lib/access-log.d.cts +34 -0
- package/lib/env.cjs +221 -0
- package/lib/env.d.cts +32 -0
- package/lib/index.cjs +13 -0
- package/lib/index.d.cts +5 -0
- package/lib/standalone-env.cjs +76 -0
- package/lib/standalone-env.d.cts +39 -0
- package/lib/start-chain-node.cjs +1112 -0
- package/lib/start-chain-node.d.cts +14 -0
- package/lib/test-hooks-token.cjs +24 -0
- package/lib/test-hooks-token.d.cts +12 -0
- package/lib/testing.cjs +23 -0
- package/lib/testing.d.cts +13 -0
- package/lib/types.cjs +0 -0
- package/lib/types.d.cts +293 -0
- package/package.json +78 -4
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChainNodeTestHooks, ChainProfile, RunningChainNode, StartChainNodeOptions } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/start-chain-node.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Boot a unified OCAP chain node (`validator`, `follower`, or `hotstuff`) with a 12-step LIFO rollback guard
|
|
7
|
+
* and 9-step reverse graceful shutdown (`docs/chain-node-design.md` §2.3–§2.4).
|
|
8
|
+
*/
|
|
9
|
+
declare function startChainNode(options: StartChainNodeOptions): Promise<RunningChainNode>;
|
|
10
|
+
declare function startChainNode(profile: ChainProfile & {
|
|
11
|
+
testHooks?: ChainNodeTestHooks;
|
|
12
|
+
}): Promise<RunningChainNode>;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { startChainNode };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
3
|
+
|
|
4
|
+
//#region src/test-hooks-token.ts
|
|
5
|
+
/**
|
|
6
|
+
* Private non-global symbol guarding `ChainNodeTestHooks` (P3-2).
|
|
7
|
+
*
|
|
8
|
+
* Intentionally created via `Symbol(...)` (NEVER `Symbol.for(...)`) and unexported from the
|
|
9
|
+
* `@ocap/chain-node` barrel so JSON/CLI/env payloads and untrusted callers cannot forge it.
|
|
10
|
+
*/
|
|
11
|
+
const CHAIN_NODE_TEST_HOOKS_TOKEN = Symbol("@ocap/chain-node/test-hooks-token");
|
|
12
|
+
function assertNotProductionForTestHooks() {
|
|
13
|
+
if (process.env.NODE_ENV === "production") throw new _ocap_util_lib_error.CustomError("FORBIDDEN_IN_PRODUCTION", "ChainNodeTestHooks cannot be enabled when NODE_ENV=production");
|
|
14
|
+
}
|
|
15
|
+
function assertValidChainNodeTestHooks(candidate) {
|
|
16
|
+
if (candidate === void 0) return;
|
|
17
|
+
assertNotProductionForTestHooks();
|
|
18
|
+
if (!candidate || typeof candidate !== "object" || candidate[CHAIN_NODE_TEST_HOOKS_TOKEN] !== true) throw new _ocap_util_lib_error.CustomError("SECURITY_VIOLATION", "Invalid ChainNodeTestHooks token: must be created via createChainNodeTestHooks from @ocap/chain-node/testing");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
exports.CHAIN_NODE_TEST_HOOKS_TOKEN = CHAIN_NODE_TEST_HOOKS_TOKEN;
|
|
23
|
+
exports.assertNotProductionForTestHooks = assertNotProductionForTestHooks;
|
|
24
|
+
exports.assertValidChainNodeTestHooks = assertValidChainNodeTestHooks;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/test-hooks-token.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Private non-global symbol guarding `ChainNodeTestHooks` (P3-2).
|
|
4
|
+
*
|
|
5
|
+
* Intentionally created via `Symbol(...)` (NEVER `Symbol.for(...)`) and unexported from the
|
|
6
|
+
* `@ocap/chain-node` barrel so JSON/CLI/env payloads and untrusted callers cannot forge it.
|
|
7
|
+
*/
|
|
8
|
+
declare const CHAIN_NODE_TEST_HOOKS_TOKEN: unique symbol;
|
|
9
|
+
declare function assertNotProductionForTestHooks(): void;
|
|
10
|
+
declare function assertValidChainNodeTestHooks(candidate: unknown): void;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { CHAIN_NODE_TEST_HOOKS_TOKEN, assertNotProductionForTestHooks, assertValidChainNodeTestHooks };
|
package/lib/testing.cjs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const require_test_hooks_token = require('./test-hooks-token.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/testing.ts
|
|
4
|
+
/**
|
|
5
|
+
* Construct a token-stamped `ChainNodeTestHooks` object for deterministic tests (`@ocap/chain-node/testing`).
|
|
6
|
+
*
|
|
7
|
+
* Hard-blocked when `process.env.NODE_ENV === 'production'` (`FORBIDDEN_IN_PRODUCTION`), and stamped with a
|
|
8
|
+
* private non-global `Symbol` (`P3-2`) re-verified inside `startChainNode` Step 1.
|
|
9
|
+
*/
|
|
10
|
+
function createChainNodeTestHooks(input = {}) {
|
|
11
|
+
require_test_hooks_token.assertNotProductionForTestHooks();
|
|
12
|
+
const stamped = { ...input };
|
|
13
|
+
Object.defineProperty(stamped, require_test_hooks_token.CHAIN_NODE_TEST_HOOKS_TOKEN, {
|
|
14
|
+
value: true,
|
|
15
|
+
enumerable: false,
|
|
16
|
+
configurable: false,
|
|
17
|
+
writable: false
|
|
18
|
+
});
|
|
19
|
+
return Object.freeze(stamped);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.createChainNodeTestHooks = createChainNodeTestHooks;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChainNodeTestHooks, ChainNodeTestHooksInput, FollowerSyncTestController, FollowerUpstreamInterceptorContext } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/testing.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Construct a token-stamped `ChainNodeTestHooks` object for deterministic tests (`@ocap/chain-node/testing`).
|
|
7
|
+
*
|
|
8
|
+
* Hard-blocked when `process.env.NODE_ENV === 'production'` (`FORBIDDEN_IN_PRODUCTION`), and stamped with a
|
|
9
|
+
* private non-global `Symbol` (`P3-2`) re-verified inside `startChainNode` Step 1.
|
|
10
|
+
*/
|
|
11
|
+
declare function createChainNodeTestHooks(input?: ChainNodeTestHooksInput): ChainNodeTestHooks;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { type ChainNodeTestHooks, type ChainNodeTestHooksInput, type FollowerSyncTestController, type FollowerUpstreamInterceptorContext, createChainNodeTestHooks };
|
package/lib/types.cjs
ADDED
|
File without changes
|
package/lib/types.d.cts
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { CHAIN_NODE_TEST_HOOKS_TOKEN } from "./test-hooks-token.cjs";
|
|
2
|
+
import express from "express";
|
|
3
|
+
import http from "node:http";
|
|
4
|
+
import { AnchorPublisher, ICheckpointSignerWallet, IHotStuffRuntimeValidatorMember, ILedgerHealth, INodeRoleConfig, ISegmentArchiveStore, IWriterLeaseConfig, Ledger, LedgerConfig } from "@arcblock/ledger-core";
|
|
5
|
+
import { SqliteLedgerStorage } from "@arcblock/ledger-sqlite";
|
|
6
|
+
import SqliteIndexDB from "@ocap/indexdb-sqlite";
|
|
7
|
+
import OCAPResolver, { FollowerSyncService, HotStuffNodeRuntime, HotStuffNodeRuntimeOptions, IColdSegmentReader, INodeMaintenanceController, NodePreferencesManager, TFollowerUpstreamFetchKind } from "@ocap/resolver";
|
|
8
|
+
import SqliteStateDB from "@ocap/statedb-sqlite";
|
|
9
|
+
import { SqliteTrustedStorage } from "@ocap/trusted-storage";
|
|
10
|
+
import { IChainConfig, IPipelineLogger, TFollowerSyncMode, TNodeWritePolicy } from "@ocap/types";
|
|
11
|
+
|
|
12
|
+
//#region src/types.d.ts
|
|
13
|
+
type ILedgerLeaseOptions = IWriterLeaseConfig;
|
|
14
|
+
type ILedgerHealthStatus = ILedgerHealth;
|
|
15
|
+
type TNodeRetentionMode = INodeRoleConfig['retentionMode'];
|
|
16
|
+
type ChainNodeSegmentPublisher = NonNullable<LedgerConfig['segmentPublisher']> & {
|
|
17
|
+
getArchiveStore?: () => ISegmentArchiveStore | undefined;
|
|
18
|
+
};
|
|
19
|
+
interface TrustedAccountConfig {
|
|
20
|
+
address: string;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Consensus / proposer signer configuration supporting `ed25519`, standard `secp256k1` (`did:abt:z...`),
|
|
25
|
+
* and Ethereum `0x...` `secp256k1` accounts.
|
|
26
|
+
*/
|
|
27
|
+
interface ChainNodeSignerConfig {
|
|
28
|
+
address: string;
|
|
29
|
+
secretKey: string;
|
|
30
|
+
publicKey?: string;
|
|
31
|
+
keyType?: 'ed25519' | 'secp256k1' | 'eth';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Public-key-only proposer configuration for legacy single-validator chains whose moderator secretKey
|
|
35
|
+
* is held offline (e.g., Blocklet Server `BLOCKLET_APP_PPK` before `CHAIN_CONSENSUS_SK` cutover).
|
|
36
|
+
* Produces unsigned local checkpoints while `storage.trustedStorageSecretKey` signs `trusted.sqlite`.
|
|
37
|
+
*/
|
|
38
|
+
interface PublicKeyOnlyValidatorSignerConfig {
|
|
39
|
+
address: string;
|
|
40
|
+
publicKey?: string;
|
|
41
|
+
secretKey?: undefined;
|
|
42
|
+
keyType?: 'ed25519' | 'secp256k1' | 'eth';
|
|
43
|
+
}
|
|
44
|
+
type ValidatorSignerConfig = ChainNodeSignerConfig | PublicKeyOnlyValidatorSignerConfig;
|
|
45
|
+
type ChainNodeRoleConfig = ValidatorRoleConfig | FollowerRoleConfig | HotStuffValidatorRoleConfig;
|
|
46
|
+
interface ValidatorRoleConfig {
|
|
47
|
+
kind: 'validator';
|
|
48
|
+
signer: ValidatorSignerConfig;
|
|
49
|
+
retentionMode?: TNodeRetentionMode;
|
|
50
|
+
hotWindowEntries?: number;
|
|
51
|
+
hotWindowCheckpoints?: number;
|
|
52
|
+
snapshotBaseUrl?: string | null;
|
|
53
|
+
witnessQuorum?: number;
|
|
54
|
+
trustedWitnesses?: Record<string, string> | string[];
|
|
55
|
+
witnessSubmitUrls?: string[];
|
|
56
|
+
anchorWebhookUrl?: string | null;
|
|
57
|
+
}
|
|
58
|
+
interface FollowerRoleConfig {
|
|
59
|
+
kind: 'follower';
|
|
60
|
+
/** `'reject'` (`FOLLOWER_READ_ONLY`) | `'forward'` (single-hop forward to Leader via `LeaderRouter`) */
|
|
61
|
+
writePolicy: TNodeWritePolicy;
|
|
62
|
+
upstreamChainUrl: string | null;
|
|
63
|
+
clusterPeerUrls?: string[];
|
|
64
|
+
snapshotBaseUrl?: string | null;
|
|
65
|
+
snapshotPrefix?: string;
|
|
66
|
+
trustedProposer?: string | null;
|
|
67
|
+
trustedProposerPublicKey?: string | null;
|
|
68
|
+
hotstuffValidators?: IHotStuffRuntimeValidatorMember[];
|
|
69
|
+
hotstuffQuorumThreshold?: number;
|
|
70
|
+
/** Whether `127.0.0.1` / RFC1918 private peers are allowed (`false` by default for SSRF safety) */
|
|
71
|
+
allowPrivatePeers?: boolean;
|
|
72
|
+
/** Reject cascaded keyless/unsigned follower upstreams with `UPSTREAM_CASCADED_FORBIDDEN` */
|
|
73
|
+
disallowKeylessCascadedUpstream?: boolean;
|
|
74
|
+
allowUnauthenticatedBootstrap?: boolean;
|
|
75
|
+
syncMode?: TFollowerSyncMode;
|
|
76
|
+
pollIntervalMs?: number;
|
|
77
|
+
maxSyncLag?: number;
|
|
78
|
+
maxUpstreamStaleMs?: number;
|
|
79
|
+
retentionMode?: TNodeRetentionMode;
|
|
80
|
+
hotWindowEntries?: number;
|
|
81
|
+
hotWindowCheckpoints?: number;
|
|
82
|
+
witnessWallet?: ICheckpointSignerWallet;
|
|
83
|
+
witnessSubmitUrls?: string[];
|
|
84
|
+
/** Optional Standby consensus signer when running a keyed Standby node */
|
|
85
|
+
signer?: ChainNodeSignerConfig;
|
|
86
|
+
/** Optional explicit runtime role (`'follower'` default or `'standby'`) */
|
|
87
|
+
runtimeRole?: 'follower' | 'standby';
|
|
88
|
+
}
|
|
89
|
+
interface HotStuffValidatorRoleConfig {
|
|
90
|
+
kind: 'hotstuff';
|
|
91
|
+
signer: ChainNodeSignerConfig;
|
|
92
|
+
validators: IHotStuffRuntimeValidatorMember[];
|
|
93
|
+
quorumThreshold?: number;
|
|
94
|
+
consensusBindHost: string;
|
|
95
|
+
consensusPort: number;
|
|
96
|
+
allowPublicConsensusBind?: boolean;
|
|
97
|
+
writePolicy?: TNodeWritePolicy;
|
|
98
|
+
allowPrivatePeers?: boolean;
|
|
99
|
+
retentionMode?: TNodeRetentionMode;
|
|
100
|
+
hotWindowEntries?: number;
|
|
101
|
+
hotWindowCheckpoints?: number;
|
|
102
|
+
snapshotBaseUrl?: string | null;
|
|
103
|
+
witnessQuorum?: number;
|
|
104
|
+
trustedWitnesses?: Record<string, string> | string[];
|
|
105
|
+
witnessSubmitUrls?: string[];
|
|
106
|
+
}
|
|
107
|
+
interface ChainAppHookContext {
|
|
108
|
+
nodeId: string;
|
|
109
|
+
dataDir: string;
|
|
110
|
+
role: ChainNodeRoleConfig['kind'];
|
|
111
|
+
config: IChainConfig;
|
|
112
|
+
statedb: SqliteStateDB;
|
|
113
|
+
indexdb: SqliteIndexDB;
|
|
114
|
+
ledger: Ledger;
|
|
115
|
+
resolver: OCAPResolver;
|
|
116
|
+
preferencesManager: NodePreferencesManager;
|
|
117
|
+
maintenanceController: INodeMaintenanceController;
|
|
118
|
+
}
|
|
119
|
+
interface ChainProfileBase {
|
|
120
|
+
/** Optional explicit nodeId (otherwise loaded/persisted in `<dataDir>/.node-id`) */
|
|
121
|
+
nodeId?: string;
|
|
122
|
+
/** Exclusive node data directory (`statedb.sqlite`, `ledger.sqlite`, `indexdb.sqlite`, `trusted.sqlite`, `.node-id`) */
|
|
123
|
+
dataDir: string;
|
|
124
|
+
http: {
|
|
125
|
+
/** Default `'127.0.0.1'`; pass `'0.0.0.0'` explicitly to listen on all interfaces */
|
|
126
|
+
host?: string;
|
|
127
|
+
/** Pass `0` for OS-assigned ephemeral port; `restart()` reuses the bound port automatically */
|
|
128
|
+
port: number;
|
|
129
|
+
corsOrigins?: string | string[] | boolean;
|
|
130
|
+
drainTimeoutMs?: number;
|
|
131
|
+
enableDashboard?: boolean;
|
|
132
|
+
enableExplorer?: boolean;
|
|
133
|
+
explorerDistDir?: string;
|
|
134
|
+
enableAccessLog?: boolean;
|
|
135
|
+
adminEnv?: Record<string, string | undefined>;
|
|
136
|
+
onGraphqlError?: (err: Error & {
|
|
137
|
+
originalError?: Error;
|
|
138
|
+
}) => void;
|
|
139
|
+
};
|
|
140
|
+
storage?: {
|
|
141
|
+
statedbPath?: string;
|
|
142
|
+
ledgerPath?: string;
|
|
143
|
+
indexdbPath?: string;
|
|
144
|
+
trustedPath?: string;
|
|
145
|
+
entryHashV2?: 'auto' | 'activate';
|
|
146
|
+
walAutoCheckpoint?: number;
|
|
147
|
+
indexWalAutoCheckpoint?: number;
|
|
148
|
+
lease?: ILedgerLeaseOptions | false;
|
|
149
|
+
/** Defaults to `role.signer.secretKey` on Validator/HotStuff; Keyless Follower uses `.follower-trusted.key` */
|
|
150
|
+
trustedStorageSecretKey?: string;
|
|
151
|
+
legacyTrustedSecretKeys?: string[];
|
|
152
|
+
trustedRetryLimit?: number;
|
|
153
|
+
trustedAllowLegacySignatures?: boolean;
|
|
154
|
+
};
|
|
155
|
+
checkpoint?: {
|
|
156
|
+
batchSize?: number;
|
|
157
|
+
timeoutMs?: number;
|
|
158
|
+
auto?: boolean;
|
|
159
|
+
periodicTimer?: boolean;
|
|
160
|
+
timerIntervalMs?: number;
|
|
161
|
+
};
|
|
162
|
+
da?: {
|
|
163
|
+
segmentPublisher?: ChainNodeSegmentPublisher | null;
|
|
164
|
+
coldArchiveReader?: IColdSegmentReader | null;
|
|
165
|
+
anchorPublisher?: AnchorPublisher | null;
|
|
166
|
+
env?: Record<string, string | undefined>;
|
|
167
|
+
};
|
|
168
|
+
genesisTime?: string;
|
|
169
|
+
reservedSymbols?: string[];
|
|
170
|
+
blacklist?: {
|
|
171
|
+
dumpPath?: string;
|
|
172
|
+
dumpIntervalMs?: number;
|
|
173
|
+
staticBlockedAddresses?: string[];
|
|
174
|
+
getTrustedAccounts?: () => Promise<TrustedAccountConfig[]> | TrustedAccountConfig[];
|
|
175
|
+
admissionBlockedCheck?: (addr: string) => boolean;
|
|
176
|
+
admissionReservedSymbolCheck?: (sym: string) => boolean;
|
|
177
|
+
};
|
|
178
|
+
txQueue?: {
|
|
179
|
+
maxRequest?: number;
|
|
180
|
+
concurrent?: number;
|
|
181
|
+
timeoutMs?: number;
|
|
182
|
+
};
|
|
183
|
+
maintenance?: {
|
|
184
|
+
pruneIndexDbFn?: (opts: {
|
|
185
|
+
findOnly?: boolean;
|
|
186
|
+
indexdb: SqliteIndexDB;
|
|
187
|
+
statedb: SqliteStateDB;
|
|
188
|
+
}) => Promise<unknown>;
|
|
189
|
+
requireAllowUpdateTokenDistributionEnv?: boolean;
|
|
190
|
+
env?: Record<string, string | undefined>;
|
|
191
|
+
};
|
|
192
|
+
validateTokenConfig?: boolean;
|
|
193
|
+
logger?: IPipelineLogger;
|
|
194
|
+
configureApp?: (app: express.Express, ctx: ChainAppHookContext) => void | Promise<void>;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Validator / HotStuff profiles require a complete `chainConfig`; Keyless Follower profiles may omit it
|
|
198
|
+
* and rehydrate `IChainConfig` directly from `statedb.sqlite` after snapshot verification.
|
|
199
|
+
*/
|
|
200
|
+
type ChainProfile = (ChainProfileBase & {
|
|
201
|
+
role: ValidatorRoleConfig | HotStuffValidatorRoleConfig;
|
|
202
|
+
chainConfig: IChainConfig;
|
|
203
|
+
}) | (ChainProfileBase & {
|
|
204
|
+
role: FollowerRoleConfig;
|
|
205
|
+
chainConfig?: Partial<IChainConfig>;
|
|
206
|
+
expectedChainId?: string;
|
|
207
|
+
});
|
|
208
|
+
type ChainNodeProfile = ChainProfile;
|
|
209
|
+
interface FollowerUpstreamInterceptorContext {
|
|
210
|
+
kind: TFollowerUpstreamFetchKind;
|
|
211
|
+
url: string;
|
|
212
|
+
init?: RequestInit;
|
|
213
|
+
}
|
|
214
|
+
interface FollowerSyncTestController {
|
|
215
|
+
pause(): void;
|
|
216
|
+
resume(): void;
|
|
217
|
+
isPaused(): boolean;
|
|
218
|
+
triggerSyncOnce(): Promise<void>;
|
|
219
|
+
}
|
|
220
|
+
interface ChainNodeTestHooksInput {
|
|
221
|
+
now?: () => number;
|
|
222
|
+
initialClockOffsetMs?: number;
|
|
223
|
+
initialClockOffsetSeconds?: number;
|
|
224
|
+
checkpoint?: {
|
|
225
|
+
batchSize?: number;
|
|
226
|
+
timeoutMs?: number;
|
|
227
|
+
};
|
|
228
|
+
logger?: IPipelineLogger;
|
|
229
|
+
followerSync?: {
|
|
230
|
+
startPaused?: boolean;
|
|
231
|
+
artificialPollDelayMs?: number;
|
|
232
|
+
interceptUpstreamFetch?: (ctx: FollowerUpstreamInterceptorContext, defaultFetch: typeof fetch) => Promise<Response>;
|
|
233
|
+
onControllerReady?: (ctrl: FollowerSyncTestController) => void;
|
|
234
|
+
};
|
|
235
|
+
hotstuff?: {
|
|
236
|
+
onOutboundConsensusRequest?: HotStuffNodeRuntimeOptions['onOutboundConsensusRequest'];
|
|
237
|
+
/** @deprecated Use `onOutboundConsensusRequest` */
|
|
238
|
+
interceptOutboundRpc?: HotStuffNodeRuntimeOptions['onOutboundConsensusRequest'];
|
|
239
|
+
};
|
|
240
|
+
resolver?: {
|
|
241
|
+
beforeStateDbCommit?: (info: {
|
|
242
|
+
commitHash: string;
|
|
243
|
+
prevHash: string;
|
|
244
|
+
seq: number;
|
|
245
|
+
}) => void | Promise<void>;
|
|
246
|
+
};
|
|
247
|
+
onAfterBoot?: (handles: {
|
|
248
|
+
dataDir: string;
|
|
249
|
+
statedb: SqliteStateDB;
|
|
250
|
+
ledger: Ledger;
|
|
251
|
+
trustedStorage: SqliteTrustedStorage;
|
|
252
|
+
}) => void | Promise<void>;
|
|
253
|
+
}
|
|
254
|
+
interface ChainNodeTestHooks extends ChainNodeTestHooksInput {
|
|
255
|
+
readonly [CHAIN_NODE_TEST_HOOKS_TOKEN]: true;
|
|
256
|
+
}
|
|
257
|
+
interface StartChainNodeOptions {
|
|
258
|
+
profile: ChainProfile;
|
|
259
|
+
testHooks?: ChainNodeTestHooks;
|
|
260
|
+
}
|
|
261
|
+
interface RunningChainNode {
|
|
262
|
+
readonly endpoint: string;
|
|
263
|
+
readonly rpcUrl: string;
|
|
264
|
+
readonly wsUrl: string;
|
|
265
|
+
readonly port: number;
|
|
266
|
+
readonly host: string;
|
|
267
|
+
readonly chainId: string;
|
|
268
|
+
readonly role: ChainNodeRoleConfig['kind'];
|
|
269
|
+
readonly nodeId: string;
|
|
270
|
+
readonly dataDir: string;
|
|
271
|
+
readonly proposerDid: string | null;
|
|
272
|
+
readonly proposerPublicKey: string | null;
|
|
273
|
+
readonly signatureKeyType: 'ed25519' | 'secp256k1' | null;
|
|
274
|
+
readonly app: express.Express;
|
|
275
|
+
readonly resolver: OCAPResolver;
|
|
276
|
+
readonly ledger: Ledger;
|
|
277
|
+
readonly ledgerStorage: SqliteLedgerStorage;
|
|
278
|
+
readonly statedb: SqliteStateDB;
|
|
279
|
+
readonly indexdb: SqliteIndexDB;
|
|
280
|
+
readonly trustedStorage: SqliteTrustedStorage;
|
|
281
|
+
readonly server: http.Server;
|
|
282
|
+
readonly followerSync?: FollowerSyncService;
|
|
283
|
+
readonly hotstuffRuntime?: HotStuffNodeRuntime;
|
|
284
|
+
readonly preferencesManager: NodePreferencesManager;
|
|
285
|
+
readonly maintenanceController: INodeMaintenanceController;
|
|
286
|
+
ledgerHealth(): Promise<ILedgerHealthStatus>;
|
|
287
|
+
advanceClock?(seconds: number): number;
|
|
288
|
+
restart(nextProfile?: Partial<ChainProfile>): Promise<RunningChainNode>;
|
|
289
|
+
stop(): Promise<void>;
|
|
290
|
+
}
|
|
291
|
+
type ChainNodeHandle = RunningChainNode;
|
|
292
|
+
//#endregion
|
|
293
|
+
export { ChainAppHookContext, ChainNodeHandle, ChainNodeProfile, ChainNodeRoleConfig, ChainNodeSegmentPublisher, ChainNodeSignerConfig, ChainNodeTestHooks, ChainNodeTestHooksInput, ChainProfile, ChainProfileBase, FollowerRoleConfig, FollowerSyncTestController, FollowerUpstreamInterceptorContext, HotStuffValidatorRoleConfig, ILedgerHealthStatus, ILedgerLeaseOptions, PublicKeyOnlyValidatorSignerConfig, RunningChainNode, StartChainNodeOptions, TNodeRetentionMode, TrustedAccountConfig, ValidatorRoleConfig, ValidatorSignerConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,80 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/chain-node",
|
|
3
|
-
"
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "1.32.0",
|
|
7
|
+
"description": "Unified OCAP chain node runtime assembly (Validator, Standby, Keyless Follower)",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./lib/index.cjs",
|
|
10
|
+
"module": "./esm/index.mjs",
|
|
11
|
+
"types": "./esm/index.d.mts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./esm/index.d.mts",
|
|
15
|
+
"import": "./esm/index.mjs",
|
|
16
|
+
"default": "./lib/index.cjs"
|
|
17
|
+
},
|
|
18
|
+
"./testing": {
|
|
19
|
+
"types": "./esm/testing.d.mts",
|
|
20
|
+
"import": "./esm/testing.mjs",
|
|
21
|
+
"default": "./lib/testing.cjs"
|
|
22
|
+
},
|
|
23
|
+
"./lib/*.js": {
|
|
24
|
+
"types": "./esm/*.d.mts",
|
|
25
|
+
"import": "./esm/*.mjs",
|
|
26
|
+
"default": "./lib/*.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./lib/*": {
|
|
29
|
+
"types": "./esm/*.d.mts",
|
|
30
|
+
"import": "./esm/*.mjs",
|
|
31
|
+
"default": "./lib/*.cjs"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"lib",
|
|
36
|
+
"esm"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsdown",
|
|
40
|
+
"prebuild": "rm -rf lib esm",
|
|
41
|
+
"lint": "biome check",
|
|
42
|
+
"lint:fix": "biome check --write",
|
|
43
|
+
"test": "bun test",
|
|
44
|
+
"coverage": "npm run test -- --coverage",
|
|
45
|
+
"clean": "rm -rf lib esm"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"ocap",
|
|
49
|
+
"chain-node",
|
|
50
|
+
"ledger",
|
|
51
|
+
"follower",
|
|
52
|
+
"validator"
|
|
53
|
+
],
|
|
54
|
+
"author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
|
|
55
|
+
"license": "MIT",
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@ocap/mcrypto": "1.32.0",
|
|
58
|
+
"@ocap/message": "1.32.0",
|
|
59
|
+
"@types/express": "^4.17.23",
|
|
60
|
+
"@types/node": "^20.10.0",
|
|
61
|
+
"tsdown": "^0.18.4"
|
|
62
|
+
},
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"@arcblock/did": "1.32.0",
|
|
65
|
+
"@arcblock/ledger-core": "1.32.0",
|
|
66
|
+
"@arcblock/ledger-sqlite": "1.32.0",
|
|
67
|
+
"@ocap/config": "1.32.0",
|
|
68
|
+
"@ocap/gql": "1.32.0",
|
|
69
|
+
"@ocap/indexdb-sqlite": "1.32.0",
|
|
70
|
+
"@ocap/resolver": "1.32.0",
|
|
71
|
+
"@ocap/state": "1.32.0",
|
|
72
|
+
"@ocap/statedb-sqlite": "1.32.0",
|
|
73
|
+
"@ocap/trusted-storage": "1.32.0",
|
|
74
|
+
"@ocap/types": "1.32.0",
|
|
75
|
+
"@ocap/util": "1.32.0",
|
|
76
|
+
"@ocap/wallet": "1.32.0",
|
|
77
|
+
"cors": "^2.8.5",
|
|
78
|
+
"express": "^4.22.1"
|
|
79
|
+
}
|
|
80
|
+
}
|