Skip to content

Commit 43f4f18

Browse files
author
Klimov Sergey
authored
Merge pull request #789 from MinterTeam/dev
v3.1.1
2 parents 8566f58 + 8641711 commit 43f4f18

13 files changed

Lines changed: 127 additions & 30 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [v3.1.1](https://github.com/MinterTeam/minter-go-node/tree/v3.1.1)
4+
5+
[Full Changelog](https://github.com/MinterTeam/minter-go-node/compare/v3.1.0...v3.1.1)
6+
7+
### Fixed
8+
9+
- Find coins with last symbol `-`
10+
- Accrual of rewards x3 with `GetAccumReward == 0`
11+
312
## [v3.1.0](https://github.com/MinterTeam/minter-go-node/tree/v3.1.0)
413

514
[Full Changelog](https://github.com/MinterTeam/minter-go-node/compare/v3.0.3...v3.1.0)

api/v2/service/candidate.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,17 @@ func (s *Service) Candidate(ctx context.Context, req *pb.CandidateRequest) (*pb.
3232
return nil, status.Error(codes.NotFound, err.Error())
3333
}
3434

35+
if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil {
36+
return nil, timeoutStatus.Err()
37+
}
38+
3539
if req.Height != 0 {
3640
cState.Candidates().LoadCandidates()
41+
cState.Validators().LoadValidators()
42+
}
43+
44+
if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil {
45+
return nil, timeoutStatus.Err()
3746
}
3847

3948
candidate := cState.Candidates().GetCandidate(pubkey)
@@ -45,15 +54,23 @@ func (s *Service) Candidate(ctx context.Context, req *pb.CandidateRequest) (*pb.
4554
cState.Candidates().LoadStakesOfCandidate(pubkey)
4655
}
4756

48-
result := makeResponseCandidate(cState, candidate, true, req.NotShowStakes)
57+
if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil {
58+
return nil, timeoutStatus.Err()
59+
}
60+
61+
result := s.makeResponseCandidate(ctx, cState, candidate, true, req.NotShowStakes)
4962
if cState.Validators().GetByPublicKey(candidate.PubKey) != nil {
5063
result.Validator = true
5164
}
5265

66+
if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil {
67+
return nil, timeoutStatus.Err()
68+
}
69+
5370
return result, nil
5471
}
5572

56-
func makeResponseCandidate(state *state.CheckState, c *candidates.Candidate, includeStakes, NotShowStakes bool) *pb.CandidateResponse {
73+
func (s *Service) makeResponseCandidate(ctx context.Context, state *state.CheckState, c *candidates.Candidate, includeStakes, NotShowStakes bool) *pb.CandidateResponse {
5774
candidate := &pb.CandidateResponse{
5875
RewardAddress: c.RewardAddress.String(),
5976
OwnerAddress: c.OwnerAddress.String(),
@@ -75,6 +92,10 @@ func makeResponseCandidate(state *state.CheckState, c *candidates.Candidate, inc
7592
candidate.Stakes = make([]*pb.CandidateResponse_Stake, 0, usedSlots)
7693
}
7794
for i, stake := range stakes {
95+
if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil {
96+
return candidate
97+
}
98+
7899
if !NotShowStakes {
79100
candidate.Stakes = append(candidate.Stakes, &pb.CandidateResponse_Stake{
80101
Owner: stake.Owner.String(),

api/v2/service/candidates.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,17 @@ func (s *Service) Candidates(ctx context.Context, req *pb.CandidatesRequest) (*p
1414
return nil, status.Error(codes.NotFound, err.Error())
1515
}
1616

17+
if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil {
18+
return nil, timeoutStatus.Err()
19+
}
20+
1721
if req.Height != 0 {
1822
cState.Candidates().LoadCandidates()
23+
cState.Validators().LoadValidators()
24+
}
25+
26+
if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil {
27+
return nil, timeoutStatus.Err()
1928
}
2029

2130
candidates := cState.Candidates().GetCandidates()
@@ -46,9 +55,13 @@ func (s *Service) Candidates(ctx context.Context, req *pb.CandidatesRequest) (*p
4655
cState.Candidates().LoadStakesOfCandidate(candidate.PubKey)
4756
}
4857

49-
responseCandidate := makeResponseCandidate(cState, candidate, req.IncludeStakes, req.NotShowStakes)
58+
responseCandidate := s.makeResponseCandidate(ctx, cState, candidate, req.IncludeStakes, req.NotShowStakes)
5059
responseCandidate.Validator = isValidator
5160

61+
if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil {
62+
return nil, timeoutStatus.Err()
63+
}
64+
5265
response.Candidates = append(response.Candidates, responseCandidate)
5366
}
5467

api/v2/service/coin_info.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ func (s *Service) CoinInfo(ctx context.Context, req *pb.CoinInfoRequest) (*pb.Co
2020
return nil, status.Error(codes.NotFound, err.Error())
2121
}
2222

23+
if coinLen := len(req.Symbol); coinLen == 0 || req.Symbol[coinLen-1] == '-' {
24+
return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.Symbol, "")))
25+
}
2326
coin := cState.Coins().GetCoinBySymbol(types.StrToCoinBaseSymbol(req.Symbol), types.GetVersionFromSymbol(req.Symbol))
2427
if coin == nil {
2528
return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.Symbol, "")))

api/v2/service/estimate_coin_buy.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ func (s *Service) EstimateCoinBuy(ctx context.Context, req *pb.EstimateCoinBuyRe
3636

3737
var coinToBuy types.CoinID
3838
if req.GetCoinToBuy() != "" {
39+
if coinLen := len(req.GetCoinToBuy()); coinLen == 0 || req.GetCoinToBuy()[coinLen-1] == '-' {
40+
return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToBuy(), "")))
41+
}
3942
symbol := cState.Coins().GetCoinBySymbol(types.StrToCoinBaseSymbol(req.GetCoinToBuy()), types.GetVersionFromSymbol(req.GetCoinToBuy()))
4043
if symbol == nil {
4144
return nil, s.createError(status.New(codes.NotFound, "Coin to sell not exists"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToBuy(), "")))
@@ -50,6 +53,9 @@ func (s *Service) EstimateCoinBuy(ctx context.Context, req *pb.EstimateCoinBuyRe
5053

5154
var coinToSell types.CoinID
5255
if req.GetCoinToSell() != "" {
56+
if coinLen := len(req.GetCoinToSell()); coinLen == 0 || req.GetCoinToSell()[coinLen-1] == '-' {
57+
return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToSell(), "")))
58+
}
5359
symbol := cState.Coins().GetCoinBySymbol(types.StrToCoinBaseSymbol(req.GetCoinToSell()), types.GetVersionFromSymbol(req.GetCoinToSell()))
5460
if symbol == nil {
5561
return nil, s.createError(status.New(codes.NotFound, "Coin to sell not exists"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToSell(), "")))

api/v2/service/estimate_coin_sell.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ func (s *Service) EstimateCoinSell(ctx context.Context, req *pb.EstimateCoinSell
3535

3636
var coinToBuy types.CoinID
3737
if req.GetCoinToBuy() != "" {
38+
if coinLen := len(req.GetCoinToBuy()); coinLen == 0 || req.GetCoinToBuy()[coinLen-1] == '-' {
39+
return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToBuy(), "")))
40+
}
3841
symbol := cState.Coins().GetCoinBySymbol(types.StrToCoinBaseSymbol(req.GetCoinToBuy()), types.GetVersionFromSymbol(req.GetCoinToBuy()))
3942
if symbol == nil {
4043
return nil, s.createError(status.New(codes.NotFound, "Coin to buy not exists"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToBuy(), "")))
@@ -49,6 +52,9 @@ func (s *Service) EstimateCoinSell(ctx context.Context, req *pb.EstimateCoinSell
4952

5053
var coinToSell types.CoinID
5154
if req.GetCoinToSell() != "" {
55+
if coinLen := len(req.GetCoinToSell()); coinLen == 0 || req.GetCoinToSell()[coinLen-1] == '-' {
56+
return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToSell(), "")))
57+
}
5258
symbol := cState.Coins().GetCoinBySymbol(types.StrToCoinBaseSymbol(req.GetCoinToSell()), types.GetVersionFromSymbol(req.GetCoinToSell()))
5359
if symbol == nil {
5460
return nil, s.createError(status.New(codes.NotFound, "Coin to sell not exists"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToSell(), "")))

