Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiple deposits #126

Merged
merged 10 commits into from
Feb 2, 2021
Merged

Fix multiple deposits #126

merged 10 commits into from
Feb 2, 2021

Conversation

vaibhavchellani
Copy link
Contributor

No description provided.

Copy link
Collaborator

@ChihChengLiang ChihChengLiang left a comment

Choose a reason for hiding this comment

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

Awesome work on fixing the encodePacked issue!
This is the first pass of the review. Might take a second round again.

err = DBI.InitAccountTree(int(accountTreeDepth.Uint64()))
err = DBI.InitAccountTree(int(accountTreeDepth.Uint64()) + 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice catch here! The DEPTH in the accountTree contract is misleading, created an issue to fix it later https://github.com/thehubbleproject/hubble-contracts/issues/457😓 .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one lead to finding another big issue, so no harm no foul.

)

// Aggregator is the service which is supposed to create batches
// It has the following tasks:
// 1. Pick txs from the mempool
// 1. Pick txs from the mempoolinaccurate number of transactione
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this accidentally committed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, will change

Comment on lines +210 to +212
func encodePacked(input ...[]byte) []byte {
return bytes.Join(input, nil)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great work solving this!

@@ -17,7 +17,7 @@ func init() {
panic(err)
}

DefaultHashes, err = GenDefaultHashes(100)
DefaultHashes, err = GenDefaultHashes(100, ZeroLeaf)
Copy link
Collaborator

Choose a reason for hiding this comment

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

No change is required here. Just want to point out that we call the zero/empty leaf differently between the contract and the client.
thehubbleproject/hubble-contracts#376 (comment)

Copy link
Collaborator

@ChihChengLiang ChihChengLiang left a comment

Choose a reason for hiding this comment

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

LGTM. The comment on merkle tree might deserve its own issue and PR to resolve.

Comment on lines +39 to +41
if len(leaves)%2 != 0 {
leaves = append(leaves, ZeroLeaf)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here we handled the odd number of leaves only in the bottom level. But the odd number of nodes should be handled at every level.

For example, say we have 9 leaves to merklise. This makes a 4 level tree (not counting the root).

  1. We add defaultHash[0] in level 0 leaves. After the ascend, level 1 has 5 nodes
  2. We add defaultHash[1] in level 1 nodes to make them 6 nodes. After the ascend, level 2 has 3 nodes.
  3. We add defaultHash[2] in level 2 nodes to make them 4 nodes. After the ascend, level 3 has 2 nodes.

I suggest this logic is better handled in the ascend method.

Comment on lines +169 to +171
if len(txs) < int(a.cfg.TxsPerCommitment) {
return commitments, ErrNotEnoughTransactions
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does a transaction take a long time to be submitted on chain if the commitment is unfilled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not really, it just might be non economical to submit unfilled commitments on-chain for a coordinator, so we allow him to configure that tightly.

@vaibhavchellani vaibhavchellani merged commit ea9af25 into master Feb 2, 2021
@vaibhavchellani vaibhavchellani deleted the fix-multiple-deposits branch February 2, 2021 08:54
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.

2 participants