Skip to content

Commit

Permalink
Merge pull request #112 from MinterTeam/dev
Browse files Browse the repository at this point in the history
v0.4.0
  • Loading branch information
danil-lashin authored Sep 19, 2018
2 parents 353b1eb + 0395c9f commit 0071525
Show file tree
Hide file tree
Showing 37 changed files with 665 additions and 3,573 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 0.4.0
*Sept 18th, 2018*

BREAKING CHANGES

- [core] Switch Ethereum Patricia Tree to IAVL
- [core] Change consensus TimeoutCommit to 4.5 sec, TimeoutPropose to 2 sec
- [core] Now validator punished if it misses 12 of 24 last blocks

IMPROVEMENT

- [config] Add validator mode
- [api] Include events by default
- [gui] Add validator status

## 0.3.8
*Sept 17th, 2018*

Expand Down
23 changes: 7 additions & 16 deletions Gopkg.lock

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

20 changes: 2 additions & 18 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,13 @@
name = "github.com/gorilla/websocket"
version = "=1.2.0"

[[constraint]]
branch = "master"
name = "github.com/hashicorp/golang-lru"

[[constraint]]
branch = "master"
name = "github.com/rcrowley/go-metrics"

[[constraint]]
name = "github.com/rs/cors"
version = "=1.4.0"

[[constraint]]
branch = "master"
name = "github.com/syndtr/goleveldb"

[[constraint]]
name = "github.com/tendermint/go-amino"
version = "=v0.12.0"
name = "github.com/danil-lashin/iavl"
version = "=v0.11.1"

[[constraint]]
name = "github.com/tendermint/tendermint"
Expand All @@ -69,10 +57,6 @@
branch = "v1"
name = "gopkg.in/check.v1"

[[constraint]]
branch = "v2"
name = "gopkg.in/karalabe/cookiejar.v2"

[prune]
go-tests = true
unused-packages = true
4 changes: 2 additions & 2 deletions api/balance_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func GetBalanceWatcher(w http.ResponseWriter, r *http.Request) {
}

func handleBalanceChanges() {
for {
handleBalanceChange(<-state.BalanceChangeChan)
for change := range state.BalanceChangeChan {
handleBalanceChange(change)
}
}

Expand Down
23 changes: 10 additions & 13 deletions api/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func Block(w http.ResponseWriter, r *http.Request) {

vars := mux.Vars(r)
height, _ := strconv.ParseInt(vars["height"], 10, 64)
includeEvents, _ := strconv.ParseBool(r.URL.Query().Get("withEvents"))

block, err := client.Block(&height)
blockResults, err := client.BlockResults(&height)
Expand Down Expand Up @@ -105,20 +104,18 @@ func Block(w http.ResponseWriter, r *http.Request) {

var eventsRaw []byte

if includeEvents {
events := eventsdb.GetCurrent().GetEvents(height)
events := eventsdb.GetCurrent().GetEvents(height)

if len(events) > 0 {
eventsRaw, err = cdc.MarshalJSON(events)
if len(events) > 0 {
eventsRaw, err = cdc.MarshalJSON(events)

if err != nil {
w.WriteHeader(http.StatusBadRequest)
json.NewEncoder(w).Encode(Response{
Code: 0,
Log: err.Error(),
})
return
}
if err != nil {
w.WriteHeader(http.StatusBadRequest)
json.NewEncoder(w).Encode(Response{
Code: 0,
Log: err.Error(),
})
return
}
}

Expand Down
4 changes: 2 additions & 2 deletions api/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ type Candidate struct {

type Validator struct {
AccumReward string `json:"accumulated_reward"`
AbsentTimes uint `json:"absent_times"`
AbsentTimes int `json:"absent_times"`
Candidate Candidate `json:"candidate"`
}

func makeResponseValidator(v state.Validator, state *state.StateDB) Validator {
return Validator{
AccumReward: v.AccumReward.String(),
AbsentTimes: v.AbsentTimes,
AbsentTimes: v.CountAbsentTimes(),
Candidate: makeResponseCandidate(*state.GetStateCandidate(v.PubKey)),
}
}
Expand Down
6 changes: 4 additions & 2 deletions cmd/minter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ func main() {

app.RunRPC(node)

go api.RunApi(app, node)
go gui.Run(cfg.GUIListenAddress)
if !cfg.ValidatorMode {
go api.RunApi(app, node)
go gui.Run(cfg.GUIListenAddress)
}

// Wait forever
common.TrapSignal(func() {
Expand Down
16 changes: 12 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ func DefaultConfig() *Config {
cfg.Mempool.RecheckEmpty = true

cfg.Consensus.WalPath = "tmdata/cs.wal/wal"
cfg.Consensus.TimeoutPropose = 3000
cfg.Consensus.TimeoutPropose = 2000
cfg.Consensus.TimeoutProposeDelta = 500
cfg.Consensus.TimeoutPrevote = 1000
cfg.Consensus.TimeoutPrevoteDelta = 500
cfg.Consensus.TimeoutPrecommit = 1000
cfg.Consensus.TimeoutPrecommitDelta = 500
cfg.Consensus.TimeoutCommit = 5000
cfg.Consensus.TimeoutCommit = 4500

cfg.PrivValidator = "config/priv_validator.json"

Expand All @@ -88,6 +88,14 @@ func GetConfig() *Config {
panic(err)
}

if cfg.ValidatorMode {
cfg.TxIndex.IndexAllTags = false
cfg.TxIndex.IndexTags = ""

cfg.RPC.ListenAddress = ""
cfg.RPC.GRPCListenAddress = ""
}

cfg.SetRoot(utils.GetMinterHome())
EnsureRoot(utils.GetMinterHome())

Expand Down Expand Up @@ -223,7 +231,7 @@ type BaseConfig struct {
// Address to listen for API connections
APIListenAddress string `mapstructure:"api_listen_addr"`

EnableEvents bool `mapstructure:"enable_events"`
ValidatorMode bool `mapstructure:"validator_mode"`
}

// DefaultBaseConfig returns a default base configuration for a Tendermint node
Expand All @@ -243,7 +251,7 @@ func DefaultBaseConfig() BaseConfig {
DBPath: "data",
GUIListenAddress: ":3000",
APIListenAddress: ":8841",
EnableEvents: false,
ValidatorMode: false,
}
}

Expand Down
26 changes: 2 additions & 24 deletions config/toml.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ gui_listen_addr = "{{ .BaseConfig.GUIListenAddress }}"
# Address to listen for API connections
api_listen_addr = "{{ .BaseConfig.APIListenAddress }}"
# Enable events for API. Slows down node.
enable_events = {{ .BaseConfig.EnableEvents }}
# Sets node to be in validator mode. Disables API, events, history of blocks, indexes, etc.
validator_mode = {{ .BaseConfig.ValidatorMode }}
# If this node is many blocks behind the tip of the chain, FastSync
# allows them to catchup quickly by downloading blocks in parallel
Expand Down Expand Up @@ -201,28 +201,6 @@ size = {{ .Mempool.Size }}
# size of the cache (used to filter transactions we saw earlier)
cache_size = {{ .Mempool.CacheSize }}
##### transactions indexer configuration options #####
[tx_index]
# What indexer to use for transactions
#
# Options:
# 1) "null" (default)
# 2) "kv" - the simplest possible indexer, backed by key-value storage (defaults to levelDB; see DBBackend).
indexer = "{{ .TxIndex.Indexer }}"
# Comma-separated list of tags to index (by default the only tag is tx hash)
#
# It's recommended to index only a subset of tags due to possible memory
# bloat. This is, of course, depends on the indexer's DB and the volume of
# transactions.
index_tags = "{{ .TxIndex.IndexTags }}"
# When set to true, tells indexer to index all tags. Note this may be not
# desirable (see the comment above). IndexTags has a precedence over
# IndexAllTags (i.e. when given both, IndexTags will be indexed).
index_all_tags = {{ .TxIndex.IndexAllTags }}
##### instrumentation configuration options #####
[instrumentation]
Expand Down
Loading

0 comments on commit 0071525

Please sign in to comment.