api/v2/service/estimate_coin_sell_all.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ func (s *Service) EstimateCoinSellAll(ctx context.Context, req *pb.EstimateCoinS
3232

3333
var coinToBuy types.CoinID
3434
if req.GetCoinToBuy() != "" {
35+
if coinLen := len(req.GetCoinToBuy()); coinLen == 0 || req.GetCoinToBuy()[coinLen-1] == '-' {
36+
return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToBuy(), "")))
37+
}
3538
symbol := cState.Coins().GetCoinBySymbol(types.StrToCoinBaseSymbol(req.GetCoinToBuy()), types.GetVersionFromSymbol(req.GetCoinToBuy()))
3639
if symbol == nil {
3740
return nil, s.createError(status.New(codes.NotFound, "Coin to buy not exists"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToBuy(), "")))
@@ -46,6 +49,9 @@ func (s *Service) EstimateCoinSellAll(ctx context.Context, req *pb.EstimateCoinS
4649

4750
var coinToSell types.CoinID
4851
if req.GetCoinToSell() != "" {
52+
if coinLen := len(req.GetCoinToSell()); coinLen == 0 || req.GetCoinToSell()[coinLen-1] == '-' {
53+
return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToSell(), "")))
54+
}
4955
symbol := cState.Coins().GetCoinBySymbol(types.StrToCoinBaseSymbol(req.GetCoinToSell()), types.GetVersionFromSymbol(req.GetCoinToSell()))
5056
if symbol == nil {
5157
return nil, s.createError(status.New(codes.NotFound, "Coin to sell not exists"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToSell(), "")))

