informalsystems / cosmwasm-to-quint

Semi-automated modelling and Model-Based Testing for CosmWasm contracts
Apache License 2.0
14 stars 1 forks source link

Stub generation #1

Closed bugarela closed 7 months ago

bugarela commented 7 months ago

Hello :octocat:

Here's the initial version of quint stubs generation for cosmwasm contracts. This version works for ctf01 and ctf02.

I'm using the rustc_plugin crate to define a compiler callback that prints quint to STDOUT. The core is implemented over the rustc_hir (Rust's High-Level IR), so we can freely change how the tool is called, as long as it receives the HIR for the CosmWasm project.

File structure

HIR Navigation

This is recursing into the HIR via the Translatable trait translate functions. These functions take a context and return a string, therefore, any information that needs to be passed beteween different components should be added to the context.

The context is mutable for now, as this seems to be the rust way. We might want to make it non-mutable if the mutability gets too confusing. I'm already having to "remember" to clear data from the context after consuming it in some places.