Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #562 from vegaprotocol/release/v0.15.x
Browse files Browse the repository at this point in the history
Release version 0.15.0
  • Loading branch information
jeremyletang authored May 16, 2022
2 parents 82d4d8d + b8a7c21 commit 4588476
Show file tree
Hide file tree
Showing 14 changed files with 353 additions and 63 deletions.
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## Unreleased (0.15.0)
## Unreleased (0.16.0)

### 🚨 Breaking changes
- [](https://github.com/vegaprotocol/vegawallet/pull/) -
Expand All @@ -17,10 +17,19 @@
### 🐛 Fixes
- [](https://github.com/vegaprotocol/vegawallet/pull/) -

## 0.15.0

### 🛠 Improvements
- [555](https://github.com/vegaprotocol/vegawallet/issues/555) - Now using full transaction structures for event emit
- [551](https://github.com/vegaprotocol/vegawallet/pull/551) - Enable system-tests with Vegacapsule

### 🐛 Fixes
- [548](https://github.com/vegaprotocol/vegawallet/pull/548) - Printer utility shouldn't write in service response

## 0.14.2

### 🛠 Improvements
- [544](https://github.com/vegaprotocol/vegawallet/issues/544) - Display transaction hash after sending transaction
- [544](https://github.com/vegaprotocol/vegagwallet/issues/544) - Display transaction hash after sending transaction

## 0.14.1

Expand Down
14 changes: 7 additions & 7 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ pipeline {
'''
}
}
stage('System Tests') {
stage('LNL System Tests') {
steps {
script {
systemTests ignoreFailure: !isPRBuild(),
systemTestsLNL ignoreFailure: !isPRBuild(),
vegaCore: params.VEGA_CORE_BRANCH,
dataNode: params.DATA_NODE_BRANCH,
vegawallet: commitHash,
Expand All @@ -177,18 +177,18 @@ pipeline {
}
}
}
stage('LNL System Tests') {
stage('Capsule System Tests') {
steps {
script {
systemTestsLNL ignoreFailure: !isPRBuild(),
vegaCore: params.VEGA_CORE_BRANCH,
systemTestsCapsule vegaCore: params.VEGA_CORE_BRANCH,
dataNode: params.DATA_NODE_BRANCH,
vegawallet: commitHash,
ethereumEventForwarder: params.ETHEREUM_EVENT_FORWARDER_BRANCH,
devopsInfra: params.DEVOPS_INFRA_BRANCH,
vegatools: params.VEGATOOLS_BRANCH,
systemTests: params.SYSTEM_TESTS_BRANCH,
protos: params.PROTOS_BRANCH
protos: params.PROTOS_BRANCH,
ignoreFailure: !isPRBuild()

}
}
}
Expand Down
22 changes: 18 additions & 4 deletions cmd/service_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
"os"
"os/signal"
"strings"
"syscall"

vgterm "code.vegaprotocol.io/shared/libs/term"
Expand Down Expand Up @@ -209,6 +210,7 @@ func RunService(w io.Writer, rf *RootFlags, f *RunServiceFlags) error {
}

pendingConsents := make(chan service.ConsentRequest, 1)
sentTxs := make(chan service.SentTransaction)

cliLog, cliLogPath, err := BuildJSONLogger(cfg.Level.String(), vegaPaths, paths.WalletCLILogsHome)
if err != nil {
Expand All @@ -226,7 +228,7 @@ func RunService(w io.Writer, rf *RootFlags, f *RunServiceFlags) error {
policy = service.NewAutomaticConsentPolicy()
} else {
cliLog.Info("Explicit consent enabled")
policy = service.NewExplicitConsentPolicy(pendingConsents)
policy = service.NewExplicitConsentPolicy(pendingConsents, sentTxs)
}
} else {
cliLog.Info("No TTY detected")
Expand Down Expand Up @@ -294,7 +296,7 @@ func RunService(w io.Writer, rf *RootFlags, f *RunServiceFlags) error {
p.NextLine()
}

waitSig(ctx, cancel, cliLog, pendingConsents, p)
waitSig(ctx, cancel, cliLog, pendingConsents, sentTxs, p)

return nil
}
Expand Down Expand Up @@ -364,7 +366,7 @@ func startTokenDApp(log *zap.Logger, f *RunServiceFlags, cfg *network.Network, c
}

// waitSig will wait for a sigterm or sigint interrupt.
func waitSig(ctx context.Context, cfunc func(), log *zap.Logger, pendingSigRequests chan service.ConsentRequest, p *printer.InteractivePrinter) {
func waitSig(ctx context.Context, cfunc func(), log *zap.Logger, pendingSigRequests chan service.ConsentRequest, sentTxs chan service.SentTransaction, p *printer.InteractivePrinter) {
gracefulStop := make(chan os.Signal, 1)

signal.Notify(gracefulStop, syscall.SIGTERM)
Expand Down Expand Up @@ -393,7 +395,19 @@ func waitSig(ctx context.Context, cfunc func(), log *zap.Logger, pendingSigReque
if flags.DoYouApproveTx() {
log.Info("user approved the signing of the transaction", zap.Any("transaction", txStr))
signRequest.Confirmations <- service.ConsentConfirmation{Decision: true, TxStr: txStr}
p.CheckMark().SuccessText("Transaction approved").NextSection()
p.CheckMark().SuccessText("Transaction approved").NextLine()

sentTx := <-sentTxs
log.Info("transaction sent", zap.Any("ID", sentTx.TxID), zap.Any("hash", sentTx.TxHash))
if sentTx.Error != nil {
log.Error("transaction failed", zap.Any("transaction", txStr))
p.BangMark().DangerText("Transaction failed! ").NextLine()
p.BangMark().DangerText("Error: ").DangerText(sentTx.Error.Error()).NextLine()
p.BangMark().DangerText("Details: ").DangerText(strings.Join(sentTx.ErrorDetails, " ,")).NextSection()
} else {
log.Info("transaction sent", zap.Any("hash", sentTx.TxHash))
p.CheckMark().Text("Transaction with hash ").SuccessText(sentTx.TxHash).Text(" sent!").NextSection()
}
} else {
log.Info("user rejected the signing of the transaction", zap.Any("transaction", txStr))
signRequest.Confirmations <- service.ConsentConfirmation{Decision: false, TxStr: txStr}
Expand Down
2 changes: 1 addition & 1 deletion cmd/tx_send.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func SendTx(w io.Writer, rf *RootFlags, req *SendTxRequest) error {

log.Info("transaction successfully sent", zap.String("hash", txHash))
if rf.Output == flags.InteractiveOutput {
p.CheckMark().InfoText("Transaction sent:").SuccessText(txHash).NextLine()
p.NextLine().CheckMark().Text("Transaction sent: ").SuccessText(txHash).NextLine()
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module code.vegaprotocol.io/vegawallet
go 1.17

require (
code.vegaprotocol.io/protos v0.50.3
code.vegaprotocol.io/protos v0.51.0
code.vegaprotocol.io/shared v0.0.0-20220321185018-3b5684b00533
github.com/blang/semver/v4 v4.0.0
github.com/cenkalti/backoff/v4 v4.1.2
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
code.vegaprotocol.io/protos v0.50.3 h1:9gSw3SDnvZ8oaPooEl2Mg7MbfMroKwutqMTvaLTD5NE=
code.vegaprotocol.io/protos v0.50.3/go.mod h1:4BqwDw6jhc/mnwbXq8ZFUtYBFCnk8tBW6zuPsBt8OrQ=
code.vegaprotocol.io/protos v0.50.4-0.20220503163151-7fc5916bf54e h1:8r9buW3Cl2aBkZj37Yuboq2Pj+pxcmXSRXI8lc3Z7Sk=
code.vegaprotocol.io/protos v0.50.4-0.20220503163151-7fc5916bf54e/go.mod h1:4BqwDw6jhc/mnwbXq8ZFUtYBFCnk8tBW6zuPsBt8OrQ=
code.vegaprotocol.io/protos v0.51.0 h1:HscwExZenysYze9N43JTqR1mStpUB82Hb48oY+lHX8M=
code.vegaprotocol.io/protos v0.51.0/go.mod h1:4BqwDw6jhc/mnwbXq8ZFUtYBFCnk8tBW6zuPsBt8OrQ=
code.vegaprotocol.io/shared v0.0.0-20220321185018-3b5684b00533 h1:IxTWvyF0i0AgUAS+FTgQKIpbsS6Ki/Y9Ug0GSlgChJw=
code.vegaprotocol.io/shared v0.0.0-20220321185018-3b5684b00533/go.mod h1:pNHKwqRDkotUN0s6jErl7Eb2EpZa2HAf03lyPMTCUT0=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
Expand Down
28 changes: 28 additions & 0 deletions node/forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,34 @@ func (n *Forwarder) LastBlockHeightAndHash(ctx context.Context) (*api.LastBlockH
return resp, clt, err
}

func (n *Forwarder) CheckTx(ctx context.Context, tx *commandspb.Transaction, cltIdx int) (*api.CheckTransactionResponse, error) {
req := api.CheckTransactionRequest{
Tx: tx,
}
var resp *api.CheckTransactionResponse
if cltIdx < 0 {
cltIdx = n.nextClt()
}
err := backoff.Retry(
func() error {
clt := n.clts[cltIdx]
r, err := clt.CheckTransaction(ctx, &req)
if err != nil {
n.log.Error("Couldn't check transaction", zap.Error(err))
return err
}
n.log.Debug("Response from CheckTransaction",
zap.Bool("success", r.Success),
)
resp = r
return nil
},
backoff.WithMaxRetries(backoff.NewExponentialBackOff(), n.nodeCfgs.Retries),
)

return resp, err
}

func (n *Forwarder) SendTx(ctx context.Context, tx *commandspb.Transaction, ty api.SubmitTransactionRequest_Type, cltIdx int) (string, error) {
req := api.SubmitTransactionRequest{
Tx: tx,
Expand Down
15 changes: 15 additions & 0 deletions service/mocks/node_forward_mock.go

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

12 changes: 10 additions & 2 deletions service/mocks/policies_mock.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
package mocks

import (
"time"

v1 "code.vegaprotocol.io/protos/vega/wallet/v1"
"code.vegaprotocol.io/vegawallet/service"
)

type MockConsentPolicy struct {
pendingEvents chan service.ConsentRequest
sentTxs chan service.SentTransaction
}

func (p *MockConsentPolicy) Report(tx service.SentTransaction) {
p.sentTxs <- tx
}

func NewMockConsentPolicy(pending chan service.ConsentRequest) service.Policy {
func NewMockConsentPolicy(pending chan service.ConsentRequest, sentTxs chan service.SentTransaction) *MockConsentPolicy {
return &MockConsentPolicy{
pendingEvents: pending,
sentTxs: sentTxs,
}
}

func (p *MockConsentPolicy) Ask(tx *v1.SubmitTransactionRequest) (bool, error) {
func (p *MockConsentPolicy) Ask(tx *v1.SubmitTransactionRequest, txID string, receivedAt time.Time) (bool, error) {
if tx.PubKey == "toBeDeclined" {
return false, nil
}
Expand Down
6 changes: 6 additions & 0 deletions service/mocks/wallet_handler_mock.go

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

38 changes: 25 additions & 13 deletions service/policies.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package service

import (
"crypto/sha256"
"fmt"
"time"

commandspb "code.vegaprotocol.io/protos/vega/commands/v1"
v1 "code.vegaprotocol.io/protos/vega/wallet/v1"
"github.com/golang/protobuf/jsonpb"
)
Expand All @@ -27,15 +26,18 @@ func (r *ConsentRequest) String() (string, error) {
return marshalledRequest, err
}

func (r *ConsentRequest) GetTxID() string {
h := sha256.New()
h.Write([]byte(fmt.Sprintf("%s%v%t", r.Tx.PubKey, r.Tx.Command, r.Tx.Propagate)))

return fmt.Sprintf("%x", h.Sum(nil))
type SentTransaction struct {
TxHash string
TxID string
ReceivedAt time.Time
Tx *commandspb.Transaction
Error error
ErrorDetails []string
}

type Policy interface {
Ask(tx *v1.SubmitTransactionRequest) (bool, error)
Ask(tx *v1.SubmitTransactionRequest, txID string, receivedAt time.Time) (bool, error)
Report(tx SentTransaction)
NeedsInteractiveOutput() bool
}

Expand All @@ -45,34 +47,44 @@ func NewAutomaticConsentPolicy() Policy {
return &AutomaticConsentPolicy{}
}

func (p *AutomaticConsentPolicy) Ask(_ *v1.SubmitTransactionRequest) (bool, error) {
func (p *AutomaticConsentPolicy) Ask(_ *v1.SubmitTransactionRequest, txID string, receivedAt time.Time) (bool, error) {
return true, nil
}

func (p *AutomaticConsentPolicy) Report(_ SentTransaction) {
// Nothing to report as we expect this policy to be non-interactive.
}

func (p *AutomaticConsentPolicy) NeedsInteractiveOutput() bool {
return false
}

type ExplicitConsentPolicy struct {
pendingEvents chan ConsentRequest
sentTxs chan SentTransaction
}

func NewExplicitConsentPolicy(pending chan ConsentRequest) Policy {
func NewExplicitConsentPolicy(pending chan ConsentRequest, sentTxs chan SentTransaction) Policy {
return &ExplicitConsentPolicy{
pendingEvents: pending,
sentTxs: sentTxs,
}
}

func (p *ExplicitConsentPolicy) Ask(tx *v1.SubmitTransactionRequest) (bool, error) {
func (p *ExplicitConsentPolicy) Ask(tx *v1.SubmitTransactionRequest, txID string, receivedAt time.Time) (bool, error) {
confirmations := make(chan ConsentConfirmation)
consentReq := ConsentRequest{Tx: tx, Confirmations: confirmations, ReceivedAt: time.Now()}
consentReq.TxID = consentReq.GetTxID()
consentReq := ConsentRequest{Tx: tx, Confirmations: confirmations, ReceivedAt: receivedAt}
consentReq.TxID = txID
p.pendingEvents <- consentReq

c := <-confirmations
return c.Decision, nil
}

func (p *ExplicitConsentPolicy) Report(tx SentTransaction) {
p.sentTxs <- tx
}

func (p *ExplicitConsentPolicy) NeedsInteractiveOutput() bool {
return true
}
Loading

0 comments on commit 4588476

Please sign in to comment.