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

feat(permit): with token name #312

Merged
merged 22 commits into from
Dec 7, 2023
Merged

feat(permit): with token name #312

merged 22 commits into from
Dec 7, 2023

Conversation

alfetopito
Copy link
Collaborator

@alfetopito alfetopito commented Nov 10, 2023

Summary

Addresses last part of #293

Depends on cowprotocol/cowswap#3374

⚠️ cowprotocol/cowswap#3374 must be deployed to PROD before this change can be merged!! ⚠️

Will not work until @cowprotocol/permit-utils is published from cowprotocol/cowswap#3374

Changes

  • Breaking schema change
  • Added name to PermitInfo
  • Added option to re-check unsupported tokens

Testing

Locally, I published @cowprotocol/permit-utils so I could run the script

With it, I updated all existing PermitInfo files

@alfetopito alfetopito self-assigned this Nov 10, 2023
Copy link

socket-security bot commented Nov 10, 2023

New and updated dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
p-retry 6.1.0 None +3 43.1 kB sindresorhus
p-throttle 5.1.0 None +0 8.7 kB sindresorhus
@cowprotocol/permit-utils 0.0.1-RC.1...0.0.1 None +0/-0 26.5 kB cowprotocol_dev

Comment on lines +18 to +20
"recheckPermitInfo:mainnet": "ts-node src/permitInfo/fetchPermitInfo.ts 1 '' '' true",
"recheckPermitInfo:gnosis": "ts-node src/permitInfo/fetchPermitInfo.ts 100 '' '' true",
"recheckPermitInfo:goerli": "ts-node src/permitInfo/fetchPermitInfo.ts 5 '' '' true",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

New helpers to recheck the ones that were previously marked as unsupported

Comment on lines +119 to +129
// Fn can only be called 2x/second
const throttle = pThrottle({
limit: 2,
interval: 1000,
})

const throttledGetTokenPermitInfo = throttle(getTokenPermitInfo)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Throttling the call to try and avoid RPC failures.
Still, every time I run the recheck, new tokens are identified as permittable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it fail a lot? I mean, how many calls w e do per token? shouldn't break if we use our RPC (nodereal)
Is not 2 per second too slow?
What do you mean with "Still, every time I run the recheck, new tokens are identified as permittable." is the script never finishing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ran it today again to get an example:

image

Will see how I can mark those failures as retryable

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Made the script more robust, and added retries.
Still found some new permittable tokens, but not after the retries were introduced.

Comment on lines -33 to -36
{
"type": "boolean",
"description": "When a token is known to not be permittable",
"const": false
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No longer have the type with only false.

Comment on lines +27 to +29
"name": {
"type": "string",
"description": "Token name as defined in the contract"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added name

yarn.lock Outdated Show resolved Hide resolved
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It got a bit verbose...
But look, so many new permittable tokens!!

@alfetopito alfetopito requested a review from a team November 10, 2023 17:32
Copy link
Contributor

@anxolin anxolin left a comment

Choose a reason for hiding this comment

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

Format seems fine to me. Sure, a bit more verbose means more bytes to transfer, but probably don't makes a big difference, so is not worth complicating the interface.

I couldn't test the PR, but i trust you say it worked for you. I don't fully get the part where you say new permeable tokens are detected in each run.

Comment on lines +119 to +129
// Fn can only be called 2x/second
const throttle = pThrottle({
limit: 2,
interval: 1000,
})

const throttledGetTokenPermitInfo = throttle(getTokenPermitInfo)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it fail a lot? I mean, how many calls w e do per token? shouldn't break if we use our RPC (nodereal)
Is not 2 per second too slow?
What do you mean with "Still, every time I run the recheck, new tokens are identified as permittable." is the script never finishing?

yarn.lock Outdated Show resolved Hide resolved
@alfetopito alfetopito force-pushed the permit/with-token-name branch from 0e56c53 to a025b96 Compare November 14, 2023 17:07
@alfetopito alfetopito requested review from a team and anxolin November 17, 2023 11:27
@anxolin anxolin force-pushed the permit/with-token-name branch from cf4c4bf to 868f4e2 Compare December 7, 2023 11:21
@anxolin anxolin marked this pull request as ready for review December 7, 2023 12:06
@@ -3,7 +3,7 @@ import { BASE_PATH } from '../const.ts'
import { Token } from '../types.ts'
import { join } from 'node:path'

export function getTokens(chainId: number, tokenListPath: string | undefined): Array<Token> {
export function getTokensFromTokenList(chainId: number, tokenListPath: string | undefined): Array<Token> {
Copy link
Contributor

Choose a reason for hiding this comment

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

@alfetopito , i believe this method should also filter the tokens by chainId.

I feel unsure if you omitted this on porpoise to discover tokens that are not listed for that specific chain but share the same address as one that is listed

As im unsure, i will play safe here and will NOT change this behaviour. Please, consider doing the filter when you are back

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right, it could as well filter tokens here.
Not a big problem though as they are filtered out later in the script.
This was meant as a simple fn to load tokens from a token list, taking into account that Goerli as a list of its own.

Copy link
Contributor

Choose a reason for hiding this comment

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

Pk, thanks for checking

@anxolin anxolin self-requested a review December 7, 2023 14:25
@anxolin anxolin merged commit 8f10869 into main Dec 7, 2023
5 checks passed
@anxolin anxolin deleted the permit/with-token-name branch December 7, 2023 14:25
@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants