Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Create golang/cosmos #2062

Merged
merged 5 commits into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,13 @@ on:
- "@agoric/sdk@*"

jobs:
docker-godeps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Save Git revision
run: git log -1 --format='%H' > packages/cosmic-swingset/lib/git-revision.txt
- name: Build Go dependencies image
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: agoric/cosmic-swingset
dockerfile: packages/cosmic-swingset/Dockerfile
context: packages/cosmic-swingset
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
snapshot: true
tags: latest

docker-sdk:
needs: docker-godeps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Save Git revision
run: git rev-parse HEAD > packages/cosmic-swingset/lib/git-revision.txt
- name: Build SDK image
# needs agoric/cosmic-swingset:latest
uses: elgohr/Publish-Docker-Github-Action@master
with:
name: agoric/agoric-sdk
Expand Down
6 changes: 3 additions & 3 deletions packages/cosmic-swingset/go.mod → go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/Agoric/cosmic-swingset
module github.com/Agoric/agoric-sdk

go 1.14

Expand Down Expand Up @@ -29,6 +29,6 @@ replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alp
// replace github.com/cosmos/cosmos-sdk => github.com/agoric-labs/cosmos-sdk v0.34.4-0.20201011165527-9684bf64c2db

// For testing against a local cosmos-sdk or tendermint
// replace github.com/cosmos/cosmos-sdk => ../../../forks/cosmos-sdk
// replace github.com/cosmos/cosmos-sdk => ../forks/cosmos-sdk

// replace github.com/tendermint/tendermint => ../../../forks/tendermint
// replace github.com/tendermint/tendermint => ../forks/tendermint
5 changes: 5 additions & 0 deletions packages/cosmic-swingset/go.sum → go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4er
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0=
Expand Down Expand Up @@ -268,6 +269,7 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
Expand Down Expand Up @@ -492,6 +494,7 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
Expand Down Expand Up @@ -617,6 +620,7 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
Expand Down Expand Up @@ -936,6 +940,7 @@ gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o=
Expand Down
91 changes: 91 additions & 0 deletions golang/cosmos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# OS
.DS_Store
*.swp
*.swo
.vscode
.idea

# Build
vendor
.vendor-new
build

# IDE
.idea/
*.iml
node_modules
t[0-9]/

ve[0-9]/
ve[0-9]-client/
*.egg-info/
__pycache__/
chains
solo
solo/

# emacs
*~

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next
lib/git-revision.txt
/binding.gyp
*-stamp
build/
152 changes: 152 additions & 0 deletions golang/cosmos/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
NAME := $(shell node -e 'console.log(require("./package.json").name)')
VERSION := $(shell node -e 'console.log(require("./package.json").version)')
COMMIT = $(shell hash=`git rev-parse --short HEAD 2>/dev/null`; if test -n "$$hash"; then echo $$hash`git diff --quiet || echo -dirty`; else cat git-revision.txt; fi)

default: all

MOD_READONLY = # -mod=readonly

BIN := $(shell echo $${GOBIN-$${GOPATH-$$HOME/go}/bin})

whitespace :=
whitespace += $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))

# process linker flags
ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=$(NAME) \
-X github.com/cosmos/cosmos-sdk/version.AppName=ag-cosmos-server \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)"

gcflags =

ifneq ($(GO_DEBUG),)
ldflags += -compressdwarf=false
gcflags += -N -l
endif

ldflags_helper = $(ldflags) \
-X github.com/cosmos/cosmos-sdk/version.AppName=ag-cosmos-helper
BUILD_FLAGS := -tags "$(build_tags)" -gcflags '$(gcflags)' -ldflags '$(ldflags)'
BUILD_FLAGS_HELPER := -tags "$(build_tags)" -gcflags '$(gcflags)' -ldflags '$(ldflags_helper)'

include Makefile.ledger

all: compile-helper compile-daemon
compile-go: compile-helper compile-libdaemon
compile-node: node-compile-gyp


compile-daemon: compile-libdaemon node-compile-gyp

# We need this so that node-gyp can be found.
node-compile-gyp:
if yarn -v >/dev/null 2>&1; then \
yarn build:gyp; \
else \
npm run build:gyp; \
fi

# Only run from the package.json build:gyp script.
compile-gyp:
cp binding.gyp.in binding.gyp
node-gyp configure build $(GYP_DEBUG) || { status=$$?; rm -f binding.gyp; exit $$status; }
rm -f binding.gyp

compile-helper: ../../go.sum
go build -v $(MOD_READONLY) $(BUILD_FLAGS_HELPER) -o build/ag-cosmos-helper ./cmd/helper

compile-libdaemon: ../../go.sum
go build -v $(MOD_READONLY) $(BUILD_FLAGS) -buildmode=c-shared -o build/libagcosmosdaemon.so ./cmd/libdaemon/main.go
test "`uname -s 2>/dev/null`" != Darwin || install_name_tool -id $$PWD/build/libagcosmosdaemon.so build/libagcosmosdaemon.so

go-mod-cache: ../../go.sum
@echo "--> Download go modules to local cache"
@go mod download

../../go.sum: ../../go.mod
@echo "--> Ensure dependencies have not been modified"
GO111MODULE=on go mod verify

