Skip to content

Commit

Permalink
Back out "missing fills" change
Browse files Browse the repository at this point in the history
Proceeding with the initial "invalid fills" change alone. The subsequent
change can be re-introduced later.
  • Loading branch information
pxrl committed Jan 17, 2024
1 parent 4697b59 commit 093d80b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 54 deletions.
54 changes: 1 addition & 53 deletions src/dataworker/Dataworker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ export class Dataworker {
const chainIds = this.chainIdListForBundleEvaluationBlockNumbers;
const updatedBlockRanges = Object.fromEntries(chainIds.map((chainId, idx) => [chainId, [...blockRanges[idx]]]));

const { deposits, allValidFills, allInvalidFills } = await this.clients.bundleDataClient._loadData(
const { allInvalidFills } = await this.clients.bundleDataClient._loadData(
blockRanges,
spokePoolClients,
isUBA,
Expand Down Expand Up @@ -543,58 +543,6 @@ export class Dataworker {
}
});

// For each deposit within the origin chain block range for which no or only partial fill events are found,
// verify whether the fill has been completed on the destination chain. If the fill has been made to completion
// then this is evidence of potential dropped/suppressed events, so narrow the block range to exclude those blocks.
const newUnfilledDeposits = deposits.filter(({ originChainId, depositId, amount, blockNumber }) => {
if (blockNumber > updatedBlockRanges[originChainId][1]) {
return false; // Fill event is already out of scope due to previous narrowing.
}
return allValidFills.find(
(fill) =>
fill.depositId === depositId && fill.originChainId === originChainId && fill.totalFilledAmount.eq(amount)
)
? false
: true;
});

// For each unfilled or partially filled deposit, verify whether it was actually filled by the proposal end block.
const fillBlocks = await sdk.utils.mapAsync(newUnfilledDeposits, async (deposit: DepositWithBlock) => {
const { spokePool, deploymentBlock } = spokePoolClients[deposit.destinationChainId];
const blockRange = updatedBlockRanges[deposit.destinationChainId];
const endBlock = blockRange[1];

// @todo: Some tests rely on this; fix!
const startBlock = blockRange[0] > deploymentBlock ? blockRange[0] : deploymentBlock;

// @todo: Beware the scenario where the fill is completed before the deposit, yet the deposit hash matches 100%.
// This corner case must be ruled out or mitigated before merge, because it will cause the proposer to throw.
return await sdk.utils.findFillBlock(spokePool, deposit as RelayData, startBlock, endBlock);
});

// Exclude each un- or partially-filled deposit that resolved to a complete fill.
fillBlocks.forEach((fillBlock, idx) => {
if (isDefined(fillBlock)) {
const deposit = newUnfilledDeposits[idx];
const { destinationChainId } = deposit;
const chain = getNetworkName(deposit.destinationChainId);

const newEndBlock = allValidFills
.filter((fill) => fill.destinationChainId === destinationChainId && fill.blockNumber < fillBlock)
.at(-1)?.blockNumber;

const previousBlockRange = updatedBlockRanges[destinationChainId];
updateEndBlock(destinationChainId, newEndBlock);
this.logger.warn({
at: "Dataworker::narrowBlockRanges",
message: `Narrowed proposal block range on ${chain} due to missing fill event at block ${fillBlock}.`,
deposit,
previousBlockRange,
newBlockRange: updatedBlockRanges[destinationChainId],
});
}
});

// Quick sanity check - make sure that the block ranges are coherent. A chain may be soft-paused if it has ongoing
// RPC issues (block ranges are frozen at the previous proposal endBlock), so ensure that this is also handled.
const finalBlockRanges = chainIds.map((chainId) => updatedBlockRanges[chainId]);
Expand Down
2 changes: 1 addition & 1 deletion test/Dataworker.proposeRootBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ describe("Dataworker: Propose root bundle", async function () {
expect(narrowedBlockRanges).to.deep.equal(safeBlockRanges);
});

it("Narrows proposal block ranges for missing fills (destination chain fill gaps)", async function () {
it.skip("Narrows proposal block ranges for missing fills (destination chain fill gaps)", async function () {
// Since the SpokePoolClient relies on SpokePoolClient.latestDepositIdQueried, we can't currently detect
// the _final_ deposit going missing. Some additional refactoring is needed to add this detection.
const missingDepositIdx = Math.floor(Math.random() * (nDeposits - 2));
Expand Down

0 comments on commit 093d80b

Please sign in to comment.