metaplex-foundation / sugar

Candy Machine Rust CLI.
Apache License 2.0
203 stars 116 forks source link

[Bug]: Transaction simulation failed: Attempt to load a program that does not exist #448

Closed ghost closed 1 year ago

ghost commented 1 year ago

Issue description

I am trying to deploy candy machine on solana-test-validator on localhost. This is because I am trying to mint nft locally. I've uploaded the assets to nft_storage and when I run sugar deploy, I see this error

 sugar deploy
[1/3] 📦 Creating collection NFT for candy machine

🛑 Error running command (re-run needed): RPC response error -32002: Transaction simulation failed: Attempt to load a program that does not exist

This is expected but I would like to load the program which it says as doesn't exist. I can't use devnet and need to use localhost. How to figure out which program to load? I would also like to know if there's any workarounds to be able to mint nft locally

Relevant log output

No response

Priority this issue should have

Low (slightly annoying)

samuelvanderwaal commented 1 year ago

@nikhil-helius You need both candy machine and token metadata deployed to your local validator in order to mint NFTs with Sugar. You can do this by cloning from an existing cluster directly with the solana validator:

solana-test-validator --clone <PROGRAM_ID> --url mainnet-beta

Alternately, you can use a tool like Amman for a more custom configuration of your localnet.

samuelvanderwaal commented 1 year ago

For CMV3 you need candy machine core and candy guard and Token Metadata so the following program ids:

ghost commented 1 year ago

Thanks, how long would the clone take? I tried for an hour for one program and when I ran solana program show --programs. I didn't see any program. With amman, I would need to specify the local path of the program and even though I did it with this config, I don't see the program loaded

  validator: {
    killRunningValidators: true,
    programs: [
      {
        label: 'Token Metadata Program',
        programId: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
        deployPath: localDeployPath('../metaplex-program-library/test-programs/mpl_token_metadata')
      },
      {
        label: 'Candy machine core',
        programId: 'CndyV3LdqHUfDLmE5naZjVN8rBZz4tqhdefbAnjHG3JR',
        deployPath: localDeployPath('../metaplex-program-library/test-programs/mpl_candy_machine')
      }
    ],
    jsonRpcUrl: 'localhost',
    websocketUrl: 'localhost',
    commitment: 'confirmed',
    ledgerDir: './test-ledger',
    resetLedger: true,
    verifyFees: false,
    detached: process.env.CI != null,
  },
samuelvanderwaal commented 1 year ago

solana-test-validator --clone is just copying the program's binary from a particular cluster so should only take a few seconds with a modern computer + internet connection. However, figuring out how to set up a local validator is not a Sugar issue and Github issues on this repo isn't the best place for it.

You can look up some general tutorials for how to use Solana local validators:

https://www.quicknode.com/guides/solana-development/getting-started/start-a-solana-local-validator/ https://docs.solana.com/developing/test-validator

ghost commented 1 year ago

Thanks, I took a look again and using solana explorer, I see that the accounts are cloned but the program is marked as closed.

Screenshot 2023-05-05 at 12 56 15 AM

If I do solana program deploy with the above *.so, then I am able to deploy the program but they get a different program ID. Is there a way to configure sugar to use the different account ids?

samuelvanderwaal commented 1 year ago

Thanks, I took a look again and using solana explorer, I see that the accounts are cloned but the program is marked as closed. Screenshot 2023-05-05 at 12 56 15 AM

If I do solana program deploy with the above *.so, then I am able to deploy the program but they get a different program ID. Is there a way to configure sugar to use the different account ids?

solana-test-validator can be tricky to use, I usually set up my localnets with Amman because it has better configuration options, IMO. You can use solana program dump to get the program binaries you want and point amman's configuration to those binaries.

Alternately, if --clone isn't working (I've had issues with it before) you can try dumping the program binaries and then starting the test validator from scratch with --reset and importing the program with --bpf-program:

solana program dump metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s mpl-token-metadata.so
solana-test-validator --bpf-program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s mpl-token-metadata.so --reset

At any rate, you'll need to do some trial and error to get it all figured out but this is not a bug or an issue with Sugar so I am going to close this issue.