Conversation
tac0turtle
left a comment
There was a problem hiding this comment.
would love to get a review from @ValarDragon and possibly @robert-zaremba if they would look at using something similar in the sdk.
Thanks for the comments @marbar3778, definitely it needs more reviews and discussion, like which hash algorithm should be included and implemented in the ADR, the setup for the SDK and other projects. @fedekunze, is there anything you think we should draft more in the ADR? |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Echoing @marbar3778's comments above - would love reviews from @ValarDragon, @robert-zaremba, and @fedekunze on this one! |
|
In SDK: we were discussing alternative (to sha256) hashing algorithms in SDK in various contexts: fast state sync (snapshot), ADR-40 (SMT), ADR-28...
So the idea would be to have an app config option for providing a hasher. That hasher can be provided as a dependency to modules / keepers etc... I would rather avoid things like a global config (see GetConfig). Implementing it should be much easier once Dependency Injection is implemented (implementation is lead by Aaron with the app wiring working group). |
robert-zaremba
left a comment
There was a problem hiding this comment.
Cusomizing hasher is an interesting feature. Few things to clarify:
- probably we will need to have both SDK and tendermint to use the same hasher
- I don't think we need to create a new interface - the standard
hash.Hashinterface should be good enough. - Need to specify where the container is stored
docs/architecture/adr-070-hasher.md
Outdated
| 2. Initialize the `HasherContainer` in the node constructor. Might require passing the hasher to the reactors. | ||
| 3. Replace the hard-coded tmhash function call using `HasherContainer.GetHasher(SHA256)`. | ||
| 4. Mock custom hasher and test it. | ||
| 5. Add new objects into the genesis file, register `Hasher` base on settings, and implement the custom transaction hash. |
There was a problem hiding this comment.
So, you are proposing to have a global instance of HashContainer? In SDK we can use the Dependency Injection framework we are working on.
There was a problem hiding this comment.
Thanks for the suggestion. Let me go check again.
There was a problem hiding this comment.
Rewrote the proposal after checking the other projects and SDK, I think to put the Container into tmhash as a global instance, do init() in the package, and then provide the Set functions to allow SDK user to inject their hasher.
docs/architecture/adr-070-hasher.md
Outdated
| "hash": { | ||
| "types": "sha256", | ||
| "custom_tx_hash_enable": "true" | ||
| } |
There was a problem hiding this comment.
does it have to be a genesis param? It should be enough if it's an app param - the node will not sync if it's using different setting than the rest of the network.
There was a problem hiding this comment.
however, external tools will need to know the hashing algorithm as well (eg to monitor TX confirmation), so having it in the genesis makes it more accessible. WDYT?
There was a problem hiding this comment.
does it have to be a genesis param? It should be enough if it's an app param - the node will not sync if it's using different setting than the rest of the network.
Is it okay to put it into the app param? In my mind, it's a genesis-bound param.
however, external tools will need to know the hashing algorithm as well (eg to monitor TX confirmation), so having it in the genesis makes it more accessible. WDYT?
Didn't think about the tooling level. But I agree, if the monitor/explorers are able to utilize it, it might make the tooling easier to integrate with the TM projects?
There was a problem hiding this comment.
I don't think this should be a consensus parameter. This would imply that it could change on-chain which would imply we need to build logic to handle the case of the hasher changing. We can add it to the genesis file though and expose what hasher is used via the RPC and app's gRPC.
There was a problem hiding this comment.
would be good to introduce genesis params #6814
There was a problem hiding this comment.
BTW: by app param I meant an app option - not a x/param thing.
There was a problem hiding this comment.
@alexanderbez @marbar3778 I moved the hasher out of the consensus parameter, but still in the genesis.json. Any better place we can add the setting before the genesis params got implemented.
|
A small note from a stranger passing by. It might be worth considering using Multihashes for this case, as they are:
|
@Wondertan Will it be too corpulent to include it into Tendermint? @alexanderbez @marbar3778 |
There shouldn't be any difference in performance for any hash algorithm in use. For sha256 multihashes they use sha-simd and similar for other algos they aim to use the most performant implementation. The only overhead is prepended bytes to self-describe the hash type in use. |
cmwaters
left a comment
There was a problem hiding this comment.
So the way I see it, the chief aspect to be decided is where on the scale of hashing customization Tendermint wants to position itself. There are a few dimensions to this.
The first of which is does Tendermint offer a set of possible options for developers to choose from or allow any hasher algorithm. For me this depends on how widespread these hashing algorithms are. If 95% of projects use 3 types of hashers then I'd tend towards supporting those three only. If there's hundreds of different hashes and they all offer unique benefits then it's probably okay to allow injection of custom algorithms.
The second dimension looks at how many different components within Tendermint shall we allow for configurable hashes. Here it looks like a developer could have a different tx.Hash() to how evidence or the commit get's hashed. For me personally (at least in the short term), I think a single hasher should be used across all types that are public i.e. when a developer sets a hash it's the only one used for that network. If more demand for increasing hashing customisation comes in the future we can review it then.
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
docs/architecture/adr-070-hasher.md
Outdated
| ``` | ||
|
|
||
| ### Chain parameter settings | ||
| For the project built on top of Tendermint can use `Hashers.RegisterHasher` to change the main hasher it would like to use. For Tendermint itself, it requires a chain parameter to indicate which hasher should be used in the service when the beginning. Therefore, we need to add a `hasher` param into the `genesis.json`. |
There was a problem hiding this comment.
wdym chain parameter here. It is not, and should not become an "on-chain parameter", changeable on the fly like consensus params.
There was a problem hiding this comment.
i believe this was inline with #6814. As you said its meant to avoid on the fly changing stuff that shouldnt be
There was a problem hiding this comment.
I will rephrase it to genesis parameter. Sorry for the ambiguity.
Co-authored-by: Callum Waters <cmwaters19@gmail.com>
Co-authored-by: Callum Waters <cmwaters19@gmail.com>
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
what's the status of this ADR @marbar3778 @cmwaters? |
This was ice boxed as we felt it wasn't really a priority. Personally, I think that custom hashing should only be used for transactions which is the only place where I can see it being a concern for applications. We can bring up this topic at the next dev call. |
ref: #6539