-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add amino JSON proto annotations #13407
Comments
Doesn't sign mode textual mean that Amino can be completely removed? If so, are these annotations worth it? How long do we see Amino sticking around? |
Good point. I meant to put that in as a caveat. I'm not really sure. If it's more that an year to SIGN_MODE_TEXTUAL maybe worth it. If it's six months, probably not. @AmauryM do you have a roadmap estimate? I did post this with the thought that it will be a while till everything is ready but I'd be happy to hear that it will be sooner. |
Ok that's fine. Since adding annotations are relatively low-lift, there's no harm in doing this. |
Even though Textual gets shipped in the next 6 months (which is my current estimate, Q1 2023), I think we still want to keep amino for a while, for the ecosystem to migrate. So my preference is still to move on with this protoreflect amino encoder for now. |
hey I'm super curious about this, as I'm building a transpiler to generate amino encoders and would love to collaborate on a standard way to create proto annotations. This seems like a relevant issue, let me know if I'm in the wrong place! A few examples that we're doing today: for example, in Another example, we are using However, these particular proto options feel less semantic than having a codegen or amino json annotation of sorts. So I was imagining something like this that I could hook into:
or something like this so it’s it’s own flag that wouldn’t get updated by devs accidentally and break codegen |
So gogoproto options should generally not be inspected by anything other than gogoproto, although maybe it's okay for use cases like yours temporarily. Gogo proto is basically a dead project and we're going to remove the annotations eventually. They're very golang specific and not semantic like you say.
|
Hey @pyramation, I created a branch to show @aaronc's // existing Msg
message MsgStoreCode {
bytes wasm_byte_code = 1 [
(gogoproto.customname) = "WASMByteCode",
(cosmos_proto.scalar) = "wasm.v1.WASMByteCode" // <--- New option
];
}
// inside new `wasm/v1/scalars.proto` file:
option (cosmos_proto.declare_scalar) = {
name: "WASMByteCode",
description: "A coswasm contract byte code",
field_type: [SCALAR_TYPE_BYTES],
amino_encoding: "Use base64 to encode this field" // Some human-readable string on how to encode this field.
// TODO: or should `amino_encoding` be machine-readable?
}; It's basically expanding on your
because we would standardize (once) in a separate |
I don't understand, why aren't we just adding the simple Happy to rename Why did this "declare_scalar" thing come in, what problem is that solving? This as a problem area should be rare, no? And for this example of WasmStoreBytes, the problem is its a one-off, not something to be routinely reused. (If it was it should just be a new proto type that we serialize, no?) Also |
I think bytes wasm_byte_code = 2 [ (gogoproto.customname) = "WASMByteCode", (cosmos.amino_encoding) = 'base64' ]; I also didn't realize the complexity of the scalar concept. I thought it was something like the |
The rationale for
so:
Without scalars, we would do
and if there are N places where we use RawContractMessage, we define encoding N times (+ risk of inconsistency). But I do agree it's slight more code to retrieve the correct encoding (i.e. need to find the |
I also don't understand the scalar concept. Feels like it just creates indirection but I might have missed something. So in CosmWasm we (ab)use the current messages implementation for embedding JSON messages sent to a contract. A separate Go type
The same applies for four message types MsgInstantiateContract, MsgInstantiateContract2, MsgExecuteContract, MsgMigrateContract as well as proposal types InstantiateContractProposal, MigrateContractProposal, SudoContractProposal, ExecuteContractProposal.
This does not sound like an issue to me. We do that for custom proto types as well and IMO every Amino JSON and textual renderer schould have a test that ensures a particular sign doc representation. |
Is there any use case for teleascope to deal with Amino? Dapps usually don't do multi sig. cc: @pyramation |
@webmaster128 the idea of
you will need to specify these hints for every codec. |
Summary
Add proto options that specify how protobuf types should be serialized in amino JSON.
Problem Definition
Currently, in amino JSON serialization options are specified by:
This means that clients need to inspect the go code directly to figure out how to generate amino JSON properly. It is also problematic for supporting the
google.golang.org/protobuf
API because those types won't work with the amino codec. (This is described more fully in #10993 where amino JSON proto annotations were first proposed).Proposal
Add protobuf options to specify amino JSON serialization options that can be used by:
Specifically, we need options for:
cosmos.msg.v1.legacy_amino_name
)omitempty
specified (maybecosmos.msg.v1.legacy_amino_omitempty
)The existing
cosmos_proto.scalar
annotation may be sufficient to handle marshaling of custom types but we need to make sure these annotations are applied consistently.In order for this system to work correctly, there needs to be some validation that options are correctly specified during Msg server registration, similar to the validation described in #13405).
Note: depending on the time frame for SIGN_MODE_TEXTUAL and how quickly we expect it to completely replace amino this issue may or may not be irrelevant.
The text was updated successfully, but these errors were encountered: