Skip to content

Commit

Permalink
Merge pull request #228 from MinterTeam/dev
Browse files Browse the repository at this point in the history
v0.16.0
  • Loading branch information
danil-lashin authored Apr 2, 2019
2 parents 9b5d612 + 8b96d25 commit 37d7e42
Show file tree
Hide file tree
Showing 173 changed files with 137,369 additions and 149 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 0.16.0

BREAKING CHANGES

- [core] Set min coin reserve to 1000 bip
- [core] Coins with 7-10 letters are now requires 100 bips fee
- [core] Delete coin if reserve is less than 100 bips OR price is less than 0.0001 bip, OR volume is less than 1 coin

IMPROVEMENT

- [api] Make compact json responses
- [api] Add `/genesis` endpoint
- [check] Make check's nonce a byte array field. Max 16 bytes.
- [appState] Use `startHeight` in genesis to manage rewards
- [crypto] Update crypto library
- [core] Add option to use cleveldb

BUG FIXES

- [core] Fix issue with multiple punishments to byzantine validator
- [core] Make accum reward of dropped validator distributes again between active ones
- [tendermint] Update to [v0.31.2](https://github.com/tendermint/tendermint/blob/master/CHANGELOG.md#v0312)

## 0.15.2

IMPROVEMENT
Expand Down
11 changes: 7 additions & 4 deletions Gopkg.lock

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

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

[[constraint]]
name = "github.com/tendermint/tendermint"
version = "0.31.1"
version = "0.31.2"

[[constraint]]
name = "github.com/MinterTeam/go-amino"
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ check: check_tools ensure_deps
build:
CGO_ENABLED=0 go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o build/minter ./cmd/minter/

build_c:
CGO_ENABLED=1 go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS) gcc' -o build/minter ./cmd/minter/

install:
CGO_ENABLED=0 go install $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' ./cmd/minter

Expand Down
1 change: 1 addition & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var Routes = map[string]*rpcserver.RPCFunc{
"unconfirmed_txs": rpcserver.NewRPCFunc(UnconfirmedTxs, "limit"),
"max_gas": rpcserver.NewRPCFunc(MaxGas, "height"),
"min_gas_price": rpcserver.NewRPCFunc(MinGasPrice, ""),
"genesis": rpcserver.NewRPCFunc(Genesis, ""),
}

func RunAPI(b *minter.Blockchain, tmRPC *rpc.Local) {
Expand Down
9 changes: 9 additions & 0 deletions api/genesis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package api

import (
"github.com/tendermint/tendermint/rpc/core/types"
)

func Genesis() (*core_types.ResultGenesis, error) {
return client.Genesis()
}
35 changes: 34 additions & 1 deletion cmd/export/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package main

import (
"encoding/json"
"github.com/MinterTeam/go-amino"
"github.com/MinterTeam/minter-go-node/cmd/utils"
"github.com/MinterTeam/minter-go-node/core/appdb"
"github.com/MinterTeam/minter-go-node/core/state"
"github.com/tendermint/tendermint/libs/common"
"github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/types"
"time"
)

func main() {
Expand Down Expand Up @@ -34,5 +37,35 @@ func main() {
panic(err)
}

println(string(jsonBytes))
appHash := [32]byte{}

// Compose Genesis
genesis := types.GenesisDoc{
GenesisTime: time.Date(2019, time.April, 2, 17, 0, 0, 0, time.UTC),
ChainID: "minter-test-network-35",
ConsensusParams: &types.ConsensusParams{
Block: types.BlockParams{
MaxBytes: 10000000,
MaxGas: 100000,
TimeIotaMs: 1000,
},
Evidence: types.EvidenceParams{
MaxAge: 1000,
},
Validator: types.ValidatorParams{
PubKeyTypes: []string{types.ABCIPubKeyTypeEd25519},
},
},
AppHash: appHash[:],
AppState: json.RawMessage(jsonBytes),
}

err = genesis.ValidateAndComplete()
if err != nil {
panic(err)
}

if err := genesis.SaveAs("genesis.json"); err != nil {
panic(err)
}
}
21 changes: 15 additions & 6 deletions cmd/minter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/tendermint/tendermint/privval"
"github.com/tendermint/tendermint/proxy"
rpc "github.com/tendermint/tendermint/rpc/client"
types2 "github.com/tendermint/tendermint/types"
"os"
"time"
)
Expand All @@ -28,12 +29,16 @@ var cfg = config.GetConfig()

