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

Use gogoproto's nullable=false #166

Merged
merged 3 commits into from
Dec 23, 2017
Merged

Use gogoproto's nullable=false #166

merged 3 commits into from
Dec 23, 2017

Conversation

jaekwon
Copy link
Contributor

@jaekwon jaekwon commented Dec 22, 2017

Avoiding pointers where it isn't necessary is generally better for security, as non-pointer/non-addressable values are immutable.

Also, some of our proto fields just shouldn't be nullable.

This PR addresses both issues.

@codecov-io
Copy link

codecov-io commented Dec 22, 2017

Codecov Report

Merging #166 into develop will not change coverage.
The diff coverage is 47.61%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #166   +/-   ##
========================================
  Coverage    10.68%   10.68%           
========================================
  Files           12       12           
  Lines         2172     2172           
========================================
  Hits           232      232           
  Misses        1924     1924           
  Partials        16       16
Impacted Files Coverage Δ
types/util.go 38.46% <ø> (ø) ⬆️
types/types.pb.go 5.02% <0%> (ø) ⬆️
example/dummy/helpers.go 100% <100%> (ø) ⬆️
example/dummy/dummy.go 66.66% <100%> (ø) ⬆️
example/dummy/persistent_dummy.go 63.1% <83.33%> (ø) ⬆️

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 e4b9f1a...a0e8a3a. Read the comment docs.

@melekes
Copy link
Contributor

melekes commented Dec 22, 2017

@ethanfrey
Copy link
Contributor

Jae, while you are looking at protobuf format (and I agree with these changes), can you check out #165 ? I think it would be nice to express all Responses like (DeliverTxResponse, error), with a litlte adjustment to protobuf, we can add a simple golang function to extract the values from a Response into a more golang-esce format, and make us all hate protobuf just a little bit less.

@jaekwon
Copy link
Contributor Author

jaekwon commented Dec 23, 2017

@ethanfrey Yeah of course, I will look at it in the next 10 hours.

@jaekwon
Copy link
Contributor Author

jaekwon commented Dec 23, 2017

@ethanfrey Done, I responded there!

@jaekwon jaekwon changed the base branch from develop to sdk2 December 23, 2017 03:40
@jaekwon jaekwon merged commit aaaacba into sdk2 Dec 23, 2017
@odeke-em
Copy link
Contributor

@jaekwon, here is a little counter. The problems with non-pointers are that:

  • now we can't tell if something was set or not
  • all data fields will be sent across the wire irrespective of if they are nil or not -- bandwidth wastage
  • Lots of data copying when we invoke methods and functions
  • the idea of being immutable might be a fallacy: for sure it provides security with args passed into when functions(however is this the common usage pattern?) vs normal usage(code in a common function where mutability will apply irrespective of if a pointer or not)
func fooWithPointer(b *Bar) {
   b.Time = time.Now()
}

// Security safe pattern, awesome
func fooWithoutPointer(b Bar) {
   b.Time = time.Now()
}

func zip(b Bar) {
   b.Time = time.Now()
   // do more stuff with b
   if b.Time.After(aLongTimeAgo) {
   }
   // Irrespective of if b was a pointer or not, we've mutated it
}

is zip the common usage pattern in our code?

@zramsay zramsay deleted the feature/nonnullable branch January 4, 2018 03:35
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