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

Add deployments file and post-deployment anvil state to the list of GitHub Release artifacts #319

Closed
3 tasks
guidanoli opened this issue Oct 17, 2024 · 2 comments · Fixed by #323
Closed
3 tasks
Assignees
Labels
A-releases Area: releases A-workflows Area: workflows T-feature Type: feature
Milestone

Comments

@guidanoli
Copy link
Collaborator

📚 Context

In development environments, it is useful to have a local private network with all the contracts deployed in it. One way to achieve that is to run some development node (such as Anvil) and deploy the contracts through the deployment scripts.

One off-side to this approach is that the developer must have Node.js and pnpm installed in their local machine. Another option, if they are using Anvil as the development node, is to serialize the post-deployment state to a file.

This is an already supported feature of Anvil. Through the --dump-state option, you can serialize the state of the blockchain into a JSON file, which can be later recuperated by the --load-state command. If you want to load a state, do something, and then dump this new state into the same file, you can just use the --state command.

However, because Anvil is still under active development, and doesn't follow a strict semantic versioning approach, breaking changes can be introduced to the serialization format. Even recently, @tuler has improved Anvil by including mined transactions (see foundry-rs/foundry#8411). Because of this, it might be wise to pin a specific version of Anvil and let it be clear on the name of state file that this version should be used. A later version might be compatible, but we won't hold any warranty.

✔️ Solution

On the CI, we can run anvil --dump-state state.json and pnpm deploy:localhost (after #317).
The resulting file can be renamed to incorporate the version of Foundry used, and uploaded as a GitHub Release artifact. Users can then download this artifact through the GitHub web UI or by downloading the file directly with curl or wget. On their side, they can then run anvil --load-state state.json.

Additionally, we should also add the export/abi/localhost.json (after #317) file to the list of GitHub Release artifacts so that users can more easily interact with the contracts, knowing their addresses and ABIs.

📈 Subtasks

  • Edit CI to upload state file
  • Release an RC to test the CI
  • Check that state file indeed works
@guidanoli guidanoli added T-feature Type: feature A-workflows Area: workflows A-releases Area: releases labels Oct 17, 2024
@guidanoli guidanoli self-assigned this Oct 17, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Rollups Unit Oct 17, 2024
@guidanoli guidanoli added this to the 2.0.0 milestone Oct 17, 2024
@tuler
Copy link
Member

tuler commented Oct 17, 2024

Note that currently the @cartesi/devnet npm package is being responsible for bundling the anvil_state.json of the rollups contracts.
https://www.npmjs.com/package/@cartesi/devnet?activeTab=code

That is being maintained by the CLI devnet package
https://github.com/cartesi/cli/tree/main/packages/devnet

@guidanoli
Copy link
Collaborator Author

Yes, but @cartesi/devnet includes several contracts that are, although useful, unrelated to rollups-contracts, such as dummy token contracts, and account abstraction contracts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-releases Area: releases A-workflows Area: workflows T-feature Type: feature
Projects
Status: 🚀 Done
Development

Successfully merging a pull request may close this issue.

2 participants