Skip to content

Commit

Permalink
resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Oct 17, 2022
2 parents ed72d71 + d8ebe64 commit 3be9232
Show file tree
Hide file tree
Showing 264 changed files with 5,597 additions and 43,274 deletions.
30 changes: 19 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,27 @@ jobs:
name: Build Docker artifact
command: docker build --pull -t "cosmwasm/wasmd:${CIRCLE_SHA1}" .
- run:
name: Push application Docker image to docker hub
name: Ensure libwasmvm version is correct
command: |
if [ "${CIRCLE_BRANCH}" = "master" ]; then
docker tag "cosmwasm/wasmd:${CIRCLE_SHA1}" cosmwasm/wasmd:latest
docker login --password-stdin -u "$DOCKER_USER" \<<<"$DOCKER_PASS"
docker push cosmwasm/wasmd:latest
docker logout
IN_DOCKER=$(docker run --rm "cosmwasm/wasmd:${CIRCLE_SHA1}" /usr/bin/wasmd query wasm libwasmvm-version)
echo "Runtime libwasmvm-version in docker: $IN_DOCKER"
IN_GOMOD=$(go list -m github.com/CosmWasm/wasmvm | cut -d" " -f2 | cut -d"v" -f2)
echo "wasmvm version in go.mod: $IN_GOMOD"
if [[ "$IN_DOCKER" != "$IN_GOMOD" ]]; then
echo "Mismatch of wasmvm versions detected"
exit 1
fi
- when:
condition:
equal: [ main, << pipeline.git.branch >> ]
steps:
- run:
name: Push application Docker image to docker hub
command: |
docker tag "cosmwasm/wasmd:${CIRCLE_SHA1}" cosmwasm/wasmd:latest
docker login --password-stdin -u "$DOCKER_USER" \<<<"$DOCKER_PASS"
docker push cosmwasm/wasmd:latest
docker logout
docker-tagged:
executor: golang
Expand All @@ -194,14 +207,9 @@ workflows:
version: 2
test-suite:
jobs:
# this is now a slow process... let's only run on master
- docker-image:
requires:
- setup-dependencies
filters:
branches:
only:
- master
- docker-tagged:
filters:
tags:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
paths:
- "**.go"
push:
branches: [ master ]
branches: [ main ]
paths:
- "**.go"

Expand All @@ -19,7 +19,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3.0.2
uses: actions/checkout@v3.1.0

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/proto-buf-publisher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.0.2
- uses: bufbuild/buf-setup-action@v1.7.0
- uses: actions/checkout@v3.1.0
- uses: bufbuild/buf-setup-action@v1.8.0

# lint checks
- uses: bufbuild/buf-lint-action@v1
Expand Down
37 changes: 34 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,43 @@
# Changelog

