akash-network / console-old

A self-custodial deploy utility for Akash Network
MIT License
16 stars 20 forks source link

Pre-flight check cert generation refresh is slow (Add Wait/ Load state) #79

Closed anilmurty closed 1 year ago

anilmurty commented 1 year ago

Describe the bug Generating a certificate from the pre-flight check page, can take anywhere from several seconds to several minutes to update certificate state, causing users to either 1) think the app is broken and abandon it or 2) think that they need to regenerate (and click the button multiple times, leading to multiple certs being created).

To Reproduce Steps to reproduce the behavior:

  1. Revoke all certs
  2. Start new deploy
  3. Generate cert from preflight check page
  4. Observe how long it takes to change from "no valid cert red state" to "valid cert, green state"

Expected behavior Should refresh instantaneously (1-2secs) so that the user does not regenerate certificates and/ or doesn't refresh the page (which will cause SDL to be invalid) or assume that the product is broken and give up.

If it is not possible for Console to speed this up (because it is dependent on the RPC node responding after querying the blockchain) then we should AT LEAST add a wait/ loading state.

The specific page is the preflight check page (/new-deployment/akash-games/tetris/preflight-check) not the cert generation page, that needs some kind of loading state to let the user know that the app is waiting on the rpc node (and blockchain) to query the cert list and come back.

So from the state you have (no active certs) - leave that as-is, then go and deploy something (just pick fun & games | tetris for example) and then when you get there and see this page:

Screenshot 2023-03-25 at 10 11 49 AM

When you click generate cert the app will show no wait state but it is actually waiting on the new cert to be available on the blockchain. If you wait long enough or refresh the page, you'll see the state change. This is where we need the wait state

anilmurty commented 1 year ago

This is dependent on the RPC node (and blockchain) responding back with the state of the certificates but we should at least add a wait. state to the user so they know that things are happening

yshsaxena commented 1 year ago

Hi @anilmurty , wanted to work on it, can you please assign it to me. I will happily take it as my first PR :)

yshsaxena commented 1 year ago

Hi @anilmurty, trying to regenerate the issue, am i going in the right direction?

Screenshot 2023-03-25 203937

anilmurty commented 1 year ago

hey @yshsaxena - thanks for helping out on this. The specific page is actually the preflight check page (/new-deployment/akash-games/tetris/preflight-check) not the cert generation page, that needs some kind of loading state to let the user know that the app is waiting on the rpc node (and blockchain) to query the cert list and come back.

So from the state you have (no active certs) - leave that as-is, then go and deploy something (just pick fun & games | tetris for example) and then when you get there and see this page:

Screenshot 2023-03-25 at 10 11 49 AM

When you click generate cert the app will show no wait state but it is actually waiting on the new cert to be available on the blockchain. If you wait long enough or refresh the page, you'll see the state change. This is where we need the wait state

yshsaxena commented 1 year ago

Hi @anilmurty, thanks for your help, what I observed is that "Create Certificate" button in preflight page is same as "Generate new certificate" button in settings, If yes, then shouldn't we use the same code as we are doing in Setting page?

anilmurty commented 1 year ago

@yshsaxena - it should ideally be using the same logic but it is totally possible that it isn't, right now.

My best guess is that it is missing a "setShowProgress(true)" and "refetch()" and some more logic that settings has:

https://github.com/akash-network/console/blob/38caa12b3b8caa3dec9abfea6a6c73ab32cecb0b/web/src/pages/Settings.tsx#L126

 const handleCreateCertificate = React.useCallback(async () => {
    setShowProgress(true);
    await createAndBroadcastCertificate(rpcEndpoint(), keplr);
    refetch();
    setCreateOpen(false);
  }, [keplr]);

vs

https://github.com/akash-network/console/blob/38caa12b3b8caa3dec9abfea6a6c73ab32cecb0b/web/src/pages/PreflightCheck.tsx#L82

const handleCreateCertificate = async () => {
    const result = await createAndBroadcastCertificate(rpcEndpoint(), keplr);

    if (result.code === 0 && result.certificate) {
      setCertificate(result.certificate);
    }
  };

but don't take my word for it -- @jtary is the tech lead for Console and will be able to provide better guidance on the differences and what's needed.

yshsaxena commented 1 year ago

Hi @anilmurty, thanks for assigned it to me, I have came up with this, any suggestions?

https://user-images.githubusercontent.com/45199433/227758000-32cc17f9-4e24-491c-8d94-3b54eeb9849a.mp4

anilmurty commented 1 year ago

@yshsaxena - that looks great! A minor suggestion and a couple questions:

  1. Would suggest changing the copy to "Please wait, creating certificate..." (note "," and lower case "c").
  2. Does it also refresh state once the cert has been generated and read from the blockchain?
  3. When you do raise the PR, please be sure to test a full deployment and confirm it works: https://docs.akash.network/guides/deploy
yshsaxena commented 1 year ago

Hi @anilmurty, thanks for the feedback, let me do a full deployment check then I will be able to give answer of your question, but for that do I have to buy some AKT?

anilmurty commented 1 year ago

@yshsaxena - Please share the keplr AKT wallet address you want to use for deploys here and I'll send you 10 $AKT to use for deployments (you should be able to test 100s of deployments with that, if you don't keep them running and just use for test)

yshsaxena commented 1 year ago

Hi @anilmurty, here is my AKT wallet address "cosmos105ucpt4sqana3ayy0jaylvvtm9qkgsf87dgva8". thanks in advance.

anilmurty commented 1 year ago

@yshsaxena - that's your cosmos wallet. need your akash walllet addr. something like "akash1tf5avu5d4fh..."

yshsaxena commented 1 year ago

"akash105ucpt4sqana3ayy0jaylvvtm9qkgsf8nk9tya"

anilmurty commented 1 year ago

sent - please confirm 10AKT received

yshsaxena commented 1 year ago

received

yshsaxena commented 1 year ago

Yeah!! its working, without refresh, status is changing.

Screenshot 2023-03-26 230954

anilmurty commented 1 year ago

awesome! - once you confirm a deployment (you can test a games | tetris deploy or something simple) and close it out (delete). If that full cycle works, you can raise the PR

yshsaxena commented 1 year ago

Hi @anilmurty, while deploying, it showing me this error, any idea? also just created a certificate last night, now i have only 4.9 ATK.

Screenshot 2023-03-27 094317

anilmurty commented 1 year ago

You need to accept a bid and deploy.

Do you have any open deployments in your deployments list. Close them and you'll get your 5AKT escrow back

anilmurty commented 1 year ago

Check the deploy docs (link I posted above)

yshsaxena commented 1 year ago

What is DSEQ? where will i find it?

Screenshot 2023-03-27 124117

yshsaxena commented 1 year ago

Got it

yshsaxena commented 1 year ago

Hi @anilmurty, I have tested the full deployment and it is working fine, PFB the screenshot.

Screenshot 2023-03-27 132152

anilmurty commented 1 year ago

Good work @yshsaxena ! - this sounds like it is ready for a PR - please open one and @jtary can help review/ merge.

Side note - you may want to close any open deployments from the deployments list, so as to preserve AKT (unless they're actual valid deployments that you want to keep running) Screenshot 2023-03-27 at 9 01 41 AM

yshsaxena commented 1 year ago

Hi @anilmurty, I have raised a Pull request regarding this issue, Kindly review. and please let me know if I did something wrong.

anilmurty commented 1 year ago

Looks good to me. Thanks @yshsaxena. @jtary should be able to review and merge during the US day time.