Skip to content

Commit

Permalink
v0.15.0 (#225)
Browse files Browse the repository at this point in the history
* Fix slash event on double sign (full resync needed)

* fix version

* Fix double sign slashing issue #215

* skip already offline candidates to prevent double punishing

* Make block hash lowercase

* Remove unused fields from config

* Fix issue #209

* Update changelog

* Delete coins with 0 reserves #217

* Add test

* Export/import app state

* Import state

* Fix genesis

* Add tests

* Switch to Amino and fixes

* Fix frozen funds height

* Refactor

* Fix

* Add ?include_stakes to /candidates endpoint #222

* Update tendermint to v0.31.0

* Update tendermint to v0.31.0

* UpdaUpdate tendermint to v0.31.0

* Add CoinLiquidation event #221
Set height to be always in uint64

* Fixes

* Change `stake` to `value` in DelegateTx

* Invariants

* Fix nil pointer exception

* Fix nil pointer exception

* Record total slashed in state

* Fix record total slashed in state

* Fix coin creation issue

* Fix genesis

* Fix node termination

* Fix invariants

* Fix mempool issue #220

* Fix tests

* Recheck mempool once per minute

* Small refactor

* Change `pubkey` to `pub_key` in all API resources

* Add invariants checker each 720 blocks

* Fix events issue

* Fix invariants

* Fix gui

* Fix gui

* Fix invariants

* Create new state for invariants checking

* Fix coin creation issues

* Compute validator power from genesis

* Update genesis

* Update config
  • Loading branch information
danil-lashin authored Mar 27, 2019
1 parent 19084d3 commit 10703fe
Show file tree
Hide file tree
Showing 65 changed files with 1,462 additions and 368 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# Changelog

## 0.15.0

BREAKING CHANGES

- [tendermint] Update to [v0.31.0](https://github.com/tendermint/tendermint/blob/master/CHANGELOG.md#v0310)

IMPROVEMENT

- [invariants] Add invariants checker each 720 blocks
- [core] Delete coins with 0 reserves #217
- [genesis] Add option to export/import state
- [api] Add ?include_stakes to /candidates endpoint #222
- [api] Change `stake` to `value` in DelegateTx
- [api] Change `pubkey` to `pub_key` in all API resources and requests
- [events] Add CoinLiquidation event #221
- [mempool] Recheck mempool once per minute

BUG FIXES

- [core] Fix double sign slashing issue #215
- [core] Fix issue with slashing small stake #209
- [core] Fix coin creation issue
- [core] Fix mempool issue #220
- [api] Make block hash lowercase #214

## 0.14.3

BUG FIXES
Expand Down
40 changes: 17 additions & 23 deletions Gopkg.lock

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

4 changes: 2 additions & 2 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

[[constraint]]
name = "github.com/danil-lashin/iavl"
revision = "83a81c94ee7eb3bd0eb14d6829bd04f22e530e6f"
revision = "98552e00562de7d0c62e0e0bf2fcedf5223517c5"

[[constraint]]
name = "github.com/tendermint/tendermint"
version = "0.30.1"
version = "0.31.0"

[[constraint]]
name = "github.com/MinterTeam/go-amino"
Expand Down
6 changes: 3 additions & 3 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ var (

var Routes = map[string]*rpcserver.RPCFunc{
"status": rpcserver.NewRPCFunc(Status, ""),
"candidates": rpcserver.NewRPCFunc(Candidates, "height"),
"candidate": rpcserver.NewRPCFunc(Candidate, "pubkey,height"),
"candidates": rpcserver.NewRPCFunc(Candidates, "height,include_stakes"),
"candidate": rpcserver.NewRPCFunc(Candidate, "pub_key,height"),
"validators": rpcserver.NewRPCFunc(Validators, "height"),
"address": rpcserver.NewRPCFunc(Address, "address,height"),
"addresses": rpcserver.NewRPCFunc(Addresses, "addresses,height"),
Expand Down Expand Up @@ -122,7 +122,7 @@ type Response struct {

func GetStateForHeight(height int) (*state.StateDB, error) {
if height > 0 {
cState, err := blockchain.GetStateForHeight(height)
cState, err := blockchain.GetStateForHeight(uint64(height))

return cState, err
}
Expand Down
8 changes: 4 additions & 4 deletions api/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ package api

import (
"bytes"
"encoding/hex"
"encoding/json"
"fmt"
"github.com/MinterTeam/minter-go-node/core/rewards"
"github.com/MinterTeam/minter-go-node/core/transaction"
"github.com/MinterTeam/minter-go-node/core/types"
"github.com/MinterTeam/minter-go-node/rpc/lib/types"
"github.com/tendermint/tendermint/libs/common"
types2 "github.com/tendermint/tendermint/types"
"math/big"
"time"
)

type BlockResponse struct {
Hash common.HexBytes `json:"hash"`
Hash string `json:"hash"`
Height int64 `json:"height"`
Time time.Time `json:"time"`
NumTxs int64 `json:"num_txs"`
Expand Down Expand Up @@ -46,7 +46,7 @@ type BlockTransactionResponse struct {
}

type BlockValidatorResponse struct {
Pubkey string `json:"pubkey"`
Pubkey string `json:"pub_key"`
Signed bool `json:"signed"`
}

Expand Down Expand Up @@ -136,7 +136,7 @@ func Block(height int64) (*BlockResponse, error) {
}

return &BlockResponse{
Hash: block.Block.Hash(),
Hash: hex.EncodeToString(block.Block.Hash()),
Height: block.Block.Height,
Time: block.Block.Time,
NumTxs: block.Block.NumTxs,
Expand Down
2 changes: 1 addition & 1 deletion api/candidate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type CandidateResponse struct {
RewardAddress types.Address `json:"reward_address"`
OwnerAddress types.Address `json:"owner_address"`
TotalStake *big.Int `json:"total_stake"`
PubKey types.Pubkey `json:"pubkey"`
PubKey types.Pubkey `json:"pub_key"`
Commission uint `json:"commission"`
Stakes []Stake `json:"stakes,omitempty"`
CreatedAtBlock uint `json:"created_at_block"`
Expand Down
4 changes: 2 additions & 2 deletions api/candidates.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package api

func Candidates(height int) (*[]CandidateResponse, error) {
func Candidates(height int, includeStakes bool) (*[]CandidateResponse, error) {
cState, err := GetStateForHeight(height)
if err != nil {
return nil, err
Expand All @@ -10,7 +10,7 @@ func Candidates(height int) (*[]CandidateResponse, error) {

result := make([]CandidateResponse, len(candidates))
for i, candidate := range candidates {
result[i] = makeResponseCandidate(candidate, false)
result[i] = makeResponseCandidate(candidate, includeStakes)
}

return &result, nil
Expand Down
2 changes: 1 addition & 1 deletion api/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type EventsResponse struct {
Events eventsdb.Events `json:"events"`
}

func Events(height int64) (*EventsResponse, error) {
func Events(height uint64) (*EventsResponse, error) {
return &EventsResponse{
Events: eventsdb.NewEventsDB(eventsdb.GetCurrentDB()).LoadEvents(height),
}, nil
Expand Down
2 changes: 1 addition & 1 deletion api/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func Transaction(hash []byte) (*TransactionResponse, error) {
return nil, err
}

if tx.Height > blockchain.LastCommittedHeight() {
if uint64(tx.Height) > blockchain.LastCommittedHeight() {
return nil, rpctypes.RPCError{Code: 404, Message: "Tx not found"}
}

Expand Down
7 changes: 4 additions & 3 deletions api/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ import (
)

type ValidatorResponse struct {
Pubkey types.Pubkey `json:"pubkey"`
Pubkey types.Pubkey `json:"pub_key"`
VotingPower int64 `json:"voting_power"`
}

type ResponseValidators []ValidatorResponse

func Validators(height int64) (*ResponseValidators, error) {
func Validators(height uint64) (*ResponseValidators, error) {
if height == 0 {
height = blockchain.Height()
}

tmVals, err := client.Validators(&height)
h := int64(height)
tmVals, err := client.Validators(&h)
if err != nil {
return nil, err
}
Expand Down
38 changes: 38 additions & 0 deletions cmd/export/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

import (
"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"
)

func main() {
err := common.EnsureDir(utils.GetMinterHome()+"/config", 0777)
if err != nil {
panic(err)
}

ldb, err := db.NewGoLevelDB("state", utils.GetMinterHome()+"/data")
if err != nil {
panic(err)
}

applicationDB := appdb.NewAppDB()
height := applicationDB.GetLastHeight()
currentState, err := state.New(height, ldb)
if err != nil {
panic(err)
}

cdc := amino.NewCodec()

jsonBytes, err := cdc.MarshalJSONIndent(currentState.Export(height), "", " ")
if err != nil {
panic(err)
}

println(string(jsonBytes))
}
12 changes: 12 additions & 0 deletions cmd/make_genesis/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package main

import (
"encoding/json"
"github.com/MinterTeam/minter-go-node/genesis"
)

func main() {
gen, _ := genesis.GetTestnetGenesis()
genesisJson, _ := json.MarshalIndent(gen, "", " ")
println(string(genesisJson))
}
Loading

0 comments on commit 10703fe

Please sign in to comment.