config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ func DefaultConfig() *Config {
7878
//cfg.StateSync.RPCServers = []string{"sync-test.minter.network:26657", "sync104.minter.su:26657", "state-test.minter.network:26657"}
7979
cfg.StateSync.RPCServers = []string{"state-test.minter.network:26657", "sync-test.minter.network:26657", "sync101.minter.su:26657"}
8080

81-
cfg.StateSync.TrustHeight = 10197600
82-
cfg.StateSync.TrustHash = "BE035F6C00320FBB76D8B3C427891A03D46B3443A9E4309D777ABC4EAB4FDFCC"
81+
cfg.StateSync.TrustHeight = 10309900
82+
cfg.StateSync.TrustHash = "95AB9C70AE7B98F955CB05039A3B2A442F3DA4F95FF82B027A8144AE0E15C6BF"
8383
cfg.StateSync.TrustPeriod = time.Hour * 8760
8484

8585
return cfg

coreV2/minter/blockchain.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,6 @@ func (blockchain *Blockchain) BeginBlock(req abciTypes.RequestBeginBlock) abciTy
283283
blockchain.stateDeliver.App.SetReward(big.NewInt(0), big.NewInt(0))
284284
}
285285

286-
//}
287-
288286
blockchain.StatisticData().PushStartBlock(&statistics.StartRequest{Height: int64(height), Now: time.Now(), HeaderTime: req.Header.Time})
289287

290288
// compute max gas

coreV2/state/bus/candidates.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type Candidates interface {
1212
SetOffline(types.Pubkey)
1313
GetCandidate(types.Pubkey) *Candidate
1414
GetCandidateByTendermintAddress(types.TmAddress) *Candidate
15+
TotalStakes() *big.Int
1516
}
1617

1718
type Stake struct {

0 commit comments

Comments
 (0)