Skip to content

Commit

Permalink
fix: we are storing heights from base chain into parallel chain (#321)
Browse files Browse the repository at this point in the history
* fix: we are storing heights from base chain into parallel chain

* Improve comment

---------

Co-authored-by: Sebastien Guillemot <[email protected]>
  • Loading branch information
ecioppettini and SebastienGllmt authored Mar 19, 2024
1 parent fb82de7 commit 80b2183
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion packages/engine/paima-sm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { STFSubmittedData } from '@paima/utils';
import {
doLog,
ENV,
GlobalConfig,
InternalEventType,
SCHEDULED_DATA_ADDRESS,
SCHEDULED_DATA_ID,
Expand Down Expand Up @@ -297,8 +298,21 @@ async function processCdeData(
dbTx: PoolClient,
inPresync: boolean
): Promise<number> {
const [mainNetwork, _] = await GlobalConfig.mainEvmConfig();
return await processCdeDataBase(cdeData, dbTx, inPresync, async () => {
await markCdeBlockheightProcessed.run({ block_height: blockHeight, network }, dbTx);
// During the presync,
// we know that the block_height is for that network in particular,
// since the block heights are not mapped in that phase.
// During the sync,
// the blockHeight we are processing here is for the main network instead,
// which doesn't make sense for cde's from other networks.
// To tackle this, we have 2 options:
// 1. Store the original block in ChainDataExtensionDatum
// and then use it to update here
// 2. (what we picked) Through the internal events (see EvmLastBlock)
if (inPresync || network == mainNetwork) {
await markCdeBlockheightProcessed.run({ block_height: blockHeight, network }, dbTx);
}
return;
});
}
Expand Down

0 comments on commit 80b2183

Please sign in to comment.