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

save confirmations sigs into app state #102

Merged
merged 48 commits into from
Dec 20, 2018
Merged
Changes from 11 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
5c9d180
starter
hamdiallam Nov 21, 2018
66de47a
testing client with ganache
hamdiallam Nov 23, 2018
48b5e14
Merge commit '1ed2e4f899f687cd0cbc28af87060fa012c4df6b' as 'contracts'
hamdiallam Nov 23, 2018
1ed2e4f
Squashed 'contracts/' content from commit ab4fd0e
hamdiallam Nov 23, 2018
5ae1fc7
contract wrappers and bindings
hamdiallam Nov 24, 2018
afa2634
subscribed to deposits/exists. Some tests
hamdiallam Nov 27, 2018
3ef8f74
added wrappers to the contracts folder
hamdiallam Nov 27, 2018
472844f
started hooking connection to app
colin-axner Dec 3, 2018
528103f
merged develop
hamdiallam Dec 3, 2018
5e12c15
Merge commit '247171637576da849a5a80ad369c91cb8d0e3a05' into rpc
hamdiallam Dec 3, 2018
2471716
Squashed 'contracts/' changes from ab4fd0e..dc28e6a
hamdiallam Dec 3, 2018
ab70ed4
MOAR PROGRESS
AdityaSripal Dec 3, 2018
c7ca091
papusa
colin-axner Dec 3, 2018
a052fd2
gopkg fix
colin-axner Dec 3, 2018
eac6e49
added clean to npm script. temp removed wrappers
hamdiallam Dec 7, 2018
582b8dc
Merge commit '6663c6816e04c161100c39f5d0e0957d36a3535b' into rpc
hamdiallam Dec 7, 2018
6663c68
Squashed 'contracts/' changes from dc28e6a..4fcc49e
hamdiallam Dec 7, 2018
c01227f
updated wrappers
hamdiallam Dec 7, 2018
7563251
updated config for block finality and eth priv key default directory
colin-axner Dec 9, 2018
8cba3b0
Squashed 'contracts/' changes from 4fcc49e..1b58d54
hamdiallam Dec 9, 2018
684b70f
Merge commit '8cba3b021c450320fbb5e5a05199467e54c70a8e' into rpc
hamdiallam Dec 9, 2018
0069dc9
deposits with finality checks
hamdiallam Dec 9, 2018
5ef281d
merge conflicts
AdityaSripal Dec 9, 2018
989e8b0
merge conflicts
AdityaSripal Dec 9, 2018
32fe39c
removed err from HasTxBeenExited
hamdiallam Dec 10, 2018
f8ea391
Merge branch 'colin/connection' of https://github.com/FourthState/pla…
AdityaSripal Dec 10, 2018
55bf4b8
refactors and added tests. Fixed deposit encoding/decoding
hamdiallam Dec 10, 2018
65c58b7
typo
hamdiallam Dec 10, 2018
3058d6b
debugging
AdityaSripal Dec 10, 2018
8678388
merge conflicts
AdityaSripal Dec 10, 2018
829b64a
changed rlp to json
hamdiallam Dec 11, 2018
e16bfbd
save progress
AdityaSripal Dec 11, 2018
975356c
fix bugs and remove print statements
AdityaSripal Dec 12, 2018
4e74968
save confirmations sigs into app state
colin-axner Dec 16, 2018
75ca7a0
added check for fee amount
colin-axner Dec 16, 2018
06f77e4
added confirmation signatures to prove command
colin-axner Dec 17, 2018
2d678b0
ante
colin-axner Dec 18, 2018
04d689c
adjusted names, load latest version
colin-axner Dec 18, 2018
9b559d2
remove prints
colin-axner Dec 18, 2018
195fc58
rebase
colin-axner Dec 20, 2018
b45694a
merge conflicts
colin-axner Dec 20, 2018
c4fb64d
merge conflicts for contracts
colin-axner Dec 20, 2018
62b6f0c
more merge conflicts
colin-axner Dec 20, 2018
95fd9f1
conflict
colin-axner Dec 20, 2018
9fd028c
undo merges that didnt delete
colin-axner Dec 20, 2018
dddede6
last of conflicts
colin-axner Dec 20, 2018
ae8b174
fixed build and test issues
colin-axner Dec 20, 2018
238b602
refactored app tests, works around genesis deposit issue
colin-axner Dec 20, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/.travis.yml
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@ before_script:
- npm install -g [email protected] [email protected]
- npm install

script:
- ganache-cli -m=plasma_mvp > /dev/null &
script:
- ganache-cli -m "they only media any modify banner suffer pole tag rule creek harvest" > /dev/null &
- sleep 5
- truffle migrate
- truffle test
4 changes: 2 additions & 2 deletions contracts/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

Thank you for considering making contributions to Fourth State's Plasma MVP implementation! We welcome contributions from anyone! See the [open issues](https://github.com/FourthState/plasma-mvp-rootchain/issues) for things we need help with!

