-
Notifications
You must be signed in to change notification settings - Fork 126
Support for Local PoW #245
Conversation
todofixthis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the idea! Agreed, needs tests — although assuming Ccurl.interface.py has sufficient test coverage, we could make good use of mocks to avoid having to do any actual PoW in the tests.
Recommend using an approach that more closely matches what we're doing for min_weight_magnitude.
To perform PoW (attach_to_tangle) locally. BaseAdatper class has a new attribute, local_pow, that is set to False by default. By declaring a new api instance with local_pow=True, attach_to_tangle calls will be handled by an interface to the ccurl library. The change is backward compatible, since if local_pow argument is omitted, behavior defaults back to 'normal'. Feature can be disabled/enabled dynamically using the api's set_local_pow() function.
todofixthis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks @lzpap! Left a few suggestions; this can be merged without requiring further review.
| def test_sandbox_adapter(self): | ||
| """ | ||
| Test if local_pow feature works with SandboxAdapter. | ||
| """ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 Out of curiosity, is the sandbox node still running? Is it time to remove SandboxAdapter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I need to be enlightened on this topic. What's the story with "the sandbox node"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was a couple of years ago now, the IF stood up a special node that would allow clients to outsource the PoW for attachToTangle. It was an asynchronous process; the client would send the request, and it would get a job ID back. The client would then need to poll the node until the PoW had been finished, and then it could retrieve the trytes ready to broadcast.
Announcement here:
https://blog.iota.org/iota-sandbox-developer-environment-c70c8206fe5f
The source code for the sandbox node itself is here:
https://github.com/iotaledger/sandbox
Related issues: #139 #228
To perform PoW (attach_to_tangle) locally, BaseAdatper class has a new attribute, local_pow,
that is set to False by default (and therefore it is backward compatible). By declaring a new api instance with local_pow=True, attach_to_tangle calls will be handled by an interface to the ccurl library. The interface can be installed via an extension module to pyota:
Or alternatively through following the steps in the README at:
https://github.com/lzpap/ccurl.interface.py
Or directly from PyPi:
TODO: write testsPlease share your thoughts about the change :)