near / cargo-near

Cargo extension for building Rust smart contracts on NEAR
Apache License 2.0
33 stars 16 forks source link

feat(source-scan): handle missing meta, --no-docker suggestion, meta example suggestion #179

Closed dj8yfo closed 1 month ago

dj8yfo commented 1 month ago

photo_2024-07-05_13-27-45 (2)

2024-07-12_17-02 2024-07-12_20-26

sample-crate-34.testnet

```json { "build_info": { "build_command": [ "cargo", "near", "build" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-git-pull-179-ccache-cut-single@sha256:b46ea2c26ef5762c0675aa3563bd38aa045366c27a9918867a2455c83c8b046a", "contract_path": "", "source_code_snapshot": "git+https://github.com/dj8yfo/sample_no_workspace?rev=241d6a2c313488e4d037fbc3cbca2763285de04d" }, "link": "https://github.com/dj8yfo/sample_no_workspace/tree/241d6a2c313488e4d037fbc3cbca2763285de04d", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.7.7" } ```

sample-subpath-in-repo-13.testnet

```json { "build_info": { "build_command": [ "cargo", "near", "build" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-git-pull-179-ccache-cut-single@sha256:b46ea2c26ef5762c0675aa3563bd38aa045366c27a9918867a2455c83c8b046a", "contract_path": "self-updates/update", "source_code_snapshot": "git+https://github.com/dj8yfo/sample_workspace?rev=49b40d149f5e595c3e0e4862c08eeb16b2a7d0d3" }, "link": "https://github.com/dj8yfo/sample_workspace/tree/49b40d149f5e595c3e0e4862c08eeb16b2a7d0d3", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "1.7.7" } ```

sample-crate-in-submodule-13.testnet

```json { "build_info": { "build_command": [ "cargo", "near", "build" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-git-pull-179-ccache-cut-single@sha256:b46ea2c26ef5762c0675aa3563bd38aa045366c27a9918867a2455c83c8b046a", "contract_path": "self-updates/update", "source_code_snapshot": "git+https://github.com/dj8yfo/sample_workspace_with_submodules?rev=e00bd4907e4a3f1fe35653a8843bcb481b3eaf94" }, "link": "https://github.com/dj8yfo/sample_workspace_with_submodules/tree/e00bd4907e4a3f1fe35653a8843bcb481b3eaf94", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "1.0.0" } ```

bitbucket-scratch-11.testnet

```json { "build_info": { "build_command": [ "cargo", "near", "build" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-git-pull-179-ccache-cut-single@sha256:b46ea2c26ef5762c0675aa3563bd38aa045366c27a9918867a2455c83c8b046a", "contract_path": "", "source_code_snapshot": "git+https://bitbucket.org/dj8yfomule/scratch_check_git?rev=f9e71feab15d2952f3baedcd2f0c642fe0db1ad8" }, "link": "https://bitbucket.org/dj8yfomule/scratch_check_git", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.1.0" } ```

repro-fct-35.testnet

```json { "build_info": { "build_command": [ "cargo", "near", "build" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-git-pull-179-ccache-cut-single@sha256:b46ea2c26ef5762c0675aa3563bd38aa045366c27a9918867a2455c83c8b046a", "contract_path": "factory", "source_code_snapshot": "git+https://github.com/dj8yfo/factory-rust?rev=1695790693f1058a70d4edc54144a94570e199bd" }, "link": "https://github.com/dj8yfo/factory-rust/tree/1695790693f1058a70d4edc54144a94570e199bd", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.1.13" } ```

donation-product.repro-fct-35.testnet

```json { "build_info": { "build_command": [ "cargo", "near", "build" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-git-pull-179-ccache-cut-single@sha256:b46ea2c26ef5762c0675aa3563bd38aa045366c27a9918867a2455c83c8b046a", "contract_path": "product-donation", "source_code_snapshot": "git+https://github.com/dj8yfo/factory-rust?rev=1695790693f1058a70d4edc54144a94570e199bd" }, "link": "https://github.com/dj8yfo/factory-rust/tree/1695790693f1058a70d4edc54144a94570e199bd", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.2.9" } ```

repro-fct-product-35.testnet

```json { "build_info": { "build_command": [ "cargo", "near", "build" ], "build_environment": "dj8yfo/sourcescan:0.x.x-dev-git-pull-179-ccache-cut-single@sha256:b46ea2c26ef5762c0675aa3563bd38aa045366c27a9918867a2455c83c8b046a", "contract_path": "product-donation", "source_code_snapshot": "git+https://github.com/dj8yfo/factory-rust?rev=1695790693f1058a70d4edc54144a94570e199bd" }, "link": "https://github.com/dj8yfo/factory-rust/tree/1695790693f1058a70d4edc54144a94570e199bd", "standards": [ { "standard": "nep330", "version": "1.2.0" } ], "version": "0.2.9" } ```

