omgnetwork / plasma-mvp

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

PlasmaRLP.getUtxoPos is incorrect #199

Closed dcb9 closed 6 years ago

dcb9 commented 6 years ago

The transaction on the child chain is defined in transaction.py as below:

https://github.com/omisego/plasma-mvp/blob/c9027936c5f8895c9004310b5c07616bb5e2f2bb/plasma_core/transaction.py#L26-L33

as noted above, we know what is in a transaction:

so if we want to the the UTXO PoS of a specific output, we should do something like this blknum * 1000000000 + index * 10000 + oindex, but the implement of this is not the same as we think.

https://github.com/omisego/plasma-mvp/blob/c9027936c5f8895c9004310b5c07616bb5e2f2bb/plasma/root_chain/contracts/PlasmaRLP.sol#L25-L27

I suppose that the correct implement is this:

- RLPDecode.toUint(txList[0 + oIndexShift]) + 
- RLPDecode.toUint(txList[1 + oIndexShift]) + 
- RLPDecode.toUint(txList[2 + oIndexShift]); 
+ RLPDecode.toUint(txList[0 + oIndexShift]) * 1000000000 +
+ RLPDecode.toUint(txList[1 + oIndexShift]) * 10000 +
+ RLPDecode.toUint(txList[2 + oIndexShift]);