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

feat: remove multivalue and reference-types features from rustc >= 1.82.0 #229

Closed

Conversation

@frol
Copy link
Contributor

frol commented Oct 7, 2024

@race-of-sloths score 5

@race-of-sloths-bot
Copy link

race-of-sloths-bot commented Oct 7, 2024

@PolyProgrammist Thank you for your contribution! Your pull request is now a part of the Race of Sloths!
Do you want to apply for monthly streak? Get 8+ score for a single PR this month and receive boost for race-of-sloths!

Shows profile picture for the author of the PR

Current status: waiting for merge
Reviewer Score
@frol 5

Your contribution is much appreciated with a final score of 5!
You have received 50 Sloth points for this contribution

What is the Race of Sloths

Race of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow

For contributors:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Invite contributor @race-of-sloths invite to invite the contributor to participate in a race or include it, if it's already a runner.
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

@frol frol force-pushed the ignore-new-features branch from 0a4b207 to bcc1a7c Compare October 7, 2024 17:59
@frol frol enabled auto-merge (squash) October 7, 2024 18:01
@dj8yfo dj8yfo self-requested a review October 7, 2024 19:01
Copy link
Collaborator

@dj8yfo dj8yfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blocking it for now

@dj8yfo
Copy link
Collaborator

dj8yfo commented Oct 7, 2024

i've encountered following results with testing scenario from cargo near new template project: https://github.com/near/cargo-near/blob/main/cargo-near/src/commands/new/new-project-template/tests/test_basics.rs#L6 (wasm for test is put statically in place with

    let contract_wasm =
        std::fs::read("./target/wasm32-unknown-unknown/release/cargo_near_new.wasm")
            .expect("read wasm");

)

If wasm is generated with RUSTFLAGS="-C link-arg=-s -C target-feature=-multivalue,-reference-types" cargo +nightly build --target wasm32-unknown-unknown --release, then following error is consistently encountered when testing with near-workspaces = 0.14.0

outcome ExecutionFinalResult {
    total_gas_burnt: NearGas {
        inner: 1421248428811,
    },
    transaction: ExecutionOutcome {
        transaction_hash: 51Ct4JFSG6X4PdqE8NjYqUakso4uoeCnvzQ8nNgDYKhx,
        block_hash: 2MQiD91ddgPXMw71DZqzediNFJ39iMqbEcAjspRSA9bn,
        logs: [],
        receipt_ids: [
            rgoCk8tLruUj6S5CHJfScDt6imKrsb9KgGLZGyPZ91M,
        ],
        gas_burnt: NearGas {
            inner: 309919164885,
        },
        tokens_burnt: NearToken {
            inner: 30991916488500000000,
        },
        executor_id: AccountId(
            "dev-20241007194856-60669284714414",
        ),
        status: SuccessReceiptId(rgoCk8tLruUj6S5CHJfScDt6imKrsb9KgGLZGyPZ91M),
    },
    receipts: [
        ExecutionOutcome {
            transaction_hash: rgoCk8tLruUj6S5CHJfScDt6imKrsb9KgGLZGyPZ91M,
            block_hash: 2y1ta45b5edzTrUR7CAENzehw9x7LRvUEGWfa2P8e81e,
            logs: [],
            receipt_ids: [
                8M3kEg7p7WZWD3zA3zpLUDNgGSg6duPxxDuhZuAnYJdL,
            ],
            gas_burnt: NearGas {
                inner: 888146701426,
            },
            tokens_burnt: NearToken {
                inner: 88814670142600000000,
            },
            executor_id: AccountId(
                "dev-20241007194855-75721432061861",
            ),
            status: Failure(ActionError(ActionError { index: Some(0), kind: FunctionCallError(CompilationError(PrepareError(Deserialization))) })),
        },
        ExecutionOutcome {
            transaction_hash: 8M3kEg7p7WZWD3zA3zpLUDNgGSg6duPxxDuhZuAnYJdL,
            block_hash: 9zUuAG6YS3doyEbw3JkZUeWLKc6NwAPWzSSwsw4rBWc2,
            logs: [],
            receipt_ids: [],
            gas_burnt: NearGas {
                inner: 223182562500,
            },
            tokens_burnt: NearToken {
                inner: 0,
            },
            executor_id: AccountId(
                "dev-20241007194856-60669284714414",
            ),
            status: SuccessValue(''),
        },
    ],
    status: Failure(ActionError(ActionError { index: Some(0), kind: FunctionCallError(CompilationError(PrepareError(Deserialization))) })),
}
thread 'test_contract_is_operational' panicked at tests/test_basics.rs:22:5:
assertion failed: outcome.is_success()

If wasm is generated with RUSTFLAGS="-C link-arg=-s -C target-feature=-multivalue,-reference-types" cargo +nightly build -Zbuild-std=panic_abort,std --target wasm32-unknown-unknown --release (+nightly is used to access -Zbuild-std nightly feature, not only to access future 1.82 flags),
then test passes.

@PolyProgrammist
Copy link
Author

@dj8yfo got it. But do you want to build with nightly when the user wants to build with stable? Because -Z is only available in nightly

@PolyProgrammist
Copy link
Author

And do you want me to enable the test you provided in CI?

@dj8yfo
Copy link
Collaborator

dj8yfo commented Oct 8, 2024

@PolyProgrammist

But do you want to build with nightly when the user wants to build with stable?

not clear how to proceed yet

And do you want me to enable the test you provided in CI?

The following case might be a good addition: run equivalent of cargo near new (via cargo-near code being tested in workflow), build the generated project with equivalent of cargo near build --no-docker (via cargo-near code being tested in workflow, Test workflow uses stable toolchain), and run equivalent of test_basics with near_workspaces on generated wasm.
The changes of this pr couldn't be fully tested in CI, as they reference an unpublished 1.82.

Please, create a separate pr for the test, if you want to do it.

@PolyProgrammist
Copy link
Author

@dj8yfo got it. I will try to find out what is the best option

@PolyProgrammist
Copy link
Author

For now left this comment in related issue in WebAssembly tool-conventions repository WebAssembly/tool-conventions#233 (comment)

@dj8yfo
Copy link
Collaborator

dj8yfo commented Oct 8, 2024

the following compile errors are triggered by cargo build --target wasm32-unknown-unknown --release in rustc 1.83.0-nightly (55a22d2a6 2024-10-06) version , unlike 1.81.0

#[cfg(all(target_family = "wasm", target_feature = "reference-types"))]
compile_error!("Compiler configuration is unsupported by <ENV NAME HERE>, because a Wasm target-feature is enabled that is not yet supported: reference-types. Use Rust 1.81 or older to get a compatible default configuration.");
#[cfg(all(target_family = "wasm", target_feature = "multivalue"))]
compile_error!("Compiler configuration is unsupported by <ENV NAME HERE>, because a Wasm target-feature is enabled that is not yet supported: multivalue. Use Rust 1.81 or older to get a compatible default configuration.");

@dj8yfo dj8yfo changed the title Remove multivalue and reference-types features from rustc >= 1.82.0 feat: remove multivalue and reference-types features from rustc >= 1.82.0 Oct 8, 2024
@frol
Copy link
Contributor

frol commented Oct 9, 2024

Do I read it right that we are basically out of luck with the stable Rust 1.82+? It seems to me that there are three options:

  1. Require Rust <1.82 in cargo-near
  2. Change build command in cargo-near in such a way that it will recompile std (it sounds like heavy-lifting in terms of implementation and in terms of contract compilation time, but I wonder if that can help to slim down the contract size thanks to LTO)
  3. Bring support for Rust 1.82 new features to nearcore

@PolyProgrammist @dj8yfo Are we on the same page? If so, I would focus on (1) and (3)

@near near deleted a comment from race-of-sloths-bot Oct 9, 2024
@near near deleted a comment from race-of-sloths-bot Oct 9, 2024
@near near deleted a comment from race-of-sloths-bot Oct 9, 2024
@near near deleted a comment from race-of-sloths-bot Oct 9, 2024
@frol frol disabled auto-merge October 9, 2024 02:51
@PolyProgrammist
Copy link
Author

Do I read it right that we are basically out of luck with the stable Rust 1.82+? It seems to me that there are three options:

  1. Require Rust <1.82 in cargo-near
  2. Change build command in cargo-near in such a way that it will recompile std (it sounds like heavy-lifting in terms of implementation and in terms of contract compilation time, but I wonder if that can help to slim down the contract size thanks to LTO)
  3. Bring support for Rust 1.82 new features to nearcore

@PolyProgrammist @dj8yfo Are we on the same page? If so, I would focus on (1) and (3)

Yes, I guess these are the options. And I 1 and 3 sound good. Also, for 2 std recompiling is only possible with nightly compiler

@frol
Copy link
Contributor

frol commented Oct 16, 2024

We worked around the compatibility issue by running wasm-opt on the final Wasm binary. We even see 10% size reduction, so it is a win. The only downside is that cargo-near-build now has this heavy wasm-opt dependency and as such near-workspaces and factory subcontracts build time will get +1 minute to the compilation time.

@frol frol closed this Oct 16, 2024
@race-of-sloths
Copy link

@PolyProgrammist Thank you for your contribution! Your pull request is now a part of the Race of Sloths!
Do you want to apply for monthly streak? Get 8+ score for a single PR this month and receive boost for race-of-sloths!

Shows inviting banner with latest news.

Shows profile picture for the author of the PR

Current status: stale

This pull request was removed from the race, but you can include it again with @race-of-sloths include command

What is the Race of Sloths

Race of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow

For contributors:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Invite contributor @race-of-sloths invite to invite the contributor to participate in a race or include it, if it's already a runner.
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

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.

5 participants