Skip to content

chore: Report invalidFills for determenistic deposits#1457

Open
dijanin-brat wants to merge 7 commits into
masterfrom
dijanin-brat/invalidFillsDetermenisticDeposits
Open

chore: Report invalidFills for determenistic deposits#1457
dijanin-brat wants to merge 7 commits into
masterfrom
dijanin-brat/invalidFillsDetermenisticDeposits

Conversation

@dijanin-brat

Copy link
Copy Markdown
Contributor

No description provided.

@dijanin-brat dijanin-brat self-assigned this Jun 9, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e3bbd37f30

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/utils/SpokeUtils.ts Outdated
Comment on lines +200 to +202
if (getCurrentTime() - fillTimestamp < unsafeDepositGracePeriodSec) {
return null;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Handle expired unsafe IDs instead of falling through

When an unsafe/deterministic fill is older than the grace period and the origin SpokePoolClient has not already indexed a matching deposit, this branch falls through to spokePoolClients[fill.originChainId]?.findDeposit(fill.depositId). The historical lookup path explicitly rejects unsafe IDs (src/arch/evm/SpokeUtils.ts:140-143 and src/arch/svm/SpokeUtils.ts:263-266 throw for isUnsafeDepositId), so findInvalidFills rejects instead of reporting an InvalidFill; the new test masks this by mocking findDeposit to return not found for all IDs.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a39686f you are right

@codex can you re-review again. We should look for deposits only in memory now

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/utils/SpokeUtils.ts Outdated
Comment on lines +201 to +205
if (unsafeDeposit) {
const fillTimestamp = await spokePoolClient.getTimestampForBlock(fill.blockNumber);
if (getCurrentTime() - fillTimestamp < unsafeDepositGracePeriodSec) {
return null;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's relatively expensive to do this lookup if we already have the deposit - wdyt about deferring the timestamp resolution until after we've verified that we don't actually have a deposit for this fill?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, make perfect sense
a66093f

Comment thread src/utils/SpokeUtils.ts Outdated
// deposit to be indexed before treating the fill as invalid.
if (unsafeDeposit) {
const fillTimestamp = await spokePoolClient.getTimestampForBlock(fill.blockNumber);
if (getCurrentTime() - fillTimestamp < unsafeDepositGracePeriodSec) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically on timestamp resolution itself, I'm also wondering if there's something cheaper that we can do - i.e. could we reference the fillDeadline instead? I'm tbf not sure if this works in all cases. An alternative could be to infer the age of the fill based an interpolation of the delta between spokePoolClient.latestHeightSearched and fill.blockNumber, where we multiply by the average block time (we should have that on-hand).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think its smart to use fillDeadline for this.
I think its much better to calculate the timestamp as you have described
a66093f

@dijanin-brat

Copy link
Copy Markdown
Contributor Author

@codex re-review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a66093f5ab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/utils/SpokeUtils.ts
// deposits already indexed in the origin SpokePoolClient's memory.
let deposit;
if (unsafeDeposit) {
deposit = originClient?.getDeposit(fill.depositId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check all deposits sharing an unsafe deposit ID

For deterministic deposits, the same unsafe depositId can be reused for different relay data (the codebase already notes that relying on depositId alone can collide for deterministic IDs). This lookup returns only the first indexed deposit with that ID, so if two unsafe deposits share an ID and the fill corresponds to a later one, validateFillForDeposit will compare against the wrong deposit and report a valid fill as invalid. Please search the indexed origin deposits for a matching relay/deposit rather than a single getDeposit(depositId) result.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants