diff --git a/packages/engine/paima-funnel/src/funnels/carp/funnel.ts b/packages/engine/paima-funnel/src/funnels/carp/funnel.ts index 67e430559..fb7cb6763 100644 --- a/packages/engine/paima-funnel/src/funnels/carp/funnel.ts +++ b/packages/engine/paima-funnel/src/funnels/carp/funnel.ts @@ -106,36 +106,45 @@ export class CarpFunnel extends BaseFunnel implements ChainFunnel { ): Promise<{ [network: number]: PresyncChainData[] | 'finished' }> { const arg = args.find(arg => arg.network == Network.CARDANO); - let data = await this.baseFunnel.readPresyncData(args); + let basePromise = this.baseFunnel.readPresyncData(args); if (arg && arg.from >= 0 && arg.from < this.startSlot) { - const poolEvents = await Promise.all( - this.sharedData.extensions - .filter(extension => extension.cdeType === ChainDataExtensionType.CardanoPool) - .map(extension => { - const data = getCdePoolData( - this.carpUrl, - extension as ChainDataExtensionCardanoDelegation, - arg.from, - Math.min(arg.to, this.startSlot - 1), - slot => { - return slot; - } - ); - return data; - }) - ); + const [poolEvents, data] = await Promise.all([ + Promise.all( + this.sharedData.extensions + .filter(extension => extension.cdeType === ChainDataExtensionType.CardanoPool) + .map(extension => { + const data = getCdePoolData( + this.carpUrl, + extension as ChainDataExtensionCardanoDelegation, + arg.from, + Math.min(arg.to, this.startSlot - 1), + slot => { + return slot; + } + ); + return data; + }) + ), + basePromise, + ]); let grouped = groupCdeData(Network.CARDANO, arg.from, arg.to, poolEvents); if (grouped.length > 0) { data[Network.CARDANO] = grouped; } - } else if (arg) { - data[Network.CARDANO] = 'finished'; - } - return data; + return data; + } else { + const data = await basePromise; + + if (arg) { + data[Network.CARDANO] = 'finished'; + } + + return data; + } } public static async recoverState( diff --git a/packages/engine/paima-runtime/src/runtime-loops.ts b/packages/engine/paima-runtime/src/runtime-loops.ts index bfb827056..1bcaa419c 100644 --- a/packages/engine/paima-runtime/src/runtime-loops.ts +++ b/packages/engine/paima-runtime/src/runtime-loops.ts @@ -108,7 +108,14 @@ async function runPresync( } await loopIfStopBlockReached(presyncBlockHeight[Network.EVM], stopBlockHeight); - doLog(`[paima-runtime] Presync finished at ${JSON.stringify(presyncBlockHeight)}`); + + const latestPresyncBlockheight = await gameStateMachine.getPresyncBlockHeight(); + doLog(`[paima-runtime] Presync finished at ${latestPresyncBlockheight}`); + + const latestPresyncSlotHeight = await gameStateMachine.getPresyncCardanoSlotHeight(); + if (latestPresyncSlotHeight > 0) { + doLog(`[paima-runtime] Cardano presync finished at ${latestPresyncSlotHeight}`); + } } async function getPresyncStartBlockheight( @@ -154,7 +161,7 @@ async function runPresyncRound( } const filteredPresyncDataList = Object.values(latestPresyncDataList) - .flatMap(network => (network !== 'finished' ? network : [])) + .flatMap(data => (data !== 'finished' ? data : [])) .filter(unit => unit.extensionDatums.length > 0); for (const presyncData of filteredPresyncDataList) { await gameStateMachine.presyncProcess(chainFunnel.getDbTx(), presyncData);