From 98404edd336e2729160ffc4bdb0148c7afeba4ad Mon Sep 17 00:00:00 2001 From: klim0v Date: Wed, 13 Apr 2022 20:05:13 +0300 Subject: [PATCH 1/9] AccumReward --- coreV2/state/bus/candidates.go | 1 + coreV2/state/candidates/bus.go | 4 +++ coreV2/state/validators/validators.go | 43 ++++++++++++++++----------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/coreV2/state/bus/candidates.go b/coreV2/state/bus/candidates.go index ca61dd4f0..e599c8b42 100644 --- a/coreV2/state/bus/candidates.go +++ b/coreV2/state/bus/candidates.go @@ -12,6 +12,7 @@ type Candidates interface { SetOffline(types.Pubkey) GetCandidate(types.Pubkey) *Candidate GetCandidateByTendermintAddress(types.TmAddress) *Candidate + TotalStakes() *big.Int } type Stake struct { diff --git a/coreV2/state/candidates/bus.go b/coreV2/state/candidates/bus.go index 47ec30705..bf21299ea 100644 --- a/coreV2/state/candidates/bus.go +++ b/coreV2/state/candidates/bus.go @@ -73,6 +73,10 @@ func (b *Bus) SetOffline(pubkey types.Pubkey) { b.candidates.SetOffline(pubkey) } +func (b *Bus) TotalStakes() *big.Int { + return b.candidates.TotalStakes() +} + // GetCandidateByTendermintAddress finds and returns candidate with given tendermint-address func (b *Bus) GetCandidateByTendermintAddress(tmAddress types.TmAddress) *bus.Candidate { candidate := b.candidates.GetCandidateByTendermintAddress(tmAddress) diff --git a/coreV2/state/validators/validators.go b/coreV2/state/validators/validators.go index 843d50917..394ff2537 100644 --- a/coreV2/state/validators/validators.go +++ b/coreV2/state/validators/validators.go @@ -509,23 +509,32 @@ func (v *Validators) PayRewardsV4(height uint64, period int64) (moreRewards *big safeRewards := big.NewInt(0).Mul(safeReward, big.NewInt(period)) safeRewards.Mul(safeRewards, stake.BipValue) safeRewards.Mul(safeRewards, big.NewInt(3)) - safeRewards.Mul(safeRewards, validator.GetAccumReward()) - safeRewards.Div(safeRewards, validator.GetTotalBipStake()) - safeRewards.Sub(safeRewards, big.NewInt(0).Div(big.NewInt(0).Mul(safeRewards, big.NewInt(int64(developers.Commission+dao.Commission))), big.NewInt(100))) - safeRewards.Sub(safeRewards, big.NewInt(0).Div(big.NewInt(0).Mul(safeRewards, big.NewInt(int64(candidate.Commission))), big.NewInt(100))) - safeRewards.Div(safeRewards, totalAccumRewards) - - calcRewards := big.NewInt(0).Mul(calcReward, big.NewInt(period)) - calcRewards.Mul(calcRewards, stake.BipValue) - calcRewards.Mul(calcRewards, validator.GetAccumReward()) - calcRewards.Div(calcRewards, validator.GetTotalBipStake()) - calcRewards.Sub(calcRewards, big.NewInt(0).Div(big.NewInt(0).Mul(calcRewards, big.NewInt(int64(developers.Commission+dao.Commission))), big.NewInt(100))) - calcRewards.Sub(calcRewards, big.NewInt(0).Div(big.NewInt(0).Mul(calcRewards, big.NewInt(int64(candidate.Commission))), big.NewInt(100))) - calcRewards.Div(calcRewards, totalAccumRewards) - - feeRewards := big.NewInt(0).Sub(reward, calcRewards) - - safeRewardVariable.Set(big.NewInt(0).Add(safeRewards, feeRewards)) + if validator.GetAccumReward().Sign() == 1 { + safeRewards.Mul(safeRewards, validator.GetAccumReward()) + safeRewards.Div(safeRewards, validator.GetTotalBipStake()) + + safeRewards.Sub(safeRewards, big.NewInt(0).Div(big.NewInt(0).Mul(safeRewards, big.NewInt(int64(developers.Commission+dao.Commission))), big.NewInt(100))) + safeRewards.Sub(safeRewards, big.NewInt(0).Div(big.NewInt(0).Mul(safeRewards, big.NewInt(int64(candidate.Commission))), big.NewInt(100))) + safeRewards.Div(safeRewards, totalAccumRewards) + + calcRewards := big.NewInt(0).Mul(calcReward, big.NewInt(period)) + calcRewards.Mul(calcRewards, stake.BipValue) + calcRewards.Mul(calcRewards, validator.GetAccumReward()) + calcRewards.Div(calcRewards, validator.GetTotalBipStake()) + calcRewards.Sub(calcRewards, big.NewInt(0).Div(big.NewInt(0).Mul(calcRewards, big.NewInt(int64(developers.Commission+dao.Commission))), big.NewInt(100))) + calcRewards.Sub(calcRewards, big.NewInt(0).Div(big.NewInt(0).Mul(calcRewards, big.NewInt(int64(candidate.Commission))), big.NewInt(100))) + calcRewards.Div(calcRewards, totalAccumRewards) + + feeRewards := big.NewInt(0).Sub(reward, calcRewards) + safeRewardVariable.Set(big.NewInt(0).Add(safeRewards, feeRewards)) + } else { + safeRewards.Div(safeRewards, v.bus.Candidates().TotalStakes()) + + safeRewards.Sub(safeRewards, big.NewInt(0).Div(big.NewInt(0).Mul(safeRewards, big.NewInt(int64(developers.Commission+dao.Commission))), big.NewInt(100))) + safeRewards.Sub(safeRewards, big.NewInt(0).Div(big.NewInt(0).Mul(safeRewards, big.NewInt(int64(candidate.Commission))), big.NewInt(100))) + + safeRewardVariable.Set(safeRewards) + } if safeRewardVariable.Sign() < 1 { continue From 552b9157e9936b173f206e9bdf4bb0e5bb0c7ada Mon Sep 17 00:00:00 2001 From: klim0v Date: Wed, 13 Apr 2022 20:19:10 +0300 Subject: [PATCH 2/9] version --- version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version/version.go b/version/version.go index e5d52d728..4f8cf517d 100755 --- a/version/version.go +++ b/version/version.go @@ -7,7 +7,7 @@ const ( var ( // Version must be a string because scripts like dist.sh read this file. - Version = "3.1.0" + Version = "3.1.1" // GitCommit is the current HEAD set using ldflags. GitCommit string From 9c2259e773b6baa022b02f0062765ca1397c3dd5 Mon Sep 17 00:00:00 2001 From: klim0v Date: Thu, 14 Apr 2022 15:41:42 +0300 Subject: [PATCH 3/9] check totalAccumRewards is 0 --- coreV2/state/validators/validators.go | 39 ++++++++++++++++++++------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/coreV2/state/validators/validators.go b/coreV2/state/validators/validators.go index 394ff2537..8065195e9 100644 --- a/coreV2/state/validators/validators.go +++ b/coreV2/state/validators/validators.go @@ -140,6 +140,19 @@ func (v *Validators) Count() int { return len(v.list) } +func (v *Validators) TotalStakes() *big.Int { + vals := v.GetValidators() + + v.lock.Lock() + defer v.lock.Unlock() + + totalStakes := big.NewInt(0) + for _, validator := range vals { + totalStakes.Add(totalStakes, validator.GetTotalBipStake()) + } + return totalStakes +} + func (v *Validators) getOrderedRemoved() []types.Pubkey { keys := make([]types.Pubkey, 0, len(v.removed)) for k := range v.removed { @@ -427,8 +440,16 @@ func (v *Validators) PayRewardsV4(height uint64, period int64) (moreRewards *big calcReward, safeReward := v.bus.App().Reward() var totalAccumRewards = big.NewInt(0) for _, validator := range vals { - totalAccumRewards = big.NewInt(0).Add(totalAccumRewards, validator.GetAccumReward()) + totalAccumRewards = totalAccumRewards.Add(totalAccumRewards, validator.GetAccumReward()) } + + var totalStakes = big.NewInt(0) + if totalAccumRewards.Sign() != 1 { + for _, validator := range vals { + totalStakes = totalStakes.Add(totalStakes, validator.GetTotalBipStake()) + } + } + for _, validator := range vals { candidate := v.bus.Candidates().GetCandidate(validator.PubKey) @@ -505,14 +526,12 @@ func (v *Validators) PayRewardsV4(height uint64, period int64) (moreRewards *big safeRewardVariable := big.NewInt(0).Set(reward) if validator.bus.Accounts().IsX3Mining(stake.Owner, height) { - - safeRewards := big.NewInt(0).Mul(safeReward, big.NewInt(period)) - safeRewards.Mul(safeRewards, stake.BipValue) - safeRewards.Mul(safeRewards, big.NewInt(3)) - if validator.GetAccumReward().Sign() == 1 { + if totalAccumRewards.Sign() == 1 { + safeRewards := big.NewInt(0).Mul(safeReward, big.NewInt(period)) + safeRewards.Mul(safeRewards, stake.BipValue) + safeRewards.Mul(safeRewards, big.NewInt(3)) safeRewards.Mul(safeRewards, validator.GetAccumReward()) safeRewards.Div(safeRewards, validator.GetTotalBipStake()) - safeRewards.Sub(safeRewards, big.NewInt(0).Div(big.NewInt(0).Mul(safeRewards, big.NewInt(int64(developers.Commission+dao.Commission))), big.NewInt(100))) safeRewards.Sub(safeRewards, big.NewInt(0).Div(big.NewInt(0).Mul(safeRewards, big.NewInt(int64(candidate.Commission))), big.NewInt(100))) safeRewards.Div(safeRewards, totalAccumRewards) @@ -528,10 +547,12 @@ func (v *Validators) PayRewardsV4(height uint64, period int64) (moreRewards *big feeRewards := big.NewInt(0).Sub(reward, calcRewards) safeRewardVariable.Set(big.NewInt(0).Add(safeRewards, feeRewards)) } else { - safeRewards.Div(safeRewards, v.bus.Candidates().TotalStakes()) - + safeRewards := big.NewInt(0).Mul(safeReward, big.NewInt(period)) + safeRewards.Mul(safeRewards, stake.BipValue) + safeRewards.Mul(safeRewards, big.NewInt(3)) safeRewards.Sub(safeRewards, big.NewInt(0).Div(big.NewInt(0).Mul(safeRewards, big.NewInt(int64(developers.Commission+dao.Commission))), big.NewInt(100))) safeRewards.Sub(safeRewards, big.NewInt(0).Div(big.NewInt(0).Mul(safeRewards, big.NewInt(int64(candidate.Commission))), big.NewInt(100))) + safeRewards.Div(safeRewards, totalStakes) safeRewardVariable.Set(safeRewards) } From 4f39f69a6c6807cd0bebf103dcb070a9fdd7fee0 Mon Sep 17 00:00:00 2001 From: klim0v Date: Thu, 14 Apr 2022 16:12:06 +0300 Subject: [PATCH 4/9] fix validator candidate status for old blocks --- api/v2/service/candidate.go | 25 +++++++++++++++++++++++-- api/v2/service/candidates.go | 15 ++++++++++++++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/api/v2/service/candidate.go b/api/v2/service/candidate.go index 5f62512d3..3f1ac0914 100644 --- a/api/v2/service/candidate.go +++ b/api/v2/service/candidate.go @@ -32,8 +32,17 @@ func (s *Service) Candidate(ctx context.Context, req *pb.CandidateRequest) (*pb. return nil, status.Error(codes.NotFound, err.Error()) } + if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil { + return nil, timeoutStatus.Err() + } + if req.Height != 0 { cState.Candidates().LoadCandidates() + cState.Validators().LoadValidators() + } + + if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil { + return nil, timeoutStatus.Err() } candidate := cState.Candidates().GetCandidate(pubkey) @@ -45,15 +54,23 @@ func (s *Service) Candidate(ctx context.Context, req *pb.CandidateRequest) (*pb. cState.Candidates().LoadStakesOfCandidate(pubkey) } - result := makeResponseCandidate(cState, candidate, true, req.NotShowStakes) + if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil { + return nil, timeoutStatus.Err() + } + + result := s.makeResponseCandidate(ctx, cState, candidate, true, req.NotShowStakes) if cState.Validators().GetByPublicKey(candidate.PubKey) != nil { result.Validator = true } + if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil { + return nil, timeoutStatus.Err() + } + return result, nil } -func makeResponseCandidate(state *state.CheckState, c *candidates.Candidate, includeStakes, NotShowStakes bool) *pb.CandidateResponse { +func (s *Service) makeResponseCandidate(ctx context.Context, state *state.CheckState, c *candidates.Candidate, includeStakes, NotShowStakes bool) *pb.CandidateResponse { candidate := &pb.CandidateResponse{ RewardAddress: c.RewardAddress.String(), OwnerAddress: c.OwnerAddress.String(), @@ -75,6 +92,10 @@ func makeResponseCandidate(state *state.CheckState, c *candidates.Candidate, inc candidate.Stakes = make([]*pb.CandidateResponse_Stake, 0, usedSlots) } for i, stake := range stakes { + if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil { + return candidate + } + if !NotShowStakes { candidate.Stakes = append(candidate.Stakes, &pb.CandidateResponse_Stake{ Owner: stake.Owner.String(), diff --git a/api/v2/service/candidates.go b/api/v2/service/candidates.go index 94c95eee3..adad02e33 100644 --- a/api/v2/service/candidates.go +++ b/api/v2/service/candidates.go @@ -14,8 +14,17 @@ func (s *Service) Candidates(ctx context.Context, req *pb.CandidatesRequest) (*p return nil, status.Error(codes.NotFound, err.Error()) } + if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil { + return nil, timeoutStatus.Err() + } + if req.Height != 0 { cState.Candidates().LoadCandidates() + cState.Validators().LoadValidators() + } + + if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil { + return nil, timeoutStatus.Err() } candidates := cState.Candidates().GetCandidates() @@ -46,9 +55,13 @@ func (s *Service) Candidates(ctx context.Context, req *pb.CandidatesRequest) (*p cState.Candidates().LoadStakesOfCandidate(candidate.PubKey) } - responseCandidate := makeResponseCandidate(cState, candidate, req.IncludeStakes, req.NotShowStakes) + responseCandidate := s.makeResponseCandidate(ctx, cState, candidate, req.IncludeStakes, req.NotShowStakes) responseCandidate.Validator = isValidator + if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil { + return nil, timeoutStatus.Err() + } + response.Candidates = append(response.Candidates, responseCandidate) } From 81e6fb7fd4bc6df722aeb91abfb7920d5675dd99 Mon Sep 17 00:00:00 2001 From: klim0v Date: Thu, 14 Apr 2022 19:30:41 +0300 Subject: [PATCH 5/9] cleanup code --- coreV2/minter/blockchain.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/coreV2/minter/blockchain.go b/coreV2/minter/blockchain.go index f752528b6..6b1e8f80d 100644 --- a/coreV2/minter/blockchain.go +++ b/coreV2/minter/blockchain.go @@ -283,8 +283,6 @@ func (blockchain *Blockchain) BeginBlock(req abciTypes.RequestBeginBlock) abciTy blockchain.stateDeliver.App.SetReward(big.NewInt(0), big.NewInt(0)) } - //} - blockchain.StatisticData().PushStartBlock(&statistics.StartRequest{Height: int64(height), Now: time.Now(), HeaderTime: req.Header.Time}) // compute max gas From 219acedd66432ff14a1d22be319c38131dcda511 Mon Sep 17 00:00:00 2001 From: klim0v Date: Fri, 15 Apr 2022 00:40:23 +0300 Subject: [PATCH 6/9] refactor pay rewards --- coreV2/state/validators/validators.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coreV2/state/validators/validators.go b/coreV2/state/validators/validators.go index 8065195e9..08fa5914d 100644 --- a/coreV2/state/validators/validators.go +++ b/coreV2/state/validators/validators.go @@ -526,7 +526,7 @@ func (v *Validators) PayRewardsV4(height uint64, period int64) (moreRewards *big safeRewardVariable := big.NewInt(0).Set(reward) if validator.bus.Accounts().IsX3Mining(stake.Owner, height) { - if totalAccumRewards.Sign() == 1 { + if totalAccumRewards.Sign() == 1 && validator.GetAccumReward().Sign() == 1 { safeRewards := big.NewInt(0).Mul(safeReward, big.NewInt(period)) safeRewards.Mul(safeRewards, stake.BipValue) safeRewards.Mul(safeRewards, big.NewInt(3)) @@ -546,7 +546,7 @@ func (v *Validators) PayRewardsV4(height uint64, period int64) (moreRewards *big feeRewards := big.NewInt(0).Sub(reward, calcRewards) safeRewardVariable.Set(big.NewInt(0).Add(safeRewards, feeRewards)) - } else { + } else if totalAccumRewards.Sign() != 1 && validator.GetAccumReward().Sign() != 1 { safeRewards := big.NewInt(0).Mul(safeReward, big.NewInt(period)) safeRewards.Mul(safeRewards, stake.BipValue) safeRewards.Mul(safeRewards, big.NewInt(3)) From afb3aa9d3408776828a8ed2cad14955a3d0c9753 Mon Sep 17 00:00:00 2001 From: klim0v Date: Mon, 18 Apr 2022 13:07:54 +0300 Subject: [PATCH 7/9] checking last symbol of coinSymbol --- api/v2/service/coin_info.go | 3 +++ api/v2/service/estimate_coin_buy.go | 6 ++++++ api/v2/service/estimate_coin_sell.go | 6 ++++++ api/v2/service/estimate_coin_sell_all.go | 6 ++++++ 4 files changed, 21 insertions(+) diff --git a/api/v2/service/coin_info.go b/api/v2/service/coin_info.go index f6c596b5a..02139b8b5 100644 --- a/api/v2/service/coin_info.go +++ b/api/v2/service/coin_info.go @@ -20,6 +20,9 @@ func (s *Service) CoinInfo(ctx context.Context, req *pb.CoinInfoRequest) (*pb.Co return nil, status.Error(codes.NotFound, err.Error()) } + if coinLen := len(req.Symbol); coinLen == 0 || req.Symbol[coinLen-1] == '-' { + return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.Symbol, ""))) + } coin := cState.Coins().GetCoinBySymbol(types.StrToCoinBaseSymbol(req.Symbol), types.GetVersionFromSymbol(req.Symbol)) if coin == nil { return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.Symbol, ""))) diff --git a/api/v2/service/estimate_coin_buy.go b/api/v2/service/estimate_coin_buy.go index 82a1b2636..8715d7922 100644 --- a/api/v2/service/estimate_coin_buy.go +++ b/api/v2/service/estimate_coin_buy.go @@ -36,6 +36,9 @@ func (s *Service) EstimateCoinBuy(ctx context.Context, req *pb.EstimateCoinBuyRe var coinToBuy types.CoinID if req.GetCoinToBuy() != "" { + if coinLen := len(req.GetCoinToBuy()); coinLen == 0 || req.GetCoinToBuy()[coinLen-1] == '-' { + return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToBuy(), ""))) + } symbol := cState.Coins().GetCoinBySymbol(types.StrToCoinBaseSymbol(req.GetCoinToBuy()), types.GetVersionFromSymbol(req.GetCoinToBuy())) if symbol == nil { 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 var coinToSell types.CoinID if req.GetCoinToSell() != "" { + if coinLen := len(req.GetCoinToSell()); coinLen == 0 || req.GetCoinToSell()[coinLen-1] == '-' { + return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToSell(), ""))) + } symbol := cState.Coins().GetCoinBySymbol(types.StrToCoinBaseSymbol(req.GetCoinToSell()), types.GetVersionFromSymbol(req.GetCoinToSell())) if symbol == nil { return nil, s.createError(status.New(codes.NotFound, "Coin to sell not exists"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToSell(), ""))) diff --git a/api/v2/service/estimate_coin_sell.go b/api/v2/service/estimate_coin_sell.go index 7214cd775..ce2155b98 100644 --- a/api/v2/service/estimate_coin_sell.go +++ b/api/v2/service/estimate_coin_sell.go @@ -35,6 +35,9 @@ func (s *Service) EstimateCoinSell(ctx context.Context, req *pb.EstimateCoinSell var coinToBuy types.CoinID if req.GetCoinToBuy() != "" { + if coinLen := len(req.GetCoinToBuy()); coinLen == 0 || req.GetCoinToBuy()[coinLen-1] == '-' { + return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToBuy(), ""))) + } symbol := cState.Coins().GetCoinBySymbol(types.StrToCoinBaseSymbol(req.GetCoinToBuy()), types.GetVersionFromSymbol(req.GetCoinToBuy())) if symbol == nil { 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 var coinToSell types.CoinID if req.GetCoinToSell() != "" { + if coinLen := len(req.GetCoinToSell()); coinLen == 0 || req.GetCoinToSell()[coinLen-1] == '-' { + return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToSell(), ""))) + } symbol := cState.Coins().GetCoinBySymbol(types.StrToCoinBaseSymbol(req.GetCoinToSell()), types.GetVersionFromSymbol(req.GetCoinToSell())) if symbol == nil { return nil, s.createError(status.New(codes.NotFound, "Coin to sell not exists"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToSell(), ""))) diff --git a/api/v2/service/estimate_coin_sell_all.go b/api/v2/service/estimate_coin_sell_all.go index d971fab7d..d37a3517a 100644 --- a/api/v2/service/estimate_coin_sell_all.go +++ b/api/v2/service/estimate_coin_sell_all.go @@ -32,6 +32,9 @@ func (s *Service) EstimateCoinSellAll(ctx context.Context, req *pb.EstimateCoinS var coinToBuy types.CoinID if req.GetCoinToBuy() != "" { + if coinLen := len(req.GetCoinToBuy()); coinLen == 0 || req.GetCoinToBuy()[coinLen-1] == '-' { + return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToBuy(), ""))) + } symbol := cState.Coins().GetCoinBySymbol(types.StrToCoinBaseSymbol(req.GetCoinToBuy()), types.GetVersionFromSymbol(req.GetCoinToBuy())) if symbol == nil { 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 var coinToSell types.CoinID if req.GetCoinToSell() != "" { + if coinLen := len(req.GetCoinToSell()); coinLen == 0 || req.GetCoinToSell()[coinLen-1] == '-' { + return nil, s.createError(status.New(codes.NotFound, "Coin not found"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToSell(), ""))) + } symbol := cState.Coins().GetCoinBySymbol(types.StrToCoinBaseSymbol(req.GetCoinToSell()), types.GetVersionFromSymbol(req.GetCoinToSell())) if symbol == nil { return nil, s.createError(status.New(codes.NotFound, "Coin to sell not exists"), transaction.EncodeError(code.NewCoinNotExists(req.GetCoinToSell(), ""))) From 65295d8f2b61ed110db162acad6a5af87b50a69a Mon Sep 17 00:00:00 2001 From: klim0v Date: Mon, 18 Apr 2022 13:13:36 +0300 Subject: [PATCH 8/9] CHANGELOG.md --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 481bfdf7a..b632bc313 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## [v3.1.1](https://github.com/MinterTeam/minter-go-node/tree/v3.1.1) + +[Full Changelog](https://github.com/MinterTeam/minter-go-node/compare/v3.1.0...v3.1.1) + +### Fixed + +- Find coins with last symbol `-` +- Accrual of rewards x3 with `GetAccumReward == 0` + ## [v3.1.0](https://github.com/MinterTeam/minter-go-node/tree/v3.1.0) [Full Changelog](https://github.com/MinterTeam/minter-go-node/compare/v3.0.3...v3.1.0) From c294035a86aa5bdf57faf830047ecc3858d75010 Mon Sep 17 00:00:00 2001 From: klim0v Date: Mon, 18 Apr 2022 15:55:22 +0300 Subject: [PATCH 9/9] update state-sync default params --- config/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 1e2b5c867..9334b1113 100644 --- a/config/config.go +++ b/config/config.go @@ -78,8 +78,8 @@ func DefaultConfig() *Config { //cfg.StateSync.RPCServers = []string{"sync-test.minter.network:26657", "sync104.minter.su:26657", "state-test.minter.network:26657"} cfg.StateSync.RPCServers = []string{"state-test.minter.network:26657", "sync-test.minter.network:26657", "sync101.minter.su:26657"} - cfg.StateSync.TrustHeight = 10197600 - cfg.StateSync.TrustHash = "BE035F6C00320FBB76D8B3C427891A03D46B3443A9E4309D777ABC4EAB4FDFCC" + cfg.StateSync.TrustHeight = 10309900 + cfg.StateSync.TrustHash = "95AB9C70AE7B98F955CB05039A3B2A442F3DA4F95FF82B027A8144AE0E15C6BF" cfg.StateSync.TrustPeriod = time.Hour * 8760 return cfg