Skip to content

Commit c845358

Browse files
committed
Changed project name(from sparse tree to partial tree)
1 parent 7c61deb commit c845358

9 files changed

+49
-52
lines changed

.travis.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ deploy:
3636
on:
3737
condition: $NEXT != $CURRENT_VERSION
3838
tags: true
39-
repo: commitground/solidity-sparse-tree
39+
repo: commitground/solidity-partial-tree
4040
on:
4141
branch: develop
42-
repo: commitground/solidity-sparse-tree
42+
repo: commitground/solidity-partial-tree
4343
- provider: npm
4444
4545
api_key:
@@ -48,15 +48,15 @@ deploy:
4848
on:
4949
condition: $LATEST != $CURRENT_VERSION
5050
tags: true
51-
repo: commitground/solidity-sparse-tree
51+
repo: commitground/solidity-partial-tree
5252
on:
5353
branch: master
54-
repo: commitground/solidity-sparse-tree
54+
repo: commitground/solidity-partial-tree
5555

5656
- provider: releases
5757
api_key:
5858
secure: V5eGBJvkmXzwZ0op21QgUupDnRAmSVUpAX7mtuHn+vJqNlv+A5aYP+vpngxDktHj/yzqxI4zjFoifyhZPpKMfHNqg9XG6XY8wyoD2MmQdqULFa7jrIqW/HcdTBsSJYSWvC2K5/B0Agd9zII7mKkK2Qdk4IMB7mIZ2MXLhZOyik288YY+h3tNGDq+A7oOmj3/VyxKtLq6YRQLGvB7KdJw2UFhuC0WUOsUwX7dVytwphB1V4lC5c4hci9tyeqKP55bf5R5B5m4cGhBPSm647Baz41MO9JA01sjQSi84ho6k/tOmR3zbeFHNpMfZc4HZfP52VNKkClH0SGSqWQYjJeXwcs3xFG6TE+lDPcPAE7a6983LIYm2W97aaq1RiYSshbc3+6bYUjURxJNzjHVmDRI0OVqLc0sBVcvK4Z7lhp0T4sgGAdn2Up1RAmHySHSJq/It0C7BOzHAggpY5wDTzR0UZOtGajPF7bRmiAbeFHC6TCqBPq4Ao88+HoyRJzya0OrL+vmLUpdK7UXgCn2z/043oEjp+3GP7AllshZxeqmuzy/gsrjcERPtn8LvnffYO0dBA40e0AyuZbu+ArMU+xDKnLUITb8Ue7rXYEVs7crVHJVSYegXghCvVeD5WAjlOaKZ8kzKKI2u6r26FdIptUMSThBfjPQuqqZVXA+dxc22g0=
5959
on:
6060
tags: true
61-
repo: commitground/solidity-sparse-tree
61+
repo: commitground/solidity-partial-tree
6262
branch: master

README.md

+20-23
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# Solidity Sparse Tree
1+
# Solidity Partial Merkle Tree
22

33
## Credits
44

