Compare commits

...

3 Commits

Author SHA1 Message Date
Mike Zak
811a2a9717 Add changelog for v0.8.10 2021-02-25 14:53:09 +02:00
Svarog
127fd065c5
Convert ProtocolError to value-type, so that it can be used withh errors.As + fix SubmitBlock ProtocolError condition (#1555)
* Fix condition from || to &&

* Convert ProtocolError to value-type, so that it can be used wihth errors.As

* Simplify condition further
2021-02-24 17:10:45 +02:00
Mike Zak
2a147fb46d Update to version 0.8.10 2021-02-24 13:24:22 +02:00
8 changed files with 30 additions and 16 deletions

View File

@ -18,7 +18,7 @@ import (
func (*FlowContext) HandleError(err error, flowName string, isStopping *uint32, errChan chan<- error) { func (*FlowContext) HandleError(err error, flowName string, isStopping *uint32, errChan chan<- error) {
isErrRouteClosed := errors.Is(err, router.ErrRouteClosed) isErrRouteClosed := errors.Is(err, router.ErrRouteClosed)
if !isErrRouteClosed { if !isErrRouteClosed {
if protocolErr := &(protocolerrors.ProtocolError{}); !errors.As(err, &protocolErr) { if protocolErr := (protocolerrors.ProtocolError{}); !errors.As(err, &protocolErr) {
panic(err) panic(err)
} }

View File

@ -107,7 +107,7 @@ func handleError(err error, flowName string, isStopping *uint32, errChan chan er
return return
} }
if protocolErr := &(protocolerrors.ProtocolError{}); errors.As(err, &protocolErr) { if protocolErr := (protocolerrors.ProtocolError{}); errors.As(err, &protocolErr) {
log.Errorf("Handshake protocol error from %s: %s", flowName, err) log.Errorf("Handshake protocol error from %s: %s", flowName, err)
if atomic.AddUint32(isStopping, 1) == 1 { if atomic.AddUint32(isStopping, 1) == 1 {
errChan <- err errChan <- err

View File

@ -1,14 +1,15 @@
package testing package testing
import ( import (
"github.com/kaspanet/kaspad/app/protocol/protocolerrors"
"github.com/pkg/errors"
"strings" "strings"
"testing" "testing"
"github.com/kaspanet/kaspad/app/protocol/protocolerrors"
"github.com/pkg/errors"
) )
func checkFlowError(t *testing.T, err error, isProtocolError bool, shouldBan bool, contains string) { func checkFlowError(t *testing.T, err error, isProtocolError bool, shouldBan bool, contains string) {
pErr := &protocolerrors.ProtocolError{} pErr := protocolerrors.ProtocolError{}
if errors.As(err, &pErr) != isProtocolError { if errors.As(err, &pErr) != isProtocolError {
t.Fatalf("Unexepcted error %+v", err) t.Fatalf("Unexepcted error %+v", err)
} }

View File

@ -1,9 +1,10 @@
package protocol package protocol
import ( import (
"sync/atomic"
"github.com/kaspanet/kaspad/app/protocol/flows/rejects" "github.com/kaspanet/kaspad/app/protocol/flows/rejects"
"github.com/kaspanet/kaspad/infrastructure/network/connmanager" "github.com/kaspanet/kaspad/infrastructure/network/connmanager"
"sync/atomic"
"github.com/kaspanet/kaspad/app/appmessage" "github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/app/protocol/flows/addressexchange" "github.com/kaspanet/kaspad/app/protocol/flows/addressexchange"
@ -75,7 +76,7 @@ func (m *Manager) routerInitializer(router *routerpkg.Router, netConnection *net
} }
func (m *Manager) handleError(err error, netConnection *netadapter.NetConnection, outgoingRoute *routerpkg.Route) { func (m *Manager) handleError(err error, netConnection *netadapter.NetConnection, outgoingRoute *routerpkg.Route) {
if protocolErr := &(protocolerrors.ProtocolError{}); errors.As(err, &protocolErr) { if protocolErr := (protocolerrors.ProtocolError{}); errors.As(err, &protocolErr) {
if !m.context.Config().DisableBanning && protocolErr.ShouldBan { if !m.context.Config().DisableBanning && protocolErr.ShouldBan {
log.Warnf("Banning %s (reason: %s)", netConnection, protocolErr.Cause) log.Warnf("Banning %s (reason: %s)", netConnection, protocolErr.Cause)

View File

@ -12,19 +12,19 @@ type ProtocolError struct {
Cause error Cause error
} }
func (e *ProtocolError) Error() string { func (e ProtocolError) Error() string {
return e.Cause.Error() return e.Cause.Error()
} }
// Unwrap returns the cause of ProtocolError, to be used with `errors.Unwrap()` // Unwrap returns the cause of ProtocolError, to be used with `errors.Unwrap()`
func (e *ProtocolError) Unwrap() error { func (e ProtocolError) Unwrap() error {
return e.Cause return e.Cause
} }
// Errorf formats according to a format specifier and returns the string // Errorf formats according to a format specifier and returns the string
// as a ProtocolError. // as a ProtocolError.
func Errorf(shouldBan bool, format string, args ...interface{}) error { func Errorf(shouldBan bool, format string, args ...interface{}) error {
return &ProtocolError{ return ProtocolError{
ShouldBan: shouldBan, ShouldBan: shouldBan,
Cause: errors.Errorf(format, args...), Cause: errors.Errorf(format, args...),
} }
@ -33,7 +33,7 @@ func Errorf(shouldBan bool, format string, args ...interface{}) error {
// New returns a ProtocolError with the supplied message. // New returns a ProtocolError with the supplied message.
// New also records the stack trace at the point it was called. // New also records the stack trace at the point it was called.
func New(shouldBan bool, message string) error { func New(shouldBan bool, message string) error {
return &ProtocolError{ return ProtocolError{
ShouldBan: shouldBan, ShouldBan: shouldBan,
Cause: errors.New(message), Cause: errors.New(message),
} }
@ -41,7 +41,7 @@ func New(shouldBan bool, message string) error {
// Wrap wraps the given error and returns it as a ProtocolError. // Wrap wraps the given error and returns it as a ProtocolError.
func Wrap(shouldBan bool, err error, message string) error { func Wrap(shouldBan bool, err error, message string) error {
return &ProtocolError{ return ProtocolError{
ShouldBan: shouldBan, ShouldBan: shouldBan,
Cause: errors.Wrap(err, message), Cause: errors.Wrap(err, message),
} }
@ -49,7 +49,7 @@ func Wrap(shouldBan bool, err error, message string) error {
// Wrapf wraps the given error with the given format and returns it as a ProtocolError. // Wrapf wraps the given error with the given format and returns it as a ProtocolError.
func Wrapf(shouldBan bool, err error, format string, args ...interface{}) error { func Wrapf(shouldBan bool, err error, format string, args ...interface{}) error {
return &ProtocolError{ return ProtocolError{
ShouldBan: shouldBan, ShouldBan: shouldBan,
Cause: errors.Wrapf(err, format, args...), Cause: errors.Wrapf(err, format, args...),
} }

View File

@ -26,7 +26,8 @@ func HandleSubmitBlock(context *rpccontext.Context, _ *router.Router, request ap
err := context.ProtocolManager.AddBlock(domainBlock) err := context.ProtocolManager.AddBlock(domainBlock)
if err != nil { if err != nil {
if !errors.As(err, &ruleerrors.RuleError{}) || !errors.As(err, &protocolerrors.ProtocolError{}) { isProtocolOrRuleError := errors.As(err, &ruleerrors.RuleError{}) || errors.As(err, &protocolerrors.ProtocolError{})
if !isProtocolOrRuleError {
return nil, err return nil, err
} }

11
changelog.txt Normal file
View File

@ -0,0 +1,11 @@
Kaspad v0.8.10 - 2021-02-25
===========================
[*] Fix bug where invalid mempool transactions were not removed (#1551)
[*] Add RPC reconnection to the miner (#1552)
[*] Remove virtual diff parents - only selectedTip is virtualDiffParent now (#1550)
[*] Fix UTXO index (#1548)
[*] Prevent fast failing (#1545)
[*] Increase the sleep time in kaspaminer when the node is not synced (#1544)
[*] Disallow header only blocks on RPC, relay and when requesting IBD full blocks (#1537)
[*] Make templateManager hold a DomainBlock and isSynced bool instead of a GetBlockTemplateResponseMessage (#1538)

View File

@ -10,8 +10,8 @@ const validCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrs
const ( const (
appMajor uint = 0 appMajor uint = 0
appMinor uint = 9 appMinor uint = 8
appPatch uint = 0 appPatch uint = 10
) )
// appBuild is defined as a variable so it can be overridden during the build // appBuild is defined as a variable so it can be overridden during the build