public view merkleProofData(bytes memory bytes, bytes32[] path) returns (bool) : Prove that some CBOR data is in the merkle tree. Use keccak256(bytes memory) to compute the leaf node’s hash and then recursively hash keccak(a+b) of sibling nodes to get the root hash. Return true if this is indeed the stored merkleRoot.
Write
public updateMerkleDB(bytes32 _merkleRoot, bytes32 _merkleTreeIPFS, bytes32 _databaseIPFS) onlyOwner : Update the MerkleDB data. Limited privileged access to contract owner. Emits a DatabaseUpdate event. Updated data comes from the following sources
Description
Create
IMerkleDB
interface and the implementation contractMerkleDB
.Smart Contract
From Notion
State
bytes32 merkleRoot
: Root of the merkle tree. Used to generate proofs that certain rows are present in the database.bytes32 merkleTreeIPFS
: IPFS Hash pointing to Merkle Tree used to generate proofsbytes32 databaseIPFS
: IPFS Hash pointing to OrbitDB document store for a more indexable table formatted version of the data.Events
DatabaseUpdate(bytes32 merkleRoot, bytes32 merkleTreeIPFS, bytes32 databaseIPFS)
: Event emitted whenever MerkleDB smart contract is updated.Interface
Read
public view merkleProofData(bytes memory bytes, bytes32[] path) returns (bool)
: Prove that some CBOR data is in the merkle tree. Usekeccak256(bytes memory)
to compute the leaf node’s hash and then recursively hashkeccak(a+b)
of sibling nodes to get the root hash. Returntrue
if this is indeed the storedmerkleRoot
.Write
public updateMerkleDB(bytes32 _merkleRoot, bytes32 _merkleTreeIPFS, bytes32 _databaseIPFS) onlyOwner
: Update the MerkleDB data. Limited privileged access to contract owner. Emits aDatabaseUpdate
event. Updated data comes from the following sourcesmerkleRoot
:db.rootHash()
merkleTreeIPFS
: Computed CID ofstate.db
file data https://github.com/nomic-io/node-merk#usage after https://github.com/nomic-io/node-merk#dbflushsyncdatabaseIPFS
: Mostly static according to https://github.com/orbitdb/orbit-db/blob/main/GUIDE.md#manifest, can be updated if the OrbitDB is reset (eg. changed access control)Links
https://docs.openzeppelin.com/contracts/4.x/api/utils#MerkleProof