@@ -274,38 +274,29 @@ export class PXEOracleInterface implements ExecutionDataProvider {
274274 * @param sender - The address sending the note
275275 * @param recipient - The address receiving the note
276276 * @returns The computed tag.
277+ * TODO(benesjan): In a follow-up PR this will only return the index and that's it.
277278 */
278- public async getNextAppTagAsSender (
279- contractAddress : AztecAddress ,
280- sender : AztecAddress ,
281- recipient : AztecAddress ,
282- ) : Promise < Fr > {
283- await this . syncTaggedLogsAsSender ( contractAddress , sender , recipient ) ;
284-
285- const directionalAppTaggingSecret = await this . #calculateDirectionalAppTaggingSecret(
286- contractAddress ,
287- sender ,
288- recipient ,
289- ) ;
290- const [ index ] = await this . taggingDataProvider . getTaggingSecretsIndexesAsSender ( [ directionalAppTaggingSecret ] ) ;
279+ public async getNextAppTagAsSender ( directionalAppTaggingSecret : Fr ) : Promise < Fr > {
280+ const index = await this . taggingDataProvider . getTaggingSecretsIndexAsSender ( directionalAppTaggingSecret ) ;
291281
282+ // TODO(benesjan): This will be reworked in a follow-up PR where we will store the new indexes in the db once
283+ // the execution finishes (then we dump the contents of the ExecutionTaggingIndexCache into the db)
292284 // Increment the index for next time
293- const contractName = await this . contractDataProvider . getDebugContractName ( contractAddress ) ;
294- this . log . debug ( `Incrementing app tagging secret at ${ contractName } (${ contractAddress } )` , {
295- directionalAppTaggingSecret,
296- sender,
297- recipient,
298- contractName,
299- contractAddress,
300- } ) ;
301-
285+ // const contractName = await this.contractDataProvider.getDebugContractName(contractAddress);
286+ // this.log.debug(`Incrementing app tagging secret at ${contractName}(${contractAddress})`, {
287+ // directionalAppTaggingSecret,
288+ // sender,
289+ // recipient,
290+ // contractName,
291+ // contractAddress,
292+ // });
302293 await this . taggingDataProvider . setTaggingSecretIndexAsSender ( directionalAppTaggingSecret , index + 1 ) ;
303294
304295 // Compute and return the tag using the current index
305296 return computeTag ( directionalAppTaggingSecret , index ) ;
306297 }
307298
308- async # calculateDirectionalAppTaggingSecret(
299+ public async calculateDirectionalAppTaggingSecret (
309300 contractAddress : AztecAddress ,
310301 sender : AztecAddress ,
311302 recipient : AztecAddress ,
@@ -359,26 +350,8 @@ export class PXEOracleInterface implements ExecutionDataProvider {
359350 } ) ) ;
360351 }
361352
362- /**
363- * Updates the local index of the shared tagging secret of a sender / recipient pair
364- * if a log with a larger index is found from the node.
365- * @param contractAddress - The address of the contract that the logs are tagged for
366- * @param sender - The address of the sender, we must know the sender's ivsk_m.
367- * @param recipient - The address of the recipient.
368- * TODO: This is used only withing PXEOracleInterface and tests so we most likely just want to hide this.
369- */
370- public async syncTaggedLogsAsSender (
371- contractAddress : AztecAddress ,
372- sender : AztecAddress ,
373- recipient : AztecAddress ,
374- ) : Promise < void > {
375- const directionalAppTaggingSecret = await this . #calculateDirectionalAppTaggingSecret(
376- contractAddress ,
377- sender ,
378- recipient ,
379- ) ;
380-
381- const [ oldIndex ] = await this . taggingDataProvider . getTaggingSecretsIndexesAsSender ( [ directionalAppTaggingSecret ] ) ;
353+ public async syncTaggedLogsAsSender ( directionalAppTaggingSecret : Fr , contractAddress : AztecAddress ) : Promise < void > {
354+ const oldIndex = await this . taggingDataProvider . getTaggingSecretsIndexAsSender ( directionalAppTaggingSecret ) ;
382355
383356 // This algorithm works such that:
384357 // 1. If we find minimum consecutive empty logs in a window of logs we set the index to the index of the last log
@@ -417,15 +390,18 @@ export class PXEOracleInterface implements ExecutionDataProvider {
417390 if ( currentIndex !== oldIndex ) {
418391 await this . taggingDataProvider . setTaggingSecretIndexAsSender ( directionalAppTaggingSecret , currentIndex ) ;
419392
420- this . log . debug ( `Syncing logs for sender ${ sender } at contract ${ contractName } (${ contractAddress } )` , {
421- sender,
422- secret : directionalAppTaggingSecret ,
423- index : currentIndex ,
424- contractName,
425- contractAddress,
426- } ) ;
393+ this . log . debug (
394+ `Syncing logs for secret ${ directionalAppTaggingSecret . toString ( ) } at contract ${ contractName } (${ contractAddress } )` ,
395+ {
396+ index : currentIndex ,
397+ contractName,
398+ contractAddress,
399+ } ,
400+ ) ;
427401 } else {
428- this . log . debug ( `No new logs found for sender ${ sender } at contract ${ contractName } (${ contractAddress } )` ) ;
402+ this . log . debug (
403+ `No new logs found for secret ${ directionalAppTaggingSecret . toString ( ) } at contract ${ contractName } (${ contractAddress } )` ,
404+ ) ;
429405 }
430406 }
431407
0 commit comments