Closed MirandaWood closed 4 years ago
MerkleTreeControllerSHAZVM
Pedantic one: please could we remove any references to specific projects (such as the ZVM)? Timber is generic, so perhaps something like 'MultipleMerkleTreesController' (or some similar, pithier name)?
As long as the single leaf event contains the term 'Leaf' and the multiple one contains 'Leaves' they can have any unique name
Is this strict naming requirement enforced somewhere in the code? I'd have thought the event names could be 'Cheese' and 'Cake' and Timber would happily listen for them and create a DB accordingly. I could be wrong.
For now, this test only works with SHA hashing (chosen for cheaper gas costs).
Is it just that we don't have a test for MiMC? Or does this new 'multiple trees' functionality only work for SHA256?
I've only read the description, so I'll take a look at the code and updated README now :)
MerkleTreeControllerSHAZVM
Pedantic one: please could we remove any references to specific projects (such as the ZVM)? Timber is generic, so perhaps something like 'MultipleMerkleTreesController' (or some similar, pithier name)?
Yes - I'll get on doing this now, they were just placeholders!
As long as the single leaf event contains the term 'Leaf' and the multiple one contains 'Leaves' they can have any unique name
Is this strict naming requirement enforced somewhere in the code? I'd have thought the event names could be 'Cheese' and 'Cake' and Timber would happily listen for them and create a DB accordingly. I could be wrong.
Originally the functions were hardcoded to look for 'NewLeaf' and 'NewLeaves', so I made them a bit more general. However we could have the first listed event to be single leaves and the second multiple leaves?
For now, this test only works with SHA hashing (chosen for cheaper gas costs).
Is it just that we don't have a test for MiMC? Or does this new 'multiple trees' functionality only work for SHA256?
Yes, it's just the test. It wouldn't be too much effort to make another contract like 'MultipleMerkleTreesMiMC' if that would be useful?
Yes, it's just the test. It wouldn't be too much effort to make another contract like 'MultipleMerkleTreesMiMC' if that would be useful?
No worries - a single test is fine, thanks for clarifying :)
:tada: This PR is included in version 3.0.0 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:
treeids
Adding functionality to allow multiple trees for one smart contract (for our ZVM/Midnight work). Timber will still work for contracts with one tree (e.g. Nightfall). For example:
MerkleTreeControllerSHAZVM
inmerkle-tree/config/default.js
has two trees, nameda
andb
with their own events to listen for and heights:These work alongside the usual
MerkleTreeController
contracts and event listeners.User
The user must specify treeid in the request body for a contract defined in the config as having more than one tree (otherwise Timber does not know which collection to point to). Everything else works as before.
Changes
Behind the scenes, the specific treeHeight is checked to match that of the config whenever a new db connection starts. The collection's name is set to
contractName_treeid
rather than just contract. Also, the specific event names are bound to the treeid when the filter is started. As long as the single leaf event contains the term 'Leaf' and the multiple one contains 'Leaves' they can have any unique name.A new test (
MerkleTreeControllerZVM.test.js
) and instructions have been added (which adds different leaves to two trees on the same contract), plus some new postman tests. For now, this test only works with SHA hashing (chosen for cheaper gas costs).