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

Can no longer mark a failed meetup as completed #275

Closed
echevrier opened this issue Oct 26, 2022 · 1 comment · Fixed by #274
Closed

Can no longer mark a failed meetup as completed #275

echevrier opened this issue Oct 26, 2022 · 1 comment · Fixed by #274

Comments

@echevrier
Copy link
Collaborator

Since paritytech/substrate#11927 changes, the storage don't persist when a call return an error. See paritytech/substrate#11533 (comment)
So

<IssuedRewards<T>>::insert((cid, cindex), meetup_index, ());
will not be saved.
The test claim_rewards_error_results_in_meetup_marked_as_completed fails at
assert!(IssuedRewards::<TestRuntime>::contains_key((cid, cindex), 1));

@echevrier
Copy link
Collaborator Author

@clangenb Before fixing this, I would like to understand the purpose of IssuedRewards<T>.

There is no "completed meetup". IssuedRewards<T> is used to ensure that the reward is issued only one time, even if claim_rewards is called multiple times:

if <IssuedRewards<T>>::contains_key((cid, cindex), meetup_index) {

The key is inserted when the rewards have been successfully issued:

<IssuedRewards<T>>::insert((cid, cindex), meetup_idx, ());

and in the registration phase, when we cannot get the participants who are eligible for the reward:
<IssuedRewards<T>>::insert((cid, cindex), meetup_index, ());

What if claim_reward fails for other reasons?
What if claim_reward is never called?

If the problem is only at

<IssuedRewards<T>>::insert((cid, cindex), meetup_index, ());
, can we emit an event in this case and the off-chain world will call an update of IssuedRewards<T> ?

echevrier pushed a commit that referenced this issue Oct 27, 2022
- Add a claim_reward feedback in the IssuedRewards Storage
- claim_reward returns OK if a MeetupValidationError occurs in the Registration phase
clangenb pushed a commit that referenced this issue Nov 9, 2022
…` storage. (#274)

* claim_rewards_error_results_in_meetup_marked_as_completed fails

* remove debug print messages

* Fix bug #275:
- Add a claim_reward feedback in the IssuedRewards Storage
- claim_reward returns OK if a MeetupValidationError occurs in the Registration phase

* rename claim_reward_successfull

* Add Cargo.lock which was falsely deleted

* Fix to compile in std and no_std mode

* Use of strongly typed MeetupResult

* Rename test

* Add missing /std into std features

* Changes from review

* Changes from review: OptionQuery

Co-authored-by: echevrier <edith.chevrier@scs.ch>
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 a pull request may close this issue.

1 participant