Skip to content

Commit

Permalink
Merge pull request #1353 from mesg-foundation/dev
Browse files Browse the repository at this point in the history
Release v0.15.0
  • Loading branch information
Nicolas Mahé authored Sep 23, 2019
2 parents 5407eb7 + beef8d6 commit 9062446
Show file tree
Hide file tree
Showing 93 changed files with 2,460 additions and 2,000 deletions.
7 changes: 4 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ run_on_machine: &run_on_machine

run_on_docker: &run_on_docker
docker:
- image: circleci/golang:1.11.4
- image: circleci/golang:1.13.0

restore_go_mod_cache: &restore_go_mod_cache
- restore_cache:
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:

"lint":
docker:
- image: golangci/golangci-lint:v1.12
- image: golangci/golangci-lint:v1.18
environment:
- GOCACHE: *go_cache_dir
steps:
Expand All @@ -91,9 +91,10 @@ jobs:
<<: *run_on_machine
steps:
- checkout
- run: docker build -t mesg/engine:$CIRCLE_TAG -t mesg/engine:latest --build-arg version=$CIRCLE_TAG .
- run: docker build -t mesg/engine:$CIRCLE_TAG -t mesg/engine:latest -t `echo mesg/engine:$CIRCLE_TAG | cut -d'.' -f1-2` --build-arg version=$CIRCLE_TAG .
- run: docker login -u $DOCKER_USER -p $DOCKER_PASS
- run: docker push mesg/engine:$CIRCLE_TAG
- run: docker push `echo mesg/engine:$CIRCLE_TAG | cut -d'.' -f1-2`
- run: docker push mesg/engine:latest

workflows:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ vendor
tmp-systemservices

# tendermint
.tendermint-validator/
.tendermint-validator/

# gogo extension
gogo/
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ linters:
- gosec
- lll
- prealloc
- funlen
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,35 @@
#### Removed
#### Experimental

## [v0.15.0](https://github.com/mesg-foundation/engine/releases/tag/v0.15.0)

#### Breaking Changes

