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

Transition to Go Modules #21

Closed
StephenButtolph opened this issue Mar 17, 2020 · 2 comments
Closed

Transition to Go Modules #21

StephenButtolph opened this issue Mar 17, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@StephenButtolph
Copy link
Contributor

Because we are requiring go >= 1.13, we should be transitioning to using go modules.

@swdee
Copy link
Contributor

swdee commented Mar 18, 2020

I took a look at this and its not straight forward due to the salticidae-go package and how it builds the salticidae dependencies with cmake before doing the go build. Under Go modules a "version" of salticidae-go gets installed under $GOPATH/pkg/mod/ - but this introduces the issue where Go protects all the files under $GOPATH/pkg/mod/ from being changed so building inside won't work.

To work around this issue, I think the simplest way is to decouple things and not build salticidae as apart of the salticidae-go package, but rather distribute salticidae as a tarball which is built and installed in the OS first as a library.

What are your thoughts?

StephenButtolph added a commit that referenced this issue Mar 31, 2020
forbid new blockchains from being validated by default subnet
@swdee
Copy link
Contributor

swdee commented Apr 2, 2020

I looked at this again today and here are the steps that would allow the project to move to Go modules.

The process requires the salticidae C library to be installed into the OS lib and include directories. The following steps outline how to compile this on Ubuntu/Debian which would be a prerequisite for developers. I would recommend this library to be available as a deb/rpm on your own YUM and APT repositories for general users so they don't need to compile.

Compile Salticidae

Install required build tools

apt-get install  libssl-dev libuv1-dev cmake make g++

Compile the specific branch of salticidae used by gecko

cd /tmp
git clone https://github.com/Determinant/salticidae.git
cd salticidae
# checkout version use by go bindings
git checkout 4fed5578db7714d8317d1bfe9262143d25034d00
# compile
cmake .
make
make install

This creates /usr/local/lib/libsalticidae.a and places the header files into /usr/local/include/salticidae/

Salticidae Go Bindings

The github.com/ava-labs/salticidae-go project needs the following code change made to https://github.com/ava-labs/salticidae-go/blob/3dfa2f843f67a037b7be0a829885c120879a9a50/salticidae.go#L2 by adding the following LDFLAGS for CGO. This line must be above the #include "salticidae/util.h line.

// #cgo LDFLAGS: -lsalticidae -luv -lssl -lcrypto -lstdc++

With this change then go build will now successfully complete without the need of make or build scripts.

Convert Gecko to Go Modules

Then to convert the gecko project over to Go Modules;

Git clone the gecko project and initialise it.

cd /tmp
git clone https://github.com/ava-labs/gecko.git
cd gecko
go mod init github.com/ava-labs/gecko

Ordinarily the next step to follow would be to build the dependencies with go mod tidy however one of the dependencies recently introduced modules into its own code base and they have subsequently broken it as documented here influxdata/influxdb#16901

To work around this current issue force use of influxdb version 1.7.9, instead of latest 1.7.10 by running.

go mod edit -require github.com/influxdata/[email protected]

Then complete dependency build.

go mod tidy

This completes the conversion to Go Modules.

Build Gecko

We can then build Gecko without the build script.

cd main/
go build
./main --help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants