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

Explicit provider ETH addr instead of derived from ETH pub key #336

Merged
merged 14 commits into from
Jun 3, 2019

Conversation

tworec
Copy link
Contributor

@tworec tworec commented Apr 15, 2019

Provider ETH address used explicitly instead of a Provider's public key in WantToComputeTask

Resolves (partly) golemfactory/golem-unlimited#217
complemetary to golemfactory/golem#4170

@tworec tworec requested review from shadeofblue and jiivan April 15, 2019 21:43
@codecov-io
Copy link

codecov-io commented Apr 15, 2019

Codecov Report

Merging #336 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #336      +/-   ##
==========================================
+ Coverage   94.84%   94.85%   +<.01%     
==========================================
  Files          31       31              
  Lines        2231     2234       +3     
==========================================
+ Hits         2116     2119       +3     
  Misses        115      115

jiivan
jiivan previously requested changes Apr 17, 2019
Copy link
Contributor

@jiivan jiivan left a comment

Choose a reason for hiding this comment

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

It duplicates #334 Will wait with review unit it's finished.

shadeofblue
shadeofblue previously approved these changes May 10, 2019
Copy link
Contributor

@shadeofblue shadeofblue left a comment

Choose a reason for hiding this comment

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

👍

shadeofblue
shadeofblue previously approved these changes May 13, 2019
@jiivan jiivan dismissed their stale review May 13, 2019 12:09

Outdated


from golem_messages import message


def pubkey_to_address(pubkey: str) -> str:
"""
convert a hex-encoded pubkey into a checksummed address
convert pubkey into a checksummed address
pubkey might be hex str or bytes or int
Copy link
Contributor

Choose a reason for hiding this comment

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

No, we don't do that here. pubkey is a string, is typed as such and leave it this way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why is that? can you provide some rationale?

Copy link
Contributor

Choose a reason for hiding this comment

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

throw-anything-as-an-argument-and-hope-for-the-best just doesn't seem like a maintainable approach. Easier to write and read code when you know the type of the variable.
Also better integration with tools like static analyzer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is how it works in eth lib used by us here. Its a standard there. We support three types of input, not 'anything': string, hexstr and int.

It is usable in such a form but I can introduce dedicated params...

Copy link
Contributor

Choose a reason for hiding this comment

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

But we don't need to support three types. At this point almost everywhere we're working on strings. So just provide strings and that's it.

Copy link
Contributor Author

@tworec tworec May 13, 2019

Choose a reason for hiding this comment

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

I needed it to support bytes representation and it seems to me I've found a pretty concise and effective way to achieve it. Much better, I think, that you can observe 5 lines below -- just expand this view and you'll see, that next util function already supports different types on the single input parameter.

This is "The Python Way":

One thing you've noticed must be corrected indeed -- the parameter type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Python way is also writing unmaintainable and illegible code, doesn't mean we should follow that.
This is the first Union type hint in this repository - meaning, what I said earlier, we don't do that here. We should be consistent within the same project and this case is way too minor to break current conventions.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't approve this change but I have nothing else to add and am dismissing my review since this won't be resolved.

Krigpl
Krigpl previously requested changes May 14, 2019

from golem_messages import message


def pubkey_to_address(pubkey: str) -> str:
"""
convert a hex-encoded pubkey into a checksummed address
convert pubkey into a checksummed address
pubkey might be hex str or bytes or int
Copy link
Contributor

Choose a reason for hiding this comment

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

Python way is also writing unmaintainable and illegible code, doesn't mean we should follow that.
This is the first Union type hint in this repository - meaning, what I said earlier, we don't do that here. We should be consistent within the same project and this case is way too minor to break current conventions.

@Krigpl Krigpl dismissed their stale review May 14, 2019 13:19

because of reasons

@tworec tworec changed the title Explicit provider ETH key instead of derived from ETH pub key Explicit provider ETH addr instead of derived from ETH pub key May 17, 2019
@@ -16,10 +17,7 @@ class Meta:
model = dt_tasks.TaskHeader
exclude = ('requestor_public_key', )

requestor_public_key = factory.LazyFunction(
lambda: encode_key_id(cryptography.ECCx(None).raw_pubkey)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should still be LazyFunction to get different pubkeys everytime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

from tests.message import mixins, helpers
import factory
Copy link
Contributor

Choose a reason for hiding this comment

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

Why move this import?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my pylint was complaining, reverting

import math
import time
import unittest
from datetime import datetime, timedelta
Copy link
Contributor

Choose a reason for hiding this comment

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

Now it's not in alphabetical order. I preferred previous ordering.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

made by pycharm import optimizator, reverting

@shadeofblue shadeofblue merged commit 0f3af63 into master Jun 3, 2019
@shadeofblue shadeofblue deleted the provider_eth_addr branch June 3, 2019 10:22
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.

5 participants