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

Validator manager contract utils #197

Closed
hwwhww opened this issue Dec 5, 2017 · 12 comments
Closed

Validator manager contract utils #197

hwwhww opened this issue Dec 5, 2017 · 12 comments

Comments

@hwwhww
Copy link
Contributor

hwwhww commented Dec 5, 2017

Implement some APIs for shard chain validators to call the validator manager contract on main chain.

Implementation should probably remain low level. A simplistic Contract class with the following API should suffice.

  • Base class with factory class method which accepts abi and returns a ContractClass
  • ContractClass as returned by BaseContract.factory can be instantiated with a single address.
  • A method on the ContractClass for constructing a transaction (TODO: should this be a dictionary, a Message class, or something else?)

There are likely some other convenience APIs that should be added around this functionality to make common tasks easier as we find what those are.

I think this code should live in something like evm.utils.contracts.

@hwwhww hwwhww added the eth2.0 label Dec 5, 2017
@mhchia mhchia self-assigned this Dec 6, 2017
@pipermerriam pipermerriam mentioned this issue Dec 6, 2017
15 tasks
@pipermerriam pipermerriam changed the title STUB: Validator manager contract utils Validator manager contract utils Dec 6, 2017
@pipermerriam
Copy link
Member

Made some updates to try and add some clarity to how this might be implemented.

@pipermerriam
Copy link
Member

@carver looks like @mhchia may be working on this but you may be well suited to assist with implementation or just sussing out the API.

@carver
Copy link
Contributor

carver commented Dec 7, 2017

Interesting, the contract API starts to feel a lot like web3.py: http://web3py.readthedocs.io/en/latest/web3.eth.html#web3.eth.Eth.contract

Maybe we could rip out some part of web3 into a new eth-contracts library, for code reuse. Either way, I'm happy to chat about API. As you can see in the docs, web3.py uses a dict when constructing a transaction.

@mhchia
Copy link
Contributor

mhchia commented Dec 7, 2017

Yep I'm working on this. I crafted an interface for RPC handling using web3.py. For validator manager contract utils, there will be a VMC contract utils class, doing contract call using the RPC interface.
However, it is still a mess now. I think an API spec will help a lot. I will soon refactor and upload my code for you to see how I can improve the code.

@pipermerriam
Copy link
Member

pipermerriam commented Dec 7, 2017

I'm going to backpedal hard on my original suggestion since I think I may have missed something crutial.

@mhchia does this interaction happen over the JSON-RPC interface?

  • If yes then we probably should use the the web3.py contract object.
  • If no then my original suggestion holds that this should probably be minimalistic and low level.

@mhchia
Copy link
Contributor

mhchia commented Dec 8, 2017

@pipermerriam
Yes it is. Previously I used the web3.py contract object.
But after, I changed to generate the tx data of the contract call transaction on our own, using eth_abi. (referenced from here)

Now performing a contract call is performed by send_vmc_tx, specifying the function_name and args. A constant call is implemented similarly by call_vmc
The implementation underneath: VMCHandler.send_vmc_tx.
I did this is because I used web3.py and eth_tester as the backends of vmc_handler. The parameters taken for the sendTransaction of both packages are the same.
So I can just generate one parameter for both backends using the same function mk_contract_tx_obj.

If it is better to use web3.py contract object, I can change to that:)
But this way I will need to figure out a prettier solution.

@mhchia mhchia mentioned this issue Dec 8, 2017
24 tasks
@pipermerriam
Copy link
Member

@mhchia

Just in case you are not aware. You may be able to slim down to a single handler that only uses web3.py and still leverage eth-tester. Web3.py ships with a special provider web3.providers.eth_tester.EthereumTesterProvider which uses eth-tester under the hood. That would allow a single handler implementation that just delegates to web3.py or potentially for you to remove the chain_handler all-together.

@mhchia
Copy link
Contributor

mhchia commented Dec 9, 2017

@pipermerriam Thank you. It's so great! I will modify them to use web3.py altogether.

@mhchia
Copy link
Contributor

mhchia commented Dec 10, 2017

I tried EthereumTesterProvider with EthereumTester(PyEVMBackend()), however it seems there are still some of the RPCs not implemented. May I change to use that later when EthereumTesterProvider is more complete? I think I can help with that after the #206 . Or it is also fine that we can do it right away and continue to #206 ?
Ah I'm not in a hurry for this part(Since TesterChainHandler is currently enough for vmc_handler to work. Please reply only when you have spare time. I really appreciate your help! :D

@pipermerriam
Copy link
Member

@mhchia which endpoints? Depending on what they are it should be easy to implement them.

@mhchia
Copy link
Contributor

mhchia commented Dec 11, 2017

I'm really sorry that I just found I missed a word in the comment above(*I'm not in a hurry for this part...). I apologize if I made you misunderstand.
About the endpoints, it seems like miner.start() is not implemented yet in the eth_tester provider.
I will fix the endpoints that is needed and use eth-tester provider and remove the TesterChainHandler. Thank you!

@hwwhww hwwhww added this to In progress in Sharding Phase 1 - Stage 1 Jan 8, 2018
@hwwhww
Copy link
Contributor Author

hwwhww commented Jan 10, 2018

close it via #206

@hwwhww hwwhww closed this as completed Jan 10, 2018
@hwwhww hwwhww moved this from In progress to Done in Sharding Phase 1 - Stage 1 Jan 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

4 participants