Skip to content

Commit

Permalink
Merging 0.12 (#39)
Browse files Browse the repository at this point in the history
* Upgrade parity-wasm

* Update contract lock files

* Use the same contract version for borner as the rest of the contracts

* Set version: 0.11.0-alpha3

* Implement From<Binary> for Vec<u8>

* Implement From<CanonicalAddr> for Vec<u8>

* Add missing newlines

* Add Binary::into_vec and CanonicalAddr::into_vec

* Remove #[inline] attributes

* Add riffle_shuffle

* Remove canonical_length parameter

* Remove the ability to change canonical length in VM's MockApi

* Use riffle_shuffle in std's MockApi

* Add simulation script

* Use riffle_shuffle in vm's MockApi

* Add left rotate by digit sum

* Add CHANGELOG/MIGRATING entries

* Update testing contract

* Move MessageInfo outside of Env

* Update do_init/handle/... exports

* Update entry_points macro

* Update burner contract

* Fix VM calls for extra arg, burner integration tests pass

* Hackatom builds properly

* Fix tests for hackatom

* Fixed all tests in vm package

* Updated queue contract

* Fix various test failures from CI

* Update hackatom contract

* Fix hackatom singlepass

* Update staking contract

* Fixed last test

* Update CHANGELOG and README

* Cleanup from PR review

* Rebuild test contract, update gas prices

* Fixed up merge conflict

* Set version: 0.11.0-alpha4

* Remove unnecessary 'static restriction from Storage and Querier

* Remove obsolete Instance::from_wasmer

* Add Querier helpers query_wasm_{smart,raw}

* Add special raw query to reflect contract

* Simplify RawResponse

* Sort imports in traits.rs

* Add Deref to some common types

* Test to show from_slice and from_binary both work on Binary now

* Use &canonical instead of canonical.as_slice() some places

* Delegate is_empty, len, into_vec into Deref target

* Sort imports

* Implement PartialEq<str> for HumanAddr

* Document and test impl Deref for HumanAddr

* Document and test impl Deref for CanonicalAddr

* Document and test impl Deref for Binary

* Set version: 0.11.0

* Test Hash and HashSet for HumanAddr

* Allow using Binary in HashSet and HashMap

* Allow using CanonicalAddr in HashSet and HashMap

* Add a Sum helper for Uint128

* Sort imports

* Implement Add for Uint128 with reference right hand side

* Implement AddAssign with reference rhs for Uint128

* Use checked_sub to implement Sub for Uint128

* Implement Sub for Uint128 with reference rhs

* Implement sum with reference rhs using add

* Cleanup error result test

* Make source type in Sum explicit

* Add CHANGELOG entries

* Pull out fn deserialize

* Test some properties of deserialized module

* Fix module name: compatability -> compatibility

* Set version: 0.11.1

* Add FfiError::IteratorDoesNotExist

* Replace range with scan/next in Storage trait

* Update MockStorage to new trait

* Use with_storage_from_context in do_next

* Remove with_iterator_from_context

* Remove VmError::IteratorDoesNotExist

* Remove iterators from ContextData

* Implement AddAssign for GasInfo

* Handle errors in self.next perperly

* Adapt burner integration tests to new storage

* Add note on iterator IDs

* Remove StorageIterator and MockIterator

* Add CHANGELOG entries

* Remove outdated doc comment

* Remove StdError::Unauthorized

* Use thiserror instead of snafu in std

* Roll out all features in CI testing, remove backtraces feature

* Convert FfiError to thiserror

* Convert CommunicationError from snafu to thiserror

* Convert RegionValidationError from snafu to thiserror

* Convert VmError from snafu to thiserror

* Remove snafu dependency from storage

* Remove the snafu dependency from cosmwasm-vm

* Create new contract_0.12.wasm development contract

* Upgrade to rust-optimizer:0.10.4 for all dev contracts

* Implement From<std::str::Utf8Error> and From<std::string::FromUtf8Error>

* Add a few more explicit result types

* Rename `Extern` to `Deps`

* Generalize denom argument in Coin constructors

* Remove change_querier

* Add ExternMut ExternRef types

* Update hackatom with ExternRef ExternMut

* Remove some generic type parameters

* Simplify hackatom contract

* Remove Q generic from ExternRef/Mut

* Update entry points for hackatom, integration tests pass

* Port burner contract

* Port queue

* Start updating storage-bucket

* Bucket works with dyn trait object

* Singleton and Sequence work with trait objects

* Update reflect contract

* Fixed iterator support in bucket

* Update staking contract

* Improve naming and docs for &dyn ReadonlyStorage cast

* Format migrating.md

* Rename Deps* types, add Copy to DepsRef

* Update contracts for renaming

* Rename Querier types, for cleaner public Api

* Revert "Rename Querier types, for cleaner public Api"

This reverts commit a7efaa3.

* Deps/DepsRef -> DepsMut/Deps

* Implement PartialEq between Binary and Vec<u8>/&[u8]

* Add missing PartialEq implementations between HumanAddr and str/&str

* Compare Binary and Vec<u8> in hackatom

* Rename module encoding -> binary

* Sort imports

* Add Binary::to_array

* Document length limit of Binary::to_array

* Ensure Binary::to_array cannot be used with Vec<u8>

* Update vm test contract, fix typo

* Let Binary::to_array compile with Rust lower than 1.47

* Remove TypedStorage and PrefixedStorage from the cosmwasm-storage

* Remove ReadonlyStorage from cosmwasm-std and -storage

* Remove ReadonlyStorage from sample contracts

* Update CHANGELOG and MIGRATING

* Set version: 0.11.2

* Bring back PrefixedStorage/ReadonlyPrefixedStorageage

* Set publish = false consistently

* Add Debug support for MemoryStorage

* Pull out InstanceOptions

* Make `FileSystemCache` crate internal

* Convert modules from file to folder

* Remove obsolete load_with_backend

* Remove backend function in favour of BACKEND_NAME constant

* Fix FileSystemCache::load return type

* Use fresh temp dir for each run in test_file_system_cache_run

* Rename to fs_cache and hits_fs_cache

* Replace wabt with wat, which is written in pure Rust

* Add Size type

* Create InMemoryCache

* Let FileSystemCache::store take a module reference only

* Integrate memory cache

* Ensure save_wasm does not write to memory cache

* Rename CosmCache to Cache

* Extract CacheOptions and make memory limit configurable

* Rename `Extern` to `Backend`

* Rename mock_dependencies -> mock_backend

* Rename FfiError -> BackendError

* Merge ffi and traits module into backend

* Add panic when setting an empty value

* Re-compile testing contract

* Set version: 0.12.0-alpha1

* Allow constructing CacheOptions crate external

* Set version: 0.12.0-alpha2

* Replace {Deps,DepsRef} with {Deps,DepsMut}

* Add helper so handler can call other handler

* Address concerns from PR review

* Show users how to properly set dependencies in migration guide

* Remove StorageTransaction and friends

* Add LimitedDisplay and implement for HashSet

* Implement LimitedDisplay for BTreeSet

* Use to_string_limited for features

* Cleanup error matching

* Show all required imports in error message

* Make imports test independent of iterator feature

* Add compatibility table

* Pull out collection_to_string_limited and implement for vector

* Explain why sorting is needed

* Test BTreeSet::to_string_limited

* Set version: 0.12.0-alpha3

* Upgarde rust-optimizer to 0.10.5

* Set version: 0.12.0

* fix: fix package/ext for upstream v0.12.0

* fix: replace log with attributes in collection-tester

It is to follow v0.12.0

* fix: replace Extern<...> with Deps[Mut] in collection_tester

It is to follow v0.12.0.

* fix: Insert arg MessageInfo in handle functions in collection_tester

It is to follow v0.12.0.

* fix: Remove unused imports

* fix: fix the type of functions in collection_tester/src/state.rs

It is to follow v0.12.0

* fix: fix collection-tester/lib.rs to use macro

* fix: delete unneeded & for querier

Now, querier is QuerierWrapper, so the & is unneeded

* fix: insert a arg Env to query function

It is to follow v0.12.0.

* fix: replace env as an arg of init with _env

* fix: version up and update Cargo.* for collection-tester

* fix: replace log with attr in token-tester

It is to follow v0.12.0.

* fix: replace Extern<...> with Deps[Mut] in token_tester

It is to follow v0.12.0.

* fix: fix the type of functions in collection_tester/src/state.rs

It is to follow v0.12.0

* fix: remove unused imports

* fix: delete unneeded & for querier

Now, querier is QuerierWrapper, so the & is unneeded

* fix: change the arg of config and config_read to follow
the change of state.rs

It is to follow v0.12.0

* fix: fix init of token-tester to use MessageInfo

It is to follow v0.12.0.

* fix: add env to args of query functions in token-tester

It is to follow v0.12.0.

* fix: fix token-tester/lib.rs to use macro

It is to follow v0.12.0.

* fix: fix test in token-tester to follow v0.12.0

* fix: versionup token-tester contract

* fix: execute cargo fmt

* fix: suppress clippy error in contracts by too_many_arguments

* fix: execute cargo fmt

Co-authored-by: Simon Warta <simon@warta.it>
Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Ethan Frey <ethanfrey@users.noreply.github.com>
  • Loading branch information
5 people committed Jan 26, 2021
1 parent ce1dd47 commit 3122042
Show file tree
Hide file tree
Showing 154 changed files with 7,405 additions and 7,224 deletions.
99 changes: 47 additions & 52 deletions .circleci/config.yml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ insert_final_newline = true

[*.rs]
indent_size = 4

[*.py]
indent_size = 4
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

# Build results
target/
contracts/**/contract.wasm
contracts/**/hash.txt
artifacts/

# IDEs
.vscode/
Expand Down
169 changes: 169 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,174 @@
# CHANGELOG

## 0.12.0 (2020-11-19)

**cosmwasm-std**

- Remove the previously deprecated `StdError::Unauthorized`. Contract specific
errors should be implemented using custom error types now (see
[migration guide](./MIGRATING.md) 0.10 -> 0.11).
- Use dependency `thiserror` instead of `snafu` to implement `StdError`. Along
with this change, the `backtraces` feature now requires Rust nightly.
- Rename `StdError::ParseErr::source` to `StdError::ParseErr::source_type` and
`StdError::SerializeErr::target` to `StdError::SerializeErr::target_type` to
work around speacial treatment of the field name `source` in thiserror.
- Rename `Extern` to `Deps` to unify naming.
- Simplify ownership of calling `handle`, etc. with `Deps` and `DepsMut` struct
that just contains references (`DepsMut` has `&mut Storage` otherwise the
same)
- Remove unused `Deps::change_querier`. If you need this or similar
functionality, create a new struct with the right querier.
- Remove `ReadonlyStorage`. You can just use `Storage` everywhere. And use
`&Storage` to provide readonly access. This was only needed to let
`PrefixedStorage`/`ReadonlyPrefixedStorage` implement the common interface,
which is something we don't need.

**cosmwasm-storage**

- `PrefixedStorage`/`ReadonlyPrefixedStorage` do not implement the
`Storage`/`ReadonlyStorage` traits anymore. If you need nested prefixes, you
need to construct them directly via `PrefixedStorage::multilevel` and
`ReadonlyPrefixedStorage::multilevel`.
- Remove unused `TypedStorage`. If you need this or similar functionality, you
probably want to use `Bucket` or `Singleton`. If you really need it, please
copy the v0.11 code into your project.
- Remove `StorageTransaction` along with `transactional` and `RepLog`. This has
not been used actively for contract development and is now maintained in a
contract testing framework.

**cosmwasm-vm**

- Remove `Storage::range` and `StorageIterator`. The storage implementation is
now responsible for maintaining iterators internally and make them accessible
via the new `Storage::scan` and `Storage::next` methods.
- Add `FfiError::IteratorDoesNotExist`. Looking at this, `FfiError` should
probably be renamed to something that includes before, on and behind the FFI
boundary to Go.
- `MockStorage` now implementes the new `Storage` trait and has an additional
`MockStorage::all` for getting all elements of an iterator in tests.
- Remove unused `Extern::change_querier`. If you need this or similar
functionality, create a new struct with the right querier.
- Let `Instance::from_code` and `CosmCache::get_instance` take options as an
`InstanceOptions` struct. This contains `gas_limit` and `print_debug` for now
and can easily be extended. `cosmwasm_vm::testing::mock_instance_options` can
be used for creating such a struct in integration tests.
- Make `FileSystemCache` crate internal. This should be used via `CosmCache`.
- Fix return type of `FileSystemCache::load` to `VmResult<Option<Module>>` in
order to differentiate missing files from errors.
- Add in-memory caching for recently used Wasm modules.
- Rename `CosmCache` to just `cosmwasm_vm::Cache` and add `CacheOptions` to
configure it.
- Rename `Extern` to `Backend`.
- Rename `mock_dependencies` to `mock_backend` and
`mock_dependencies_with_balances` to `mock_backend_with_balances`.
- Rename `FfiError`/`FfiResult` to `BackendError`/`BackendResult` and adapt
`VmError` accordingly.

## 0.11.2 (2020-10-26)

**cosmwasm-std**

- Implement `From<std::str::Utf8Error>` and `From<std::string::FromUtf8Error>`
for `StdError`.
- Generalize denom argument from `&str` to `S: Into<String>` in `coin`, `coins`
and `Coin::new`.
- Implement `PartialEq` between `Binary` and `Vec<u8>`/`&[u8]`.
- Add missing `PartialEq` implementations between `HumanAddr` and `str`/`&str`.
- Add `Binary::to_array`, which allows you to copy binary content into a
fixed-length `u8` array. This is espeically useful for creating integers from
binary data.

## 0.11.1 (2020-10-12)

**cosmwasm-std**

- Implement `Hash` and `Eq` for `Binary` to allow using `Binary` in `HashSet`
and `HashMap`.
- Implement `Hash` and `Eq` for `CanonicalAddr` to allow using `CanonicalAddr`
in `HashSet` and `HashMap`.
- Implement `Add`, `AddAssign` and `Sub` with references on the right hand side
for `Uint128`.
- Implement `Sum<Uint128>` and `Sum<&'a Uint128>` for `Uint128`.

## 0.11.0 (2020-10-08)

**all**

- Drop support for Rust versions lower than 1.45.2.
- The serialization of the result from `init`/`migrate`/`handle`/`query` changed
in an incompatible way. See the new `ContractResult` and `SystemResult` types
and their documentation.
- Pass `Env` into `query` as well. As this doesn't have `MessageInfo`, we
removed `MessageInfo` from `Env` and pass that as a separate argument to
`init`, `handle`, and `query`. See the example
[type definitions in the README](README.md#implementing-the-smart-contract) to
see how to update your contract exports (just add one extra arg each).

**cosmwasm-std**

- Add `time_nanos` to `BlockInfo` allowing access to high precision block times.
- Change `FullDelegation::accumulated_rewards` from `Coin` to `Vec<Coin>`.
- Rename `InitResponse::log`, `MigrateResponse::log` and `HandleResponse::log`
to `InitResponse::attributes`, `MigrateResponse::attributes` and
`HandleResponse::attributes`.
- Rename `LogAttribute` to `Attribute`.
- Rename `log` to `attr`.
- Rename `Context::add_log` to `Context::add_attribute`.
- Add `Api::debug` for emitting debug messages during development.
- Fix error type for response parsing errors in `ExternalQuerier::raw_query`.
This was `Ok(Err(StdError::ParseErr))` instead of
`Err(SystemError::InvalidResponse)`, implying an error created in the target
contract.
- Deprecate `StdError::Unauthorized` and `StdError::unauthorized` in favour of
custom errors. From now on `StdError` should only be created by the standard
library and should only contain cases the standard library needs.
- Let `impl Display for CanonicalAddr` use upper case hex instead of base64.
This also affects `CanonicalAddr::to_string`.
- Create trait `CustomQuery` for the generic argument in
`QueryRequest<C: CustomQuery>`. This allows us to provide
`impl<C: CustomQuery> From<C> for QueryRequest<C>` for any custom query.
- Implement `From<Binary> for Vec<u8>`.
- Implement `From<CanonicalAddr> for Vec<u8>`.
- Add `Binary::into_vec` and `CanonicalAddr::into_vec`.
- The `canonical_length` argument was removed from `mock_dependencies`,
`mock_dependencies_with_balances`. In the now deprecated `MockApi::new`, the
argument is unused. Contracts should not need to set this value and usually
should not make assumptions about the value.
- The canonical address encoding in `MockApi::canonical_address` and
`MockApi::human_address` was changed to an unpredicatable represenation of
non-standard length that aims to destroy most of the input structure.

**cosmwasm-storage**

- Change order of arguments such that `storage` is always first followed by
namespace in `Bucket::new`, `Bucket::multilevel`, `ReadonlyBucket::new`,
`ReadonlyBucket::multilevel`, `bucket` and `bucket_read`.
- Change order of arguments such that `storage` is always first followed by
namespace in `PrefixedStorage::new`, `PrefixedStorage::multilevel`,
`ReadonlyPrefixedStorage::new`, `ReadonlyPrefixedStorage::multilevel`,
`prefixed` and `prefixed_read`.

**cosmwasm-vm**

- `CosmCache::new`, `Instance::from_code` and `Instance::from_module` now take
an additional argument to enable/disable printing debug logs from contracts.
- Bump required export `cosmwasm_vm_version_3` to `cosmwasm_vm_version_4`.
- The `canonical_length` argument was removed from `mock_dependencies`,
`mock_dependencies_with_balances` and `MockApi::new_failing`. In the now
deprecated `MockApi::new`, the argument is unused. Contracts should not need
to set this value and usually should not make assumptions about the value.
- The canonical address encoding in `MockApi::canonical_address` and
`MockApi::human_address` was changed to an unpredicatable represenation of
non-standard length that aims to destroy most of the input structure.

## 0.10.1 (2020-08-25)

**cosmwasm-std**

- Fix bug where `ExternalStorage.range()` would cause VM error if either lower
or upper bound was set
([#508](https://github.com/CosmWasm/cosmwasm/issues/508))

## 0.10.0 (2020-07-30)

**all**
Expand Down
Loading

0 comments on commit 3122042

Please sign in to comment.