55
This implementation is based on [Christian Reitwießner](https://github.com/chriseth)'s [patricia-tree](https://github.com/chriseth/patricia-tree)
66

77

88
##### latest released version
9-
[![npm](https://img.shields.io/npm/v/solidity-sparse-tree/latest.svg)](https://www.npmjs.com/package/solidity-sparse-tree)
10-
[![Build Status](https://travis-ci.org/commitground/solidity-sparse-tree.svg?branch=master)](https://travis-ci.org/commitground/solidity-sparse-tree)
11-
[![Coverage Status](https://coveralls.io/repos/github/commitground/solidity-sparse-tree/badge.svg?branch=master)](https://coveralls.io/github/commitground/solidity-sparse-tree?branch=develop)
9+
[![npm](https://img.shields.io/npm/v/solidity-partial-tree/latest.svg)](https://www.npmjs.com/package/solidity-partial-tree)
10+
[![Build Status](https://travis-ci.org/commitground/solidity-partial-tree.svg?branch=master)](https://travis-ci.org/commitground/solidity-partial-tree)
11+
[![Coverage Status](https://coveralls.io/repos/github/commitground/solidity-partial-tree/badge.svg?branch=master)](https://coveralls.io/github/commitground/solidity-partial-tree?branch=develop)
1212

1313
##### in progress
14-
[![npm](https://img.shields.io/npm/v/solidity-sparse-tree/next.svg)](https://www.npmjs.com/package/solidity-sparse-tree)
15-
[![Build Status](https://travis-ci.org/commitground/solidity-sparse-tree.svg?branch=develop)](https://travis-ci.org/commitground/solidity-sparse-tree)
16-
[![Coverage Status](https://coveralls.io/repos/github/commitground/solidity-sparse-tree/badge.svg?branch=develop)](https://coveralls.io/github/commitground/solidity-sparse-tree?branch=develop)
14+
[![npm](https://img.shields.io/npm/v/solidity-partial-tree/next.svg)](https://www.npmjs.com/package/solidity-partial-tree)
15+
[![Build Status](https://travis-ci.org/commitground/solidity-partial-tree.svg?branch=develop)](https://travis-ci.org/commitground/solidity-partial-tree)
16+
[![Coverage Status](https://coveralls.io/repos/github/commitground/solidity-partial-tree/badge.svg?branch=develop)](https://coveralls.io/github/commitground/solidity-partial-tree?branch=develop)
1717

1818
[![JavaScript Style Guide](https://cdn.rawgit.com/standard/standard/master/badge.svg)](https://github.com/standard/standard)
1919

@@ -22,27 +22,27 @@ This implementation is based on [Christian Reitwießner](https://github.com/chri
2222
## Usage
2323

2424
```bash
25-
npm i solidity-sparse-tree
25+
npm i solidity-partial-tree
2626
npm i solidity-patricia-tree
2727
```
2828

2929
```solidity
3030
pragma solidity ^0.4.24;
3131
32-
import {SparseTree} from "solidity-sparse-tree/contracts/tree.sol";
3332
import {PatriciaTree} from "solidity-patricia-tree/contracts/tree.sol";
33+
import {PartialMerkleTree} from "solidity-partial-tree/contracts/tree.sol";
3434
35-
contract TestSparseTree {
36-
using SparseTree for SparseTree.Tree;
35+
contract TestPartialMerkleTree {
36+
using PartialMerkleTree for PartialMerkleTree.Tree;
3737
using PatriciaTree for PatriciaTree.Tree;
3838
3939
PatriciaTree.Tree patriciaTree;
40-
SparseTree.Tree sparseTree;
40+
PartialMerkleTree.Tree partialTree;
4141
4242
/**
4343
* @dev we can reenact merkle tree transformation by submitting only referred siblings instead of submitting all nodes
4444
*/
45-
function testSparseTree() public {
45+
function testOnChainProof() public {
4646
// update merkle root
4747
patriciaTree.insert("key1", "val1");
4848
patriciaTree.insert("key2", "val2");
@@ -56,23 +56,23 @@ contract TestSparseTree {
5656
bytes32[] memory siblings;
5757
(branchMask, siblings) = patriciaTree.getProof("key1");
5858
59-
// Init sparse tree with the root hash
60-
sparseTree.initialize(phaseAOfPatriciaTree);
59+
// Init partial tree with the root hash
60+
partialTree.initialize(phaseAOfPatriciaTree);
6161
// commit branch (we submit sibling data here)
62-
sparseTree.commitBranch("key1", "val1", branchMask, siblings);
62+
partialTree.commitBranch("key1", "val1", branchMask, siblings);
6363
6464
// Update key1 of patricia tree
6565
patriciaTree.insert("key1", "val4");
6666
67-
// Update key1 of sparse tree
68-
sparseTree.insert("key1", "val4");
67+
// Update key1 of partial tree
68+
partialTree.insert("key1", "val4");
6969
7070
// get updated root hashes of each tree
7171
bytes32 phaseBOfPatriciaTree = patriciaTree.getRootHash();
72-
bytes32 phaseBOfSparseTree = sparseTree.getRootHash();
72+
bytes32 phaseBOfPartialTree = partialTree.getRootHash();
7373
7474
// We have succeeded to reenact merkle tree transformation without submitting all node data
75-
require(phaseBOfPatriciaTree == phaseBOfSparseTree);
75+
require(phaseBOfPatriciaTree == phaseBOfPartialTree);
7676
}
7777
}
7878
```
@@ -90,9 +90,6 @@ npm install
9090

9191
### Tests
9292

93-
Test cases include the information about how the functions work, but also includes a demo scenario.
94-
Running and reading the test cases will help you understand how it works.
95-
9693
```bash
9794
npm run test
9895
```

contracts/data.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ library D {
1212
}
1313

1414
struct Edge {
15-
bytes32 header; // variable for sparse tree <[email protected]>
15+
bytes32 header; // variable for partial merkle tree <[email protected]>
1616
bytes32 node;
1717
Label label;
1818
}

contracts/implementation.sol

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
pragma solidity ^0.4.24;
22

3-
import {SparseTree} from "./tree.sol";
3+
import {PartialMerkleTree} from "./tree.sol";
44

5-
contract SparseTreeImplementation {
6-
using SparseTree for SparseTree.Tree;
7-
SparseTree.Tree tree;
5+
contract PartialMerkleTreeImplementation {
6+
using PartialMerkleTree for PartialMerkleTree.Tree;
7+
PartialMerkleTree.Tree tree;
88

99
constructor () public {
1010
}
@@ -37,6 +37,6 @@ contract SparseTreeImplementation {
3737
}
3838

3939
function verifyProof(bytes32 rootHash, bytes key, bytes value, uint branchMask, bytes32[] siblings) public pure {
40-
SparseTree.verifyProof(rootHash, key, value, branchMask, siblings);
40+
PartialMerkleTree.verifyProof(rootHash, key, value, branchMask, siblings);
4141
}
4242
}

contracts/tree.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {D} from "./data.sol";
88
Based on patricia-trie implementation of chriseth
99
*/
1010

11-
library SparseTree {
11+
library PartialMerkleTree {
1212
using D for D.Edge;
1313

1414
struct Tree {

migrations/2_deploy_contracts.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const Tree = artifacts.require('SparseTree')
2-
const Implementation = artifacts.require('SparseTreeImplementation')
1+
const Tree = artifacts.require('PartialMerkleTree')
2+
const Implementation = artifacts.require('PartialMerkleTreeImplementation')
33

44
module.exports = function (deployer) {
55
deployer.deploy(Tree).then(() => {

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "solidity-sparse-tree",
2+
"name": "solidity-partial-tree",
33
"version": "1.0.0",
4-
"description": "Sparse Tree solidity implemenation",
4+
"description": "Solidity implementation of partial merkle tree",
55
"directories": {
66
"test": "test"
77
},
@@ -24,19 +24,19 @@
2424
},
2525
"repository": {
2626
"type": "git",
27-
"url": "git+https://github.com/commitground/solidity-sparse-tree.git"
27+
"url": "git+https://github.com/commitground/solidity-partial-tree.git"
2828
},
2929
"keywords": [
3030
"Solidity",
31-
"Sparse",
31+
"Partial",
3232
"Patricia",
3333
"Merkle",
3434
"Tree"
3535
],
3636
"author": "Wanseob Lim<[email protected]>",
3737
"license": "MIT",
3838
"bugs": {
39-
"url": "https://github.com/commitground/solidity-sparse-tree/issues"
39+
"url": "https://github.com/commitground/solidity-partial-tree/issues"
4040
},
41-
"homepage": "https://github.com/commitground/solidity-sparse-tree#readme"
41+
"homepage": "https://github.com/commitground/solidity-partial-tree#readme"
4242
}

test/SparseTree.Test.js renamed to test/PartialMerkleTree.Test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ const assert = chai.assert
33
const BigNumber = web3.BigNumber
44
const should = chai.use(require('chai-bignumber')(BigNumber)).should()
55

6-
const SparseTreeImplementation = artifacts.require('SparseTreeImplementation')
6+
const PartialMerkleTreeImplementation = artifacts.require('PartialMerkleTreeImplementation')
77
const { toNodeObject, progress } = require('./utils')
88

99
const ZERO = '0x0000000000000000000000000000000000000000000000000000000000000000'
1010

11-
contract('SparseTree', async ([_, primary, nonPrimary]) => {
12-
context('SparseTree is also a kind of patricia merkle tree', async () => {
11+
contract('PartialMerkleTree', async ([_, primary, nonPrimary]) => {
12+
context('PartialMerkleTree is also a kind of patricia merkle tree', async () => {
1313
let tree
14-
beforeEach('deploy SparseTree', async () => {
15-
tree = await SparseTreeImplementation.new({ from: primary })
14+
beforeEach('deploy PartialMerkleTree', async () => {
15+
tree = await PartialMerkleTreeImplementation.new({ from: primary })
1616
})
1717
describe('insert()', async () => {
1818
it('should not use gas more than 1 million', async () => {
@@ -84,7 +84,7 @@ contract('SparseTree', async ([_, primary, nonPrimary]) => {
8484
let rootHashOfFirstTree = await tree.getRootHash()
8585

8686
// deploy a second tree
87-
let secondTree = await SparseTreeImplementation.new({ from: primary })
87+
let secondTree = await PartialMerkleTreeImplementation.new({ from: primary })
8888
// insert same items into the second tree
8989
for (const key of Object.keys(items)) {
9090
await progress.log(`Insert items into the second tree (${key}, ${items[key]})`, 500)
@@ -152,8 +152,8 @@ contract('SparseTree', async ([_, primary, nonPrimary]) => {
152152
let siblingsForKey1
153153
let referredValueForKey1
154154
before(async () => {
155-
treeA = await SparseTreeImplementation.new()
156-
treeB = await SparseTreeImplementation.new()
155+
treeA = await PartialMerkleTreeImplementation.new()
156+
treeB = await PartialMerkleTreeImplementation.new()
157157

158158
await treeA.insert('key1', 'val1')
159159
await treeA.insert('key2', 'val2')

0 commit comments

Comments
 (0)