Skip to content

Commit

Permalink
Merge pull request #2529 from vegaprotocol/release/v0.27.0
Browse files Browse the repository at this point in the history
Release v0.27.0
  • Loading branch information
edd authored Nov 3, 2020
2 parents 5255261 + 79e8289 commit 883fcda
Show file tree
Hide file tree
Showing 236 changed files with 11,093 additions and 4,088 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Changelog

## 0.27.0

*2020-10-30*

This release contains a fix (read: large reduction in memory use) around auction modes with particularly large order books that caused slow block times when handling orders placed during an opening auction. It also contains a lot of internal work related to the liquidity provision mechanics.

### New
- [#2498](https://github.com/vegaprotocol/vega/pull/2498) Automatically create a bond account for liquidity providers
- [#2596](https://github.com/vegaprotocol/vega/pull/2496) Create liquidity measurement API
- [#2490](https://github.com/vegaprotocol/vega/pull/2490) GraphQL: Add Withdrawal and Deposit events to event bus
- [#2476](https://github.com/vegaprotocol/vega/pull/2476) 🔥`MarketData` now uses RFC339 formatted times, not seconds
- [#2473](https://github.com/vegaprotocol/vega/pull/2473) Add network parameters related to target stake calculation
- [#2506](https://github.com/vegaprotocol/vega/pull/2506) Network parameters can now contain JSON configuration

### Improvements
- [#2521](https://github.com/vegaprotocol/vega/pull/2521) Optimise memory usage when building cumulative price levels
- [#2520](https://github.com/vegaprotocol/vega/pull/2520) Fix indicative price calculation
- [#2517](https://github.com/vegaprotocol/vega/pull/2517) Improve command line for rate limiting in faucet & wallet
- [#2510](https://github.com/vegaprotocol/vega/pull/2510) Remove reference to external risk model
- [#2509](https://github.com/vegaprotocol/vega/pull/2509) Fix panic when loading an invalid genesis configuration
- [#2502](https://github.com/vegaprotocol/vega/pull/2502) Fix pointer when using amend in place
- [#2487](https://github.com/vegaprotocol/vega/pull/2487) Remove context from struct that didn't need it
- [#2485](https://github.com/vegaprotocol/vega/pull/2485) Refactor event bus event transmission
- [#2481](https://github.com/vegaprotocol/vega/pull/2481) Add `LiquidityProvisionSubmission` transaction
- [#2480](https://github.com/vegaprotocol/vega/pull/2480) Remove unused code
- [#2479](https://github.com/vegaprotocol/vega/pull/2479) Improve validation of external resources
- [#1936](https://github.com/vegaprotocol/vega/pull/1936) Upgrade to Tendermint 0.33.8

## 0.26.1

*2020-10-23*
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ race: ## Run data race detector

.PHONY: mocks
mocks: ## Make mocks
@[ -d vendor ] && mv vendor vendor.tmp
@go generate ./...
@[ -d vendor.tmp ] && mv vendor.tmp vendor

.PHONY: msan
msan: ## Run memory sanitizer
Expand Down Expand Up @@ -117,6 +119,7 @@ print_check: ## Check for fmt.Print functions in Go code
find -name vendor -prune -o \
-name cmd -prune -o \
-name '*_test.go' -prune -o \
-name 'flags.go' -prune -o \
-name '*.go' -print0 | \
xargs -0 grep -E '^([^/]|/[^/])*fmt.Print' | \
tee "$$f" && \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Vega

Version 0.26.1.
Version 0.27.0.

A decentralised trading platform that allows pseudo-anonymous trading of derivatives on a blockchain.

Expand Down
2 changes: 1 addition & 1 deletion accounts/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const namedLogger = "accounts"

// Config represents the configuration of the Account service
type Config struct {
Level encoding.LogLevel
Level encoding.LogLevel `long:"log-level"`
}

// NewDefaultConfig creates an instance of the package specific configuration, given a
Expand Down
10 changes: 5 additions & 5 deletions api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const namedLogger = "api.grpc"

// Config represents the configuration of the api package
type Config struct {
Level encoding.LogLevel
Timeout encoding.Duration
Port int
IP string
StreamRetries int
Level encoding.LogLevel `long:"log-level"`
Timeout encoding.Duration `long:"timeout"`
Port int `long:"port"`
IP string `long:"ip"`
StreamRetries int `long:"stream-retries"`
}

// NewDefaultConfig creates an instance of the package specific configuration, given a
Expand Down
9 changes: 5 additions & 4 deletions api/mocks/evt_forwarder_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions api/mocks/liquidity_service_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"code.vegaprotocol.io/vega/contextutil"
"code.vegaprotocol.io/vega/fee"
"code.vegaprotocol.io/vega/governance"
"code.vegaprotocol.io/vega/liquidity"
"code.vegaprotocol.io/vega/logging"
"code.vegaprotocol.io/vega/monitoring"
"code.vegaprotocol.io/vega/netparams"
Expand Down Expand Up @@ -44,6 +45,7 @@ type GRPCServer struct {
candleService *candles.Svc
marketService MarketService
orderService *orders.Svc
liquidityService *liquidity.Svc
partyService *parties.Svc
timeService *vegatime.Svc
tradeService *trades.Svc
Expand Down Expand Up @@ -81,6 +83,7 @@ func NewGRPCServer(
marketService MarketService,
partyService *parties.Svc,
orderService *orders.Svc,
liquidityService *liquidity.Svc,
tradeService *trades.Svc,
candleService *candles.Svc,
accountsService *accounts.Svc,
Expand Down Expand Up @@ -109,6 +112,7 @@ func NewGRPCServer(
stats: stats,
client: client,
orderService: orderService,
liquidityService: liquidityService,
tradeService: tradeService,
candleService: candleService,
timeService: timeService,
Expand Down Expand Up @@ -217,6 +221,7 @@ func (g *GRPCServer) Start() {
log: g.log,
blockchain: g.client,
tradeOrderService: g.orderService,
liquidityService: g.liquidityService,
accountService: g.accountsService,
marketService: g.marketService,
governanceService: g.governanceService,
Expand Down Expand Up @@ -250,6 +255,7 @@ func (g *GRPCServer) Start() {
DepositService: g.depositService,
MarketDepthService: g.marketDepthService,
NetParamsService: g.netParamsService,
LiquidityService: g.liquidityService,
ctx: g.ctx,
}
go tradingDataSvc.updateNetInfo(g.ctx)
Expand Down
52 changes: 43 additions & 9 deletions api/trading.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (
"sync"
"time"

"code.vegaprotocol.io/vega/blockchain"
"code.vegaprotocol.io/vega/evtforward"
"code.vegaprotocol.io/vega/logging"
"code.vegaprotocol.io/vega/metrics"
"code.vegaprotocol.io/vega/monitoring"
types "code.vegaprotocol.io/vega/proto"
protoapi "code.vegaprotocol.io/vega/proto/api"
"code.vegaprotocol.io/vega/txn"
"code.vegaprotocol.io/vega/wallet/crypto"

"github.com/golang/protobuf/proto"
Expand All @@ -32,6 +32,13 @@ type TradeOrderService interface {
PrepareAmendOrder(ctx context.Context, amendment *types.OrderAmendment) error
}

// LiquidityService ...
//go:generate go run github.com/golang/mock/mockgen -destination mocks/liquidity_service_mock.go -package mocks code.vegaprotocol.io/vega/api LiquidityService
type LiquidityService interface {
PrepareLiquidityProvisionSubmission(context.Context, *types.LiquidityProvisionSubmission) error
Get(market, party string) ([]types.LiquidityProvision, error)
}

// AccountService ...
//go:generate go run github.com/golang/mock/mockgen -destination mocks/account_service_mock.go -package mocks code.vegaprotocol.io/vega/api AccountService
type AccountService interface {
Expand All @@ -48,7 +55,7 @@ type GovernanceService interface {
// EvtForwarder
//go:generate go run github.com/golang/mock/mockgen -destination mocks/evt_forwarder_mock.go -package mocks code.vegaprotocol.io/vega/api EvtForwarder
type EvtForwarder interface {
Forward(e *types.ChainEvent, pk string) error
Forward(ctx context.Context, e *types.ChainEvent, pk string) error
}

// Blockchain ...
Expand All @@ -62,6 +69,7 @@ type tradingService struct {

blockchain Blockchain
tradeOrderService TradeOrderService
liquidityService LiquidityService
accountService AccountService
marketService MarketService
governanceService GovernanceService
Expand All @@ -82,7 +90,7 @@ func (s *tradingService) PrepareSubmitOrder(ctx context.Context, req *protoapi.S
if err != nil {
return nil, apiError(codes.Internal, ErrSubmitOrder, err)
}
if raw, err = blockchain.TxEncode(raw, blockchain.SubmitOrderCommand); err != nil {
if raw, err = txn.Encode(raw, txn.SubmitOrderCommand); err != nil {
return nil, apiError(codes.Internal, ErrSubmitOrder, err)
}
return &protoapi.PrepareSubmitOrderResponse{
Expand All @@ -102,7 +110,7 @@ func (s *tradingService) PrepareCancelOrder(ctx context.Context, req *protoapi.C
if err != nil {
return nil, apiError(codes.Internal, ErrCancelOrder, err)
}
if raw, err = blockchain.TxEncode(raw, blockchain.CancelOrderCommand); err != nil {
if raw, err = txn.Encode(raw, txn.CancelOrderCommand); err != nil {
return nil, apiError(codes.Internal, ErrCancelOrder, err)
}
return &protoapi.PrepareCancelOrderResponse{
Expand All @@ -121,7 +129,7 @@ func (s *tradingService) PrepareAmendOrder(ctx context.Context, req *protoapi.Am
if err != nil {
return nil, apiError(codes.Internal, ErrAmendOrder, err)
}
if raw, err = blockchain.TxEncode(raw, blockchain.AmendOrderCommand); err != nil {
if raw, err = txn.Encode(raw, txn.AmendOrderCommand); err != nil {
return nil, apiError(codes.Internal, ErrAmendOrder, err)
}
return &protoapi.PrepareAmendOrderResponse{
Expand Down Expand Up @@ -159,7 +167,7 @@ func (s *tradingService) PrepareWithdraw(
if err != nil {
return nil, apiError(codes.Internal, ErrPrepareWithdraw, err)
}
if raw, err = blockchain.TxEncode(raw, blockchain.WithdrawCommand); err != nil {
if raw, err = txn.Encode(raw, txn.WithdrawCommand); err != nil {
return nil, apiError(codes.Internal, ErrPrepareWithdraw, err)
}
return &protoapi.PrepareWithdrawResponse{
Expand All @@ -185,7 +193,7 @@ func (s *tradingService) PrepareProposal(
return nil, apiError(codes.Internal, ErrPrepareProposal, err)
}

if raw, err = blockchain.TxEncode(raw, blockchain.ProposeCommand); err != nil {
if raw, err = txn.Encode(raw, txn.ProposeCommand); err != nil {
return nil, apiError(codes.Internal, ErrPrepareProposal, err)
}
return &protoapi.PrepareProposalResponse{
Expand Down Expand Up @@ -214,7 +222,7 @@ func (s *tradingService) PrepareVote(ctx context.Context, req *protoapi.PrepareV
if err != nil {
return nil, apiError(codes.Internal, ErrPrepareVote, err)
}
if raw, err = blockchain.TxEncode(raw, blockchain.VoteCommand); err != nil {
if raw, err = txn.Encode(raw, txn.VoteCommand); err != nil {
return nil, apiError(codes.Internal, ErrPrepareVote, err)
}
return &protoapi.PrepareVoteResponse{
Expand All @@ -223,6 +231,32 @@ func (s *tradingService) PrepareVote(ctx context.Context, req *protoapi.PrepareV
}, nil
}

func (s *tradingService) PrepareLiquidityProvision(ctx context.Context, req *protoapi.PrepareLiquidityProvisionRequest) (*protoapi.PrepareLiquidityProvisionResponse, error) {
startTime := time.Now()
defer metrics.APIRequestAndTimeGRPC("PrepareLiquidity", startTime)

if err := req.Validate(); err != nil {
return nil, apiError(codes.InvalidArgument, ErrMalformedRequest, err)
}

if err := s.liquidityService.PrepareLiquidityProvisionSubmission(ctx, req.Submission); err != nil {
return nil, apiError(codes.Internal, ErrPrepareVote, err)
}

raw, err := proto.Marshal(req.Submission)
if err != nil {
return nil, apiError(codes.Internal, ErrPrepareVote, err)
}

if raw, err = txn.Encode(raw, txn.LiquidityProvisionCommand); err != nil {
return nil, apiError(codes.Internal, ErrPrepareVote, err)
}

return &protoapi.PrepareLiquidityProvisionResponse{
Blob: raw,
}, nil
}

func (s *tradingService) PropagateChainEvent(ctx context.Context, req *protoapi.PropagateChainEventRequest) (*protoapi.PropagateChainEventResponse, error) {
if req.Evt == nil {
return nil, apiError(codes.InvalidArgument, ErrMalformedRequest)
Expand All @@ -248,7 +282,7 @@ func (s *tradingService) PropagateChainEvent(ctx context.Context, req *protoapi.
}

var ok = true
err = s.evtForwarder.Forward(req.Evt, req.PubKey)
err = s.evtForwarder.Forward(ctx, req.Evt, req.PubKey)
if err != nil {
s.log.Error("unable to forward chain event",
logging.String("pubkey", req.PubKey),
Expand Down
17 changes: 17 additions & 0 deletions api/trading_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ type tradingDataService struct {
DepositService DepositService
MarketDepthService *subscribers.MarketDepthBuilder
NetParamsService NetParamsService
LiquidityService LiquidityService
ctx context.Context

chainID string
Expand All @@ -234,6 +235,22 @@ type tradingDataService struct {
netInfoLastUpdate time.Time
}

func (t *tradingDataService) LiquidityProvisions(ctx context.Context, req *protoapi.LiquidityProvisionsRequest) (*protoapi.LiquidityProvisionsResponse, error) {
defer metrics.StartAPIRequestAndTimeGRPC("LiquidityProvisions")()
lps, err := t.LiquidityService.Get(req.Market, req.Party)
if err != nil {
return nil, err
}
out := make([]*types.LiquidityProvision, 0, len(lps))
for _, v := range lps {
v := v
out = append(out, &v)
}
return &protoapi.LiquidityProvisionsResponse{
LiquidityProvisions: out,
}, nil
}

func (t *tradingDataService) NetworkParameters(ctx context.Context, req *protoapi.NetworkParametersRequest) (*protoapi.NetworkParametersResponse, error) {
defer metrics.StartAPIRequestAndTimeGRPC("NetworkParameters")()
nps := t.NetParamsService.GetAll()
Expand Down
Loading

0 comments on commit 883fcda

Please sign in to comment.