Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into patch-12
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Dec 3, 2024
2 parents 3bdd56a + b2b6abe commit 55d930a
Show file tree
Hide file tree
Showing 71 changed files with 1,444 additions and 541 deletions.
5 changes: 2 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ orbs:
executors:
golang:
docker:
- image: cimg/go:1.21
- image: cimg/go:1.23

commands:
make:
Expand Down Expand Up @@ -80,13 +80,12 @@ jobs:
lint:
docker:
- image: golangci/golangci-lint:v1.54.2
- image: golangci/golangci-lint:v1.60.3
steps:
- checkout
- run:
name: Lint
command: |
golangci-lint run --version
golangci-lint run --tests=false --timeout=5m0s
test-cover:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: autofix.ci # needed to securely identify the workflow

on:
pull_request:

permissions:
contents: read

jobs:
autofix-protobuf:
runs-on: ubuntu-latest
container:
image: ghcr.io/cosmos/proto-builder:0.14.0
options: --user root # workaround for a problem during actions/checkout, see https://github.com/actions/checkout/issues/1014
steps:
- uses: actions/checkout@v4
- name: Fix permissions # needed because of root user fix above
run: git config --global --add safe.directory "$PWD"
- name: Format protobuf
run: find ./ -name "*.proto" -exec clang-format -i {} \;
- name: Generate protobuf
run: sh ./scripts/protocgen.sh
- name: Format
run: make format

# Get latest version from https://autofix.ci/setup
- uses: autofix-ci/action@dd55f44df8f7cdb7a6bf74c78677eb8acd40cd0a
22 changes: 22 additions & 0 deletions .github/workflows/proto-buf-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Protobuf Linting
# run buf lint (https://buf.build/)
# This workflow is only run when a .proto file has been changed
on:
pull_request:
paths:
- "proto/**"

permissions:
contents: read

jobs:
buf-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/[email protected]

# lint checks
- uses: bufbuild/buf-lint-action@v1
with:
input: "proto"
2 changes: 1 addition & 1 deletion .github/workflows/proto-buf-publisher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: bufbuild/buf-setup-action@v1.45.0
- uses: bufbuild/buf-setup-action@v1.47.2

# lint checks
- uses: bufbuild/buf-lint-action@v1
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/typo-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Check for typos

on:
merge_group:
pull_request:
push:
branches:
- main
workflow_dispatch:

