-
Notifications
You must be signed in to change notification settings - Fork 193
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
refactor(perp): Remove unnecessary panics | #1 #1126
Merged
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e00712c
remove unnecessary panics in x/perp
Unique-Divine 5bed36e
change log
Unique-Divine bdb30af
chore: re-run linter
Unique-Divine 5033e7b
test(oracle): stop the tyrannical behavior of tally_fuzz_test.go
Unique-Divine 699257f
test(oracle): try assert.NotPanics for keys of length 0
Unique-Divine 3a4c7c1
feat,test(common): Create StringSet for easy set management
Unique-Divine ad7e866
test(oracle): Increase coverage and end the collections panics in
Unique-Divine fd4be81
fix(oracle): small bug in TestFuzz_PickReferencePair
Unique-Divine 1640306
test,feat(common): address PR feedback and add a more generic version…
Unique-Divine 74cbfd3
linter
Unique-Divine 9794d2a
Update x/common/error_test.go
Unique-Divine 865ffc9
Merge branch 'master' into realu/remove-panics-perp
Unique-Divine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the type switch statement catch all these cases already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's how I thought it would work at first too. The reason it skips those blocks is that
any
andinterface{}
are actual types. They don't actual mean "any type" but rather "an object of typeany
".Let's say we pass in an argument,
arg
, that fits thefmt.Stringer
interface likesdk.Coin
orsdk.AccAddress
. Whenarg
enters this function, it won't actually have the type offmt.Stringer
, so it will pass all of the case statements and end up in default.Then, when it reaches the
arg := arg.(fmt.Stringer)
block, it will enter the function withfmt.Stringer
as its value forarg.(type)
. Sincearg
actually is an instance of that fits this interface, theTryCatch
will run smoothly.However, it has to guess by manually attempting to cast as each type. Go assumes the type casting will work and forces the object to have a certain type, then it panics if something doesn't make sense, then defers, then recovers, and finally moves to the next
TryCatch
.This basically shows why Python is so slow.