diff --git a/.circleci/config.yml b/.circleci/config.yml index d85378348035..4e41bc37b85e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,10 +11,15 @@ jobs: make docker-build no_output_timeout: 2400s - run: sudo chown -R 100:1000 docker/config/ && sudo chmod -R 777 docker/config/ + - run: + name: Infra standup + working_directory: /home/circleci/project/docker + command: docker-compose up ganache truffle + background: true - run: name: Test - command: | - make test + working_directory: /home/circleci/project/docker + command: docker-compose up vault_server no_output_timeout: 2400s - run: name: Save Docker image diff --git a/API.md b/API.md index 267db540461c..ef8ad7d2268b 100644 --- a/API.md +++ b/API.md @@ -240,13 +240,14 @@ Submits the Merkle root of a Plasma block | name | Name of the wallet - provided in the URI. | | address | Account address which will submit the block - provided in the URI. | | contract | The address of the Block Controller contract. | -| gas_price | The gas price for the transaction in wei. Defaults to 0 - which means use the estimated gas price. | +| gas_price | The gas price for the transaction in wei. | | block_root | The Merkle root of a Plasma block. | +| nonce | Transaction order. | ### EXAMPLE ```sh -curl -X PUT -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token)" -d '{"block_root":"1234qweradgf1234qweradgf","contract":"0xd185aff7fb18d2045ba766287ca64992fdd79b1e"}' http://127.0.0.1:8900/v1/immutability-eth-plugin/wallets/plasma-deployer/accounts/0x888a65279D4a3A4E3cbA57D5B3Bd3eB0726655a6/plasma/submitBlock +curl -X PUT -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token)" -d '{"block_root":"1234qweradgf1234qweradgf","contract":"0xd185aff7fb18d2045ba766287ca64992fdd79b1e", "gas_price: "20000000000", nonce: "0""}' http://127.0.0.1:8900/v1/immutability-eth-plugin/wallets/plasma-deployer/accounts/0x888a65279D4a3A4E3cbA57D5B3Bd3eB0726655a6/plasma/submitBlock { "request_id": "00a614f3-9bd3-60f4-25be-384a8d3cc5ff", @@ -258,29 +259,10 @@ curl -X PUT -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token)" "from": "0x4BC91c7fA64017a94007B7452B75888cD82185F7", "gas_limit": 73623, "gas_price": 20000000000, - "nonce": 1, + "nonce": 0, "signed_transaction": "0xf889018504a817c80083011f9794d185aff7fb18d2045ba766287ca64992fdd79b1e80a4baa4769431323334717765726164676631323334717765726164676600000000000000001ca04b14e95372a41a74585c04c7967c45f2d1d51e4f5cd59b7c95a2c16ecbd63e79a04fcc461cfd165d8ba1f9cafe37ce7c025c0cec0533880abda3df754c9c749d9a", "transaction_hash": "0x6cfad4034bf147accb815922bb4f71ed8ae676e65580ab259d9d1d8713047c7f" }, "warnings": null } -``` - -### ACTIVATE CHILD CHAIN - -Activates the child chain so that child chain can start to submit child blocks to root chain. - -#### INPUTS - -| Parameter | Description | -| --- | ----------- | -| name | Name of the wallet - provided in the URI. | -| address | Account address which will submit the block - provided in the URI. | -| contract | The address of the Block Controller contract. | -| gas_price | The gas price for the transaction in wei. Defaults to 0 - which means use the estimated gas price. | - -### EXAMPLE - -```sh -curl -X PUT -H "X-Vault-Request: true" -H "X-Vault-Token: $(vault print token)" -d '{"contract":"0xd185aff7fb18d2045ba766287ca64992fdd79b1e"}' http://127.0.0.1:8900/v1/immutability-eth-plugin/wallets/plasma-deployer/accounts/0x888a65279D4a3A4E3cbA57D5B3Bd3eB0726655a6/plasma/activateChildChain -``` +``` \ No newline at end of file diff --git a/docker/config/entrypoint.sh b/docker/config/entrypoint.sh index 888f3a5ddb42..7be216bd4ef5 100755 --- a/docker/config/entrypoint.sh +++ b/docker/config/entrypoint.sh @@ -188,6 +188,11 @@ else test_plugin fi -# Don't exit until vault dies -wait $VAULT_PID +if [ -n "$TEST" ]; then + echo "Dying." +else + echo "Don't exit until vault dies." + wait $VAULT_PID +fi + diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 4d00f75db68e..1176027fe1fe 100755 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -46,11 +46,8 @@ services: - testnet ports: - "8200:8900" - depends_on: - - "ganache" - links: - - "ganache" - - "truffle" + environment: + - TEST=true volumes: - "./config:/home/vault/config:rw" - "../contracts:/home/vault/contracts:ro" diff --git a/ethereum/path_plasma.go b/ethereum/path_plasma.go index c34d380f17b4..6e701ddcc5ca 100644 --- a/ethereum/path_plasma.go +++ b/ethereum/path_plasma.go @@ -44,8 +44,7 @@ Allows the authority to submit the Merkle root of a Plasma block. }, "gas_price": { Type: framework.TypeString, - Description: "The gas price for the transaction in wei. Defaults to 0 - which means use the estimated gas price.", - Default: "0", + Description: "The gas price for the transaction in wei.", }, "nonce": { Type: framework.TypeString, @@ -117,20 +116,20 @@ func (b *PluginBackend) pathPlasmaSubmitBlock(ctx context.Context, req *logical. if err != nil { return nil, err } - //transactOpts needs gas etc. Use supplied gas_price if > 0 + //transactOpts needs gas etc. Use supplied gas_price gasPriceRaw := data.Get("gas_price").(string) - - if gasPriceRaw != "0" { - transactOpts.GasPrice = util.ValidNumber(gasPriceRaw) + if gasPriceRaw == "" { + return nil, fmt.Errorf("invalid gas_price") } - - //transactOpts needs nonce. Use supplied nonce is > 0 + transactOpts.GasPrice = util.ValidNumber(gasPriceRaw) + + //transactOpts needs nonce. Use supplied nonce nonceRaw := data.Get("nonce").(string) - - if nonceRaw != "0" { - transactOpts.Nonce = util.ValidNumber(nonceRaw) + if nonceRaw == "" { + return nil, fmt.Errorf("invalid nonce") } - + transactOpts.Nonce = util.ValidNumber(nonceRaw) + plasmaSession := &plasma.PlasmaSession{ Contract: instance, // Generic contract caller binding to set the session for CallOpts: *callOpts, // Call options to use throughout this session diff --git a/scripts/smoke.plasma.sh b/scripts/smoke.plasma.sh index 7940c16a095b..947a0bff20da 100755 --- a/scripts/smoke.plasma.sh +++ b/scripts/smoke.plasma.sh @@ -55,20 +55,21 @@ echo "UNAUTHORIZED=$UNAUTHORIZED" banner vault write -format=json -f -output-curl-string immutability-eth-plugin/wallets/plasma-deployer/accounts banner + echo "*** SHOULD FAIL! ***" echo "UNAUTHORIZED SUBMISSION OF BLOCK BY $UNAUTHORIZED" -echo "vault write -format=json immutability-eth-plugin/wallets/plasma-deployer/accounts/$UNAUTHORIZED/plasma/submitBlock nonce=0 block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT" -vault write -format=json immutability-eth-plugin/wallets/plasma-deployer/accounts/$UNAUTHORIZED/plasma/submitBlock nonce=0 block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT +echo "vault write -format=json immutability-eth-plugin/wallets/plasma-deployer/accounts/$UNAUTHORIZED/plasma/submitBlock nonce=0 gas_price=$GAS_PRICE_HIGH block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT" +vault write -format=json immutability-eth-plugin/wallets/plasma-deployer/accounts/$UNAUTHORIZED/plasma/submitBlock nonce=0 gas_price=$GAS_PRICE_HIGH block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT banner -vault write -output-curl-string immutability-eth-plugin/wallets/plasma-deployer/accounts/$UNAUTHORIZED/plasma/submitBlock nonce=0 block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT +vault write -output-curl-string immutability-eth-plugin/wallets/plasma-deployer/accounts/$UNAUTHORIZED/plasma/submitBlock nonce=0 gas_price=$GAS_PRICE_HIGH block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT banner echo "*** SHOULD SUCCEED ***" echo "AUTHORIZED SUBMISSION OF BLOCK BY $ORIGINAL_AUTHORITY" -echo "vault write -format=json immutability-eth-plugin/wallets/plasma-deployer/accounts/$ORIGINAL_AUTHORITY/plasma/submitBlock nonce=0 block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT" -vault write -format=json immutability-eth-plugin/wallets/plasma-deployer/accounts/$ORIGINAL_AUTHORITY/plasma/submitBlock nonce=0 block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT +echo "vault write -format=json immutability-eth-plugin/wallets/plasma-deployer/accounts/$ORIGINAL_AUTHORITY/plasma/submitBlock nonce=0 gas_price=$GAS_PRICE_HIGH block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT" +vault write -format=json immutability-eth-plugin/wallets/plasma-deployer/accounts/$ORIGINAL_AUTHORITY/plasma/submitBlock nonce=0 gas_price=$GAS_PRICE_HIGH block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT banner -vault write -output-curl-string immutability-eth-plugin/wallets/plasma-deployer/accounts/$ORIGINAL_AUTHORITY/plasma/submitBlock nonce=0 block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT +vault write -output-curl-string immutability-eth-plugin/wallets/plasma-deployer/accounts/$ORIGINAL_AUTHORITY/plasma/submitBlock nonce=0 gas_price=$GAS_PRICE_HIGH block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT banner echo "*** SHOULD SUCCEED ***" @@ -77,3 +78,20 @@ echo "vault write -format=json immutability-eth-plugin/wallets/plasma-deployer/a vault write -format=json immutability-eth-plugin/wallets/plasma-deployer/accounts/$ORIGINAL_AUTHORITY/plasma/submitBlock nonce=1 gas_price=$GAS_PRICE_HIGH block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT banner vault write -output-curl-string immutability-eth-plugin/wallets/plasma-deployer/accounts/$ORIGINAL_AUTHORITY/plasma/submitBlock nonce=1 gas_price=$GAS_PRICE_HIGH block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT + +banner +echo "*** SHOULD FAIL! ***" +echo "AUTHORIZED SUBMISSION OF BLOCK BY $ORIGINAL_AUTHORITY - USER SUPPLIED GAS PRICE WITHOUT NONCE" +echo "vault write -format=json immutability-eth-plugin/wallets/plasma-deployer/accounts/$ORIGINAL_AUTHORITY/plasma/submitBlock gas_price=$GAS_PRICE_HIGH block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT" +vault write -format=json immutability-eth-plugin/wallets/plasma-deployer/accounts/$ORIGINAL_AUTHORITY/plasma/submitBlock gas_price=$GAS_PRICE_HIGH block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT +banner +vault write -output-curl-string immutability-eth-plugin/wallets/plasma-deployer/accounts/$ORIGINAL_AUTHORITY/plasma/submitBlock gas_price=$GAS_PRICE_HIGH block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT + +banner +echo "*** SHOULD FAIL! ***" +echo "AUTHORIZED SUBMISSION OF BLOCK BY $ORIGINAL_AUTHORITY - USER SUPPLIED NONCE WITHOUT GAS PRICE" +echo "vault write -format=json immutability-eth-plugin/wallets/plasma-deployer/accounts/$ORIGINAL_AUTHORITY/plasma/submitBlock nonce=1 block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT" +vault write -format=json immutability-eth-plugin/wallets/plasma-deployer/accounts/$ORIGINAL_AUTHORITY/plasma/submitBlock nonce=1 block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT +banner +vault write -output-curl-string immutability-eth-plugin/wallets/plasma-deployer/accounts/$ORIGINAL_AUTHORITY/plasma/submitBlock nonce=1 block_root=$BLOCK_ROOT contract=$PLASMA_CONTRACT +