ink! Analyzer: Retroactive funding for ink! 4.x to 5.0 migration features, and other major improvements
### IMPORTANT: If you're having trouble loading and voting on this proposal in Polkassembly on Chrome You can: - Either use Subsquare (https://polkadot.subsquare.io/referenda/779). - Or try Polkassembly on Firefox (may be slow, but loads eventually). There seems to be an issue with Polkassembly loading this proposal in Chrome that's already been reported to the team at https://github.com/polkassembly/polkassembly/issues/1608 --- Hello, I'm [David Semakula (@davidsemakula)][me] - the creator of [ink! analyzer][ink-analyzer]. This is a follow-up proposal to [#619: ink! Analyzer: Retroactive funding for ink! v5 support][ink-v5-proposal]. So, if you've already read [#619][ink-v5-proposal], you can skip ahead to the "Proposal Ask" section, as the updated number of *unique installs* for the [Visual Studio Code extension][vs-code-extension] (now *~415* compared *~350* in [#619][ink-v5-proposal]) is the only meaningful difference in the introductory sections. Additionally, be sure to also check out the "Previous Funding" section for more context about scope differences, and timing of the proposals and related ink! analyzer feature releases. [me]: https://github.com/davidsemakula [ink-analyzer]: https://github.com/ink-analyzer [ink-v5-proposal]: https://polkadot.polkassembly.io/referenda/619 ## What's ink! analyzer? [ink! analyzer][ink-analyzer] is a collection of modular and reusable libraries and tools for semantic analysis of [ink!] smart contracts. In short, ink! analyzer is to ink!, what [rust-analyzer] is to [Rust]. [ink!]: https://use.ink [rust-analyzer]: https://github.com/rust-lang/rust-analyzer [Rust]: https://www.rust-lang.org/ More technically, rust-analyzer is a Rust compiler frontend/semantic analyzer for [IDEs][IDE] that's built on a [lossless and resilient parser][ra-design-goals] (this part is very important for IDE/editor tooling because the program is essentially perpetually incorrect as you type in an IDE/editor). So rust-analyzer "understands" core Rust language concepts (e.g. that a trait implementation like `impl MyTrait for MyStruct {}` must define all the required associated items of the trait), and provides [intelligent editing features][intellisense] to help you with those kinds of core Rust language features. However, when it comes to [Rust syntax extensions/DSLs like ink!'s attribute macros][ink-macros], when you annotate a `mod` item with `#[ink::contract]`, all rust-analyzer "knows" is that this is a custom attribute, it doesn't "know" that an ink! contract `mod` must have exactly one `struct` item annotated with `#[ink(storage)]` or any of the other semantic rules for ink! contracts, so this is where ink! analyzer comes in 🙂. [IDE]: https://en.wikipedia.org/wiki/Integrated\_development\_environment [intellisense]: https://code.visualstudio.com/docs/editor/intellisense [ink-macros]: https://use.ink/getting-started/creating-an-ink-project/ [ra-design-goals]: https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/syntax.md#design-goals For a deeper dive on the problems ink! analyzer solves and technical details about its architecture, check out [this detailed introductory blog post][ink-analyzer-intro]. You can also check out [this awesome X/Twitter thread by the ink! lang team][twitter-thread] for a quick walkthrough of ink! analyzer features. [ink-analyzer-intro]: https://analyze.ink/blog/introducing-ink-analyzer [twitter-thread]: https://twitter.com/ink\_lang/status/1762795949259448776 ## Adoption ink! analyzer's most user/developer facing component is currently a [Visual Studio Code extension][vs-code-extension], which has over *~415 unique installs* (first released in Aug/2023). However, ink! analyzer is built with an IDE/editor agnostic architecture to maximize re-usability of it's core components i.e. - [A modular domain-specific semantic analysis library for ink!][semantic-analyzer] built on a resilient and lossless parser. - A [Language Server Protocol (LSP)][LSP] [implementation][lsp-server] built on top of the aforementioned semantic analysis library.  *Figure 1: ink! Analyzer - LSP based Architecture Diagram* These two components (i.e. the [semantic analyzer][semantic-analyzer] and [language server][lsp-server]) can be reused to add ink! language support to multiple IDEs, code editors and other development tools. In particular, a large number of IDEs and code editors support LSP servers, these include [Visual Studio Code, Visual Studio, Vim / Neovim, Emacs, Atom, Sublime Text, Acme, Lapce, Eclipse and many more][lsp-tools]. [semantic-analyzer]: https://github.com/ink-analyzer/ink-analyzer/tree/master/crates/analyzer [lsp-server]: https://github.com/ink-analyzer/ink-analyzer/tree/master/crates/lsp-server [vs-code-extension]: https://marketplace.visualstudio.com/items?itemName=ink-analyzer.ink-analyzer [LSP]: https://microsoft.github.io/language-server-protocol/ [lsp-tools]: https://microsoft.github.io/language-server-protocol/implementors/tools/ Therefore, ink! analyzer makes it relatively easy for: - Users to enable ink! language support for their IDE, code editor or other development tool if it has either a native/built-in or third-party LSP client that can be configured to launch an LSP server using an executable command (i.e. the path to an [installed ink! Language Server binary][lsp-server-install]) and can use stdio (standard in/standard out) as the message transport. - Developers to either build extensions/plugins/integrations that add ink! language support to any tool with robust LSP client libraries/APIs/modules, or add first-class ink! language support to an existing LSP client (e.g. an open-source extension/plugin/integration). [lsp-server-install]: https://github.com/ink-analyzer/ink-analyzer/tree/master/crates/lsp-server#installation The latter option typically provides a better user experience as the user doesn't have to manually install (and update) the ink! Language Server as it can be bundled (or installed/updated) by the extension/plugin/integration. The [Visual Studio Code extension][vs-code-extension] serves as a showcase and [reference implementation][vs-code-extension-src] for this use case/approach. However, ink! analyzer also [distributes compiled ink! Language Server (`ink-lsp-server`) binaries for most of the major platforms/architectures][ink-lsp-server-releases] for non-VS Code users and developers. [vs-code-extension-src]: https://github.com/ink-analyzer/ink-vscode [ink-lsp-server-releases]: https://github.com/ink-analyzer/ink-analyzer/releases **NOTE:** While the first version of the [ink! analyzer VS Code extension][vs-code-extension] was released in Aug/2023, work on the core components (i.e. [semantic analyzer][semantic-analyzer] and [language server][lsp-server]) started well before in Mar/2023. ## Proposal Ask This treasury proposal requests *retroactive funding* for adding [ink! 4.x to 5.0 migration][ink-v4-to-v5] features, along with other major improvements, to ink! analyzer. Requested Amount: $56,750 ([in USDT on AssetHub][treasury-usdt] - learn more [here][treasury-usdt-forum], [here][treasury-usdt-test] and [here][asset-hub-balance]) [ink-v5]: https://github.com/paritytech/ink/releases/tag/v5.0.0 [ink-v4-to-v5]: https://use.ink/faq/migrating-from-ink-4-to-5 [treasury-usdt]: https://polkadot.subsquare.io/referenda/457 [treasury-usdt-forum]: https://forum.polkadot.network/t/multi-asset-treasury-and-milestone-based-spends/6780 [treasury-usdt-test]: https://polkadot.subsquare.io/referenda/756 [asset-hub-balance]: https://assethub-polkadot.subscan.io/account/14xmwinmCEz6oRrFdczHKqHgWNMiCysE2KrA4jXXAAM1Eogk | Breakdown/Tasks | Hours | |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------| | ink! 4.x to 5.0 attribute-based entity migrations
- Events 2.0 migration
- Chain extension attribute macro and associated `fn` attribute argument migrations
- SCALE codec traits `derive` migration
- E2E test attribute and argument migration
- Unit tests
| ~108 | | ink! 4.x to 5.0 e2e `Client` and `MessageBuilder` API migrations
- New "builder" APIs and `ContractsBackend` trait for `instantiate`, `instantiate_dry_run`, `call`, `call_dry_run`, `upload` e.t.c
- New `ChainBackend` trait for `create_and_fund_account`, `balance`, `runtime_call` e.t.c
- Update e2e tests `fn` signature to include new `E2EBackend` trait
- Replace deprecated `build_message` fn, `MessageBuilder` type, and related `call` callback with new API equivalents
- Remove ink! e2e deprecated imports i.e. `build_message`, `MessageBuilder` e.t.c
- Unit tests
| ~196 | | ink! 4.x to 5.0 semantics-preserving cross-contract host function related API migrations
- Replace `call` from `CallBuilder` via `build_call` with `call_v1`
- Add an `instantiate_v1` call before other method calls on `CreateBuilder`s via `build_create`
- Replace `instantiate_contract` and `invoke_contract` with `instantiate_contract_v1` and `invoke_contract_v1` for direct calls in any function
- Replace `instantiate_contract` and `invoke_contract` with `instantiate_contract_v1` and `invoke_contract_v1` for indirect calls via `Self::env()` and `self.env()` in constructors and messages
- Replace `Call` constructors with `CallV1`
- Unit tests
| ~156 | | ink! 4.x to 5.0 migration command and code action, and `Cargo.toml` migration
- `Cargo.toml` migration
- Replace references to `SCALE` codec items with equivalent `ink` re-exports
- Command and code action for performing migration (across semantic analyzer, language server and VS Code extension)
- Unit tests
| ~124 | | General ink! 5.0 additions and improvements
- Support for ink! workspace dependencies
- Command and code action for extracting events into standalone packages (across semantic analyzer, language server and VS Code extension)
- Completions and code actions for ink! combine extensions declarative macro
- Unit tests
| ~132 | | General robustness and feature improvements
- Update completions to support inserting full ink! entities (i.e. full Rust items not just ink! attribute macros and arguments e.g. ink! constructor and message `fn` items as completions when typing `fn` inside `impl` blocks e.t.c)
- Improve item resolution utilities (e.g. add ability to resolve imports in function items)
- Improve interface for traversing ink! attribute argument meta-items
- Performance improvements (e.g. removing needless eager evaluation)
- Unit tests
| ~144 | | Integration tests (across semantic analyzer, language server and VS Code extension) | ~40 | | Documentation | ~8 | | **Total Hours** | **~908** | | **Hourly Rate** | **$62.5** | | **Total Amount** | **$56,750** | **NOTE:** All ink! analyzer components are [fully open-source][ink-analyzer] and distributed under [OSI approved licenses][OSI-licenses]. [ink-analyzer-architecture]: https://github.com/ink-analyzer/ink-analyzer/blob/master/README.md#architecture [OSI-licenses]: https://opensource.org/licenses ## Previous Funding Previous work for ink! analyzer was funded by two generous [Web3 Foundation technical grants][w3f-grants], and one retroactive treasury proposal. - https://github.com/w3f/Grants-Program/blob/master/applications/ink-analyzer.md ($30,000) - https://github.com/w3f/Grants-Program/blob/master/applications/ink-analyzer-phase-2.md ($59,600) - https://polkadot.polkassembly.io/referenda/619 (2,812.27 DOT/ ~$26,500 on 27/Mar/2024) However, with the project now relatively mature and having some meaningful adoption, I've moved to a retroactive treasury funding model for future updates. **NOTE:** The [previous "v5 support" retroactive treasury proposal][ink-v5-proposal] only included ink! v5 support, while this proposal is *mainly focused* on [ink! v4 to v5 migration][ink-v4-to-v5] features, but also includes a few other major improvements (e.g. support for ink! workspace dependencies, and a major update to [completions][vscode-completions] infrastructure, that enables support for full ink! entity completions, to complement the already existing support for ink! attribute macro and argument completions - see breakdown above for details and/or check out [this blog post][ink-analyzer-blog-updates]). Lastly, similar to the [previous "v5 support" retroactive treasury proposal][ink-v5-proposal], work on these features in ink! analyzer started well before the official [ink! v5 release][ink-v5] (13/Mar/2024), however, these features still "needed some polish" during the [initial release for ink! v5 support in ink! analyzer][ink-analyzer-v5-lsp-server] (16/Mar/2024 - [see also][ink-analyzer-v5-vscode]), and so were excluded from both the initial release and the [previous "v5 support" retroactive treasury proposal][ink-v5-proposal] (27/Mar/2024). [w3f-grants]: https://grants.web3.foundation/ [vscode-completions]: https://code.visualstudio.com/api/language-extensions/programmatic-language-features#show-code-completion-proposals [ink-analyzer-blog-updates]: https://analyze.ink/blog/ink-v4-to-v5 [ink-analyzer-v5-lsp-server]: https://github.com/ink-analyzer/ink-analyzer/releases/tag/lsp-server-v0.2.26 [ink-analyzer-v5-vscode]: https://github.com/ink-analyzer/ink-vscode/releases/tag/v0.1.27 ## Why not Wasm Smart Contracts Bounty / ink!ubator ? Historically, as noted above, initial work for ink! analyzer was funded by [Web3 Foundation technical grants][w3f-grants]. This is partly because [development of ink! analyzer kicked off in Mar/2023][ink-analyzer-pr], while the [ink!ubator: Ecosystem Grants][inkubator-grants] program [only started receiving grant applications around ~May/2023][inkubator-pr] (note that discussions for the [Wasm Smart Contracts Bounty][wasm-bounty] started well before this though). In the present, with [ink!ubator being an incubation program following a cohort schedule][inkubator], and ink! analyzer now being a relatively mature project with some meaningful adoption, the need to support new [ink! features and syntax][ink-v5] as close to release as possible (hence the choice of retroactive funding), means the ink!ubator cohort schedule is not a good fit for this stage of the project. [ink-analyzer-pr]: https://github.com/w3f/Grants-Program/pull/1615 [inkubator]: https://use.ink/ubator [inkubator-grants]: https://github.com/use-inkubator/Ecosystem-Grants [inkubator-pr]: https://github.com/use-inkubator/Ecosystem-Grants/pull/7 [wasm-bounty]: https://polkadot.polkassembly.io/bounty/19 ## More about the author. I'm an independent Software Engineer & Systems Architect with over 10+ years of experience. I also [*independently* contribute][ra-contributions] to [rust-analyzer] (a Rust compiler front-end for IDEs). I've also made some [*independent* contributions][ink-contributions] to [ink!][ink-repo]. You can check out my [GitHub profile][me] and/or my [personal website][website] for more details. [website]: https://davidsemakula.com/ [ra-contributions]: https://github.com/rust-lang/rust-analyzer/pulls?q=is%3Apr+author%3Adavidsemakula [ink-contributions]: https://github.com/paritytech/ink/pulls?q=is%3Apr+author%3Adavidsemakula [ink-repo]: https://github.com/paritytech/ink
Comments (2)
Proposal Passed
3
of 3Summary
0%
Aye
0%
Nay
Aye (51)0.0 DOT
Support0.0 DOT
Nay (2)0.0 DOT
Voting Data
Approval%
Support%
Threshold0.00%
Threshold0.00%
Big thank you to everyone who supported this proposal! 🙂