jobs:
check-typos:
name: "Spell-check repository source"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run spell-check
uses: crate-ci/typos@master
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
- Log query error before redacting [\#1593](https://github.com/CosmWasm/wasmd/issues/1593)
- Restrict pagination on all-state-query [\#1619](https://github.com/CosmWasm/wasmd/pull/1619)
- Bug in IbcQuery::ListChannels implementation when port is unset [\#1597](https://github.com/CosmWasm/wasmd/issues/1597)
- Ensure some contraints and limits on pin/unpin code ids [\#1624](https://github.com/CosmWasm/wasmd/pull/1624)
- Ensure some constraints and limits on pin/unpin code ids [\#1624](https://github.com/CosmWasm/wasmd/pull/1624)
- Ensure genesis import works with both address generators [\#1629](https://github.com/CosmWasm/wasmd/issues/1629)
- Set default query limit and ensure constraints [\#1632](https://github.com/CosmWasm/wasmd/pull/1632)

Expand All @@ -174,7 +174,7 @@
- If `port_id` is omitted, all channels bound to the contract's port will be listed.
- Restrict pagination on all-state-query [\#1619](https://github.com/CosmWasm/wasmd/pull/1619)
- Pagination limit is set to 100 for all-state-query. See also [\#1632](https://github.com/CosmWasm/wasmd/pull/1632)
- Ensure some contraints and limits on pin/unpin code ids [\#1624](https://github.com/CosmWasm/wasmd/pull/1624)
- Ensure some constraints and limits on pin/unpin code ids [\#1624](https://github.com/CosmWasm/wasmd/pull/1624)
- Total number of code ids is limited to 50 for pin/unpin operations
- Custom StoreCode Authorization for authz module [\#1584](https://github.com/CosmWasm/wasmd/issues/1584)

Expand Down Expand Up @@ -413,7 +413,7 @@ below to learn more!

[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)
- Add dependencies for protobuf and remove third_party folder [/#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)
Expand Down Expand Up @@ -455,7 +455,7 @@ No

**Fixed Bugs**

- Fix: Make events in reply completely determinisitic by stripping out anything coming from Cosmos SDK (not CosmWasm codebase) [\#917](https://github.com/CosmWasm/wasmd/pull/917) ([assafmo](https://github.com/assafmo))
- Fix: Make events in reply completely deterministic by stripping out anything coming from Cosmos SDK (not CosmWasm codebase) [\#917](https://github.com/CosmWasm/wasmd/pull/917) ([assafmo](https://github.com/assafmo))

Migration notes:

Expand Down
12 changes: 5 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
# docker build . -t cosmwasm/wasmd:latest
# docker run --rm -it cosmwasm/wasmd:latest /bin/sh

# Using Alpine 3.19+ as the build system is currently broken,
# see https://github.com/CosmWasm/wasmvm/issues/523
FROM golang:1.21-alpine3.18 AS go-builder
FROM golang:1.23-alpine3.19 AS go-builder

# this comes from standard alpine nightly file
# https://github.com/rust-lang/docker-rust-nightly/blob/master/alpine3.12/Dockerfile
Expand All @@ -17,10 +15,10 @@ RUN apk add git
WORKDIR /code
COPY . /code/
# See https://github.com/CosmWasm/wasmvm/releases
ADD https://github.com/CosmWasm/wasmvm/releases/download/v2.1.2/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v2.1.2/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 0881c5b463e89e229b06370e9e2961aec0a5c636772d5142c68d351564464a66
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep 58e1f6bfa89ee390cb9abc69a5bc126029a497fe09dd399f38a82d0d86fe95ef
ADD https://github.com/CosmWasm/wasmvm/releases/download/v2.2.0-rc.2/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/v2.2.0-rc.2/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 7af80eb7e79d82789eca0d5512a87dc20e96182590fe88ae5fd0153e31c097c9
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep 2c497b5246c7217a70c447c50117c7fb09909ec23e6e4151a4de3e5f29db8134

# force it to use static lib (from above) not standard libgo_cosmwasm.so file
RUN LEDGER_ENABLED=false BUILD_TAGS=muslc LINK_STATICALLY=true make build
Expand Down
8 changes: 4 additions & 4 deletions EVENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ consistent order (and avoid dictionaries/hashes). Here is a simple Event in JSON
"type": "wasm",
"attributes": [
{"key": "_contract_address", "value": "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6"},
{"key": "transfered", "value": "777000"}
{"key": "transferred", "value": "777000"}
]
}
```
Expand Down Expand Up @@ -321,10 +321,10 @@ action emitting events, so we define a structure to flatten this event tree:
* All events are returned in execution order as [defined by CosmWasm docs](https://github.com/CosmWasm/cosmwasm/blob/main/SEMANTICS.md#dispatching-messages)
* `x/wasm` keeper emits a custom event for each call to a contract entry point. Not just `execute`, `instantiate`,
and `migrate`, but also `reply`, `sudo` and all ibc entry points.
* This means all `wasm*` events are preceeded by the cosmwasm entry point that returned them.
* This means all `wasm*` events are preceded by the cosmwasm entry point that returned them.

To make this more clear, I will provide an example of executing a contract, which returns two messages, one to instantiate a new
contract and the other to set the withdrawl address, while also using `ReplyOnSuccess` for the instantiation (to get the
contract and the other to set the withdrawal address, while also using `ReplyOnSuccess` for the instantiation (to get the
address). It will emit a series of events that looks something like this:

```go
Expand All @@ -335,7 +335,7 @@ sdk.NewEvent(
sdk.NewAttribute("sender", msg.Sender),
),

// top-level exection call
// top-level execution call
sdk.NewEvent(
"execute",
sdk.NewAttribute("_contract_address", contractAddr.String()),
Expand Down
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ SIMAPP = ./app

# for dockerized protobuf tools
DOCKER := $(shell which docker)
BUF_IMAGE=bufbuild/buf@sha256:3cb1f8a4b48bd5ad8f09168f10f607ddc318af202f5c057d52a45216793d85e5 #v1.4.0
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(BUF_IMAGE)
HTTPS_GIT := https://github.com/CosmWasm/wasmd.git

export GO111MODULE = on
Expand Down Expand Up @@ -187,10 +185,10 @@ proto-swagger-gen:
@./scripts/protoc-swagger-gen.sh

proto-lint:
@$(DOCKER_BUF) lint --error-format=json
@$(protoImage) buf lint --error-format=json

proto-check-breaking:
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main
@$(protoImage) buf breaking --against $(HTTPS_GIT)#branch=main

.PHONY: all install install-debug \
go-mod-cache draw-deps clean build format \
Expand Down
6 changes: 3 additions & 3 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ docker run --rm -it \

## Take majority control of the chain

In genesis we have a valiator with 250 million `ustake` bonded. We want to be easily
In genesis we have a validator with 250 million `ustake` bonded. We want to be easily
able to pass a proposal with our client. Let us bond 700 million `ustake` to ensure
we have > 67% of the voting power and will pass with the validator not voting.

Expand All @@ -167,7 +167,7 @@ docker run --rm -it \
## Vote on the upgrade

Now that we see the chain is running and producing blocks, and our client has
enough token to control the netwrok, let's create a governance
enough token to control the network, let's create a governance
upgrade proposal for the new chain to move to `musselnet-v2` (this must be the
same name as we use in the handler we created above, change this to match what
you put in your handler):
Expand Down Expand Up @@ -298,7 +298,7 @@ docker run --rm -it \
After this, we just let the chain run and open the terminal so you can see the log files.
It should keep producing blocks until it hits height 500 (or whatever you set there),
when the process will print a huge stacktrace and hang. Immediately before the stack trace, you
should see a line like this (burried under tons of tendermint logs):
should see a line like this (buried under tons of tendermint logs):

`8:50PM ERR UPGRADE "musselnet-v2" NEEDED at height: 100:`

Expand Down
8 changes: 8 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[default]
extend-ignore-re = ["(?Rm)^.*(#|//)\\s*spellchecker:disable-line$"]

[default.extend-identifiers]
iNdEx = "iNdEx"

[files]
extend-exclude = ["**/go.mod", "**/go.sum", "**/*.pb.go"]
6 changes: 3 additions & 3 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type HandlerOptions struct {
ante.HandlerOptions

IBCKeeper *keeper.Keeper
WasmConfig *wasmTypes.WasmConfig
NodeConfig *wasmTypes.NodeConfig
WasmKeeper *wasmkeeper.Keeper
TXCounterStoreService corestoretypes.KVStoreService
CircuitKeeper *circuitkeeper.Keeper
Expand All @@ -40,7 +40,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
if options.SignModeHandler == nil {
return nil, errors.New("sign mode handler is required for ante builder")
}
if options.WasmConfig == nil {
if options.NodeConfig == nil {
return nil, errors.New("wasm config is required for ante builder")
}
if options.TXCounterStoreService == nil {
Expand All @@ -52,7 +52,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {

anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
wasmkeeper.NewLimitSimulationGasDecorator(options.WasmConfig.SimulationGasLimit), // after setup context to enforce limits early
wasmkeeper.NewLimitSimulationGasDecorator(options.NodeConfig.SimulationGasLimit), // after setup context to enforce limits early
wasmkeeper.NewCountTXDecorator(options.TXCounterStoreService),
wasmkeeper.NewGasRegisterDecorator(options.WasmKeeper.GetGasRegister()),
wasmkeeper.NewTxContractsDecorator(),
Expand Down
11 changes: 6 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ func NewWasmApp(
)

wasmDir := filepath.Join(homePath, "wasm")
wasmConfig, err := wasm.ReadWasmConfig(appOpts)
nodeConfig, err := wasm.ReadNodeConfig(appOpts)
if err != nil {
panic(fmt.Sprintf("error while reading wasm config: %s", err))
}
Expand All @@ -645,7 +645,8 @@ func NewWasmApp(
app.MsgServiceRouter(),
app.GRPCQueryRouter(),
wasmDir,
wasmConfig,
nodeConfig,
wasmtypes.VMConfig{},
wasmkeeper.BuiltInCapabilities(),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
wasmOpts...,
Expand Down Expand Up @@ -871,7 +872,7 @@ func NewWasmApp(
app.SetPreBlocker(app.PreBlocker)
app.SetBeginBlocker(app.BeginBlocker)
app.SetEndBlocker(app.EndBlocker)
app.setAnteHandler(txConfig, wasmConfig, keys[wasmtypes.StoreKey])
app.setAnteHandler(txConfig, nodeConfig, keys[wasmtypes.StoreKey])

// must be before Loading version
// requires the snapshot store to be created and registered as a BaseAppOption
Expand Down Expand Up @@ -934,7 +935,7 @@ func NewWasmApp(
return app
}

func (app *WasmApp) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtypes.WasmConfig, txCounterStoreKey *storetypes.KVStoreKey) {
func (app *WasmApp) setAnteHandler(txConfig client.TxConfig, nodeConfig wasmtypes.NodeConfig, txCounterStoreKey *storetypes.KVStoreKey) {
anteHandler, err := NewAnteHandler(
HandlerOptions{
HandlerOptions: ante.HandlerOptions{
Expand All @@ -945,7 +946,7 @@ func (app *WasmApp) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtype
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
IBCKeeper: app.IBCKeeper,
WasmConfig: &wasmConfig,
NodeConfig: &nodeConfig,
WasmKeeper: &app.WasmKeeper,
TXCounterStoreService: runtime.NewKVStoreService(txCounterStoreKey),
CircuitKeeper: &app.CircuitKeeper,
Expand Down
4 changes: 2 additions & 2 deletions app/params/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Package params defines the simulation parameters in the gaia.
It contains the default weights used for each transaction used on the module's
simulation. These weights define the chance for a transaction to be simulated at
any gived operation.
any given operation.
You can repace the default values for the weights by providing a params.json
You can replace the default values for the weights by providing a params.json
file with the weights defined for each of the transaction operations:
{
Expand Down
4 changes: 2 additions & 2 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ func TestAppImportExport(t *testing.T) {
failedKVAs, failedKVBs := simtestutil.DiffKVStores(storeA, storeB, skipPrefixes[keyName])
if !assert.Equal(t, len(failedKVAs), len(failedKVBs), "unequal sets of key-values to compare in %q", keyName) {
for _, v := range failedKVBs {
t.Logf("store missmatch: %q\n", v)
t.Logf("store mismatch: %q\n", v)
}
t.FailNow()
}

t.Logf("compared %d different key/value pairs between %s and %s\n", len(failedKVAs), appKeyA, appKeyB)
if !assert.Equal(t, 0, len(failedKVAs), simtestutil.GetSimulationLog(keyName, app.SimulationManager().StoreDecoders, failedKVAs, failedKVBs)) {
for _, v := range failedKVAs {
t.Logf("store missmatch: %q\n", v)
t.Logf("store mismatch: %q\n", v)
}
t.FailNow()
}
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (app *WasmApp) RegisterUpgradeHandlers() {
// register store loader for current upgrade
for _, upgrade := range Upgrades {
if upgradeInfo.Name == upgrade.UpgradeName {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades)) // nolint:gosec
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &upgrade.StoreUpgrades))
break
}
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/wasmd/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func initAppConfig() (string, interface{}) {
type CustomAppConfig struct {
serverconfig.Config

Wasm wasmtypes.WasmConfig `mapstructure:"wasm"`
Wasm wasmtypes.NodeConfig `mapstructure:"wasm"`
}

// Optionally allow the chain developer to overwrite the SDK's default
Expand All @@ -84,7 +84,7 @@ func initAppConfig() (string, interface{}) {

customAppConfig := CustomAppConfig{
Config: *srvCfg,
Wasm: wasmtypes.DefaultWasmConfig(),
Wasm: wasmtypes.DefaultNodeConfig(),
}

customAppTemplate := serverconfig.DefaultConfigTemplate +
Expand Down Expand Up @@ -260,7 +260,6 @@ var tempDir = func() string {
if err != nil {
panic("failed to create temp dir: " + err.Error())
}
defer os.RemoveAll(dir)

return dir
}
Loading

0 comments on commit 55d930a

Please sign in to comment.