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

contract init should generate a contract that's compatible with fuzzing #1800

Open
leighmcculloch opened this issue Dec 17, 2024 · 0 comments · May be fixed by #1814
Open

contract init should generate a contract that's compatible with fuzzing #1800

leighmcculloch opened this issue Dec 17, 2024 · 0 comments · May be fixed by #1814
Assignees
Labels
bug Something isn't working

Comments

@leighmcculloch
Copy link
Member

leighmcculloch commented Dec 17, 2024

What version are you using?

22.0.1

What did you do?

  1. Create a contract.
    stellar contract init
    
  2. Add fuzzing to the contract.
    cargo fuzz init
    
  3. Edit the fuzz_target_1 to use the contract, by referencing the contract's crate.
  4. Run the fuzzer
    cargo +nightly fuzz run fuzz_target_1
    

What did you expect to see?

The fuzz test run.

What did you see instead?

Errors saying that the contract crate doesn't exist and isn't imported as a dependency. The crate is listed as a dependency, but fails to import because the crate-type is fixed to cdylib only.

Suggested fix

The crate-type should default to ["lib", "cdylib"] so that the crate can be released as a wasm file, as well as be imported into fuzzing tests.

There's some history to why the lib wasn't included. Having multiple crate-type's causes builds for wasms to skip link-time optimizations (LTO), resulting in larger wasm files. We used to avoid that issue by defaulting to, and telling folks, not to use lib in their crate-type. But that was impractical advice, because you need lib in the crate-type to do fuzzing and some other things. Today we recommend using stellar contract build that runs the build with some flags that result in LTO being activated for the wasm build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog (Not Ready)
Development

Successfully merging a pull request may close this issue.

1 participant