-
Notifications
You must be signed in to change notification settings - Fork 3
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: migration to cargo near #184
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rustc 1.84.0 + building wasm using cargo-near-build directly during testing works correctly: https://github.com/Near-One/omni-bridge/actions/runs/12738704841/job/35501410832?pr=184 |
frolvanya
force-pushed
the
feat/migration-to-cargo-near
branch
10 times, most recently
from
January 16, 2025 10:31
509fa26
to
bd8dbf2
Compare
frolvanya
force-pushed
the
feat/migration-to-cargo-near
branch
10 times, most recently
from
January 22, 2025 02:30
cdf0f64
to
11cbf7f
Compare
dj8yfo
added a commit
to near/cargo-near
that referenced
this pull request
Jan 22, 2025
…e in tests context (#292) reason for this pr is that [LazyLock initialization block](https://github.com/NEAR-DevHub/neardevhub-contract/blob/083fdde69d147f43bd320094db1b3a8acf64c841/tests/test_env/mod.rs#L20-L27) doesn't work to ensure tested contracts are built only once for `cargo nextest run` as **cargo-nextest** uses a process-per-test runner, and for usual `cargo test` workflows it may not be convenient/possible to unite all tests into a single test module, thus contracts' build will run at least once per each test module. This pr minimizes time spent on contracts' rebuilding after initial build, so that LazyLock init block isn't that much needed any more, but it depends on separating target folders of different contracts being tested similar to dj8yfo/neardevhub-contract@cbbf0ee to avoid partially rebuilding contracts starting with `near-sdk-macros` crate, if it's shared in common release profile when different contracts are in a workspace. --- this results in ```bash • Building contract │ Finished `release` profile [optimized] target(s) in 0.08s • Running an optimize for size post-step with wasm-opt... /home/user/Documents/code/near/neardevhub-contract/target/wasm32-unknown-unknown/release/devhub.wasm -> /tmp/optimized-s2bmSK.wasm • done ✓ Contract successfully built! (in CARGO_NEAR_BUILD_ENVIRONMENT=host) - Binary: /home/user/Documents/code/near/neardevhub-contract/target/near/devhub.wasm - SHA-256 checksum hex : 1f568ea4c5eabf9c947a201f3adf38a4e47056658aa512fdfc722f17de9d3aa3 - SHA-256 checksum bs58: 37LC32jmZFmZN8KesPipwUn4ZyhW4994coXqSWMdnDQv - ABI: /home/user/Documents/code/near/neardevhub-contract/target/near/devhub_abi.json - Embedded ABI: /home/user/Documents/code/near/neardevhub-contract/target/near/devhub_abi.zst Finished cargo near build in 5s Here is the console command if you ever need to re-run it again: cargo near build non-reproducible-wasm ``` instead of ```bash • Building contract │ Compiling near-sdk-macros v5.5.0 │ Compiling near-sdk v5.5.0 │ Compiling devhub_common v0.1.0 (/home/user/Documents/code/near/neardevhub-contract/d evhub_common) │ Compiling near-contract-standards v5.5.0 │ Compiling devhub v0.2.0 (/home/user/Documents/code/near/neardevhub-contract) │ Finished `release` profile [optimized] target(s) in 15.52s • Running an optimize for size post-step with wasm-opt... /home/user/Documents/code/near/neardevhub-contract/target/wasm32-unknown-unknown/release/d evhub.wasm -> /tmp/optimized-FbzCfP.wasm • done ✓ Contract successfully built! (in CARGO_NEAR_BUILD_ENVIRONMENT=host) - Binary: /home/user/Documents/code/near/neardevhub-contract/target/ne ar/devhub.wasm - SHA-256 checksum hex : 1f568ea4c5eabf9c947a201f3adf38a4e47056658aa512fdfc722f17de9d3aa3 - SHA-256 checksum bs58: 37LC32jmZFmZN8KesPipwUn4ZyhW4994coXqSWMdnDQv - ABI: /home/user/Documents/code/near/neardevhub-contract/target/ne ar/devhub_abi.json - Embedded ABI: /home/user/Documents/code/near/neardevhub-contract/target/ne ar/devhub_abi.zst Finished cargo near build in 20s ``` on rebuilds. and wasm-opt stage skipping was handled in e746699 . No file locks were added, it would still waste some cpu, if multiple builders enter the wasm-opt stage around the same time, but it does save on time and locks are perceived as unneeded complexity at this time. --- vaguely related to Near-One/omni-bridge#184 --------- Co-authored-by: dj8yf0μl <noreply@nowhere.org> Co-authored-by: Vlad Frolov <frolvlad@gmail.com>
Testing time increased without patch
Multiple jobs didn't speed up the compilation process
frolvanya
force-pushed
the
feat/migration-to-cargo-near
branch
from
January 22, 2025 17:18
5e2f84b
to
7206017
Compare
frolvanya
force-pushed
the
feat/migration-to-cargo-near
branch
from
January 22, 2025 17:19
7206017
to
841b997
Compare
frolvanya
force-pushed
the
feat/migration-to-cargo-near
branch
from
January 22, 2025 17:49
b25eccd
to
61b80d6
Compare
frolvanya
force-pushed
the
feat/migration-to-cargo-near
branch
from
January 24, 2025 05:11
d8331d9
to
5211a34
Compare
karim-en
approved these changes
Jan 31, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Usage Guide
Compilation
There're two options to compile contract:
Makefile
from the root of repocargo near
command directly:$ cargo near build reproducible-wasm # or we might need to specify `manifest-path` if the current pwd is not a contract (e.g pwd is ./near) $ cargo near build reproducible-wasm --manifest-path ./omni-prover/evm-prover/Cargo.toml
Warning
If you have darwin-arm64 (aka MacBook with M chip) you would need to have rosetta installed (
softwareupdate --install-rosetta
). Otherwise, you might run in an issue during compilation with DockerDeployment
There're two options to deploy as well:
cargo near build
or usecargo near deploy
:This command will build and deploy wasm for us
Note
cargo near
works in interactive mode as well just likenear-cli-rs
. Meaning you can callcargo near
and process the rest in interactive mode by building command with a correct options