omgnetwork / plasma-mvp

OmiseGO's research implementation of Minimal Viable Plasma
MIT License
561 stars 158 forks source link

CLI Example 'sendtx' outdated and broken #162

Closed bh2smith closed 6 years ago

bh2smith commented 6 years ago

Issue Type

[x] bug report
[ ] feature request

Current Behavior

sendtx example is missing parameter, cur12 for TokenAddress that was introduced in commit 9feb73e174a4cebef343852d4c07ae1c3c0fc991. However, even with the inclusion of a null address, 0x0, a call to sendtx yields an AttributeError at validate_transaction.

submitblock and withdrawdeposit also crashing;

Steps to Reproduce

  1. At first,
    omg sendtx 1 0 0 0 0 0 0xfd02EcEE62797e75D86BCff1642EB0844afB28c7 50 0x4B3eC6c9dC67079E82152d6D55d8dd96a8e6AA26 45 5 3bb369fecdc16b93b99514d8ed9c2e87c5824cf4a6a98d2e8e91b7dd0c063304

    results in

Error: Invalid value for "amount1": 0x4B3eC6c9dC67079E82152d6D55d8dd96a8e6AA26 is not a valid integer

  1. After including null address in appropriate location
    omg sendtx 1 0 0 0 0 0 0x0 0xfd02EcEE62797e75D86BCff1642EB0844afB28c7 50 0x4B3eC6c9dC67079E82152d6D55d8dd96a8e6AA26 45 5 3bb369fecdc16b93b99514d8ed9c2e87c5824cf4a6a98d2e8e91b7dd0c063304

    results in

Error: {'code': -32000, 'message': 'Server error', 'data': {'type': 'AttributeError', 'args': ["'str' object has no attribute 'amount1'"], 'message': "'str' object has no attribute 'amount1'"}} additional details can be found from the child chain's server output

with additional traceback (from child-chain logs)

API Exception: {'type': 'AttributeError', 'args': ("'str' object has no attribute 'amount1'",), 'message': "'str' object has no attribute 'amount1'"} Traceback (most recent call last): File "/Users/admin/Projects/venv3/lib/python3.6/site-packages/jsonrpc/manager.py", line 112, in _get_responses result = method(*request.args, **request.kwargs) File "plasma/child_chain/server.py", line 16, in dispatcher["apply_transaction"] = lambda transaction: child_chain.apply_transaction(transaction) File "/Users/admin/Projects/plasma-mvp/plasma/child_chain/child_chain.py", line 36, in apply_transaction self.chain.validate_transaction(tx, self.current_block.spent_utxos) File "/Users/admin/Projects/plasma-mvp/plasma_core/chain.py", line 55, in validate_transaction output_amount = tx.amount1 + tx.amount2 AttributeError: 'str' object has no attribute 'amount1' 127.0.0.1 - - [23/Jul/2018 15:45:48] "POST /jsonrpc HTTP/1.1" 200

  1. One can also see that the other two Example commands
omg submitblock 3bb369fecdc16b93b99514d8ed9c2e87c5824cf4a6a98d2e8e91b7dd0c063304

results in

TypeError: Object of type 'Block' is not JSON serializable

and

omg withdrawdeposit 0xfd02EcEE62797e75D86BCff1642EB0844afB28c7 1 100

results in

web3.exceptions.ValidationError: Could not identify the intended function with name startDepositExit, positional argument(s) of type (<class 'int'>, <class 'int'>) and keyword argument(s) of type {}. Found 1 function(s) with the name startDepositExit: ['startDepositExit(uint256,address,uint256)'] Function invocation failed due to improper number of arguments.

(but these may be due to previous errors)...

Expected Behavior

Sample commands should be updated with feature changes.

System Specs

asn1crypto==0.24.0 atomicwrites==1.1.5 attrdict==2.0.0 attrs==18.1.0 bitcoin==1.1.42 certifi==2018.4.16 cffi==1.11.5 chardet==3.0.4 click==6.7 cryptography==2.2.2 cytoolz==0.9.0.1 eth-abi==1.1.1 eth-account==0.2.3 eth-hash==0.1.0 eth-keyfile==0.5.1 eth-keys==0.2.0b3 eth-rlp==0.1.2 eth-tester==0.1.0b15 eth-utils==1.0.3 ethereum==2.3.0 ethjsonrpc==0.4.0 flake8==3.5.0 future==0.16.0 hexbytes==0.1.0 idna==2.7 json-rpc==1.10.8 lru-dict==1.1.6 mccabe==0.6.1 more-itertools==4.2.0 nose==1.3.7 parsimonious==0.8.0 pbkdf2==1.3 plasma==0.0.0 pluggy==0.6.0 plyvel==1.0.4 py==1.5.3 py-ecc==1.4.2 py-solc==3.1.0 pycodestyle==2.3.1 pycparser==2.18 pycryptodome==3.6.1 pyethash==0.1.27 pyflakes==1.6.0 pylru==1.1.0 pyOpenSSL==18.0.0 pysha3==1.0.2 pytest==3.6.1 PyYAML==3.12 repoze.lru==0.7 requests==2.19.0 rlp==0.6.0 scrypt==0.8.6 semantic-version==2.6.0 six==1.11.0 toolz==0.9.0 urllib3==1.23 virtualenv==16.0.0 web3==4.3.0 websockets==4.0.1 Werkzeug==0.13

bg1156 commented 6 years ago

('Web3.py only accepts checksum addresses.

bh2smith commented 6 years ago

This is not the problem I am facing at the moment. It appears to be an empty array in client.blocks

tina1998612 commented 6 years ago

I'm facing the same problem using Ubuntu

bh2smith commented 6 years ago

Please see #161 and the proposed solution.

bh2smith commented 6 years ago

Note that once the sendtx is accepted by the CLI (without error); We get the following problem

API Exception: {'type': 'AttributeError', 'args': ("'str' object has no attribute 'amount1'",), 'message': "'str' object has no attribute 'amount1'"}
Traceback (most recent call last):
  File "~/plasma-mvp/plasma_core/chain.py", line 55, in validate_transaction
    output_amount = tx.amount1 + tx.amount2
AttributeError: 'str' object has no attribute 'amount1'

Which is resolved with a try-catch with tx (since sometimes the encoded version is passed and sometimes not).

@kfichter, I will include my fix to both of these (since they are directly related to the same issue) so not to spam your issue-box.

smartcontracts commented 6 years ago

Hey @bh2smith can you confirm this is fixed?

bh2smith commented 6 years ago

@kfichter yes, this is now working, but I am wondering why the transaction fee attribute has been removed from this feature?

smartcontracts commented 6 years ago

We switched over to implicit transaction fees (fee = input value - output value).