* Start cosmos-sdk v0.47 integration (#1136) * Upgrade to sdk v0.47 branch * More integration work * SDK version upgrade; fixes * More fixes * Fixes * Deactivate failing tests * SDK + ibc-go version upgrades * limix gas fix (cherry picked from commit f7f841768e5051d96d243b42ce4f231a33020326) * with valset in bench (cherry picked from commit 35b2a8fd2c23d6160fca540771fd348913f7f143) * Revert staking query handler; fix tests * Minor cleanup * Rebased * Address linter issues * Set legacy router proper * Deactivate failing test. Race condition needs to handled in SDK * Address some code smells * Bump sdk version * Use gov v1 internally for votes * Activate test after sdk fix * Add group test * Add config template for wasm fields * Add Rust backtrace flag for more debug output on simulations * Set unique node folder for tests * Revert "Add Rust backtrace flag for more debug output on simulations" This reverts commit 218c3c6ce137dc02f7bc38391408d3460fb27e6f. * Simulations * Run also im/export + deterministic sims * Add package prefix to interfaces * Add signer annotation (https://github.com/cosmos/cosmos-sdk/issues/10933), minor cleanup * Bump sdk version * Review comments Co-authored-by: vuong <nguyenvuong1122000@gmail.com> * Bump bufbuild/buf-setup-action from 1.11.0 to 1.12.0 Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.11.0 to 1.12.0. - [Release notes](https://github.com/bufbuild/buf-setup-action/releases) - [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.11.0...v1.12.0) --- updated-dependencies: - dependency-name: bufbuild/buf-setup-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> (cherry picked from commitf4905955b5) * Remove intertx for vanilla ICA * fix msg format in EVENTS.md (cherry picked from commit38d466adfd) * Better to sdk coin convertion (#1164) * Better to sdk coin convertion * Review feedback (cherry picked from commita925a9ed61) * Disallow only address permission (#1163) * Remove AccessTypeOnlyAddress for store msg * Remove AccessTypeOnlyAddress for update config msg * Review feedback Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com> Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com> (cherry picked from commit8991633de2) * Integrate wasmvm v1.2.0 (backport #1161) (#1175) * Integrate wasmvm v1.2.0 (#1161) * Bump wasmvm version * Bump wasm test contracts * Encode weighted votes * Encode instantiate2 * Handle code info query; better wasmvm errors * Fix readme * Make linter happy * add non cgo build * Review comments * Bump wasmvm to release version Co-authored-by: jhernandezb <contact@jhernandez.me> (cherry picked from commit957b38e0a5) # Conflicts: # x/wasm/keeper/handler_plugin_encoders.go # x/wasm/keeper/handler_plugin_encoders_test.go # x/wasm/keeper/keeper.go # x/wasm/keeper/keeper_test.go * Adress merge conflicts Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> * Bump bufbuild/buf-setup-action from 1.12.0 to 1.13.0 Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.12.0 to 1.13.0. - [Release notes](https://github.com/bufbuild/buf-setup-action/releases) - [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.12.0...v1.13.0) --- updated-dependencies: - dependency-name: bufbuild/buf-setup-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> (cherry picked from commitffa0e5e5e1) * Emit events for setContractAdmin + setAccessConfig (#1179) (cherry picked from commitc9e7830ac1) * Dependency upgrades (#1172) * Bump sdk version to lastest * Bump ibc-go version to lastest * Remove channel hack * Update to ibc-go v7 + protoVer=0.11.5 * Bump bufbuild/buf-setup-action from 1.13.0 to 1.13.1 Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.13.0 to 1.13.1. - [Release notes](https://github.com/bufbuild/buf-setup-action/releases) - [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.13.0...v1.13.1) --- updated-dependencies: - dependency-name: bufbuild/buf-setup-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> (cherry picked from commitde27e7f82f) * Fix typos (backport #1185) (#1194) * Fix typos (cherry picked from commitc88b8194cb) # Conflicts: # proto/cosmwasm/wasm/v1/tx.proto * Fix merge conflict --------- Co-authored-by: Alex Peters <alpe@users.noreply.github.com> * Bump bufbuild/buf-setup-action from 1.13.1 to 1.14.0 (#1200) Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.13.1 to 1.14.0. - [Release notes](https://github.com/bufbuild/buf-setup-action/releases) - [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.13.1...v1.14.0) --- updated-dependencies: - dependency-name: bufbuild/buf-setup-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commitf3fc31c386) * list-contract-by-code bugfix (cherry picked from commit2ccffed778) * fix: stargate querier does not reset the state (cherry picked from commitfd0323541d) * test: add unit test (cherry picked from commit6d8018ac59) * Add Windows client support (#1197) * Add Windows client support * Separate server and windows client --------- Co-authored-by: Alex Peters <alpe@users.noreply.github.com> (cherry picked from commit8a20779518) * Bump bufbuild/buf-setup-action from 1.14.0 to 1.15.0 Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.14.0 to 1.15.0. - [Release notes](https://github.com/bufbuild/buf-setup-action/releases) - [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.14.0...v1.15.0) --- updated-dependencies: - dependency-name: bufbuild/buf-setup-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> (cherry picked from commite5fab3da5a) * Rename windows client binary (cherry picked from commitde09c7fe2b) * Return IBC packet sequence number (backport #1225) (#1233) * Return IBC packet sequence number (#1225) * Return IBC packet sequence number * Fix review feedbacks * Remove names to return values in DispatchMsg method * Fix comments (cherry picked from commit4f1c57fc12) # Conflicts: # x/wasm/keeper/handler_plugin.go * Fix merge conflict --------- Co-authored-by: pinosu <95283998+pinosu@users.noreply.github.com> Co-authored-by: Alex Peters <alpe@users.noreply.github.com> * Test rust panic for regression (cherry picked from commita52e604966) * Fix client checksum verification (#1234) * Fix client checksum verification * Review comments (cherry picked from commit1a8019b380) # Conflicts: # x/wasm/client/cli/gov_tx.go * Fix merge conflict * Fix linters * Configure sonarcloud analysis (cherry picked from commit85cf1614fb) * Bump bufbuild/buf-setup-action from 1.15.0 to 1.15.1 Bumps [bufbuild/buf-setup-action](https://github.com/bufbuild/buf-setup-action) from 1.15.0 to 1.15.1. - [Release notes](https://github.com/bufbuild/buf-setup-action/releases) - [Commits](https://github.com/bufbuild/buf-setup-action/compare/v1.15.0...v1.15.1) --- updated-dependencies: - dependency-name: bufbuild/buf-setup-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> (cherry picked from commit730ea5a1cf) * Make `CaptureIbcEvents` in ibctesting public. Before this change, it wasn't possible to implement the `chain.SendMsgs` method without [copying](https://github.com/public-awesome/ics721/blob/main/e2e/suite_helpers.go#L81-L98) them over. (cherry picked from commitb64fa078a3) * Upgrade to wasmvm 1.2.1 (backport #1245) (#1254) * Upgrade to wasmvm 1.2.1 (#1245) * Use wasmvm store adapter * Bump wasmvm to v1.2.1 (cherry picked from commit850f901b2e) # Conflicts: # go.mod # go.sum # x/wasm/keeper/keeper.go * Resolve conflicts --------- Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> * WIP All cometbft (#1244) * Dep upgrade; use CometBft * Remove duplicte message events * Add changelog for v0.31.0 (#1188) * Start changelog for v0.31.0 * Add ICA upgrade * Add proto version link to buf.build * Update changelog (#1239) * Update changelog * Update changelog with latest changes * Set release date --------- Co-authored-by: pinosu <95283998+pinosu@users.noreply.github.com> (cherry picked from commitbc0e817912) * Remove new message type event * Support msg update params gov proposal (#1247) * Add MsgUpdateParams support * Implement UpdateParams msg * Fix test UpdateParams * Add migration test * Fix * Fix lint issues * Revert changes according to review feedback * Remove more x/params dependencies * Remove x/params from genesis test * Formatting * Restore old changes * fix lint * Fix tests and restructure migrations * Rename alias for convention --------- Co-authored-by: Alex Peters <alpe@users.noreply.github.com> * Fix test data generator (#1263) * linting 47 pr (#1261) * lint cosmwasm for sdk 47 * fix * remove setGenesis * remove additional unused functions * pass tests * use SDK's errors module * unecessary conversions * unnecessary conversions * remove unneeded event manager * complete linting of tests for 47 * add test for reimportation * check errors * Update x/wasm/keeper/proposal_integration_test.go Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> * apply suggestion * suggestions * lints * don't return error in when making new transactions * no todo's in the code * Fix test data generator * Update x/wasm/types/genesis_test.go Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> * use the full string invalid address (2 words) always --------- Co-authored-by: Alexander Peters <alpe@users.noreply.github.com> * Regenerate from proto; remove dead code; polish code * Set SDK version to v0.47x.0 (#1262) * Set SDK version to v0.47x.0 * Set chainID * Minor updates * Set chainID for simulations * Buf mod update * Use sdk tag instead of hash in buf * Bump ibc-go to v7.0.0 * faddat/re merge main (#1274) undefined --------- Co-authored-by: vuong <nguyenvuong1122000@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: llllllluc <58892938+llllllluc@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Gjermund Garaba <gjermund@garaba.net> Co-authored-by: Nikhil Suri <nikhilsuri@comcast.net> Co-authored-by: Paul <p22626262@gmail.com> Co-authored-by: pinosu <95283998+pinosu@users.noreply.github.com> Co-authored-by: ekez <zekemedley@gmail.com> Co-authored-by: Jacob Gadikian <jacobgadikian@gmail.com>
Wasm Zone
This repository hosts Wasmd, the first implementation of a cosmos zone with wasm smart contracts enabled.
This code was forked from the cosmos/gaia repository as a basis and then we added x/wasm and cleaned up
many gaia-specific files. However, the wasmd binary should function just like gaiad except for the
addition of the x/wasm module.
Note: Requires Go 1.19+
For critical security issues & disclosure, see SECURITY.md.
Compatibility with CosmWasm contracts
Compatibility
A VM can support one or more contract-VM interface versions. The interface version is communicated by the contract via a Wasm export. This is the current compatibility list:
| wasmd | wasmvm | cosmwasm-vm | cosmwasm-std |
|---|---|---|---|
| 0.40 | v1.2.1 | 1.0-1.2 | |
| 0.31 | v1.2.0 | 1.0-1.2 | |
| 0.30 | v1.1.0 | 1.0-1.1 | |
| 0.29 | v1.1.0 | 1.0-1.1 | |
| 0.28 | v1.0.0 | 1.0-1.1 | |
| 0.27 | v1.0.0 | 1.0 | |
| 0.26 | 1.0.0-beta10 | 1.0 | |
| 0.25 | 1.0.0-beta10 | 1.0 | |
| 0.24 | 1.0.0-beta7 | 1.0.0-beta6 | 1.0 |
| 0.23 | 1.0.0-beta5 | 1.0 | |
| 0.22 | 1.0.0-beta5 | 1.0 | |
| 0.21 | 1.0.0-beta2 | 1.0 | |
| 0.20 | 1.0.0-beta | 1.0 | |
| 0.19 | 0.16 | 0.16 | |
| 0.18 | 0.16 | 0.16 | |
| 0.17 | 0.14 | 0.14 | |
| 0.16 | 0.14 | 0.14 | |
| 0.15 | 0.13 | 0.11-0.13 | |
| 0.14 | 0.13 | 0.11-0.13 | |
| 0.13 | 0.12 | 0.11-0.13 | |
| 0.12 | 0.12 | 0.11-0.13 | |
| 0.11 | 0.11 | 0.11-0.13 | |
| 0.10 | 0.10 | 0.10 | |
| 0.9 | 0.9 | 0.9 | |
| 0.8 | 0.8 | 0.8 |
Note: cosmwasm_std v1.0 means it supports contracts compiled by any v1.0.0-betaX or 1.0.x.
It will also run contracts compiled with 1.x assuming they don't opt into any newer features.
The 1.x cosmwasm_vm will support all contracts with 1.0 <= version <= 1.x.
Note that cosmwasm-std version defines which contracts are compatible with this system. The wasm code uploaded must
have been compiled with one of the supported cosmwasm-std versions, or will be rejected upon upload (with some error
message about "contract too old?" or "contract too new?"). cosmwasm-vm version defines the runtime used. It is a
breaking change to switch runtimes (you will need to organize a chain upgrade). As of cosmwasm-vm 0.13 we are
using wasmer 1.0, which is significantly more performant than the older versions.
Supported Systems
The supported systems are limited by the dlls created in wasmvm. In particular, we only support MacOS and Linux.
However, M1 macs are not fully supported. (Experimental support was merged with wasmd 0.24)
For linux, the default is to build for glibc, and we cross-compile with CentOS 7 to provide
backwards compatibility for glibc 2.12+. This includes all known supported distributions
using glibc (CentOS 7 uses 2.12, obsolete Debian Jessy uses 2.19).
As of 0.9.0 we support muslc Linux systems, in particular Alpine linux,
which is popular in docker distributions. Note that we do not store the
static muslc build in the repo, so you must compile this yourself, and pass -tags muslc.
Please look at the Dockerfile for an example of how we build a static Go
binary for muslc. (Or just use this Dockerfile for your production setup).
Stability
This is beta software It is run in some production systems, but we cannot yet provide a stability guarantee
and have not yet gone through and audit of this codebase. Note that the
CosmWasm smart contract framework used by wasmd is in a 1.0 release candidate
as of March 2022, with stability guarantee and addressing audit results.
As of wasmd 0.22, we will work to provide upgrade paths for this module for projects running a non-forked
version on their live networks. If there are Cosmos SDK upgrades, you will have to run their migration code
for their modules. If we change the internal storage of x/wasm we will provide a function to migrate state that
can be called by an x/upgrade handler.
The APIs are pretty stable, but we cannot guarantee their stability until we reach v1.0. However, we will provide a way for you to hard-fork your way to v1.0.
Thank you to all projects who have run this code in your mainnets and testnets and given feedback to improve stability.
Encoding
The used cosmos-sdk version is in transition migrating from amino encoding to protobuf for state. So are we now.
We use standard cosmos-sdk encoding (amino) for all sdk Messages. However, the message body sent to all contracts,
as well as the internal state is encoded using JSON. Cosmwasm allows arbitrary bytes with the contract itself
responsible for decoding. For better UX, we often use json.RawMessage to contain these bytes, which enforces that it is
valid json, but also give a much more readable interface. If you want to use another encoding in the contracts, that is
a relatively minor change to wasmd but would currently require a fork. Please open an issue if this is important for
your use case.
Quick Start
make install
make test
if you are using a linux without X or headless linux, look at this article or #31.
Protobuf
The protobuf files for this project are published automatically to the buf repository to make integration easier:
| wasmd version | buf tag |
|---|---|
| 0.31.x | e0e5a6fa433449e695af692478c86fb5 |
| 0.30.x | 6508ee062011440c907de6f5c40398ea |
| 0.29.x | 51931206dbe09529c1819a8a2863d291035a2549 |
Generate protobuf
make proto-gen
The generators are executed within a Docker container, now.
Dockerized
We provide a docker image to help with test setups. There are two modes to use it
Build: docker build -t cosmwasm/wasmd:latest . or pull from dockerhub
Dev server
Bring up a local node with a test account containing tokens
This is just designed for local testing/CI - do not use these scripts in production. Very likely you will assign tokens to accounts whose mnemonics are public on github.
docker volume rm -f wasmd_data
# pass password (one time) as env variable for setup, so we don't need to keep typing it
# add some addresses that you have private keys for (locally) to give them genesis funds
docker run --rm -it \
-e PASSWORD=xxxxxxxxx \
--mount type=volume,source=wasmd_data,target=/root \
cosmwasm/wasmd:latest /opt/setup_wasmd.sh cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6
# This will start both wasmd and rest-server, both are logged
docker run --rm -it -p 26657:26657 -p 26656:26656 -p 1317:1317 \
--mount type=volume,source=wasmd_data,target=/root \
cosmwasm/wasmd:latest /opt/run_wasmd.sh
CI
For CI, we want to generate a template one time and save to disk/repo. Then we can start a chain copying the initial state, but not modifying it. This lets us get the same, fresh start every time.
# Init chain and pass addresses so they are non-empty accounts
rm -rf ./template && mkdir ./template
docker run --rm -it \
-e PASSWORD=xxxxxxxxx \
--mount type=bind,source=$(pwd)/template,target=/root \
cosmwasm/wasmd:latest /opt/setup_wasmd.sh cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6
sudo chown -R $(id -u):$(id -g) ./template
# FIRST TIME
# bind to non-/root and pass an argument to run.sh to copy the template into /root
# we need wasmd_data volume mount not just for restart, but also to view logs
docker volume rm -f wasmd_data
docker run --rm -it -p 26657:26657 -p 26656:26656 -p 9090:9090 \
--mount type=bind,source=$(pwd)/template,target=/template \
--mount type=volume,source=wasmd_data,target=/root \
cosmwasm/wasmd:latest /opt/run_wasmd.sh /template
# RESTART CHAIN with existing state
docker run --rm -it -p 26657:26657 -p 26656:26656 -p 1317:1317 \
--mount type=volume,source=wasmd_data,target=/root \
cosmwasm/wasmd:latest /opt/run_wasmd.sh
Runtime flags
We provide a number of variables in app/app.go that are intended to be set via -ldflags -X ...
compile-time flags. This enables us to avoid copying a new binary directory over for each small change
to the configuration.
Available flags:
-X github.com/CosmWasm/wasmd/app.NodeDir=.corald- set the config/data directory for the node (default~/.wasmd)-X github.com/CosmWasm/wasmd/app.Bech32Prefix=coral- set the bech32 prefix for all accounts (defaultwasm)-X github.com/CosmWasm/wasmd/app.ProposalsEnabled=true- enable all x/wasm governance proposals (defaultfalse)-X github.com/CosmWasm/wasmd/app.EnableSpecificProposals=MigrateContract,UpdateAdmin,ClearAdmin- enable a subset of the x/wasm governance proposal types (overridesProposalsEnabled)
Examples:
wasmdis a generic, permissionless version using thecosmosbech32 prefix
Compile Time Parameters
Besides those above variables (meant for custom wasmd compilation), there are a few more variables which
we allow blockchains to customize, but at compile time. If you build your own chain and import x/wasm,
you can adjust a few items via module parameters, but a few others did not fit in that, as they need to be
used by stateless ValidateBasic(). Thus, we made them public var and these can be overridden in the app.go
file of your custom chain.
wasmtypes.MaxLabelSize = 64to set the maximum label size on instantiation (default 128)wasmtypes.MaxWasmSize=777000to set the max size of compiled wasm to be accepted (default 819200)wasmtypes.MaxProposalWasmSize=888000to set the max size of gov proposal compiled wasm to be accepted (default 3145728)
Genesis Configuration
We strongly suggest to limit the max block gas in the genesis and not use the default value (-1 for infinite).
"consensus_params": {
"block": {
"max_gas": "SET_YOUR_MAX_VALUE",
Tip: if you want to lock this down to a permisisoned network, the following script can edit the genesis file
to only allow permissioned use of code upload or instantiating. (Make sure you set app.ProposalsEnabled=true
in this binary):
sed -i 's/permission": "Everybody"/permission": "Nobody"/' .../config/genesis.json
Contributors
Much thanks to all who have contributed to this project, from this app, to the cosmwasm framework, to example contracts and documentation.
Or even testing the app and bringing up critical issues. The following have helped bring this project to life:
- Ethan Frey ethanfrey
- Simon Warta webmaster128
- Alex Peters alpe
- Aaron Craelius aaronc
- Sunny Aggarwal sunnya97
- Cory Levinson clevinson
- Sahith Narahari sahith-narahari
- Jehan Tremback jtremback
- Shane Vitarana shanev
- Billy Rennekamp okwme
- Westaking westaking
- Marko marbar3778
- JayB kogisin
- Rick Dudley AFDudley
- KamiD KamiD
- Valery Litvin litvintech
- Leonardo Bragagnolo bragaz
Sorry if I forgot you from this list, just contact me or add yourself in a PR :)