Skip to content
This repository was archived by the owner on Jul 15, 2018. It is now read-only.

Fee is a KI64Pair#167

Merged
jaekwon merged 1 commit intosdk2from
feature/fee-ki64pair
Dec 25, 2017
Merged

Fee is a KI64Pair#167
jaekwon merged 1 commit intosdk2from
feature/fee-ki64pair

Conversation

@jaekwon
Copy link
Contributor

@jaekwon jaekwon commented Dec 23, 2017

  • There's little difference between []byte and string (in most languages you can cast it) but there are small issues with string:
    -> Unable to correctly deserialize strings containing null characters protobuf-c/protobuf-c#203
    -> We already use KVPair in several places and it's always been {[]byte, []byte} (e.g. we should refactor to eventually just use tmlibs/common/KVPair. Using gogoproto we can do that now).
    -> Protobuf3 strings are supposed to be only utf8 or 7-bit ansii but for something called "KVPair", we don't want to be restricted to unicode or ansii characters.
    -> Perhaps using []byte makes us more vigilant in validating the input before accepting it, than be lulled into complacency w/ a string.

So this PR simplifies KVPair to just be ([]byte, []byte), and mayb we can do another PR to just use tmlibs/common.KVPair instead, or do it here.

It also introduces a more restrictive type, KI64Pair. We can later introduce KI32Pair, KU64Pair, etc.

@codecov-io
Copy link

Codecov Report

Merging #167 into sdk2 will decrease coverage by 0.41%.
The diff coverage is 15.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##             sdk2     #167      +/-   ##
==========================================
- Coverage   10.68%   10.26%   -0.42%     
==========================================
  Files          12       12              
  Lines        2172     2163       -9     
==========================================
- Hits          232      222      -10     
- Misses       1924     1925       +1     
  Partials       16       16
Impacted Files Coverage Δ
types/util.go 0% <ø> (-38.47%) ⬇️
example/dummy/dummy.go 66.66% <100%> (ø) ⬆️
types/types.pb.go 5.01% <5.88%> (-0.01%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update aaaacba...eb13d65. Read the comment docs.

Data: []byte("hello"),
Gas: 43,
Fee: 12,
Fee: KI64Pair{[]byte("pho"), 12},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hahah SF life ;)

Copy link
Contributor

@odeke-em odeke-em left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I don't understand how the protobuf-c null terminator string problem affects us in Go.

@jaekwon
Copy link
Contributor Author

jaekwon commented Dec 23, 2017

It doesn't affect us but it will affect anyone writing C applications, if we ever put a 0x00 byte in the KVPair "string".

@odeke-em
Copy link
Contributor

Gotcha gotcha, great point.

@ebuchman
Copy link
Contributor

Presumably the idea here is to put the coin denomination in as the key?

I think part of the motivation for the previous KVPair structure was to enable DeliverTx tags to have values that are either strings or integers - this change would force them to be strings (well, bytes, but same same). Is that what we want ?

Otherwise this looks good, except that we may actually want int128 ...

@jaekwon
Copy link
Contributor Author

jaekwon commented Dec 25, 2017

The pubsub query could include casting of bytes into anything... so maybe for comparison you need to first cast it like "int64(value) < 123" or something. @melekes

@jaekwon jaekwon merged commit f390385 into sdk2 Dec 25, 2017
@melekes
Copy link
Contributor

melekes commented Dec 25, 2017

yeah, we'll need to cast before making a comparison

https://github.com/tendermint/tmlibs/blob/master/pubsub/query/query.go#L228-L249

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants