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

bug: wagmi generate with foundry plugin shuffles output, producing large diffs #2528

Closed
1 task done
dcposch opened this issue Jun 10, 2023 · 11 comments · Fixed by #2547
Closed
1 task done

bug: wagmi generate with foundry plugin shuffles output, producing large diffs #2528

dcposch opened this issue Jun 10, 2023 · 11 comments · Fixed by #2547
Labels
Good First Issue Misc: Good First Issue

Comments

@dcposch
Copy link

dcposch commented Jun 10, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Package Version

1.1.0

Current Behavior

Running wagmi generate outputs contracts in seemingly random order each time it's run.

Expected Behavior

Running wagmi generate twice on identical inputs should, ideally, generate identical outputs.

This has two main benefits:

  • Concise git diff
  • Reproducible builds

Steps To Reproduce

To reproduce easily

git clone https://github.com/daimo-eth/daimo
cd daimo/packages/daimo-api
git checkout 603a172e
npm ci && npm run gen

This runs wagmi generate. Finally, run

git diff

This shows a big diff. The input contracts have not changed. Outputgen/contracts.ts is functionally identical but reordered.

Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)

https://github.com/daimo-eth/daimo/tree/603a172eb9f902b11446f8d0721956cb338cd47a

Anything else?

This might be fixable by sorting the ABI items by name, internally, before generating output.

Finally, I recommend removing the date from the header line

// Generated by @wagmi/cli@1.1.0 on 6/10/2023 at 4:33:44 AM

at which point identical inputs = identical generated outputs.

@tmm
Copy link
Member

tmm commented Jun 10, 2023

Will take a look. Might be faster if you create a minimal example with only the code required to reproduce.

@dcposch
Copy link
Author

dcposch commented Jun 10, 2023

Thanks! I can if necessary, but try the steps to reproduce above first--lmk if you run into any issues.

@Iamshankhadeep
Copy link
Contributor

@tmm can I work on this issue ?

@tmm
Copy link
Member

tmm commented Jun 14, 2023

@Iamshankhadeep go for it!

@llllvvuu
Copy link
Contributor

PR looks good, doesn't address the header diff but that's trivial to deal with using sed 1d. Use-case for this is to run codegen in CI to prevent bugs.

@gosuto-inzasheru
Copy link

i can confirm we see the same thing happening in two different locals with identical environments: generated.ts's order of contracts differs resulting in big diffs.

@IstoraMandiri
Copy link

Would also like an option to disable the header - there's no need to check in a new timestamp.

@llllvvuu
Copy link
Contributor

Would also like an option to disable the header - there's no need to check in a new timestamp.

Yeah I think this is a reasonable use-case too.

Usually people say not to check in "build outputs". But that assumes wagmi is another thing to add to the dev/watch/build/publish pipeline, and it's easier to just check it into GitHub. I wrote up the proposal here:

#2930

@dcposch
Copy link
Author

dcposch commented Nov 27, 2023

Seeing this issue again

Local

> wagmi -v && wagmi generate

wagmi/1.5.2 darwin-arm64 node-v20.9.0
wagmi/1.5.2
...
✔ Validating plugins
✔ Resolving contracts
✔ Running plugins
✔ Writing to src/generated.ts

In CI

> wagmi -v && wagmi generate

wagmi/1.5.2 linux-x64 node-v20.9.0
wagmi/1.5.2
...
- Validating plugins
✔ Validating plugins
- Resolving contracts
✔ Resolving contracts
- Running plugins
✔ Running plugins
- Writing to src/generated.ts
✔ Writing to src/generated.ts

Reordering, but only on specific OSs?

wagmi generate output appears shuffled again, but only on the build machine (Ubuntu) vs local (Mac). Identical inputs.

Steps to reproduce:

Clone https://github.com/daimo-eth/daimo

git checkout d1a8eb9f1fd
npm ci
npm run codegen

...this should produce no diff on Mac and a large diff on Linux. See otherwise identical versions above ^

@dcposch
Copy link
Author

dcposch commented Nov 27, 2023

cc @tmm @llllvvuu

Copy link
Contributor

github-actions bot commented Jan 5, 2024

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest wagmi version. If you have any other comments you can create a new discussion.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good First Issue Misc: Good First Issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants