beamer-bridge / beamer

Beamer - Bridging rollups with L1 inherited security
https://beamerbridge.com
MIT License
45 stars 21 forks source link

feat: use account path for relayer #2126

Closed bilbeyt closed 1 year ago

bilbeyt commented 1 year ago

Closes: #2102

compojoom commented 1 year ago

the js part from my perspective looks ok. I have one remark though: const wallet = Wallet.fromEncryptedJsonSync(encryptedWalletJson, password);

Back in the day when I joined the trustlines team the app was loading the key from keystore json - this very expensive operation and was locking the UI thread for 30+ seconds on some devices. I know that here we run on a server and we can wait, but want to make sure that we are aware of this. https://docs.ethers.org/v5/api/signer/#Wallet-fromEncryptedJsonSync

This operation will operate synchronously which will lock up the user interface, possibly for a non-trivial duration. Most applications should use the asynchronous fromEncryptedJson instead.

Switching to creating the wallet from privatekey made a huge difference in the speed. Not sure if it matters for our use case, but just keep that in mind. Are the other python threads which are working with the other chains going to work?

bilbeyt commented 1 year ago

When we need to call relayer from agent, we will create a keystore file and random password then will pass this path and password to the relayer and then relayer will decrypt it. It will be done only once when relayer initialized, so we wouldnt have any bad effects considering this is not frontend directly.

compojoom commented 1 year ago

What do you mean once? The relayer will have to decode the json file on every start. I don't have a benchmark, maybe on the server it is way faster than on crappy phones... I'm just saying that the relayer is going to become slower when called. That's all

bilbeyt commented 1 year ago

What do you mean once? The relayer will have to decode the json file on every start. I don't have a benchmark, maybe on the server it is way faster than on crappy phones... I'm just saying that the relayer is going to become slower when called. That's all

Yes, comparing doing this on fronted using on relayer with agent server is much faster, but yes it will be called every start and agent has no idea what is happening with relayer so they dont notice a little bit slowness and relayer is also waiting on steps already it can wait 30 secs even

istankovic commented 1 year ago

What do you mean once? The relayer will have to decode the json file on every start. I don't have a benchmark, maybe on the server it is way faster than on crappy phones... I'm just saying that the relayer is going to become slower when called. That's all

Thanks for the note, @compojoom. I don't think this matter here though because the relayer will never be invoked by the frontend, only by the agent, and since it does not happen too often, the slower operation is quite acceptable.

manuelwedler commented 1 year ago

Also had a look and I think it's fine like this. Most of the following functionality after the start depends on the unlocked account. The alternative would be to do it asynchronously and wait in case it is not ready. That would add some complexity which is not worth it imo since we would wait immediately anyway.