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

Add Decoder for The Graph staking #6712

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

d347h-eth
Copy link
Contributor

@d347h-eth d347h-eth commented Oct 6, 2023

Related to #2044

For Delegator staking the typical scenario is:

  • call delegate() (emits StakeDelegated event)
  • call undelegate() (emits StakeDelegatedLocked event)
  • call withdrawDelegated() (emits StakeDelegatedWithdrawn event)

@CLAassistant
Copy link

CLAassistant commented Oct 6, 2023

CLA assistant check
All committers have signed the CLA.

@d347h-eth d347h-eth added the ready for peer review Backend PR ready to be reviewed by colleagues label Oct 6, 2023
@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

Merging #6712 (61099ca) into develop (1c3e052) will decrease coverage by 0.01%.
Report is 3 commits behind head on develop.
The diff coverage is 82.02%.

@@             Coverage Diff             @@
##           develop    #6712      +/-   ##
===========================================
- Coverage    78.69%   78.69%   -0.01%     
===========================================
  Files         1147     1149       +2     
  Lines       100321   100410      +89     
  Branches     11714    11723       +9     
===========================================
+ Hits         78951    79013      +62     
- Misses       19497    19511      +14     
- Partials      1873     1886      +13     
Flag Coverage Δ
backend 80.11% <82.02%> (-0.03%) ⬇️
frontend_unit 76.15% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...lchen/chain/ethereum/modules/thegraph/constants.py 100.00% <100.00%> (ø)
...ehlchen/chain/ethereum/modules/thegraph/decoder.py 81.39% <81.39%> (ø)

... and 20 files with indirect coverage changes

Copy link
Member

@LefterisJP LefterisJP left a comment

Choose a reason for hiding this comment

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

Left some comments

rotkehlchen/chain/ethereum/modules/the_graph/constants.py Outdated Show resolved Hide resolved
rotkehlchen/chain/ethereum/modules/the_graph/constants.py Outdated Show resolved Hide resolved
rotkehlchen/chain/ethereum/modules/the_graph/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/ethereum/modules/the_graph/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/ethereum/modules/the_graph/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_the_graph.py Outdated Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_the_graph.py Outdated Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_the_graph.py Outdated Show resolved Hide resolved
rotkehlchen/chain/ethereum/modules/the_graph/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/ethereum/modules/the_graph/decoder.py Outdated Show resolved Hide resolved
Copy link
Member

@LefterisJP LefterisJP left a comment

Choose a reason for hiding this comment

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

Some smaller comments


# also account for the GRT burnt due to delegation tax
tokens_burnt = initial_amount_norm - stake_amount_norm
if tokens_burnt > 0:
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this always be true? Or just going for some kidn of future proof thing where maybe the protocol removes the fee?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should always be true, yes, so it's just a sanity-check to not send a negative amount into a new EvmEvent instance.

rotkehlchen/chain/ethereum/modules/thegraph/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/ethereum/modules/thegraph/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/ethereum/modules/thegraph/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/ethereum/modules/thegraph/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/ethereum/modules/thegraph/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/chain/ethereum/modules/thegraph/decoder.py Outdated Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_main.py Show resolved Hide resolved
rotkehlchen/tests/unit/decoders/test_thegraph.py Outdated Show resolved Hide resolved
Copy link
Member

@LefterisJP LefterisJP left a comment

Choose a reason for hiding this comment

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

Also the PR has 7 commits already. It should only have 1. Or 2. One for implementation and 1 for tests. As linked before in contribution guide we keep commits doing one thing and if multiple commits are for same reason combine them.

Copy link
Member

@LefterisJP LefterisJP left a comment

Choose a reason for hiding this comment

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

Thanks. Looks good to me, will merge.

Do the small nitpicks in the next PR and keep them in mind. Also you would need to add a changelog in the next PR.

delegator = hex_or_bytes_to_address(context.tx_log.topics[2])
if delegator is None or self.base.is_tracked(delegator) is False:
return DEFAULT_DECODING_OUTPUT
indexer = hex_or_bytes_to_address(context.tx_log.topics[1])
Copy link
Member

Choose a reason for hiding this comment

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

Use newline after if. Helps readability

Suggested change
indexer = hex_or_bytes_to_address(context.tx_log.topics[1])
indexer = hex_or_bytes_to_address(context.tx_log.topics[1])

delegator = hex_or_bytes_to_address(context.tx_log.topics[2])
if delegator is None or self.base.is_tracked(delegator) is False:
return DEFAULT_DECODING_OUTPUT
indexer = hex_or_bytes_to_address(context.tx_log.topics[1])
Copy link
Member

Choose a reason for hiding this comment

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

Use newline after if. Helps readability

Suggested change
indexer = hex_or_bytes_to_address(context.tx_log.topics[1])
indexer = hex_or_bytes_to_address(context.tx_log.topics[1])

delegator = hex_or_bytes_to_address(context.tx_log.topics[2])
if delegator is None or self.base.is_tracked(delegator) is False:
return DEFAULT_DECODING_OUTPUT
indexer = hex_or_bytes_to_address(context.tx_log.topics[1])
Copy link
Member

Choose a reason for hiding this comment

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

Use newline after if. Helps readability

Suggested change
indexer = hex_or_bytes_to_address(context.tx_log.topics[1])
indexer = hex_or_bytes_to_address(context.tx_log.topics[1])

Comment on lines +167 to +168
'Withdraw 1003.70342593701668535 GRT'
' from indexer 0x6125eA331851367716beE301ECDe7F38A7E429e7'
Copy link
Member

Choose a reason for hiding this comment

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

This is also a nitpick and can't enforce from linter but I have notices when you split a sentence string across multiple lines you end the line without a space and start the new with a space. Can you try to be doing the opposite? It's how we do it in the rest of the code.

Really minor nitpick to keep in mind. Here and in all other places you do it.

Suggested change
'Withdraw 1003.70342593701668535 GRT'
' from indexer 0x6125eA331851367716beE301ECDe7F38A7E429e7'
'Withdraw 1003.70342593701668535 GRT '
'from indexer 0x6125eA331851367716beE301ECDe7F38A7E429e7'

@LefterisJP LefterisJP merged commit dec19d6 into rotki:develop Oct 9, 2023
15 checks passed
@gitpoap-bot
Copy link

gitpoap-bot bot commented Oct 9, 2023

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

GitPOAP: 2023 rotki Contributor:

GitPOAP: 2023 rotki Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.

@LefterisJP LefterisJP temporarily deployed to cassette-merge October 9, 2023 10:51 — with GitHub Actions Inactive
@rotkibot
Copy link

rotkibot commented Oct 9, 2023

rotki/test-caching/tree/issue_2044_the_graph_staking was successfully merged

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.

None yet

4 participants