Contribute to design discussions and conversation by joining the #plasma-dev channel on Blockchain @ Berkeley's [public slack](https://www.berkeleyblockchain.slack.com/).
Contribute to design discussions and conversation by joining our [Discord Server](https://discord.gg/YTB5A4P).

## How to get started:

@@ -17,7 +17,7 @@ Otherwise:
Install dependencies with:
``npm install``

**Note**: requires Solidity 0.4.24 and Truffle 4.1.13
**Note**: requires Solidity 0.4.24 and Truffle 4.1.14

Make sure the tests pass:
1. Start ganache-cli: ``ganache-cli -m=plasma_mvp``
8 changes: 4 additions & 4 deletions contracts/README.md
Original file line number Diff line number Diff line change
@@ -15,12 +15,12 @@ The root contract of a Plasma child chain represents an intermediary who can res
A transaction is encoded in the following form:

```
[
[Blknum1, TxIndex1, Oindex1, DepositNonce1, Amount1, ConfirmSig1,
[
[Blknum1, TxIndex1, Oindex1, DepositNonce1, Owner1, Input1ConfirmSig,

Blknum2, TxIndex2, Oindex2, DepositNonce2, Amount2, ConfirmSig2,
Blknum2, TxIndex2, Oindex2, DepositNonce2, Owner2, Input2ConfirmSig,

NewOwner, Denom1, NewOwner, Denom2, Fee],
NewOwner, Denom1, NewOwner, Denom2, Fee],

[Signature1, Signature2]
]
60 changes: 47 additions & 13 deletions contracts/contracts/libraries/Validator.sol
Original file line number Diff line number Diff line change
@@ -8,30 +8,64 @@ library Validator {
// @param leaf a leaf of the tree
// @param index position of this leaf in the tree that is zero indexed
// @param rootHash block header of the merkle tree
// @param proof sequence of hashes from the leaf to check against the root
function checkMembership(bytes32 leaf, uint256 index, bytes32 rootHash, bytes proof)
// @param proof sequence of 32-byte hashes from the leaf up to, but excluding, the root
function checkMembership(bytes32 leaf, uint256 index, bytes32 rootHash, bytes proof, uint256 total)
internal
pure
returns (bool)
{
// depth 16 merkle tree
require(proof.length == 512, "Incorrect proof length");
// variable size Merkle tree, but proof must consist of 32-byte hashes
require(proof.length % 32 == 0, "Incorrect proof length");

bytes32 computedHash = computeHashFromAunts(index, total, leaf, proof);
return computedHash == rootHash;
}

// from https://tendermint.com/docs/spec/blockchain/encoding.html#merkle-trees
function computeHashFromAunts(uint256 index, uint256 total, bytes32 leaf, bytes innerHashes)
internal
pure
returns (bytes32)
{
require(index < total, "Index must be less than total number of leaf nodes");
require(total > 0, "Must have at least one leaf node");

if (total == 1) {
require(innerHashes.length == 0, "Simple Tree with 1 txn should have no innerHashes");
return leaf;
}
require(innerHashes.length != 0, "Simple Tree with > 1 txn should have innerHashes");

uint256 numLeft = (total + 1) / 2;
bytes32 proofElement;
bytes32 computedHash = leaf;

for (uint256 i = 32; i <= 512; i += 32) {
// prepend 0x20 byte literal to hashes
// tendermint prefixes intermediate hashes with 0x20 bytes literals
// before hashing them.
bytes memory b = new bytes(1);
assembly {
let memPtr := add(b, 0x20)
mstore8(memPtr, 0x20)
}

if (index < numLeft) {
bytes32 leftHash = computeHashFromAunts(index, numLeft, leaf, slice(innerHashes, 0, innerHashes.length - 32));
uint innerHashesMemOffset = innerHashes.length - 32;
assembly {
proofElement := mload(add(proof, i))
// get the last 32-byte hash from innerHashes array
proofElement := mload(add(add(innerHashes, 0x20), innerHashesMemOffset))
}
if (index % 2 == 0) {
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));

return sha256(abi.encodePacked(b, leftHash, b, proofElement));
} else {
bytes32 rightHash = computeHashFromAunts(index-numLeft, total-numLeft, leaf, slice(innerHashes, 0, innerHashes.length - 32));
innerHashesMemOffset = innerHashes.length - 32;
assembly {
// get the last 32-byte hash from innerHashes array
proofElement := mload(add(add(innerHashes, 0x20), innerHashesMemOffset))
}
index = index / 2;
return sha256(abi.encodePacked(b, proofElement, b, rightHash));
}
return computedHash == rootHash;
}

// @param txHash transaction hash
4 changes: 2 additions & 2 deletions contracts/contracts/libraries/Validator_Test.sol
Original file line number Diff line number Diff line change
@@ -10,12 +10,12 @@ contract Validator_Test {

using Validator for bytes32;

function checkMembership(bytes32 leaf, uint256 index, bytes32 rootHash, bytes proof)
function checkMembership(bytes32 leaf, uint256 index, bytes32 rootHash, bytes proof, uint256 total)
public
pure
returns (bool)
{
return leaf.checkMembership(index, rootHash, proof);
return leaf.checkMembership(index, rootHash, proof, total);
}

function checkSigs(bytes32 txHash, bytes32 confirmationHash, bool input1, bytes sig0, bytes sig1, bytes confirmSignatures)
Loading