Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: validate bids order #124

Merged
merged 1 commit into from
Feb 5, 2024
Merged

fix: validate bids order #124

merged 1 commit into from
Feb 5, 2024

Conversation

nikkaroraa
Copy link
Collaborator

@nikkaroraa nikkaroraa commented Jan 31, 2024

Task:

Fix "validate bids" order

Description

Using Promise.all doesn't guarantee the order in which the promises are going to be resolved. Whichever gets the response first, gets resolved first. As a result of that, the value of filledAmt was getting increased in a random order.

We made this change to incorporate async nonce checks.

Fix is to separately get the nonce check and then synchronously filter the bids in the order that they are supposed to.

Fixes ENG-2045

Type of change

  • New feature
  • Bug fix
  • Testing code
  • Document update or config files

Copy link

linear bot commented Jan 31, 2024

Copy link

vercel bot commented Jan 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
squeeth-portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 31, 2024 7:58am
squeeth-portal-goerli ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 31, 2024 7:58am
squeeth-portal-test ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 31, 2024 7:58am

Copy link
Collaborator

@alpinechicken alpinechicken left a comment

Choose a reason for hiding this comment

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

lgtm

return nonceResults.reduce((acc, { bidder, nonce, isNonceUsed }) => {
acc[`${bidder}-${nonce}`] = isNonceUsed
return acc
}, {} as { [key: string]: boolean })
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question from my javascript ignorance: do we need to give {} as { [key : string]: boolean} for the initial value of the accumulator or could we just give empty array for the reduce?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

here we are dealing with objects, so need to give empty object ie {}. if it'd have been an array, then empty array would have worked

Copy link
Collaborator

@alpinechicken alpinechicken Feb 1, 2024

Choose a reason for hiding this comment

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

that makes sense but would it work if we just gave it {} like

  return nonceResults.reduce((acc, { bidder, nonce, isNonceUsed }) => {
    acc[`${bidder}-${nonce}`] = isNonceUsed
    return acc
  }, {})

@nikkaroraa nikkaroraa merged commit dcb6bb0 into main Feb 5, 2024
5 checks passed
@nikkaroraa nikkaroraa deleted the fix-validate-bids branch February 5, 2024 13:05
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