- ([#1329](https://github.com/mesg-foundation/engine/pull/1329)) Calculate process hash based on the nodes.
- ([#1335](https://github.com/mesg-foundation/engine/pull/1335)) Remove plural form from instance list proto service.
- ([#1337](https://github.com/mesg-foundation/engine/pull/1337)) Namespace protobuf types and api.

#### Experimental

- ([#1267](https://github.com/mesg-foundation/engine/pull/1267)) Implement service SDK with Cosmos.
- ([#1308](https://github.com/mesg-foundation/engine/pull/1308)) Simplify cosmos keybase by just creating a NewMnemonic helper.
- ([#1331](https://github.com/mesg-foundation/engine/pull/1331)) Add --exp to dev command.
- ([#1343](https://github.com/mesg-foundation/engine/pull/1343)) Add account sdk and its api.

#### Added

- ([#1316](https://github.com/mesg-foundation/engine/pull/1316)) Add constant to process map.
- ([#1317](https://github.com/mesg-foundation/engine/pull/1317)) Add tests for orchestrator.
- ([#1342](https://github.com/mesg-foundation/engine/pull/1342)) Build and publish docker image with minor-only tag.

#### Changed

- ([#1305](https://github.com/mesg-foundation/engine/pull/1305)) Use protobuf struct in create function of service SDK.
- ([#1321](https://github.com/mesg-foundation/engine/pull/1321)) Only force hash calculation on interface containing struct.
- ([#1322](https://github.com/mesg-foundation/engine/pull/1322)) Update golang to 1.13.
- ([#1323](https://github.com/mesg-foundation/engine/pull/1323)) Remove unused docker api mocks.
- ([#1347](https://github.com/mesg-foundation/engine/pull/1347)) Update marketplace system service with latest mesg-js.

## [v0.14.2](https://github.com/mesg-foundation/engine/releases/tag/v0.14.2)

#### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# base Go image version.
FROM golang:1.11.4-stretch AS build
FROM golang:1.13.0-stretch AS build

RUN apt-get update && \
apt-get install -y jq && \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.tools
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# base Go image version.
FROM golang:1.11.4-stretch
FROM golang:1.13.0-stretch

WORKDIR /project

Expand Down
75 changes: 75 additions & 0 deletions account/account.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions config/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"

"github.com/mesg-foundation/engine/instance"
"github.com/mesg-foundation/engine/service"
"github.com/mesg-foundation/engine/protobuf/api"
)

// Default compiled version of the service. These compiled versions are overritten by the build
Expand All @@ -30,7 +30,7 @@ var (
type ServiceConfig struct {
Key string
Env map[string]string
Definition *service.Service
Definition *api.CreateServiceRequest
Instance *instance.Instance
}

Expand Down Expand Up @@ -58,13 +58,13 @@ func (c *Config) setupServices() error {
}

func (c *Config) createServiceConfig(key string, compilatedJSON string, env map[string]string) (*ServiceConfig, error) {
var srv service.Service
if err := json.Unmarshal([]byte(compilatedJSON), &srv); err != nil {
var req api.CreateServiceRequest
if err := json.Unmarshal([]byte(compilatedJSON), &req); err != nil {
return nil, err
}
return &ServiceConfig{
Key: key,
Definition: &srv,
Definition: &req,
Env: env,
}, nil
}
5 changes: 4 additions & 1 deletion core/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,11 @@ func main() {
logrus.WithField("module", "main").Fatalln(err)
}

// create cosmos client
client := cosmos.NewClient(node, app.Cdc(), kb, cfg.Cosmos.ChainID)

// init sdk
sdk, err = enginesdk.New(c, instanceDB, executionDB, processDB, cfg.Name, strconv.Itoa(port))
sdk, err = enginesdk.New(client, app.Cdc(), kb, c, instanceDB, executionDB, processDB, cfg.Name, strconv.Itoa(port))
if err != nil {
logrus.WithField("module", "main").Fatalln(err)
}
Expand Down
29 changes: 17 additions & 12 deletions cosmos/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,22 @@ func NewClient(node *node.Node, cdc *codec.Codec, kb keys.Keybase, chainID strin
}
}

// QueryWithData is abci.query wraper with errors check.
// It retruns slice of bytes, height and an error.
func (c *Client) QueryWithData(path string, data []byte) ([]byte, int64, error) {
result, err := c.ABCIQuery(path, data)
// Query is abci.query wrapper with errors check and decode data.
func (c *Client) Query(path string, ptr interface{}) error {
result, err := c.ABCIQuery(path, nil)
if err != nil {
return nil, 0, err
return err
}
resp := result.Response
if !resp.IsOK() {
return nil, 0, errors.New(resp.Log)
if !result.Response.IsOK() {
return errors.New(result.Response.Log)
}
return resp.Value, resp.Height, nil
return c.cdc.UnmarshalJSON(result.Response.Value, ptr)
}

// BuildAndBroadcastMsg builds and signs message and broadcast it to node.
func (c *Client) BuildAndBroadcastMsg(msg sdktypes.Msg, accName, accPassword string, accNumber, accSeq uint64) (*tenderminttypes.TxResult, error) {
func (c *Client) BuildAndBroadcastMsg(msg sdktypes.Msg, accName, accPassword string, accNumber, accSeq uint64) (*abci.ResponseDeliverTx, error) {
txBuilder := NewTxBuilder(c.cdc, accNumber, accSeq, c.kb, c.chainID)
// TODO: cannot sign 2 tx at the same time. Maybe keybase cannot be access at the same time. Add a lock?
signedTx, err := txBuilder.BuildAndSignStdTx(msg, accName, accPassword)
if err != nil {
return nil, err
Expand All @@ -72,18 +71,24 @@ func (c *Client) BuildAndBroadcastMsg(msg sdktypes.Msg, accName, accPassword str
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
defer cancel()

out, err := c.Subscribe(ctx, "", "tx.hash='"+txres.Hash.String()+"'")
subscriber := "engine"
query := tenderminttypes.EventQueryTxFor(encodedTx).String()
out, err := c.Subscribe(ctx, subscriber, query)
if err != nil {
return nil, err
}
defer c.Unsubscribe(ctx, subscriber, query)

select {
case result := <-out:
data, ok := result.Data.(tenderminttypes.EventDataTx)
if !ok {
return nil, errors.New("result data is not the right type")
}
return &data.TxResult, nil
if data.TxResult.Result.IsErr() {
return nil, errors.New("an error occurred in transaction")
}
return &data.TxResult.Result, nil
case <-ctx.Done():
return nil, errors.New("i/o timeout")
}
Expand Down
15 changes: 4 additions & 11 deletions cosmos/keybase.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,12 @@ func NewKeybase(dir string) (*Keybase, error) {
return &Keybase{kb}, nil
}

// GenerateAccount creates an account.
func (kb *Keybase) GenerateAccount(name, mnemonic, password string) (keys.Info, error) {
// NewMnemonic returns a new mnemonic phrase.
func (kn *Keybase) NewMnemonic() (string, error) {
// read entropy seed straight from crypto.Rand and convert to mnemonic
entropySeed, err := bip39.NewEntropy(mnemonicEntropySize)
if err != nil {
return nil, err
}

if mnemonic == "" {
mnemonic, err = bip39.NewMnemonic(entropySeed)
if err != nil {
return nil, err
}
return "", err
}
return kb.CreateAccount(name, mnemonic, "", password, 0, 0)
return bip39.NewMnemonic(entropySeed)
}
3 changes: 3 additions & 0 deletions cosmos/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ func (m AppModule) NewQuerierHandler() sdk.Querier {
return func(request sdk.Request, path []string, req abci.RequestQuery) ([]byte, sdk.Error) {
data, err := m.querier(request, path, req)
if err != nil {
if errsdk, ok := err.(sdk.Error); ok {
return nil, errsdk
}
return nil, sdk.ErrInternal(err.Error())
}
res, err := m.cdc.MarshalJSON(data)
Expand Down
2 changes: 1 addition & 1 deletion cosmos/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewNode(app *App, kb *Keybase, cfg *tmconfig.Config, ccfg *config.CosmosCon
cdc := app.Cdc()

// generate first user
account, err := kb.GenerateAccount(ccfg.GenesisAccount.Name, ccfg.GenesisAccount.Mnemonic, ccfg.GenesisAccount.Password)
account, err := kb.CreateAccount(ccfg.GenesisAccount.Name, ccfg.GenesisAccount.Mnemonic, "", ccfg.GenesisAccount.Password, 0, 0)
if err != nil {
return nil, err
}
Expand Down
10 changes: 7 additions & 3 deletions dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ set -e

DIR=$(pwd)

# network to connect multiple engine instances
TENDERMINT_NETWORK="mesg-tendermint"
# Flags
if [[ $* == *--exp* ]]; then
EXPERIMENTAL_FLAGS+=" --experimental-network"
fi

# mesg config variables
MESG_NAME=${MESG_NAME:-"engine"}
Expand All @@ -15,6 +17,8 @@ MESG_LOG_FORCECOLORS=${MESG_LOG_FORCECOLORS:-"false"}
MESG_LOG_LEVEL=${MESG_LOG_LEVEL:-"debug"}
MESG_SERVER_PORT=${MESG_SERVER_PORT:-"50052"}

# network to connect multiple engine instances
TENDERMINT_NETWORK="mesg-tendermint"
TENDERMINT_HOME_CONFIG="$MESG_PATH/tendermint"
TENDERMINT_NETWORK_ALIAS=${TENDERMINT_NETWORK_ALIAS:-$MESG_NAME}
TENDERMINT_VALIDATOR_NAME=${TENDERMINT_VALIDATOR_NAME:-"validator"}
Expand Down Expand Up @@ -155,6 +159,6 @@ docker service create \
--network name=$TENDERMINT_NETWORK,alias=$TENDERMINT_NETWORK_ALIAS \
--publish $MESG_SERVER_PORT:50052 \
$TENDERMINT_VALIDATOR_PORT_PUBLISH \
mesg/engine:$VERSION ./engine --experimental-network
mesg/engine:$VERSION ./engine $EXPERIMENTAL_FLAGS

docker service logs --follow --raw $MESG_NAME
Loading

0 comments on commit 9062446

Please sign in to comment.