1. 04 Oct, 2021 1 commit
    • Robin Freyler's avatar
      Implement selector_id!, selector_bytes! and blake2x256! macros (#947) · bd4b51e3
      Robin Freyler authored
      * add selector_id! and selector_bytes! proc macros
      
      * implement blake2x256! macro
      
      * re-export blake2x256! macro from ink_lang crate
      
      * apply rustfmt
      
      * add BLAKE2b to hunspell dictionary
      
      * add UI tests for blake2x256! macro
      
      * improve span for non-literal inputs to blake2x256! macro
      
      * add non-literal input failure UI test to blake2x256! macro
      
      * improve error span for non-literal selector_{id,bytes}! macro inputs
      
      * rename UI test blake2x256 -> blake2x256_macro
      
      * rename UI test
      
      * add UI tests for selector_id! proc. macro
      
      * fix UI test
      
      * fix UI test expectation
      
      * add UI tests for seletor_bytes! macro
      
      * make flaky and broken codecov CI happy again ...
      bd4b51e3
  2. 29 Sep, 2021 1 commit
  3. 27 Sep, 2021 1 commit
    • tash-2s's avatar
      [storage] Allow one variant enum to derive SpreadLayout (#942) · fd94d383
      tash-2s authored
      
      
      * [storage] Allow one variant enum to derive SpreadLayout
      
      I have an enum that has only one variant, and I want to store the enum value in the storage. I might add new variants later in development, so the enum is not useless.
      
      The current implementation doesn't allow to derive the `SpreadLayout` trait for one variant enums, and I fixed it on this PR.
      
      # Sample code
      
      ```rust
      #![cfg_attr(not(feature = "std"), no_std)]
      
      use ink_lang as ink;
      
      #[derive(
          Copy,
          Clone,
          scale::Encode,
          scale::Decode,
          ink_storage::traits::SpreadLayout,
          ink_storage::traits::PackedLayout,
      )]
      #[cfg_attr(
          feature = "std",
          derive(scale_info::TypeInfo, ink_storage::traits::StorageLayout)
      )]
      pub enum MyEnum {
          A,
      }
      
      #[ink::contract]
      mod enum_test {
          use super::MyEnum;
      
          #[ink(storage)]
          pub struct EnumTest {
              value: MyEnum,
          }
      
          impl EnumTest {
              #[ink(constructor)]
              pub fn new() -> Self {
                  Self { value: MyEnum::A }
              }
      
              #[ink(message)]
              pub fn get(&self) -> MyEnum {
                  self.value
              }
          }
      }
      ```
      
      Without this change, I get this error.
      
      ```
      $ cargo +nightly contract build
       [1/5] Building cargo project
          Updating crates.io index
         Compiling enum_test v0.1.0 (/private/var/folders/zn/l2f569z56vnghtt524x1mv6w0000gn/T/cargo-contract_FM50JF)
      error: proc-macro derive panicked
        --> /snip/enum_test/lib.rs:10:5
         |
      10 |     ink_storage::traits::SpreadLayout,
         |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         |
         = help: message: can only operate on enums
      ```
      
      * Update crates/storage/derive/src/spread_layout.rs
      Co-authored-by: Hero Bird's avatarRobin Freyler <robbepop@web.de>
      
      * cargo fmt
      Co-authored-by: Hero Bird's avatarRobin Freyler <robbepop@web.de>
      fd94d383
  4. 23 Sep, 2021 2 commits
  5. 22 Sep, 2021 2 commits
    • Robin Freyler's avatar
    • Michael Müller's avatar
      Fix code coverage (#917) · 511b9c68
      Michael Müller authored
      * Add `-Clink-dead-code`
      
      * Test trait cross-call only when not measuring code coverage
      
      Otherwise a linker error will happen due
      to `__ink_enforce_error` being included.
      
      * Fix `clippy::derivable_impls`
      
      * Fix `dead_code`
      
      The `struct` is only a public-facing API.
      
      * Fix yaml
      
      * Remove `allow(dead_code)`
      
      * Actually use `$POLL_SLEEP`
      
      * Produce `unreachable!` instead of linker error for `codecov` CI stage
      
      * Move `if` condition outside of `quote`
      
      * Improve macro hygiene
      
      * Reduce code duplication
      511b9c68
  6. 21 Sep, 2021 5 commits
    • Robin Freyler's avatar
      Misc cleanups in ink! codegen (#935) · b4e2781c
      Robin Freyler authored
      * remove some duplicated AsRef impl code in generators
      
      * improve #[ink::test] macro hygiene and error message upon failure
      
      * import standard ink! traits anonymously in codegen
      
      * modernize and improve macro hygiene of metadata codegen
      
      * modernize and simplify and improve macro hygiene of storage codegen
      
      * extend selector_works unit test
      
      * fix minor error in item impl error message
      b4e2781c
    • Robin Freyler's avatar
      Move ink_lang_macro UI tests into macro-specific folders (#934) · 87867ef8
      Robin Freyler authored
      * move ink_lang_macro UI tests into macro-specific folders
      
      * fix GitLab CI formatting pass
      
      * migrate back to a single trybuild test case
      
      This is because our CI currently fails if we have multiple test cases.
      87867ef8
    • Robin Freyler's avatar
      Refactor and modernize dispatch codegen (#933) · 0270add0
      Robin Freyler authored
      * implement Display for ink_lang::Error
      
      * re-export HexLiteral trait from ink_lang_ir crate
      
      * use big-letters for hex-encoded message and constructor identifiers in codegen
      
      * improve panic messages in dispatch codegen for call and deploy fns
      
      * improve macro hygiene in dispatch codegen
      
      * add ir::Selector::into_be_u32 method
      
      * improve and modernize dispatch selector namespace codegen
      0270add0
    • Robin Freyler's avatar
      Check namespace argument is identifier (#931) · 41b0a1c0
      Robin Freyler authored
      * check that argument in #[ink(namespace = "argument")] is a Rust identifier
      
      * add UI tests for #[ink(namespace = "..")] ink! property
      
      # Conflicts:
      #	crates/lang/macro/tests/compile_tests.rs
      #	crates/lang/macro/tests/ui/fail/N-01-namespace-invalid-identifier.rs
      #	crates/lang/macro/tests/ui/fail/N-01-namespace-invalid-identifier.stderr
      #	crates/lang/macro/tests/ui/fail/N-02-namespace-invalid-type.rs
      #	crates/lang/macro/tests/ui/fail/N-02-namespace-invalid-type.stderr
      #	crates/lang/macro/tests/ui/fail/N-03-namespace-missing-argument.rs
      #	crates/lang/macro/tests/ui/fail/N-03-namespace-missing-argument.stderr
      
      * fix error message for non-identifier namespace argument
      41b0a1c0
    • Robin Freyler's avatar
      09ec050e
  7. 20 Sep, 2021 3 commits
    • Robin Freyler's avatar
      Expand selectors as hex-encoded literals in metadata (#927) · 725c2f70
      Robin Freyler authored
      * add HexLiteral utility trait to expand hex-encoded integer literals
      
      * add ir::Selector::hex_lits method
      
      * expand into hex-encoded integer literals for metadata selectors
      
      * simplify Selector::hex_lits method using array::map API
      
      * add unit test for Selector::hex_lits method
      725c2f70
    • Robin Freyler's avatar
      Improve SpreadLayout and StorageLayout derive macro hygiene (#926) · 9bab4838
      Robin Freyler authored
      * miscellaneous improvements to macro hygiene in derive macros
      
      * fix storage_derive UI tests
      9bab4838
    • Robin Freyler's avatar
      Make #[ink(selector = ..)] take a u32 parameter instead of a string (#928) · c9a97bbe
      Robin Freyler authored
      * make #[ink(selector = ..)] take an integer instead of a string
      
      Also warn about deprecation if a user still uses the old string parameter.
      
      * update tests for new selector int parameter
      
      * update contract examples for new selector int parameter
      
      * remove unused regex dependency from ink_lang_ir
      
      Also remove unnecessary regex dependency from ink_lang_codegen
      
      * update README for new selector int parameter
      
      Also update namespace parameter description.
      
      * update preliminary release notes
      
      * update spellcheck dict
      c9a97bbe
  8. 17 Sep, 2021 2 commits
    • Michael Müller's avatar
      Fix nightly clippy warnings (#925) · 4155ebe2
      Michael Müller authored
      * Derive `Default`
      
      * Fix `field is never read`
      4155ebe2
    • Michael Müller's avatar
      Fix nightly clippy errors (#921) · c2ea64b5
      Michael Müller authored
      * Fix `clippy::derivable_impls`
      
      * Fix `dead_code`
      
      The `struct` is only a public-facing API.
      
      * Get rid of `allow(dead_code)`
      
      * Revert "Get rid of `allow(dead_code)`"
      
      This reverts commit 6b9a95f9.
      
      * Revert "Fix `dead_code`"
      
      This reverts commit 42ab18be.
      
      * New approach to fix `dead_code`
      
      * Fix naming
      
      * Reflect that `return_type` never needs to be read
      
      * Fix typo
      c2ea64b5
  9. 09 Sep, 2021 1 commit
  10. 06 Sep, 2021 1 commit
  11. 03 Sep, 2021 1 commit
  12. 02 Sep, 2021 1 commit
  13. 30 Aug, 2021 1 commit
  14. 25 Aug, 2021 1 commit
  15. 16 Aug, 2021 1 commit
  16. 12 Aug, 2021 1 commit
  17. 05 Aug, 2021 2 commits
    • Michael Müller's avatar
      Import quickcheck macro only for bump allocator (#887) · 3c8b1030
      Michael Müller authored
      * Import quickcheck macro only for bump allocator
      
      The fuzz tests exist only in the bump allocator.
      
      * Apply `cargo fmt`
      3c8b1030
    • Michael Müller's avatar
      Run clippy with `--all-targets` (#884) · 4b909706
      Michael Müller authored
      * Add clippy flag `--all-targets`
      
      * Fix `redundant_closure`
      
      * Fix `redundant_clone`
      
      * Fix `clone_on_copy`
      
      * Fix `needless_borrow`
      
      * Fix `bool_assert_comparison`
      
      * Fix `len_zero`
      
      * Fix `stable_sort_primitive`
      
      * Forward feature
      
      * Allow `type_complexity`
      
      * Fix `unnecessary_mut_passed`
      
      * Fix `manual_map`
      
      * Fix `match_like_matches_macro`
      
      * Remove duplicate test
      
      * Fix `new_without_default`
      
      * Fix `match_ref_pats`
      
      * Allow clippy rules for  tests
      
      * Fix `unit_arg`
      
      * Apply `cargo fmt`
      
      * Add explanatory comments
      
      * Remove `--all-targets` for Wasm tests
      
      * Fix `or_fun_call`
      
      * Fix `bool_comparison`
      
      * Fix `needless_collect`
      
      * Revert "Forward feature"
      
      This reverts commit 472c50ed.
      
      * Fix `bool_assert_comparison`
      
      * Deactivate test because of feature issue with dev-dependencies
      
      * Add flag
      
      * Fix `unique_topics` tests
      
      * Allow `clippy:bool_assert_comparison`
      
      * Revert "Fix `bool_assert_comparison`"
      
      This reverts commit bceb2dc2.
      
      * Revert "Fix `bool_comparison`"
      
      This reverts commit 02960f98.
      
      * Fix flags positioning
      
      * Add comment for clarification
      
      * Fix comparison
      
      * Do not check all targets for target = wasm32
      
      * Adapt `check-workspace.sh` with clippy flag
      
      * Add clarification comment
      
      * Ignore test
      
      * Revert `CLIPPY_FLAGS` hack
      
      * Link ink! issue
      
      * Fix `assert`'s
      
      * Fix `assert`'s
      4b909706
  18. 02 Aug, 2021 1 commit
  19. 30 Jul, 2021 1 commit
  20. 28 Jul, 2021 1 commit
  21. 22 Jul, 2021 1 commit
  22. 21 Jul, 2021 1 commit
  23. 20 Jul, 2021 2 commits
    • Hernando Castano's avatar
      Add Bump Allocator (#831) · 5fd8f876
      Hernando Castano authored
      * Add bump allocator skeleton
      
      * Implement `alloc` for our bump allocator
      
      * Make the allocator usable globally
      
      * Remove unused `init()` function
      
      * Nightly RustFmt
      
      * Use global mutable static instead of Mutex
      
      This will reduce our use of dependencies which will hopefully
      reduce our final Wasm binary size.
      
      Also, apparently spinlocks aren't actually all that efficient.
      See: https://matklad.github.io/2020/01/02/spinlocks-considered-harmful.html
      
      * Stop assuming that memory is allocated at address `0`
      
      * Remove semicolon
      
      * Use correct address when checking if we're OOM
      
      * Remove unnecessary unsafe block
      
      * Return null pointers instead of panicking
      
      Panicking in the global allocator is considered undefined behaviour.
      
      * Use `checked_add` when getting upper limit memory address
      
      * Use `MAX` associated const instead of `max_value`
      
      * Inline `GlobalAlloc` methods
      
      * Turns out I can't early return from `unwrap_or_else` 🤦
      
      * Rollback my build script hacks
      
      * Add initialization function to allocator
      
      * Add some docs
      
      * Make the bump allocator the default allocator
      
      * Allow bump allocator to be tested on Unix platforms
      
      * Remove unecessary checked_add
      
      * Add error messages to unrecoverable errors
      
      * Remove `init` function from allocator
      
      Instead we now request a new page whenver we need it, regardless
      of whether or not it's the first time we're allocating memory.
      
      * Try switching from `mmap` to `malloc` when in `std` env
      
      * Fix `is_null()` check when requesting memory
      
      * Stop requesting real memory for `std` testing
      
      Instead this tracks pages internally in the same way that the Wasm
      environment would. This means we can test our allocator implementation
      instead of fighting with `libc`.
      
      * Gate the global bump allocator when not in `std`
      
      * Allow for multi-page allocations
      
      * Update the module documentation
      
      * Override `alloc_zeroed` implementation
      
      * Forgot to update Wasm target function name
      
      * Appease the spellchecker
      
      * Use proper English I guess
      
      * Get rid of `page_requests` field
      
      * Explicitly allow test builds to use test implementation
      
      * All link to zero'd Wasm memory reference
      
      * Check that our initial pointer is 0 in a test
      
      * Add `cfg_if` branch for non-test, `std` enabled builds
      
      * Simplify `cfg_if` statement
      5fd8f876
    • Michael Müller's avatar
      Fix `clippy::self-named-constructor` (#866) · 4ff763c9
      Michael Müller authored
      error: constructor `lazy` has the same name as the type
      	   --> crates/storage/src/lazy/mod.rs:121:5
      
      	       121 | /     pub(crate) fn lazy(key: Key) -> Self {
      	       122 | |         Self {
      	       123 | |             cell: LazyCell::lazy(key),
      	       124 | |         }
      	       125 | |     }
      		   | |_____^
      
      	= note: `-D clippy::self-named-constructor` implied by `-D warnings`
      	= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#self_named_constructor
      4ff763c9
  24. 19 Jul, 2021 1 commit
  25. 13 Jul, 2021 2 commits
  26. 09 Jul, 2021 1 commit
    • Karel L. Kubat's avatar
      Implement binary_search for `collections::Vec` (#836) · 36bbdec1
      Karel L. Kubat authored
      
      
      * [storage] Implement binary_search
      
      * [storage] Add binary_search testcase for missing smaller element
      
      * [storage] use indexing instead of Vec::get
      Co-authored-by: Hero Bird's avatarRobin Freyler <robbepop@web.de>
      
      * [storage] Port binary_search tests from core
      
      * [storage] Format tests
      
      * [storage] Format tests
      
      * Remove old comment
      Co-authored-by: Hero Bird's avatarRobin Freyler <robbepop@web.de>
      
      * [storage] Incorporate review feedback
      
      * [CI] add comparator to spellcheck
      
      Porting binary_search to the storage Vec, including the documentation found in core, led to a failure in spellcheck. Since core is considered to be correct, it is updated on spellcheck.
      
      * incorporate review feedback
      
      * add permalink to stdlib source
      
      * Split long line
      
      * fix examples
      
      * RustFmt the doc examples
      Co-authored-by: Hero Bird's avatarRobin Freyler <robbepop@web.de>
      Co-authored-by: default avatarHernando Castano <hernando@hcastano.com>
      36bbdec1
  27. 08 Jul, 2021 2 commits