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

Resolve M1 tests on latest sandbox from failing #110

Closed
ChaoticTempest opened this issue Apr 5, 2022 · 8 comments
Closed

Resolve M1 tests on latest sandbox from failing #110

ChaoticTempest opened this issue Apr 5, 2022 · 8 comments
Assignees

Comments

@ChaoticTempest
Copy link
Member

ChaoticTempest commented Apr 5, 2022

M1 tests will yield the following error message:

Error: Action #0: CompilationError(WasmerCompileError

{ msg: "The target x86_64 without AVX is not yet supported (see [https://docs.wasmer.io/ecosystem/wasmer/wasmer-features| https://docs.wasmer.io/ecosystem/wasmer/wasmer-features])" }

)

We will need to switch to wasmtime for sandbox builds on nearcore

@syrusakbary
Copy link

Wasmer in master already supports M1 natively with Singlepass (as well as the supporting x86_64 without AVX)

@ChaoticTempest
Copy link
Member Author

Wasmer in master already supports M1 natively with Singlepass (as well as the supporting x86_64 without AVX)

Thanks for letting me know, but this is a forked wasmer dating back a bit and specifically in https://github.com/near/nearcore. There's efforts right now to upgrade it or might have already been upgraded but still lacks some stuff

@ChaoticTempest
Copy link
Member Author

ChaoticTempest commented Apr 6, 2022

@AustinBaggio @itegulov @Ekleog

Posting here for visibility

me:

it looks like the wasmtime match branch in precompile_contract_vm just panics by default

Ekleog:

Makes sense! I thought the cache was already disabled but it seems not. Can you try with this patch, and/or let me know your procedure to run the sandbox?

diff --git a/nearcore/src/runtime/mod.rs b/nearcore/src/runtime/mod.rs
index 0991e4bbd..8dbd521bc 100644
--- a/nearcore/src/runtime/mod.rs
+++ b/nearcore/src/runtime/mod.rs
@@ -517,6 +517,12 @@ impl NightshadeRuntime {
                epoch_height, &epoch_id, current_protocol_version, is_first_block_of_version,
         );
 
+        use near_vm_runner::internal::VMKind;
+
+        let cache: Option<Arc<dyn CompiledContractCache>> = match VMKind::for_protocol_version(current_protocol_version) {
+            VMKind::Wasmtime => None,
+            _ => Some(Arc::new(StoreCompiledContractCache { store: self.store.clone() })),
+        };
         let apply_state = ApplyState {
             block_index: block_height,
             prev_block_hash: *prev_block_hash,
@@ -529,7 +535,7 @@ impl NightshadeRuntime {
             random_seed,
             current_protocol_version,
             config: self.runtime_config_store.get_config(current_protocol_version).clone(),
-            cache: Some(Arc::new(StoreCompiledContractCache { store: self.store.clone() })),
+            cache,
             is_new_chunk,
             migration_data: Arc::clone(&self.migration_data),
             migration_flags: MigrationFlags {

had to do some minor adjustments and it worked for the examples, but now I'm getting some timeouts on transactions with tests (just logs though):

❯ NEAR_SANDBOX_BIN_PATH="/Users/tensor/space/nearcore/sandbox/debug/neard" cargo test -- --nocapture 
    Finished test [unoptimized + debuginfo] target(s) in 0.22s
     Running unittests (target/debug/deps/workspaces-3d90dfffcecb5756)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/batch_tx.rs (target/debug/deps/batch_tx-53dc4dd377139ade)

running 1 test
test_batch_tx: Ok("/Users/tensor/space/nearcore/sandbox/debug/neard")
2022-04-06T18:15:29.057268Z ERROR workspaces: Calling RPC method RpcBroadcastTxCommitRequest { signed_transaction: SignedTransaction { transaction: Transaction { signer_id: AccountId("dev-20220406181516-21378987261596"), public_key: ed25519:5WMgq6gKZbAr7xBZmXJHjnj4C3UZkNJ4F5odisUBFcRh, nonce: 2000001, receiver_id: AccountId("dev-20220406181516-21378987261596"), block_hash: `HZUmmfTAQjGuZS9HXPdLXx58VNBTMUJqE5ihQeTjrrKf`, actions: [FunctionCall(FunctionCallAction { method_name: set_status, args: `{"message":"hello_world"}`, gas: 10000000000000, deposit: 0 }), FunctionCall(FunctionCallAction { method_name: set_status, args: `{"message":"world_hello"}`, gas: 10000000000000, deposit: 0 })] }, signature: ed25519:2YeHgAQagTKDJmgqr6wnjrGrvBsT87TZEcw9jXwdfRGXA1YUshhuFW22qvNtt2Kz2T8kGQnq3p5E2qeVxiNF295J, hash: `AkvZntDRdTmGq6ZYdxkwvEpUL8HTPcLFzPqDRdpgh3nE`, size: 287 } } resulted in error TransportError(RecvError(PayloadParseError(Unmatched(Object({"error": Object({"cause": Object({"name": String("TIMEOUT_ERROR")}), "code": Number(-32000), "data": String("Timeout"), "message": String("Server error"), "name": String("HANDLER_ERROR")}), "id": String("3300986b-cf1e-43a1-bdf2-e41db767478c"), "jsonrpc": String("2.0")})))))
test test_batch_tx ... ok

and those tests are passing still, so mostly likely because I'm using a debug build of sandbox. Looks like its working for M1 builds then after that patch!

If anyone wants to test this themselves:

  • make sandbox in nearcore with the patch above.
  • clone https://github.com/near/workspaces-rs and checkout branch tmp/sandbox-m1
  • then run NEAR_SANDBOX_BIN_PATH="/path/to/nearcore/sandbox/debug/neard" cargo test

Some action items:

  • Get patch into nearcore. @Ekleog do you want to get this one in, since there might be more things you're considering adding.
  • Make M1 binaries available (at least have cross compilation binaries when we build on Macs) so we can make use of them here. EDIT: @rtsai123 what's the process like adding a new build pipeline for M1 on nearcore?

near-bulldozer bot pushed a commit to near/nearcore that referenced this issue May 9, 2022
We have not implemented build caching for wasmtime yet. As such, we also
need to not try using it, or the build will fail.

Partial fix for near/near-workspaces-rs#110

@matklad I'm not sure how good I feel about exposing VMKind while it was previously marked as internal. It was already being used by at least near-vm-runner-standalone and runtime-param-estimator, but still. The issue is, if I'm not doing that it means that somewhere else down the call chain we would have to ignore a correctly-configured contract cache, which feels worse to me than exposing VMKind.

What do you think about that? Or is internal maybe for "anything in nearcore but semver doesn't apply"?

cc @ChaoticTempest
@dragoonzx
Copy link

Waiting for M1 support 🙏

@bulbazavr1024
Copy link

@syrusakbary Hey! Any updates ?

@ChaoticTempest
Copy link
Member Author

Currently being worked on, and should be out soon within the month. We're in the last stages of this and currently building out the pipeline for publishing nearcore binaries for M1

@nujabes403
Copy link

@ChaoticTempest Could I know the exact date of M1 support?

@ChaoticTempest
Copy link
Member Author

resolved with 0.4.0 now supporting M1!

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

No branches or pull requests

5 participants