dj8yfo commented 1 month ago

@race-of-sloths include

race-of-sloths commented 1 month ago

@dj8yfo Thank you for your contribution! Your pull request is now a part of the Race of Sloths!

[

<source media="(prefers-color-scheme: light)" srcset="https://badge.race-of-sloths.com/dj8yfo?type=bot&theme=light">
<img alt="Shows profile picture for the author of the PR" src="https://badge.race-of-sloths.com/dj8yfo?type=bot&theme=white">

](https://race-of-sloths.com/profile/dj8yfo)

Current status: executed | Reviewer | Score | |--------|--------| | @frol | 8 | **The average score is 8** @dj8yfo check out your results on the [Race of Sloths Leaderboard!](https://race-of-sloths.com/leaderboard) and in the [profile](https://race-of-sloths.com/profile/dj8yfo)
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](https://race-of-sloths.com/leaderboard) - Keep weekly and monthly streaks to reach higher positions - Boast your contributions with a dynamic picture of your [Profile](https://race-of-sloths.com/profile/dj8yfo) 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](https://race-of-sloths.com) for additional details!

Bot commands - For contributors - **Include a PR:** `@race-of-sloths include` to enter the Race with your PR - For maintainers: - **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
dj8yfo commented 1 month ago

testing of factory in https://github.com/dj8yfo/factory-rust revealed a bug:

❯ sha256sum *.wasm
# contracts, deployed from https://github.com/dj8yfo/factory-rust/tree/1f2c380f8bf5f2ee793b28ba257129d445e116d1
60e7690fd83b5bb3e623ecf0577f15986cb80867ba9ba84a910150d64cbbb04d  donation-product_repro-fct-30_testnet.wasm
6af1c80093e0dd138a9833edf5f0cb7c833d59a1814eeae334490bbf7cbe7472  repro-fct-30_testnet.wasm
# error!!!
665e9b8d94f537793708ebf84b6546bd3d92f17c4adda76df9db61baa494a124  repro-fct-product-30_testnet.wasm

Updating cargo-near to 0.6.3 in [build-dependencies] with commit https://github.com/dj8yfo/factory-rust/commit/2ee944cccb37a8373ec9bdd27d9d942329c314f0 results in identical wasms for product from factory and standalone product:

# contracts, deployed from https://github.com/dj8yfo/factory-rust/tree/2ee944cccb37a8373ec9bdd27d9d942329c314f0
❯ sha256sum *.wasm
96888ead8940315835c9b78c8738497d0c0e57b9154dc4461c9ff4b84760473c  donation-product_repro-fct-31_testnet.wasm
515ca086bc220b2ef8284be6dc5d3a1cf667295a861965d70f5e2671920f992a  repro-fct-31_testnet.wasm
96888ead8940315835c9b78c8738497d0c0e57b9154dc4461c9ff4b84760473c  repro-fct-product-31_testnet.wasm

Problem must be in this line: https://github.com/near/cargo-near/blob/main/cargo-near/src/commands/build_command/build.rs#L69

near contract download-abi repro-fct-product-30.testnet save-to-file repro-fct-product-30_testnet.abi.json network-config testnet now
near contract download-abi donation-product.repro-fct-30.testnet save-to-file donation-product_repro-fct-30_testnet.abi.json network-config testnet now
❯ diff donation-product_repro-fct-30_testnet.abi.json repro-fct-product-30_testnet.abi.json
8c8
<       "builder": "cargo-near 0.6.2"
---
>       "builder": "cargo-near 0.6.3"

Presumable fix is to export CARGO_NEAR_VERSION and reuse it inside of nested builds with cargo_near::build_extended in build.rs or remove https://github.com/near/near-abi-rs/blob/main/near-abi/src/lib.rs#L65 field entirely.

race-of-sloths commented 1 month ago

🌟 Score recorded!

@frol, thank you for scoring this pull request in the Race of Sloths!

race-of-sloths commented 1 month ago

✅ PR is finalized!

Your contribution is much appreciated with a final score of 8! You have received 90 (80 base + 10 monthly bonus) Sloth points for this contribution

Congratulations @dj8yfo! Your PR was highly scored and you completed another monthly streak! To keep your monthly streak make another pull request next month and get 8+ score for it