Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add flag to anchor test to invoke validator with --no-bpf-jit #970

Closed
byang223 opened this issue Nov 3, 2021 · 8 comments
Closed

add flag to anchor test to invoke validator with --no-bpf-jit #970

byang223 opened this issue Nov 3, 2021 · 8 comments

Comments

@byang223
Copy link

byang223 commented Nov 3, 2021

Getting this error when I run anchor test

Translating error FetchError: request to http://localhost:8899/ failed, reason: socket hang up
    at ClientRequest.<anonymous> (~/dev/solana_project/node_modules/node-fetch/lib/index.js:1461:11)
    at ClientRequest.emit (node:events:390:28)
    at Socket.socketOnEnd (node:_http_client:471:9)
    at Socket.emit (node:events:402:35)
    at endReadableNT (node:internal/streams/readable:1343:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET'
}

I'm on an M1 Macbook, running this in a Rosetta shell. I also installed solana from source. I believe my rust toolchain is set up correctly.

rustup show
Default host: x86_64-apple-darwin
rustup home:  /Users/byang/.rustup

installed toolchains
--------------------

stable-x86_64-apple-darwin (default)
bpf

active toolchain
----------------

stable-x86_64-apple-darwin (default)
rustc 1.56.1 (59eed8a2a 2021-11-01)

I'm not seeing anything terribly interesting in validator.log except the JIT panick below...but I'm new to rust.

[2021-11-03T07:25:15.861336000Z INFO  solana_metrics::metrics] datapoint: cost_tracker_stats bank_slot=1i block_cost=47224i transaction_count=2i number_of_accounts=2i costliest_account="GuhPaDzNtk6ZxeKS9tCSYSX51EJM3XhHWbsN2H6o5jWe" costliest_account_cost=47224i
thread 'sol-rpc-el' panicked at 'JIT is only supported on x86_64', /Users/byang/.cargo/registry/src/github.com-1ecc6299db9ec823/solana_rbpf-0.2.11/src/jit.rs:738:13

Any idea why this may be happening and where is a good place to start investigating?

@byang223
Copy link
Author

byang223 commented Nov 3, 2021

I tried to run the test using the solana-test-validator instead and was able to get a bit further

solana-test-validator --reset --no-bpf-jit

Now when I run anchor test --skip-local-validator, it finishes deploying the contract but has trouble talking to it

Error: failed to send transaction: Transaction simulation failed: Attempt to load a program that does not exist
      at Connection.sendEncodedTransaction (node_modules/@solana/web3.js/src/connection.ts:3689:13)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at Connection.sendRawTransaction (node_modules/@solana/web3.js/src/connection.ts:3649:20)
      at sendAndConfirmRawTransaction (node_modules/@solana/web3.js/src/util/send-and-confirm-raw-transaction.ts:27:21)
      at Provider.send (node_modules/@project-serum/anchor/src/provider.ts:114:18)
      at Object.rpc [as initialize] (node_modules/@project-serum/anchor/src/program/namespace/rpc.ts:24:23)

btw, just running this on the anchor init project

@fanatid
Copy link
Contributor

fanatid commented Nov 3, 2021

jit is supported only on x86_64, and not on windows :(
but it does not look like anchor issue, better to create an issue or pull request in https://github.com/solana-labs/rbpf

@byang223
Copy link
Author

byang223 commented Nov 3, 2021

jit is supported only on x86_64, and not on windows :( but it does not look like anchor issue, better to create an issue or pull request in https://github.com/solana-labs/rbpf

I was able to circumvent the problem by disabling bpf-jit in the validator. However, I'm still having trouble with anchor test. The deploy portion finishes successfully test block with the transaction still fails. Instead of using anchor.workspace to load the program, I tried it with this block of code and it seems to have worked. So maybe the issue resides with workspace and its dependencies?

@byang223
Copy link
Author

byang223 commented Nov 3, 2021

I updated Anchor.toml programs.localnet section to match the deployed program ID and it seemed to have work. For some reason this is different than the ID declared in the contract

use anchor_lang::prelude::*;

declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");

What's the purpose of declare_id?

@byang223
Copy link
Author

byang223 commented Nov 3, 2021

Seems like the answer to this question is mostly addressed in #866

I guess the feature request here then is to allow anchor test to be able to add an additional flag --no-bpf-jit to starting solana-test-validator. This will allow people on M1 and Windows to use anchor test without running into issues. Unless I made a big mistake in installation...in which case maybe documentation issue.

@byang223 byang223 changed the title anchor test failing with socket hang up add flag to anchor test to invoke validator with --no-bpf-jit Nov 3, 2021
@tomlinton
Copy link
Contributor

I've never required that flag on an M1, it works without it. Not objecting to adding the --no-bpf-jit flag though as most other options for the test validator can be controlled in Anchor.toml.

@fanatid
Copy link
Contributor

fanatid commented Nov 12, 2021

No need to add this flag to anchor. Solana should disable jit automatically in newer versions. solana-labs/solana#21215

@paul-schaaf
Copy link
Contributor

solana-labs/solana#21215 has been merged so Im closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants