-
Notifications
You must be signed in to change notification settings - Fork 43
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: gelato and local signers #1346
Changes from 16 commits
c79fc21
b50d215
91f4cc2
703ef6e
2110f3e
5c6ea57
52b223e
0a70028
8db5ebd
382920f
c9998fa
3029656
fb3d672
a48cf21
2a19907
588abc7
77a0404
10b0173
df1f4c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Client } from "@upstash/qstash"; | ||
|
||
import { RelayRequest, RelayStrategy, RelayStrategyName } from "./_types"; | ||
import { resolveVercelEndpoint } from "../_utils"; | ||
|
||
const client = new Client({ | ||
token: process.env.QSTASH_TOKEN!, | ||
}); | ||
|
||
export async function pushRelayRequestToQueue({ | ||
request, | ||
strategy, | ||
}: { | ||
request: RelayRequest; | ||
strategy: RelayStrategy; | ||
}) { | ||
const strategyName = strategy.strategyName; | ||
const queue = getRelayRequestQueue(strategyName, request.chainId); | ||
await queue.upsert({ | ||
parallelism: strategy.queueParallelism, | ||
}); | ||
|
||
const baseUrl = resolveVercelEndpoint(true); | ||
const response = await queue.enqueueJSON({ | ||
retries: 3, | ||
contentBasedDeduplication: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this solve nonce collision? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea that's the idea. by using a queue and setting parallelism to the number of signers we have, we should be able to mitigate nonce collisions on a single chain. |
||
headers: new Headers({ | ||
"Retry-After": "1", | ||
}), | ||
url: `${baseUrl}/api/relay/jobs/process`, | ||
body: { | ||
request, | ||
strategyName, | ||
}, | ||
}); | ||
return response; | ||
} | ||
|
||
function getRelayRequestQueue( | ||
strategyName: RelayStrategyName, | ||
chainId: number | ||
) { | ||
return client.queue({ | ||
queueName: `relay-request-queue-${chainId}-${strategyName}`, | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is each queue/strategy using different EOAs? If not, how do we avoid nonce collisions between txns submitted within the same block between these queues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it depends on the strategy. for example, if using Gelato, we don't need to handle nonce collisions because they take care of it. if using local signers, then we need to implement a mechanism/handler that's able to prevent nonce collisions.