Skip to content

Move storage derives to ink crate#1400

Merged
ascjones merged 14 commits intomasterfrom
aj/move-derives-to-ink-crate
Sep 20, 2022
Merged

Move storage derives to ink crate#1400
ascjones merged 14 commits intomasterfrom
aj/move-derives-to-ink-crate

Conversation

@ascjones
Copy link
Copy Markdown
Collaborator

As discussed in #1223, one problem is that the storage traits derive macros (Storable, StorableHint, StorageKey, StorageLayout) generate code which assumes the top level ink crate is in scope e.g. ::ink::storage::traits::StorageKey. Therefore if a user were to import the standalone ink_storage crate and use those derives, it would not work.

This PR solves that by moving the storage derives into the ink crate itself, ensuring it is only possible to use those derives together with the ink crate.

@ascjones ascjones requested review from a team, HCastano and cmichi as code owners September 16, 2022 13:08
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Sep 16, 2022

Codecov Report

Merging #1400 (e877c90) into master (3eb6eb0) will increase coverage by 0.38%.
The diff coverage is 71.42%.

❗ Current head e877c90 differs from pull request most recent head d8da53d. Consider uploading reports for the commit d8da53d to get more accurate results

@@            Coverage Diff             @@
##           master    #1400      +/-   ##
==========================================
+ Coverage   71.62%   72.01%   +0.38%     
==========================================
  Files         187      185       -2     
  Lines        5844     5813      -31     
==========================================
  Hits         4186     4186              
+ Misses       1658     1627      -31     
Impacted Files Coverage Δ
crates/ink/macro/src/lib.rs 100.00% <ø> (ø)
crates/ink/macro/src/storage/storable.rs 92.68% <ø> (ø)
crates/ink/macro/src/storage/storage_layout.rs 90.24% <ø> (ø)
crates/ink/macro/src/storage/tests/mod.rs 0.00% <ø> (ø)
...nk/tests/ui/contract/pass/storage-packed-fields.rs 12.50% <ø> (ø)
...ests/ui/storage_item/pass/argument_derive_false.rs 100.00% <ø> (ø)
...ts/ui/storage_item/pass/complex_non_packed_enum.rs 88.13% <ø> (ø)
.../ui/storage_item/pass/complex_non_packed_struct.rs 96.42% <ø> (ø)
.../tests/ui/storage_item/pass/complex_packed_enum.rs 100.00% <ø> (ø)
...ests/ui/storage_item/pass/complex_packed_struct.rs 100.00% <ø> (ø)
... and 10 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ascjones ascjones force-pushed the aj/move-derives-to-ink-crate branch from b9e101f to d8da53d Compare September 20, 2022 11:03
@ascjones ascjones merged commit e809445 into master Sep 20, 2022
@ascjones ascjones deleted the aj/move-derives-to-ink-crate branch September 20, 2022 11:35
@ascjones ascjones mentioned this pull request Sep 22, 2022
@xiyu1984
Copy link
Copy Markdown

Hey @ascjones ,
Where is the ::ink_storage::traits::push_spread_root::<Self>(self, &root_key); in 4.0.0-alpha.3?
I have tried ::ink::storage::traits::push_spread_root::<Self>(self, &root_key); but still not found.

image

Are there any suggestions? Thanks~

@ascjones
Copy link
Copy Markdown
Collaborator Author

Hi @xiyu1984, those methods and traits have been removed as part of the storage rework: see the release notes: https://github.com/paritytech/ink/blob/master/CHANGELOG.md#storage-rework

@xiyu1984
Copy link
Copy Markdown

xiyu1984 commented Sep 29, 2022

Hi @xiyu1984, those methods and traits have been removed as part of the storage rework: see the release notes: https://github.com/paritytech/ink/blob/master/CHANGELOG.md#storage-rework

Hi @ascjones , thanks a lot. My use case is that I need a re-entry call to a smart contract. That is, Contract A calls contract B, and then contract B calls back to contract A to update a state(a member of contract A). In the last version of ink, I use push_spread_root and pull_spread_root to make sure the state in contract A is updated. The related code can be seen here. Are there any suggestions of how to implement it currently?
Thanks again~

@xgreenx
Copy link
Copy Markdown
Contributor

xgreenx commented Sep 29, 2022

@xiyu1984 I can't compile it because I don't have a payload crate, but the fix should look like this dantenetwork/protocol-stack-for-ink#10

@xiyu1984
Copy link
Copy Markdown

xiyu1984 commented Sep 29, 2022

@xiyu1984 I can't compile it because I don't have a payload crate, but the fix should look like this dantenetwork/protocol-stack-for-ink#10

Hey @xgreenx,
Yes, it works~ Thank you very much~ I remember that I solved the re-entry problem last time with the help of you. So, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants