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

Update to scale-info 1.0, introduce metadata format versioning #845

Merged
merged 26 commits into from
Oct 11, 2021

Conversation

ascjones
Copy link
Collaborator

@ascjones ascjones commented Jul 7, 2021

Use scale-info 1.0 everywhere.

Introduces metadata versioning as specified in #941.

Companion cargo-contract PR: use-ink/cargo-contract#342

todo

  • Update cargo-contract
  • Ensure polkadot-js/api is updated to handle the new metadata format for Canvas UI and polkadot.js/apps

See polkadot-js/api#3687 for polkadot.js and polkadot-js/api#3759 for UI compat progress.

@ascjones ascjones changed the title Update to scale-info 0.9 Update to scale-info 0.9 Jul 7, 2021
@ascjones ascjones added the E-in-progress A task that is already being worked on. label Jul 7, 2021
@ascjones ascjones changed the title Update to scale-info 0.9 Update to scale-info 0.10 Jul 30, 2021
@ascjones ascjones changed the title Update to scale-info 0.10 Update to scale-info 1.0 Sep 2, 2021
@ascjones ascjones marked this pull request as ready for review September 2, 2021 15:01
@ascjones ascjones removed the E-in-progress A task that is already being worked on. label Sep 8, 2021
Copy link
Collaborator

@cmichi cmichi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

I just want to wait with the merge until we have our CI running again everywhere. Otherwise it will become more hairy to sort out where a failure goes back to.

The CI is currently failing because of a number of issues: we changed our repository setup and there are some follow-ups to be done in GitLab (see the issues I created in the ci_cd repo), but also because I yesterday found WebAssembly/binaryen#4148.

@ascjones
Copy link
Collaborator Author

Cool feel free to merge this when ready then 👍

@cmichi
Copy link
Collaborator

cmichi commented Sep 14, 2021

Ah could you add the change to RELEASES.md as well? Makes it easier for the next release.

@codecov-commenter
Copy link

codecov-commenter commented Sep 14, 2021

Codecov Report

Merging #845 (0bff439) into master (c9a97bb) will increase coverage by 0.44%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #845      +/-   ##
==========================================
+ Coverage   84.17%   84.61%   +0.44%     
==========================================
  Files         172      172              
  Lines        7924     7852      -72     
==========================================
- Hits         6670     6644      -26     
+ Misses       1254     1208      -46     
Impacted Files Coverage Δ
crates/metadata/src/layout/tests.rs 100.00% <ø> (ø)
crates/primitives/src/key.rs 81.48% <0.00%> (-1.02%) ⬇️
crates/storage/src/alloc/boxed/storage.rs 100.00% <ø> (ø)
...ates/storage/src/collections/hashmap/fuzz_tests.rs 95.74% <0.00%> (+1.06%) ⬆️
crates/engine/src/test_api.rs 98.41% <0.00%> (+4.36%) ⬆️
crates/allocator/src/bump.rs 100.00% <0.00%> (+20.00%) ⬆️
crates/engine/src/ext.rs 95.40% <0.00%> (+24.94%) ⬆️
crates/engine/src/types.rs 100.00% <0.00%> (+33.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c9a97bb...0bff439. Read the comment docs.

Copy link
Collaborator

@Robbepop Robbepop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Looking forward to having this merged!

@ascjones
Copy link
Collaborator Author

Note that the cargo-contract companion use-ink/cargo-contract#342 will not pass CI until this PR makes it into a new release candidate (as far as I understand)

@Robbepop
Copy link
Collaborator

Robbepop commented Sep 20, 2021

Can we merge this now that all tests are passing and we have approvals?
Should we release another ink! RC to make cargo contract master work again?

@cmichi
Copy link
Collaborator

cmichi commented Sep 21, 2021

This PR is blocked by https://github.com/polkadot-js/apps/issues/6167.

@cmichi cmichi added the E-blocked The task is blocked on some other task to be finished. label Sep 21, 2021
@ascjones ascjones changed the title Update to scale-info 1.0 Update to scale-info 1.0, introduce metadata format versioning Sep 23, 2021
RELEASES.md Outdated Show resolved Hide resolved
crates/metadata/src/lib.rs Outdated Show resolved Hide resolved
ascjones and others added 9 commits September 23, 2021 15:53
Co-authored-by: Michael Müller <michi@parity.io>
Co-authored-by: Michael Müller <michi@parity.io>
* [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: Robin Freyler <robbepop@web.de>

* cargo fmt

Co-authored-by: Robin Freyler <robbepop@web.de>
Updates the requirements on [pretty_assertions](https://github.com/colin-kiegel/rust-pretty-assertions) to permit the latest version.
- [Release notes](https://github.com/colin-kiegel/rust-pretty-assertions/releases)
- [Changelog](https://github.com/colin-kiegel/rust-pretty-assertions/blob/main/CHANGELOG.md)
- [Commits](rust-pretty-assertions/rust-pretty-assertions@v0.7.1...v1.0.0)

---
updated-dependencies:
- dependency-name: pretty_assertions
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@ascjones ascjones merged commit ff723b1 into master Oct 11, 2021
@ascjones ascjones deleted the aj-upgrade-scale-info branch October 11, 2021 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-blocked The task is blocked on some other task to be finished.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants