-
Notifications
You must be signed in to change notification settings - Fork 367
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(evmutil): register MsgConvertCosmosCoinToERC20 on amino #1599
Conversation
also use new register method that checks length to catch ledger issues
@@ -63,6 +69,64 @@ func TestExport(t *testing.T) { | |||
assert.Len(t, exportedApp.Validators, 1) // no validators set in default genesis | |||
} | |||
|
|||
// TestLegacyMsgAreAminoRegistered checks if all known msg types are registered on the app's amino codec. | |||
// It doesn't check if they are registered on the module codecs used for signature checking. |
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.
is refers to the ModuleCdc
right?
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.
yeah, I was thinking we could add tests to the modules to cover them. But if we replace them with a global codec as they've done in v0.46 (cosmos/cosmos-sdk#11240) we could run this test on that global codec.
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.
great test addition
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.
i register this type in the upcoming PR with the handler implementation. 😄 maybe that's unorthodox!? but this is a great test guaranteeing we're registering messages as soon as they're introduced.
} | ||
|
||
// Check the msg is registered in amino by checking a repeat registration call panics. | ||
panicValue, ok := catchPanic(func() { |
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.
super clever way to check the messages are registered 👍 🥇
nit: you can probably use require.PanicsWithValue
(or PanicsWithError
) to test this.
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.
thanks, I started with PanicsWithValue/Error
but the panic returns an error msg containing the go type name of the msg (eg "types.MsgPlaceBid"
). I couldn't think of a way to reconstruct it to do the comparison.
|
||
for i, msgName := range msgProtoNames { | ||
// skip external unregistered msgs | ||
if msgName == sdk.MsgTypeURL(&evmtypes.MsgEthereumTx{}) || |
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.
i'd love if this was a list called unregisteredMsgs
or something similar
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.
agreed, it's a bit confusing, changed to protoRegisteredMsgs
as at this point it's unclear if these msgs are all registered on amino or not
Description
Noticed the new
MsgConvertCosmosCoinToERC20
wasn't registered on amino. So added a test to help catch this in the future by checking all msgs registered on the proto codec are on amino. It's not perfect, we should ideally checkmsg.GetSignBytes
returns properly encoded msgs (it uses a local amino, not the app's amino). But it did catch a pre-existing issue where we hadn't setup the registration inmodule.go
.Also added this to the list of gotchas with link to explainer. It's unlikely to cause issues but can in very particular cases mess with tx signing.
Checklist