Skip to content
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

Break down packages #600

Draft
wants to merge 61 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
5eeb9ab
most tests pass
faddat Dec 19, 2024
26fc9f5
Merge remote-tracking branch 'origin/main'
faddat Dec 19, 2024
c114170
sleep`
faddat Dec 19, 2024
7e23cac
cleanup
faddat Dec 19, 2024
ae1b69e
don't close cache in ReleasCache
faddat Dec 19, 2024
03575a1
additional cleanup
faddat Dec 19, 2024
d06a50d
resolve further issues
faddat Dec 19, 2024
8fc8213
fix issues with siguantures
faddat Dec 20, 2024
9a337bb
memory management
faddat Dec 20, 2024
62a2b75
fix analyzecode
faddat Dec 20, 2024
e0a26b2
database functions
faddat Dec 20, 2024
adddaef
fix issues related to db_scan
faddat Dec 20, 2024
b0fe30b
fix addr_validate
faddat Dec 20, 2024
e51b683
add 3 types of sig verification
faddat Dec 20, 2024
e8bb8f1
add query_chain host function
faddat Dec 20, 2024
1aba7bc
gci
faddat Dec 20, 2024
06918ac
fix testfloats
faddat Dec 20, 2024
fdeda87
fix out of bounds memory access
faddat Dec 21, 2024
237fa73
add missing host functions
faddat Dec 21, 2024
51a29b3
revert golangci changes to focus on the insantiate issue
faddat Dec 21, 2024
76ab8e1
Merge remote-tracking branch 'upstream/main' into merged-chaos
faddat Dec 21, 2024
136538c
Refactor memory management and host functions in wasmvm
faddat Dec 22, 2024
5b2ef78
testifylint execpt for the MockInfoBin
faddat Dec 22, 2024
58a57ab
Create tests.yml
faddat Dec 22, 2024
9404e32
testifylint execpt for the MockInfoBin
faddat Dec 22, 2024
3eb0c97
gci'd
faddat Dec 22, 2024
64e241e
continue test cleanup
faddat Dec 22, 2024
675f892
gci is much better than goimports
faddat Dec 22, 2024
1921179
use latest linter
faddat Dec 22, 2024
f8005f8
resolve issues with goroutine
faddat Dec 22, 2024
445f165
enable errcheck and thelper linters
faddat Dec 22, 2024
2226db6
remove manual host side deallocation
faddat Dec 22, 2024
f2476ef
progress...
faddat Dec 22, 2024
80e9ddd
update runtime
faddat Dec 22, 2024
cbcf5a9
update contracts used in testing`
faddat Dec 22, 2024
3286d4f
update capabilities
faddat Dec 22, 2024
bd565b4
correct typo from adjusting tests.
faddat Dec 22, 2024
7bd5e19
Merge branch 'faddat/testifylint' into faddat/errcheck
faddat Dec 22, 2024
806765d
Merge commit 'cbcf5a9' into merged-chaos
faddat Dec 22, 2024
1ad7343
Merge commit '3286d4f' into merged-chaos
faddat Dec 22, 2024
ee2187d
Revert "update capabilities"
faddat Dec 23, 2024
6875d5f
Revert "update runtime"
faddat Dec 23, 2024
eb485f8
add cryptographic imports
faddat Dec 23, 2024
1e0588a
replace deprecated library
faddat Dec 23, 2024
4dacdd8
all signature mismatches resolved
faddat Dec 23, 2024
da99b00
add validation.go
faddat Dec 23, 2024
6b34c21
TestStoreCode passes, introduce table-driven test
faddat Dec 23, 2024
35f5986
improve debug
faddat Dec 24, 2024
9810ad1
Merge commit '58a57ab' into merged-chaos
faddat Dec 25, 2024
4f8afaa
`Merge commit 'bd565b4' into merged-chaos
faddat Dec 25, 2024
8ac36b5
Merge commit '7bd5e19' into merged-chaos
faddat Dec 25, 2024
dda5695
lint
faddat Dec 25, 2024
ccc48d7
update linter config
faddat Dec 25, 2024
4309b4e
Update .gitignore, modify mock time format, and enhance host function…
faddat Dec 26, 2024
9af9725
restore libwasmvm to ease reference
faddat Dec 26, 2024
83a8f08
high quality debug info
faddat Jan 2, 2025
03e886a
add additional debug (look at adapted vs actual...)
faddat Jan 3, 2025
0d45e1e
turn on debug
faddat Jan 3, 2025
4e497f5
Enhance testing capabilities, improve gas tracking, and validate memo…
faddat Jan 4, 2025
4a5e8a9
Add new contracts and update existing ones with improved schemas and …
faddat Jan 4, 2025
fafed9d
break packages down into smaller pieces
faddat Jan 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/workflows/lint-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21.4'
go-version: "1.21.4"
cache: false
- name: golangci-lint
uses: golangci/[email protected]
with:
# Require: The version of golangci-lint to use.
# When `install-mode` is `binary` (default) the value can be v1.2 or v1.2.3 or `latest` to use the latest version.
# When `install-mode` is `goinstall` the value can be v1.2.3, `latest`, or the hash of a commit.
version: v1.56.2
version: v1.62.2

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on: [push, pull_request]
name: Test
jobs:
test:
strategy:
matrix:
go-version: [1.23.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- run: go test ./...
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
/demo
tmp
a.out
assistant*
libwasmvm/target/**

# macOS
.DS_Store
40 changes: 37 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,44 @@
run:
tests: true

linters:
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- gofumpt
- goimports
- gci
- testifylint
- errcheck
- thelper
- staticcheck

linters-settings:
goimports:
local-prefixes: github.com/CosmWasm/wasmvm
gci:
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`,
# If `custom-order` is `true`, it follows the order of `sections` option.
# Default: ["standard", "default"]
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/cosmos/cosmos-sdk) # Custom section: groups all imports with the specified Prefix.
- prefix(github.com/cosmos/ibc-go)
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
- alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled.
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
# Skip generated files.
# Default: true
skip-generated: false
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true
# Drops lexical ordering for custom sections.
# Default: false
no-lex-order: true

