-
Notifications
You must be signed in to change notification settings - Fork 29
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
integrations: Remove extra fetching of runtime public key #379
Conversation
✅ Deploy Preview for oasisprotocol-sapphire-paratime canceled.
|
So, this is a workaround for the fact that Viem's code for packing transactions isn't async, meaning when we encrypt a transaction we can't do an RPC request to retrieve the calldata public key. We do the first fetch to retrieve the public key, and then the timer proactively fetches public keys. Without the timer and periodic public key fetching the app will eventually start encrypting transactions with expired keys causing it to fail. It would be good to find a workaround for this, as it's not the best. But just removing it will cause long-running dApps to break. |
It would be good to setup a test case for using Viem from Node CLI to reproduce. And use https://www.npmjs.com/package/wtfnode to see which handles are still active. Could use a let callback = () => {
console.log('Interval tick');
// Your interval logic here
};
const weakCallback = new WeakRef(callback);
const intervalId = setInterval(() => {
const cb = weakCallback.deref();
if (cb) {
cb();
} else {
console.log('Callback has been garbage collected');
clearInterval(intervalId);
}
}, 1000);
// At some point later
callback = null; // Allow the callback to be garbage collected Or we could trap Or we could https://albraga.gitbooks.io/mastering-node-js-book/content/unref-and-ref.html
setTimeout(() => { console.log("now stop"); }, 100);
let intervalId = setInterval(() => { console.log("running") }, 1);
intervalId.unref() |
Or... we could refactor the Viem code to not do any transaction encryption inside the non-async Viem code, and push it all into the provider code? However, last time I tried that it had trouble as it wasn't always going through the provider and I had trouble intercepting calls to the provider. |
@@ -123,9 +123,6 @@ export async function createSapphireSerializer< | |||
const fetcher = new KeyFetcher(); | |||
const provider = client as EthereumProvider; | |||
await fetcher.fetch(provider); | |||
setTimeout(async () => { |
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.
Lets document the reason for having the interval timer.
It be changed to setInterval
, so it's continuous.
And the interval ID should be unref
'd
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.
Agree. unref
seems best right now.
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.
Have you been able to reproduce the problem with a test? Would be good to have this in CI
Closing this in favor of #383 |
Description
Address Node timeout issue encountered by developers.
sapphire-paratime/integrations/viem-v2/src/index.ts
Lines 126 to 128 in 77a2bea
Resolution
I don't think we need the second
fetch
.