raiden-contracts
raiden-contracts copied to clipboard
Define order for the event fields in ChannelSettled and ChannelOpened
ChannelOpened
uses the order of the addresses provided by the caller:
https://github.com/raiden-network/raiden-contracts/blob/7212a66be1908af8b657c36de5393a04838af2e4/raiden_contracts/data/source/raiden/TokenNetwork.sol#L301-L306
ChannelSettled
uses the a very weird order. The participant which has the highest transferred amount will be the second address, and if the transferred amounts are equal the order is defined by the caller:
https://github.com/raiden-network/raiden-contracts/blob/7212a66be1908af8b657c36de5393a04838af2e4/raiden_contracts/data/source/raiden/TokenNetwork.sol#L1423-L1428
https://github.com/raiden-network/raiden-contracts/blob/7212a66be1908af8b657c36de5393a04838af2e4/raiden_contracts/data/source/raiden/TokenNetwork.sol#L793-L799
Having an predefined order for these events would simplify the clients. e.g. For the channel settle event the client has to do 2 or 4 database queries, to find the corresponding locksroots from the sent/received messages, and it has to handle corner cases where the locksroots are reused:
https://github.com/raiden-network/raiden/blob/db910951f12d5f4226e74b25e67dcce8c139dc71/raiden/blockchain/state.py#L96-L101