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

Contract state is no longer required to implement StateClone for unit testing #321

Merged
merged 9 commits into from
Aug 21, 2023

Conversation

target-san
Copy link
Contributor

@target-san target-san commented Jul 21, 2023

Purpose

Remove StateClone trait, which was needed only to clone toplevel contract state during unit testing

Changes

  • TestHost implementation no longer imposes StateClone constraint onto state type
  • State is cloned by deserializing it from storage
  • StateClone is removed (see comment)

Checklist

  • My code follows the style of this project.
  • The code compiles without warnings.
  • I have performed a self-review of the changes.
  • I have documented my code, in particular the intent of the
    hard-to-understand areas.
  • (If necessary) I have updated the CHANGELOG.

CLA acceptance

By submitting the contribution I accept the terms and conditions of the
Contributor License Agreement v1.0

@target-san
Copy link
Contributor Author

One thing which I didn't touch is whether TestHost::with_rollback should be modified to perform actual operation on cloned state and leave original state as-is, just in case

@abizjak
Copy link
Member

abizjak commented Jul 25, 2023

Hi. thanks for the effort.

We were planning to deprecate the entire test infrastructure as it is now in favor of the testing library and with that we would remove in particular the StateClone, but also the odd and hard to explain "state_parameter = S" annotation on the macros, and a few generics on entrypoints.

I would prefer to do that in one big release, rather than deprecating/removing things one at a time.

Is this blocking you?

If it is, I don't think deprecating is the right approach. People should not be writing these by hand anyhow, so we should just remove the StateClone trait entirely.

@target-san
Copy link
Contributor Author

Well, this test infra is kind of useful in some scenarios 'cause it allows debugging contract directly.

Nope, it's not blocking me or anything. Just had some spare time and inspiration to drop it. Thought that soft deprecation is better, as it won't break other users' code. Shall I remove StateClone completely?

@abizjak
Copy link
Member

abizjak commented Jul 27, 2023

Well, this test infra is kind of useful in some scenarios 'cause it allows debugging contract directly.

Sure, but the issue is that it adds a lot of complexity, both in terms of the way the contracts look (with extra generics), and with the amount of code we need to maintain (for example the entire implementation of test infrastructure, including its own state implementation). So our conclusion is that iti s not worth it.

Nope, it's not blocking me or anything. Just had some spare time and inspiration to drop it. Thought that soft deprecation is better, as it won't break other users' code. Shall I remove StateClone completely?

Yes, that'd be my preference.

@target-san
Copy link
Contributor Author

I dropped StateClone completely, both in this repo and in concordium-contracts-common: please check PR 104
Unfortunately this one's incomplete, as I'll have to fix smart contract templates checking on CI

…plates, such that crates from working copy are used
@target-san
Copy link
Contributor Author

target-san commented Aug 7, 2023

Ok, so StateClone is now completely removed, and all checks are fixed.
Plz note that PR 104 should be merged first in order to set proper submodule reference

@abizjak abizjak mentioned this pull request Aug 19, 2023
5 tasks
Copy link
Member

@abizjak abizjak left a comment

Choose a reason for hiding this comment

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

Looks good.

Sorry for the tardiness here as well. This will be released on Monday.

I have merged it into #330

@abizjak abizjak merged commit ccaf814 into Concordium:main Aug 21, 2023
126 checks passed
@target-san target-san deleted the remove-state-clone branch August 21, 2023 07:40
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.

None yet

2 participants