-
Notifications
You must be signed in to change notification settings - Fork 93
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
[WIP] use base64 over base64-bytestring #1631
Conversation
831561e
to
11b6cce
Compare
Does this pass replay? |
11b6cce
to
5eb5591
Compare
No; I think that we actually do need to keep |
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 should double check that all use of base64 is the URL variant without padding.
Regarding replay: this should be fine since chainweb doesn't put base64 encoded things on-chain. Base64 is used only as textual representation of binary data (mostly in JSON). Merkle hashes of on-chain data are computed on the plain binary representation.
However, I am not 100% certain about the use of base64 within pact service. In theory it shouldn't affect on-chain data (in particular errors in pact service shouldn't be included on-chain), but we should double check that.
, base64-bytestring >= 1.0 && < 1.1 | ||
-- due to change in error message that is inlined in pact |
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.
👍 the upper bound is tracked in the cabal.project file.
@@ -325,8 +325,7 @@ library | |||
, attoparsec >= 0.13 | |||
, base >= 4.12 && < 5 | |||
, base16-bytestring >= 0.1 | |||
, base64-bytestring >= 1.0 && < 1.1 | |||
-- due to change in error message that is inlined in pact | |||
, base64 >= 0.5 && < 0.6 |
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 this known to break with base64 >=0.6? Otherwise please remove, since we don't manually track "soft" upper bounds.
, base64 >= 0.5 && < 0.6 | |
, base64 >= 0.5 |
@@ -746,7 +750,7 @@ getDecimal = do | |||
|
|||
mockDecode :: ByteString -> Either String MockTx | |||
mockDecode s = do | |||
s' <- B64.decode s | |||
s' <- first T.unpack $ B64U.decodeBase64 $ B64.assertBase64 @'B64.UrlPadded @_ s |
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 am a bit concerned about B64.UrlPadded
. Does this mean the it uses padding? All use of base64 throughout chainweb should be base64Url without padding.
. first (Base64DecodeException . T.pack) | ||
. B64.decode | ||
. first Base64DecodeException | ||
. B64.decodeBase64 | ||
. B64.assertBase64 @'B64.StdPadded @_ |
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.
Are the functions for the unpadded (and non-url) variants used anywhere in the code? If not we should consider removing them, so that nobody uses them. This is to keep used encodings simple and consistent.
@@ -325,8 +325,7 @@ library | |||
, attoparsec >= 0.13 | |||
, base >= 4.12 && < 5 | |||
, base16-bytestring >= 0.1 | |||
, base64-bytestring >= 1.0 && < 1.1 | |||
-- due to change in error message that is inlined in pact | |||
, base64 >= 0.5 && < 0.6 |
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.
It seems that version 0.5 of base64 hasn't yet been released. The latest version on Hackage is 0.4.2.4. 0.5 is only available as source repository from Github. If 0.5 is actually required, we would have to ask the maintainer (@emilypi?) to release 0.5 on Hackage or include it as source repository package in cabal.project.
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.
It hasn't been released and I"m still working on the PR, which will significantly affect this PR.
I like your enthusiasm @chessai! However, this is jumping the gun alittle bit. The PR that is going in to serve as the basis for That said, with the addition of SIMD support, I do endorse this change, and I would like to revert from
It should @jwiegley, since we're going in at the chainweb level, and the problems with replay w.r.t. Base64 are with the Pact natives wholesale committing to the error format returned by |
Thanks, Yeah, after talking to you yesterday/digging around in your PR/the codebase more, it seems like this is indeed jumping the gun. I'll leave this open for now, because I do think it's something we should return to. |
I added SIMD to base64 (See PR).
Per profiling, chainweb-node spends about 6% of its time performing base64 decode on blocks. According to the microbenchmarks, this should hopefully offer a speedup of ~15x on decode of things that are the average block size.
The other nice thing about the
base64
library is that it has the option of being more type-safe.All these assertions I've added here are unsafe, but, they were just implicit before.