2

I am trying to run Solana test validator using this command, so that I can do NFT testing.

solana-test-validator --url https://api.devnet.solana.com --clone metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s --clone PwDiXFxQsGra4sFFTT8r1QWRMd4vfumiWC1jfWNfdYT --clone mgr99QFMYByTqGPWmNqunV7vBLmWWXdSrHUfV8Jf3JM --clone ojLGErfqghuAqpJXE1dguXF7kKfvketCEeah8ig6GU3

The problem I am facing is:

  • cli version 1.8.x is not able to deploy the program I am testing
  • cli version 1.9.x or 1.10.x runs very slow while testing. Transaction is taking a long time to process

During my search, I came across this issue: https://github.com/solana-labs/solana/issues/23376

Is there some flags that we can use to make the local validator fast for testing?

My Computer: Macbook Pro with M1 Pro

--- Working Solution ---

After referencing the staking contract by cardinal labs, I found out this:

Loading program like this was causing my tests to run slow:

export function loadProgram(walletKeyPair: anchor.web3.Keypair) {
  const conn = new anchor.web3.Connection(
    process.env.ANCHOR_PROVIDER_URL
  );
  const walletWrapper = new anchor.Wallet(walletKeyPair);
  const provider = new anchor.AnchorProvider(conn, walletWrapper, {
    preflightCommitment: "processed",
    commitment: "processed",
  });
  return new anchor.Program(IDL, PROGRAM_ID, provider);
}

Loading program like this made my tests run fast:

const getProvider = (): anchor.AnchorProvider => {
  const anchorProvider = anchor.AnchorProvider.env();
  anchor.setProvider(anchorProvider);
  return anchorProvider;
};

export function loadProgram() {
  const provider = getProvider();
  return new anchor.Program(IDL, PROGRAM_ID, provider);
}

1 Answer 1

2

It takes a long time to process, or stalls completely?

I was running into errors with transactions stalling indefinitely on my M1. Running solana-test-validator with --no-bpf-jit fixed it.

1
  • It takes a long time to process the transaction. I tried using --no-bpf-jit flag but it did not improved the speed. Sep 14, 2022 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.