Skip to content

Commit

Permalink
Merge pull request #315 from MinterTeam/dev
Browse files Browse the repository at this point in the history
v1.1.6
  • Loading branch information
danil-lashin authored Apr 7, 2020
2 parents a995e23 + eb86074 commit ac621f8
Show file tree
Hide file tree
Showing 30 changed files with 1,682 additions and 410 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.git
55 changes: 46 additions & 9 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,58 @@
name: docker

on: push
on:
push:
branches:
- master

pull_request:
branches:
- master

jobs:
docker:
env:
CONTAINER_NAME: minter_node
CONTAINER_TIMEOUT_SEC: 10
API_RUN_PORT: 8841
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Build & Push to Docker Hub
uses: opspresso/action-docker@master
env:
USERNAME: ${{ secrets.DOCKER_HUB_USER }}
PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
IMAGE_NAME: "minterteam/minter"
LATEST: "true"
TAG_NAME: "v1.0.5"
- name: Set envs
run: |
echo ::set-env name=VERSION::$(awk -F\" '/Version =/ { print $2; exit }' < version/version.go)
- name: Docker build
run: docker build -t ${{ secrets.DOCKER_HUB_USER }}/minter:${{ env.VERSION }} .

- name: Start docker container
run: docker run -d --name $CONTAINER_NAME -p $API_RUN_PORT:8841 ${{ secrets.DOCKER_HUB_USER }}/minter:${{ env.VERSION }}

- name: Check container is still running
run: |
echo ::set-env name=RUN_TEST_RESULT::$(sleep $CONTAINER_TIMEOUT_SEC && if [[ $(docker inspect -f "{{.State.Running}}" $CONTAINER_NAME 2> /dev/null) == true ]]; then echo OK; else echo FAIL; fi;)
- name: Check api is available by HTTP (response code is 200)
run: |
echo ::set-env name=API_TEST_RESULT::$(if [[ $(curl -LIs localhost:$API_RUN_PORT -o /dev/null -w '%{http_code}') == 200 ]]; then echo OK; else echo FAIL; fi)
- name: Print test results
run: |
echo $RUN_TEST_RESULT
echo $API_TEST_RESULT
- name: Tests fail
run: docker logs $CONTAINER_NAME && exit 1
if: ${{ env.RUN_TEST_RESULT }} == 'FAIL' || ${{ env.API_TEST_RESULT }} == 'FAIL'

- name: Docker push versioned image
run: docker push ${{ secrets.DOCKER_HUB_USER }}/minter:${{ env.VERSION }}
if: github.ref == 'refs/heads/master'

- name: Docker push latest image
run: docker push ${{ secrets.DOCKER_HUB_USER }}/minter:latest
if: github.ref == 'refs/heads/master'
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Changelog

## 1.1.6

IMPROVEMENT

- [export] Added export command
- [db] Update IAVL to v0.13.2
- [console] Added dashboard command
- [docker] Fix docker build config (@dmitry-ee)

BUG FIXES

- [prometheus] Fix too many open descriptors problem

## 1.1.5

IMPROVEMENT
Expand Down
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ RUN make build
FROM ubuntu:bionic

COPY --from=builder /gopath/src/github.com/MinterTeam/minter-go-node/build/minter/ /usr/bin/minter
RUN apt update && apt install libleveldb1v5 -y --no-install-recommends -q
RUN addgroup minteruser && useradd --no-log-init -r -m -d /minter -g minteruser minteruser
RUN chown -R minteruser:minteruser /minter
RUN apt update && apt install libleveldb1v5 ca-certificates -y --no-install-recommends -q && \
addgroup minteruser && \
useradd --no-log-init -r -m -d /minter -g minteruser minteruser && \
chown -R minteruser:minteruser /minter && \
rm -rf /var/lib/apt/lists/*

USER minteruser
WORKDIR /minter
RUN mkdir /minter/data
RUN mkdir /minter/data
EXPOSE 8841
ENTRYPOINT ["/usr/bin/minter"]
CMD ["node", "--home-dir", "/minter"]
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ You can get official installation instructions in our [docs](https://docs.minter
- [Documentation](https://docs.minter.network)
- [Official site](https://minter.network)
- [About Minter Blockchain](https://about.minter.network)
- [Minter Console](https://testnet.console.minter.network)
- [Minter Console](https://console.minter.network)
- [Minter Explorer](https://explorer.minter.network/)
- [Telegram Bot Wallet](https://t.me/BipWallet_Bot)
- [Android Wallet](https://play.google.com/store/apps/details?id=network.minter.bipwallet)

### Related repositories

- [minter-go-node-docs](https://github.com/MinterTeam/minter-go-node-docs) - Docs for Minter Node
- [node-grpc-gateway](https://github.com/MinterTeam/node-grpc-gateway) - gRPC interface and Swagger for Node API v2

### Community
- [Telegram Channel (English)](https://t.me/MinterTeam)
- [Telegram Channel (Russian)](https://t.me/MinterNetwork)
Expand Down
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func responseTime(b *minter.Blockchain) func(f func(http.ResponseWriter, *http.R
return func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
f(w, r)
b.StatisticData().SetApiTime(time.Now().Sub(start), r.URL.Path)
go b.StatisticData().SetApiTime(time.Now().Sub(start), r.URL.Path)
}
}
}
Expand Down
41 changes: 3 additions & 38 deletions api/v2/service/missed_blocks.go
Original file line number Diff line number Diff line change
@@ -1,51 +1,16 @@
package service

import (
"bytes"
"context"
"encoding/hex"
"fmt"
pb "github.com/MinterTeam/node-grpc-gateway/api_pb"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)

func (s *Service) MissedBlocks(_ context.Context, req *pb.MissedBlocksRequest) (*pb.MissedBlocksResponse, error) {
cState, err := s.getStateForHeight(req.Height)
blocks, count, err := s.blockchain.MissedBlocks(req.PublicKey, uint64(req.Height))
if err != nil {
return new(pb.MissedBlocksResponse), status.Error(codes.NotFound, err.Error())
return new(pb.MissedBlocksResponse), err
}

if req.Height != 0 {
cState.Lock()
cState.Validators.LoadValidators()
cState.Unlock()
}

cState.RLock()
defer cState.RUnlock()

vals := cState.Validators.GetValidators()
if vals == nil {
return new(pb.MissedBlocksResponse), status.Error(codes.NotFound, "Validators not found")
}

for _, val := range vals {
if len(req.PublicKey) < 3 {
return new(pb.MissedBlocksResponse), status.Error(codes.InvalidArgument, "invalid public_key")
}
decodeString, err := hex.DecodeString(req.PublicKey[2:])
if err != nil {
return new(pb.MissedBlocksResponse), status.Error(codes.InvalidArgument, err.Error())
}
if bytes.Compare(val.PubKey[:], decodeString) == 0 {
return &pb.MissedBlocksResponse{
MissedBlocks: val.AbsentTimes.String(),
MissedBlocksCount: fmt.Sprintf("%d", val.CountAbsentTimes()),
}, nil
}
}

return new(pb.MissedBlocksResponse), status.Error(codes.NotFound, "Validator not found")

return &pb.MissedBlocksResponse{MissedBlocks: blocks, MissedBlocksCount: fmt.Sprintf("%d", count)}, nil
}
1 change: 0 additions & 1 deletion api/v2/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func Run(srv *service.Service, addrGRPC, addrApi string) error {
grpc.UnaryInterceptor(grpc_prometheus.UnaryServerInterceptor),
)
gw.RegisterApiServiceServer(grpcServer, srv)
grpc_prometheus.EnableHandlingTimeHistogram()
grpc_prometheus.Register(grpcServer)

var group errgroup.Group
Expand Down
5 changes: 5 additions & 0 deletions cli/pb/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

cd "$(dirname "$0")" || exit

protoc --go_out=plugins=grpc:. ./manager.proto
Loading

0 comments on commit ac621f8

Please sign in to comment.