Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Modifications for better cross-project use of HashDB/Patricia Trie #7019

Closed
rphmeier opened this issue Nov 10, 2017 · 4 comments
Closed

Modifications for better cross-project use of HashDB/Patricia Trie #7019

rphmeier opened this issue Nov 10, 2017 · 4 comments
Assignees
Labels
F6-refactor 📚 Code needs refactoring. M4-core ⛓ Core client code / Rust. P5-sometimesoon 🌲 Issue is worth doing soon.

Comments

@rphmeier
Copy link
Contributor

rphmeier commented Nov 10, 2017

cc @debris

HashDB interface currently uses local primitive types, while with the primitives crate approach local types can be used. Also the assumption on keccak is not likely to remain strong.

A modification of the interface from

trait HashDB {
    fn insert(&mut self, value: Vec<u8>) -> H256; 

    ....
}
trait HashFunction {
    type Out: Debug + PartialEq + Eq + Clone + Copy + Hash + Send + Sync;

    fn hash(x: &[u8]) -> Self::Out;
}

trait HashDB<F: HashFunction> {
    fn insert(&mut self, value: Vec<u8>) -> F::Out;

    ....
}

would be a definite improvement and lead to the crate carrying around fewer dependencies.


One problem is the special-casing of many known hashes like NULL_RLP, RLP_EMPTY, etc. in the patricia trie or in memory db. How can we handle the special cases correctly without re-hashing or doing extra work on each hash?

@rphmeier rphmeier added F6-refactor 📚 Code needs refactoring. M4-core ⛓ Core client code / Rust. labels Nov 10, 2017
@rphmeier
Copy link
Contributor Author

Trait aliases makes this even better, but a local trait KeccakDB: HashDB<Keccak256> {} with a blanket impl would be fine too.

@5chdn 5chdn modified the milestones: 1.10, 1.9 Nov 13, 2017
@5chdn 5chdn added the P5-sometimesoon 🌲 Issue is worth doing soon. label Nov 13, 2017
@5chdn 5chdn modified the milestones: 1.9, 1.10 Jan 5, 2018
@5chdn 5chdn modified the milestones: 1.10, 1.11 Jan 23, 2018
@5chdn 5chdn modified the milestones: 1.11, 1.12 Mar 1, 2018
@5chdn 5chdn modified the milestones: 1.12, 1.13 Apr 24, 2018
@folsen
Copy link
Contributor

folsen commented May 20, 2018

@dvdplm is this related to what you're working on?

@rphmeier
Copy link
Contributor Author

I think this is a part of it yeah. I forgot I filed this one!

@dvdplm dvdplm self-assigned this May 21, 2018
@5chdn 5chdn modified the milestones: 2.1, 2.2 Jul 17, 2018
@5chdn 5chdn added this to the 2.2 milestone Sep 27, 2018
@5chdn 5chdn removed this from the 2.2 milestone Oct 29, 2018
@5chdn 5chdn added this to the 2.3 milestone Oct 29, 2018
@5chdn 5chdn modified the milestones: 2.3, 2.4 Jan 10, 2019
@5chdn 5chdn modified the milestones: 2.4, 2.5 Feb 21, 2019
@soc1c soc1c modified the milestones: 2.5, 2.6 Apr 2, 2019
@ordian ordian modified the milestones: 2.6, 2.7 Jul 12, 2019
@adria0
Copy link

adria0 commented Jul 27, 2020

Closing the issue due to its stale state

@adria0 adria0 closed this as completed Jul 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
F6-refactor 📚 Code needs refactoring. M4-core ⛓ Core client code / Rust. P5-sometimesoon 🌲 Issue is worth doing soon.
Projects
None yet
Development

No branches or pull requests

7 participants