Skip to content

Commit

Permalink
Merge pull request #1857 from mesg-foundation/dev
Browse files Browse the repository at this point in the history
Release v0.25.1
  • Loading branch information
Nicolas Mahé authored May 28, 2020
2 parents 0ed64d3 + 7662c15 commit 73a6b0c
Show file tree
Hide file tree
Showing 33 changed files with 313 additions and 101 deletions.
2 changes: 0 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
steps:
- checkout
- setup_remote_docker
- run: docker swarm init
- <<: *restore_go_cache
- <<: *restore_go_path
- run: make test
Expand All @@ -67,7 +66,6 @@ jobs:
sudo rm -rf /usr/local/go
curl -sSL "https://dl.google.com/go/go1.13.10.linux-amd64.tar.gz" | sudo tar -xz -C /usr/local/
echo "export PATH=$PATH:/usr/local/go/bin" >> $BASH_ENV
- run: docker swarm init
- <<: *restore_go_cache
- <<: *restore_go_path
- run: make e2e
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

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

#### Changed

- ([#1845](https://github.com/mesg-foundation/engine/pull/1845)) Set default flag gasPrice of the orchestrator to null.
- ([#1851](https://github.com/mesg-foundation/engine/pull/1851)) Remove swarm init from ci.

#### Fixed

- ([#1838](https://github.com/mesg-foundation/engine/pull/1838)) Remove min gas price from dev chain and e2e.
- ([#1841](https://github.com/mesg-foundation/engine/pull/1841)) Fix dev-starter when user stop script during the first sleep of 5 sec.
- ([#1843](https://github.com/mesg-foundation/engine/pull/1843)) Display body in lcd client on error.
- ([#1844](https://github.com/mesg-foundation/engine/pull/1844)) Add a check in LCD client if the account exists or not.
- ([#1846](https://github.com/mesg-foundation/engine/pull/1846)) Fix command execution list because of not set filter.
- ([#1848](https://github.com/mesg-foundation/engine/pull/1848)) Implement import and export functions in modules.

#### Dependencies

- ([#1835](https://github.com/mesg-foundation/engine/pull/1835)) Bump github.com/cosmos/cosmos-sdk from 0.38.3 to 0.38.4.

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

#### Breaking Changes
Expand Down
23 changes: 4 additions & 19 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/bank"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
Expand Down Expand Up @@ -315,25 +314,11 @@ func NewInitApp(

// The AnteHandler handles signature verification and transaction pre-processing
app.SetAnteHandler(
sdk.ChainAnteDecorators(
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
ante.NewMempoolFeeDecorator(),
ante.NewValidateBasicDecorator(),
ante.NewValidateMemoDecorator(app.accountKeeper),
ante.NewConsumeGasForTxSizeDecorator(app.accountKeeper),
ante.NewSetPubKeyDecorator(app.accountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators
ante.NewValidateSigCountDecorator(app.accountKeeper),
ante.NewDeductFeeDecorator(app.accountKeeper, app.supplyKeeper),
ante.NewSigGasConsumeDecorator(app.accountKeeper, auth.DefaultSigVerificationGasConsumer),
ante.NewSigVerificationDecorator(app.accountKeeper),
newForceCheckTxProxyDecorator(ante.NewIncrementSequenceDecorator(app.accountKeeper)), // innermost AnteDecorator
auth.NewAnteHandler(
app.accountKeeper,
app.supplyKeeper,
auth.DefaultSigVerificationGasConsumer,
),
// Previous implementation:
// auth.NewAnteHandler(
// app.accountKeeper,
// app.supplyKeeper,
// auth.DefaultSigVerificationGasConsumer,
// ),
)

// initialize stores
Expand Down
29 changes: 0 additions & 29 deletions app/decorator.go

This file was deleted.

2 changes: 1 addition & 1 deletion cmd/mesg-cli/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func startOrchestratorCmd(cdc *codec.Codec) *cobra.Command {
cmd.Flags().String(flagGrpcAddr, ":50052", "The address for the gRPC server to expose")
cmd.Flags().String(flagAuthorizedPubKeys, "", "The authorized pubkeys to communicate with the gRPC server")
cmd.Flags().String(flagMnemonic, "", "The account's mnemonic that will be used to sign transactions")
cmd.Flags().String(flagGasPrices, "1.0atto", "The gas price to sign tx")
cmd.Flags().String(flagGasPrices, "", "The gas price to sign tx")
cmd.Flags().String(flagExecPrice, "10000atto", "The execution price to create execution")
cmd.Flags().String(flagAccNumber, "0", "The account number of the hd path to use to derive the mnemonic")
cmd.Flags().String(flagAccIndex, "0", "The account index of the hd path to use to derive the mnemonic")
Expand Down
24 changes: 14 additions & 10 deletions cosmos/lcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ func (lcd *LCD) Get(path string, ptr interface{}) error {
return err
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return fmt.Errorf("request status code is not 2XX, got %d", resp.StatusCode)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return fmt.Errorf("request status code is not 2XX, got %d with body: %s", resp.StatusCode, body)
}
cosResp := rest.ResponseWithHeight{}
if err := lcd.cdc.UnmarshalJSON(body, &cosResp); err != nil {
return err
Expand Down Expand Up @@ -108,13 +108,13 @@ func (lcd *LCD) PostBare(path string, req interface{}, ptr interface{}) error {
return err
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return fmt.Errorf("request status code is not 2XX, got %d", resp.StatusCode)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
return fmt.Errorf("request status code is not 2XX, got %d with body: %s", resp.StatusCode, body)
}
if err := lcd.cdc.UnmarshalJSON(body, ptr); err != nil {
return err
}
Expand Down Expand Up @@ -180,14 +180,18 @@ func (lcd *LCD) getAccount() (*auth.BaseAccount, error) {
}
lcd.acc = auth.NewBaseAccount(accKb.GetAddress(), nil, accKb.GetPubKey(), 0, 0)
}
localSeq := lcd.acc.GetSequence()
if err := lcd.Get("auth/accounts/"+lcd.acc.GetAddress().String(), &lcd.acc); err != nil {
var accR *auth.BaseAccount
if err := lcd.Get("auth/accounts/"+lcd.acc.GetAddress().String(), &accR); err != nil {
return nil, err
}
if accR.Address.Empty() {
return nil, fmt.Errorf("account %q doesn't exist", lcd.acc.GetAddress().String())
}
// replace seq if sup
if localSeq > lcd.acc.GetSequence() {
lcd.acc.SetSequence(localSeq)
if lcd.acc.GetSequence() > accR.GetSequence() {
accR.SetSequence(lcd.acc.GetSequence())
}
lcd.acc = accR
return lcd.acc, nil
}

Expand Down
7 changes: 3 additions & 4 deletions cosmos/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,11 @@ func (c *RPC) GetAccount() (authExported.Account, error) {
if err != nil {
return nil, err
}
localSeq := c.acc.GetSequence()
c.acc = accR
// replace seq if sup
if localSeq > c.acc.GetSequence() {
c.acc.SetSequence(localSeq)
if c.acc.GetSequence() > accR.GetSequence() {
accR.SetSequence(c.acc.GetSequence())
}
c.acc = accR
return c.acc, nil
}

Expand Down
1 change: 1 addition & 0 deletions dev-chain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ See file `dev-genesis.json`
### Validator

Address: `mesg10cjcxje0jjdxzdq5hpqa4dc4znhuxsax2zh7mp`
Validator address: `mesgvaloper10cjcxje0jjdxzdq5hpqa4dc4znhuxsaxkrzt5d`
Pubkey: `mesgpub1addwnpepq0gwhzul5qcycxxs6r7jdzdn5q29mj2a8gmngfrcfa6l8qs2dar4s2jqycv`
Mnemonic: `fruit lock run bike eyebrow unique embrace cost parade welcome more frown oxygen crane club donate grid harsh marriage host skirt sign warfare cup`
Coins: 100000000stake (but used in gentx)
Expand Down
1 change: 1 addition & 0 deletions dev-chain/cli/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ chain-id = "mesg-dev-chain"
# orchestrtor
authorized-pubkeys = "mesgpub1addwnpepqvdrcdvg3x4tf0y5aapn47njxapdu4l0jgsjzcm2klp9a7eztva66eqnadt"
mnemonic = "neutral false together tattoo matrix stamp poem mouse chair chair grain pledge mandate layer shiver embark struggle vicious antenna total faith genre valley mandate"
gas-prices = ""
2 changes: 1 addition & 1 deletion dev-chain/validator/config/app.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The minimum gas prices a validator is willing to accept for processing a
# transaction. A transaction's fees must meet the minimum of any denomination
# specified in this config (e.g. 0.25token1;0.0001token2).
minimum-gas-prices = "1.0atto"
minimum-gas-prices = ""
2 changes: 1 addition & 1 deletion e2e/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type apiclient struct {

const (
chainID = "mesg-dev-chain"
gasPrices = "1.0atto"
gasPrices = ""
pollingInterval = 500 * time.Millisecond // half a block
pollingTimeout = 10 * time.Second // 10 blocks

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/btcsuite/btcd v0.0.0-20190807005414-4063feeff79a // indirect
github.com/containerd/containerd v1.3.0 // indirect
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc // indirect
github.com/cosmos/cosmos-sdk v0.38.3
github.com/cosmos/cosmos-sdk v0.38.4
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d
github.com/cskr/pubsub v1.0.2
github.com/docker/cli v0.0.0-20191011045415-5d85cdacd257
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosmos/cosmos-sdk v0.38.3 h1:qIBTiw+2T9POaSUJ5rvbBbXeq8C8btBlJxnSegPBd3Y=
github.com/cosmos/cosmos-sdk v0.38.3/go.mod h1:rzWOofbKfRt3wxiylmYWEFHnxxGj0coyqgWl2I9obAw=
github.com/cosmos/cosmos-sdk v0.38.4 h1:jPZOvhMQkm7wwwzcLxuluhVpKfuIgddNGt999pAiz/Y=
github.com/cosmos/cosmos-sdk v0.38.4/go.mod h1:rzWOofbKfRt3wxiylmYWEFHnxxGj0coyqgWl2I9obAw=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=
Expand Down
14 changes: 14 additions & 0 deletions scripts/dev-starter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,29 @@ set -m
mesg-daemon start &
daemon=$!

# function that stop child processes
function stop {
echo "stopping daemon"
kill $daemon
wait $daemon
exit 0
}

# trap both sigint (ctrl+c) and sigterm (OS ask process to be stopped)
trap stop SIGINT
trap stop SIGTERM

# wait 5 sec for the daemon to start rpc server
sleep 5 &
wait $!

# start lcd
echo "starting lcd"
mesg-cli rest-server --laddr tcp://0.0.0.0:1317 &
lcd=$!

# start orchestrator
echo "starting orchestrator"
mesg-cli orchestrator start &
orchestrator=$!

Expand Down
6 changes: 5 additions & 1 deletion x/execution/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ func GetCmdList(queryRoute string, cdc *codec.Codec) *cobra.Command {
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryList), nil)
data, err := cliCtx.Codec.MarshalJSON(types.ListFilter{})
if err != nil {
return err
}
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryList), data)
if err != nil {
fmt.Printf("could not list executions\n%s\n", err.Error())
return nil
Expand Down
9 changes: 8 additions & 1 deletion x/execution/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (
// and the keeper's address to pubkey map
func InitGenesis(ctx sdk.Context, k Keeper, data types.GenesisState) []abci.ValidatorUpdate {
k.SetParams(ctx, data.Params)
if err := k.Import(ctx, data.Executions); err != nil {
panic(err)
}
return []abci.ValidatorUpdate{}
}

Expand All @@ -18,5 +21,9 @@ func InitGenesis(ctx sdk.Context, k Keeper, data types.GenesisState) []abci.Vali
// with InitGenesis
func ExportGenesis(ctx sdk.Context, k Keeper) (data types.GenesisState) {
params := k.GetParams(ctx)
return types.NewGenesisState(params)
execs, err := k.List(ctx, types.ListFilter{})
if err != nil {
panic(err)
}
return types.NewGenesisState(params, execs)
}
13 changes: 13 additions & 0 deletions x/execution/internal/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,3 +469,16 @@ func (k *Keeper) fetchEmitters(ctx sdk.Context, proc *process.Process, nodeKey s
}
return matchedRuns, nil
}

// Import imports a list of executions into the store.
func (k *Keeper) Import(ctx sdk.Context, execs []*executionpb.Execution) error {
store := ctx.KVStore(k.storeKey)
for _, exec := range execs {
value, err := k.cdc.MarshalBinaryLengthPrefixed(exec)
if err != nil {
return sdkerrors.Wrapf(sdkerrors.ErrJSONMarshal, err.Error())
}
store.Set(exec.Hash, value)
}
return nil
}
23 changes: 19 additions & 4 deletions x/execution/internal/types/genesis.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
package types

import (
fmt "fmt"

executionpb "github.com/mesg-foundation/engine/execution"
"github.com/mesg-foundation/engine/ext/xvalidator"
)

// GenesisState - all instance state that must be provided at genesis
type GenesisState struct {
Params Params `json:"params" yaml:"params"`
Params Params `json:"params" yaml:"params" validate:"dive"`
Executions []*executionpb.Execution `json:"executions" yaml:"executions" validate:"dive"`
}

// NewGenesisState creates a new GenesisState object
func NewGenesisState(params Params) GenesisState {
return GenesisState{Params: params}
func NewGenesisState(params Params, execs []*executionpb.Execution) GenesisState {
return GenesisState{
Params: params,
Executions: execs,
}
}

// DefaultGenesisState - default GenesisState used by Cosmos Hub
func DefaultGenesisState() GenesisState {
return GenesisState{
Params: DefaultParams(),
Params: DefaultParams(),
Executions: []*executionpb.Execution{},
}
}

// ValidateGenesis validates the instance genesis parameters
func ValidateGenesis(data GenesisState) error {
if err := xvalidator.Struct(data); err != nil {
return fmt.Errorf("failed to validate %s genesis state: %w", ModuleName, err)
}
return nil
}
9 changes: 8 additions & 1 deletion x/instance/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ import (

// InitGenesis initialize default parameters and the keeper's address to pubkey map.
func InitGenesis(ctx sdk.Context, k Keeper, data types.GenesisState) []abci.ValidatorUpdate {
if err := k.Import(ctx, data.Instances); err != nil {
panic(err)
}
return []abci.ValidatorUpdate{}
}

// ExportGenesis writes the current store values // to a genesis file,
// which can be imported again with InitGenesis.
func ExportGenesis(ctx sdk.Context, k Keeper) types.GenesisState {
return types.NewGenesisState()
instances, err := k.List(ctx)
if err != nil {
panic(err)
}
return types.NewGenesisState(instances)
}
Loading

0 comments on commit 73a6b0c

Please sign in to comment.