Skip to content

Commit 1b26bca

Browse files
Antoine de Chevignéclaude
andcommitted
Add OP Stack L1 transaction filtering in blockSync
- Filter L1 transactions to only OP-relevant contracts when workspace has opChildConfigs (similar to existing Orbit filtering) - Include opChildConfigs in initial workspace query to avoid extra DB call - Reuse loaded opChildConfigs for batch detection instead of re-querying Contracts filtered: batchInboxAddress, optimismPortalAddress, l2OutputOracleAddress, disputeGameFactoryAddress, systemConfigAddress 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 91991e2 commit 1b26bca

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

run/jobs/blockSync.js

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ module.exports = async job => {
2929
include: [
3030
'user',
3131
'orbitConfig',
32+
{
33+
model: OpChainConfig,
34+
as: 'opChildConfigs'
35+
},
3236
{
3337
model: Explorer,
3438
as: 'explorer',
@@ -176,14 +180,43 @@ module.exports = async job => {
176180
processedBlock.transactionsCount = filteredTransactions.length;
177181
}
178182

183+
// OP Stack L1 filtering - only sync OP-relevant transactions
184+
if (workspace.opChildConfigs && workspace.opChildConfigs.length > 0) {
185+
let opContractAddresses = [];
186+
187+
for (const opConfig of workspace.opChildConfigs) {
188+
if (opConfig.batchInboxAddress)
189+
opContractAddresses.push(opConfig.batchInboxAddress.toLowerCase());
190+
if (opConfig.optimismPortalAddress)
191+
opContractAddresses.push(opConfig.optimismPortalAddress.toLowerCase());
192+
if (opConfig.l2OutputOracleAddress)
193+
opContractAddresses.push(opConfig.l2OutputOracleAddress.toLowerCase());
194+
if (opConfig.disputeGameFactoryAddress)
195+
opContractAddresses.push(opConfig.disputeGameFactoryAddress.toLowerCase());
196+
if (opConfig.systemConfigAddress)
197+
opContractAddresses.push(opConfig.systemConfigAddress.toLowerCase());
198+
}
199+
200+
opContractAddresses = [...new Set(opContractAddresses)];
201+
202+
const opFilteredTransactions = processedBlock.transactions.filter(tx => {
203+
if (!tx.to) return false;
204+
return opContractAddresses.includes(tx.to.toLowerCase());
205+
});
206+
207+
if (opFilteredTransactions.length > 0)
208+
logger.info(`OP filtered transactions: ${opFilteredTransactions.length}`);
209+
210+
processedBlock.transactions = opFilteredTransactions;
211+
processedBlock.transactionsCount = opFilteredTransactions.length;
212+
}
213+
179214
const syncedBlock = await workspace.safeCreatePartialBlock(processedBlock);
180215
if (!syncedBlock)
181216
return "Couldn't store block";
182217

183-
// OP Stack batch detection - check if this L1 workspace has OP child chains
184-
const opChildConfigs = await OpChainConfig.findAll({
185-
where: { parentWorkspaceId: workspace.id }
186-
});
218+
// OP Stack batch detection - use already-loaded opChildConfigs
219+
const opChildConfigs = workspace.opChildConfigs || [];
187220

188221
for (const opConfig of opChildConfigs) {
189222
if (!opConfig.batchInboxAddress) continue;

0 commit comments

Comments
 (0)