diff --git a/.github/workflows/builds_and_tests.yml b/.github/workflows/builds_and_tests.yml index 08f7b596..d6fb13ef 100644 --- a/.github/workflows/builds_and_tests.yml +++ b/.github/workflows/builds_and_tests.yml @@ -52,7 +52,7 @@ jobs: - name: set up uses: actions/setup-go@v2 with: - go-version: ^1.17.4 + go-version: 1.17 id: go - name: Checkout uses: actions/checkout@v2 @@ -66,7 +66,7 @@ jobs: - name: set up uses: actions/setup-go@v2 with: - go-version: ^1.17.4 + go-version: 1.17 id: go - name: CHeckout uses: actions/checkout@v2 @@ -88,7 +88,7 @@ jobs: - name: set up uses: actions/setup-go@v2 with: - go-version: ^1.17.4 + go-version: 1.17 id: go - name: Install shfmt run: GO111MODULE=on go install mvdan.cc/sh/v3/cmd/shfmt@v3.4.0 @@ -140,7 +140,7 @@ jobs: - name: set up uses: actions/setup-go@v3.2.1 with: - go-version: 1.18 + go-version: 1.17 id: go - name: Checkout uses: actions/checkout@v2 @@ -159,7 +159,7 @@ jobs: - name: set up uses: actions/setup-go@v2 with: - go-version: ^1.17.4 + go-version: 1.17 id: go - name: Checkout uses: actions/checkout@v2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 17604f4b..5429fcbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,19 @@ # Changelog +## [Unreleased] -## [[v1.0.0-0.10.0](https://github.com/line/wasmvm/compare/v0.16.3-0.9.0...v1.0.0-0.10.0)] - 2022-06-21 +### Features + +### Fixes +* fix: getmetrics test due to this is environment-dependent test ([#80](https://github.com/line/wasmvm/pull/80)) + +### Changes +* chore: remove the copied interface from tm-db ([#82](https://github.com/line/wasmvm/pull/82)) +* refactor: Revert using line/tm-db ([#77](https://github.com/line/wasmvm/pull/77)) +* ci: add release job ([#71](https://github.com/line/wasmvm/pull/71)) +* chore: Revert linux_static ([#70](https://github.com/line/wasmvm/pull/70)) + +## [v1.0.0-0.10.0] - 2022-06-21 ### Features @@ -11,7 +23,7 @@ * improve CHANGELOG's template and devtools/update_changlog.sh ([#60](https://github.com/line/wasmvm/pull/60)) -## [[0.16.3-0.9.0](https://github.com/line/wasmvm/compare/v0.14.0-0.8.0...0.16.3-0.9.0)] - 2022-03-03 +## [v0.16.3-0.9.0] - 2022-03-03 ### Changes @@ -24,28 +36,28 @@ * fix Cargo.toml path in devtools/set_version.sh (part of [#59](https://github.com/line/wasmvm/issues/59)) -## [[v0.14.0-0.8.0](https://github.com/line/wasmvm/compare/v0.14.0-0.7.0...v0.14.0-0.8.0)] - 2021-10-01 +## [v0.14.0-0.8.0] - 2021-10-01 ### Features * change tag name for static build ([#49](https://github.com/line/wasmvm/issues/49)) -## [[0.14.0-0.7.0](https://github.com/line/wasmvm/compare/v0.14.0-0.6.1...0.14.0-0.7.0)] - 2021-09-30 +## [v0.14.0-0.7.0] - 2021-09-30 ### Features * add static linking of wasmvm ([#46](https://github.com/line/wasmvm/issues/46)) -## [[0.14.0-0.6.1](https://github.com/line/wasmvm/compare/v0.14.0-0.6.0...0.14.0-0.6.1)] - 2021-07-15 +## [v0.14.0-0.6.1] - 2021-07-15 ### Fixes * rebuild shared libs to resolve compile error ([#44](https://github.com/line/wasmvm/issues/44)) -## [[v0.14.0-0.6.0](https://github.com/line/wasmvm/compare/v0.14.0-0.5.0...v0.14.0-0.6.0)] - 2021-07-12 +## [v0.14.0-0.6.0] - 2021-07-12 ### Changes * update upstream Cosmwasm/wasmvm version to 0.14.0 (#36) @@ -53,14 +65,14 @@ * change the depended CosmWasm/cosmwasm to line/cosmwasm -## [[v0.14.0-0.5.0](https://github.com/line/wasmvm/compare/v0.14.0-0.4.0...v0.14.0-0.5.0)] - 2021-05-12 +## [v0.14.0-0.5.0] - 2021-05-12 ### Changes * Change the module uri from github.com/CosmWasm/wasmvm to github.com/link/wasmvm ([#23](https://github.com/line/wasmvm/issues/23)) -## [[v0.14.0-0.4.0](https://github.com/line/wasmvm/compare/v0.14.0-0.3.0...v0.14.0-0.4.0)] - 2021-05-03 +## [v0.14.0-0.4.0] - 2021-05-03 ### Changes @@ -76,7 +88,7 @@ The implementation of KVStore now must return a newly defined iterator rather than the `tm-db` defines. -## [[v0.14.0-0.3.0](https://github.com/line/wasmvm/compare/v0.12.0-0.1.0...v0.14.0-0.3.0)] - 2021-04-08 +## [v0.14.0-0.3.0] - 2021-04-08 ### Changes * Update upstream Cosmwasm/wasmvm version to 0.14.0-beta1 (#8) @@ -85,7 +97,7 @@ * Adjust semantic PR validation rule (#9) -## [0.12.0-0.1.0] - 2021-02-15 +## [v0.12.0-0.1.0] - 2021-02-15 ### Add * Add semantic.yml for semantic pull request (#6) @@ -102,3 +114,15 @@ Initial code is based on the wasmvm v0.12.0, cosmwasm v0.12.0 * (cosmwasm) [v0.12.0](https://github.com/CosmWasm/cosmwasm/releases/tag/v0.12.0). Please refer [CHANGELOG_OF_WASMVM_v0.12.0](https://github.com/CosmWasm/wasmvm/releases?after=v0.13.0) + +[Unreleased]:https://github.com/line/wasmvm/compare/v1.0.0-0.10.0...HEAD +[v1.0.0-0.10.0]:https://github.com/line/wasmvm/compare/v0.16.3-0.9.0...v1.0.0-0.10.0 +[v0.16.3-0.9.0]:https://github.com/line/wasmvm/compare/v0.14.0-0.8.0...v0.16.3-0.9.0 +[v0.14.0-0.8.0]:https://github.com/line/wasmvm/compare/v0.14.0-0.7.0...v0.14.0-0.8.0 +[v0.14.0-0.7.0]:https://github.com/line/wasmvm/compare/v0.14.0-0.6.1...v0.14.0-0.7.0 +[v0.14.0-0.6.1]:https://github.com/line/wasmvm/compare/v0.14.0-0.6.0...v0.14.0-0.6.1 +[v0.14.0-0.6.0]:https://github.com/line/wasmvm/compare/v0.14.0-0.5.0...v0.14.0-0.6.0 +[v0.14.0-0.5.0]:https://github.com/line/wasmvm/compare/v0.14.0-0.4.0...v0.14.0-0.5.0 +[v0.14.0-0.4.0]:https://github.com/line/wasmvm/compare/v0.14.0-0.3.0...v0.14.0-0.4.0 +[v0.14.0-0.3.0]:https://github.com/line/wasmvm/compare/v0.12.0-0.1.0...v0.14.0-0.3.0 +[v0.12.0-0.1.0]:https://github.com/line/wasmvm/compare/v0.12.0...v0.12.0-0.1.0 diff --git a/api/callbacks.go b/api/callbacks.go index b0cbcf75..7cd6aec0 100644 --- a/api/callbacks.go +++ b/api/callbacks.go @@ -43,6 +43,8 @@ import ( "runtime/debug" "unsafe" + dbm "github.com/tendermint/tm-db" + "github.com/line/wasmvm/types" ) @@ -112,37 +114,12 @@ type KVStore interface { // Start must be less than end, or the Iterator is invalid. // Iterator must be closed by caller. // To iterate over entire domain, use store.Iterator(nil, nil) - Iterator(start, end []byte) Iterator + Iterator(start, end []byte) dbm.Iterator // Iterator over a domain of keys in descending order. End is exclusive. // Start must be less than end, or the Iterator is invalid. // Iterator must be closed by caller. - ReverseIterator(start, end []byte) Iterator -} - -// Iterator copies a subset of types from lbm-sdk -type Iterator interface { - // Valid returns whether the current iterator is valid. Once invalid, the Iterator remains - // invalid forever. - Valid() bool - - // Next moves the iterator to the next key in the database, as defined by order of iteration. - // If Valid returns false, this method will panic. - Next() - - // Key returns the key at the current position. Panics if the iterator is invalid. - // CONTRACT: key readonly []byte - Key() (key []byte) - - // Value returns the value at the current position. Panics if the iterator is invalid. - // CONTRACT: value readonly []byte - Value() (value []byte) - - // Error returns the last error encountered by the iterator, if any. - Error() error - - // Close closes the iterator, releasing any allocated resources. - Close() error + ReverseIterator(start, end []byte) dbm.Iterator } var db_vtable = C.Db_vtable{ @@ -191,7 +168,7 @@ const frameLenLimit = 32768 // contract: original pointer/struct referenced must live longer than C.Db struct // since this is only used internally, we can verify the code that this is the case -func buildIterator(callID uint64, it Iterator) (C.iterator_t, error) { +func buildIterator(callID uint64, it dbm.Iterator) (C.iterator_t, error) { idx, err := storeIterator(callID, it, frameLenLimit) if err != nil { return C.iterator_t{}, err @@ -297,7 +274,7 @@ func cScan(ptr *C.db_t, gasMeter *C.gas_meter_t, usedGas *C.uint64_t, start C.U8 s := copyU8Slice(start) e := copyU8Slice(end) - var iter Iterator + var iter dbm.Iterator gasBefore := gm.GasConsumed() switch order { case 1: // Ascending diff --git a/api/iterator.go b/api/iterator.go index 11648c1f..acaca864 100644 --- a/api/iterator.go +++ b/api/iterator.go @@ -3,10 +3,12 @@ package api import ( "fmt" "sync" + + dbm "github.com/tendermint/tm-db" ) -// frame stores all Iterators for one contract -type frame []Iterator +// frame stores all Iterators for one contract call +type frame []dbm.Iterator // iteratorFrames contains one frame for each contract call, indexed by contract call ID. var iteratorFrames = make(map[uint64]frame) @@ -50,7 +52,7 @@ func endCall(callID uint64) { // storeIterator will add this to the end of the frame for the given ID and return a reference to it. // We start counting with 1, so the 0 value is flagged as an error. This means we must // remember to do idx-1 when retrieving -func storeIterator(callID uint64, it Iterator, frameLenLimit int) (uint64, error) { +func storeIterator(callID uint64, it dbm.Iterator, frameLenLimit int) (uint64, error) { iteratorFramesMutex.Lock() defer iteratorFramesMutex.Unlock() @@ -69,7 +71,7 @@ func storeIterator(callID uint64, it Iterator, frameLenLimit int) (uint64, error // retrieveIterator will recover an iterator based on index. This ensures it will not be garbage collected. // We start counting with 1, in storeIterator so the 0 value is flagged as an error. This means we must // remember to do idx-1 when retrieving -func retrieveIterator(callID uint64, index uint64) Iterator { +func retrieveIterator(callID uint64, index uint64) dbm.Iterator { iteratorFramesMutex.Lock() defer iteratorFramesMutex.Unlock() myFrame := iteratorFrames[callID] diff --git a/api/iterator_test.go b/api/iterator_test.go index 4207d400..52a31793 100644 --- a/api/iterator_test.go +++ b/api/iterator_test.go @@ -68,7 +68,7 @@ func TestStoreIterator(t *testing.T) { callID2 := startCall() store := dbm.NewMemDB() - var iter Iterator + var iter dbm.Iterator var index uint64 var err error @@ -102,7 +102,7 @@ func TestStoreIteratorHitsLimit(t *testing.T) { callID := startCall() store := dbm.NewMemDB() - var iter Iterator + var iter dbm.Iterator var err error const limit = 2 @@ -127,7 +127,7 @@ func TestRetrieveIterator(t *testing.T) { callID2 := startCall() store := dbm.NewMemDB() - var iter Iterator + var iter dbm.Iterator var err error iter, _ = store.Iterator(nil, nil) diff --git a/api/memory_test.go b/api/memory_test.go index c3aef249..b05b94fd 100644 --- a/api/memory_test.go +++ b/api/memory_test.go @@ -58,7 +58,6 @@ func TestCreateAndDestroyUnmanagedVector(t *testing.T) { // Like the test above but without `newUnmanagedVector` calls. // Since only Rust can actually create them, we only test edge cases here. - //go:nocheckptr func TestCopyDestroyUnmanagedVector(t *testing.T) { { diff --git a/api/mocks.go b/api/mocks.go index 2701ae4b..f5015621 100644 --- a/api/mocks.go +++ b/api/mocks.go @@ -302,7 +302,7 @@ func (l Lookup) Delete(key []byte) { } // Iterator wraps the underlying DB's Iterator method panicing on error. -func (l Lookup) Iterator(start, end []byte) Iterator { +func (l Lookup) Iterator(start, end []byte) dbm.Iterator { l.meter.ConsumeGas(RangePrice, "range") iter, err := l.db.Iterator(start, end) if err != nil { @@ -313,7 +313,7 @@ func (l Lookup) Iterator(start, end []byte) Iterator { } // ReverseIterator wraps the underlying DB's ReverseIterator method panicing on error. -func (l Lookup) ReverseIterator(start, end []byte) Iterator { +func (l Lookup) ReverseIterator(start, end []byte) dbm.Iterator { l.meter.ConsumeGas(RangePrice, "range") iter, err := l.db.ReverseIterator(start, end) if err != nil { diff --git a/lib.go b/lib.go index c54fffc8..6fac4764 100644 --- a/lib.go +++ b/lib.go @@ -17,8 +17,6 @@ type WasmCode []byte // KVStore is a reference to some sub-kvstore that is valid for one instance of a code type KVStore = api.KVStore -type Iterator = api.Iterator - // GoAPI is a reference to some "precompiles", go callbacks type GoAPI = api.GoAPI