-
Notifications
You must be signed in to change notification settings - Fork 134
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
Slate binary/base64 encoding #112
Conversation
libwallet/src/slate_versions/mod.rs
Outdated
}; | ||
|
||
Ok(VersionedSlate::V2(slate)) | ||
} | ||
} | ||
|
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.
Sorry, I know you asked but I think this should go into the Slate, not the versioned file. Would the assumption be that you would only really want to serialize the latest slate to binary?
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.
Why would we only want to serialize the latest? If we choose that route, we have to always be backward-compatible with future changes.
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.
Right, in the current setup, it's expected that each new version of the slate will require implementing conversions between previous version->current version and back. So this would require a second implementation to support the binary conversion as well. Perhaps we just want to consider swapping to using one or the other, but not getting into a position where we need to support both.
@@ -346,7 +348,11 @@ pub fn receive( | |||
g_args: &GlobalArgs, | |||
args: ReceiveArgs, | |||
) -> Result<(), Error> { | |||
let adapter = FileWalletCommAdapter::new(); | |||
let adapter = match args.method.as_str() { | |||
"file" => FileWalletCommAdapter::new(), |
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.
Our plan is to deprecate "file" then, right? I can't think of any reason we would want file support when we have something as simple as a string.
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.
Not sure I understand, why would we want to deprecate the ability to save a slate as a file?
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.
This fully replaces every use case for file send/receive. One of our many usability issues right now is the fact that there are so many different ways to send/receive grin. Certain exchanges only support certain methods, and the same goes for wallets. It may sound counter-intuitive, but the way we make grin more usable is to support fewer transfer methods, not more.
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.
Still not with you here. Are you suggesting that anyone using the command line wallet should have to cut and paste strings into the command line instead of being allowed to specify a file name, and everyone creating a new transaction for email send (for instance) would either have to cut/paste or pipe output into a file?
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.
Sure, seems easy enough. Regardless, I'm not as worried about the 'file' method as having a separate serialization format for files. If we're going to serialize slates to base64 for files too, then I'm ok with keeping it.
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.
we can keep the file as is for now and have it output a hex or b64 file after the hard fork
So now we have to worry about binary serialization and json serialization with each new slate version. Can we stop supporting json with future versions, and just send base64 via HTTP as well? |
Couple of comments inline, and a few more observations:
|
Also, not quite convinced that outputting the base64 to the terminal should be the default, it seems to be more useful in the case of interacting with a webpage as opposed to the existing CLI wallet to CLI wallet transfer |
@DavidBurkett I know you don't like this because it adds maintenance burden, but how do you do QR codes without it ? |
@mcdallas What is it you think I don't like? I love the idea of base64 encoding binary slates. It's something I had thought about before, and I was your biggest proponent when you brought it up after the last dev meeting. What I don't like is continuing to support json slates when this is clearly better. |
Okay, after the discussion above and a bit more thinking, I'm very not sure this is something we just want to smash into 1.1.0 a couple of days before we release it. The major concerns here are that we're creating 2 separate slate formats here that have to be maintained through all future versions, and applying them a bit inconsistently. I'm not against changing the slate format to be a binary-only one more conducive to compaction, as there's nothing special about the choice of json originally other than it was easiest during early development. But I think the changeover should be planned out beforehand, the binary slate format generally agreed upon, and then on release of a particular version, all slates will be in the binary format (or base64 representation thereof). This way, we'll only need to implement the json->binary conversion once in the upgrade/downgrade chain, and eventually be able to drop support for the json altogether at the next hard fork. |
This PR adds --method string to all the wallet commands |
@yeastplume the reason that I want this to 1.1.0 is if we release invoicing without strings, all the exchanges/pools are going to implement it over http and when 1.1.1 is released they are never going to change it. Imo it is worth it postponing 1.1.0 |
Right, problem here is that 1.1.0 has already been dragging on quite a bit, we can't release grin server 1.1.0 without releasing grin-wallet as well, and we very much need to get it out as we only really have a couple of weeks now to get changes in for the 2.0.0 fork version. For the record, I'm perfectly fine with targeting this functionality for 2.0.0 by treating the binary-serialized slate as Slate V3 implementing the conversion between V2 and V3 in the conversion pipeline, and ensuring all slate input/output is consistent. Another complication that's just come to mind here here is that the V2 wallet API uses json slates as arguments (and are very easy for API consumers to read,) so I don't think that dropping all json support for slates is viable... again it all needs to be thought through. |
moved ser/deset to a trait and rebased on latest |
@mcdallas Thanks again for continuing to work on this, it looks in a good state now, and thanks for changing the serialization to be consistent with the rest of grin. Only think I'd say now is the binary serialization could probably use a couple of small unit tests, particularly to inform future developers that they need to be changed when the slate format changes. After thinking a bit more and considering this looks more or less complete I could probably be convinced to merge this in before 1.1.0, so long it comes with the caveat that we're not going to do another beta for it (any issues will have to be fixed in the point release). I'll just summarize current apprehensions:
Does this thinking make sense? Would anyone else have any major concerns here before we merge this? |
I think we can avoid adding versioning to the binary encoding and be backwards compatible by appending any new field at the end of the slate. Also for anyone reviewing this, it would be nice to review the serialization format itself and if anything needs to change, because changing anything after it goes live (except adding new fields) will be backwards incompatible |
I strongly prefer a version byte. |
Apologies this got closed accidentally due to branch changes (I missed this one,) conversation is still open, would appreciate if you could reopen. But I think this will need an RFC under the upcoming structure changes |
this PR:
StdioWalletCommAdapter
that reads/writes base64 slates to stdi/ostring
method to theinvoice
,pay
,send
,receive
andfinalize
commandsand makes it the default for
invoice
andpay
You can create an invoice with
grin-wallet invoice <amount>
you can process an invoice with
grin-wallet pay -i <b64string>
you can finalize with
grin-wallet finalize -m string -i <b64string>
any of this commands with
-m string
and without-i
will read from stdin