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
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
38 additions
and
37 deletions
+38
-37
appchain.go
internal/appchain/appchain.go
+22
-19
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
+1
-1
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
import
(
"context"
"errors"
"fmt"
"strconv"
"strings"
...
...
@@ -115,26 +116,28 @@ 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
.
WithField
(
"error"
,
"Unmarshal payload"
)
}
if
!
response
.
Status
{
pd
:=
&
pb
.
Payload
{}
if
err
:=
pd
.
Unmarshal
(
response
.
Result
.
Payload
);
err
!=
nil
{
entry
.
Panic
(
"Unmarshal payload
"
)
entry
.
WithFields
(
logrus
.
Fields
{
"result"
:
response
.
Message
,
"payload"
:
pd
,
})
.
Warn
(
"Get wrong response, need rollback on source chain
"
)
}
entry
.
WithFields
(
logrus
.
Fields
{
"result"
:
response
.
Message
,
"payload"
:
pd
,
})
.
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
{
...
...
@@ -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
)
}
...
...
internal/lite/hub_lite/header.go
View file @
81e2537e
...
...
@@ -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
)
}
...
...
model/pb/basic.pb.go
View file @
81e2537e
...
...
@@ -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.
...
...
model/pb/ibtp.go
View file @
81e2537e
...
...
@@ -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
)
}
model/pb/ibtp.pb.go
View file @
81e2537e
...
...
@@ -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.
...
...
model/pb/ibtp.proto
View file @
81e2537e
...
...
@@ -63,5 +63,5 @@ message IBTPs {
}
message
result
{
repeated
bytes
data
=
1
;
repeated
bytes
data
=
1
;
}
model/pb/ibtpx.pb.go
View file @
81e2537e
...
...
@@ -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.
...
...
model/pb/message.pb.go
View file @
81e2537e
...
...
@@ -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.
...
...
pkg/plugins/grpc.go
View file @
81e2537e
...
...
@@ -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
)
{
...
...
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