-
Notifications
You must be signed in to change notification settings - Fork 71
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 page comparing ink! and CosmWasm #63
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start!
By the way, do you also mind wrapping lines at 90 characters?
docs/intro/ink-vs-cosmwasm.md
Outdated
|
||
The architecture philosophy is likely the point where CosmWasm and ink! differ the most. CosmWasm follows the actor model design pattern, while ink! follows a synchronous execution model. That means some fundamental differences in how the source code is structured. | ||
|
||
After a CosmWasm contract is deployed to the chain, it needs to be instantiated before it is usable. An ink! contract on the other hand is usable right after it’s been deployed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under the hood we also have a different deploy
and instantiate
steps, but the UIs just hide that for you. One benefit of this is that you can deploy a contract once (say, an ERC-20) and instantiate it multiple times with different parameters (token name, decimals, etc.).
Not sure if this need to be in the Architecture
section though, could be closer to where we talk about the constructors
docs/intro/ink-vs-cosmwasm.md
Outdated
- `execute` which has the actor perform operations to its internal state. | ||
- `query` which retrieves data from the actor’s internal state. | ||
|
||
An ink! contract can have as many entry point functions as the developer desires, and differently from CosmWasm, it doesn’t rely on JSON schemas for defining how the messages are structured. Instead, ink! makes heavy usage of Rust macros. The main ink! macros are: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you refer to "entry point functions" do you mean public dispatchables (e.g #[ink(message)]
)?
docs/intro/ink-vs-cosmwasm.md
Outdated
An ink! contract can have as many entry point functions as the developer desires, and differently from CosmWasm, it doesn’t rely on JSON schemas for defining how the messages are structured. Instead, ink! makes heavy usage of Rust macros. The main ink! macros are: | ||
- `#[ink(storage)]` which annotates a struct with the main variables that represent a contract internal state. | ||
- `#[ink(event)]` and `#[ink(topic)]` which annotates a struct and its members as the events and topics that the contract might emit. | ||
- `#[ink(constructor)]` which is called when the contract is deployed, and is responsible for bootstrapping the initial contract state into the storage. It is analogous to the CosmWasm instantiate function, with the difference that it is called as soon as the contract is deployed onto the chain, not on separate instantiation calls. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `#[ink(constructor)]` which is called when the contract is deployed, and is responsible for bootstrapping the initial contract state into the storage. It is analogous to the CosmWasm instantiate function, with the difference that it is called as soon as the contract is deployed onto the chain, not on separate instantiation calls. | |
- `#[ink(constructor)]` which is called when the contract is deployed, and is responsible for bootstrapping the initial contract state into the storage. It is analogous to the CosmWasm `instantiate` function, with the difference that it is called as soon as the contract is deployed onto the chain, not on separate instantiation calls. |
docs/intro/ink-vs-cosmwasm.md
Outdated
- `query` which retrieves data from the actor’s internal state. | ||
|
||
An ink! contract can have as many entry point functions as the developer desires, and differently from CosmWasm, it doesn’t rely on JSON schemas for defining how the messages are structured. Instead, ink! makes heavy usage of Rust macros. The main ink! macros are: | ||
- `#[ink(storage)]` which annotates a struct with the main variables that represent a contract internal state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `#[ink(storage)]` which annotates a struct with the main variables that represent a contract internal state. | |
- `#[ink(storage)]` which annotates a struct which represents contract's internal state. |
docs/intro/ink-vs-cosmwasm.md
Outdated
An ink! contract can have as many entry point functions as the developer desires, and differently from CosmWasm, it doesn’t rely on JSON schemas for defining how the messages are structured. Instead, ink! makes heavy usage of Rust macros. The main ink! macros are: | ||
- `#[ink(storage)]` which annotates a struct with the main variables that represent a contract internal state. | ||
- `#[ink(event)]` and `#[ink(topic)]` which annotates a struct and its members as the events and topics that the contract might emit. | ||
- `#[ink(constructor)]` which is called when the contract is deployed, and is responsible for bootstrapping the initial contract state into the storage. It is analogous to the CosmWasm instantiate function, with the difference that it is called as soon as the contract is deployed onto the chain, not on separate instantiation calls. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `#[ink(constructor)]` which is called when the contract is deployed, and is responsible for bootstrapping the initial contract state into the storage. It is analogous to the CosmWasm instantiate function, with the difference that it is called as soon as the contract is deployed onto the chain, not on separate instantiation calls. | |
- `#[ink(constructor)]` which is called when the contract is deployed, and is responsible for bootstrapping the initial contract state into the storage. It is analogous to the CosmWasm instantiate function. |
The architecture philosophy is likely the point where CosmWasm and ink! differ the most. CosmWasm follows the actor model design pattern, while ink! follows a synchronous execution model. That means some fundamental differences in how the source code is structured. | ||
|
||
After a CosmWasm contract is deployed to the chain, it needs to be instantiated before it is usable. An ink! contract on the other hand is usable right after it’s been deployed. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add a section here like
# Development
docs/intro/ink-vs-cosmwasm.md
Outdated
|
||
For CosmWasm development and on-chain testing, `wasmd` can be operated as a local setup (single or multiple nodes), or connected to the `cliffnet` public test network. | ||
|
||
Ink! contracts can be deployed on a few different options: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ink! contracts can be deployed on a few different options: | |
ink! contracts can be deployed on a few different options: |
docs/intro/ink-vs-cosmwasm.md
Outdated
|
||
There are other ink! macros, for which details can be found at [Macros & Attributes](/macros-attributes). | ||
|
||
# Node Template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Node Template | |
# Local Development Network |
docs/intro/ink-vs-cosmwasm.md
Outdated
|
||
# Node Template | ||
|
||
CosmWasm is modular, meaning that any blockchain using the Cosmos SDK can add smart contract support to their chain. That is similar to the Substrate approach, where chains have the option to add pallet-contracts to their runtime. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move this to the Architecture
section
|
||
In terms of Substrate, `substrate-node-template` is a basic generic template of a node. Similar to `x/wasm`, `pallet-contracts` is the module that adds WebAssembly smart contract functionality to the chain. Parity provides [substrate-contracts-node](https://github.com/paritytech/substrate-contracts-node), which is analogous to `wasmd`: a basic template node for smart contract development. | ||
|
||
# Testnets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move this after Unit Testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
#62