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

Reject invalid attributes #562

Merged
merged 4 commits into from
Jul 27, 2021
Merged

Reject invalid attributes #562

merged 4 commits into from
Jul 27, 2021

Conversation

ethanfrey
Copy link
Member

@ethanfrey ethanfrey commented Jul 26, 2021

Closes #560

Return error on invalid events/attributes returned from contracts

@ethanfrey ethanfrey requested a review from webmaster128 July 26, 2021 20:12
@ethanfrey ethanfrey requested a review from alpe as a code owner July 26, 2021 20:12
@codecov
Copy link

codecov bot commented Jul 26, 2021

Codecov Report

Merging #562 (d540e00) into master (86d96fd) will increase coverage by 0.06%.
The diff coverage is 87.87%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #562      +/-   ##
==========================================
+ Coverage   59.59%   59.65%   +0.06%     
==========================================
  Files          45       45              
  Lines        5242     5260      +18     
==========================================
+ Hits         3124     3138      +14     
- Misses       1890     1892       +2     
- Partials      228      230       +2     
Impacted Files Coverage Δ
x/wasm/keeper/keeper.go 85.38% <50.00%> (-0.60%) ⬇️
x/wasm/keeper/events.go 100.00% <100.00%> (ø)

}
value := strings.TrimSpace(l.Value)
if len(value) == 0 {
return nil, sdkerrors.Wrap(types.ErrInvalidEvent, fmt.Sprintf("Empty attribute value. Key: %s", key))
Copy link
Member

Choose a reason for hiding this comment

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

Why is this check needed? Can't you have contracts that always set an attribute that is potentially empty (e.g. custom note)

Copy link
Member Author

Choose a reason for hiding this comment

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

There is no way to search for this if it is empty. The syntax is <type>.<key> = <value>

I guess this might be allowed, I should check on the sdk side.

Copy link
Member Author

Choose a reason for hiding this comment

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

I added a TODO and asked the sdk team if it is valid.
Shall we make the decision before merge?

Copy link
Member

Choose a reason for hiding this comment

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

Alright. I'm fine either way and do not know what the best way to handle this is.

@ethanfrey ethanfrey merged commit b2adcc4 into master Jul 27, 2021
@ethanfrey ethanfrey deleted the 560-reject-invalid-attributes branch July 27, 2021 12:24
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.

Return error when contract returns invalid events
2 participants