## [Unreleased](https://github.com/CosmWasm/wasmd/tree/HEAD)
- Upgrade go to v1.18 [\#866]https://github.com/CosmWasm/wasmd/pull/866/) ([faddat](https://github.com/faddat))

[Full Changelog](https://github.com/CosmWasm/wasmd/compare/v0.29.0...HEAD)

## [v0.29.0](https://github.com/CosmWasm/wasmd/tree/v0.29.0) (2022-10-10)

[Full Changelog](https://github.com/CosmWasm/wasmd/compare/v0.28.0...v0.29.0)
- Add dependencies for protobuf and remove third_party forlder [/#1030](https://github.com/CosmWasm/wasmd/pull/1030)
- Check wasmvm version on startup [\#1029](https://github.com/CosmWasm/wasmd/pull/1029/)
- Allow AccessConfig to use a list of addresses instead of just a single address [\#945](https://github.com/CosmWasm/wasmd/issues/945)
- Make contract addresses predictable \("deterministic"\) [\#942](https://github.com/CosmWasm/wasmd/issues/942)
- Add query for the total supply of a coin [\#903](https://github.com/CosmWasm/wasmd/pull/903) ([larry0x](https://github.com/larry0x))
- Upgrade go to v1.18 [\#866](https://github.com/CosmWasm/wasmd/pull/866/) ([faddat](https://github.com/faddat))
- Upgrade to ibc-go v3.3.0 REQUIRES [MIGRATION](https://github.com/cosmos/ibc-go/blob/v3.2.3/docs/migrations/support-denoms-with-slashes.md) [\#1016](https://github.com/CosmWasm/wasmd/pull/1016)
- Upgrade to cosmos-sdk v0.45.8 [\#964](https://github.com/CosmWasm/wasmd/pull/964/) ([faddat](https://github.com/faddat))
- Upgrade wasmvm to v1.1.1 [\#1012](https://github.com/CosmWasm/wasmd/pull/1012), see [wasmvm v1.1.1](https://github.com/CosmWasm/wasmvm/releases/tag/v1.1.1)
- Add documentation how to add x/wasm to a new Cosmos SDK chain [\#876](https://github.com/CosmWasm/wasmd/issues/876)
- Upgrade keyring / go-keychain dependencies (removes deprecate warning) [\#957](https://github.com/CosmWasm/wasmd/issues/957)
- Make contract pinning an optional field in StoreCode proposals [\#972](https://github.com/CosmWasm/wasmd/issues/972)
- Add gRPC query for WASM params [\#889](https://github.com/CosmWasm/wasmd/issues/889)
- Expose Keepers in app.go? [\#881](https://github.com/CosmWasm/wasmd/issues/881)
- Remove unused `flagProposalType` flag in gov proposals [\#849](https://github.com/CosmWasm/wasmd/issues/849)
- Restrict code access config modifications [\#901](https://github.com/CosmWasm/wasmd/pull/901)
- Prevent migration to a restricted code [\#900](https://github.com/CosmWasm/wasmd/pull/900)
- Charge gas to unzip wasm code [\#898](https://github.com/CosmWasm/wasmd/pull/898)

### Notable changes:
- BaseAccount and pruned vesting account types can be re-used for contracts addresses
- A new [MsgInstantiateContract2](https://github.com/CosmWasm/wasmd/pull/1014/files#diff-bf58b9da4b674719f07dd5421c532c1ead13a15f8896b59c1f724215d2064b73R75) was introduced which is an additional value for `message` type events
- Store event contains a new attribute with the code checksum now
- New `wasmd tx wasm instantiate2` CLI command for predictable addresses on instantiation
- New `cosmwasm_1_1` CosmWasm capability (former "feature") was introduced in [cosmwasm/#1356](https://github.com/CosmWasm/cosmwasm/pull/1356) to support total supply queries
- Protobuf files are published to [buf.build](https://buf.build/cosmwasm/wasmd/docs/main:cosmwasm.wasm.v1)

### Migration notes:
- See ibc-go [migration notes](https://github.com/cosmos/ibc-go/blob/v3.3.0/docs/migrations/support-denoms-with-slashes.md)


[Full Changelog](https://github.com/CosmWasm/wasmd/compare/v0.28.0...HEAD)

## [v0.28.0](https://github.com/CosmWasm/wasmd/tree/v0.28.0) (2022-07-29)

[Full Changelog](https://github.com/CosmWasm/wasmd/compare/v0.27.0...v0.28.0)
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ WORKDIR /code
COPY . /code/

# See https://github.com/CosmWasm/wasmvm/releases
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.0.0/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7d2239e9f25e96d0d4daba982ce92367aacf0cbd95d2facb8442268f2b1cc1fc
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep f6282df732a13dec836cda1f399dd874b1e3163504dbd9607c6af915b2740479
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.1.1/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v1.1.1/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 9ecb037336bd56076573dc18c26631a9d2099a7f2b40dc04b6cae31ffb4c8f9a
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep 6e4de7ba9bad4ae9679c7f9ecf7e283dd0160e71567c6a7be6ae47c81ebe7f32

# Copy the library you want to the final location that will be found by the linker flag `-lwasmvm_muslc`
RUN cp /lib/libwasmvm_muslc.${arch}.a /lib/libwasmvm_muslc.a
Expand Down
48 changes: 23 additions & 25 deletions INTEGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
# Integration

If you want to use Wasm in your own app, here is how you can get this working
quickly and easily. First, check to make sure you fit the pre-requisites,
quickly and easily.
First start with This [article](https://medium.com/cosmwasm/cosmwasm-for-ctos-iv-native-integrations-713140bf75fc)
in the "CosmWasm for CTOs" series that gives you a high level view.
Then check to make sure you fit the pre-requisites,
then integrate the `x/wasm` module as described below, and finally, you
can add custom messages and queries to your custom Go/SDK modules, exposing
them to any chain-specific contract.
Expand All @@ -14,26 +17,18 @@ The pre-requisites of integrating `x/wasm` into your custom app is to be using
a compatible version of the Cosmos SDK, and to accept some limits to the
hardware it runs on.

| wasmd | Cosmos SDK |
|:------:|:-----------:|
| v0.24 | v0.45.0 |
| v0.23 | v0.45.0 |
| v0.22 | v0.45.0 |
| v0.21 | v0.42.x |
| v0.20 | v0.42.x |
| v0.19 | v0.42.x |
| v0.18 | v0.42.x |
| v0.17 | v0.42.x |
| v0.16 | v0.42.x |
| v0.15 | v0.41.x |
| v0.14 | v0.40.x |
| v0.13 | v0.40.0-rc3 |
| v0.12 | v0.40.0-rc3 |
| v0.11 | v0.39.1 |
| v0.10 | v0.39.1 |
| v0.9 | v0.38.3 |
| v0.8 | v0.38.3 |
| v0.7 | v0.38.3 |
| wasmd | Cosmos SDK |
|:-----:|:----------:|
| v0.29 | v0.45.8 |
| v0.28 | v0.45.5 |
| v0.27 | v0.45.4 |
| v0.26 | v0.45.1 |
| v0.25 | v0.45.1 |
| v0.24 | v0.45.0 |
| v0.23 | v0.45.0 |
| v0.22 | v0.45.0 |
| v0.21 | v0.42.x |


We currently only support Intel/AMD64 CPUs and OSX or Linux. For Linux, the standard build
commands work for `glibc` systems (Ubuntu, Debian, CentOS, etc). If you wish to compile
Expand Down Expand Up @@ -72,9 +67,12 @@ from the Cosmos SDK, and enabled them in `app.go`. If so, you can just look
at [`wasmd/app/app.go`](https://github.com/CosmWasm/wasmd/blob/master/app/app.go#)
for how to do so (just search there for lines with `wasm`).

`wasmd` also comes with a custom `ante handler` that adds the TX position in the block into the context
and passes it to the contracts. In order to support this feature you would need to add our custom
ante handler into the `ante handler chain` as in: [`app/ante.go`](https://github.com/CosmWasm/wasmd/blob/master/app/ante.go)
`wasmd` also comes with 2 custom `ante handlers`:
* `CountTXDecorator` adds the TX position in the block into the context and passes it to the contracts
* `LimitSimulationGasDecorator` prevents an "infinite gas" query

In order to support these features you would need to add our custom
ante handlers into the `ante handler chain` as in: [`app/ante.go`](https://github.com/CosmWasm/wasmd/blob/master/app/ante.go)

### Copied into your app

Expand Down Expand Up @@ -202,5 +200,5 @@ the SDK is implemented properly.

Once you have tested this and are happy with the results, you can wire it up in `app.go`.
Just edit [the default `NewKeeper` constructor](https://github.com/CosmWasm/wasmd/blob/v0.8.0-rc1/app/app.go#L257-L258)
to have the proper `supportedFeatures` and pass in the `CustomEncoder` and `CustomQuerier` as the last two arguments to `NewKeeper`.
to have the proper `availableCapabilities` and pass in the `CustomEncoder` and `CustomQuerier` as the last two arguments to `NewKeeper`.
Now you can compile your chain and upload your custom contracts on it.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ format: format-tools
###############################################################################
### Protobuf ###
###############################################################################
PROTO_BUILDER_IMAGE=tendermintdev/sdk-proto-gen:v0.2
PROTO_BUILDER_IMAGE=tendermintdev/sdk-proto-gen:v0.7
PROTO_FORMATTER_IMAGE=tendermintdev/docker-build-proto@sha256:aabcfe2fc19c31c0f198d4cd26393f5e5ca9502d7ea3feafbfe972448fee7cae

proto-all: proto-format proto-lint proto-gen format
Expand All @@ -178,7 +178,7 @@ proto-format:
@echo "Formatting Protobuf files"
$(DOCKER) run --rm -v $(CURDIR):/workspace \
--workdir /workspace $(PROTO_FORMATTER_IMAGE) \
find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \;
find ./ -name *.proto -exec clang-format -i {} \;

proto-swagger-gen:
@./scripts/protoc-swagger-gen.sh
Expand Down
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ version is communicated by the contract via a Wasm export. This is the current
compatibility list:

| wasmd | wasmvm | cosmwasm-vm | cosmwasm-std |
| ----- | ------------ | ----------- | ------------ |
|-------|--------------|-------------|--------------|
| 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 |
Expand All @@ -52,7 +54,7 @@ It will also run contracts compiled with 1.x assuming they don't opt into any ne
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 rejeted upon upload (with some error
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](https://github.com/wasmerio/wasmer/) 1.0, which is significantly more performant than the older versions.
Expand Down Expand Up @@ -95,9 +97,9 @@ The used cosmos-sdk version is in transition migrating from amino encoding to pr

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 decodng. For better UX, we often use `json.RawMessage` to contain these bytes, which enforces that it is
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 in issue if this is important for
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
Expand All @@ -109,6 +111,12 @@ make test
if you are using a linux without X or headless linux, look at [this article](https://ahelpme.com/linux/dbusexception-could-not-get-owner-of-name-org-freedesktop-secrets-no-such-name) or [#31](https://github.com/CosmWasm/wasmd/issues/31#issuecomment-577058321).

## Protobuf
The protobuf files for this project are published automatically to the [buf repository](https://buf.build/) to make integration easier:

| wasmd version | buf tag |
|---------------|---------------------------------------------------------------------------------------------------------------------------------------------|
| 0.26.x | [51931206dbe09529c1819a8a2863d291035a2549](https://buf.build/cosmwasm/wasmd/tree/51931206dbe09529c1819a8a2863d291035a2549:cosmwasm/wasm/v1) |

Generate protobuf
```shell script
make proto-gen
Expand Down
16 changes: 13 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ func NewWasmApp(

// The last arguments can contain custom message handlers, and custom query handlers,
// if we want to allow any custom callbacks
supportedFeatures := "iterator,staking,stargate"
availableCapabilities := "iterator,staking,stargate,cosmwasm_1_1"
app.WasmKeeper = wasm.NewKeeper(
appCodec,
keys[wasm.StoreKey],
Expand All @@ -524,7 +524,7 @@ func NewWasmApp(
app.GRPCQueryRouter(),
wasmDir,
wasmConfig,
supportedFeatures,
availableCapabilities,
wasmOpts...,
)

Expand Down Expand Up @@ -773,7 +773,17 @@ func NewWasmApp(
// Name returns the name of the App
func (app *WasmApp) Name() string { return app.BaseApp.Name() }

// application updates every begin block
// ModuleManager returns instance
func (app *WasmApp) ModuleManager() module.Manager {
return *app.mm
}

// ModuleConfigurator returns instance
func (app *WasmApp) ModuleConfigurator() module.Configurator {
return app.configurator
}

// BeginBlocker application updates every begin block
func (app *WasmApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
return app.mm.BeginBlock(ctx, req)
}
Expand Down
29 changes: 24 additions & 5 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"math/rand"
"path/filepath"
"strconv"
"testing"
Expand Down Expand Up @@ -71,6 +70,29 @@ func setup(t testing.TB, withGenesis bool, invCheckPeriod uint, opts ...wasm.Opt
return app, GenesisState{}
}

// Setup initializes a new WasmApp with DefaultNodeHome for integration tests
func Setup(isCheckTx bool, opts ...wasm.Option) *WasmApp {
db := dbm.NewMemDB()
app := NewWasmApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 5, MakeEncodingConfig(), wasm.EnableAllProposals, EmptyBaseAppOptions{}, opts)

if !isCheckTx {
genesisState := NewDefaultGenesisState()
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
if err != nil {
panic(err)
}

app.InitChain(
abci.RequestInitChain{
Validators: []abci.ValidatorUpdate{},
ConsensusParams: DefaultConsensusParams,
AppStateBytes: stateBytes,
},
)
}
return app
}

// SetupWithGenesisValSet initializes a new WasmApp with a validator set and genesis accounts
// that also act as delegators. For simplicity, each validator is bonded with a delegation
// of one consensus engine unit (10^6) in the default token of the WasmApp from first genesis
Expand Down Expand Up @@ -284,7 +306,7 @@ func CheckBalance(t *testing.T, app *WasmApp, addr sdk.AccAddress, balances sdk.
require.True(t, balances.IsEqual(app.BankKeeper.GetAllBalances(ctxCheck, addr)))
}

const DefaultGas = 1200000
const DefaultGas = 1_500_000

// SignCheckDeliver checks a generated signed transaction and simulates a
// block commitment with the given transaction. A test assertion is made using
Expand All @@ -295,7 +317,6 @@ func SignCheckDeliver(
chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey,
) (sdk.GasInfo, *sdk.Result, error) {
tx, err := helpers.GenTx(
rand.New(rand.NewSource(time.Now().UnixNano())),
txCfg,
msgs,
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)},
Expand Down Expand Up @@ -345,7 +366,6 @@ func SignAndDeliver(
chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey,
) (sdk.GasInfo, *sdk.Result, error) {
tx, err := helpers.GenTx(
rand.New(rand.NewSource(time.Now().UnixNano())),
txCfg,
msgs,
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)},
Expand Down Expand Up @@ -383,7 +403,6 @@ func GenSequenceOfTxs(txGen client.TxConfig, msgs []sdk.Msg, accNums []uint64, i
var err error
for i := 0; i < numToGenerate; i++ {
txs[i], err = helpers.GenTx(
rand.New(rand.NewSource(time.Now().UnixNano())),
txGen,
msgs,
sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)},
Expand Down
Loading

0 comments on commit 3be9232

Please sign in to comment.