chainapsis / keplr-wallet

The most powerful wallet for the Cosmos ecosystem and the Interchain
https://www.keplr.app
Other
774 stars 463 forks source link

akash: set proper gasPriceStep #1192

Closed andy108369 closed 3 months ago

andy108369 commented 3 months ago

Ensure Akash gas prices are consistent with the parameters specified in the cosmos/chain-registry.


The values should correspond to https://github.com/cosmos/chain-registry/blob/ca50127279cac8a5988aac3e508c107c355eeb5a/akash/chain.json#L19-L21

I couldn't verify whether this PR works since while Keplr Wallet lets me init the wallet (enter 12 word seed, finalize the wallet creation) after building master or v0.12.123, it then simply not opening... it gets stuck at this window: image

Errors: image

This is how I've built it:

nvm install 18
nvm use 18
npm install -g yarn

curl -Lo protoc-21.3.zip https://github.com/protocolbuffers/protobuf/releases/download/v21.3/protoc-21.3-linux-x86_64.zip
unzip protoc-21.3.zip -d $HOME/protoc
sudo cp -r $HOME/protoc/include /usr/local
sudo cp -r $HOME/protoc/bin /usr/local

yarn
yarn build

have then loaded it up apps/extension/build/manifest-v3 up in Google Chrome's chrome://extensions/ with Developer mode enabled.

Verification

To verify, one would need to go to https://console.akash.network and try to deploy something such as Hello World app, using rpc.akashnet.net (Default RPC node, selected in the left bottom corner of the site), and see what fees Keplr is offering to broadcast the user transactions with. They should be around 3000-4000 uakt instead of 300-400 uakt as of right now.

andy108369 commented 3 months ago

Figured it's likely not working for me because it's lacking these variables delivered via Github Secrets as am building it locally: https://github.com/chainapsis/keplr-wallet/blob/v0.12.123/.github/workflows/publish.yml#L32-L49

andy108369 commented 3 months ago

After disabling the minimization, I could narrow down to the bit of code which errors.


## The error

![image](https://github.com/user-attachments/assets/ccba2d43-b17f-4c46-ba77-155c0caf3928)

The project was built with these keys (have extracted them from the release):

export KEPLR_EXT_ANALYTICS_API_URL='https://analytics.keplr.app' export KEPLR_EXT_ANALYTICS_API_AUTH_TOKEN='REDACTED' export KEPLR_EXT_COINGECKO_COIN_DATA_BY_TOKEN_ADDRESS='/coingecko-token-info/coins/{coingeckoChainId}/contract/{contractAddress}' export KEPLR_EXT_COINGECKO_ENDPOINT='/price/simple' export KEPLR_EXT_CHAIN_REGISTRY_URL='https://chain-registry.keplr.app' export KEPLR_EXT_ETHEREUM_ENDPOINT='https://eth-mainnet.g.alchemy.com/v2/REDACTED'

export NODE_ENV=development


Looks like I am missing `KEPLR_EXT_TX_HISTORY_BASE_URL`:

$ git grep baseURL | grep KEPLR apps/extension/src/stores/root.tsx: baseURL: process.env["KEPLR_EXT_TX_HISTORY_BASE_URL"], apps/mobile/src/stores/root.tsx: baseURL: process.env['KEPLR_EXT_TX_HISTORY_BASE_URL'] || '',



## Update

even after setting `KEPLR_EXT_TX_HISTORY_BASE_URL` (by exporting it in bash before `yarn build`) am getting the same error.
I believe the issue is that it gets omitted among with the rest of variables here, due to `NODE_ENV=development`:
https://github.com/chainapsis/keplr-wallet/blob/v0.12.124/apps/extension/webpack.config.js#L180

However, even after setting `NODE_ENV=production` (prior to `yarn && yarn build`) -- am still getting the same error.
Might be that NODE_ENV defaults to `development` when am loading up Chrome extension in Developer mode? (not an expert with the chrome extensions / js)
andy108369 commented 3 months ago

@Thunnini any help please?

andy108369 commented 3 months ago

Ok, made it work by fixing the following function in packages/simple-fetch/src/fetch.ts file:

Didn't require setting none of the KEPLR_EXT_*, NODE_ENV env variables.

before

export function makeURL(baseURL: string, url: string): string {
  const baseURLInstance = new URL(baseURL);
  baseURL = removeLastSlashIfIs(baseURLInstance.origin);
  url =
    removeLastSlashIfIs(baseURLInstance.pathname) +
    "/" +
    removeFirstSlashIfIs(url);

  return removeLastSlashIfIs(baseURL + "/" + removeFirstSlashIfIs(url));
}

after

export function makeURL(baseURL: string, url: string): string {
  try {
    // Validate if baseURL is a valid URL string
    if (typeof baseURL === 'string' && baseURL.startsWith('http')) {
      const baseURLInstance = new URL(baseURL);
      baseURL = removeLastSlashIfIs(baseURLInstance.origin);
      url =
        removeLastSlashIfIs(baseURLInstance.pathname) +
        "/" +
        removeFirstSlashIfIs(url);

      return removeLastSlashIfIs(baseURL + "/" + removeFirstSlashIfIs(url));
    } else {
      throw new Error('Invalid baseURL');
    }
  } catch (error) {
    console.error('Error constructing URL:', error.message);
    return ''; // Or handle the error as appropriate
  }
}

image

cc @Thunnini

andy108369 commented 3 months ago

Figured this PR doesn't do much, it displays the same Low, Average & High values as before (tested v0.12.125). I'm wondering what'd be the best way to tackle this though since some validators running with minimum gas prices set to 0.025 AKT (High) will never accept Low & Average fees set by Keplr Extension.

Neither this value (minimum gas prices) can be queried from the network (RPC/validator) directly. As the Akash validators can be accepting anything between the valid range (including): 0.00025 and 0.025 AKT this becomes rather a challenge. I guess this will work as long as there is at least one validator accepting the lower fees (lower than 0.025 AKT) in the active set.

It would be ideal if a simulation could be run to estimate the required fee in advance, similar to how Keplr handles the Claim All function. However, I'm uncertain if the pre-estimated fee can be directly passed to the Keplr wallet afterward.

before this PR

image

with this PR

image

andy108369 commented 3 months ago

Closing as it appears Keplr already relies upon the Chain Registry values https://github.com/cosmos/chain-registry/blob/ca50127279cac8a5988aac3e508c107c355eeb5a/akash/chain.json#L15-L23

(could see it'd pull akashnet.json with the gasPriceStep in it in the Inspect views: service worker window when debugged Keplr extension)