Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
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
plugin
Commits
1654df76
Commit
1654df76
authored
Dec 14, 2021
by
hezhengjun
Committed by
33cn
Dec 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable resend
parent
215460f5
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
172 additions
and
5 deletions
+172
-5
chain33RelayerCmd.go
plugin/dapp/cross2eth/ebcli/chain33RelayerCmd.go
+28
-0
relayer.proto
plugin/dapp/cross2eth/ebrelayer/proto/relayer.proto
+5
-0
chain33.go
plugin/dapp/cross2eth/ebrelayer/relayer/chain33/chain33.go
+54
-0
manager.go
plugin/dapp/cross2eth/ebrelayer/relayer/manager.go
+17
-0
info.go
plugin/dapp/cross2eth/ebrelayer/types/info.go
+1
-1
relayer.pb.go
plugin/dapp/cross2eth/ebrelayer/types/relayer.pb.go
+67
-4
No files found.
plugin/dapp/cross2eth/ebcli/chain33RelayerCmd.go
View file @
1654df76
...
...
@@ -30,6 +30,7 @@ func Chain33RelayerCmd() *cobra.Command {
ShowBridgeRegistryAddr4chain33Cmd
(),
TokenAddressCmd
(),
MultiSignCmd
(),
ResendChain33EventCmd
(),
)
return
cmd
...
...
@@ -421,3 +422,30 @@ func showChain33Relayer2EthTxs(cmd *cobra.Command, args []string) {
fmt
.
Println
(
hash
)
}
}
func
ResendChain33EventCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"resendChain33Event"
,
Short
:
"resend Chain33Event to ethereum process goroutine"
,
Run
:
resendChain33Event
,
}
addResendChain33EventFlags
(
cmd
)
return
cmd
}
func
addResendChain33EventFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
Int64P
(
"height"
,
"g"
,
0
,
"height begin to resend chain33 event "
)
_
=
cmd
.
MarkFlagRequired
(
"height"
)
}
func
resendChain33Event
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
height
,
_
:=
cmd
.
Flags
()
.
GetInt64
(
"height"
)
resendChain33EventReq
:=
&
ebTypes
.
ResendChain33EventReq
{
Height
:
height
,
}
var
res
rpctypes
.
Reply
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"Manager.ResendChain33Event"
,
resendChain33EventReq
,
&
res
)
ctx
.
Run
()
}
plugin/dapp/cross2eth/ebrelayer/proto/relayer.proto
View file @
1654df76
...
...
@@ -241,3 +241,8 @@ message BalanceLockedReq {
string
bridgeBank
=
1
;
string
tokenAddr
=
2
;
}
message
ResendChain33EventReq
{
int64
height
=
1
;
}
plugin/dapp/cross2eth/ebrelayer/relayer/chain33/chain33.go
View file @
1654df76
...
...
@@ -266,6 +266,60 @@ func (chain33Relayer *Relayer4Chain33) handleBurnLockEvent(evmEventType events.C
}
//DeployContrcts 部署以太坊合约
func
(
chain33Relayer
*
Relayer4Chain33
)
ResendChain33Event
(
height
int64
)
(
err
error
)
{
txLogs
,
err
:=
chain33Relayer
.
syncEvmTxLogs
.
GetNextValidEvmTxLogs
(
height
)
if
nil
==
txLogs
||
nil
!=
err
{
if
err
!=
nil
{
relayerLog
.
Error
(
"ResendChain33Event"
,
"Failed to GetNextValidTxReceipts due to:"
,
err
.
Error
())
return
err
}
return
nil
}
relayerLog
.
Debug
(
"ResendChain33Event"
,
"lastHeight4Tx"
,
chain33Relayer
.
lastHeight4Tx
,
"valid tx receipt with height:"
,
txLogs
.
Height
)
txAndLogs
:=
txLogs
.
TxAndLogs
for
_
,
txAndLog
:=
range
txAndLogs
{
tx
:=
txAndLog
.
Tx
//确认订阅的evm交易类型和合约地址
if
!
strings
.
Contains
(
string
(
tx
.
Execer
),
"evm"
)
{
relayerLog
.
Error
(
"ResendChain33Event received logs not from evm tx"
,
"tx.Execer"
,
string
(
tx
.
Execer
))
continue
}
var
evmAction
evmtypes
.
EVMContractAction
err
:=
chain33Types
.
Decode
(
tx
.
Payload
,
&
evmAction
)
if
nil
!=
err
{
relayerLog
.
Error
(
"ResendChain33Event"
,
"Failed to decode action for tx with hash"
,
common
.
ToHex
(
tx
.
Hash
()))
continue
}
//确认监听的合约地址
if
evmAction
.
ContractAddr
!=
chain33Relayer
.
bridgeBankAddr
{
relayerLog
.
Error
(
"ResendChain33Event received logs not from bridgeBank"
,
"evmAction.ContractAddr"
,
evmAction
.
ContractAddr
)
continue
}
for
_
,
evmlog
:=
range
txAndLog
.
LogsPerTx
.
Logs
{
var
evmEventType
events
.
Chain33EvmEvent
if
chain33Relayer
.
bridgeBankEventBurnSig
==
common
.
ToHex
(
evmlog
.
Topic
[
0
])
{
evmEventType
=
events
.
Chain33EventLogBurn
}
else
if
chain33Relayer
.
bridgeBankEventLockSig
==
common
.
ToHex
(
evmlog
.
Topic
[
0
])
{
evmEventType
=
events
.
Chain33EventLogLock
}
else
{
continue
}
if
err
:=
chain33Relayer
.
handleBurnLockEvent
(
evmEventType
,
evmlog
.
Data
,
tx
.
Hash
());
nil
!=
err
{
return
err
}
}
}
return
nil
}
//DeployContrcts 部署以太坊合约
func
(
chain33Relayer
*
Relayer4Chain33
)
DeployContracts
()
(
bridgeRegistry
string
,
err
error
)
{
bridgeRegistry
=
""
if
nil
==
chain33Relayer
.
deployInfo
{
...
...
plugin/dapp/cross2eth/ebrelayer/relayer/manager.go
View file @
1654df76
...
...
@@ -374,6 +374,23 @@ func (manager *Manager) Deploy2Chain33(param interface{}, result *interface{}) e
return
nil
}
func
(
manager
*
Manager
)
ResendChain33Event
(
param
*
relayerTypes
.
ResendChain33EventReq
,
result
*
interface
{})
error
{
manager
.
mtx
.
Lock
()
defer
manager
.
mtx
.
Unlock
()
if
err
:=
manager
.
checkPermission
();
nil
!=
err
{
return
err
}
err
:=
manager
.
chain33Relayer
.
ResendChain33Event
(
param
.
Height
)
if
nil
!=
err
{
return
err
}
*
result
=
rpctypes
.
Reply
{
IsOk
:
true
,
Msg
:
"Successful to ResendChain33Event"
,
}
return
nil
}
func
(
manager
*
Manager
)
CreateERC20ToChain33
(
param
relayerTypes
.
ERC20Token
,
result
*
interface
{})
error
{
manager
.
mtx
.
Lock
()
defer
manager
.
mtx
.
Unlock
()
...
...
plugin/dapp/cross2eth/ebrelayer/types/info.go
View file @
1654df76
package
types
//Version4Relayer ...
const
Version4Relayer
=
"0.1.
2
"
const
Version4Relayer
=
"0.1.
3
"
const
(
Chain33BlockChainName
=
"Chain33-mainchain"
...
...
plugin/dapp/cross2eth/ebrelayer/types/relayer.pb.go
View file @
1654df76
...
...
@@ -2384,6 +2384,53 @@ func (x *BalanceLockedReq) GetTokenAddr() string {
return
""
}
type
ResendChain33EventReq
struct
{
state
protoimpl
.
MessageState
sizeCache
protoimpl
.
SizeCache
unknownFields
protoimpl
.
UnknownFields
Height
int64
`protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"`
}
func
(
x
*
ResendChain33EventReq
)
Reset
()
{
*
x
=
ResendChain33EventReq
{}
if
protoimpl
.
UnsafeEnabled
{
mi
:=
&
file_relayer_proto_msgTypes
[
35
]
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
ms
.
StoreMessageInfo
(
mi
)
}
}
func
(
x
*
ResendChain33EventReq
)
String
()
string
{
return
protoimpl
.
X
.
MessageStringOf
(
x
)
}
func
(
*
ResendChain33EventReq
)
ProtoMessage
()
{}
func
(
x
*
ResendChain33EventReq
)
ProtoReflect
()
protoreflect
.
Message
{
mi
:=
&
file_relayer_proto_msgTypes
[
35
]
if
protoimpl
.
UnsafeEnabled
&&
x
!=
nil
{
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
if
ms
.
LoadMessageInfo
()
==
nil
{
ms
.
StoreMessageInfo
(
mi
)
}
return
ms
}
return
mi
.
MessageOf
(
x
)
}
// Deprecated: Use ResendChain33EventReq.ProtoReflect.Descriptor instead.
func
(
*
ResendChain33EventReq
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
file_relayer_proto_rawDescGZIP
(),
[]
int
{
35
}
}
func
(
x
*
ResendChain33EventReq
)
GetHeight
()
int64
{
if
x
!=
nil
{
return
x
.
Height
}
return
0
}
var
File_relayer_proto
protoreflect
.
FileDescriptor
var
file_relayer_proto_rawDesc
=
[]
byte
{
...
...
@@ -2658,8 +2705,11 @@ var file_relayer_proto_rawDesc = []byte{
0x6b
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x0a
,
0x62
,
0x72
,
0x69
,
0x64
,
0x67
,
0x65
,
0x42
,
0x61
,
0x6e
,
0x6b
,
0x12
,
0x1c
,
0x0a
,
0x09
,
0x74
,
0x6f
,
0x6b
,
0x65
,
0x6e
,
0x41
,
0x64
,
0x64
,
0x72
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x09
,
0x74
,
0x6f
,
0x6b
,
0x65
,
0x6e
,
0x41
,
0x64
,
0x64
,
0x72
,
0x42
,
0x0a
,
0x5a
,
0x08
,
0x2e
,
0x2e
,
0x2f
,
0x74
,
0x79
,
0x70
,
0x65
,
0x73
,
0x62
,
0x06
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x33
,
0x72
,
0x22
,
0x2f
,
0x0a
,
0x15
,
0x52
,
0x65
,
0x73
,
0x65
,
0x6e
,
0x64
,
0x43
,
0x68
,
0x61
,
0x69
,
0x6e
,
0x33
,
0x33
,
0x45
,
0x76
,
0x65
,
0x6e
,
0x74
,
0x52
,
0x65
,
0x71
,
0x12
,
0x16
,
0x0a
,
0x06
,
0x68
,
0x65
,
0x69
,
0x67
,
0x68
,
0x74
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x03
,
0x52
,
0x06
,
0x68
,
0x65
,
0x69
,
0x67
,
0x68
,
0x74
,
0x42
,
0x0a
,
0x5a
,
0x08
,
0x2e
,
0x2e
,
0x2f
,
0x74
,
0x79
,
0x70
,
0x65
,
0x73
,
0x62
,
0x06
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x33
,
}
var
(
...
...
@@ -2674,7 +2724,7 @@ func file_relayer_proto_rawDescGZIP() []byte {
return
file_relayer_proto_rawDescData
}
var
file_relayer_proto_msgTypes
=
make
([]
protoimpl
.
MessageInfo
,
3
5
)
var
file_relayer_proto_msgTypes
=
make
([]
protoimpl
.
MessageInfo
,
3
6
)
var
file_relayer_proto_goTypes
=
[]
interface
{}{
(
*
Account4Relayer
)(
nil
),
// 0: types.Account4Relayer
(
*
ValidatorAddr4EthRelayer
)(
nil
),
// 1: types.ValidatorAddr4EthRelayer
...
...
@@ -2711,6 +2761,7 @@ var file_relayer_proto_goTypes = []interface{}{
(
*
ETHTokenLockAddress
)(
nil
),
// 32: types.ETHTokenLockAddress
(
*
ETHConfigLockedTokenOffline
)(
nil
),
// 33: types.ETHConfigLockedTokenOffline
(
*
BalanceLockedReq
)(
nil
),
// 34: types.BalanceLockedReq
(
*
ResendChain33EventReq
)(
nil
),
// 35: types.ResendChain33EventReq
}
var
file_relayer_proto_depIdxs
=
[]
int32
{
25
,
// 0: types.TokenAddressArray.tokenAddress:type_name -> types.TokenAddress
...
...
@@ -3149,6 +3200,18 @@ func file_relayer_proto_init() {
return
nil
}
}
file_relayer_proto_msgTypes
[
35
]
.
Exporter
=
func
(
v
interface
{},
i
int
)
interface
{}
{
switch
v
:=
v
.
(
*
ResendChain33EventReq
);
i
{
case
0
:
return
&
v
.
state
case
1
:
return
&
v
.
sizeCache
case
2
:
return
&
v
.
unknownFields
default
:
return
nil
}
}
}
type
x
struct
{}
out
:=
protoimpl
.
TypeBuilder
{
...
...
@@ -3156,7 +3219,7 @@ func file_relayer_proto_init() {
GoPackagePath
:
reflect
.
TypeOf
(
x
{})
.
PkgPath
(),
RawDescriptor
:
file_relayer_proto_rawDesc
,
NumEnums
:
0
,
NumMessages
:
3
5
,
NumMessages
:
3
6
,
NumExtensions
:
0
,
NumServices
:
0
,
},
...
...
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