Skip to content

Add mediation fees for internal routing and maximum fee limit#4760

Merged
LefterisJP merged 17 commits into
raiden-network:developfrom
LefterisJP:workon_4751
Sep 10, 2019
Merged

Add mediation fees for internal routing and maximum fee limit#4760
LefterisJP merged 17 commits into
raiden-network:developfrom
LefterisJP:workon_4751

Conversation

@LefterisJP
Copy link
Copy Markdown
Contributor

Fixes: #4751

Description

Check the issue.

PR review check list

Quality check list that cannot be automatically verified.

  • Safety
  • Code quality
    • Error conditions are handled
    • Exceptions are propagated to the correct parent greenlet
    • Exceptions are correctly classified as recoverable or unrecoverable
  • Compatibility
    • State changes are forward compatible
    • Transport messages are backwards and forward compatible
  • Commits
    • Have good messages
    • Squashed unecessary commits
  • If it's a bug fix:
    • Regression test for the bug
      • Properly covers the bug
      • If an integration test is used, it could not be written as a unit test
  • Documentation
    • A new CLI flag was introduced, is there documentation that explains usage?
  • Specs
    • If this is a protocol change, are the specs updated accordingly? If so, please link PR from the specs repo.
  • Is it a user facing feature/bug fix?
    • Changelog entry has been added

Comment thread raiden/tests/unit/transfer/mediated_transfer/test_initiatorstate.py Outdated
Comment thread raiden/tests/integration/transfer/test_mediatedtransfer.py
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 6, 2019

Codecov Report

Merging #4760 into develop will decrease coverage by 0.11%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4760      +/-   ##
===========================================
- Coverage    80.75%   80.63%   -0.12%     
===========================================
  Files          119      119              
  Lines        14373    14384      +11     
  Branches      2217     2219       +2     
===========================================
- Hits         11607    11599       -8     
- Misses        2111     2122      +11     
- Partials       655      663       +8
Impacted Files Coverage Δ
raiden/settings.py 100% <100%> (ø) ⬆️
raiden/routing.py 78.5% <100%> (+0.4%) ⬆️
raiden/transfer/mediated_transfer/initiator.py 98.7% <100%> (+0.06%) ⬆️
raiden/storage/serialization/types.py 59.7% <0%> (-8.96%) ⬇️
raiden/tasks.py 68.08% <0%> (-2.84%) ⬇️
raiden/utils/echo_node.py 67.79% <0%> (-1.7%) ⬇️
raiden/raiden_event_handler.py 91.5% <0%> (-0.66%) ⬇️
raiden/network/transport/matrix/transport.py 80.44% <0%> (-0.6%) ⬇️
raiden/network/proxies/token_network.py 49.75% <0%> (-0.5%) ⬇️
raiden/transfer/channel.py 89.14% <0%> (-0.23%) ⬇️
... and 2 more

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 12b673d...33df00b. Read the comment docs.

Comment thread raiden/transfer/mediated_transfer/initiator.py
Comment thread raiden/tests/utils/transfer.py Outdated
Comment thread raiden/tests/integration/transfer/test_mediatedtransfer.py
Comment thread raiden/tests/unit/transfer/mediated_transfer/test_initiatorstate.py Outdated
@LefterisJP
Copy link
Copy Markdown
Contributor Author

Rebased on latest develop and solved conflicts

@LefterisJP LefterisJP force-pushed the workon_4751 branch 2 times, most recently from 390130a to 410b6cd Compare September 9, 2019 14:50
@Dominik1999
Copy link
Copy Markdown
Contributor

Does the maximum fee limit also count for routes being provided by the pfs?
It should do so.

@LefterisJP
Copy link
Copy Markdown
Contributor Author

Does the maximum fee limit also count for routes being provided by the pfs?
It should do so.

Yes the code for the check is after the routes have been acquired (by whatever means, pfs or internal routing)

@LefterisJP
Copy link
Copy Markdown
Contributor Author

Hey @karlb

Rebasing on #4786 broke this PR unfortunately on the test_mediated_transfer_with_fees.

So had to spend some time figuring it out.

Turns out that since you were patching the fees and setting them to a standard 20% for each mediator, quite a lot of combinations of amount + fees would not work and end up not completing the transfer (due to less than the final amount reaching the target). So what I added is:

  1. An exception that is thrown if gevent timeout kills the waiting for the transfer. This helps by giving a nice explanation to what happened. Before the test just failed with some big gevent traces which were impossible to read.

  2. Wrote a check in the test to validate given amount/fee combinations and make sure that with the given 20% mediation fees per mediator of the test, the amount reaches the target (before trying the transfer)

@LefterisJP LefterisJP merged commit 4f5e8fc into raiden-network:develop Sep 10, 2019
@LefterisJP LefterisJP deleted the workon_4751 branch September 10, 2019 06:42
Comment thread raiden/routing.py

# https://github.com/raiden-network/raiden/issues/4751
# Internal routing doesn't know about fee so it should set a percentage per hop
estimated_fee = FeeAmount(round(INTERNAL_ROUTING_DEFAULT_FEE_PERC * amount))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We're adding fees here even in case of a direct transfer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry for not being thorough, yesterday. It also looks like we only apply INTERNAL_ROUTING_DEFAULT_FEE_PERC once. Wasn't the intention of the ticket to do that once per hop?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'll write a PR that changes these two things. If any of these statements is wrong, let me know!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@karlb

We're adding fees here even in case of a direct transfer.

It's correct. I did not notice that.

It also looks like we only apply INTERNAL_ROUTING_DEFAULT_FEE_PERC once. Wasn't the intention of the ticket to do that once per hop?

No, since we are not sure of the hops anyway in internal routing the intention (and it's also written in the issue) was to add a big percentage.

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.

Add Fees to internal Routing

4 participants