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

Memory Progress #609

Closed
wants to merge 90 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 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
311ef12
Refactor WazeroRuntime to support additional parameters in contract f…
faddat Jan 5, 2025
7282c60
Add gas tracking functionality and refactor gas costs in runtime
faddat Jan 5, 2025
0a8eb5c
Refactor tests and improve error handling in IBC and memory database
faddat Jan 5, 2025
38c321e
Update .gitignore, enhance debug logging in host functions, and impro…
faddat Jan 5, 2025
fa17dcf
align runtime with lib
faddat Jan 5, 2025
f78dd37
Refactor WazeroRuntime to centralize parameter validation
faddat Jan 5, 2025
f6910f8
Enhance callContractFn with structured memory management and detailed…
faddat Jan 6, 2025
58af4fd
fix lints
faddat Jan 6, 2025
e31ce9e
ensure we are getting type error
faddat Jan 11, 2025
b3e5f06
wazero-contest
faddat Jan 11, 2025
9d9d3b6
Merge branch 'main' into faddat/memory-progress
faddat Jan 11, 2025
fcf80bf
improve logging
faddat Jan 11, 2025
f9da8c8
Merge branch 'faddat/memory-progress' of https://github.com/faddat/go…
faddat Jan 11, 2025
dda9917
ultimate logging
faddat Jan 11, 2025
e93cd11
remove contracts from git for reviewability
faddat Jan 11, 2025
cb90d0f
fix serialization, now issue is memory again
faddat Jan 11, 2025
5298c9d
most debug yet
faddat Jan 11, 2025
b7732c5
out of bounds memory access everywhere
faddat Jan 11, 2025
d9434a8
back at invalid type
faddat Jan 11, 2025
181d0a8
omg stuff ran
faddat Jan 11, 2025
e5541f7
testfloats passes
faddat Jan 11, 2025
3f82f1e
testfloats still passes
faddat Jan 11, 2025
a09db13
testfloats still passes
faddat Jan 11, 2025
7651286
update how tests work
faddat Jan 11, 2025
c2ee34a
update tests so they're individual
faddat Jan 11, 2025
8de7fad
testfloats still works
faddat Jan 11, 2025
ff20c3a
Revert "testfloats still works"
faddat Jan 11, 2025
847bab6
macos...
faddat Jan 11, 2025
3a20226
use macos and ubunut
faddat Jan 11, 2025
e568cb4
update tests
faddat Jan 11, 2025
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
1,181 changes: 1,181 additions & 0 deletions .github/workflows/tests.yml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
*.iml
.idea
.vscode
**combined_code.txt
/vm
/contracts


# no static libraries (35MB+)
/internal/api/lib*.a
Expand All @@ -13,6 +17,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
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
11 changes: 6 additions & 5 deletions ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,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 @@ -109,7 +110,7 @@ func TestIBCHandshake(t *testing.T) {
require.NoError(t, err)
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 +133,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 +201,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 +238,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 +333,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