func main() {
err := common.EnsureDir(utils.GetMinterHome()+"/config", 0777)

if err != nil {
log.Error(err.Error())
os.Exit(1)
}

if err := common.EnsureDir(utils.GetMinterHome()+"/tmdata/blockstore.db", 0777); err != nil {
log.Error(err.Error())
os.Exit(1)
}

if *utils.ShowNodeId {
showNodeID()
return
Expand All @@ -46,11 +51,11 @@ func main() {

app := minter.NewMinterBlockchain()

tmCfg := config.GetTmConfig()
tmConfig := config.GetTmConfig()

// update BlocksTimeDelta
// TODO: refactor
blockStoreDB, err := tmNode.DefaultDBProvider(&tmNode.DBContext{ID: "blockstore", Config: tmCfg})
blockStoreDB, err := tmNode.DefaultDBProvider(&tmNode.DBContext{ID: "blockstore", Config: tmConfig})
if err != nil {
panic(err)
}
Expand All @@ -67,7 +72,7 @@ func main() {
blockStoreDB.Close()

// start TM node
node := startTendermintNode(app, tmCfg)
node := startTendermintNode(app, tmConfig)

client := rpc.NewLocal(node)
status, _ := client.Status()
Expand Down Expand Up @@ -125,7 +130,7 @@ func startTendermintNode(app types.Application, cfg *tmCfg.Config) *tmNode.Node
privval.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()),
nodeKey,
proxy.NewLocalClientCreator(app),
genesis.GetTestnetGenesis,
getGenesis,
tmNode.DefaultDBProvider,
tmNode.DefaultMetricsProvider(cfg.Instrumentation),
log.With("module", "tendermint"),
Expand All @@ -146,6 +151,10 @@ func startTendermintNode(app types.Application, cfg *tmCfg.Config) *tmNode.Node
return node
}

func getGenesis() (doc *types2.GenesisDoc, e error) {
return types2.GenesisDocFromFile(utils.GetMinterHome() + "/config/genesis.json")
}

func showNodeID() {
nodeKey, err := p2p.LoadNodeKey(cfg.NodeKeyFile())
if err != nil {
Expand All @@ -165,5 +174,5 @@ func showValidator() {
}

pv := privval.LoadFilePV(keyFilePath, cfg.PrivValidatorStateFile())
fmt.Printf("Mp%x", pv.GetPubKey().Bytes()[5:])
fmt.Printf("Mp%x\n", pv.GetPubKey().Bytes()[5:])
}
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func DefaultBaseConfig() BaseConfig {
ProfListenAddress: "",
FastSync: true,
FilterPeers: false,
DBBackend: "leveldb",
DBBackend: "cleveldb",
DBPath: "data",
GUIListenAddress: ":3000",
APIListenAddress: "tcp://0.0.0.0:8841",
Expand Down
27 changes: 20 additions & 7 deletions core/appdb/appdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/binary"
"errors"
"github.com/MinterTeam/minter-go-node/cmd/utils"
"github.com/MinterTeam/minter-go-node/config"
"github.com/tendermint/go-amino"
"github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/db"
Expand All @@ -16,6 +17,7 @@ var (
const (
hashPath = "hash"
heightPath = "height"
startHeightPath = "startHeight"
blockTimeDeltaPath = "blockDelta"
validatorsPath = "validators"

Expand Down Expand Up @@ -60,6 +62,23 @@ func (appDB *AppDB) SetLastHeight(height uint64) {
appDB.db.Set([]byte(heightPath), h)
}

func (appDB *AppDB) SetStartHeight(height uint64) {
h := make([]byte, 8)
binary.BigEndian.PutUint64(h, height)
appDB.db.Set([]byte(startHeightPath), h)
}

func (appDB *AppDB) GetStartHeight() uint64 {
result := appDB.db.Get([]byte(startHeightPath))
var height uint64

if result != nil {
height = binary.BigEndian.Uint64(result)
}

return height
}

func (appDB *AppDB) GetValidators() types.ValidatorUpdates {
result := appDB.db.Get([]byte(validatorsPath))

Expand Down Expand Up @@ -126,13 +145,7 @@ func (appDB *AppDB) SetLastBlocksTimeDelta(height uint64, delta int) {
}

func NewAppDB() *AppDB {
ldb, err := db.NewGoLevelDB(dbName, utils.GetMinterHome()+"/data")

if err != nil {
panic(err)
}

return &AppDB{
db: ldb,
db: db.NewDB(dbName, db.DBBackendType(config.GetConfig().DBBackend), utils.GetMinterHome()+"/data"),
}
}
6 changes: 3 additions & 3 deletions core/check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var (
)

type Check struct {
Nonce uint64
Nonce []byte
DueBlock uint64
Coin types.CoinSymbol
Value *big.Int
Expand Down Expand Up @@ -91,7 +91,7 @@ func (check *Check) SetSignature(sig []byte) {
func (check *Check) String() string {
sender, _ := check.Sender()

return fmt.Sprintf("Check sender: %s nonce: %d, dueBlock: %d, value: %s %s", sender.String(), check.Nonce,
return fmt.Sprintf("Check sender: %s nonce: %x, dueBlock: %d, value: %s %s", sender.String(), check.Nonce,
check.DueBlock, check.Value.String(), check.Coin.String())
}

Expand Down Expand Up @@ -124,7 +124,7 @@ func recoverPlain(sighash types.Hash, R, S, Vb *big.Int) (types.Address, error)
return types.Address{}, ErrInvalidSig
}
V := byte(Vb.Uint64() - 27)
if !crypto.ValidateSignatureValues(V, R, S) {
if !crypto.ValidateSignatureValues(V, R, S, true) {
return types.Address{}, ErrInvalidSig
}
// encode the snature in uncompressed format
Expand Down
1 change: 1 addition & 0 deletions core/code/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const (
CheckUsed uint32 = 503
TooHighGasPrice uint32 = 504
WrongGasCoin uint32 = 505
TooLongNonce uint32 = 506

// multisig
IncorrectWeights uint32 = 601
Expand Down
Loading

0 comments on commit 37d7e42

Please sign in to comment.