Skip to content

Commit

Permalink
Merge pull request #680 from MinterTeam/dev
Browse files Browse the repository at this point in the history
v2.5.0
  • Loading branch information
danil-lashin authored Sep 2, 2021
2 parents de9e3e6 + f5a6a79 commit de7950c
Show file tree
Hide file tree
Showing 40 changed files with 2,368 additions and 563 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Publish
on:
push:
tags:
- '*'
jobs:
publish:
name: Publish for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
asset_name: linux_amd64
- os: macos-latest
asset_name: darwin_amd64
steps:

- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
go-version: ^1.16

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

- name: Set version to environment variables
id: get-version
run: |
rm -rf build
mkdir -p assets
echo ::set-output name=GIT_COMMIT::$(git rev-parse --short=8 HEAD)
echo ::set-output name=VERSION::$(awk -F\" '/Version =/ { print $2; exit }' < version/version.go)
- name: Building version ${{ steps.get-version.outputs.VERSION }} for ${{ matrix.asset_name }}
run: |
make build_c
- name: Packaging in zip archive
run: |
zip -j "./assets/minter_${{ steps.get-version.outputs.VERSION }}_${{ steps.get-version.outputs.GIT_COMMIT }}_${{ matrix.asset_name }}.zip" ./build/minter
shasum -a256 ./assets/minter_${{ steps.get-version.outputs.VERSION }}_${{ steps.get-version.outputs.GIT_COMMIT }}_${{ matrix.asset_name }}.zip > "./assets/minter_${{ steps.get-version.outputs.VERSION }}_${{ steps.get-version.outputs.GIT_COMMIT }}_${{ matrix.asset_name }}_SHA256SUMS"
- name: Upload binary to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./assets/minter_${{ steps.get-version.outputs.VERSION }}_${{ steps.get-version.outputs.GIT_COMMIT }}_${{ matrix.asset_name }}.zip
tag: ${{ github.ref }}
file_glob: true
overwrite: true

- name: Upload SHA256SUMS to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./assets/minter_${{ steps.get-version.outputs.VERSION }}_${{ steps.get-version.outputs.GIT_COMMIT }}_${{ matrix.asset_name }}_SHA256SUMS
tag: ${{ github.ref }}
file_glob: true
overwrite: true
22 changes: 18 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
# Changelog

## [v2.5.0](https://github.com/MinterTeam/minter-go-node/tree/v2.5.0)

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

### Added

- Commission fee for unsuccessful transactions
- Prioritizing transactions in a block based on gas multiplier (not enabled)

### Fixed

- Custom commissions with gas multiplier
- Parallel getting and updating of balances

## [v2.4.1](https://github.com/MinterTeam/minter-go-node/tree/v2.4.1)

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

### Fixed

- Fixed deadlock in block's commit
- Deadlock in block's commit
- Backward compatibility of older blocks

## [v2.4.0](https://github.com/MinterTeam/minter-go-node/tree/v2.4.0)
Expand Down Expand Up @@ -40,7 +54,7 @@

### Fixed

- Fix a critical bug in the exchange transaction through the pool
- Critical bug in the exchange transaction through the pool
- Import and export for new entities
- Graceful stop of the node

Expand All @@ -58,7 +72,7 @@

### Fixed

- Fix issue with db corruption while using delegated balance of addresses API
- Issue with db corruption while using delegated balance of addresses API
- Improved processing of incoming transactions

## [v2.0.2](https://github.com/MinterTeam/minter-go-node/tree/v2.0.2)
Expand All @@ -75,7 +89,7 @@

### Fixed

- Fix issue with db corruption while using list of candidates API
- Issue with db corruption while using list of candidates API
- Connecting to peers with cli

### Added
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ build:
CGO_ENABLED=0 go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' -o build/minter ./cmd/minter/

build_c:
CGO_ENABLED=1 go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS) gcc cleveldb' -o build/minter ./cmd/minter/
CGO_ENABLED=1 go build $(BUILD_FLAGS) -tags '$(BUILD_TAGS) gcc' -o build/minter ./cmd/minter/

install:
CGO_ENABLED=0 go install $(BUILD_FLAGS) -tags '$(BUILD_TAGS)' ./cmd/minter
Expand Down
30 changes: 28 additions & 2 deletions api/v2/service/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ import (
"context"
"encoding/hex"
"fmt"
"math/big"
"strings"

"github.com/MinterTeam/minter-go-node/coreV2/state"
"github.com/MinterTeam/minter-go-node/coreV2/state/accounts"
"github.com/MinterTeam/minter-go-node/coreV2/state/coins"
"github.com/MinterTeam/minter-go-node/coreV2/types"
"github.com/MinterTeam/minter-go-node/formula"
pb "github.com/MinterTeam/node-grpc-gateway/api_pb"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"math/big"
"strings"
)

type stakeUser struct {
Expand Down Expand Up @@ -144,9 +146,33 @@ func (s *Service) Address(ctx context.Context, req *pb.AddressRequest) (*pb.Addr
}
res.BipValue = coinsBipValue.String()
res.TransactionCount = cState.Accounts().GetNonce(address)

res.Multisig = s.getMultisig(cState.Accounts().GetAccount(address))

return &res, nil
}

func (s *Service) getMultisig(account *accounts.Model) *pb.Multisig {
if !account.IsMultisig() {
return nil
}

multisig := account.Multisig()
var weights []uint64
for _, weight := range multisig.Weights {
weights = append(weights, uint64(weight))
}
var addresses []string
for _, add := range multisig.Addresses {
addresses = append(addresses, add.String())
}
return &pb.Multisig{
Threshold: uint64(multisig.Threshold),
Weights: weights,
Addresses: addresses,
}
}

func customCoinBipBalance(valueToSell *big.Int, coinFrom *coins.Model) *big.Int {
if coinFrom.ID().IsBaseCoin() {
return valueToSell
Expand Down
7 changes: 4 additions & 3 deletions api/v2/service/addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"context"
"encoding/hex"
"fmt"
"math/big"
"strings"

"github.com/MinterTeam/minter-go-node/coreV2/types"
pb "github.com/MinterTeam/node-grpc-gateway/api_pb"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"math/big"
"strings"
)

// Addresses returns list of addresses.
Expand Down Expand Up @@ -139,7 +140,7 @@ func (s *Service) Addresses(ctx context.Context, req *pb.AddressesRequest) (*pb.
}
res.BipValue = coinsBipValue.String()
res.TransactionCount = cState.Accounts().GetNonce(address)

res.Multisig = s.getMultisig(cState.Accounts().GetAccount(address))
response.Addresses[addr] = &res
}

Expand Down
8 changes: 5 additions & 3 deletions api/v2/service/data_encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func encode(data transaction.Data, txType transaction.TxType, rCoins coins.RCoin
Commission: uint64(d.Commission),
}
case transaction.TypeVoteCommission:
d := data.(*transaction.VoteCommissionDataV1)
d := data.(*transaction.VoteCommissionDataV250)
m = priceCommissionData(d, rCoins.GetCoin(d.Coin))
case transaction.TypeVoteUpdate:
d := data.(*transaction.VoteUpdateDataV230)
Expand Down Expand Up @@ -358,7 +358,7 @@ func encode(data transaction.Data, txType transaction.TxType, rCoins coins.RCoin
return a, nil
}

func priceCommissionData(d *transaction.VoteCommissionDataV1, coin *coins.Model) proto.Message {
func priceCommissionData(d *transaction.VoteCommissionDataV250, coin *coins.Model) proto.Message {
return &pb.VoteCommissionData{
PubKey: d.PubKey.String(),
Height: d.Height,
Expand Down Expand Up @@ -408,7 +408,9 @@ func priceCommissionData(d *transaction.VoteCommissionDataV1, coin *coins.Model)
BurnToken: d.BurnToken.String(),
VoteCommission: d.VoteCommission.String(),
VoteUpdate: d.VoteUpdate.String(),
// FailedTx: d.FailedTX.String(),
FailedTx: d.FailedTxPrice().String(),
AddLimitOrder: d.AddLimitOrderPrice().String(),
RemoveLimitOrder: d.RemoveLimitOrderPrice().String(),
}
}

Expand Down
9 changes: 5 additions & 4 deletions api/v2/service/estimate_coin_buy.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (s *Service) calcBuyFromPool(ctx context.Context, value *big.Int, cState *s
swapChecker := cState.Swap().GetSwapper(sellCoinID, buyCoinID)

if !swapChecker.Exists() {
return nil, s.createError(status.New(codes.NotFound, fmt.Sprintf("swap pool beetwen coins %s and %s not exists", coinFrom.GetFullSymbol(), coinBuy.GetFullSymbol())), transaction.EncodeError(code.NewPairNotExists(coinFrom.ID().String(), coinBuy.ID().String())))
return nil, s.createError(status.New(codes.NotFound, fmt.Sprintf("swap pool between coins %s and %s not exists", coinFrom.GetFullSymbol(), coinBuy.GetFullSymbol())), transaction.EncodeError(code.NewPairNotExists(coinFrom.ID().String(), coinBuy.ID().String())))
}

if _, ok := dup[swapChecker.GetID()]; ok {
Expand All @@ -188,7 +188,7 @@ func (s *Service) calcBuyFromPool(ctx context.Context, value *big.Int, cState *s
if sellValue == nil {
reserve0, reserve1 := swapChecker.Reserves()
symbolOut := coinBuy.GetFullSymbol()
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(), sellValue.String(), coinBuy.ID().String(), value.String(), reserve0.String(), reserve1.String())))
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())))
}

coinSell := coinFrom
Expand Down Expand Up @@ -229,8 +229,9 @@ func (s *Service) calcBuyFromBancor(value *big.Int, coinTo transaction.Calculate
value = formula.CalculatePurchaseAmount(coinTo.Volume(), coinTo.Reserve(), coinTo.Crr(), value)
}
if !coinFrom.ID().IsBaseCoin() {
value = formula.CalculateSaleAmount(coinFrom.Volume(), coinFrom.Reserve(), coinFrom.Crr(), value)
if errResp := transaction.CheckReserveUnderflow(coinFrom, value); errResp != nil {
var errResp *transaction.Response
value, errResp = transaction.CalculateSaleAmountAndCheck(coinFrom, value)
if errResp != nil {
return nil, s.createError(status.New(codes.FailedPrecondition, errResp.Log), errResp.Info)
}
}
Expand Down
5 changes: 3 additions & 2 deletions api/v2/service/estimate_coin_sell.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,9 @@ func (s *Service) calcSellFromBancor(value *big.Int, coinTo transaction.Calculat
}

if !coinFrom.ID().IsBaseCoin() {
value = formula.CalculateSaleReturn(coinFrom.Volume(), coinFrom.Reserve(), coinFrom.Crr(), value)
if errResp := transaction.CheckReserveUnderflow(coinFrom, value); errResp != nil {
var errResp *transaction.Response
value, errResp = transaction.CalculateSaleReturnAndCheck(coinFrom, value)
if errResp != nil {
return nil, s.createError(status.New(codes.FailedPrecondition, errResp.Log), errResp.Info)
}
}
Expand Down
6 changes: 4 additions & 2 deletions api/v2/service/price_commission.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ func priceCommissionResponse(price *commission.Price, coin *coins.Model) *pb.Pri
SellBancor: price.SellBancor.String(),
SellAllBancor: price.SellAllBancor.String(),
BuyPoolBase: price.BuyPoolBase.String(),
SellPoolBase: price.SellPoolBase.String(),
SellAllPoolBase: price.SellAllPoolBase.String(),
BuyPoolDelta: price.BuyPoolDelta.String(),
SellPoolBase: price.SellPoolBase.String(),
SellPoolDelta: price.SellPoolDelta.String(),
SellAllPoolBase: price.SellAllPoolBase.String(),
SellAllPoolDelta: price.SellAllPoolDelta.String(),
CreateTicker3: price.CreateTicker3.String(),
CreateTicker4: price.CreateTicker4.String(),
Expand Down Expand Up @@ -77,5 +77,7 @@ func priceCommissionResponse(price *commission.Price, coin *coins.Model) *pb.Pri
VoteCommission: price.VoteCommission.String(),
VoteUpdate: price.VoteUpdate.String(),
FailedTx: price.FailedTxPrice().String(),
AddLimitOrder: price.AddLimitOrderPrice().String(),
RemoveLimitOrder: price.RemoveLimitOrderPrice().String(),
}
}
3 changes: 2 additions & 1 deletion api/v2/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ func serveOpenAPI(prefix string, mux *http.ServeMux) error {

func unaryTimeoutInterceptor(timeout time.Duration) func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
withTimeout, _ := context.WithTimeout(ctx, timeout)
withTimeout, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
return handler(withTimeout, req)
}
}
Expand Down
Loading

0 comments on commit de7950c

Please sign in to comment.