Finally running plasma_cash with Embark

This commit is contained in:
Richard Ramos 2018-07-31 20:38:43 -04:00
parent 6d37870846
commit a9c54f50b9
6 changed files with 101 additions and 26 deletions

1
.gitignore vendored
View File

@ -17,6 +17,7 @@ dist/
# pyenv
.python-version
erc721plasma/
# dotenv
.env

View File

@ -26,12 +26,25 @@
"DelegationProxyKernel": { "deploy": false },
"ProposalCuration": { "deploy": false },
"Democracy": { "deploy": false },
"TestToken": {
"TestToken": { "deploy": false },
"AddressUtils": { "deploy": false },
"PollManager": { "deploy": false },
"ERC721BasicToken": { "deploy": false },
"ERC721Token": { "deploy": false },
"RLP": { "deploy": false },
"SparseMerkleTree": { "deploy": false },
"ECVerify": { "deploy": false },
"Transaction": { "deploy": false },
"ValidatorManagerContract": {},
"RootChain": {
"args": ["$ValidatorManagerContract"]
},
"CryptoCards":{
"args": ["$RootChain"]
},
"MiniMeTokenFactory": {
},
"PollManager": { "deploy": false },
"SNT": {
"instanceOf": "MiniMeToken",
"args": [
@ -44,31 +57,16 @@
true
]
},
"AddressUtils": { "deploy": false },
"SupportsInterfaceWithLookup": { "deploy": false },
"ERC721BasicToken": { "deploy": false },
"ERC721Token": { "deploy": false },
"RLP": { "deploy": false },
"SparseMerkleTree": { "deploy": false },
"ECVerify": { "deploy": false },
"Transaction": { "deploy": false },
"ValidatorManagerContract": {},
"RootChain": {
"args": ["$ValidatorManagerContract"]
},
"PlasmaERC20":{ "deploy": false },
"PlasmaSNT": {
"instanceOf": "PlasmaERC20",
"args": ["$RootChain", "$SNT", "PlasmaSNT", "PSNT"],
"onDeploy": [
"ValidatorManagerContract.methods.toggleToken($PlasmaSNT).send()",
"PlasmaSNT.methods.setExchangeRate(0, 5000000000000000000).send()"
]
"args": ["$RootChain", "$SNT", "PlasmaSNT", "PSNT"]
}
}
},
"afterDeploy": [
"ValidatorManagerContract.methods.toggleToken('$CryptoCards').send()",
"PlasmaSNT.methods.setExchangeRate(0, 5000000000000000000).send()"
]
},

View File

@ -0,0 +1,40 @@
pragma solidity ^0.4.24;
import "openzeppelin-solidity/contracts/token/ERC721/ERC721Token.sol";
contract CryptoCards is ERC721Token("CryptoCards", "CCC") {
address plasma;
constructor (address _plasma) public {
plasma = _plasma;
}
function register() external {
// Give each new player 5 cards
for (int j = 0; j < 5; j++) {
create();
}
}
function depositToPlasmaWithData(uint tokenId, bytes _data) public {
require(plasma != address(0));
safeTransferFrom(
msg.sender,
plasma,
tokenId,
_data);
}
function depositToPlasma(uint tokenId) public {
require(plasma != address(0));
safeTransferFrom(msg.sender, plasma, tokenId);
}
function create() private {
uint256 tokenId = allTokens.length + 1;
_mint(msg.sender, tokenId);
}
}

View File

@ -1,3 +1,37 @@
# @rramos notes
I configured the project to run with Embark (Only demo.py was tested). To run this project in Ubuntu, the following steps need to be executed
1. `npm install`
2. Open at least 4 terminals (you can use `tmux` for this)
3. In Terminal-1, execute `embark simulator`
4. In Terminal-2, execute `embark run`
5. In Terminal-3:
```
cd plasma_cash
virtualenv erc721plasma -p python3.6
source erc721plasma/bin/activate
pip install -r requirements.txt
FLASK_APP=./child_chain FLASK_ENV=development flask run --port=8546
```
6. In Terminal-4:
```
cd plasma_cash
source erc721plasma/bin/activate
python demo.py
```
Most of the previous instructions are covered here, I just wrote them here for quick reference.
If installing the server from scratch:
1. Install Nodejs with `nvm`
2. Follow the instructions from Embark for its installation,
3. `sudo apt install virtualenv python3 python3-dev libssl-dev build-essential`
_NOTE_: `nvm` and Embark must be installed with a normal user. Don't use `root`!
# Development Dependencies
A patched version of web3.py is used because otherwise it does not work with Ganache due to issue #674. In addition, in order to be able to monitor events, PR #827, which is not merged yet. Pyethereum dependencies broke recently so we need to manually install a slightly older version of rlp encoding. Flask is used for server purposes.

View File

@ -1,7 +1,8 @@
plasma_config = dict(
validator_manager='0x494748735312D87C54Ff36E9dc71f90fb800D7Df',
root_chain='0xe5731c3df7a510fba6c5b2766251ce631C6B1d78',
validator_manager='0xd8a512EBD6fd82f44dFFD968EEB0835265497d20',
root_chain='0x494748735312D87C54Ff36E9dc71f90fb800D7Df',
token_contract='0x6427A6200Bed37FC1e512BdeA49D25Aa9089CF47',
authority='0xf942d5d524ec07158df4354402bfba8d928c99d0ab34d0799a6158d56156d986',
alice='0x88f37cfbaed8c0c515c62a17a3a1ce2f397d08bbf20dcc788b69f11b5a5c9791',
bob='0xf4ebc8adae40bfc741b0982c206061878bffed3ad1f34d67c94fa32c3d33eac8',
@ -10,6 +11,7 @@ plasma_config = dict(
mallory='0x130137aa9a7fbc7cadc98c079cda47a999ff41931d9feaab621855beceed71f7',
eve='0xead83d04f741d2b3ab50be1299c18aa1a82c241606861a9a6d3122443496522d',
trudy='0xe6e893ac9f1c1db066a8a83a376554084b0a786e4cdcd91559d68bd4a1dac396',
players=[
'0x56901d80abc6953d1dc01de2f077b75260f49a3304f665b57ed13514a7e2a2bc',
'0xedc63d0e14b29aaa26c7585e962f93abb59bd7d8b01b585e073dc03d052a000b',

View File

@ -8,7 +8,7 @@ class DependencyContainer(object):
def __init__(self):
self._child_chain = None
self.root_chain_abi = '../dist/contracts/RootChain.json'
self.token_contract_abi = '../dist/contracts/PlasmaERC20.json'
self.token_contract_abi = '../dist/contracts/CryptoCards.json'
self.endpoint = 'http://localhost:8545'
self.root_chain = PlasmaCash(
plasma_config['authority'],