-
Notifications
You must be signed in to change notification settings - Fork 9
Conversation
sanitizeOps: false, | ||
sanitizeResources: false, |
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.
Smoldot seems to not clear a few timers started in
at start_timer (https://deno.land/x/[email protected]/instance/bindings-smoldot-light.js:107:17)
f43a9b4
to
2b14816
Compare
rpc/client.ts
Outdated
const pendingCall = this.pendingCalls[egressMessageId]; | ||
if (!pendingCall) { | ||
console.log({ e }); | ||
// TODO: pipe error to listeners and message the likely cause, | ||
// a duplicate client. | ||
throw new Error(); | ||
} |
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.
I think this check can be removed.
It happens when the provider is being discarded and an inflight/pending response is emitted.
In that scenario, I assume that we don't care about the response so we can ignore it.
Thoughts @harrysolovay?
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.
Which lines specifically?
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.
if (!pendingCall) {
console.log({ e });
// TODO: pipe error to listeners and message the likely cause,
// a duplicate client.
throw new Error();
}
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.
Gotcha. Removing sounds good.
try { | ||
conn = await connection(chainSpec, listener); | ||
} catch (error) { | ||
listener(new ProviderHandlerError(error as SmoldotHandlerErrorData)); |
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.
Awesome solution!
rpc/client.ts
Outdated
const pendingCall = this.pendingCalls[egressMessageId]; | ||
if (!pendingCall) { | ||
console.log({ e }); | ||
// TODO: pipe error to listeners and message the likely cause, | ||
// a duplicate client. | ||
throw new Error(); | ||
} |
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.
Which lines specifically?
| CrashError | ||
| JsonRpcDisabledError | ||
| AddChainError; | ||
type SmoldotCloseErrorData = AlreadyDestroyedError | CrashError; |
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.
Awesome
rpc/provider/smoldot.ts
Outdated
@@ -67,27 +92,24 @@ async function connection( | |||
} | |||
let conn = connections.get(chainSpec); | |||
if (!conn) { | |||
// TODO: try catch this and send through handler within a `ProviderHandlerError` | |||
const inner = await client.addChain({ chainSpec }); |
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.
for parachain support, all you need to do is to pass in the potentialRelayChains all the chains inner that you collect during the addChain.
Meaning something like:
const inner = await client.addChain({ chainSpec }); | |
const innerMap: Chain[] = []; | |
connections.forEach((value: SmoldotProviderConnection) => { | |
innerMap.push(value.inner); | |
}); | |
const inner = await client.addChain({ chainSpec, potentialRelayChains: innerMap }); |
As described yesterday, smoldot will understand which parachain should go to which chain etc etc.
EDIT: Tested the solution and It works - This is the testing code
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.
thx @wirednkod
The parachain support will be done in a separate PR
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.
@harrysolovay we need to decide 2 things
- 1st when connecting to a parachain, I believe that we need to pass the parachain spec and the potential relay chain spec
- 2nd smoldot connection clean up, given that it takes time to sync the light client, connecting/disconnecting to the same chain will make it slow, so perhaps we can keep the synced state without closing the connections
Thouths?
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.
thx @wirednkod The parachain support will be done in a separate PR
9b5b629
to
b527680
Compare
rpc/provider/smoldot.ts
Outdated
let inner: Chain; | ||
if (typeof chainSpec === "string") { | ||
inner = await client.addChain({ chainSpec }); | ||
} else { | ||
const [parachainSpec, relayChainSpec] = chainSpec; | ||
const relayChainConnection = await client.addChain({ chainSpec: relayChainSpec }); | ||
inner = await client.addChain({ | ||
chainSpec: parachainSpec, | ||
potentialRelayChains: [relayChainConnection], | ||
}); | ||
} |
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.
@harrysolovay @wirednkod WDYT?
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.
Looks fantastic!
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.
Giving my 2 cents here, I think this will strict the user always to start relay chain and parachain at the same spot of the application... IMO these steps should be separated (add relay chain, add parachain) with the same function
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.
thanks for the input @wirednkod
For now, the relay/parachain start will be on demand on the first .send
invocation.
Co-authored-by: Harry Solovay <[email protected]>
b527680
to
e262b4f
Compare
Resolves #376
Description
Improve Smoldot integration for relay chains by
.send
requests to specific.send
callsSmoldot parachain integration will be tacked in an upcoming PR