mimblewimble / grin

Minimal implementation of the Mimblewimble protocol.
https://grin.mw/
Apache License 2.0
5.04k stars 991 forks source link

[TUI] block hashes in TUI will need to be larger than first 8 chars for mainnet #2314

Closed antiochp closed 5 years ago

antiochp commented 5 years ago

John Tromp @tromp 15:30 btw, the TUI only shows 8 hex digits of hash

jaspervdm @jaspervdm 15:31 or 5 even

John Tromp @tromp 15:31 that won't cut it on mainnet, where most will be 0

antiochp commented 5 years ago

Commented on #2325 but commenting here as well -

We should scope this beyond the tui to include everywhere we display a block hash - api, logs etc. i.e. We should probably modify the default formatter for Hash.

Having a big bunch of 0s prefixing a block hash is a real pain for display purposes...


Random thought (ignoring the fact we are 6 days from mainnet) -

If a block hash is effectively -

Would it be possible to reference blocks via -

Is there any reason this wouldn't work or would make things significantly more complex?

tromp commented 5 years ago

there's no need to hash twice. the options are either to show

1) around 10 to 13 hex digits, of which the first 5 would normally be 0, leaving 5 to 8 useful ones. 2) the show the last 8 hex digits

antiochp commented 5 years ago

Is there an option 3 here as well - just strip off the 0 prefix and show the first 8 useful digits?

antiochp commented 5 years ago

If we implement whatever logic we go with here -

https://github.com/mimblewimble/grin/blob/5915580ab372dd85c0cc615d9df1c9aa6329f0f0/core/src/core/hash.rs#L39-L52

Then we should be able to simply print block.hash() directly everywhere and have it do the right thing.

tromp commented 5 years ago

Stripping off all leading zeroes is an option, but feels like a hack to me. My preference is for option 1 with 12 hex digits, i.e. the first 48 bits of hash. The 5 leading 0s is like a sanity check that you're dealing with a blockhash.

eupn commented 5 years ago

@tromp how about this? Show twice as less starting zeroes and some digits from the end.

antiochp commented 5 years ago

OK I vote for what @tromp suggested as option 1 - keep it really simple and show the first 12 digits.

I like the idea of the sanity check. I also prefer seeing the first digits (vs. the last digits) as its easier to compare visually against full block hashes displayed elsewhere, like block explorers in the browser etc.

tromp commented 5 years ago

@eupn that is more than 12 chars in total and harder to cut and paste, as double-clicking will not select across the dots.