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

bump: rust to 1.82, pkgs versions + cargo-near version in ci #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dj8yfo
Copy link

@dj8yfo dj8yfo commented Nov 11, 2024

@denbite can you check whether your contract is fully operational on this branch? (on 1.82)

I do not suggest that you merge the pr, as it will increase the runtime of first run of cargo test for approximately 2 min or so, i'm just interested if different non-trivial contracts work on 1.82 with cargo-near. The alternative of running nightly is much more painful than this, and i'm not sure when support of new features of 1.82 will be rolled out in nearcore.

I did see a couple of weird artifacts with this pr too, but then it has been at least 5 ok runs of test in sandbox on cargo clean state ofcode as if just after checkout from this branch.

@dj8yfo dj8yfo marked this pull request as ready for review November 11, 2024 18:58
@dj8yfo dj8yfo changed the title bump: pkgs versions + cargo-near version in ci bump: rust to 1.82, pkgs versions + cargo-near version in ci Nov 11, 2024
@denbite
Copy link
Member

denbite commented Nov 19, 2024

@dj8yfo couldn't compile this version locally, fails with the following error
cargo-near version 0.12.1
platform aarch64-apple-darwin

[wasm-validator error in function 518] unexpected false: SIMD operations require SIMD [--enable-simd], on
(v128.load offset=16 align=4
 (local.get $2)
)
[wasm-validator error in function 518] unexpected false: SIMD operations require SIMD [--enable-simd], on
(v128.load align=4
 (i32.add
  (i32.add
   (local.get $2)
   (i32.const 16)
  )
  (i32.const 16)
 )
)
[wasm-validator error in function 518] unexpected false: SIMD operations require SIMD [--enable-simd], on
(v128.store align=4
 (i32.add
  (local.tee $9
   (i32.add
    (local.get $8)
    (local.get $1)
   )
  )
  (i32.const 16)
 )
 (v128.load align=4
  (i32.add
   (i32.add
    (local.get $2)
    (i32.const 16)
   )
   (i32.const 16)
  )
 )
)
[wasm-validator error in function 518] unexpected false: SIMD operations require SIMD [--enable-simd], on
(v128.store align=4
 (local.get $9)
 (local.get $10)
)
[wasm-validator error in function 518] unexpected false: all used types should be allowed, on
518
[wasm-validator error in function 526] unexpected false: SIMD operations require SIMD [--enable-simd], on
(v128.load offset=16 align=4
 (local.get $2)
)
[wasm-validator error in function 526] unexpected false: SIMD operations require SIMD [--enable-simd], on
(v128.store align=4
 (local.get $0)
 (v128.load offset=16 align=4
  (local.get $2)
 )
)
[wasm-validator error in function 540] unexpected false: all used features should be allowed, on
(v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000)
[wasm-validator error in function 540] unexpected false: SIMD operations require SIMD [--enable-simd], on
(v128.store align=8
 (local.tee $3
  (i32.add
   (i32.add
    (local.get $2)
    (i32.const 16)
   )
   (i32.const 16)
  )
 )
 (local.tee $4
  (v128.const i32x4 0x00000000 0x00000000 0x00000000 0x00000000)
 )
)
[wasm-validator error in function 540] unexpected false: SIMD operations require SIMD [--enable-simd], on
(v128.store offset=16 align=8
 (local.get $2)
 (local.get $4)
)
[wasm-validator error in function 540] unexpected false: SIMD operations require SIMD [--enable-simd], on
(v128.load align=8
 (local.get $3)
)
[wasm-validator error in function 540] unexpected false: SIMD operations require SIMD [--enable-simd], on
(v128.store align=1
 (i32.add
  (local.get $0)
  (i32.const 16)
 )
 (v128.load align=8
  (local.get $3)
 )
)
[wasm-validator error in function 540] unexpected false: SIMD operations require SIMD [--enable-simd], on
(v128.load offset=16 align=8
 (local.get $2)
)
[wasm-validator error in function 540] unexpected false: SIMD operations require SIMD [--enable-simd], on
(v128.store align=1
 (local.get $0)
 (v128.load offset=16 align=8
  (local.get $2)
 )
)
[wasm-validator error in function 540] unexpected false: all used types should be allowed, on
540
[wasm-validator error in function 546] unexpected false: SIMD operations require SIMD [--enable-simd], on
(v128.load align=4
 (local.get $3)
)
[wasm-validator error in function 546] unexpected false: SIMD operations require SIMD [--enable-simd], on
(v128.store align=4
 (local.get $0)
 (v128.load align=4
  (local.get $3)
 )
)
• failed

image

@dj8yfo
Copy link
Author

dj8yfo commented Nov 19, 2024

@denbite plz update fmt and see how it goes in ci.
I've had a similar error with --enable-simd (on linux) too, but then i reinstalled 1.82 and didn't see it again on quite a few cycles of repo checkout/build (on 1.81 and 1.82).
Thing is , i had a wasm generated on 1.81 with --enable-simd feature too, and it didn't work in sandbox (by plain cargo build --target wasm...).
But then the nigthmare went away, and i did quite a few cycles of checkout main/build+test on 1.81/checkout pr's compare branch/build+test on 1.82. (and now both 1.81 and 1.82 wasms generated by raw cargo command didn't have --enable-simd wasm feature enabled).

@dj8yfo
Copy link
Author

dj8yfo commented Nov 20, 2024

did a few combinations to try to reproduce the initial --enable-simd feature enabled i had seen (including uninstalling 1.82 and switching to it with not-cleaned target after 1.81), but had no juice with reproducing it again. (on x86_64-unknown-linux-gnu)

Below are states obtained after building on cargo clean state:

  1. cargo build --target wasm32-unknown-unknown --release (main, 6f37e08)
╭───┬───────────────────────────────────────────────────────────────────┬──────────────────────────┬─────────────────────────────────────╮
│ # │                               name                                │         features         │                rustc                │
├───┼───────────────────────────────────────────────────────────────────┼──────────────────────────┼─────────────────────────────────────┤
│ 0 │ target/wasm32-unknown-unknown/release/deps/near_abstract_dao.wasm │ --enable-mutable-globals │ rustc 1.81.0 (eeb90cda1 2024-09-04) │
│   │                                                                   │ --enable-sign-ext        │                                     │
│ 1 │ target/wasm32-unknown-unknown/release/near_abstract_dao.wasm      │ --enable-mutable-globals │ rustc 1.81.0 (eeb90cda1 2024-09-04) │
│   │                                                                   │ --enable-sign-ext        │                                     │
│ 2 │ tests/res/mpc_contract.wasm                                       │ --enable-mutable-globals │ rustc 1.81.0 (eeb90cda1 2024-09-04) │
│   │                                                                   │ --enable-sign-ext        │                                     │
╰───┴───────────────────────────────────────────────────────────────────┴──────────────────────────┴─────────────────────────────────────╯
  1. cargo near build --no-docker --no-abi (main, 6f37e08)
╭───┬───────────────────────────────────────────────────────────────────┬──────────────────────────┬─────────────────────────────────────╮
│ # │                               name                                │         features         │                rustc                │
├───┼───────────────────────────────────────────────────────────────────┼──────────────────────────┼─────────────────────────────────────┤
│ 0 │ target/near/near_abstract_dao.wasm                                │ --enable-mutable-globals │ rustc 1.81.0 (eeb90cda1 2024-09-04) │
│   │                                                                   │ --enable-sign-ext        │                                     │
│ 1 │ target/wasm32-unknown-unknown/release/deps/near_abstract_dao.wasm │ --enable-mutable-globals │ rustc 1.81.0 (eeb90cda1 2024-09-04) │
│   │                                                                   │ --enable-sign-ext        │                                     │
│ 2 │ target/wasm32-unknown-unknown/release/near_abstract_dao.wasm      │ --enable-mutable-globals │ rustc 1.81.0 (eeb90cda1 2024-09-04) │
│   │                                                                   │ --enable-sign-ext        │                                     │
│ 3 │ tests/res/mpc_contract.wasm                                       │ --enable-mutable-globals │ rustc 1.81.0 (eeb90cda1 2024-09-04) │
│   │                                                                   │ --enable-sign-ext        │                                     │
╰───┴───────────────────────────────────────────────────────────────────┴──────────────────────────┴─────────────────────────────────────╯
  1. cargo build --target wasm32-unknown-unknown --release (pr, fe9d167)
