Skip to content

Commit

Permalink
Merge pull request #237 from MinterTeam/dev
Browse files Browse the repository at this point in the history
v0.19.0
  • Loading branch information
danil-lashin authored Apr 17, 2019
2 parents 5bea610 + fd9901a commit 91a268f
Show file tree
Hide file tree
Showing 66 changed files with 28,230 additions and 631 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## 0.19.0

BREAKING CHANGES

- [core] Add ChainID to transactions
- [core] Add ChainID to check
- [core] Simplify coin creation commissions (remove base commission)

IMPROVEMENT

- [api] Fix list of endpoints
- [cmd] Minter node now launched as `minter node` command

BUG FIXES

- [core] Fix incorrect coin conversion
- [tendermint] Update to [v0.31.5](https://github.com/tendermint/tendermint/blob/master/CHANGELOG.md#v0315)

## 0.18.1

BUG FIXES
Expand Down
23 changes: 20 additions & 3 deletions Gopkg.lock

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

6 changes: 5 additions & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
name = "github.com/gobuffalo/packr"
version = "=1.11.1"

[[constraint]]
name = "github.com/spf13/cobra"
version = "^0.0.3"

[[constraint]]
name = "github.com/rs/cors"
version = "^1.6.0"
Expand All @@ -16,7 +20,7 @@

[[constraint]]
name = "github.com/tendermint/tendermint"
version = "0.31.3"
version = "0.31.5"

[[constraint]]
name = "github.com/MinterTeam/go-amino"
Expand Down
11 changes: 6 additions & 5 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/MinterTeam/minter-go-node/config"
"github.com/MinterTeam/minter-go-node/core/minter"
"github.com/MinterTeam/minter-go-node/core/state"
"github.com/MinterTeam/minter-go-node/eventsdb"
"github.com/MinterTeam/minter-go-node/eventsdb/events"
"github.com/MinterTeam/minter-go-node/log"
"github.com/MinterTeam/minter-go-node/rpc/lib/server"
"github.com/rs/cors"
Expand All @@ -27,7 +27,7 @@ var (
cdc = amino.NewCodec()
blockchain *minter.Blockchain
client *rpc.Local
cfg = config.GetConfig()
minterCfg *config.Config
)

var Routes = map[string]*rpcserver.RPCFunc{
Expand All @@ -54,9 +54,10 @@ var Routes = map[string]*rpcserver.RPCFunc{
"genesis": rpcserver.NewRPCFunc(Genesis, ""),
}

func RunAPI(b *minter.Blockchain, tmRPC *rpc.Local) {
func RunAPI(b *minter.Blockchain, tmRPC *rpc.Local, cfg *config.Config) {
minterCfg = cfg
RegisterCryptoAmino(cdc)
eventsdb.RegisterAminoEvents(cdc)
events.RegisterAminoEvents(cdc)
RegisterEvidenceMessages(cdc)

client = tmRPC
Expand All @@ -66,7 +67,7 @@ func RunAPI(b *minter.Blockchain, tmRPC *rpc.Local) {
m := http.NewServeMux()
logger := log.With("module", "rpc")
rpcserver.RegisterRPCFuncs(m, Routes, cdc, logger)
listener, err := rpcserver.Listen(config.GetConfig().APIListenAddress, rpcserver.Config{
listener, err := rpcserver.Listen(cfg.APIListenAddress, rpcserver.Config{
MaxOpenConnections: cfg.APISimultaneousRequests,
})

Expand Down
9 changes: 2 additions & 7 deletions api/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type BlockTransactionResponse struct {
RawTx string `json:"raw_tx"`
From string `json:"from"`
Nonce uint64 `json:"nonce"`
GasPrice *big.Int `json:"gas_price"`
GasPrice uint32 `json:"gas_price"`
Type transaction.TxType `json:"type"`
Data json.RawMessage `json:"data"`
Payload []byte `json:"payload"`
Expand Down Expand Up @@ -76,11 +76,6 @@ func Block(height int64) (*BlockResponse, error) {
return nil, err
}

gas := tx.Gas()
if tx.Type == transaction.TypeCreateCoin {
gas += tx.GetDecodedData().(*transaction.CreateCoinData).Commission()
}

txs[i] = BlockTransactionResponse{
Hash: fmt.Sprintf("Mt%x", rawTx.Hash()),
RawTx: fmt.Sprintf("%x", []byte(rawTx)),
Expand All @@ -91,7 +86,7 @@ func Block(height int64) (*BlockResponse, error) {
Data: data,
Payload: tx.Payload,
ServiceData: tx.ServiceData,
Gas: gas,
Gas: tx.Gas(),
GasCoin: tx.GasCoin,
Tags: tags,
Code: blockResults.Results.DeliverTx[i].Code,
Expand Down
5 changes: 3 additions & 2 deletions api/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package api

import (
"github.com/MinterTeam/minter-go-node/eventsdb"
"github.com/MinterTeam/minter-go-node/eventsdb/events"
)

type EventsResponse struct {
Events eventsdb.Events `json:"events"`
Events events.Events `json:"events"`
}

func Events(height uint64) (*EventsResponse, error) {
return &EventsResponse{
Events: eventsdb.NewEventsDB(eventsdb.GetCurrentDB()).LoadEvents(height),
Events: eventsdb.GetCurrent().LoadEvents(height),
}, nil
}
6 changes: 2 additions & 4 deletions api/min_gas_price.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package api

import "math/big"

func MinGasPrice() (*big.Int, error) {
return blockchain.MinGasPrice(), nil
func MinGasPrice() (uint64, error) {
return uint64(blockchain.MinGasPrice()), nil
}
2 changes: 1 addition & 1 deletion api/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func Status() (*StatusResponse, error) {
}

stateHistory := "off"
if cfg.BaseConfig.KeepStateHistory {
if minterCfg.BaseConfig.KeepStateHistory {
stateHistory = "on"
}

Expand Down
7 changes: 1 addition & 6 deletions api/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ func Transaction(hash []byte) (*TransactionResponse, error) {
return nil, err
}

gas := decodedTx.Gas()
if decodedTx.Type == transaction.TypeCreateCoin {
gas += decodedTx.GetDecodedData().(*transaction.CreateCoinData).Commission()
}

return &TransactionResponse{
Hash: common.HexBytes(tx.Tx.Hash()),
RawTx: fmt.Sprintf("%x", []byte(tx.Tx)),
Expand All @@ -44,7 +39,7 @@ func Transaction(hash []byte) (*TransactionResponse, error) {
Nonce: decodedTx.Nonce,
GasPrice: decodedTx.GasPrice,
GasCoin: decodedTx.GasCoin,
Gas: gas,
Gas: decodedTx.Gas(),
Type: decodedTx.Type,
Data: data,
Payload: decodedTx.Payload,
Expand Down
10 changes: 2 additions & 8 deletions api/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/MinterTeam/minter-go-node/core/types"
"github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/rpc/core/types"
"math/big"
)

type TransactionResponse struct {
Expand All @@ -18,7 +17,7 @@ type TransactionResponse struct {
From string `json:"from"`
Nonce uint64 `json:"nonce"`
Gas int64 `json:"gas"`
GasPrice *big.Int `json:"gas_price"`
GasPrice uint32 `json:"gas_price"`
GasCoin types.CoinSymbol `json:"gas_coin"`
Type transaction.TxType `json:"type"`
Data json.RawMessage `json:"data"`
Expand Down Expand Up @@ -54,19 +53,14 @@ func Transactions(query string) (*[]TransactionResponse, error) {
return nil, err
}

gas := decodedTx.Gas()
if decodedTx.Type == transaction.TypeCreateCoin {
gas += decodedTx.GetDecodedData().(*transaction.CreateCoinData).Commission()
}

result[i] = TransactionResponse{
Hash: common.HexBytes(tx.Tx.Hash()),
RawTx: fmt.Sprintf("%x", []byte(tx.Tx)),
Height: tx.Height,
Index: tx.Index,
From: sender.String(),
Nonce: decodedTx.Nonce,
Gas: gas,
Gas: decodedTx.Gas(),
GasPrice: decodedTx.GasPrice,
GasCoin: decodedTx.GasCoin,
Type: decodedTx.Type,
Expand Down
5 changes: 3 additions & 2 deletions cmd/export/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"github.com/MinterTeam/go-amino"
"github.com/MinterTeam/minter-go-node/cmd/utils"
"github.com/MinterTeam/minter-go-node/config"
"github.com/MinterTeam/minter-go-node/core/appdb"
"github.com/MinterTeam/minter-go-node/core/state"
"github.com/tendermint/tendermint/libs/common"
Expand All @@ -23,9 +24,9 @@ func main() {
panic(err)
}

applicationDB := appdb.NewAppDB()
applicationDB := appdb.NewAppDB(config.GetConfig())
height := applicationDB.GetLastHeight()
currentState, err := state.New(height, ldb)
currentState, err := state.New(height, ldb, false)
if err != nil {
panic(err)
}
Expand Down
Loading

0 comments on commit 91a268f

Please sign in to comment.