asgardex / asgardex-desktop

ASGARDEX desktop wallet and decentralized exchange for THORChain, 100% open-source
https://www.asgardex.com
MIT License
39 stars 19 forks source link

Avalanche not loading in Asgardex #97

Closed ChilledSilver closed 11 months ago

ChilledSilver commented 11 months ago

The Avalanche blockchain is not loading when opening Asgardex desktop app. I am unable to see my current balance, transact.

Issue description

  1. Open Asgardex desktop
  2. Notice at the top "API RATE LIMIT EXCEEDED". This has already been reported
  3. Scroll down to see your Avalanche balance. See "ERROR" message
  4. Pop out for more details. See "NO PROVIDER ABLE TO GET BALANCE" image

Your Environment

Windows laptop

This did not use to be a problem before in this version so something broke in the backend?

Thorian1te commented 11 months ago

could be fixed with the latest Avax package Everything seems to be working fine on my dev env & 1.20.6v

ChilledSilver commented 11 months ago

Thanks, how do I get that "latest Avax package“?

Thorian1te commented 11 months ago

new release coming soon. it will have the latest Avax package in it

mtfgha commented 11 months ago

I'm also running desktop v1.20.6 but had a different problem with Avalanche. My wallet was created from scratch from an externally generated BIP39 seed phrase, which is perhaps why my experience differed from OP's.

Here's what happened: I performed an ETH->AVAX swap, which succeeded, however my AVAX balance remained zero even after several minutes had passed. Then I noticed that the wallet's ETH and AVAX addresses are the same! (As is the BNB address, by the way.) Of course this is an error, as AVAX has its own address format which differs from ETH's. Not to mention that the wallet ought to be using a different derivation path for the two coins.

A Midgard API query to the ETH address on the ETH chain revealed that the TX memo indeed read =:AVAX.AVAX:(ETH address)..., while a query to the address on the AVAX chain showed nothing.

Strangely enough, the funds did eventually show up, about 40 minutes later, both in the Midgard query and in the wallet (!).

So now I'm left wondering whether my AVAX balance is spendable, and if so, whether it will remain spendable after the new release. Currently ETH and AVAX share the same privkey/pubkey pair, but I assume after the fix this will not be the case.

I've also noticed that ERC20 and Binance Chain tokens are missing in the wallet. Perhaps this is a related problem? Just for the record: I've made some successful BTC->RUNE and BTC->ETH swaps with the wallet, so these coins seem to be working as they should.

Thorian1te commented 11 months ago
  1. xchain-crypto uses BIP39 as well - a package that is used by Asgardex.
  2. There is an outbound Delay on Thorchain, (attribute this to your funds arriving 40 mins later) you can always Track the tx. (a link in the tx modal)
  3. Both Ethereum and Avalanche's C-Chain (one of the three chains in the Avalanche network) use the Ethereum Virtual Machine (EVM). Because of this, they share the same address format and generation method, which is based on the public key derived from the user's private key. You sound confused here, pls go away and do some research
  4. Considering the above, it will be spendable
mtfgha commented 11 months ago

Thanks for getting back to me. Now I understand the reason for the delay.

However, AVAX is traded on the X-chain, is it not?

Quoting from https://docs.avax.network/learn/avalanche/avalanche-platform:

X-Chain

The X-Chain is responsible for operations on digital smart assets known as Avalanche Native Tokens. A smart asset is a representation of a real-world resource (for example, equity, or a bond) with sets of rules that govern its behavior, like "can’t be traded until tomorrow." The X-Chain API supports the creation and trade of Avalanche Native Tokens.

One asset traded on the X-Chain is AVAX. When you issue a transaction to a blockchain on Avalanche, you pay a fee denominated in AVAX.

And Avalanche X-addresses look like this: X-avax13k6hxpfuu80dlnqlqs0dxxjrzl4lxz94n38vnw. The C-chain doesn't seem relevant in our case, as we're exchanging tokens, not executing smart contracts.

Assuming asgardex is compliant with BIP32/BIP44/SLIP44, as are hardware wallets like Ledger, AVAX has its own registered path component (0x80002328) different from ETH's (0x8000003c), so will have its own independent keys/addresses.

Quoting from https://www.ledger.com/blog/understanding-crypto-addresses-and-derivation-paths/:

Each level of this derivation path has a special meaning:

m / purpose' / coin_type' / account' / change / address_index

purpose: legacy bitcoin accounts and other blockchain ecosystems that comply with BIP44 (44), segwit (49), Native segwit (84), Bitcoin taproot (86)

coin_type: Refer to SLIP44 – Registered coin types for BIP44. Every crypto currency has its own value. This field allows accounts from different blockchains to use completely different and independent trees of keys. It guarantees isolation and avoids key reuse, which would be a privacy leak.

(emphasis mine)

Thorian1te commented 11 months ago

It is not, for the purpose of thorchain see If you want to use the Avalanche network for DeFi, then the C-Chain is the one you want. The C stands for contract, and this is the chain that’s used for smart contracts. The key difference with the other chains is that the c-chain uses an Ethereum-style address with 0x at the beginning, and can be added to MetaMask.

since thorchain wants to interact with the c-chain or contract chain for the purpose of using other Avax tokens like usdc we are most definitely executing smart contracts

pls do some more researching

https://medium.com/thorchain/thorchain-integration-of-avalanche-c-chain-complete-de8786ac7435

mtfgha commented 11 months ago

OK, now I get it. Thanks for the link. However, it would still be desirable to use independent derivation paths for ETH and AVAX to avoid key reuse, which should always be avoided in principle.

Also, how do I swap to ERC20 tokens like USDT? They're missing in the wallet.

Thorian1te commented 11 months ago

Issue with that is Compatibility and Accessibility This approach requires careful management and support from your wallet software. How many wallet support this unique path.

you can't, until a pool is created thorchain pools > https://thornode.ninerealms.com/thorchain/pools

Im no longer going to be your search engine. Pls do the research

mtfgha commented 11 months ago

Thanks, you've been a great help. Apologize for the somewhat uninformed questions. I'm an old Bitcoiner, but new to Thorchain.

Thorian1te commented 11 months ago

All good. I am a little short in my answers today as I am in the middle of releasing a new version of Asgardex. Any other issues come and chat in discord.

mtfgha commented 11 months ago

No problem. Best of luck with the upcoming release!

ChilledSilver commented 11 months ago

Upgraded to Asgardex v1.20.7 and still seeing this issue. Let me know if I can help diagnose further?

mtfgha commented 11 months ago

Upgraded to Asgardex v1.20.7 and still seeing this issue. Let me know if I can help diagnose further?

I'm no expert, but this looks like a connectivity issue. The remote server might be rejecting your IP for some reason. I'm seeing the balance and transacting AVAX successfully with my wallet (v1.20.6). (The "problem" I was experiencing turned out to be a problem with my lack of understanding of the wallet's key derivation method.) Have you tried connecting from a different location, or via VPN?

If that doesn't work, you might try doing a fresh install: record your seed phrase, rename the existing app data folder, and then recreate the wallet from your seed phrase as follows:

Click "IMPORT AN EXISTING WALLET WITH FUNDS ON IT"

Select "PHRASE" tab

Enter seed phrase at "ENTER PHRASE"

If anything goes wrong, you can always delete the newly created app data folder and replace it with the old one to restore your original setup.

GrassRootsCrypto commented 11 months ago

Re-tested with the latest build and this is working.