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: improve clarity wasm deployment comparison #1358

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

hugocaillard
Copy link
Collaborator

Description

In clarinet console, we are already doing a complete comparison of the interpreter vs wasm results and diags (see code.
But it wasn't the case for contract deployments (in clarinet check or clarinet console).
This PR fixes it.

It also improves the handling of project with multiple contracts.

Test

The contract will result in a compile error in clarity wasm:

(define-map mp {x: uint} {y: (list 20 (response (buff 21) int)) })

(map-insert mp
  {x: u306845443603200851488318099 }
  {y: (list
    (ok 0xac50891b72b93b496d25caedc508e9f65b98727ee6)
    (ok 0x53f588bdbb3495aee902cdaa863d31e2dc42b8215d)
    (ok 0xccc90ca2258d144e11cd32c453599bd36d039120e6)
    (ok 0x032ee22a2028f05e537ebab0eae0fa2b8fc4ba8d1d)
  )}
)

This contract will return a different value between the interpreter (returning 7) and clarity-wasm (returning none)

(+ 3 4)

(define-private (foo) 42)

Load these two contracts in the same project to see how it handle errors in multiple contracts
It'll

✔ 2 contracts checked

> clarinet check --enable-clarity-wasm
Diagnostics of contract ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test differs between clarity and clarity-wasm
[components/clarinet-cli/src/frontend/cli.rs:1439] diags = Some(
    [],
)
[components/clarinet-cli/src/frontend/cli.rs:1440] wasm_diags = Some(
    [
        Diagnostic {
            level: Error,
            message: "Wasm Runtime Error: Runtime error while interpreting ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test: Wasm(Runtime(error while executing at wasm backtrace:\n    0: 0x17c5 - <unknown>!<wasm function 60>\n\nCaused by:\n    Wasm(InvalidIndicator(21))))",
            spans: [],
            suggestion: None,
        },
    ],
)
Evaluation value of contract ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.vault differs between clarity and clarity-wasm
[components/clarinet-cli/src/frontend/cli.rs:1449] value = Some(
    Some(
        Int(
            7,
        ),
    ),
)
[components/clarinet-cli/src/frontend/cli.rs:1450] wasm_value = Some(
    None,
)
It appears that Clarity-Wasm is returning an unexpected result.
Please help improve the Stacks network by reporting this issue at https://github.com/stacks-network/clarity-wasm/issues/new/choose and include the errors above along with the source code that triggered this.

✔ 2 contracts checked

@hugocaillard
Copy link
Collaborator Author

I started an other branch to explore how I can refactor this part of the code base, especially to simplify the DeploymentGenerationArtifacts type in the deployment flow. Not sure I'll get it done for the upcoming release though

Copy link

codecov bot commented Feb 21, 2024

Codecov Report

Attention: 23 lines in your changes are missing coverage. Please review.

Comparison is base (abc3458) 41.19% compared to head (3cc976e) 41.18%.

Files Patch % Lines
components/clarinet-cli/src/frontend/cli.rs 0.00% 20 Missing ⚠️
components/clarinet-deployments/src/lib.rs 25.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1358      +/-   ##
===========================================
- Coverage    41.19%   41.18%   -0.02%     
===========================================
  Files           86       86              
  Lines        31625    31637      +12     
===========================================
+ Hits         13029    13030       +1     
- Misses       18596    18607      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@csgui csgui left a comment

Choose a reason for hiding this comment

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

Code LGTM!

@hugocaillard hugocaillard merged commit 0f9e612 into develop Feb 21, 2024
19 checks passed
@hugocaillard hugocaillard deleted the feat/improve-clarity-wasm-handling branch February 21, 2024 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants