Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
sidecar
Commits
81e2537e
Commit
81e2537e
authored
Apr 07, 2022
by
suyanlong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug
parent
3f382b79
Pipeline
#8630
failed with stages
Changes
9
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
29 additions
and
28 deletions
+29
-28
appchain.go
internal/appchain/appchain.go
+14
-11
header.go
internal/lite/hub_lite/header.go
+2
-2
basic.pb.go
model/pb/basic.pb.go
+2
-1
ibtp.go
model/pb/ibtp.go
+0
-6
ibtp.pb.go
model/pb/ibtp.pb.go
+2
-1
ibtp.proto
model/pb/ibtp.proto
+0
-0
ibtpx.pb.go
model/pb/ibtpx.pb.go
+2
-1
message.pb.go
model/pb/message.pb.go
+2
-1
grpc.go
pkg/plugins/grpc.go
+5
-5
No files found.
internal/appchain/appchain.go
View file @
81e2537e
...
@@ -2,6 +2,7 @@ package appchain
...
@@ -2,6 +2,7 @@ package appchain
import
(
import
(
"context"
"context"
"errors"
"fmt"
"fmt"
"strconv"
"strconv"
"strings"
"strings"
...
@@ -115,17 +116,19 @@ func (a *appChain) applyInterchainIBTP(ibtp *pb.IBTP) (*pb.IBTP, error) {
...
@@ -115,17 +116,19 @@ func (a *appChain) applyInterchainIBTP(ibtp *pb.IBTP) (*pb.IBTP, error) {
// execute interchain tx, and if execution failed, try to rollback
// execute interchain tx, and if execution failed, try to rollback
response
,
err
:=
a
.
client
.
SubmitIBTP
(
ibtp
)
response
,
err
:=
a
.
client
.
SubmitIBTP
(
ibtp
)
if
err
!=
nil
{
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
{
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
{
if
!
response
.
Status
{
pd
:=
&
pb
.
Payload
{}
pd
:=
&
pb
.
Payload
{}
if
err
:=
pd
.
Unmarshal
(
response
.
Result
.
Payload
);
err
!=
nil
{
if
err
:=
pd
.
Unmarshal
(
response
.
Result
.
Payload
);
err
!=
nil
{
entry
.
Panic
(
"Unmarshal payload"
)
entry
.
WithField
(
"error"
,
"Unmarshal payload"
)
}
}
entry
.
WithFields
(
logrus
.
Fields
{
entry
.
WithFields
(
logrus
.
Fields
{
...
@@ -133,8 +136,8 @@ func (a *appChain) applyInterchainIBTP(ibtp *pb.IBTP) (*pb.IBTP, error) {
...
@@ -133,8 +136,8 @@ func (a *appChain) applyInterchainIBTP(ibtp *pb.IBTP) (*pb.IBTP, error) {
"payload"
:
pd
,
"payload"
:
pd
,
})
.
Warn
(
"Get wrong response, need rollback on source chain"
)
})
.
Warn
(
"Get wrong response, need rollback on source chain"
)
}
}
return
response
.
Result
,
nil
return
response
.
Result
,
nil
}
}
}
func
(
a
*
appChain
)
applyReceiptIBTP
(
ibtp
*
pb
.
IBTP
)
error
{
func
(
a
*
appChain
)
applyReceiptIBTP
(
ibtp
*
pb
.
IBTP
)
error
{
...
@@ -165,7 +168,7 @@ 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
fmt
.
Errorf
(
"execute callback tx: %w"
,
err
)
}
}
return
nil
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
())
a
.
logger
.
Errorf
(
"Execution of callback function failed: %s"
,
err
.
Error
())
}
}
return
nil
return
nil
...
@@ -200,7 +203,7 @@ func (a *appChain) Rollback(ibtp *pb.IBTP, isSrcChain bool) {
...
@@ -200,7 +203,7 @@ func (a *appChain) Rollback(ibtp *pb.IBTP, isSrcChain bool) {
return
fmt
.
Errorf
(
"execute callback tx: %w"
,
err
)
return
fmt
.
Errorf
(
"execute callback tx: %w"
,
err
)
}
}
return
nil
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
())
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) {
...
@@ -287,7 +290,7 @@ func (a *appChain) QueryIBTP(to string, id string) (*pb.IBTP, error) {
}
}
c
<-
e
c
<-
e
return
nil
return
nil
},
strategy
.
Wait
(
2
*
time
.
Second
));
err
!=
nil
{
},
strategy
.
Limit
(
3
),
strategy
.
Wait
(
2
*
time
.
Second
));
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
...
@@ -314,7 +317,7 @@ func (a *appChain) QueryOuterMeta() map[string]uint64 {
...
@@ -314,7 +317,7 @@ func (a *appChain) QueryOuterMeta() map[string]uint64 {
return
err
return
err
}
}
return
nil
return
nil
},
strategy
.
Wait
(
2
*
time
.
Second
));
err
!=
nil
{
},
strategy
.
Limit
(
3
),
strategy
.
Wait
(
2
*
time
.
Second
));
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
...
...
internal/lite/hub_lite/header.go
View file @
81e2537e
...
@@ -73,7 +73,7 @@ func (lite *HubLite) syncBlock() {
...
@@ -73,7 +73,7 @@ func (lite *HubLite) syncBlock() {
}
}
return
nil
return
nil
},
strategy
.
Wait
(
1
*
time
.
Second
))
},
strategy
.
Limit
(
3
),
strategy
.
Wait
(
1
*
time
.
Second
))
if
err
!=
nil
{
if
err
!=
nil
{
lite
.
logger
.
Panic
(
err
)
lite
.
logger
.
Panic
(
err
)
}
}
...
@@ -91,7 +91,7 @@ func (lite *HubLite) getHeaderChannel() chan *pb.BlockHeader {
...
@@ -91,7 +91,7 @@ func (lite *HubLite) getHeaderChannel() chan *pb.BlockHeader {
}
}
return
nil
return
nil
},
strategy
.
Wait
(
2
*
time
.
Second
));
err
!=
nil
{
},
strategy
.
Limit
(
3
),
strategy
.
Wait
(
2
*
time
.
Second
));
err
!=
nil
{
panic
(
err
)
panic
(
err
)
}
}
...
...
model/pb/basic.pb.go
View file @
81e2537e
...
@@ -5,10 +5,11 @@ package pb
...
@@ -5,10 +5,11 @@ package pb
import
(
import
(
fmt
"fmt"
fmt
"fmt"
proto
"github.com/gogo/protobuf/proto"
io
"io"
io
"io"
math
"math"
math
"math"
math_bits
"math/bits"
math_bits
"math/bits"
proto
"github.com/gogo/protobuf/proto"
)
)
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
...
model/pb/ibtp.go
View file @
81e2537e
...
@@ -43,7 +43,6 @@ func (m *IBTP) Category() IBTP_Category {
...
@@ -43,7 +43,6 @@ func (m *IBTP) Category() IBTP_Category {
return
IBTP_UNKNOWN
return
IBTP_UNKNOWN
}
}
func
(
m
*
IBTP
)
ServicePair
()
string
{
func
(
m
*
IBTP
)
ServicePair
()
string
{
return
fmt
.
Sprintf
(
"%s-%s"
,
m
.
From
,
m
.
To
)
return
fmt
.
Sprintf
(
"%s-%s"
,
m
.
From
,
m
.
To
)
}
}
...
@@ -102,8 +101,3 @@ func ParseIBTPID(id string) (string, string, uint64, error) {
...
@@ -102,8 +101,3 @@ func ParseIBTPID(id string) (string, string, uint64, error) {
func
GenServicePair
(
from
,
to
string
)
string
{
func
GenServicePair
(
from
,
to
string
)
string
{
return
fmt
.
Sprintf
(
"%s-%s"
,
from
,
to
)
return
fmt
.
Sprintf
(
"%s-%s"
,
from
,
to
)
}
}
model/pb/ibtp.pb.go
View file @
81e2537e
...
@@ -5,10 +5,11 @@ package pb
...
@@ -5,10 +5,11 @@ package pb
import
(
import
(
fmt
"fmt"
fmt
"fmt"
proto
"github.com/gogo/protobuf/proto"
io
"io"
io
"io"
math
"math"
math
"math"
math_bits
"math/bits"
math_bits
"math/bits"
proto
"github.com/gogo/protobuf/proto"
)
)
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
...
model/pb/ibtp.proto
View file @
81e2537e
model/pb/ibtpx.pb.go
View file @
81e2537e
...
@@ -5,10 +5,11 @@ package pb
...
@@ -5,10 +5,11 @@ package pb
import
(
import
(
fmt
"fmt"
fmt
"fmt"
proto
"github.com/gogo/protobuf/proto"
io
"io"
io
"io"
math
"math"
math
"math"
math_bits
"math/bits"
math_bits
"math/bits"
proto
"github.com/gogo/protobuf/proto"
)
)
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
...
model/pb/message.pb.go
View file @
81e2537e
...
@@ -5,10 +5,11 @@ package pb
...
@@ -5,10 +5,11 @@ package pb
import
(
import
(
fmt
"fmt"
fmt
"fmt"
proto
"github.com/gogo/protobuf/proto"
io
"io"
io
"io"
math
"math"
math
"math"
math_bits
"math/bits"
math_bits
"math/bits"
proto
"github.com/gogo/protobuf/proto"
)
)
// Reference imports to suppress errors if they are not otherwise used.
// Reference imports to suppress errors if they are not otherwise used.
...
...
pkg/plugins/grpc.go
View file @
81e2537e
...
@@ -50,7 +50,7 @@ func (s *GRPCServer) GetIBTP(_ *pb.Empty, conn pb.AppchainPlugin_GetIBTPServer)
...
@@ -50,7 +50,7 @@ func (s *GRPCServer) GetIBTP(_ *pb.Empty, conn pb.AppchainPlugin_GetIBTPServer)
return
err
return
err
}
}
return
nil
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
)
logger
.
Error
(
"Execution of plugin server sending ibtp failed"
,
"error"
,
err
)
}
}
}
}
...
@@ -202,7 +202,7 @@ func (g *GRPCClient) handleIBTPStream(conn pb.AppchainPlugin_GetIBTPClient, ibtp
...
@@ -202,7 +202,7 @@ func (g *GRPCClient) handleIBTPStream(conn pb.AppchainPlugin_GetIBTPClient, ibtp
return
err
return
err
}
}
return
nil
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
)
logger
.
Error
(
"Execution of client recv failed"
,
"error"
,
err
)
}
}
...
@@ -217,7 +217,7 @@ func (g *GRPCClient) handleIBTPStream(conn pb.AppchainPlugin_GetIBTPClient, ibtp
...
@@ -217,7 +217,7 @@ func (g *GRPCClient) handleIBTPStream(conn pb.AppchainPlugin_GetIBTPClient, ibtp
func
(
g
*
GRPCClient
)
SubmitIBTP
(
ibtp
*
pb
.
IBTP
)
(
*
pb
.
SubmitIBTPResponse
,
error
)
{
func
(
g
*
GRPCClient
)
SubmitIBTP
(
ibtp
*
pb
.
IBTP
)
(
*
pb
.
SubmitIBTPResponse
,
error
)
{
var
err
error
var
err
error
response
:=
&
pb
.
SubmitIBTPResponse
{}
response
:=
&
pb
.
SubmitIBTPResponse
{}
retry
.
Retry
(
func
(
attempt
uint
)
error
{
err
=
retry
.
Retry
(
func
(
attempt
uint
)
error
{
response
,
err
=
g
.
client
.
SubmitIBTP
(
g
.
doneContext
,
ibtp
)
response
,
err
=
g
.
client
.
SubmitIBTP
(
g
.
doneContext
,
ibtp
)
if
err
!=
nil
{
if
err
!=
nil
{
logger
.
Error
(
"submit ibtp to plugin server"
,
logger
.
Error
(
"submit ibtp to plugin server"
,
...
@@ -226,9 +226,9 @@ func (g *GRPCClient) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) {
...
@@ -226,9 +226,9 @@ func (g *GRPCClient) SubmitIBTP(ibtp *pb.IBTP) (*pb.SubmitIBTPResponse, error) {
return
err
return
err
}
}
return
nil
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
)
{
func
(
g
*
GRPCClient
)
RollbackIBTP
(
ibtp
*
pb
.
IBTP
,
srcChain
bool
)
(
*
pb
.
RollbackIBTPResponse
,
error
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment