Skip to content

Commit 6b078d8

Browse files
authored
Merge pull request #733 from MinterTeam/dev
v2.6
2 parents 7cf8f1b + 7a48b32 commit 6b078d8

125 files changed

Lines changed: 16608 additions & 1334 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
name: m2-testnet
1+
name: taconet
22

33
on:
44
push:
5-
branches: [ v2.0 ]
5+
branches: [ taconet ]
66

77
jobs:
88
build:
99
name: Build & Deploy
1010
runs-on: ubuntu-latest
1111
steps:
12-
- name: Set up Go 1.15
12+
- name: Set up Go 1.16
1313
uses: actions/setup-go@v2
1414
with:
15-
go-version: ^1.15
15+
go-version: ^1.16
1616

1717
- name: Check out code into the Go module directory
1818
uses: actions/checkout@v2
1919

2020
- name: Get dependencies
2121
run: |
22-
go mod download
22+
go mod tidy
2323
2424
- name: Build
2525
env:
@@ -38,14 +38,14 @@ jobs:
3838
target: "/tmp/node"
3939
rm: true
4040

41-
- name: Rename old build
41+
- name: Remove old build
4242
uses: appleboy/ssh-action@master
4343
with:
4444
host: ${{ secrets.NODE_V2_HOST }}
4545
USERNAME: ${{ secrets.NODE_V2_USERNAME }}
4646
PORT: ${{ secrets.NODE_V2_PORT }}
4747
KEY: ${{ secrets.NODE_V2_SSH }}
48-
script: mv /opt/minter/node/minter /opt/minter/node/minter_${{ github.sha }}
48+
script: rm /opt/minter/node/minter
4949

5050
- name: Copy new build
5151
uses: appleboy/ssh-action@master
@@ -56,6 +56,15 @@ jobs:
5656
KEY: ${{ secrets.NODE_V2_SSH }}
5757
script: mv /tmp/node/build/minter /opt/minter/node/minter
5858

59+
- name: Copy backup build
60+
uses: appleboy/ssh-action@master
61+
with:
62+
host: ${{ secrets.NODE_V2_HOST }}
63+
USERNAME: ${{ secrets.NODE_V2_USERNAME }}
64+
PORT: ${{ secrets.NODE_V2_PORT }}
65+
KEY: ${{ secrets.NODE_V2_SSH }}
66+
script: cp /opt/minter/node/minter /opt/minter/node/minter_${{ github.sha }}
67+
5968
- name: Restart service
6069
uses: appleboy/ssh-action@master
6170
with:

CHANGELOG.md

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

3+
## [v2.6.0](https://github.com/MinterTeam/minter-go-node/tree/v2.6.0)
4+
5+
[Full Changelog](https://github.com/MinterTeam/minter-go-node/compare/v2.5.0...v2.6.0)
6+
7+
### Added
8+
9+
- AMM with Order Book
10+
- Allow all holders to burn tokens
11+
- Limitation of the maximum total stake of a candidate to 20% of the sum of all candidates
12+
- Removal of candidates that do not fall into the top 100 by stake size
13+
314
## [v2.5.0](https://github.com/MinterTeam/minter-go-node/tree/v2.5.0)
415

516
[Full Changelog](https://github.com/MinterTeam/minter-go-node/compare/v2.4.1...v2.5.0)

api/v2/service/block.go

Lines changed: 119 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99
"time"
1010

11+
"github.com/MinterTeam/minter-go-node/coreV2/events"
1112
"github.com/MinterTeam/minter-go-node/coreV2/state/coins"
1213
"github.com/MinterTeam/minter-go-node/coreV2/types"
1314
pb "github.com/MinterTeam/node-grpc-gateway/api_pb"
@@ -17,6 +18,8 @@ import (
1718
tmTypes "github.com/tendermint/tendermint/types"
1819
"google.golang.org/grpc/codes"
1920
"google.golang.org/grpc/status"
21+
"google.golang.org/protobuf/proto"
22+
"google.golang.org/protobuf/types/known/anypb"
2023
)
2124

2225
// Block returns block data at given height.
@@ -42,7 +45,7 @@ func (s *Service) Block(ctx context.Context, req *pb.BlockRequest) (*pb.BlockRes
4245
if _, ok := fields[pb.BlockField_transactions]; ok {
4346
blockResults, err = s.client.BlockResults(ctx, &height)
4447
if err != nil {
45-
return nil, status.Error(codes.NotFound, "Block results not found")
48+
return nil, status.Error(codes.NotFound, "Block results not found") // fmt.Sprintf("Block results not found: %v", err))
4649
}
4750
}
4851

@@ -73,6 +76,121 @@ func (s *Service) Block(ctx context.Context, req *pb.BlockRequest) (*pb.BlockRes
7376
TransactionCount: uint64(len(block.Block.Txs)),
7477
}
7578

79+
if req.Events {
80+
loadEvents := s.blockchain.GetEventsDB().LoadEvents(uint32(req.Height))
81+
for _, event := range loadEvents {
82+
var m proto.Message
83+
switch e := event.(type) {
84+
case *events.JailEvent:
85+
m = &pb.JailEvent{
86+
ValidatorPubKey: e.ValidatorPubKeyString(),
87+
JailedUntil: e.JailedUntil,
88+
}
89+
case *events.OrderExpiredEvent:
90+
m = &pb.OrderExpiredEvent{
91+
Id: e.ID,
92+
Address: e.AddressString(),
93+
Coin: e.Coin,
94+
Amount: e.Amount,
95+
}
96+
case *events.RewardEvent:
97+
m = &pb.RewardEvent{
98+
Role: pb.RewardEvent_Role(pb.RewardEvent_Role_value[e.Role]),
99+
Address: e.AddressString(),
100+
Amount: e.Amount,
101+
ForCoin: e.ForCoin,
102+
ValidatorPubKey: e.ValidatorPubKeyString(),
103+
}
104+
case *events.SlashEvent:
105+
m = &pb.SlashEvent{
106+
Address: e.AddressString(),
107+
Amount: e.Amount,
108+
Coin: e.Coin,
109+
ValidatorPubKey: e.ValidatorPubKeyString(),
110+
}
111+
case *events.StakeKickEvent:
112+
m = &pb.StakeKickEvent{
113+
Address: e.AddressString(),
114+
Amount: e.Amount,
115+
Coin: e.Coin,
116+
ValidatorPubKey: e.ValidatorPubKeyString(),
117+
}
118+
case *events.UnbondEvent:
119+
m = &pb.UnbondEvent{
120+
Address: e.AddressString(),
121+
Amount: e.Amount,
122+
Coin: e.Coin,
123+
ValidatorPubKey: e.ValidatorPubKeyString(),
124+
}
125+
case *events.RemoveCandidateEvent:
126+
m = &pb.RemoveCandidateEvent{
127+
CandidatePubKey: e.CandidatePubKeyString(),
128+
}
129+
case *events.UpdateNetworkEvent:
130+
m = &pb.UpdateNetworkEvent{
131+
Version: e.Version,
132+
}
133+
case *events.UpdateCommissionsEvent:
134+
m = &pb.UpdateCommissionsEvent{
135+
Coin: e.Coin,
136+
PayloadByte: e.PayloadByte,
137+
Send: e.Send,
138+
BuyBancor: e.BuyBancor,
139+
SellBancor: e.SellBancor,
140+
SellAllBancor: e.SellAllBancor,
141+
BuyPoolBase: e.BuyPoolBase,
142+
BuyPoolDelta: e.BuyPoolDelta,
143+
SellPoolBase: e.SellPoolBase,
144+
SellPoolDelta: e.SellPoolDelta,
145+
SellAllPoolBase: e.SellAllPoolBase,
146+
SellAllPoolDelta: e.SellAllPoolDelta,
147+
CreateTicker3: e.CreateTicker3,
148+
CreateTicker4: e.CreateTicker4,
149+
CreateTicker5: e.CreateTicker5,
150+
CreateTicker6: e.CreateTicker6,
151+
CreateTicker7_10: e.CreateTicker7_10,
152+
CreateCoin: e.CreateCoin,
153+
CreateToken: e.CreateToken,
154+
RecreateCoin: e.RecreateCoin,
155+
RecreateToken: e.RecreateToken,
156+
DeclareCandidacy: e.DeclareCandidacy,
157+
Delegate: e.Delegate,
158+
Unbond: e.Unbond,
159+
RedeemCheck: e.RedeemCheck,
160+
SetCandidateOn: e.SetCandidateOn,
161+
SetCandidateOff: e.SetCandidateOff,
162+
CreateMultisig: e.CreateMultisig,
163+
MultisendBase: e.MultisendBase,
164+
MultisendDelta: e.MultisendDelta,
165+
EditCandidate: e.EditCandidate,
166+
SetHaltBlock: e.SetHaltBlock,
167+
EditTickerOwner: e.EditTickerOwner,
168+
EditMultisig: e.EditMultisig,
169+
EditCandidatePublicKey: e.EditCandidatePublicKey,
170+
CreateSwapPool: e.CreateSwapPool,
171+
AddLiquidity: e.AddLiquidity,
172+
RemoveLiquidity: e.RemoveLiquidity,
173+
EditCandidateCommission: e.EditCandidateCommission,
174+
MintToken: e.MintToken,
175+
BurnToken: e.BurnToken,
176+
VoteCommission: e.VoteCommission,
177+
VoteUpdate: e.VoteUpdate,
178+
FailedTx: e.FailedTx,
179+
AddLimitOrder: e.AddLimitOrder,
180+
RemoveLimitOrder: e.RemoveLimitOrder,
181+
}
182+
default:
183+
return nil, status.Error(codes.Internal, "unknown event type")
184+
}
185+
186+
a, err := anypb.New(m)
187+
if err != nil {
188+
return nil, status.Error(codes.Internal, err.Error())
189+
}
190+
response.Events = append(response.Events, a)
191+
}
192+
}
193+
76194
for field := range fields {
77195
if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil {
78196
return nil, timeoutStatus.Err()

api/v2/service/blocks.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package service
22

33
import (
44
"context"
5+
56
pb "github.com/MinterTeam/node-grpc-gateway/api_pb"
67
"google.golang.org/grpc/codes"
78
"google.golang.org/grpc/status"
@@ -17,6 +18,7 @@ func (s *Service) Blocks(ctx context.Context, req *pb.BlocksRequest) (*pb.Blocks
1718
Height: i,
1819
Fields: req.Fields,
1920
FailedTxs: req.FailedTxs,
21+
Events: req.Events,
2022
})
2123
if err != nil {
2224
if status.Code(err) == codes.NotFound {

api/v2/service/data_encoder.go

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func encode(data transaction.Data, txType transaction.TxType, rCoins coins.RCoin
7575
Stake: d.Stake.String(),
7676
}
7777
case transaction.TypeDelegate:
78-
d := data.(*transaction.DelegateData)
78+
d := data.(*transaction.DelegateDataV260)
7979
m = &pb.DelegateData{
8080
PubKey: d.PubKey.String(),
8181
Coin: &pb.Coin{
@@ -199,7 +199,7 @@ func encode(data transaction.Data, txType transaction.TxType, rCoins coins.RCoin
199199
PubKey: d.PubKey.String(),
200200
}
201201
case transaction.TypeUnbond:
202-
d := data.(*transaction.UnbondData)
202+
d := data.(*transaction.UnbondDataV260)
203203
m = &pb.UnbondData{
204204
PubKey: d.PubKey.String(),
205205
Coin: &pb.Coin{
@@ -209,7 +209,7 @@ func encode(data transaction.Data, txType transaction.TxType, rCoins coins.RCoin
209209
Value: d.Value.String(),
210210
}
211211
case transaction.TypeAddLiquidity:
212-
d := data.(*transaction.AddLiquidityDataV240)
212+
d := data.(*transaction.AddLiquidityDataV260)
213213
m = &pb.AddLiquidityData{
214214
Coin0: &pb.Coin{
215215
Id: uint64(d.Coin0),
@@ -238,7 +238,7 @@ func encode(data transaction.Data, txType transaction.TxType, rCoins coins.RCoin
238238
MinimumVolume1: d.MinimumVolume1.String(),
239239
}
240240
case transaction.TypeBuySwapPool:
241-
d := data.(*transaction.BuySwapPoolDataV240)
241+
d := data.(*transaction.BuySwapPoolDataV260)
242242
var coinsInfo []*pb.Coin
243243
for _, coin := range d.Coins {
244244
coinsInfo = append(coinsInfo, &pb.Coin{
@@ -252,7 +252,7 @@ func encode(data transaction.Data, txType transaction.TxType, rCoins coins.RCoin
252252
MaximumValueToSell: d.MaximumValueToSell.String(),
253253
}
254254
case transaction.TypeSellSwapPool:
255-
d := data.(*transaction.SellSwapPoolDataV240)
255+
d := data.(*transaction.SellSwapPoolDataV260)
256256
var coinsInfo []*pb.Coin
257257
for _, coin := range d.Coins {
258258
coinsInfo = append(coinsInfo, &pb.Coin{
@@ -266,7 +266,7 @@ func encode(data transaction.Data, txType transaction.TxType, rCoins coins.RCoin
266266
MinimumValueToBuy: d.MinimumValueToBuy.String(),
267267
}
268268
case transaction.TypeSellAllSwapPool:
269-
d := data.(*transaction.SellAllSwapPoolDataV240)
269+
d := data.(*transaction.SellAllSwapPoolDataV260)
270270
var coinsInfo []*pb.Coin
271271
for _, coin := range d.Coins {
272272
coinsInfo = append(coinsInfo, &pb.Coin{
@@ -299,7 +299,7 @@ func encode(data transaction.Data, txType transaction.TxType, rCoins coins.RCoin
299299
Burnable: d.Burnable,
300300
}
301301
case transaction.TypeBurnToken:
302-
d := data.(*transaction.BurnTokenData)
302+
d := data.(*transaction.BurnTokenDataV260)
303303
m = &pb.BurnTokenData{
304304
Coin: &pb.Coin{
305305
Id: uint64(d.Coin),
@@ -346,6 +346,25 @@ func encode(data transaction.Data, txType transaction.TxType, rCoins coins.RCoin
346346
Volume0: d.Volume0.String(),
347347
Volume1: d.Volume1.String(),
348348
}
349+
case transaction.TypeAddLimitOrder:
350+
d := data.(*transaction.AddLimitOrderData)
351+
m = &pb.AddLimitOrderData{
352+
CoinToBuy: &pb.Coin{
353+
Id: uint64(d.CoinToBuy),
354+
Symbol: rCoins.GetCoin(d.CoinToBuy).GetFullSymbol(),
355+
},
356+
CoinToSell: &pb.Coin{
357+
Id: uint64(d.CoinToSell),
358+
Symbol: rCoins.GetCoin(d.CoinToSell).GetFullSymbol(),
359+
},
360+
ValueToBuy: d.ValueToBuy.String(),
361+
ValueToSell: d.ValueToSell.String(),
362+
}
363+
case transaction.TypeRemoveLimitOrder:
364+
d := data.(*transaction.RemoveLimitOrderData)
365+
m = &pb.RemoveLimitOrderData{
366+
Id: uint64(d.ID),
367+
}
349368
default:
350369
return nil, errors.New("unknown tx type")
351370
}

api/v2/service/estimate_coin_buy.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package service
33
import (
44
"context"
55
"fmt"
6+
"github.com/MinterTeam/minter-go-node/coreV2/state/coins"
67
"math/big"
78

89
"github.com/MinterTeam/minter-go-node/coreV2/code"
@@ -184,21 +185,20 @@ func (s *Service) calcBuyFromPool(ctx context.Context, value *big.Int, cState *s
184185
}
185186
}
186187

187-
sellValue := swapChecker.CalculateSellForBuy(buyValue)
188-
if sellValue == nil {
189-
reserve0, reserve1 := swapChecker.Reserves()
190-
symbolOut := coinBuy.GetFullSymbol()
191-
return nil, s.createError(status.New(codes.FailedPrecondition, fmt.Sprintf("You wanted to buy %s %s, but pool reserve has only %s %s", value, symbolOut, reserve1.String(), symbolOut)), transaction.EncodeError(code.NewInsufficientLiquidity(coinFrom.ID().String(), "", coinBuy.ID().String(), value.String(), reserve0.String(), reserve1.String())))
192-
}
193-
194188
coinSell := coinFrom
195189
if sellCoinID != coinSell.ID() {
196190
coinSell = cState.Coins().GetCoin(sellCoinID)
197191
}
198192

199-
if errResp := transaction.CheckSwap(swapChecker, coinSell, coinBuy, sellValue, buyValue, true); errResp != nil {
193+
errResp, sellValue := transaction.CheckSwap(swapChecker, coinSell, coinBuy, coins.MaxCoinSupply(), buyValue, true)
194+
if errResp != nil {
200195
return nil, s.createError(status.New(codes.FailedPrecondition, errResp.Log), errResp.Info)
201196
}
197+
if sellValue == nil || sellValue.Sign() != 1 {
198+
reserve0, reserve1 := swapChecker.Reserves()
199+
symbolOut := coinBuy.GetFullSymbol()
200+
return nil, s.createError(status.New(codes.FailedPrecondition, fmt.Sprintf("You wanted to buy %s %s, but pool reserve has only %s %s", value, symbolOut, reserve1.String(), symbolOut)), transaction.EncodeError(code.NewInsufficientLiquidity(coinFrom.ID().String(), "", coinBuy.ID().String(), value.String(), reserve0.String(), reserve1.String())))
201+
}
202202

203203
buyValue = sellValue
204204
coinBuy = coinSell
@@ -283,7 +283,7 @@ func (s *Service) calcBuyPoolWithCommission(ctx context.Context, commissions *co
283283

284284
commissionPoolSwapper := cState.Swap().GetSwapper(requestCoinCommissionID, types.GetBaseCoinID())
285285
if commissionFromPool && requestCoinCommissionID != types.GetBaseCoinID() {
286-
commissionPoolSwapper = commissionPoolSwapper.AddLastSwapStep(commission, commissionInBaseCoin)
286+
commissionPoolSwapper = commissionPoolSwapper.AddLastSwapStepWithOrders(commission, commissionInBaseCoin, false)
287287
}
288288

289289
if timeoutStatus := s.checkTimeout(ctx); timeoutStatus != nil {

0 commit comments

Comments
 (0)