╭───┬───────────────────────────────────────────────────────────────────┬──────────────────────────┬─────────────────────────────────────╮
│ # │                               name                                │         features         │                rustc                │
├───┼───────────────────────────────────────────────────────────────────┼──────────────────────────┼─────────────────────────────────────┤
│ 0 │ target/wasm32-unknown-unknown/release/deps/near_abstract_dao.wasm │ --enable-mutable-globals │ rustc 1.82.0 (f6e511eec 2024-10-15) │
│   │                                                                   │ --enable-sign-ext        │                                     │
│   │                                                                   │ --enable-reference-types │                                     │
│   │                                                                   │ --enable-multivalue      │                                     │
│ 1 │ target/wasm32-unknown-unknown/release/near_abstract_dao.wasm      │ --enable-mutable-globals │ rustc 1.82.0 (f6e511eec 2024-10-15) │
│   │                                                                   │ --enable-sign-ext        │                                     │
│   │                                                                   │ --enable-reference-types │                                     │
│   │                                                                   │ --enable-multivalue      │                                     │
│ 2 │ tests/res/mpc_contract.wasm                                       │ --enable-mutable-globals │ rustc 1.82.0 (f6e511eec 2024-10-15) │
│   │                                                                   │ --enable-sign-ext        │                                     │
╰───┴───────────────────────────────────────────────────────────────────┴──────────────────────────┴─────────────────────────────────────╯
  1. cargo near build --no-docker --no-abi (pr, fe9d167)
╭───┬───────────────────────────────────────────────────────────────────┬──────────────────────────┬─────────────────────────────────────╮
│ # │                               name                                │         features         │                rustc                │
├───┼───────────────────────────────────────────────────────────────────┼──────────────────────────┼─────────────────────────────────────┤
│ 0 │ target/near/near_abstract_dao.wasm                                │ --enable-mutable-globals │ rustc 1.82.0 (f6e511eec 2024-10-15) │
│   │                                                                   │ --enable-sign-ext        │                                     │
│ 1 │ target/wasm32-unknown-unknown/release/deps/near_abstract_dao.wasm │ --enable-mutable-globals │ rustc 1.82.0 (f6e511eec 2024-10-15) │
│   │                                                                   │ --enable-sign-ext        │                                     │
│ 2 │ target/wasm32-unknown-unknown/release/near_abstract_dao.wasm      │ --enable-mutable-globals │ rustc 1.82.0 (f6e511eec 2024-10-15) │
│   │                                                                   │ --enable-sign-ext        │                                     │
│ 3 │ tests/res/mpc_contract.wasm                                       │ --enable-mutable-globals │ rustc 1.82.0 (f6e511eec 2024-10-15) │
│   │                                                                   │ --enable-sign-ext        │                                     │
╰───┴───────────────────────────────────────────────────────────────────┴──────────────────────────┴─────────────────────────────────────╯

@dj8yfo
Copy link
Author

dj8yfo commented Nov 20, 2024

@denbite i was able to reproduce this error from screenshot above by explicitly exporting
export RUSTFLAGS="-C target-feature=+simd128"

before running build with cargo near build --no-docker --no-abi ,

i know how this potentially might be resolved (--enable-simd has conflict with another RUSTFLAGS='-C link-arg=-s' ,
because with -s linker erases header which contains indication , that --enable-simd is used, and that confuses wasm-opt, as it requires this header to be set, if it sees instructions, related to --enable-simd)

but i doubt this needs to be supported,
image

because contract built with plain cargo command ( cargo build --target wasm32-unknown-unknown --release ) on 1.81 with export RUSTFLAGS="-C target-feature=+simd128" with --enable-simd feature as a result fails on latest 0.15.0 near-workspaces sandbox (6 or so days ago from nearcore) with

        },
    ],
    status: Failure(ActionError(ActionError { index: Some(0), kind: FunctionCallError(CompilationError(PrepareError(Deserialization))) })),
}
thread 'test_sign_eip1559_payload_on_many_chains' panicked at tests/common.rs:52:5:
Failed to initialize Abstract DAO contract!

Can you retest locally, what your RUSTFLAGS is before running cargo build --target wasm32-unknown-unknown --release on 1.82 , and then, if it's unset,
check what wasm-opt --print-features FILE.wasm prints .
(this might be a flaky rustc 1.82 bug, where this +simd128 gets enabled spontaneously ;
the project doesn't have
a hidden .cargo/config.toml or something, which could enable it implicitly)

@denbite
Copy link
Member

denbite commented Nov 20, 2024

@dj8yfo I've just managed to build the contract with cargo near build on 1.82, errors disappeared once I've entirely removed profile.release section from the Cargo.toml file
both integration and unit tests are passing

image

@dj8yfo
Copy link
Author

dj8yfo commented Nov 20, 2024

@denbite if you have regular reproduction of --enable-simd popping up in wasm on 1.82 after
cargo build --target wasm32-unknown-unknown --release
on fe9d167,

