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

fix(ecocredit/marketplace): nil expirations no longer pruned #1115

Merged
merged 8 commits into from
May 31, 2022

Conversation

technicallyty
Copy link
Contributor

@technicallyty technicallyty commented May 19, 2022

Description

Fixes a bug where sell orders with nil expirations were being pruned

Closes: #1114


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@codecov
Copy link

codecov bot commented May 19, 2022

Codecov Report

Merging #1115 (0fd5057) into master (eb54e96) will decrease coverage by 5.67%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1115      +/-   ##
==========================================
- Coverage   69.78%   64.10%   -5.68%     
==========================================
  Files         218      215       -3     
  Lines       22243    20357    -1886     
==========================================
- Hits        15522    13050    -2472     
- Misses       5391     6049     +658     
+ Partials     1330     1258      -72     
Flag Coverage Δ
experimental-codecov ?
stable-codecov 64.10% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Copy link
Member

@ryanchristo ryanchristo 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 to me. Nice work.

}
}
for _, id := range expiredOrderIds {
if err := k.stateStore.SellOrderTable().Delete(ctx, &marketplaceapi.SellOrder{Id: id}); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Actually, it looks like we can call this within the it.Next() loop rather than appending to expiredOrderIds. No need to create expiredOrderIds and append the expired orders and then loop through a second time.

Copy link
Contributor Author

@technicallyty technicallyty May 21, 2022

Choose a reason for hiding this comment

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

per https://github.com/cosmos/cosmos-sdk/blob/main/orm/model/ormtable/iterator.go#L15-L19 we should not mutate the table during iteration.

however, i came back to this and actually might have a better solution 😈 . so after talking with aaron, nil timestamps are actually treated/encoded as zero values, or timestamppb.Timestamp{Seconds:0, Nanos: 0}. so if we want the performance boost of DeleteRange, we could just delete everything starting at timestamppb.Timestamp{Seconds:0, Nanos: 1}.

the tests still hold up with this change 😄 . lmk if that sounds sane or not

@aaronc
Copy link
Member

aaronc commented May 21, 2022

Seeing this I really think this should be fixed in the orm because otherwise it's unexpected behavior

Copy link
Member

@ryanchristo ryanchristo left a comment

Choose a reason for hiding this comment

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

Updates look good to me. Just a couple nits.

@technicallyty technicallyty marked this pull request as draft May 23, 2022 15:04
@technicallyty
Copy link
Contributor Author

going to convert to draft here pending #1115 (comment), we might not need this

@technicallyty technicallyty marked this pull request as ready for review May 31, 2022 15:12
@technicallyty technicallyty mentioned this pull request May 31, 2022
4 tasks
@technicallyty
Copy link
Contributor Author

merging here, can revert with #1136 when the ORM changes are integrated

@technicallyty technicallyty enabled auto-merge (squash) May 31, 2022 15:26
@technicallyty technicallyty merged commit 12969b5 into master May 31, 2022
@technicallyty technicallyty deleted the ty/1114-prune_bug branch May 31, 2022 15:57
@ryanchristo
Copy link
Member

Hmm... why did project code coverage go down by more than 5%?

Screenshot from 2022-06-01 08-28-49

@ryanchristo
Copy link
Member

Looks like it went back up more than 5% with the latest commit... Not exactly sure what happened there.

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.

Prune Orders deletes nil value expirations
4 participants