###############################################################################
### Protobuf ###
###############################################################################

proto-gen: proto-tools
./scripts/protocgen.sh

proto-lint: proto-tools
buf check lint --error-format=json

proto-check-breaking: proto-tools
buf check breaking --against-input '.git#branch=master'

TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.0-rc3/proto/tendermint
GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
IBC_PROTO_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/master/proto/ibc/core
COSMOS_SDK_PROTO_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/master/proto/cosmos/base

GOGO_PROTO_TYPES = third_party/proto/gogoproto
IBC_CHANNEL_TYPES = third_party/proto/ibc/core/channel/v1
IBC_CLIENT_TYPES = third_party/proto/ibc/core/client/v1
SDK_QUERY_TYPES = third_party/proto/cosmos/base/query/v1beta1

proto-update-deps:
mkdir -p $(GOGO_PROTO_TYPES)
curl -sSL $(GOGO_PROTO_URL)/gogoproto/gogo.proto > $(GOGO_PROTO_TYPES)/gogo.proto

mkdir -p $(IBC_CHANNEL_TYPES)
curl -sSL $(IBC_PROTO_URL)/channel/v1/channel.proto > $(IBC_CHANNEL_TYPES)/channel.proto

mkdir -p $(IBC_CLIENT_TYPES)
curl -sSL $(IBC_PROTO_URL)/client/v1/client.proto > $(IBC_CLIENT_TYPES)/client.proto

mkdir -p $(SDK_QUERY_TYPES)
curl -sSL $(COSMOS_SDK_PROTO_URL)/query/v1beta1/pagination.proto > $(SDK_QUERY_TYPES)/pagination.proto


UNAME_S ?= $(shell uname -s)
UNAME_M ?= $(shell uname -m)

BUF_VERSION ?= 0.11.0

PROTOC_VERSION ?= 3.11.2
ifeq ($(UNAME_S),Linux)
PROTOC_ZIP ?= protoc-${PROTOC_VERSION}-linux-x86_64.zip
endif
ifeq ($(UNAME_S),Darwin)
PROTOC_ZIP ?= protoc-${PROTOC_VERSION}-osx-x86_64.zip
endif

proto-tools: proto-tools-stamp buf

proto-tools-stamp:
echo "Installing protoc compiler..."
(cd /tmp; \
curl -OL "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/${PROTOC_ZIP}"; \
unzip -o ${PROTOC_ZIP} -d ${BIN}/.. bin/protoc 'include/*'; \
rm -f ${PROTOC_ZIP})

echo "Installing protoc-gen-gocosmos..."
go install github.com/regen-network/cosmos-proto/protoc-gen-gocosmos

# Create dummy file to satisfy dependency and avoid
# rebuilding when this Makefile target is hit twice
# in a row
touch $@

buf: buf-stamp

buf-stamp:
echo "Installing buf..."
curl -sSL \
"https://github.com/bufbuild/buf/releases/download/v${BUF_VERSION}/buf-${UNAME_S}-${UNAME_M}" \
-o "${BIN}/buf" && \
chmod +x "${BIN}/buf"

touch $@

tools-clean:
rm -f proto-tools-stamp buf-stamp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ import (
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

gaiaappparams "github.com/Agoric/cosmic-swingset/app/params"
"github.com/Agoric/cosmic-swingset/x/dibc"
"github.com/Agoric/cosmic-swingset/x/swingset"
gaiaappparams "github.com/Agoric/agoric-sdk/golang/cosmos/app/params"
"github.com/Agoric/agoric-sdk/golang/cosmos/x/dibc"
"github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package app

import (
"github.com/Agoric/cosmic-swingset/app/params"
"github.com/Agoric/agoric-sdk/golang/cosmos/app/params"
"github.com/cosmos/cosmos-sdk/std"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"msvs_settings": {
"VCCLCompilerTool": { "ExceptionHandling": 1 },
},
"sources": [ "lib/agcosmosdaemon-node.cc" ],
"sources": [ "src/agcosmosdaemon-node.cc" ],
"include_dirs": [
"<!@(node -p \"require('node-addon-api').include\")",
"<!@(node -p \"require('napi-thread-safe-callback').include\")"
],
"dependencies": ["<!(node -p \"require('node-addon-api').gyp\")"],
"libraries": [ "-Wl,-rpath,<!(pwd)/lib", "<!(pwd)/lib/libagcosmosdaemon.so" ],
"libraries": [ "-Wl,-rpath,<!(pwd)/build", "<!(pwd)/build/libagcosmosdaemon.so" ],
"conditions": [
['OS=="mac"', {
'cflags+': ['-fvisibility=hidden'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"os"
"path/filepath"

"github.com/Agoric/cosmic-swingset/app"
"github.com/Agoric/cosmic-swingset/lib/daemon"
"github.com/Agoric/agoric-sdk/golang/cosmos/app"
"github.com/Agoric/agoric-sdk/golang/cosmos/daemon"
)

func main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"errors"
"os"

"github.com/Agoric/cosmic-swingset/lib/daemon"
swingset "github.com/Agoric/cosmic-swingset/x/swingset"
"github.com/Agoric/agoric-sdk/golang/cosmos/daemon"
swingset "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset"
)

type goReturn = struct {
Expand Down
Loading