Commit 81e2537e authored by suyanlong's avatar suyanlong

Fixed bug

parent 3f382b79
Pipeline #8630 failed with stages
......@@ -2,6 +2,7 @@ package appchain
import (
"context"
"errors"
"fmt"
"strconv"
"strings"
......@@ -115,17 +116,19 @@ func (a *appChain) applyInterchainIBTP(ibtp *pb.IBTP) (*pb.IBTP, error) {
// execute interchain tx, and if execution failed, try to rollback
response, err := a.client.SubmitIBTP(ibtp)
if err != nil {
entry.WithField("error", err).Panic("Submit ibtp")
//entry.WithField("error", err).Panic("Submit ibtp")
entry.WithField("error", err)
return nil, err
}
if response == nil || response.Result == nil {
entry.WithField("error", err).Panic("empty response")
}
err := errors.New("empty response")
entry.WithField("error", err)
return nil, err
} else {
if !response.Status {
pd := &pb.Payload{}
if err := pd.Unmarshal(response.Result.Payload); err != nil {
entry.Panic("Unmarshal payload")
entry.WithField("error", "Unmarshal payload")
}
entry.WithFields(logrus.Fields{
......@@ -133,8 +136,8 @@ func (a *appChain) applyInterchainIBTP(ibtp *pb.IBTP) (*pb.IBTP, error) {
"payload": pd,
}).Warn("Get wrong response, need rollback on source chain")
}
return response.Result, nil
}
}
func (a *appChain) applyReceiptIBTP(ibtp *pb.IBTP) error {
......@@ -165,7 +168,7 @@ func (a *appChain) applyReceiptIBTP(ibtp *pb.IBTP) error {
return fmt.Errorf("execute callback tx: %w", err)
}
return nil
}, strategy.Wait(1*time.Second)); err != nil {
}, strategy.Limit(3), strategy.Wait(1*time.Second)); err != nil {
a.logger.Errorf("Execution of callback function failed: %s", err.Error())
}
return nil
......@@ -200,7 +203,7 @@ func (a *appChain) Rollback(ibtp *pb.IBTP, isSrcChain bool) {
return fmt.Errorf("execute callback tx: %w", err)
}
return nil
}, strategy.Wait(1*time.Second)); err != nil {
}, strategy.Limit(3), strategy.Wait(1*time.Second)); err != nil {
a.logger.Errorf("Execution of callback function failed: %s", err.Error())
}
}
......@@ -287,7 +290,7 @@ func (a *appChain) QueryIBTP(to string, id string) (*pb.IBTP, error) {
}
c <- e
return nil
}, strategy.Wait(2*time.Second)); err != nil {
}, strategy.Limit(3), strategy.Wait(2*time.Second)); err != nil {
panic(err)
}
......@@ -314,7 +317,7 @@ func (a *appChain) QueryOuterMeta() map[string]uint64 {
return err
}
return nil
}, strategy.Wait(2*time.Second)); err != nil {
}, strategy.Limit(3), strategy.Wait(2*time.Second)); err != nil {
panic(err)
}
......
......@@ -73,7 +73,7 @@ func (lite *HubLite) syncBlock() {
}
return nil
}, strategy.Wait(1*time.Second))
}, strategy.Limit(3), strategy.Wait(1*time.Second))
if err != nil {
lite.logger.Panic(err)
}
......@@ -91,7 +91,7 @@ func (lite *HubLite) getHeaderChannel() chan *pb.BlockHeader {
}
return nil
}, strategy.Wait(2*time.Second)); err != nil {
}, strategy.Limit(3), strategy.Wait(2*time.Second)); err != nil {
panic(err)
}
......
......@@ -5,10 +5,11 @@ package pb
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.
......
......@@ -43,7 +43,6 @@ func (m *IBTP) Category() IBTP_Category {
return IBTP_UNKNOWN
}
func (m *IBTP) ServicePair() string {
return fmt.Sprintf("%s-%s", m.From, m.To)
}
......@@ -102,8 +101,3 @@ func ParseIBTPID(id string) (string, string, uint64, error) {
func GenServicePair(from, to string) string {
return fmt.Sprintf("%s-%s", from, to)
}
......@@ -5,10 +5,11 @@ package pb
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.
......
......@@ -5,10 +5,11 @@ package pb
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.
......
......@@ -5,10 +5,11 @@ package pb
import (
fmt "fmt"
proto "github.com/gogo/protobuf/proto"
io "io"
math "math"
math_bits "math/bits"
proto "github.com/gogo/protobuf/proto"
)
// Reference imports to suppress errors if they are not otherwise used.
......
......@@ -50,7 +50,7 @@ func (s *GRPCServer) GetIBTP(_ *pb.Empty, conn pb.AppchainPlugin_GetIBTPServer)
return err
}
return nil
}, strategy.Wait(1*time.Second)); err != nil {
}, strategy.Limit(3), strategy.Wait(1*time.Second)); err != nil {
logger.Error("Execution of plugin server sending ibtp failed", "error", err)
}
}
......@@ -202,7 +202,7 @@ func (g *GRPCClient) handleIBTPStream(conn pb.AppchainPlugin_GetIBTPClient, ibtp
return err
}
return nil
}, strategy.Wait(1*time.Second)); err != nil {
}, strategy.Limit(3), strategy.Wait(1*time.Second)); err != nil {
logger.Error("Execution of client recv failed", "error", err)
}
......@@ -217,7 +217,7 @@ func (g *GRPCClient) handleIBTPStream(conn pb.AppchainPlugin_GetIBTPClient, ibtp
func (g *GRPCClient) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) {
var err error
response := &pb.SubmitIBTPResponse{}
retry.Retry(func(attempt uint) error {
err = retry.Retry(func(attempt uint) error {
response, err = g.client.SubmitIBTP(g.doneContext, ibtp)
if err != nil {
logger.Error("submit ibtp to plugin server",
......@@ -226,9 +226,9 @@ func (g *GRPCClient) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) {
return err
}
return nil
}, strategy.Wait(1*time.Second))
}, strategy.Limit(3), strategy.Wait(1*time.Second))
return response, nil
return response, err
}
func (g *GRPCClient) RollbackIBTP(ibtp *pb.IBTP, srcChain bool) (*pb.RollbackIBTPResponse, error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment