Skip to content

Commit

Permalink
Merge branch 'development' into deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
iulianpascalau committed Apr 2, 2020
2 parents c1ce75e + f185a7f commit 6ec34a0
Show file tree
Hide file tree
Showing 346 changed files with 10,255 additions and 6,194 deletions.
25 changes: 23 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: go

go: 1.13
go: "1.13"

os:
- linux
Expand All @@ -14,9 +14,10 @@ osx_image: xcode11.3

before_script:
- APP_VER=$(git describe --tags --long --dirty)
- APP_VER_SHORT=$(git describe --tags)
- GOOS=$(go env GOOS)
- GOARCH=$(go env GOARCH)
- ARCHIVE="elrond_""$APP_VER""_""$GOOS""_""$GOARCH"".tgz"
- ARCHIVE="elrond_""$APP_VER_SHORT""_""$GOOS""_""$GOARCH"".tgz"

script:
- ERD_PACKAGE=node
Expand All @@ -25,6 +26,26 @@ script:
- ERD_PACKAGE=keygenerator
- cd $TRAVIS_BUILD_DIR/cmd/$ERD_PACKAGE
- go build -o "$TRAVIS_BUILD_DIR/build/$ERD_PACKAGE" -a -i -ldflags="-X main.appVersion=$APP_VER"
- ERD_PACKAGE=logviewer
- cd $TRAVIS_BUILD_DIR/cmd/$ERD_PACKAGE
- go build -o "$TRAVIS_BUILD_DIR/build/$ERD_PACKAGE" -a -i -ldflags="-X main.appVersion=$APP_VER"
- ERD_PACKAGE=termui
- cd $TRAVIS_BUILD_DIR/cmd/$ERD_PACKAGE
- go build -o "$TRAVIS_BUILD_DIR/build/$ERD_PACKAGE" -a -i -ldflags="-X main.appVersion=$APP_VER"

- GOOS=$(go env GOOS)
- GOARCH=$(go env GOARCH)
- cd $TRAVIS_BUILD_DIR
- ARWEN_VERSION=$(cat go.mod | grep arwen | sed 's/^.*arwen-wasm-vm *//')
- if [[ "$GOOS" == linux && "$GOARCH" == amd64 ]]; then
cp -f $GOPATH/pkg/mod/github.com/\!elrond\!network/arwen-wasm-vm@$ARWEN_VERSION/wasmer/libwasmer_linux_amd64.so $TRAVIS_BUILD_DIR/build;
fi
- if [[ "$GOOS" == linux && "$GOARCH" == arm64 ]]; then
cp -f $GOPATH/pkg/mod/github.com/\!elrond\!network/arwen-wasm-vm@$ARWEN_VERSION/wasmer/libwasmer_linux_arm64.so $TRAVIS_BUILD_DIR/build;
fi
- if [[ "$GOOS" == darwin && "$GOARCH" == amd64 ]]; then
cp -f $GOPATH/pkg/mod/github.com/\!elrond\!network/arwen-wasm-vm@$ARWEN_VERSION/wasmer/libwasmer_darwin_amd64.dylib $TRAVIS_BUILD_DIR/build;
fi

before_deploy:
- cd "$TRAVIS_BUILD_DIR/build"
Expand Down
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"net/http"
"reflect"

logger "github.com/ElrondNetwork/elrond-go-logger"
"github.com/ElrondNetwork/elrond-go/api/address"
"github.com/ElrondNetwork/elrond-go/api/logs"
"github.com/ElrondNetwork/elrond-go/api/middleware"
Expand All @@ -12,7 +13,6 @@ import (
valStats "github.com/ElrondNetwork/elrond-go/api/validator"
"github.com/ElrondNetwork/elrond-go/api/vmValues"
"github.com/ElrondNetwork/elrond-go/core/check"
"github.com/ElrondNetwork/elrond-go/logger"
"github.com/ElrondNetwork/elrond-go/marshal"
"github.com/gin-contrib/cors"
"github.com/gin-contrib/pprof"
Expand Down
2 changes: 1 addition & 1 deletion api/logs/logSender.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package logs
import (
"strings"

logger "github.com/ElrondNetwork/elrond-go-logger"
"github.com/ElrondNetwork/elrond-go/core/check"
"github.com/ElrondNetwork/elrond-go/logger"
"github.com/ElrondNetwork/elrond-go/marshal"
"github.com/gorilla/websocket"
)
Expand Down
2 changes: 1 addition & 1 deletion api/logs/logSender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"testing"
"time"

"github.com/ElrondNetwork/elrond-go-logger"
"github.com/ElrondNetwork/elrond-go/api/logs"
"github.com/ElrondNetwork/elrond-go/api/mock"
"github.com/ElrondNetwork/elrond-go/logger"
"github.com/gorilla/websocket"
"github.com/stretchr/testify/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion api/mock/loggerStub.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mock

import "github.com/ElrondNetwork/elrond-go/logger"
import "github.com/ElrondNetwork/elrond-go-logger"

// LoggerStub -
type LoggerStub struct {
Expand Down
14 changes: 14 additions & 0 deletions api/node/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,27 @@ type shardStatisticsResponse struct {

// Routes defines node related routes
func Routes(router *gin.RouterGroup) {
router.GET("/epoch", EpochData)
router.GET("/heartbeatstatus", HeartbeatStatus)
router.GET("/statistics", Statistics)
router.GET("/status", StatusMetrics)
router.GET("/p2pstatus", P2pStatusMetrics)
// placeholder for custom routes
}

// EpochData returns data about current epoch
func EpochData(c *gin.Context) {
ef, ok := c.MustGet("elrondFacade").(FacadeHandler)
if !ok {
c.JSON(http.StatusInternalServerError, gin.H{"error": errors.ErrInvalidAppContext.Error()})
return
}

epochMetrics := ef.StatusMetrics().EpochMetrics()

c.JSON(http.StatusOK, gin.H{"epochData": epochMetrics})
}

// HeartbeatStatus respond with the heartbeat status of the node
func HeartbeatStatus(c *gin.Context) {
ef, ok := c.MustGet("elrondFacade").(FacadeHandler)
Expand Down
25 changes: 25 additions & 0 deletions api/node/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/ElrondNetwork/elrond-go/api/errors"
"github.com/ElrondNetwork/elrond-go/api/mock"
"github.com/ElrondNetwork/elrond-go/api/node"
"github.com/ElrondNetwork/elrond-go/core"
"github.com/ElrondNetwork/elrond-go/core/statistics"
"github.com/ElrondNetwork/elrond-go/node/external"
"github.com/ElrondNetwork/elrond-go/node/heartbeat"
Expand Down Expand Up @@ -251,6 +252,30 @@ func TestP2PStatusMetrics_ShouldDisplayNonP2pMetrics(t *testing.T) {
assert.False(t, strings.Contains(respStr, key))
}

func TestEpochMetrics_ShouldWork(t *testing.T) {
statusMetricsProvider := statusHandler.NewStatusMetrics()
key := core.MetricEpochNumber
value := uint64(37)
statusMetricsProvider.SetUInt64Value(key, value)

facade := mock.Facade{}
facade.StatusMetricsHandler = func() external.StatusMetricsHandler {
return statusMetricsProvider
}

ws := startNodeServer(&facade)
req, _ := http.NewRequest("GET", "/node/epoch", nil)
resp := httptest.NewRecorder()
ws.ServeHTTP(resp, req)

respBytes, _ := ioutil.ReadAll(resp.Body)
respStr := string(respBytes)
assert.Equal(t, resp.Code, http.StatusOK)

keyAndValueFoundInResponse := strings.Contains(respStr, key) && strings.Contains(respStr, fmt.Sprintf("%d", value))
assert.True(t, keyAndValueFoundInResponse)
}

func loadResponse(rsp io.Reader, destination interface{}) {
jsonParser := json.NewDecoder(rsp)
err := jsonParser.Decode(destination)
Expand Down
8 changes: 4 additions & 4 deletions api/validator/routes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ func TestValidatorStatistics_ReturnsSuccessfully(t *testing.T) {

mapToReturn := make(map[string]*state.ValidatorApiResponse)
mapToReturn["test"] = &state.ValidatorApiResponse{
NrLeaderSuccess: 5,
NrLeaderFailure: 2,
NrValidatorSuccess: 7,
NrValidatorFailure: 3,
NumLeaderSuccess: 5,
NumLeaderFailure: 2,
NumValidatorSuccess: 7,
NumValidatorFailure: 3,
}

facade := mock.Facade{
Expand Down
5 changes: 3 additions & 2 deletions cmd/logviewer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"syscall"
"time"

"github.com/ElrondNetwork/elrond-go-logger"
"github.com/ElrondNetwork/elrond-go/core"
"github.com/ElrondNetwork/elrond-go/logger"
"github.com/ElrondNetwork/elrond-go/marshal"
"github.com/gorilla/websocket"
"github.com/urfave/cli"
Expand Down Expand Up @@ -185,7 +185,8 @@ func startLogViewer(ctx *cli.Context) error {
WithLoggerName: argsConfig.withLoggerName,
}

profile.Apply()
err = profile.Apply()
log.LogIfError(err)

go func() {
for {
Expand Down
5 changes: 3 additions & 2 deletions cmd/logviewer/testing/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import (
"syscall"
"time"

"github.com/ElrondNetwork/elrond-go/logger"
"github.com/ElrondNetwork/elrond-go-logger"
"github.com/ElrondNetwork/elrond-go-logger/proto"
"github.com/ElrondNetwork/elrond-go/marshal"
"github.com/gorilla/websocket"
"github.com/urfave/cli"
Expand Down Expand Up @@ -254,7 +255,7 @@ func generateLogLine(idxCrtLogLevel *int, count *int) logger.LogLineHandler {

logLine := &logger.LogLineWrapper{}
logLine.LoggerName = "websocket test"
logLine.Correlation = logger.LogCorrelationMessage{Shard: "foobar", Epoch: 42}
logLine.Correlation = proto.LogCorrelationMessage{Shard: "foobar", Epoch: 42}
logLine.Message = "websocket test message"
logLine.LogLevel = int32(logLevel)
logLine.Args = []string{"count", fmt.Sprintf("%v", *count)}
Expand Down
12 changes: 6 additions & 6 deletions cmd/node/config/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
FilePath = "BlockHeaders"
Type = "LvlDBSerial"
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxBatchSize = 1
MaxOpenFiles = 10

[BootstrapStorage]
Expand All @@ -86,7 +86,7 @@
FilePath = "MetaBlock"
Type = "LvlDBSerial"
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxBatchSize = 1
MaxOpenFiles = 10

[TxStorage]
Expand Down Expand Up @@ -141,7 +141,7 @@
FilePath = "ShardHdrHashNonce"
Type = "LvlDBSerial"
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxBatchSize = 1
MaxOpenFiles = 10

[MetaHdrNonceHashStorage]
Expand All @@ -152,7 +152,7 @@
FilePath = "MetaHdrHashNonce"
Type = "LvlDBSerial"
BatchDelaySeconds = 2
MaxBatchSize = 100
MaxBatchSize = 1
MaxOpenFiles = 10

[AccountsTrieStorage]
Expand Down Expand Up @@ -364,5 +364,5 @@
PeerStatePruningEnabled = true

[BlockSizeThrottleConfig]
MinSizeInBytes = 104857 # 10% from 1MB
MaxSizeInBytes = 943718 # 90% from 1MB
MinSizeInBytes = 943718 # 943718 is 90% from 1MB or 104857 is 10% from 1MB
MaxSizeInBytes = 943718 # 943718 is 90% from 1MB
44 changes: 1 addition & 43 deletions cmd/node/config/economics.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Econimics config of the node
#Economics config of the node
[GlobalSettings]
TotalSupply = "20000000000000000000000000000" #20BILERD
MinimumInflation = 0.0
Expand Down Expand Up @@ -28,45 +28,3 @@
MaximumPercentageToBleed = "0.5"
BleedPercentagePerRound = "0.00001"
UnJailValue = "1000"

[RatingSettings]
StartRating = 500000
MaxRating = 1000000
MinRating = 1
ProposerIncreaseRatingStep = 405
ProposerDecreaseRatingStep = 810
ValidatorIncreaseRatingStep = 81
ValidatorDecreaseRatingStep = 162
[[RatingSettings.SelectionChance]]
MaxThreshold = 0
ChancePercent = 5
[[RatingSettings.SelectionChance]]
MaxThreshold = 100000
ChancePercent = 0
[[RatingSettings.SelectionChance]]
MaxThreshold = 200000
ChancePercent = 16
[[RatingSettings.SelectionChance]]
MaxThreshold = 300000
ChancePercent = 17
[[RatingSettings.SelectionChance]]
MaxThreshold = 400000
ChancePercent = 18
[[RatingSettings.SelectionChance]]
MaxThreshold = 500000
ChancePercent = 19
[[RatingSettings.SelectionChance]]
MaxThreshold = 600000
ChancePercent = 20
[[RatingSettings.SelectionChance]]
MaxThreshold = 700000
ChancePercent = 21
[[RatingSettings.SelectionChance]]
MaxThreshold = 800000
ChancePercent = 22
[[RatingSettings.SelectionChance]]
MaxThreshold = 900000
ChancePercent = 23
[[RatingSettings.SelectionChance]]
MaxThreshold = 1000000
ChancePercent = 24
43 changes: 43 additions & 0 deletions cmd/node/config/ratings.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#Ratings configuration

# proposer-validator importanceRatio = 1 =>
# 50% rating increase from proposer and 50% rating increase from validator

# ProposerIncreaseRatingStep = 1/2 * (maxRating - startRating)/(nrTimesProposerPerHour * hoursToGetToMaxRating)
# ValidatorIncreaseRatingStep = 1/2 * (maxRating - startRating)/(nrTimeValidatorPerHour * hoursToGetToMaxRating)
# ProposerDecreaseRatingStep = -2 * ProposerIncreaseRatingStep
# ValidatorDecreaseRatingStep = -2 * ValidatorIncreaseRatingStep


[General]
StartRating = 500000
MaxRating = 1000000
MinRating = 1
SignedBlocksThreshold = 0.025
SelectionChances = [
{ MaxThreshold = 0, ChancePercent = 5},
{ MaxThreshold = 100000,ChancePercent = 0},
{ MaxThreshold = 200000,ChancePercent = 16},
{ MaxThreshold = 300000,ChancePercent = 17},
{ MaxThreshold = 400000,ChancePercent = 18},
{ MaxThreshold = 500000,ChancePercent = 19},
{ MaxThreshold = 600000,ChancePercent = 20},
{ MaxThreshold = 700000,ChancePercent = 21},
{ MaxThreshold = 800000,ChancePercent = 22},
{ MaxThreshold = 900000,ChancePercent = 23},
{ MaxThreshold = 1000000,ChancePercent = 24},
]

[ShardChain.RatingSteps]
ProposerIncreaseRatingStep = 405
ProposerDecreaseRatingStep = -810
ValidatorIncreaseRatingStep = 81
ValidatorDecreaseRatingStep = -162
ConsecutiveMissedBlocksPenalty = 1.12

[MetaChain.RatingSteps]
ProposerIncreaseRatingStep = 810
ProposerDecreaseRatingStep = -1620
ValidatorIncreaseRatingStep = 162
ValidatorDecreaseRatingStep = -324
ConsecutiveMissedBlocksPenalty = 1.12
Loading

0 comments on commit 6ec34a0

Please sign in to comment.