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

revert to 14 contracts #598

Draft
wants to merge 54 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 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
55b631f
revert to older contracts in wazero branch
faddat Dec 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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 ./...
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
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ go 1.21

require (
github.com/google/btree v1.0.0
github.com/kilic/bls12-381 v0.1.0
github.com/shamaton/msgpack/v2 v2.2.0
github.com/stretchr/testify v1.8.1
github.com/tetratelabs/wazero v1.8.2
golang.org/x/sys v0.16.0
)

Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/kilic/bls12-381 v0.1.0 h1:encrdjqKMEvabVQ7qYOKu1OvhqpK4s47wDYtNiPtlp4=
github.com/kilic/bls12-381 v0.1.0/go.mod h1:vDTTHJONJ6G+P2R74EhnyotQDTliQDnFEwhdmfzw1ig=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand All @@ -22,6 +24,9 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/tetratelabs/wazero v1.8.2 h1:yIgLR/b2bN31bjxwXHD8a3d+BogigR952csSDdLYEv4=
github.com/tetratelabs/wazero v1.8.2/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
golang.org/x/sys v0.0.0-20201101102859-da207088b7d1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
14 changes: 7 additions & 7 deletions ibc_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build cgo && !nolink_libwasmvm

package cosmwasm

import (
Expand Down Expand Up @@ -76,6 +74,7 @@ type AcknowledgeDispatch struct {
}

func toBytes(t *testing.T, v interface{}) []byte {
t.Helper()
bz, err := json.Marshal(v)
require.NoError(t, err)
return bz
Expand Down Expand Up @@ -107,9 +106,10 @@ func TestIBCHandshake(t *testing.T) {
}
i, _, err := vm.Instantiate(checksum, env, info, toBytes(t, init_msg), store, *goapi, querier, gasMeter1, TESTING_GAS_LIMIT, deserCost)
require.NoError(t, err)
t.Logf("Instantiation response: %+v", i)
assert.NotNil(t, i.Ok)
iResponse := i.Ok
require.Equal(t, 0, len(iResponse.Messages))
require.Empty(t, iResponse.Messages)

// channel open
gasMeter2 := api.NewMockGasMeter(TESTING_GAS_LIMIT)
Expand All @@ -132,7 +132,7 @@ func TestIBCHandshake(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, conn.Ok)
connResponse := conn.Ok
require.Equal(t, 1, len(connResponse.Messages))
require.Len(t, connResponse.Messages, 1)

// check for the expected custom event
expected_events := []types.Event{{
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestIBCPacketDispatch(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, conn.Ok)
connResponse := conn.Ok
require.Equal(t, 1, len(connResponse.Messages))
require.Len(t, connResponse.Messages, 1)
id := connResponse.Messages[0].ID

// mock reflect init callback (to store address)
Expand Down Expand Up @@ -237,7 +237,7 @@ func TestIBCPacketDispatch(t *testing.T) {
var accounts ListAccountsResponse
err = json.Unmarshal(qResponse, &accounts)
require.NoError(t, err)
require.Equal(t, 1, len(accounts.Accounts))
require.Len(t, accounts.Accounts, 1)
require.Equal(t, CHANNEL_ID, accounts.Accounts[0].ChannelID)
require.Equal(t, REFLECT_ADDR, accounts.Accounts[0].Account)

Expand Down Expand Up @@ -332,7 +332,7 @@ func TestIBCMsgGetChannel(t *testing.T) {
require.Equal(t, msg1.GetChannel(), msg4.GetChannel())
require.Equal(t, msg1.GetChannel(), msg5.GetChannel())
require.Equal(t, msg1.GetChannel(), msg6.GetChannel())
require.Equal(t, msg1.GetChannel().Endpoint.ChannelID, CHANNEL_ID)
require.Equal(t, CHANNEL_ID, msg1.GetChannel().Endpoint.ChannelID)
}

func TestIBCMsgGetCounterVersion(t *testing.T) {
Expand Down
44 changes: 44 additions & 0 deletions internal/adapter/interface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// file: internal/runtime/wasm_runtime.go
package runtime

import "github.com/CosmWasm/wasmvm/v2/types"

type WasmRuntime interface {
// InitCache sets up any runtime-specific cache or resources. Returns a handle.
InitCache(config types.VMConfig) (any, error)

// ReleaseCache frees resources created by InitCache.
ReleaseCache(handle any)

// Compilation and code storage
StoreCode(code []byte, persist bool) (checksum []byte, err error)
StoreCodeUnchecked(code []byte) ([]byte, error)
GetCode(checksum []byte) ([]byte, error)
RemoveCode(checksum []byte) error
Pin(checksum []byte) error
Unpin(checksum []byte) error
AnalyzeCode(checksum []byte) (*types.AnalysisReport, error)

// Execution lifecycles
Instantiate(checksum []byte, env []byte, info []byte, msg []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)
Execute(checksum []byte, env []byte, info []byte, msg []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)
Migrate(checksum []byte, env []byte, msg []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)
MigrateWithInfo(checksum []byte, env []byte, msg []byte, migrateInfo []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)
Sudo(checksum []byte, env []byte, msg []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)
Reply(checksum []byte, env []byte, reply []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)
Query(checksum []byte, env []byte, query []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)

// IBC entry points
IBCChannelOpen(checksum []byte, env []byte, msg []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)
IBCChannelConnect(checksum []byte, env []byte, msg []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)
IBCChannelClose(checksum []byte, env []byte, msg []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)
IBCPacketReceive(checksum []byte, env []byte, msg []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)
IBCPacketAck(checksum []byte, env []byte, msg []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)
IBCPacketTimeout(checksum []byte, env []byte, msg []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)
IBCSourceCallback(checksum []byte, env []byte, msg []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)
IBCDestinationCallback(checksum []byte, env []byte, msg []byte, otherParams ...interface{}) ([]byte, types.GasReport, error)

// Metrics
GetMetrics() (*types.Metrics, error)
GetPinnedMetrics() (*types.PinnedMetrics, error)
}
Loading
Loading