-
Notifications
You must be signed in to change notification settings - Fork 379
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
Move a constant down the call stack. #2493
Conversation
I don't think that this support should have been removed. It has nothing to do with the signature stuff you were working on. |
It's already all gone from the API, and is currently hardcoded, just at a higher level: trillian/log/sequencer_manager.go Line 57 in 41c0759
|
I know. I didn't get to review that PR so didn't get a chance to raise an issue about it. |
This was really more of a continuation of the removal of the map code (all the other hashing schemes still there were map-specific, so had been removed already), and removing unused RPCs and fields in RPC request/response protobufs (once there was just one hashing scheme, nothing set this field anymore). |
Are we good with this? This is a very mechanical change, it should be easy to validate that it has no effect other than reducing complexity. |
I have a mixed feeling about this PR.
Hard-coding the RFC hasher seems a bit too much to me, I would keep it slightly more abstract. It's sometimes convenient for testing to provide a custom "human-readable" hasher, e.g. we have something like this internally: // nodeHash returns a test "hash" for the given tree node. It looks like
// treeID:[begin,end) where [begin,end) is the leaves range under this node.
func nodeHash(treeID int64, id compact.NodeID) []byte {
begin, end := id.Index<<id.Level, (id.Index+1)<<id.Level
return []byte(fmt.Sprintf("%d:[%d,%d)", treeID, begin, end))
}
// glueChildren is a test "hash" that simply concatenates parts of two child
// hashes in such a way that the result corresponds to the string that nodeHash
// function would generate for their parent node.
func glueChildren(left, right []byte) []byte {
l := bytes.IndexByte(left, ',')
r := bytes.IndexByte(right, ',')
return append(append([]byte{}, left[:l]...), right[r:]...)
} We don't use it here, but I can easily see how it could be used (instead / in addition to "golden" tests with long unreadable hashes). |
This commit message was initially poorly formulated, and has been updated. This does not reduce the usage of the The I agree that the particular aspect of dealing with empty trees should probably not be handled by Trillian, but this is a much bigger change, which I am not currently proposing, and should probably not happen with Trillian in its current form (of an out-of-process RPC server), but incorporated into the "next generation" (which is more likely to be packaged as an in-process library). But all of this is far beyond the scope of this PR, which merely applies constant folding in order to reduce the complexity and the cognitive load for people reading this code. I would gladly review PRs to move towards what you are proposing, though! |
Good point, Pavel, on potential improvements and the custom hasher for testing. |
Part of #2378 and #2245.
Checklist