1

Got Visual Studio Code. Got geth in some folder or other. Installed go extension to Visual Studio Code. Installed go tools via Visual Studio Code (including Delve)

Now what? How do I build, run, debug etc?

  • geth is built with make , if you want to build it with some other IDE, you will have to copy all dependencies which go in the vendor directory. If you are kind of the level of developer to build your own proprietary client (which on open source software is kinda difficult due to license issues) then you should know well enough how to configure Go paths in your IDE – Nulik Feb 27 '18 at 3:15
  • The protocol is not covered by a license I think, and the code itself will be licensed for closed source, according to Ethereum Foundation. I am writing the client in c#, i just need geth running to compare runtime behaviour.Why by the way MAKE and not go build? – Sentinel Feb 27 '18 at 7:14
  • the protocol is not patented so you can implement it your own way. I doubt you can close a GPL licensed code unless you have a private agreement with Ethereum Foundation, and btw it is only a part of the code included in the tar ball. You would have to speak with every code author to get permission to close it. Check the dependencies which are in the vendor directory. – Nulik Feb 27 '18 at 12:51
  • the make uses go build inside, so you can use go build too, you just have to copy the dependencies to your GOPATH – Nulik Feb 27 '18 at 12:52
  • @Nulik not sure what you are referring to. If I write my own client, from scratch, it is my code. Aside from that the Eth foundation explicitly state in their licensing page that they have no license defined yet and when they do they intend to make sure it supports on-premise private and closed source deployments. – Sentinel Feb 27 '18 at 22:19
3

OK I found that basically geth can be taken from git into a local folder, which should match a folder structure prescribed by golang and is available in their documentation online.

The 'Build Ethereum' online wiki pages recommend to install the golang tools using 'chocolatey', but Visual Studio Code also has similar install routines for go tools, which are also described online. (Btw I had problems with chocolatey. I happened to be downloading and installing Reason 10 for some synth work and chocolatey got confused and put MingW (which I think I don't need actually) into Reason 10. When I used chocolatey do uninstall MingW it also uninstalled Reason 10. Cool!)

From there an environment variable needs to be set called GOPATH which points to that folder containing the geth sources. Then Visual Studio Code needs to be configured to run "go build" or "go install" commands. I updated the tasks.json to look like this:

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
    {
        "label": "Make Geth",
        "type": "shell",
        "command": "go",
        "args": [
            "install",
            "./..."
        ],
        "group": {
            "kind": "build",
            "isDefault": true
        },

    }]
}

I also configured the debugger by adding the following launch.json into the .vscode workspace subfolder. This, surprisingly, works like a charm. Just launch the process in your workspace and as if by magic, breakpoints get hit. Note that your GOPATH should include the semicolon separated list of GOPATHS, one to your geth go-workspace and one to the default in C:\users\home where the Delve tool was installed (I think)

{
"version": "0.2.0",
"configurations": [
    {
        "name": "Launch",
        "type": "go",
        "request": "launch",
        "mode": "exec",
        "remotePath": "",
        "port": 2345,
        "host": "127.0.0.1",
        "program": "C:\\Geth\\gs\\bin\\geth.exe",
        "env": {},
        "args": ["--datadir",
             "/tmp/eth/60/01" ,
            "--verbosity",
            "9",
            "--nodiscover", 
            "--bootnodes",
            "enode://c50f8c5a50b898ab66231754855c582548ce722311e73c5e664a563ff35d8bddb26c10c74c2ebe62c69c6c7ed00031ef3e2d7fd563ff77cff91775cd3f07e4c3@[::]:30301",  

            "--port",
            "30303", 
            "--rpcport",
            "8101",
            "console 2"],
        "showLog": true
    }]
}

Note that I am using a local private bootnode in the above config. Remove this if you don't want it. Also, the separation of args like that was necessary. For some reason specifying eg "--rpcport 8101" as an arg failed.

IPC is not disabled. With Delve there is no support at time of writing in VSCode for reading from STDIN. So it is not possible to run and test different commands (eg: Add Peer) that way. What I did to get around that was in CMD (admin) go to the folder where geth is and run the following (after geth had been started and running in VSCode/Delve):

geth attach ipc:\\.\pipe\geth.ipc
0

As far as I'm aware Geth is used primarily for running nodes, mining etc. Correct me if I'm wrong. You'll probably want to use web3 if you're trying to add functionality to a Dapp (I assume you're trying to do this).

  • 1
    In short, I am not using web3, I am writing my own client. – Sentinel Feb 26 '18 at 23:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.