Skip to content

Conversation

@onacitarhan17
Copy link
Contributor

No description provided.

@onacitarhan17 onacitarhan17 requested a review from thep2p as a code owner April 17, 2022 18:52
* @param n number of elements to create
* @return a new skip list with n random elements
*/
public static MerkleTree createSkipList(int n) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like there are still residues of SkipList in this PR, please check and fix.

Copy link
Contributor Author

@onacitarhan17 onacitarhan17 Apr 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 29bb463

/**
* Encapsulates tests for an authenticated and concurrent implementation of SkipList ADS.
*/
public class MerkleTreeTest {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment for each test briefly explaining what it evaluates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in df3b433

Comment on lines 65 to 67
if (e == null) {
return null;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid input must trigger an IllegalArgumentException, the get should explicitly list the exceptions it throws, and those exceptions must be bubbled up to the caller, literally safely fail the main. Also, please add a test covering this test case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 94cfe9b

}
if (proof == null) {
return null;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a happy path, do we expect to have a null proof? if we don't, then this line steps into an illegal state, and hence must throw an IllegalStateException. (Also, please add test covering this test case).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 205970f

}

private Proof getProof(Identifier id) {
Integer idx = leafNodesHashTable.get(hasher.computeHash(id));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ids are unique, i.e., they correspond to the hash of entities they keep, hence, there is no need to hash them again, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in d3b1343

Comment on lines 41 to 43
if (e == null) {
lock.writeLock().unlock();
return null;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it an IllegalArgumentException case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 94cfe9b

}

@Override
public AuthenticatedEntity put(Entity e) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A general comment about this and some subsequent methods, where unlocking the lock is happening on several disjoint execution paths. It makes the implementation daunting to keep track of lock-unlock state transitions and makes it bug-prone regarding the liveness issues. Hence, please use try-finally blocks to lock and unlock only once.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in ccffc17

AuthenticatedEntity put(Entity e);

AuthenticatedEntity get(Identifier id);
AuthenticatedEntity get(Entity e);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong! get is utilized only when we have the id of the entity and not the entity itself. Please abide to the original interface.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in cc555b4

* @return SHA3-256 hash object of the commutative concatenation (i.e. max(b1,b2) || min(b1,b2))
* of the two byte arrays.
*/
public Sha3256Hash computeHash(byte[] b1, byte[] b2) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not always h(b1||b2)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in d0f93ab

Entity entity = new EntityFixture();
try {
merkleTree.put(entity);
AuthenticatedEntity authenticatedEntity = merkleTree.get(entity);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get should be done in a separate for loop (sequentially), once all put threads are done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 8cdb9a2

@thep2p thep2p merged commit f83b947 into master Apr 24, 2022
@thep2p thep2p deleted the ozan/merkletree branch April 24, 2022 08:14
akucukoduk16 pushed a commit that referenced this pull request Apr 25, 2022
* implements merkle tree implementation and insertion to it

* implements merkle tree authentication

* implements tests

* implements hash table for searching in merkle tree

* implements thread safety to merkle tree implementation

* fixes lint & spotbugs issues

* renames Merkle Tree creation function in MerkleTreeFixture.java

* suppresses EI_EXPOSE_REP warnings in spotbugs

* suppresses warnings in spotbugs

* adds comments for unit tests

* handles exceptions on MerkleTree.java

* changes how id of an entity is stored on the merkle tree, changed from hash(id) to id

* handles exceptions better for locks

* changes get method in a way it gets the AuthenticatedEntity by id not Entity

* improves thread safety check

* improves exception handling1

* improves the hashing and how proofs are created in merkle tree

* applies revisions

* applies revisions

* applies revisions

* applies revisions

* fixes lint

* removes unnecessary setters

* removes unnecessary setters

* fixes a java doc

* applies revisions

* fixes lint

* applies revisions

Co-authored-by: Yahya <yhassanzadeh13@ku.edu.tr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants