@ocap/statedb-sqlite 1.31.0 → 1.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/index.d.mts +2 -1
- package/esm/index.mjs +2 -1
- package/esm/tombstone-cleanup.d.mts +59 -0
- package/esm/tombstone-cleanup.mjs +207 -0
- package/lib/index.cjs +7 -0
- package/lib/index.d.cts +2 -1
- package/lib/tombstone-cleanup.cjs +213 -0
- package/lib/tombstone-cleanup.d.cts +59 -0
- package/package.json +8 -8
package/esm/index.d.mts
CHANGED
|
@@ -2,4 +2,5 @@ import { Database, SqliteOperationContext } from "./interfaces.mjs";
|
|
|
2
2
|
import { DurableObjectSqliteDialect, DurableObjectSqliteDialectConfig, IDurableObjectSqlStorage, IDurableObjectSqlStorageCursor, SqliteConfig, createKysely, getRawDatabase } from "./kysely.mjs";
|
|
3
3
|
import SqliteStateDB from "./db.mjs";
|
|
4
4
|
import { ChainStateAuditReport, InvariantSeverity, InvariantViolation, ReconcileAction, ReconcileOptions, ReconcileResult, assertSqliteStateDb, reconcileChainState, verifyChainStateInvariants } from "./reconcile.mjs";
|
|
5
|
-
|
|
5
|
+
import { ApplyTombstoneCleanupOptions, TombstoneBalanceRow, TombstoneCleanupApplyResult, TombstoneCleanupPlan, TombstoneTokenSummary, applyTombstoneBalanceCleanup, compareUpdatedAtTimestamps, computeTombstoneCleanupPlanDigest, extractContextUpdatedAt, isBalanceTimestampNotAfterAccount, planTombstoneBalanceCleanup } from "./tombstone-cleanup.mjs";
|
|
6
|
+
export { type ApplyTombstoneCleanupOptions, type ChainStateAuditReport, type Database, DurableObjectSqliteDialect, type DurableObjectSqliteDialectConfig, type IDurableObjectSqlStorage, type IDurableObjectSqlStorageCursor, type InvariantSeverity, type InvariantViolation, type ReconcileAction, type ReconcileOptions, type ReconcileResult, type SqliteConfig, type SqliteOperationContext, SqliteStateDB, SqliteStateDB as default, type TombstoneBalanceRow, type TombstoneCleanupApplyResult, type TombstoneCleanupPlan, type TombstoneTokenSummary, applyTombstoneBalanceCleanup, assertSqliteStateDb, compareUpdatedAtTimestamps, computeTombstoneCleanupPlanDigest, createKysely, extractContextUpdatedAt, getRawDatabase, isBalanceTimestampNotAfterAccount, planTombstoneBalanceCleanup, reconcileChainState, verifyChainStateInvariants };
|
package/esm/index.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { DurableObjectSqliteDialect, createKysely, getRawDatabase } from "./kysely.mjs";
|
|
2
2
|
import db_default from "./db.mjs";
|
|
3
3
|
import { assertSqliteStateDb, reconcileChainState, verifyChainStateInvariants } from "./reconcile.mjs";
|
|
4
|
+
import { applyTombstoneBalanceCleanup, compareUpdatedAtTimestamps, computeTombstoneCleanupPlanDigest, extractContextUpdatedAt, isBalanceTimestampNotAfterAccount, planTombstoneBalanceCleanup } from "./tombstone-cleanup.mjs";
|
|
4
5
|
|
|
5
6
|
//#region src/index.ts
|
|
6
7
|
var src_default = db_default;
|
|
7
8
|
|
|
8
9
|
//#endregion
|
|
9
|
-
export { DurableObjectSqliteDialect, db_default as SqliteStateDB, assertSqliteStateDb, createKysely, src_default as default, getRawDatabase, reconcileChainState, verifyChainStateInvariants };
|
|
10
|
+
export { DurableObjectSqliteDialect, db_default as SqliteStateDB, applyTombstoneBalanceCleanup, assertSqliteStateDb, compareUpdatedAtTimestamps, computeTombstoneCleanupPlanDigest, createKysely, src_default as default, extractContextUpdatedAt, getRawDatabase, isBalanceTimestampNotAfterAccount, planTombstoneBalanceCleanup, reconcileChainState, verifyChainStateInvariants };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Database } from "./interfaces.mjs";
|
|
2
|
+
import SqliteStateDB from "./db.mjs";
|
|
3
|
+
import { Kysely, Transaction } from "kysely";
|
|
4
|
+
|
|
5
|
+
//#region src/tombstone-cleanup.d.ts
|
|
6
|
+
interface TombstoneBalanceRow {
|
|
7
|
+
accountAddress: string;
|
|
8
|
+
tokenAddress: string;
|
|
9
|
+
balance: string;
|
|
10
|
+
balanceUpdatedAt: string;
|
|
11
|
+
accountUpdatedAt: string;
|
|
12
|
+
migratedTo: string[];
|
|
13
|
+
}
|
|
14
|
+
interface TombstoneTokenSummary {
|
|
15
|
+
tokenAddress: string;
|
|
16
|
+
staleBalanceSum: string;
|
|
17
|
+
rowCount: number;
|
|
18
|
+
accountCount: number;
|
|
19
|
+
}
|
|
20
|
+
interface TombstoneCleanupPlan {
|
|
21
|
+
mode: 'plan';
|
|
22
|
+
totalRows: number;
|
|
23
|
+
totalAccounts: number;
|
|
24
|
+
totalTokens: number;
|
|
25
|
+
perTokenTotals: Record<string, TombstoneTokenSummary>;
|
|
26
|
+
rows: TombstoneBalanceRow[];
|
|
27
|
+
skippedPostMigrationRows: TombstoneBalanceRow[];
|
|
28
|
+
planDigest: string;
|
|
29
|
+
}
|
|
30
|
+
interface ApplyTombstoneCleanupOptions {
|
|
31
|
+
apply: boolean;
|
|
32
|
+
expectedPlanDigest: string;
|
|
33
|
+
}
|
|
34
|
+
interface TombstoneCleanupApplyResult {
|
|
35
|
+
mode: 'apply';
|
|
36
|
+
applied: boolean;
|
|
37
|
+
deletedRows: number;
|
|
38
|
+
deletedAccounts: number;
|
|
39
|
+
perTokenDeletedTotals: Record<string, TombstoneTokenSummary>;
|
|
40
|
+
rows: TombstoneBalanceRow[];
|
|
41
|
+
planDigest: string;
|
|
42
|
+
}
|
|
43
|
+
declare function extractContextUpdatedAt(rawContext: unknown): string;
|
|
44
|
+
declare function compareUpdatedAtTimestamps(a: string, b: string): number;
|
|
45
|
+
declare function isBalanceTimestampNotAfterAccount(balanceUpdatedAt: string, accountUpdatedAt: string): boolean;
|
|
46
|
+
declare function computeTombstoneCleanupPlanDigest(rows: ReadonlyArray<Pick<TombstoneBalanceRow, 'accountAddress' | 'tokenAddress' | 'balance' | 'balanceUpdatedAt'>>): string;
|
|
47
|
+
type KyselyExecutor = Kysely<Database> | Transaction<Database>;
|
|
48
|
+
/**
|
|
49
|
+
* Produce a read-only, deterministic cleanup plan for stale `balance` rows attached to
|
|
50
|
+
* migrated tombstone accounts (`json_array_length(account.migratedTo) > 0` and `balance.updatedAt <= account.updatedAt`).
|
|
51
|
+
*/
|
|
52
|
+
declare function planTombstoneBalanceCleanup(dbOrKysely: SqliteStateDB | KyselyExecutor): Promise<TombstoneCleanupPlan>;
|
|
53
|
+
/**
|
|
54
|
+
* Execute digest-guarded deletion of stale tombstone `balance` rows inside an atomic transaction.
|
|
55
|
+
* Recomputes the plan inside the transaction and aborts if `planDigest !== expectedPlanDigest`.
|
|
56
|
+
*/
|
|
57
|
+
declare function applyTombstoneBalanceCleanup(dbOrKysely: SqliteStateDB | KyselyExecutor, options: ApplyTombstoneCleanupOptions): Promise<TombstoneCleanupApplyResult>;
|
|
58
|
+
//#endregion
|
|
59
|
+
export { ApplyTombstoneCleanupOptions, TombstoneBalanceRow, TombstoneCleanupApplyResult, TombstoneCleanupPlan, TombstoneTokenSummary, applyTombstoneBalanceCleanup, compareUpdatedAtTimestamps, computeTombstoneCleanupPlanDigest, extractContextUpdatedAt, isBalanceTimestampNotAfterAccount, planTombstoneBalanceCleanup };
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { sql } from "kysely";
|
|
3
|
+
import { BN } from "@ocap/util";
|
|
4
|
+
|
|
5
|
+
//#region src/tombstone-cleanup.ts
|
|
6
|
+
const CANONICAL_UINT_REGEX = /^(?:0|[1-9]\d*)$/;
|
|
7
|
+
const SHA256_HEX_REGEX = /^[a-f0-9]{64}$/i;
|
|
8
|
+
function parseJsonValue(raw, fallback) {
|
|
9
|
+
if (raw === null || raw === void 0 || raw === "") return fallback;
|
|
10
|
+
if (typeof raw === "object") return raw;
|
|
11
|
+
if (typeof raw !== "string") return fallback;
|
|
12
|
+
try {
|
|
13
|
+
return JSON.parse(raw) ?? fallback;
|
|
14
|
+
} catch {
|
|
15
|
+
return fallback;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function extractContextUpdatedAt(rawContext) {
|
|
19
|
+
const ctx = parseJsonValue(rawContext, {});
|
|
20
|
+
if (!ctx || typeof ctx !== "object") return "";
|
|
21
|
+
const candidate = ctx.renaissanceTime || ctx.updatedAt || ctx.genesisTime || "";
|
|
22
|
+
return typeof candidate === "string" ? candidate.trim() : String(candidate ?? "").trim();
|
|
23
|
+
}
|
|
24
|
+
function compareUpdatedAtTimestamps(a, b) {
|
|
25
|
+
const normA = a.trim();
|
|
26
|
+
const normB = b.trim();
|
|
27
|
+
if (normA === normB) return 0;
|
|
28
|
+
if (!normA) return -1;
|
|
29
|
+
if (!normB) return 1;
|
|
30
|
+
if (/^-?\d+(?:\.\d+)?$/.test(normA) && /^-?\d+(?:\.\d+)?$/.test(normB)) {
|
|
31
|
+
const numA = Number(normA);
|
|
32
|
+
const numB = Number(normB);
|
|
33
|
+
if (Number.isFinite(numA) && Number.isFinite(numB) && numA !== numB) return numA < numB ? -1 : 1;
|
|
34
|
+
}
|
|
35
|
+
const msA = Date.parse(normA);
|
|
36
|
+
const msB = Date.parse(normB);
|
|
37
|
+
if (Number.isFinite(msA) && Number.isFinite(msB)) {
|
|
38
|
+
if (msA !== msB) return msA < msB ? -1 : 1;
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
return normA < normB ? -1 : 1;
|
|
42
|
+
}
|
|
43
|
+
function isBalanceTimestampNotAfterAccount(balanceUpdatedAt, accountUpdatedAt) {
|
|
44
|
+
const balTs = balanceUpdatedAt.trim();
|
|
45
|
+
const accTs = accountUpdatedAt.trim();
|
|
46
|
+
if (!balTs) return true;
|
|
47
|
+
if (!accTs) return false;
|
|
48
|
+
return compareUpdatedAtTimestamps(balTs, accTs) <= 0;
|
|
49
|
+
}
|
|
50
|
+
function compareTombstoneRows(a, b) {
|
|
51
|
+
if (a.accountAddress !== b.accountAddress) return a.accountAddress < b.accountAddress ? -1 : 1;
|
|
52
|
+
if (a.tokenAddress !== b.tokenAddress) return a.tokenAddress < b.tokenAddress ? -1 : 1;
|
|
53
|
+
return 0;
|
|
54
|
+
}
|
|
55
|
+
function computeTombstoneCleanupPlanDigest(rows) {
|
|
56
|
+
const canonical = [...rows].sort(compareTombstoneRows).map((r) => [
|
|
57
|
+
r.accountAddress,
|
|
58
|
+
r.tokenAddress,
|
|
59
|
+
r.balance,
|
|
60
|
+
r.balanceUpdatedAt
|
|
61
|
+
]);
|
|
62
|
+
return createHash("sha256").update(JSON.stringify(canonical)).digest("hex");
|
|
63
|
+
}
|
|
64
|
+
function buildPerTokenSummaries(rows) {
|
|
65
|
+
const byToken = /* @__PURE__ */ new Map();
|
|
66
|
+
for (const row of rows) {
|
|
67
|
+
const balBn = CANONICAL_UINT_REGEX.test(row.balance) ? new BN(row.balance, 10) : new BN(0);
|
|
68
|
+
const existing = byToken.get(row.tokenAddress);
|
|
69
|
+
if (existing) {
|
|
70
|
+
existing.sum = existing.sum.add(balBn);
|
|
71
|
+
existing.rowCount += 1;
|
|
72
|
+
existing.accounts.add(row.accountAddress);
|
|
73
|
+
} else byToken.set(row.tokenAddress, {
|
|
74
|
+
sum: balBn,
|
|
75
|
+
rowCount: 1,
|
|
76
|
+
accounts: new Set([row.accountAddress])
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const sortedTokenAddresses = Array.from(byToken.keys()).sort();
|
|
80
|
+
const result = {};
|
|
81
|
+
for (const tokenAddress of sortedTokenAddresses) {
|
|
82
|
+
const entry = byToken.get(tokenAddress);
|
|
83
|
+
result[tokenAddress] = {
|
|
84
|
+
tokenAddress,
|
|
85
|
+
staleBalanceSum: entry.sum.toString(10),
|
|
86
|
+
rowCount: entry.rowCount,
|
|
87
|
+
accountCount: entry.accounts.size
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
function isSqliteStateDB(dbOrKysely) {
|
|
93
|
+
const candidate = dbOrKysely;
|
|
94
|
+
return Boolean(candidate && typeof candidate === "object" && typeof candidate.getKysely === "function" && typeof candidate.runAsLambda === "function");
|
|
95
|
+
}
|
|
96
|
+
function resolveKyselyExecutor(dbOrKysely) {
|
|
97
|
+
if (isSqliteStateDB(dbOrKysely)) return dbOrKysely.getKysely();
|
|
98
|
+
return dbOrKysely;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Produce a read-only, deterministic cleanup plan for stale `balance` rows attached to
|
|
102
|
+
* migrated tombstone accounts (`json_array_length(account.migratedTo) > 0` and `balance.updatedAt <= account.updatedAt`).
|
|
103
|
+
*/
|
|
104
|
+
async function planTombstoneBalanceCleanup(dbOrKysely) {
|
|
105
|
+
const rawRows = await resolveKyselyExecutor(dbOrKysely).selectFrom("balance as b").innerJoin("account as a", "b.address", "a.address").where("a.migratedTo", "is not", null).where(sql`CASE WHEN json_valid(a.migratedTo) THEN json_array_length(a.migratedTo) > 0 ELSE 0 END`).select([
|
|
106
|
+
"b.address as accountAddress",
|
|
107
|
+
"b.tokenAddress as tokenAddress",
|
|
108
|
+
"b.balance as balance",
|
|
109
|
+
"b.context as balanceContext",
|
|
110
|
+
"a.migratedTo as migratedTo",
|
|
111
|
+
"a.context as accountContext"
|
|
112
|
+
]).execute();
|
|
113
|
+
const eligibleRows = [];
|
|
114
|
+
const skippedPostMigrationRows = [];
|
|
115
|
+
for (const raw of rawRows) {
|
|
116
|
+
const migratedToRaw = parseJsonValue(raw.migratedTo, []);
|
|
117
|
+
if (!Array.isArray(migratedToRaw)) continue;
|
|
118
|
+
const migratedTo = migratedToRaw.map((x) => String(x ?? "").trim()).filter((x) => x.length > 0);
|
|
119
|
+
if (migratedTo.length === 0) continue;
|
|
120
|
+
const accountAddress = String(raw.accountAddress ?? "");
|
|
121
|
+
const tokenAddress = String(raw.tokenAddress ?? "");
|
|
122
|
+
const balance = String(raw.balance ?? "0");
|
|
123
|
+
const balanceUpdatedAt = extractContextUpdatedAt(raw.balanceContext);
|
|
124
|
+
const accountUpdatedAt = extractContextUpdatedAt(raw.accountContext);
|
|
125
|
+
const row = {
|
|
126
|
+
accountAddress,
|
|
127
|
+
tokenAddress,
|
|
128
|
+
balance,
|
|
129
|
+
balanceUpdatedAt,
|
|
130
|
+
accountUpdatedAt,
|
|
131
|
+
migratedTo
|
|
132
|
+
};
|
|
133
|
+
if (isBalanceTimestampNotAfterAccount(balanceUpdatedAt, accountUpdatedAt)) eligibleRows.push(row);
|
|
134
|
+
else skippedPostMigrationRows.push(row);
|
|
135
|
+
}
|
|
136
|
+
eligibleRows.sort(compareTombstoneRows);
|
|
137
|
+
skippedPostMigrationRows.sort(compareTombstoneRows);
|
|
138
|
+
const perTokenTotals = buildPerTokenSummaries(eligibleRows);
|
|
139
|
+
const uniqueAccounts = new Set(eligibleRows.map((r) => r.accountAddress));
|
|
140
|
+
const planDigest = computeTombstoneCleanupPlanDigest(eligibleRows);
|
|
141
|
+
return {
|
|
142
|
+
mode: "plan",
|
|
143
|
+
totalRows: eligibleRows.length,
|
|
144
|
+
totalAccounts: uniqueAccounts.size,
|
|
145
|
+
totalTokens: Object.keys(perTokenTotals).length,
|
|
146
|
+
perTokenTotals,
|
|
147
|
+
rows: eligibleRows,
|
|
148
|
+
skippedPostMigrationRows,
|
|
149
|
+
planDigest
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Execute digest-guarded deletion of stale tombstone `balance` rows inside an atomic transaction.
|
|
154
|
+
* Recomputes the plan inside the transaction and aborts if `planDigest !== expectedPlanDigest`.
|
|
155
|
+
*/
|
|
156
|
+
async function applyTombstoneBalanceCleanup(dbOrKysely, options) {
|
|
157
|
+
if (!options || options.apply !== true) throw new Error("applyTombstoneBalanceCleanup requires explicit { apply: true }");
|
|
158
|
+
const expectedDigest = String(options.expectedPlanDigest ?? "").trim().toLowerCase();
|
|
159
|
+
if (!SHA256_HEX_REGEX.test(expectedDigest)) throw new Error("applyTombstoneBalanceCleanup requires a valid 64-character SHA-256 expectedPlanDigest");
|
|
160
|
+
const executeInTxn = async (txn) => {
|
|
161
|
+
const freshPlan = await planTombstoneBalanceCleanup(txn);
|
|
162
|
+
if (freshPlan.planDigest.toLowerCase() !== expectedDigest) throw new Error(`PLAN_DIGEST_MISMATCH: expected planDigest "${options.expectedPlanDigest}", but current state produced "${freshPlan.planDigest}"`);
|
|
163
|
+
if (freshPlan.rows.length === 0) return {
|
|
164
|
+
mode: "apply",
|
|
165
|
+
applied: false,
|
|
166
|
+
deletedRows: 0,
|
|
167
|
+
deletedAccounts: 0,
|
|
168
|
+
perTokenDeletedTotals: {},
|
|
169
|
+
rows: [],
|
|
170
|
+
planDigest: freshPlan.planDigest
|
|
171
|
+
};
|
|
172
|
+
let deletedRows = 0;
|
|
173
|
+
const deletedAccountSet = /* @__PURE__ */ new Set();
|
|
174
|
+
for (const row of freshPlan.rows) {
|
|
175
|
+
const accountRow = await txn.selectFrom("account").where("address", "=", row.accountAddress).where("migratedTo", "is not", null).where(sql`CASE WHEN json_valid(migratedTo) THEN json_array_length(migratedTo) > 0 ELSE 0 END`).select([
|
|
176
|
+
"address",
|
|
177
|
+
"context",
|
|
178
|
+
"tokens"
|
|
179
|
+
]).executeTakeFirst();
|
|
180
|
+
if (!accountRow) throw new Error(`TOMBSTONE_STATE_CHANGED: account "${row.accountAddress}" is no longer a migrated tombstone during apply`);
|
|
181
|
+
const currentAccountUpdatedAt = extractContextUpdatedAt(accountRow.context);
|
|
182
|
+
if (!isBalanceTimestampNotAfterAccount(row.balanceUpdatedAt, currentAccountUpdatedAt)) throw new Error(`TOMBSTONE_TIMESTAMP_CHANGED: balance row (${row.accountAddress}, ${row.tokenAddress}) post-dates account timestamp during apply`);
|
|
183
|
+
const delResult = await txn.deleteFrom("balance").where("address", "=", row.accountAddress).where("tokenAddress", "=", row.tokenAddress).where("balance", "=", row.balance).executeTakeFirst();
|
|
184
|
+
const count = Number(delResult.numDeletedRows ?? 0n);
|
|
185
|
+
if (count !== 1) throw new Error(`TOMBSTONE_ROW_CONCURRENT_MODIFICATION: expected to delete 1 balance row for (${row.accountAddress}, ${row.tokenAddress}), deleted ${count}`);
|
|
186
|
+
deletedRows += count;
|
|
187
|
+
deletedAccountSet.add(row.accountAddress);
|
|
188
|
+
if (accountRow.tokens !== null && accountRow.tokens !== void 0 && accountRow.tokens !== "{}") await txn.updateTable("account").set({ tokens: "{}" }).where("address", "=", row.accountAddress).execute();
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
mode: "apply",
|
|
192
|
+
applied: deletedRows > 0,
|
|
193
|
+
deletedRows,
|
|
194
|
+
deletedAccounts: deletedAccountSet.size,
|
|
195
|
+
perTokenDeletedTotals: freshPlan.perTokenTotals,
|
|
196
|
+
rows: freshPlan.rows,
|
|
197
|
+
planDigest: freshPlan.planDigest
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
if (isSqliteStateDB(dbOrKysely)) return dbOrKysely.runAsLambda((txn) => executeInTxn(txn));
|
|
201
|
+
const kysely = resolveKyselyExecutor(dbOrKysely);
|
|
202
|
+
if ("transaction" in kysely && typeof kysely.transaction === "function") return kysely.transaction().execute((txn) => executeInTxn(txn));
|
|
203
|
+
return executeInTxn(kysely);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
//#endregion
|
|
207
|
+
export { applyTombstoneBalanceCleanup, compareUpdatedAtTimestamps, computeTombstoneCleanupPlanDigest, extractContextUpdatedAt, isBalanceTimestampNotAfterAccount, planTombstoneBalanceCleanup };
|
package/lib/index.cjs
CHANGED
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
2
2
|
const require_kysely = require('./kysely.cjs');
|
|
3
3
|
const require_db = require('./db.cjs');
|
|
4
4
|
const require_reconcile = require('./reconcile.cjs');
|
|
5
|
+
const require_tombstone_cleanup = require('./tombstone-cleanup.cjs');
|
|
5
6
|
|
|
6
7
|
//#region src/index.ts
|
|
7
8
|
var src_default = require_db.default;
|
|
@@ -9,9 +10,15 @@ var src_default = require_db.default;
|
|
|
9
10
|
//#endregion
|
|
10
11
|
exports.DurableObjectSqliteDialect = require_kysely.DurableObjectSqliteDialect;
|
|
11
12
|
exports.SqliteStateDB = require_db.default;
|
|
13
|
+
exports.applyTombstoneBalanceCleanup = require_tombstone_cleanup.applyTombstoneBalanceCleanup;
|
|
12
14
|
exports.assertSqliteStateDb = require_reconcile.assertSqliteStateDb;
|
|
15
|
+
exports.compareUpdatedAtTimestamps = require_tombstone_cleanup.compareUpdatedAtTimestamps;
|
|
16
|
+
exports.computeTombstoneCleanupPlanDigest = require_tombstone_cleanup.computeTombstoneCleanupPlanDigest;
|
|
13
17
|
exports.createKysely = require_kysely.createKysely;
|
|
14
18
|
exports.default = src_default;
|
|
19
|
+
exports.extractContextUpdatedAt = require_tombstone_cleanup.extractContextUpdatedAt;
|
|
15
20
|
exports.getRawDatabase = require_kysely.getRawDatabase;
|
|
21
|
+
exports.isBalanceTimestampNotAfterAccount = require_tombstone_cleanup.isBalanceTimestampNotAfterAccount;
|
|
22
|
+
exports.planTombstoneBalanceCleanup = require_tombstone_cleanup.planTombstoneBalanceCleanup;
|
|
16
23
|
exports.reconcileChainState = require_reconcile.reconcileChainState;
|
|
17
24
|
exports.verifyChainStateInvariants = require_reconcile.verifyChainStateInvariants;
|
package/lib/index.d.cts
CHANGED
|
@@ -2,4 +2,5 @@ import { Database, SqliteOperationContext } from "./interfaces.cjs";
|
|
|
2
2
|
import { DurableObjectSqliteDialect, DurableObjectSqliteDialectConfig, IDurableObjectSqlStorage, IDurableObjectSqlStorageCursor, SqliteConfig, createKysely, getRawDatabase } from "./kysely.cjs";
|
|
3
3
|
import SqliteStateDB from "./db.cjs";
|
|
4
4
|
import { ChainStateAuditReport, InvariantSeverity, InvariantViolation, ReconcileAction, ReconcileOptions, ReconcileResult, assertSqliteStateDb, reconcileChainState, verifyChainStateInvariants } from "./reconcile.cjs";
|
|
5
|
-
|
|
5
|
+
import { ApplyTombstoneCleanupOptions, TombstoneBalanceRow, TombstoneCleanupApplyResult, TombstoneCleanupPlan, TombstoneTokenSummary, applyTombstoneBalanceCleanup, compareUpdatedAtTimestamps, computeTombstoneCleanupPlanDigest, extractContextUpdatedAt, isBalanceTimestampNotAfterAccount, planTombstoneBalanceCleanup } from "./tombstone-cleanup.cjs";
|
|
6
|
+
export { type ApplyTombstoneCleanupOptions, type ChainStateAuditReport, type Database, DurableObjectSqliteDialect, type DurableObjectSqliteDialectConfig, type IDurableObjectSqlStorage, type IDurableObjectSqlStorageCursor, type InvariantSeverity, type InvariantViolation, type ReconcileAction, type ReconcileOptions, type ReconcileResult, type SqliteConfig, type SqliteOperationContext, SqliteStateDB, SqliteStateDB as default, type TombstoneBalanceRow, type TombstoneCleanupApplyResult, type TombstoneCleanupPlan, type TombstoneTokenSummary, applyTombstoneBalanceCleanup, assertSqliteStateDb, compareUpdatedAtTimestamps, computeTombstoneCleanupPlanDigest, createKysely, extractContextUpdatedAt, getRawDatabase, isBalanceTimestampNotAfterAccount, planTombstoneBalanceCleanup, reconcileChainState, verifyChainStateInvariants };
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let node_crypto = require("node:crypto");
|
|
3
|
+
let kysely = require("kysely");
|
|
4
|
+
let _ocap_util = require("@ocap/util");
|
|
5
|
+
|
|
6
|
+
//#region src/tombstone-cleanup.ts
|
|
7
|
+
const CANONICAL_UINT_REGEX = /^(?:0|[1-9]\d*)$/;
|
|
8
|
+
const SHA256_HEX_REGEX = /^[a-f0-9]{64}$/i;
|
|
9
|
+
function parseJsonValue(raw, fallback) {
|
|
10
|
+
if (raw === null || raw === void 0 || raw === "") return fallback;
|
|
11
|
+
if (typeof raw === "object") return raw;
|
|
12
|
+
if (typeof raw !== "string") return fallback;
|
|
13
|
+
try {
|
|
14
|
+
return JSON.parse(raw) ?? fallback;
|
|
15
|
+
} catch {
|
|
16
|
+
return fallback;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function extractContextUpdatedAt(rawContext) {
|
|
20
|
+
const ctx = parseJsonValue(rawContext, {});
|
|
21
|
+
if (!ctx || typeof ctx !== "object") return "";
|
|
22
|
+
const candidate = ctx.renaissanceTime || ctx.updatedAt || ctx.genesisTime || "";
|
|
23
|
+
return typeof candidate === "string" ? candidate.trim() : String(candidate ?? "").trim();
|
|
24
|
+
}
|
|
25
|
+
function compareUpdatedAtTimestamps(a, b) {
|
|
26
|
+
const normA = a.trim();
|
|
27
|
+
const normB = b.trim();
|
|
28
|
+
if (normA === normB) return 0;
|
|
29
|
+
if (!normA) return -1;
|
|
30
|
+
if (!normB) return 1;
|
|
31
|
+
if (/^-?\d+(?:\.\d+)?$/.test(normA) && /^-?\d+(?:\.\d+)?$/.test(normB)) {
|
|
32
|
+
const numA = Number(normA);
|
|
33
|
+
const numB = Number(normB);
|
|
34
|
+
if (Number.isFinite(numA) && Number.isFinite(numB) && numA !== numB) return numA < numB ? -1 : 1;
|
|
35
|
+
}
|
|
36
|
+
const msA = Date.parse(normA);
|
|
37
|
+
const msB = Date.parse(normB);
|
|
38
|
+
if (Number.isFinite(msA) && Number.isFinite(msB)) {
|
|
39
|
+
if (msA !== msB) return msA < msB ? -1 : 1;
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
return normA < normB ? -1 : 1;
|
|
43
|
+
}
|
|
44
|
+
function isBalanceTimestampNotAfterAccount(balanceUpdatedAt, accountUpdatedAt) {
|
|
45
|
+
const balTs = balanceUpdatedAt.trim();
|
|
46
|
+
const accTs = accountUpdatedAt.trim();
|
|
47
|
+
if (!balTs) return true;
|
|
48
|
+
if (!accTs) return false;
|
|
49
|
+
return compareUpdatedAtTimestamps(balTs, accTs) <= 0;
|
|
50
|
+
}
|
|
51
|
+
function compareTombstoneRows(a, b) {
|
|
52
|
+
if (a.accountAddress !== b.accountAddress) return a.accountAddress < b.accountAddress ? -1 : 1;
|
|
53
|
+
if (a.tokenAddress !== b.tokenAddress) return a.tokenAddress < b.tokenAddress ? -1 : 1;
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
function computeTombstoneCleanupPlanDigest(rows) {
|
|
57
|
+
const canonical = [...rows].sort(compareTombstoneRows).map((r) => [
|
|
58
|
+
r.accountAddress,
|
|
59
|
+
r.tokenAddress,
|
|
60
|
+
r.balance,
|
|
61
|
+
r.balanceUpdatedAt
|
|
62
|
+
]);
|
|
63
|
+
return (0, node_crypto.createHash)("sha256").update(JSON.stringify(canonical)).digest("hex");
|
|
64
|
+
}
|
|
65
|
+
function buildPerTokenSummaries(rows) {
|
|
66
|
+
const byToken = /* @__PURE__ */ new Map();
|
|
67
|
+
for (const row of rows) {
|
|
68
|
+
const balBn = CANONICAL_UINT_REGEX.test(row.balance) ? new _ocap_util.BN(row.balance, 10) : new _ocap_util.BN(0);
|
|
69
|
+
const existing = byToken.get(row.tokenAddress);
|
|
70
|
+
if (existing) {
|
|
71
|
+
existing.sum = existing.sum.add(balBn);
|
|
72
|
+
existing.rowCount += 1;
|
|
73
|
+
existing.accounts.add(row.accountAddress);
|
|
74
|
+
} else byToken.set(row.tokenAddress, {
|
|
75
|
+
sum: balBn,
|
|
76
|
+
rowCount: 1,
|
|
77
|
+
accounts: new Set([row.accountAddress])
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const sortedTokenAddresses = Array.from(byToken.keys()).sort();
|
|
81
|
+
const result = {};
|
|
82
|
+
for (const tokenAddress of sortedTokenAddresses) {
|
|
83
|
+
const entry = byToken.get(tokenAddress);
|
|
84
|
+
result[tokenAddress] = {
|
|
85
|
+
tokenAddress,
|
|
86
|
+
staleBalanceSum: entry.sum.toString(10),
|
|
87
|
+
rowCount: entry.rowCount,
|
|
88
|
+
accountCount: entry.accounts.size
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
function isSqliteStateDB(dbOrKysely) {
|
|
94
|
+
const candidate = dbOrKysely;
|
|
95
|
+
return Boolean(candidate && typeof candidate === "object" && typeof candidate.getKysely === "function" && typeof candidate.runAsLambda === "function");
|
|
96
|
+
}
|
|
97
|
+
function resolveKyselyExecutor(dbOrKysely) {
|
|
98
|
+
if (isSqliteStateDB(dbOrKysely)) return dbOrKysely.getKysely();
|
|
99
|
+
return dbOrKysely;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Produce a read-only, deterministic cleanup plan for stale `balance` rows attached to
|
|
103
|
+
* migrated tombstone accounts (`json_array_length(account.migratedTo) > 0` and `balance.updatedAt <= account.updatedAt`).
|
|
104
|
+
*/
|
|
105
|
+
async function planTombstoneBalanceCleanup(dbOrKysely) {
|
|
106
|
+
const rawRows = await resolveKyselyExecutor(dbOrKysely).selectFrom("balance as b").innerJoin("account as a", "b.address", "a.address").where("a.migratedTo", "is not", null).where(kysely.sql`CASE WHEN json_valid(a.migratedTo) THEN json_array_length(a.migratedTo) > 0 ELSE 0 END`).select([
|
|
107
|
+
"b.address as accountAddress",
|
|
108
|
+
"b.tokenAddress as tokenAddress",
|
|
109
|
+
"b.balance as balance",
|
|
110
|
+
"b.context as balanceContext",
|
|
111
|
+
"a.migratedTo as migratedTo",
|
|
112
|
+
"a.context as accountContext"
|
|
113
|
+
]).execute();
|
|
114
|
+
const eligibleRows = [];
|
|
115
|
+
const skippedPostMigrationRows = [];
|
|
116
|
+
for (const raw of rawRows) {
|
|
117
|
+
const migratedToRaw = parseJsonValue(raw.migratedTo, []);
|
|
118
|
+
if (!Array.isArray(migratedToRaw)) continue;
|
|
119
|
+
const migratedTo = migratedToRaw.map((x) => String(x ?? "").trim()).filter((x) => x.length > 0);
|
|
120
|
+
if (migratedTo.length === 0) continue;
|
|
121
|
+
const accountAddress = String(raw.accountAddress ?? "");
|
|
122
|
+
const tokenAddress = String(raw.tokenAddress ?? "");
|
|
123
|
+
const balance = String(raw.balance ?? "0");
|
|
124
|
+
const balanceUpdatedAt = extractContextUpdatedAt(raw.balanceContext);
|
|
125
|
+
const accountUpdatedAt = extractContextUpdatedAt(raw.accountContext);
|
|
126
|
+
const row = {
|
|
127
|
+
accountAddress,
|
|
128
|
+
tokenAddress,
|
|
129
|
+
balance,
|
|
130
|
+
balanceUpdatedAt,
|
|
131
|
+
accountUpdatedAt,
|
|
132
|
+
migratedTo
|
|
133
|
+
};
|
|
134
|
+
if (isBalanceTimestampNotAfterAccount(balanceUpdatedAt, accountUpdatedAt)) eligibleRows.push(row);
|
|
135
|
+
else skippedPostMigrationRows.push(row);
|
|
136
|
+
}
|
|
137
|
+
eligibleRows.sort(compareTombstoneRows);
|
|
138
|
+
skippedPostMigrationRows.sort(compareTombstoneRows);
|
|
139
|
+
const perTokenTotals = buildPerTokenSummaries(eligibleRows);
|
|
140
|
+
const uniqueAccounts = new Set(eligibleRows.map((r) => r.accountAddress));
|
|
141
|
+
const planDigest = computeTombstoneCleanupPlanDigest(eligibleRows);
|
|
142
|
+
return {
|
|
143
|
+
mode: "plan",
|
|
144
|
+
totalRows: eligibleRows.length,
|
|
145
|
+
totalAccounts: uniqueAccounts.size,
|
|
146
|
+
totalTokens: Object.keys(perTokenTotals).length,
|
|
147
|
+
perTokenTotals,
|
|
148
|
+
rows: eligibleRows,
|
|
149
|
+
skippedPostMigrationRows,
|
|
150
|
+
planDigest
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Execute digest-guarded deletion of stale tombstone `balance` rows inside an atomic transaction.
|
|
155
|
+
* Recomputes the plan inside the transaction and aborts if `planDigest !== expectedPlanDigest`.
|
|
156
|
+
*/
|
|
157
|
+
async function applyTombstoneBalanceCleanup(dbOrKysely, options) {
|
|
158
|
+
if (!options || options.apply !== true) throw new Error("applyTombstoneBalanceCleanup requires explicit { apply: true }");
|
|
159
|
+
const expectedDigest = String(options.expectedPlanDigest ?? "").trim().toLowerCase();
|
|
160
|
+
if (!SHA256_HEX_REGEX.test(expectedDigest)) throw new Error("applyTombstoneBalanceCleanup requires a valid 64-character SHA-256 expectedPlanDigest");
|
|
161
|
+
const executeInTxn = async (txn) => {
|
|
162
|
+
const freshPlan = await planTombstoneBalanceCleanup(txn);
|
|
163
|
+
if (freshPlan.planDigest.toLowerCase() !== expectedDigest) throw new Error(`PLAN_DIGEST_MISMATCH: expected planDigest "${options.expectedPlanDigest}", but current state produced "${freshPlan.planDigest}"`);
|
|
164
|
+
if (freshPlan.rows.length === 0) return {
|
|
165
|
+
mode: "apply",
|
|
166
|
+
applied: false,
|
|
167
|
+
deletedRows: 0,
|
|
168
|
+
deletedAccounts: 0,
|
|
169
|
+
perTokenDeletedTotals: {},
|
|
170
|
+
rows: [],
|
|
171
|
+
planDigest: freshPlan.planDigest
|
|
172
|
+
};
|
|
173
|
+
let deletedRows = 0;
|
|
174
|
+
const deletedAccountSet = /* @__PURE__ */ new Set();
|
|
175
|
+
for (const row of freshPlan.rows) {
|
|
176
|
+
const accountRow = await txn.selectFrom("account").where("address", "=", row.accountAddress).where("migratedTo", "is not", null).where(kysely.sql`CASE WHEN json_valid(migratedTo) THEN json_array_length(migratedTo) > 0 ELSE 0 END`).select([
|
|
177
|
+
"address",
|
|
178
|
+
"context",
|
|
179
|
+
"tokens"
|
|
180
|
+
]).executeTakeFirst();
|
|
181
|
+
if (!accountRow) throw new Error(`TOMBSTONE_STATE_CHANGED: account "${row.accountAddress}" is no longer a migrated tombstone during apply`);
|
|
182
|
+
const currentAccountUpdatedAt = extractContextUpdatedAt(accountRow.context);
|
|
183
|
+
if (!isBalanceTimestampNotAfterAccount(row.balanceUpdatedAt, currentAccountUpdatedAt)) throw new Error(`TOMBSTONE_TIMESTAMP_CHANGED: balance row (${row.accountAddress}, ${row.tokenAddress}) post-dates account timestamp during apply`);
|
|
184
|
+
const delResult = await txn.deleteFrom("balance").where("address", "=", row.accountAddress).where("tokenAddress", "=", row.tokenAddress).where("balance", "=", row.balance).executeTakeFirst();
|
|
185
|
+
const count = Number(delResult.numDeletedRows ?? 0n);
|
|
186
|
+
if (count !== 1) throw new Error(`TOMBSTONE_ROW_CONCURRENT_MODIFICATION: expected to delete 1 balance row for (${row.accountAddress}, ${row.tokenAddress}), deleted ${count}`);
|
|
187
|
+
deletedRows += count;
|
|
188
|
+
deletedAccountSet.add(row.accountAddress);
|
|
189
|
+
if (accountRow.tokens !== null && accountRow.tokens !== void 0 && accountRow.tokens !== "{}") await txn.updateTable("account").set({ tokens: "{}" }).where("address", "=", row.accountAddress).execute();
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
mode: "apply",
|
|
193
|
+
applied: deletedRows > 0,
|
|
194
|
+
deletedRows,
|
|
195
|
+
deletedAccounts: deletedAccountSet.size,
|
|
196
|
+
perTokenDeletedTotals: freshPlan.perTokenTotals,
|
|
197
|
+
rows: freshPlan.rows,
|
|
198
|
+
planDigest: freshPlan.planDigest
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
if (isSqliteStateDB(dbOrKysely)) return dbOrKysely.runAsLambda((txn) => executeInTxn(txn));
|
|
202
|
+
const kysely$1 = resolveKyselyExecutor(dbOrKysely);
|
|
203
|
+
if ("transaction" in kysely$1 && typeof kysely$1.transaction === "function") return kysely$1.transaction().execute((txn) => executeInTxn(txn));
|
|
204
|
+
return executeInTxn(kysely$1);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
//#endregion
|
|
208
|
+
exports.applyTombstoneBalanceCleanup = applyTombstoneBalanceCleanup;
|
|
209
|
+
exports.compareUpdatedAtTimestamps = compareUpdatedAtTimestamps;
|
|
210
|
+
exports.computeTombstoneCleanupPlanDigest = computeTombstoneCleanupPlanDigest;
|
|
211
|
+
exports.extractContextUpdatedAt = extractContextUpdatedAt;
|
|
212
|
+
exports.isBalanceTimestampNotAfterAccount = isBalanceTimestampNotAfterAccount;
|
|
213
|
+
exports.planTombstoneBalanceCleanup = planTombstoneBalanceCleanup;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Database } from "./interfaces.cjs";
|
|
2
|
+
import SqliteStateDB from "./db.cjs";
|
|
3
|
+
import { Kysely, Transaction } from "kysely";
|
|
4
|
+
|
|
5
|
+
//#region src/tombstone-cleanup.d.ts
|
|
6
|
+
interface TombstoneBalanceRow {
|
|
7
|
+
accountAddress: string;
|
|
8
|
+
tokenAddress: string;
|
|
9
|
+
balance: string;
|
|
10
|
+
balanceUpdatedAt: string;
|
|
11
|
+
accountUpdatedAt: string;
|
|
12
|
+
migratedTo: string[];
|
|
13
|
+
}
|
|
14
|
+
interface TombstoneTokenSummary {
|
|
15
|
+
tokenAddress: string;
|
|
16
|
+
staleBalanceSum: string;
|
|
17
|
+
rowCount: number;
|
|
18
|
+
accountCount: number;
|
|
19
|
+
}
|
|
20
|
+
interface TombstoneCleanupPlan {
|
|
21
|
+
mode: 'plan';
|
|
22
|
+
totalRows: number;
|
|
23
|
+
totalAccounts: number;
|
|
24
|
+
totalTokens: number;
|
|
25
|
+
perTokenTotals: Record<string, TombstoneTokenSummary>;
|
|
26
|
+
rows: TombstoneBalanceRow[];
|
|
27
|
+
skippedPostMigrationRows: TombstoneBalanceRow[];
|
|
28
|
+
planDigest: string;
|
|
29
|
+
}
|
|
30
|
+
interface ApplyTombstoneCleanupOptions {
|
|
31
|
+
apply: boolean;
|
|
32
|
+
expectedPlanDigest: string;
|
|
33
|
+
}
|
|
34
|
+
interface TombstoneCleanupApplyResult {
|
|
35
|
+
mode: 'apply';
|
|
36
|
+
applied: boolean;
|
|
37
|
+
deletedRows: number;
|
|
38
|
+
deletedAccounts: number;
|
|
39
|
+
perTokenDeletedTotals: Record<string, TombstoneTokenSummary>;
|
|
40
|
+
rows: TombstoneBalanceRow[];
|
|
41
|
+
planDigest: string;
|
|
42
|
+
}
|
|
43
|
+
declare function extractContextUpdatedAt(rawContext: unknown): string;
|
|
44
|
+
declare function compareUpdatedAtTimestamps(a: string, b: string): number;
|
|
45
|
+
declare function isBalanceTimestampNotAfterAccount(balanceUpdatedAt: string, accountUpdatedAt: string): boolean;
|
|
46
|
+
declare function computeTombstoneCleanupPlanDigest(rows: ReadonlyArray<Pick<TombstoneBalanceRow, 'accountAddress' | 'tokenAddress' | 'balance' | 'balanceUpdatedAt'>>): string;
|
|
47
|
+
type KyselyExecutor = Kysely<Database> | Transaction<Database>;
|
|
48
|
+
/**
|
|
49
|
+
* Produce a read-only, deterministic cleanup plan for stale `balance` rows attached to
|
|
50
|
+
* migrated tombstone accounts (`json_array_length(account.migratedTo) > 0` and `balance.updatedAt <= account.updatedAt`).
|
|
51
|
+
*/
|
|
52
|
+
declare function planTombstoneBalanceCleanup(dbOrKysely: SqliteStateDB | KyselyExecutor): Promise<TombstoneCleanupPlan>;
|
|
53
|
+
/**
|
|
54
|
+
* Execute digest-guarded deletion of stale tombstone `balance` rows inside an atomic transaction.
|
|
55
|
+
* Recomputes the plan inside the transaction and aborts if `planDigest !== expectedPlanDigest`.
|
|
56
|
+
*/
|
|
57
|
+
declare function applyTombstoneBalanceCleanup(dbOrKysely: SqliteStateDB | KyselyExecutor, options: ApplyTombstoneCleanupOptions): Promise<TombstoneCleanupApplyResult>;
|
|
58
|
+
//#endregion
|
|
59
|
+
export { ApplyTombstoneCleanupOptions, TombstoneBalanceRow, TombstoneCleanupApplyResult, TombstoneCleanupPlan, TombstoneTokenSummary, applyTombstoneBalanceCleanup, compareUpdatedAtTimestamps, computeTombstoneCleanupPlanDigest, extractContextUpdatedAt, isBalanceTimestampNotAfterAccount, planTombstoneBalanceCleanup };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocap/statedb-sqlite",
|
|
3
3
|
"description": "OCAP statedb adapter that uses SQLite as backend",
|
|
4
|
-
"version": "1.31.
|
|
4
|
+
"version": "1.31.1",
|
|
5
5
|
"author": "wangshijun <shijun@arcblock.io> (https://www.arcblock.io)",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/ArcBlock/blockchain/issues",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"wangshijun <shijun@arcblock.io> (https://www.arcblock.io)"
|
|
15
15
|
],
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@ocap/statedb-test": "1.31.
|
|
17
|
+
"@ocap/statedb-test": "1.31.1"
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://github.com/ArcBlock/blockchain/tree/master/statedb/sqlite",
|
|
20
20
|
"keywords": [
|
|
@@ -63,12 +63,12 @@
|
|
|
63
63
|
"clean": "rm -rf lib esm"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@arcblock/did": "1.31.
|
|
67
|
-
"@arcblock/did-util": "1.31.
|
|
68
|
-
"@ocap/state": "1.31.
|
|
69
|
-
"@ocap/statedb": "1.31.
|
|
70
|
-
"@ocap/types": "1.31.
|
|
71
|
-
"@ocap/util": "1.31.
|
|
66
|
+
"@arcblock/did": "1.31.1",
|
|
67
|
+
"@arcblock/did-util": "1.31.1",
|
|
68
|
+
"@ocap/state": "1.31.1",
|
|
69
|
+
"@ocap/statedb": "1.31.1",
|
|
70
|
+
"@ocap/types": "1.31.1",
|
|
71
|
+
"@ocap/util": "1.31.1",
|
|
72
72
|
"better-sqlite3": "^11.8.1",
|
|
73
73
|
"kysely": "^0.28.14",
|
|
74
74
|
"kysely-bun-sqlite": "^0.4.0",
|