Contract development

sjosephsjoseph Member Posts: 30

Quick question on how folks are doing the development / testing of contracts.
My laptop takes forever to mine ether and I am not able get enough to learn/test/iterate on contracts. Does it make sense to create a private chain ( with --maxpeers=0) and test out the contracts before actual deployment? Other ways?

Comments

  • SmithgiftSmithgift Member Posts: 64
    I'm on a laptop that is actually incapable of mining, but I'm still developing.

    My primary tool is the Mix IDE (found only on the develop branch of cpp-ethereum). Its main feature (and the main reason I use it) is that it creates its own private debug version of the blockchain, which allows you to have accounts start with arbitrary amounts of Ether. and mining a block is instant. It gives immediate notice of syntax errors when editing solidity, which allows you to stumble into the correct syntax. It also has its own webserver/browser for developing the front-end. It's supposed to even be able to deploy contracts, but I haven't figured that part out yet.

    I'm also working on a private chain. I myself use a separate computer to actually mine blocks on the private chain, and by separate computer I mean a virtualized Ubuntu that CPU mines with its sole available core. As I'm the only one on my own network, it gets one hundred percent of the blocks and gets them at an average of 12 seconds per block.

    Again, though, I recommend Mix. It's far far easier, even with its issues.
  • sjosephsjoseph Member Posts: 30

    Thanks @Smithgift .. This is really helpful... I was thinking of using Cosmos for dev on a geth private chain ( with --maxpeers=0) . Will take Mix for a spin. Wasn't sure if it was ready

    Anyone else have other dev environment setup/tools
  • tomgalvintomgalvin Member Posts: 10
    If you want to do actual work on the testnet, you can get some free ether from https://zerogox.com/ethereum/wei_faucet, although, be warned that this is more for the final phase of testing, as you have to deal with constant forks and stuff.
  • sjosephsjoseph Member Posts: 30
    Thanks @tomgalvin . I dd try the faucet a few times but the site seems to crash quite often or is down quite frequently :neutral:
  • YarkoLYarkoL Member Posts: 9
    I use private network on Ubuntu for contract development with Geth. It's great because I don't have
    to setup VM's and stuff, just open two consoles with different datadirs and ports and hook
    up the one with the other as a bootnode. Mining testnet ether is also very easy.

    What I cannot do is use registry for addresses and metadata, although I guess it is possible
    to implement one's own. But that is no big hurdle. All in all I'm very impressed with
    the capabilities of Ethereum so far.
  • PranayPranay Member Posts: 58
    Private chain is better option for development and testing. We are doing the same.
  • oomooomo Member Posts: 31
    @Pranay and I are on same team and as he mentioned we have a working demo/development environment. This is our environment

    One Ubuntu Server -
    • Two geth nodes running. Each node running in different "datadir", with different RPC ports. One node in mining mode and other mode in non-mining mode
    • Both on private test net (set up by passing non-zero networkId)
    • Bind to RPCADDR of 0.0.0.0 - This allows us to use Cosmo to access our node
    • Not setting peers, so it defaults to whatever is set by geth (I believe it is 25).
    • Node.js running web3 and express as an interface to our web application.
    We have been using Cosmo (I use the one hosted on cosmo.to and set the rpc provider pointing to our nodes) We love it - even though there are some limitation (communicated to Developer already) and he responds to them promptly.

    I have few questions for people who are running in similar setup (private network, etc.)
    1. Setting maxpeers=0 will disable network. Do I still have to run two nodes?
    2. In Private network, do I really need two nodes as I current have?
    3. In two nodes private network, do I have to have one node in mining mode (I assume I have to, as the mining node is the one processing the transaction) ?
    4. In my environment, my machine is always pegged to 100% and all that it is doing is making ether most of the time. I am not even sure what is it doing to mine those ether, especially in my private network. If I turn on the verbosity I see bunch of messages about subprotocol errors, etc. but at the same time I get messages that it is mining too. First of all, why is my CPU running 100%? And what is making the node doing to mine some ethers?
    5. We have noticed that in some cases after getting to 29,999 blocks, it cannot mine any more blocks? Is there some limitation to number of blocks private network? In this case we have restart everything again including creating new contracts, etc.
    TIA
  • sjosephsjoseph Member Posts: 30

    Thanks @oomo for the detailed setup of your dev environment. Really helpful for a lot if us here

    Here are some observations from my end
    -Setting maxpeers=0 will disable network. Do I still have to run two nodes?
    >> Setting maxpeers=0 seems to create a 1-node private network. I find this similar to having one node with a non-zero network id and maxpeers set to default. I am sure there are subtler differences and would be great if the ethereum core-devs or anyone else can provide added insight on the difference.

    -In Private network, do I really need two nodes as I current have?
    I am able to get do quite a bit of contract dev by just having a single node in private network mining mode. I assume if you want to test out distributed contract invocation scenarios then having more than 1 might be useful. But sounds like you seem to be doing it so that one node can mine and the other can act as a regular node ?

    - In my environment, my machine is always pegged to 100% and all that it is doing is making ether most of the time.
    I haven't seen this but could be because I run only one private node.
  • chocolatepumpkinchocolatepumpkin Member Posts: 10
    I'm finding the getting started guides really difficult and frankly just wrong for getting your first "Hello World" running on a laptop VM on a private test network. Also many of the guides are seriously out of date.

    I'm going to assume you are using geth. If you are using GUIs, well, how are you going to automate your testing?...

    First, you need these command line options so that mining is very cheap. Not sure if you need both, but I use them: --dev and --lightkdf. With these mining takes the standard 8 seconds per block.

    a working example command line that's running great on an Ubuntu VM inside VirtualBox on OSX El Capitan with one vCPU.

    geth --datadir ~/dapps/testing/00/ --port 30310 --rpcport 8110 --networkid 4567890 --dev --lightkdf --nodiscover --maxpeers 0 --vmdebug --verbosity 6 --pprof --pprofport 6110 console 2>> ~/dapp/testint/00/00.log


    Also, and very important due to rapid development, the version I'm running where this worked:

    [email protected]:~$ geth version
    Geth
    Version: 1.4.0-unstable
    Protocol Versions: [63 62 61]
    Network Id: 1
    Go Version: go1.5.1
    OS: linux
    GOPATH=
    GOROOT=/usr/lib/go
  • chocolatepumpkinchocolatepumpkin Member Posts: 10
    I'll also add that you don't need to have multiple instances running. Running one with multiple accounts is sufficient for contract development.

    try the "personal" API e.g. personal.newAccount("mypassword"). You can create as many accounts as you wish and transfer and contract all day.

Sign In or Register to comment.