Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MonitoringService.monitor() takes a MessageTypeId #1025

Merged
merged 7 commits into from
May 28, 2019

Conversation

pirapira
Copy link
Contributor

into account when validating the signature.

This closes #1021 .

@pirapira pirapira force-pushed the monitor-message-id branch from 09f4c4e to add1794 Compare May 27, 2019 13:41
@codecov
Copy link

codecov bot commented May 27, 2019

Codecov Report

Merging #1025 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1025      +/-   ##
==========================================
+ Coverage   85.14%   85.15%   +0.01%     
==========================================
  Files          20       20              
  Lines        1373     1374       +1     
  Branches      182      182              
==========================================
+ Hits         1169     1170       +1     
  Misses        158      158              
  Partials       46       46
Impacted Files Coverage Δ
raiden_contracts/utils/proofs.py 92.1% <ø> (ø) ⬆️
raiden_contracts/constants.py 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5cf939a...e9e83f0. Read the comment docs.

@codecov
Copy link

codecov bot commented May 27, 2019

Codecov Report

Merging #1025 into master will increase coverage by 0.11%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1025      +/-   ##
==========================================
+ Coverage   85.18%   85.29%   +0.11%     
==========================================
  Files          20       20              
  Lines        1377     1374       -3     
  Branches      182      178       -4     
==========================================
- Hits         1173     1172       -1     
+ Misses        158      157       -1     
+ Partials       46       45       -1
Impacted Files Coverage Δ
raiden_contracts/utils/proofs.py 92.1% <ø> (ø) ⬆️
raiden_contracts/constants.py 100% <100%> (ø) ⬆️
raiden_contracts/deploy/__main__.py 93.5% <0%> (+0.08%) ⬆️
raiden_contracts/utils/pending_transfers.py 96.22% <0%> (+3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e298e0...ee881ff. Read the comment docs.

@pirapira pirapira requested a review from karlb May 27, 2019 18:13
"\x19Ethereum Signed Message:\n200",
monitoring_service_address,
chain_id,
uint256(MessageTypeId.MSReward),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we add a message id to the signature, shouldn't we put it in the same place for all messages (e.g. first in the signature)? Otherwise there could still be conflicts (although highly unlikely). Example:

Message1 (of MessageTypeId 5):

  • 10: TokenAmount
  • 5: MessageTypeId
  • signature

Message2 (of MessageTypeId 10):

  • 10: MessageTypeId
  • 5: ChannelID
  • signature

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should put the ID in the same place always.

In TokenNetwork, the message ID is always the third element after an address and a chain_id.

        bytes32 message_hash = keccak256(abi.encodePacked(
            signature_prefix,
            message_length,
            address(this),
            chain_id,
            uint256(MessageTypeId.Withdraw),
            channel_identifier,
            participant,
            total_withdraw
        ));

I can change them as well, but that causes some additional work (adjusting the client).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't expect the third place to be the fixed location. This also required the same length of the first two arguments in all cases to be safe. But I guess this is the case for us. No need to change if you watch out for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add the convention in the contribution guide. I think the current convention is

address message_destination,
uint256 chain_id,
uin256 message_type,
...

I agree the third position looks like a random choice.

@@ -342,11 +344,13 @@ contract MonitoringService is Utils {
returns (address signature_address)
{
bytes32 message_hash = keccak256(abi.encodePacked(
"\x19Ethereum Signed Message:\n148",
"\x19Ethereum Signed Message:\n200",
monitoring_service_address,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reward is not bound to a specific monitoring service. Did you want to use monitoring_service_contract_address here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, suddenly I remember that there should be a competition between MSs.

And yes, monitoring_service_contract_address is the right one.

@pirapira pirapira force-pushed the monitor-message-id branch from e9e83f0 to 5929723 Compare May 28, 2019 09:38
@pirapira
Copy link
Contributor Author

@karlb please have another look.

raiden_contracts/utils/proofs.py Outdated Show resolved Hide resolved
raiden_contracts/utils/proofs.py Outdated Show resolved Hide resolved
@pirapira
Copy link
Contributor Author

@karlb ready for a merge?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MonitoringService.monitor() should add a MessageID when it recovers an address from the signature
2 participants