issues:
max-issues-per-linter: 0
max-same-issues: 0
2 changes: 1 addition & 1 deletion cmd/demo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ func main() {

if file == "version" {
libwasmvmVersion, err := wasmvm.LibwasmvmVersion()
fmt.Printf("libwasmvm: %s\n", libwasmvmVersion)
if err != nil {
panic(err)
}
fmt.Printf("libwasmvm: %s\n", libwasmvmVersion)
return
}

Expand Down
131 changes: 131 additions & 0 deletions contracts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Example contracts

Those contracts are made for development purpose only. For more realistic
example contracts, see
[cosmwasm-examples](https://github.com/CosmWasm/cosmwasm-examples).

## The contracts

Introducing the development contracts in the order they were created.

1. **hackatom** is the very first development contract that was created at a
Cosmos Hackatom in Berlin in 2019, the event where CosmWasm was born. It is a
very basic escrow contract. During the years of CosmWasm development, many
more test cases were hacked into it.
2. **queue** shows and tests the newly added iterator support
([#181](https://github.com/CosmWasm/cosmwasm/pull/181)).
3. **reflect** is an evolution of the
[mask contract](https://medium.com/cosmwasm/introducing-the-mask-41d11e51bccf),
which allows the user to send messages to the contract which are then emitted
with the contract as the sender. It later got support to handle sub messages
and replies ([#796](https://github.com/CosmWasm/cosmwasm/pull/796)).
4. **staking** is a staking derivatives example showing how the contract itself
can be a delegator.
5. **burner** shows how contract migrations work, which were added in CosmWasm
0.9 ([#413](https://github.com/CosmWasm/cosmwasm/pull/413)). It shuts down
the contract my clearing all state and sending all tokens to a given address.
6. **ibc-reflect**/**ibc-reflect-send** are inspired by the idea of Interchain
Accounts and demonstrate the power of contract to contract IBC.
ibc-reflect-send receives a message on chain A and sends it to an ibc-reflect
instance on chain B where the message is executed.
7. **crypto-verify** shows how to use the CosmWasm crypto APIs for signature
verification ([#783](https://github.com/CosmWasm/cosmwasm/pull/783)).
8. **floaty** emits float operations when compiled to Wasm and allows us to test
how tooling and the runtime deal with those operations
([#970](https://github.com/CosmWasm/cosmwasm/pull/970)).
9. **cyberpunk** is an attempt to cleanup hackatom and make writing runtime
tests (cosmwasm-vm/wamsmvm) easier by avoid the need for the escrow setup
that hackatom has.
10. **virus** is a contract that reproduces itself and does nothing useful
beyond that, showing how to use instantiate2 from a contract.
11. **empty** is an empty contract that does nothing. It is used to test that we
can store contracts with no entry points.

## Optimized builds

Those development contracts are used for testing in other repos, e.g. in
[wasmvm](https://github.com/CosmWasm/wasmvm/tree/main/testdata) or
[cosmjs](https://github.com/cosmos/cosmjs/tree/main/scripts/wasmd/contracts).

They are [built and deployed](https://github.com/CosmWasm/cosmwasm/releases) by
the CI for every release tag. In case you need to build them manually for some
reason, use the following commands:

```sh
# cd to the repo root first

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_burner",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.0 ./contracts/burner

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_crypto_verify",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.0 ./contracts/crypto-verify

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_cyberpunk",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.0 ./contracts/cyberpunk

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_floaty",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.0 ./contracts/floaty

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_hackatom",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.0 ./contracts/hackatom

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_ibc_reflect",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.0 ./contracts/ibc-reflect

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_ibc_reflect_send",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.0 ./contracts/ibc-reflect-send

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_queue",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.0 ./contracts/queue

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_reflect",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.0 ./contracts/reflect

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_staking",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.0 ./contracts/staking

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_virus",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.0 ./contracts/virus

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_empty",target=/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/optimizer:0.15.0 ./contracts/empty
```

## Entry points

The development contracts in this folder contain a variety of different entry
points in order to demonstrate and test the flexibility we have.

| Contract | Has `query` | Has `migrate` |
| ----------- | ----------- | ------------- |
| burner | no | yes |
| hackatom | yes | yes |
| ibc-reflect | yes | no |
| queue | yes | yes |
| reflect | yes | no |
| staking | yes | no |
| virus | no | no |
6 changes: 6 additions & 0 deletions contracts/burner/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[alias]
wasm = "build --release --lib --target wasm32-unknown-unknown"
wasm-debug = "build --lib --target wasm32-unknown-unknown"
unit-test = "test --lib"
integration-test = "test --test integration"
schema = "run --bin schema"
Loading
Loading