Root chain contracts for Plasma M(ore)VP, work in progress.
This version of the contract implements Plasma MVP (Buterin, Poon, Knott). This implementation is a PoA scheme with one operator and multiple watchers (users). Detailed description of our child chain design is in Tesuji document.
Implementation differs from MVP in few regards:
- Added protection against chain re-orgs (omgnetwork/plasma-mvp#51).
- Added collected fee exiting for PoA operator.
- Added ERC20 handling.
- Merkle tree used is of variable depth.
- Transaction fee is implicit, not explicit.
While this implementation contains confirmations, this is a temporary state as we are going to replace confirmations with the exit game defined in MoreVP (Fichter, Jones) in the future. Reasons include:
- Bad UX, need to propagate confirm sigs somehow.
- Receiver can lie about receiving money; to prove sending, sender needs to publish confirmation to Ethereum.
- Additional signature check per tx is needed.
- No good way of doing partially signed transactions / atomic swaps.
See here.
Normally funds are protected by M(ore)VP mechanisms. There is an attack vector where operator spots large deposit in Ethereum mempool and produces a block to steal. If malicious block is mined before the deposit, deposit can be stolen. We are intending to use elevated exit priority for deposits so they always wait at most Minimal Finalization Period, while exit from fraudulent block will have to wait for Minimal Finalization Period + Required Exit Period.
Installing dependencies needed for compilation:
make init
Installing dependencies needed to run tests:
make dev
Building and running tests:
make test
Running slow (overnight) tests:
make runslow | tee raport.txt
Requires node.js >= 8
Install dependencies:
npm install
Deploying the contracts requires two accounts:
DEPLOYER
The account that actually deploys the contractsAUTHORITY
The Authority account callsRootChain.init()
and is the account used by the Child chain (or operator). By default a newAUTHORITY
account is created when deploying, and will be funded with some ETH from theDEPLOYER
account. If you prefer you can use an existingAUTHORITY
account, but it must not have made any transaction prior to callingRootChain.init()
i.e. its nonce must be 0.
Normally you will deploy the contracts using an Ethereum client that you run yourself, such as Geth or Parity. However, you can also use a provider such as Infura. In this case you'll need to know the private keys for the DEPLOYER
and AUTHORITY
accounts. See truffle-config.js
for an example.
Certain configuration values need to be set, depending how you're deploying. These values can be set in the environment or in a file called .env
MIN_EXIT_PERIOD
Minimum exit period in seconds. Required.SOLC_VERSION
Solidity compiler version. Defaults to0.4.25
ETH_CLIENT_HOST
Host of Ethereum client. Defaults to127.0.0.1
ETH_CLIENT_PORT
Port of Ethereum client. Defaults to8545
DEPLOYER_ADDRESS
Address of theDEPLOYER
account. Defaults toaccounts[0]
DEPLOYER_PASSPHRASE
Passphrase of theDEPLOYER
account.AUTHORITY_PASSPHRASE
Passphrase of theAUTHORITY
account.AUTHORITY_ADDRESS_INITIAL_AMOUNT
The amount the fund theAUTHORITY
account with (in wei). Defaults to 1 ETH.USE_EXISTING_AUTHORITY_ADDRESS
Set totrue
if you want to use an existingAUTHORITY
account instead of creating a new one. You must also setAUTHORITY_ADDRESS
Run truffle, passing in the network e.g.
npx truffle migrate --network local
Truffle will compile and deploy the contracts. If all goes well it will output the results:
{
"contract_addr":"0xb6d73FCDD7F3E053990518eAe1306D7893EEFE12",
"txhash_contract":"0x1595b181ece865ccc9e3a025931be0566dd6e7bec739d79faafb1d5215b01c71",
"authority_addr":"0xF0B750F59Fff5C2be61870Dc0DA58e5e8d8F4232"
}