you should open an issue in https://github.com/rust-lang/rust (
with absolutely minimal description,
fe9d167 as the precise code being compiled,
and link to this pr for more context)
you may be then asked about some specific details of your environment

because it has no reason to pop up without +simd128 feature being specified. i'd open it myself but i don't reproduce it anymore after stumbling upon it initially

@denbite
Copy link
Member

denbite commented Nov 21, 2024

@dj8yfo I regularly reproduce the issue when running RUSTFLAGS="-C link-arg=-s" cargo build --target wasm32-unknown-unknown --release, but compiling with unset RUSTFLAGS doesn't have the issue at all

@dj8yfo
Copy link
Author

dj8yfo commented Nov 21, 2024

@denbite can you confirm that output of wasm-opt --print-features RESULT_FILE.wasm contains --enable-simd ?
(https://command-not-found.com/wasm-opt)
If so, you should open an issue to https://github.com/rust-lang/rust

For me, RUSTFLAGS="-C link-arg=-s" cargo build --target wasm32-unknown-unknown --release doesn't result in --enable-simd present in output

@denbite
Copy link
Member

denbite commented Nov 21, 2024

@dj8yfo yes, it's there
creating an issue in https://github.com/rust-lang/rust

@denbite
Copy link
Member

denbite commented Nov 21, 2024

@dj8yfo I've just realized that all this time I was using an updated Cargo.lock file, which I believe was causing those errors with --enable-simd

I managed to compile the project without any errors after I've pulled your branch from scratch
So, right now running RUSTFLAGS="-C link-arg=-s" cargo build --target wasm32-unknown-unknown --release and then wasm-opt --print-features target/wasm32-unknown-unknown/release/near_abstract_dao.wasm, outputs as follows:

image

I am still able to reproduce the issue if I update dependencies with cargo update before compiling

@dj8yfo Please, try the following steps on your machine, just curious if that would fail as it does on mine:
git switch 1.82_what
cargo update
RUSTFLAGS="-C link-arg=-s" cargo build --target wasm32-unknown-unknown --release
wasm-opt --print-features target/wasm32-unknown-unknown/release/near_abstract_dao.wasm

On my machine, I end up seeing the error with --enable-simd
image

@dj8yfo
Copy link
Author

dj8yfo commented Nov 21, 2024

@denbite, yes , i can easily reproduce --enable-simd after cargo update
with cargo build --target wasm32-unknown-unknown (no RUSTFLAGS needed for a minimalistic issue)
i'll create an issue then myself

@dj8yfo
Copy link
Author

dj8yfo commented Nov 21, 2024

@denbite looks like you'd have to bisect the diff of Cargo.lock-s and find the library that enables +simd128 and
tell the author he had made a mistake 🤦‍♂️

there appears to be nothing specific about 1.82 in particular or changes of #9 ,
because doing cargo update on 6f37e08 pulls in --enable-simd anyway ,
which is not gonna work as per @nagisa -s comment above

@dj8yfo
Copy link
Author

dj8yfo commented Nov 21, 2024

@denbite i've managed to narrow the diff, i've found at least one match, which introduces the breakage:

diff --git a/Cargo.lock b/Cargo.lock
index e94eba4..eebc8bd 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -472,23 +472,23 @@ name = "colored"
 version = "2.1.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8"
 dependencies = [
  "lazy_static",
  "windows-sys 0.48.0",
 ]
 
 [[package]]
 name = "const-hex"
-version = "1.12.0"
+version = "1.13.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "94fb8a24a26d37e1ffd45343323dc9fe6654ceea44c12f2fcb3d7ac29e610bc6"
+checksum = "0121754e84117e65f9d90648ee6aa4882a6e63110307ab73967a4c5e7e69e586"
 dependencies = [
  "cfg-if 1.0.0",
  "cpufeatures",
  "hex",
  "proptest",
  "serde",
 ]
 
 [[package]]
 name = "const-oid"

https://github.com/DaniPopes/const-hex/blob/85f08142ccc5300c90faa94484b20db19388bf19/src/arch/wasm32.rs#L71-L72

EDIT: this is the only problematic one

@denbite
Copy link
Member

denbite commented Nov 22, 2024

@dj8yfo the author of const-hex has recently released a new version (1.13.2), and I just tried to compile the contract, passed without any issues
wasm-opt returns

--enable-mutable-globals
--enable-sign-ext

@denbite
Copy link
Member

denbite commented Nov 22, 2024

does it mean I can safely upgrade main branch to 1.82?

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

Successfully merging this pull request may close these issues.

2 participants