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
fc3dafc5
Commit
fc3dafc5
authored
May 20, 2020
by
whisker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix refactor bug
parent
b1a0fb3e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
412 additions
and
161 deletions
+412
-161
RopstenTest.sh
plugin/dapp/x2Ethereum/cmd/build/RopstenTest.sh
+21
-21
allRelayerTest.sh
plugin/dapp/x2Ethereum/cmd/build/allRelayerTest.sh
+22
-22
perf_test.sh
plugin/dapp/x2Ethereum/cmd/build/perf_test.sh
+9
-9
commands.go
plugin/dapp/x2Ethereum/commands/commands.go
+5
-11
query.go
plugin/dapp/x2Ethereum/commands/query.go
+0
-1
ethereumRelayerCmd.go
plugin/dapp/x2Ethereum/ebcli/ethereumRelayerCmd.go
+32
-3
parser.go
plugin/dapp/x2Ethereum/ebrelayer/ethtxs/parser.go
+1
-1
queryFromEth.go
plugin/dapp/x2Ethereum/ebrelayer/ethtxs/queryFromEth.go
+12
-0
relayToChain33.go
plugin/dapp/x2Ethereum/ebrelayer/ethtxs/relayToChain33.go
+2
-4
relayToEthereum.go
plugin/dapp/x2Ethereum/ebrelayer/ethtxs/relayToEthereum.go
+1
-1
types.go
plugin/dapp/x2Ethereum/ebrelayer/ethtxs/types.go
+2
-2
events.go
plugin/dapp/x2Ethereum/ebrelayer/events/events.go
+1
-1
ethereum.go
...in/dapp/x2Ethereum/ebrelayer/relayer/ethereum/ethereum.go
+4
-0
manager.go
plugin/dapp/x2Ethereum/ebrelayer/relayer/manager.go
+28
-3
config.pb.go
plugin/dapp/x2Ethereum/ebrelayer/types/config.pb.go
+1
-2
relayer.pb.go
plugin/dapp/x2Ethereum/ebrelayer/types/relayer.pb.go
+1
-2
exec.go
plugin/dapp/x2Ethereum/executor/exec.go
+9
-4
exec_local.go
plugin/dapp/x2Ethereum/executor/exec_local.go
+4
-4
query.go
plugin/dapp/x2Ethereum/executor/query.go
+2
-3
x2ethereumaction.go
plugin/dapp/x2Ethereum/executor/x2ethereumaction.go
+7
-9
x2ethereumdb.go
plugin/dapp/x2Ethereum/executor/x2ethereumdb.go
+1
-1
x2ethereum.proto
plugin/dapp/x2Ethereum/proto/x2ethereum.proto
+5
-5
allRelayerTest.sh
plugin/dapp/x2Ethereum/testsh/allRelayerTest.sh
+195
-5
bridgeBankTest.sh
plugin/dapp/x2Ethereum/testsh/bridgeBankTest.sh
+24
-24
ebrelayerTest.sh
plugin/dapp/x2Ethereum/testsh/ebrelayerTest.sh
+7
-7
x2ethereumTest.sh
plugin/dapp/x2Ethereum/testsh/x2ethereumTest.sh
+3
-3
const.go
plugin/dapp/x2Ethereum/types/const.go
+4
-4
x2ethereum.go
plugin/dapp/x2Ethereum/types/x2ethereum.go
+9
-9
x2ethereum.pb.go
plugin/dapp/x2Ethereum/types/x2ethereum.pb.go
+0
-0
No files found.
plugin/dapp/x2Ethereum/cmd/build/RopstenTest.sh
View file @
fc3dafc5
...
...
@@ -206,14 +206,14 @@ function EthImportKey() {
function
TestChain33ToEthAssets
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
# token4chain33 在 以太坊 上先有 bty
tokenSymbol
=
"bty"
tokenSymbol
=
"
coins.
bty"
result
=
$(${
CLIA
}
relayer ethereum token4chain33
-s
"
${
tokenSymbol
}
"
)
tokenAddrBty
=
$(
cli_ret
"
${
result
}
"
"token4chain33"
".addr"
)
#tokenAddrBty="0xE79142B3171019fcfcA838f0792edB08d4F2a94F"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
AddrBty
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# chain33 lock bty
...
...
@@ -226,14 +226,14 @@ function TestChain33ToEthAssets() {
eth_block_wait
$((
maturityDegree
+
3
))
https://ropsten-rpc.linkpool.io/
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
AddrBty
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"5"
# eth burn
result
=
$(${
CLIA
}
relayer ethereum burn
-m
5
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33SenderAddr
}
"
-t
"
${
tokenAddrBty
}
"
)
cli_ret
"
${
result
}
"
"burn"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
AddrBty
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# eth 等待 10 个区块
...
...
@@ -305,23 +305,23 @@ function TestETH2Chain33Erc20() {
result
=
$(${
CLIA
}
relayer ethereum mint
-m
1000
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"mint"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"1000"
result
=
$(${
CLIA
}
relayer ethereum bridgeBankAddr
)
bridgeBankAddr
=
$(
cli_ret
"
${
result
}
"
"bridgeBankAddr"
".addr"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# lock 100
result
=
$(${
CLIA
}
relayer ethereum lock
-m
100
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33Validator1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"lock"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"900"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
# eth 等待 10 个区块
...
...
@@ -340,10 +340,10 @@ function TestETH2Chain33Erc20() {
eth_block_wait 2 https://ropsten-rpc.linkpool.io/
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
...
...
@@ -352,7 +352,7 @@ function TestETH2Chain33Erc20() {
function
TestChain33ToEthAssetsKill
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
tokenSymbol
=
"bty"
tokenSymbol
=
"
coins.
bty"
if
[
"
${
tokenAddrBty
}
"
==
""
]
;
then
# token4chain33 在 以太坊 上先有 bty
result
=
$(${
CLIA
}
relayer ethereum token4chain33
-s
"
${
tokenSymbol
}
"
)
...
...
@@ -361,7 +361,7 @@ function TestChain33ToEthAssetsKill() {
# tokenAddrBty="0xE79142B3171019fcfcA838f0792edB08d4F2a94F"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
AddrBty
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
kill_ebrelayerC
...
...
@@ -374,19 +374,19 @@ function TestChain33ToEthAssetsKill() {
eth_block_wait
$((
maturityDegree
+
3
))
https://ropsten-rpc.linkpool.io/
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
AddrBty
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
start_ebrelayerC
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
AddrBty
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"1.41"
# eth burn
result
=
$(${
CLIA
}
relayer ethereum burn
-m
1.41
-k
"
${
ethReceiverAddrKey2
}
"
-r
"
${
chain33Validator1
}
"
-t
"
${
tokenAddrBty
}
"
)
cli_ret
"
${
result
}
"
"burn"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
AddrBty
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# eth 等待 10 个区块
...
...
@@ -477,13 +477,13 @@ function TestETH2Chain33Erc20Kill() {
result
=
$(${
CLIA
}
relayer ethereum mint
-m
1000
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"mint"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"1000"
result
=
$(${
CLIA
}
relayer ethereum bridgeBankAddr
)
bridgeBankAddr
=
$(
cli_ret
"
${
result
}
"
"bridgeBankAddr"
".addr"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
kill_ebrelayerC
...
...
@@ -493,10 +493,10 @@ function TestETH2Chain33Erc20Kill() {
result
=
$(${
CLIA
}
relayer ethereum lock
-m
100
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33Validator1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"lock"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"900"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
# eth 等待 10 个区块
...
...
@@ -526,10 +526,10 @@ function TestETH2Chain33Erc20Kill() {
start_ebrelayerC
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
...
...
plugin/dapp/x2Ethereum/cmd/build/allRelayerTest.sh
View file @
fc3dafc5
...
...
@@ -221,14 +221,14 @@ function InitChain33Vilators() {
function
TestChain33ToEthAssets
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
# token4chain33 在 以太坊 上先有 bty
result
=
$(${
CLIA
}
relayer ethereum token4chain33
-s
bty
)
result
=
$(${
CLIA
}
relayer ethereum token4chain33
-s
coins.
bty
)
tokenAddrBty
=
$(
cli_ret
"
${
result
}
"
"token4chain33"
".addr"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddrBty
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# chain33 lock bty
hash
=
$(${
Chain33Cli
}
send x2ethereum lock
-a
5
-t
bty
-r
${
ethReceiverAddr1
}
-q
${
tokenAddrBty
}
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
hash
=
$(${
Chain33Cli
}
send x2ethereum lock
-a
5
-t
coins.
bty
-r
${
ethReceiverAddr1
}
-q
${
tokenAddrBty
}
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
block_wait
"
${
Chain33Cli
}
"
$((
maturityDegree
+
2
))
check_tx
"
${
Chain33Cli
}
"
"
${
hash
}
"
...
...
@@ -237,14 +237,14 @@ function TestChain33ToEthAssets() {
eth_block_wait
$((
maturityDegree
+
2
))
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddrBty
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"5"
# eth burn
result
=
$(${
CLIA
}
relayer ethereum burn
-m
5
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33SenderAddr
}
"
-t
"
${
tokenAddrBty
}
"
)
cli_ret
"
${
result
}
"
"burn"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddrBty
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# eth 等待 10 个区块
...
...
@@ -315,23 +315,23 @@ function TestETH2Chain33Erc20() {
result
=
$(${
CLIA
}
relayer ethereum mint
-m
1000
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"mint"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"1000"
result
=
$(${
CLIA
}
relayer ethereum bridgeBankAddr
)
bridgeBankAddr
=
$(
cli_ret
"
${
result
}
"
"bridgeBankAddr"
".addr"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# lock 100
result
=
$(${
CLIA
}
relayer ethereum lock
-m
100
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33Validator1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"lock"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"900"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
# eth 等待 10 个区块
...
...
@@ -350,10 +350,10 @@ function TestETH2Chain33Erc20() {
eth_block_wait 2
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
...
...
@@ -364,11 +364,11 @@ function TestChain33ToEthAssetsKill() {
if
[
"
${
tokenAddrBty
}
"
==
""
]
;
then
# token4chain33 在 以太坊 上先有 bty
result
=
$(${
CLIA
}
relayer ethereum token4chain33
-s
bty
)
result
=
$(${
CLIA
}
relayer ethereum token4chain33
-s
coins.
bty
)
tokenAddrBty
=
$(
cli_ret
"
${
result
}
"
"token4chain33"
".addr"
)
fi
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddrBty
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
kill_ebrelayerC
...
...
@@ -381,19 +381,19 @@ function TestChain33ToEthAssetsKill() {
eth_block_wait
$((
maturityDegree
+
2
))
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddrBty
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
start_ebrelayerC
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddrBty
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"5"
# eth burn
result
=
$(${
CLIA
}
relayer ethereum burn
-m
5
-k
"
${
ethReceiverAddrKey2
}
"
-r
"
${
chain33Validator1
}
"
-t
"
${
tokenAddrBty
}
"
)
cli_ret
"
${
result
}
"
"burn"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddrBty
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# eth 等待 10 个区块
...
...
@@ -484,13 +484,13 @@ function TestETH2Chain33Erc20Kill() {
result
=
$(${
CLIA
}
relayer ethereum mint
-m
1000
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"mint"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"1000"
result
=
$(${
CLIA
}
relayer ethereum bridgeBankAddr
)
bridgeBankAddr
=
$(
cli_ret
"
${
result
}
"
"bridgeBankAddr"
".addr"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
kill_ebrelayerC
...
...
@@ -500,10 +500,10 @@ function TestETH2Chain33Erc20Kill() {
result
=
$(${
CLIA
}
relayer ethereum lock
-m
100
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33Validator1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"lock"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"900"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
# eth 等待 10 个区块
...
...
@@ -533,10 +533,10 @@ function TestETH2Chain33Erc20Kill() {
start_ebrelayerC
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
...
...
plugin/dapp/x2Ethereum/cmd/build/perf_test.sh
View file @
fc3dafc5
...
...
@@ -104,8 +104,8 @@ loop_send_lock_bty() {
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
preEthBalance[
$i
]=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethAddress
[i]
}
"
-t
"
${
tokenAddrBty
}
"
| jq
-r
".balance"
)
ethTxHash
=
$(${
Chain33_CLI
}
send x2ethereum lock
-q
"
${
tokenAddrBty
}
"
-a
1
-r
${
ethAddress
[i]
}
-t
bty
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
preEthBalance[
$i
]=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethAddress
[i]
}
"
-t
"
coins.bty
"
| jq
-r
".balance"
)
ethTxHash
=
$(${
Chain33_CLI
}
send x2ethereum lock
-q
"
${
tokenAddrBty
}
"
-a
1
-r
${
ethAddress
[i]
}
-t
coins.
bty
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
echo
${
i
}
"lock chain33 tx hash:"
${
ethTxHash
}
let
i++
done
...
...
@@ -114,7 +114,7 @@ loop_send_lock_bty() {
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
nowEthBalance
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethAddress
[i]
}
"
-t
"
${
tokenAddrBty
}
"
| jq
-r
".balance"
)
nowEthBalance
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethAddress
[i]
}
"
-t
"
coins.bty
"
| jq
-r
".balance"
)
res
=
$((
nowEthBalance
-
preEthBalance[i]
))
echo
${
i
}
"preBalance"
${
preEthBalance
[i]
}
"nowBalance"
${
nowEthBalance
}
"diff"
${
res
}
check_number
"
${
res
}
"
1
...
...
@@ -136,7 +136,7 @@ loop_send_burn_bty() {
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
preEthBalance[
$i
]=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethAddress
[i]
}
"
-t
"
${
tokenAddrBty
}
"
| jq
-r
".balance"
)
preEthBalance[
$i
]=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethAddress
[i]
}
"
-t
"
coins.bty
"
| jq
-r
".balance"
)
approveTxHash
=
$(${
CLIA
}
relayer ethereum approve
-m
1
-k
"
${
privateKeys
[i]
}
"
-t
"
${
tokenAddrBty
}
"
)
ethTxHash
=
$(${
CLIA
}
relayer ethereum burn-async
-m
1
-k
"
${
privateKeys
[i]
}
"
-r
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
"
${
tokenAddrBty
}
"
)
echo
${
i
}
"burn-async tx hash:"
${
ethTxHash
}
...
...
@@ -147,7 +147,7 @@ loop_send_burn_bty() {
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
nowEthBalance
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethAddress
[i]
}
"
-t
"
${
tokenAddrBty
}
"
| jq
-r
".balance"
)
nowEthBalance
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethAddress
[i]
}
"
-t
"
coins.bty
"
| jq
-r
".balance"
)
res
=
$((
preEthBalance[i]
-
nowEthBalance
))
echo
${
i
}
"preBalance"
${
preEthBalance
[i]
}
"nowBalance"
${
nowEthBalance
}
"diff"
${
res
}
check_number
"
${
res
}
"
1
...
...
@@ -167,7 +167,7 @@ loop_send_lock_erc20() {
preChain33Balance
=
$(${
Chain33_CLI
}
x2ethereum balance
-s
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
-t
testc | jq
".res"
| jq
".[]"
| jq
".balance"
|
sed
's/\"//g'
)
i
=
0
preEthBalance
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
Ethsender
}
"
-t
"
${
tokenAddr
}
"
| jq
-r
".balance"
)
preEthBalance
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
Ethsender
}
"
-t
"
testc
"
| jq
-r
".balance"
)
approveTxHash
=
$(${
CLIA
}
relayer ethereum approve
-m
10
-k
"
${
privateKeys
[5]
}
"
-t
"
${
tokenAddr
}
"
)
echo
${
i
}
"lock-async erc20 approve tx hash:"
${
approveTxHash
}
...
...
@@ -180,7 +180,7 @@ loop_send_lock_erc20() {
eth_block_wait
$((
maturityDegree
+
2
))
nowEthBalance
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
Ethsender
}
"
-t
"
${
tokenAddr
}
"
| jq
-r
".balance"
)
nowEthBalance
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
Ethsender
}
"
-t
"
testc
"
| jq
-r
".balance"
)
res
=
$((
preEthBalance
-
nowEthBalance
))
echo
${
i
}
"preBalance"
${
preEthBalance
}
"nowBalance"
${
nowEthBalance
}
"diff"
${
res
}
check_number
"
${
diff
}
"
7
...
...
@@ -200,7 +200,7 @@ loop_send_burn_erc20() {
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
preEthBalance[i]
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethAddress
[i]
}
"
-t
"
${
tokenAddr
}
"
| jq
-r
".balance"
)
preEthBalance[i]
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethAddress
[i]
}
"
-t
"
testc
"
| jq
-r
".balance"
)
ethTxHash
=
$(${
Chain33_CLI
}
send x2ethereum burn
-a
1
-r
${
ethAddress
[i]
}
-t
testc
-q
"
${
tokenAddr
}
"
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
echo
${
i
}
"burn chain33 tx hash:"
${
ethTxHash
}
let
i++
...
...
@@ -210,7 +210,7 @@ loop_send_burn_erc20() {
i
=
0
while
[[
i
-lt
${#
privateKeys
[@]
}
]]
;
do
nowEthBalance
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethAddress
[i]
}
"
-t
"
${
tokenAddr
}
"
| jq
-r
".balance"
)
nowEthBalance
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethAddress
[i]
}
"
-t
"
testc
"
| jq
-r
".balance"
)
res
=
$((
nowEthBalance
-
preEthBalance[i]
))
echo
${
i
}
"preBalance"
${
preEthBalance
[i]
}
"nowBalance"
${
nowEthBalance
}
"diff"
${
res
}
check_number
"
${
res
}
"
1
...
...
plugin/dapp/x2Ethereum/commands/commands.go
View file @
fc3dafc5
...
...
@@ -143,9 +143,6 @@ func CreateRawWithdrawEthTxCmd() *cobra.Command {
addEth2Chain33Flags
(
cmd
)
cmd
.
Flags
()
.
StringP
(
"exec"
,
"e"
,
""
,
"exec name token or coins"
)
_
=
cmd
.
MarkFlagRequired
(
"exec"
)
return
cmd
}
...
...
@@ -203,7 +200,7 @@ func CreateRawWithdrawChain33TxCmd() *cobra.Command {
func
addChain33ToEthFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"contract"
,
"q"
,
""
,
"token contract address,nil for ETH"
)
cmd
.
Flags
()
.
StringP
(
"symbol"
,
"t"
,
""
,
"token symbol in chain33"
)
cmd
.
Flags
()
.
StringP
(
"symbol"
,
"t"
,
""
,
"token symbol in chain33
,coins.bty etc.
"
)
_
=
cmd
.
MarkFlagRequired
(
"symbol"
)
cmd
.
Flags
()
.
StringP
(
"receiver"
,
"r"
,
""
,
"ethereum receiver address"
)
...
...
@@ -221,16 +218,16 @@ func burn(cmd *cobra.Command, args []string) {
amount
,
_
:=
cmd
.
Flags
()
.
GetFloat64
(
"amount"
)
nodeAddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"node_addr"
)
if
contract
==
""
{
contract
=
"0x0000000000000000000000000000000000000000"
}
decimal
,
err
:=
utils
.
GetDecimalsFromNode
(
contract
,
nodeAddr
)
if
err
!=
nil
{
fmt
.
Println
(
"get decimal error"
)
return
}
if
contract
==
""
{
contract
=
"0x0000000000000000000000000000000000000000"
}
params
:=
&
types3
.
Chain33ToEth
{
TokenContract
:
contract
,
EthereumReceiver
:
receiver
,
...
...
@@ -254,9 +251,6 @@ func CreateRawChain33ToEthTxCmd() *cobra.Command {
addChain33ToEthFlags
(
cmd
)
cmd
.
Flags
()
.
StringP
(
"exec"
,
"e"
,
""
,
"exec name token or coins"
)
_
=
cmd
.
MarkFlagRequired
(
"exec"
)
return
cmd
}
...
...
plugin/dapp/x2Ethereum/commands/query.go
View file @
fc3dafc5
...
...
@@ -26,7 +26,6 @@ func queryCmd() *cobra.Command {
queryConsensusCmd
(),
queryTotalPowerCmd
(),
querySymbolTotalAmountByTxTypeCmd
(),
queryRelayerBalanceCmd
(),
)
return
cmd
}
...
...
plugin/dapp/x2Ethereum/ebcli/ethereumRelayerCmd.go
View file @
fc3dafc5
...
...
@@ -49,6 +49,7 @@ func EthereumRelayerCmd() *cobra.Command {
ShowBridgeRegistryAddrCmd
(),
StaticsCmd
(),
TransferTokenCmd
(),
GetToken2addressCmd
(),
)
return
cmd
...
...
@@ -683,17 +684,17 @@ func GetBalanceCmd() *cobra.Command {
func
GetBalanceFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"owner"
,
"o"
,
""
,
"owner address"
)
_
=
cmd
.
MarkFlagRequired
(
"owner"
)
cmd
.
Flags
()
.
StringP
(
"token
Addr"
,
"t"
,
""
,
"token address, optional,
nil for Eth"
)
cmd
.
Flags
()
.
StringP
(
"token
"
,
"t"
,
""
,
"token symbol,
nil for Eth"
)
}
func
GetBalance
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
owner
,
_
:=
cmd
.
Flags
()
.
GetString
(
"owner"
)
token
Addr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"tokenAddr
"
)
token
,
_
:=
cmd
.
Flags
()
.
GetString
(
"token
"
)
para
:=
ebTypes
.
BalanceAddr
{
Owner
:
owner
,
TokenAddr
:
token
Addr
,
TokenAddr
:
token
,
}
var
res
ebTypes
.
ReplyBalance
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"RelayerManager.GetBalance"
,
para
,
&
res
)
...
...
@@ -772,3 +773,31 @@ func TransferToken(cmd *cobra.Command, args []string) {
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"RelayerManager.TransferToken"
,
para
,
&
res
)
ctx
.
Run
()
}
func
GetToken2addressCmd
()
*
cobra
.
Command
{
cmd
:=
&
cobra
.
Command
{
Use
:
"tokenaddr"
,
Short
:
"get token address by symbol"
,
Run
:
GetToken2address
,
}
GetToken2addressFlags
(
cmd
)
return
cmd
}
func
GetToken2addressFlags
(
cmd
*
cobra
.
Command
)
{
cmd
.
Flags
()
.
StringP
(
"token"
,
"t"
,
""
,
"token symbol"
)
_
=
cmd
.
MarkFlagRequired
(
"token"
)
}
func
GetToken2address
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
rpcLaddr
,
_
:=
cmd
.
Flags
()
.
GetString
(
"rpc_laddr"
)
tokenSymbol
,
_
:=
cmd
.
Flags
()
.
GetString
(
"token"
)
para
:=
ebTypes
.
TokenStatics
{
TokenAddr
:
tokenSymbol
,
}
var
res
ebTypes
.
ReplyAddr
ctx
:=
jsonclient
.
NewRPCCtx
(
rpcLaddr
,
"RelayerManager.ShowTokenAddrBySymbol"
,
para
,
&
res
)
ctx
.
Run
()
}
plugin/dapp/x2Ethereum/ebrelayer/ethtxs/parser.go
View file @
fc3dafc5
...
...
@@ -99,7 +99,7 @@ func ParseBurnLockTxReceipt(claimType events.Event, receipt *chain33Types.Receip
chain33Sender
=
[]
byte
(
chain33ToEth
.
Chain33Sender
)
ethereumReceiver
=
common
.
HexToAddress
(
chain33ToEth
.
EthereumReceiver
)
tokenContractAddress
=
common
.
HexToAddress
(
chain33ToEth
.
TokenContract
)
symbol
=
chain33ToEth
.
Eth
Symbol
symbol
=
chain33ToEth
.
IssuerDot
Symbol
chain33ToEth
.
Amount
=
types
.
TrimZeroAndDot
(
chain33ToEth
.
Amount
)
amount
=
big
.
NewInt
(
1
)
amount
,
_
=
amount
.
SetString
(
chain33ToEth
.
Amount
,
10
)
...
...
plugin/dapp/x2Ethereum/ebrelayer/ethtxs/queryFromEth.go
View file @
fc3dafc5
...
...
@@ -135,3 +135,15 @@ func GetDepositFunds(client *ethclient.Client, tokenAddrStr string) (string, err
}
return
supply
.
String
(),
nil
}
func
GetToken2address
(
bridgeBank
*
generated
.
BridgeBank
,
tokenSymbol
string
)
(
string
,
error
)
{
opts
:=
&
bind
.
CallOpts
{
Pending
:
true
,
Context
:
context
.
Background
(),
}
tokenAddr
,
err
:=
bridgeBank
.
GetToken2address
(
opts
,
tokenSymbol
)
if
nil
!=
err
{
return
""
,
err
}
return
tokenAddr
.
String
(),
nil
}
plugin/dapp/x2Ethereum/ebrelayer/ethtxs/relayToChain33.go
View file @
fc3dafc5
...
...
@@ -27,8 +27,7 @@ func RelayLockToChain33(privateKey chain33Crypto.PrivKey, claim *ebrelayerTypes.
EthereumChainID
:
claim
.
EthereumChainID
,
BridgeContractAddress
:
claim
.
BridgeBrankAddr
,
Nonce
:
claim
.
Nonce
,
LocalCoinSymbol
:
claim
.
Symbol
,
LocalCoinExec
:
X2Eth
,
IssuerDotSymbol
:
claim
.
Symbol
,
TokenContractAddress
:
claim
.
TokenAddr
,
EthereumSender
:
claim
.
EthereumSender
,
Chain33Receiver
:
claim
.
Chain33Receiver
,
...
...
@@ -84,8 +83,7 @@ func RelayBurnToChain33(privateKey chain33Crypto.PrivKey, claim *ebrelayerTypes.
EthereumChainID
:
claim
.
EthereumChainID
,
BridgeContractAddress
:
claim
.
BridgeBrankAddr
,
Nonce
:
claim
.
Nonce
,
LocalCoinSymbol
:
claim
.
Symbol
,
LocalCoinExec
:
X2Eth
,
IssuerDotSymbol
:
claim
.
Symbol
,
TokenContractAddress
:
claim
.
TokenAddr
,
EthereumSender
:
claim
.
EthereumSender
,
Chain33Receiver
:
claim
.
Chain33Receiver
,
...
...
plugin/dapp/x2Ethereum/ebrelayer/ethtxs/relayToEthereum.go
View file @
fc3dafc5
...
...
@@ -32,7 +32,7 @@ func RelayOracleClaimToEthereum(oracleInstance *generated.Oracle, client *ethcli
}
auth
.
GasLimit
=
GasLimit
claimID
:=
crypto
.
Keccak256Hash
(
chain33TxHash
,
claim
.
Chain33Sender
,
claim
.
EthereumReceiver
.
Bytes
(),
claim
.
TokenContractAddress
.
Bytes
(
),
claim
.
Amount
.
Bytes
())
claimID
:=
crypto
.
Keccak256Hash
(
chain33TxHash
,
claim
.
Chain33Sender
,
claim
.
EthereumReceiver
.
Bytes
(),
[]
byte
(
claim
.
Symbol
),
claim
.
Amount
.
Bytes
())
// Sign the hash using the active validator's private key
signature
,
err
:=
SignClaim4Eth
(
claimID
,
privateKey
)
...
...
plugin/dapp/x2Ethereum/ebrelayer/ethtxs/types.go
View file @
fc3dafc5
...
...
@@ -9,8 +9,8 @@ import (
const
(
X2Eth
=
"x2ethereum"
BurnAction
=
"
WithdrawChain33
"
LockAction
=
"Chain33ToEth"
BurnAction
=
"
Chain33ToEthBurn
"
LockAction
=
"Chain33ToEth
Lock
"
)
// OracleClaim : contains data required to make an OracleClaim
...
...
plugin/dapp/x2Ethereum/ebrelayer/events/events.go
View file @
fc3dafc5
...
...
@@ -31,7 +31,7 @@ const (
// String : returns the event type as a string
func
(
d
Event
)
String
()
string
{
return
[
...
]
string
{
"unknown-x2ethereum"
,
"
WithdrawChain33-burn"
,
"Chain33ToEth-l
ock"
,
"LogLock"
,
"LogChain33TokenBurn"
,
"LogNewProphecyClaim"
}[
d
]
return
[
...
]
string
{
"unknown-x2ethereum"
,
"
Chain33ToEthBurn"
,
"Chain33ToEthL
ock"
,
"LogLock"
,
"LogChain33TokenBurn"
,
"LogNewProphecyClaim"
}[
d
]
}
// Chain33MsgAttributeKey : enum containing supported attribute keys
...
...
plugin/dapp/x2Ethereum/ebrelayer/relayer/ethereum/ethereum.go
View file @
fc3dafc5
...
...
@@ -257,6 +257,10 @@ func (ethRelayer *EthereumRelayer) ShowDepositStatics(tokenAddr string) (string,
return
ethtxs
.
GetDepositFunds
(
ethRelayer
.
client
,
tokenAddr
)
}
func
(
ethRelayer
*
EthereumRelayer
)
ShowTokenAddrBySymbol
(
tokenSymbol
string
)
(
string
,
error
)
{
return
ethtxs
.
GetToken2address
(
ethRelayer
.
x2EthContracts
.
BridgeBank
,
tokenSymbol
)
}
func
(
ethRelayer
*
EthereumRelayer
)
IsProphecyPending
(
claimID
[
32
]
byte
)
(
bool
,
error
)
{
return
ethtxs
.
IsProphecyPending
(
claimID
,
ethRelayer
.
ethValidator
,
ethRelayer
.
x2EthContracts
.
Chain33Bridge
)
}
...
...
plugin/dapp/x2Ethereum/ebrelayer/relayer/manager.go
View file @
fc3dafc5
...
...
@@ -5,6 +5,7 @@ import (
"fmt"
"math/big"
"strconv"
"strings"
"sync"
"sync/atomic"
...
...
@@ -507,16 +508,25 @@ func (manager *RelayerManager) IsProphecyPending(claimID [32]byte, result *inter
func
(
manager
*
RelayerManager
)
GetBalance
(
balanceAddr
relayerTypes
.
BalanceAddr
,
result
*
interface
{})
error
{
manager
.
mtx
.
Lock
()
defer
manager
.
mtx
.
Unlock
()
balance
,
err
:=
manager
.
ethRelayer
.
GetBalance
(
balanceAddr
.
TokenAddr
,
balanceAddr
.
Owner
)
var
addr
string
var
err
error
if
balanceAddr
.
TokenAddr
!=
""
{
addr
,
err
=
manager
.
ethRelayer
.
ShowTokenAddrBySymbol
(
balanceAddr
.
TokenAddr
)
if
nil
!=
err
{
return
err
}
}
balance
,
err
:=
manager
.
ethRelayer
.
GetBalance
(
addr
,
balanceAddr
.
Owner
)
if
nil
!=
err
{
return
err
}
var
d
int64
if
balanceAddr
.
TokenAddr
==
""
||
balanceAddr
.
TokenAddr
==
"0x0000000000000000000000000000000000000000
"
{
if
balanceAddr
.
TokenAddr
==
""
||
strings
.
ToLower
(
balanceAddr
.
TokenAddr
)
==
"eth
"
{
d
=
18
}
else
{
d
,
err
=
manager
.
GetDecimals
(
balanceAddr
.
TokenA
ddr
)
d
,
err
=
manager
.
GetDecimals
(
a
ddr
)
if
err
!=
nil
{
return
errors
.
New
(
"get decimals error"
)
}
...
...
@@ -601,6 +611,21 @@ func (manager *RelayerManager) ShowDepositStatics(token relayerTypes.TokenStatic
return
nil
}
func
(
manager
*
RelayerManager
)
ShowTokenAddrBySymbol
(
token
relayerTypes
.
TokenStatics
,
result
*
interface
{})
error
{
manager
.
mtx
.
Lock
()
defer
manager
.
mtx
.
Unlock
()
addr
,
err
:=
manager
.
ethRelayer
.
ShowTokenAddrBySymbol
(
token
.
TokenAddr
)
if
nil
!=
err
{
return
err
}
*
result
=
relayerTypes
.
ReplyAddr
{
IsOK
:
true
,
Addr
:
addr
,
}
return
nil
}
func
(
manager
*
RelayerManager
)
ShowTxReceipt
(
txhash
string
,
result
*
interface
{})
error
{
manager
.
mtx
.
Lock
()
defer
manager
.
mtx
.
Unlock
()
...
...
plugin/dapp/x2Ethereum/ebrelayer/types/config.pb.go
View file @
fc3dafc5
...
...
@@ -5,9 +5,8 @@ package types
import
(
fmt
"fmt"
math
"math"
proto
"github.com/golang/protobuf/proto"
math
"math"
)
// Reference imports to suppress errors if they are not otherwise used.
...
...
plugin/dapp/x2Ethereum/ebrelayer/types/relayer.pb.go
View file @
fc3dafc5
...
...
@@ -5,9 +5,8 @@ package types
import
(
fmt
"fmt"
math
"math"
proto
"github.com/golang/protobuf/proto"
math
"math"
)
// Reference imports to suppress errors if they are not otherwise used.
...
...
plugin/dapp/x2Ethereum/executor/exec.go
View file @
fc3dafc5
...
...
@@ -20,7 +20,7 @@ import (
// Eth2Chain33类型的交易是Ethereum侧锁定一定金额的eth或者erc20到合约中
// 然后relayer端订阅到该消息后向chain33发送该类型消息
// 本端在验证该类型的请求合理后铸币,并生成相同数额的token
func
(
x
*
x2ethereum
)
Exec_Eth2Chain33
_l
ock
(
payload
*
x2eTy
.
Eth2Chain33
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
x
*
x2ethereum
)
Exec_Eth2Chain33
L
ock
(
payload
*
x2eTy
.
Eth2Chain33
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
newAction
(
x
,
tx
,
int32
(
index
))
if
action
==
nil
{
return
nil
,
errors
.
New
(
"Create Action Error"
)
...
...
@@ -33,7 +33,7 @@ func (x *x2ethereum) Exec_Eth2Chain33_lock(payload *x2eTy.Eth2Chain33, tx *types
//---------------- Chain33(eth/erc20)------> Ethereum -------------------//
// WithdrawChain33类型的交易是将Eth端因Chain33端锁定所生成的token返还给Chain33端(Burn)
func
(
x
*
x2ethereum
)
Exec_Chain33ToEth
_b
urn
(
payload
*
x2eTy
.
Chain33ToEth
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
x
*
x2ethereum
)
Exec_Chain33ToEth
B
urn
(
payload
*
x2eTy
.
Chain33ToEth
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
newAction
(
x
,
tx
,
int32
(
index
))
if
action
==
nil
{
return
nil
,
errors
.
New
(
"Create Action Error"
)
...
...
@@ -44,7 +44,7 @@ func (x *x2ethereum) Exec_Chain33ToEth_burn(payload *x2eTy.Chain33ToEth, tx *typ
//---------------- Chain33(eth/erc20) --> Ethereum-------------------//
// 将因ethereum端锁定的eth或者erc20而在chain33端生成的token返还
func
(
x
*
x2ethereum
)
Exec_Eth2Chain33
_b
urn
(
payload
*
x2eTy
.
Eth2Chain33
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
x
*
x2ethereum
)
Exec_Eth2Chain33
B
urn
(
payload
*
x2eTy
.
Eth2Chain33
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
newAction
(
x
,
tx
,
int32
(
index
))
if
action
==
nil
{
return
nil
,
errors
.
New
(
"Create Action Error"
)
...
...
@@ -57,7 +57,7 @@ func (x *x2ethereum) Exec_Eth2Chain33_burn(payload *x2eTy.Eth2Chain33, tx *types
// Chain33ToEth类型的交易是Chain33侧在本端发出申请
// 在本端锁定一定数额的token,然后在ethereum端生成相同数额的token
func
(
x
*
x2ethereum
)
Exec_Chain33ToEth
_l
ock
(
payload
*
x2eTy
.
Chain33ToEth
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
func
(
x
*
x2ethereum
)
Exec_Chain33ToEth
L
ock
(
payload
*
x2eTy
.
Chain33ToEth
,
tx
*
types
.
Transaction
,
index
int
)
(
*
types
.
Receipt
,
error
)
{
action
:=
newAction
(
x
,
tx
,
int32
(
index
))
if
action
==
nil
{
return
nil
,
errors
.
New
(
"Create Action Error"
)
...
...
@@ -156,10 +156,15 @@ func (x *x2ethereum) Exec_SetConsensusThreshold(payload *x2eTy.MsgConsensusThres
func
checkTxSignBySpecificAddr
(
tx
*
types
.
Transaction
,
addrs
[]
string
)
error
{
signAddr
:=
address
.
PubKeyToAddr
(
tx
.
Signature
.
Pubkey
)
var
exist
bool
for
_
,
addr
:=
range
addrs
{
if
signAddr
==
addr
{
exist
=
true
continue
}
}
if
!
exist
{
return
x2eTy
.
ErrInvalidAdminAddress
}
...
...
plugin/dapp/x2Ethereum/executor/exec_local.go
View file @
fc3dafc5
...
...
@@ -12,7 +12,7 @@ import (
* 非关键数据,本地存储(localDB), 用于辅助查询,效率高
*/
func
(
x
*
x2ethereum
)
ExecLocal_Eth2Chain33
_l
ock
(
payload
*
x2eTy
.
Eth2Chain33
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
x
*
x2ethereum
)
ExecLocal_Eth2Chain33
L
ock
(
payload
*
x2eTy
.
Eth2Chain33
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
set
,
err
:=
x
.
execLocal
(
receiptData
)
if
err
!=
nil
{
return
set
,
err
...
...
@@ -20,7 +20,7 @@ func (x *x2ethereum) ExecLocal_Eth2Chain33_lock(payload *x2eTy.Eth2Chain33, tx *
return
x
.
addAutoRollBack
(
tx
,
set
.
KV
),
nil
}
func
(
x
*
x2ethereum
)
ExecLocal_Eth2Chain33
_b
urn
(
payload
*
x2eTy
.
Eth2Chain33
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
x
*
x2ethereum
)
ExecLocal_Eth2Chain33
B
urn
(
payload
*
x2eTy
.
Eth2Chain33
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
set
,
err
:=
x
.
execLocal
(
receiptData
)
if
err
!=
nil
{
return
set
,
err
...
...
@@ -28,7 +28,7 @@ func (x *x2ethereum) ExecLocal_Eth2Chain33_burn(payload *x2eTy.Eth2Chain33, tx *
return
x
.
addAutoRollBack
(
tx
,
set
.
KV
),
nil
}
func
(
x
*
x2ethereum
)
ExecLocal_Chain33ToEth
_b
urn
(
payload
*
x2eTy
.
Chain33ToEth
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
x
*
x2ethereum
)
ExecLocal_Chain33ToEth
B
urn
(
payload
*
x2eTy
.
Chain33ToEth
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
set
,
err
:=
x
.
execLocal
(
receiptData
)
if
err
!=
nil
{
return
set
,
err
...
...
@@ -36,7 +36,7 @@ func (x *x2ethereum) ExecLocal_Chain33ToEth_burn(payload *x2eTy.Chain33ToEth, tx
return
x
.
addAutoRollBack
(
tx
,
set
.
KV
),
nil
}
func
(
x
*
x2ethereum
)
ExecLocal_Chain33ToEth
_l
ock
(
payload
*
x2eTy
.
Chain33ToEth
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
func
(
x
*
x2ethereum
)
ExecLocal_Chain33ToEth
L
ock
(
payload
*
x2eTy
.
Chain33ToEth
,
tx
*
types
.
Transaction
,
receiptData
*
types
.
ReceiptData
,
index
int
)
(
*
types
.
LocalDBSet
,
error
)
{
set
,
err
:=
x
.
execLocal
(
receiptData
)
if
err
!=
nil
{
return
set
,
err
...
...
plugin/dapp/x2Ethereum/executor/query.go
View file @
fc3dafc5
...
...
@@ -5,7 +5,6 @@ import (
"strings"
"github.com/33cn/chain33/account"
"github.com/33cn/chain33/common/address"
"github.com/33cn/chain33/types"
x2eTy
"github.com/33cn/plugin/plugin/dapp/x2Ethereum/types"
)
...
...
@@ -166,7 +165,7 @@ func (x *x2ethereum) Query_GetRelayerBalance(in *x2eTy.QueryRelayerBalance) (typ
return
nil
,
err
}
acc
:=
accDB
.
Load
ExecAccount
(
in
.
Address
,
address
.
ExecAddress
(
x2eTy
.
X2ethereumX
)
)
acc
:=
accDB
.
Load
Account
(
in
.
Address
)
res
:=
new
(
x2eTy
.
ReceiptQueryRelayerBalanceForOneToken
)
res
.
TokenAddr
=
in
.
TokenAddr
res
.
TokenSymbol
=
in
.
TokenSymbol
...
...
@@ -191,7 +190,7 @@ func (x *x2ethereum) Query_GetRelayerBalance(in *x2eTy.QueryRelayerBalance) (typ
return
nil
,
err
}
acc
:=
accDB
.
Load
ExecAccount
(
in
.
Address
,
address
.
ExecAddress
(
x2eTy
.
X2ethereumX
)
)
acc
:=
accDB
.
Load
Account
(
in
.
Address
)
res
:=
new
(
x2eTy
.
ReceiptQueryRelayerBalanceForOneToken
)
res
.
TokenAddr
=
addr
res
.
TokenSymbol
=
in
.
TokenSymbol
...
...
plugin/dapp/x2Ethereum/executor/x2ethereumaction.go
View file @
fc3dafc5
...
...
@@ -72,13 +72,12 @@ func (a *action) procEth2Chain33_lock(ethBridgeClaim *x2eTy.Eth2Chain33) (*types
if
status
.
Text
==
x2eTy
.
EthBridgeStatus_SuccessStatusText
{
// mavl-x2ethereum-eth+tokenAddress
// 这里为了区分相同tokensymbol不同tokenAddress做了级联处理
_
,
symbol
,
_
:=
x2eTy
.
DivideDot
(
ethBridgeClaim
.
IssuerDotSymbol
)
accDB
,
err
:=
account
.
NewAccountDB
(
a
.
api
.
GetConfig
(),
x2eTy
.
X2ethereumX
,
strings
.
ToLower
(
symbol
+
ethBridgeClaim
.
TokenContractAddress
),
a
.
db
)
accDB
,
err
:=
account
.
NewAccountDB
(
a
.
api
.
GetConfig
(),
x2eTy
.
X2ethereumX
,
strings
.
ToLower
(
ethBridgeClaim
.
IssuerDotSymbol
+
ethBridgeClaim
.
TokenContractAddress
),
a
.
db
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"relay procMsgEth2Chain33,exec=%s,sym=%s"
,
x2eTy
.
X2ethereumX
,
s
ymbol
)
return
nil
,
errors
.
Wrapf
(
err
,
"relay procMsgEth2Chain33,exec=%s,sym=%s"
,
x2eTy
.
X2ethereumX
,
ethBridgeClaim
.
IssuerDotS
ymbol
)
}
r
,
err
:=
a
.
oracle
.
ProcessSuccessfulClaimForLock
(
status
.
FinalClaim
,
a
.
execaddr
,
symbol
,
accDB
)
r
,
err
:=
a
.
oracle
.
ProcessSuccessfulClaimForLock
(
status
.
FinalClaim
,
a
.
execaddr
,
accDB
)
if
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -122,10 +121,9 @@ func (a *action) procChain33ToEth_burn(msgBurn *x2eTy.Chain33ToEth) (*types.Rece
return
nil
,
err
}
_
,
symbol
,
_
:=
x2eTy
.
DivideDot
(
msgBurn
.
IssuerDotSymbol
)
accDB
,
err
:=
account
.
NewAccountDB
(
a
.
api
.
GetConfig
(),
x2eTy
.
X2ethereumX
,
strings
.
ToLower
(
symbol
+
msgBurn
.
TokenContract
),
a
.
db
)
accDB
,
err
:=
account
.
NewAccountDB
(
a
.
api
.
GetConfig
(),
x2eTy
.
X2ethereumX
,
strings
.
ToLower
(
msgBurn
.
IssuerDotSymbol
+
msgBurn
.
TokenContract
),
a
.
db
)
if
err
!=
nil
{
return
nil
,
errors
.
Wrapf
(
err
,
"relay procMsgBurn,exec=%s,sym=%s"
,
x2eTy
.
X2ethereumX
,
s
ymbol
)
return
nil
,
errors
.
Wrapf
(
err
,
"relay procMsgBurn,exec=%s,sym=%s"
,
x2eTy
.
X2ethereumX
,
msgBurn
.
IssuerDotS
ymbol
)
}
r
,
err
:=
a
.
oracle
.
ProcessBurn
(
a
.
fromaddr
,
a
.
execaddr
,
msgBurn
.
Amount
,
msgBurn
.
TokenContract
,
msgBurn
.
Decimals
,
accDB
)
if
err
!=
nil
{
...
...
@@ -162,7 +160,7 @@ func (a *action) procChain33ToEth_lock(msgLock *x2eTy.Chain33ToEth) (*types.Rece
var
accDB
*
account
.
DB
exec
,
symbol
,
_
:=
x2eTy
.
DivideDot
(
msgLock
.
IssuerDotSymbol
)
if
exec
==
"coins"
{
accDB
:
=
account
.
NewCoinsAccount
(
a
.
api
.
GetConfig
())
accDB
=
account
.
NewCoinsAccount
(
a
.
api
.
GetConfig
())
accDB
.
SetDB
(
a
.
db
)
}
else
{
accDB
,
err
=
account
.
NewAccountDB
(
a
.
api
.
GetConfig
(),
exec
,
strings
.
ToLower
(
symbol
),
a
.
db
)
...
...
@@ -233,7 +231,7 @@ func (a *action) procEth2Chain33_burn(withdrawEth *x2eTy.Eth2Chain33) (*types.Re
var
accDB
*
account
.
DB
exec
,
symbol
,
_
:=
x2eTy
.
DivideDot
(
withdrawEth
.
IssuerDotSymbol
)
if
exec
==
"coins"
{
accDB
:
=
account
.
NewCoinsAccount
(
a
.
api
.
GetConfig
())
accDB
=
account
.
NewCoinsAccount
(
a
.
api
.
GetConfig
())
accDB
.
SetDB
(
a
.
db
)
}
else
{
accDB
,
err
=
account
.
NewAccountDB
(
a
.
api
.
GetConfig
(),
exec
,
strings
.
ToLower
(
symbol
),
a
.
db
)
...
...
plugin/dapp/x2Ethereum/executor/x2ethereumdb.go
View file @
fc3dafc5
...
...
@@ -27,7 +27,7 @@ func NewOracle(db dbm.KV, consensusThreshold int64) *Oracle {
}
// 处理经过审核的关于Lock的claim
func
(
o
*
Oracle
)
ProcessSuccessfulClaimForLock
(
claim
,
execAddr
,
tokenSymbol
string
,
accDB
*
account
.
DB
)
(
*
types
.
Receipt
,
error
)
{
func
(
o
*
Oracle
)
ProcessSuccessfulClaimForLock
(
claim
,
execAddr
string
,
accDB
*
account
.
DB
)
(
*
types
.
Receipt
,
error
)
{
var
receipt
*
types
.
Receipt
oracleClaim
,
err
:=
CreateOracleClaimFromOracleString
(
claim
)
if
err
!=
nil
{
...
...
plugin/dapp/x2Ethereum/proto/x2ethereum.proto
View file @
fc3dafc5
...
...
@@ -12,17 +12,17 @@ enum EthBridgeStatus {
message
X2ethereumAction
{
oneof
value
{
Eth2Chain33
eth2Chain33
=
1
;
Eth2Chain33
withdrawEth
=
2
;
Chain33ToEth
withdrawChain33
=
3
;
Chain33ToEth
chain33ToEth
=
4
;
Eth2Chain33
eth2Chain33
Lock
=
1
;
Eth2Chain33
eth2Chain33Burn
=
2
;
Chain33ToEth
chain33ToEthBurn
=
3
;
Chain33ToEth
chain33ToEth
Lock
=
4
;
MsgValidator
addValidator
=
5
;
MsgValidator
removeValidator
=
6
;
MsgValidator
modifyPower
=
7
;
MsgConsensusThreshold
setConsensusThreshold
=
8
;
AssetsTransfer
transfer
=
9
;
AssetsTransferToExec
transferToExec
=
10
;
AssetsWithdraw
withdraw
=
11
;
AssetsWithdraw
withdraw
FromExec
=
11
;
}
int32
ty
=
12
;
}
...
...
plugin/dapp/x2Ethereum/testsh/allRelayerTest.sh
View file @
fc3dafc5
This diff is collapsed.
Click to expand it.
plugin/dapp/x2Ethereum/testsh/bridgeBankTest.sh
View file @
fc3dafc5
...
...
@@ -67,13 +67,13 @@ TestETH2Chain33Erc20() {
result
=
$(${
CLI
}
relayer ethereum mint
-m
1000
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"mint"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"1000"
result
=
$(${
CLI
}
relayer ethereum bridgeBankAddr
)
bridgeBankAddr
=
$(
cli_ret
"
${
result
}
"
"bridgeBankAddr"
".addr"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# ETH 2 chain33 lock 前先审批一下
...
...
@@ -85,10 +85,10 @@ TestETH2Chain33Erc20() {
result
=
$(${
CLI
}
relayer ethereum lock
-m
100
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33SenderAddr
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"lock"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"900"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
# ETH 2 chain33 withdraw 40
...
...
@@ -98,10 +98,10 @@ TestETH2Chain33Erc20() {
walitProphecyFinish
"
${
ethReceiverAddr2
}
"
"
${
tokenAddr
}
"
40
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"40"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"60"
# burn 60
...
...
@@ -110,10 +110,10 @@ TestETH2Chain33Erc20() {
walitProphecyFinish
"
${
ethReceiverAddr2
}
"
"
${
tokenAddr
}
"
100
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
echo
"===========
$FUNCNAME
end ==========="
...
...
@@ -132,13 +132,13 @@ TestETH2Chain33Erc20_err() {
result
=
$(${
CLI
}
relayer ethereum mint
-m
1000
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"mint"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"1000"
result
=
$(${
CLI
}
relayer ethereum bridgeBankAddr
)
bridgeBankAddr
=
$(
cli_ret
"
${
result
}
"
"bridgeBankAddr"
".addr"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# ETH 2 chain33 lock 前先审批一下
...
...
@@ -149,7 +149,7 @@ TestETH2Chain33Erc20_err() {
result
=
$(${
CLI
}
relayer ethereum lock
-m
200
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33SenderAddr
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret_err
"
${
result
}
"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# lock 1100 err
...
...
@@ -158,7 +158,7 @@ TestETH2Chain33Erc20_err() {
result
=
$(${
CLI
}
relayer ethereum lock
-m
1100
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33SenderAddr
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret_err
"
${
result
}
"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
result
=
$(${
CLI
}
relayer ethereum approve
-m
300
-k
"
${
ethReceiverAddrKey1
}
"
-t
"
${
tokenAddr
}
"
)
...
...
@@ -169,10 +169,10 @@ TestETH2Chain33Erc20_err() {
result
=
$(${
CLI
}
relayer ethereum lock
-m
300
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33SenderAddr
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"lock"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"700"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"300"
# -c 1 burn 500
...
...
@@ -181,10 +181,10 @@ TestETH2Chain33Erc20_err() {
sleep
15
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Addr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
bridgeBankAddr
}
"
-t
"
${
token
Symbol
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"300"
echo
"===========
$FUNCNAME
end ==========="
...
...
@@ -283,10 +283,10 @@ TestChain33ToEthAssets() {
echo
"===========
$FUNCNAME
begin ==========="
result
=
$(${
CLI
}
relayer unlock
-p
123456hzj
)
# token4chain33 在 以太坊 上先有 bty
result
=
$(${
CLI
}
relayer ethereum token4chain33
-s
bty
)
result
=
$(${
CLI
}
relayer ethereum token4chain33
-s
coins.
bty
)
tokenAddr
=
$(
cli_ret
"
${
result
}
"
"token4chain33"
".addr"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# -c 2 chain33 lock 100
...
...
@@ -295,26 +295,26 @@ TestChain33ToEthAssets() {
walitProphecyFinish
"
${
ethReceiverAddr1
}
"
"
${
tokenAddr
}
"
"100"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
# transfer 10
result
=
$(${
CLI
}
relayer ethereum transfer
-m
10
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"transfer"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"90"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"10"
result
=
$(${
CLI
}
relayer ethereum transfer
-m
10
-k
"
${
ethReceiverAddrKey2
}
"
-r
"
${
ethReceiverAddr3
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"transfer"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr3
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr3
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"10"
result
=
$(${
CLI
}
relayer ethereum transfer
-m
10
-k
"
${
ethReceiverAddrKey2
}
"
-r
"
${
ethReceiverAddr3
}
"
-t
"
${
tokenAddr
}
"
)
...
...
@@ -327,7 +327,7 @@ TestChain33ToEthAssets() {
result
=
$(${
CLI
}
relayer ethereum burn
-m
90
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
chain33SenderAddr
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"burn"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# brun 10 err
...
...
plugin/dapp/x2Ethereum/testsh/ebrelayerTest.sh
View file @
fc3dafc5
...
...
@@ -112,23 +112,23 @@ function ImportCBDKey() {
TestChain33ToEth
()
{
echo
"===========
$FUNCNAME
begin ==========="
# token4chain33 在 以太坊 上先有 bty
result
=
$(${
CLIA
}
relayer ethereum token4chain33
-s
bty
)
result
=
$(${
CLIA
}
relayer ethereum token4chain33
-s
coins.
bty
)
tokenAddr
=
$(
cli_ret
"
${
result
}
"
"token4chain33"
".addr"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
for
name
in
A B C D
;
do
CLI
=
"../build/ebcli_
$name
"
# -c 2 chain33 lock 100
result
=
$(${
CLI
}
relayer ethereum prophecy
-i
"
${
prophecyTx0
}
"
-m
100
-a
"
${
chain33SenderAddr
}
"
-c
2
-r
"
${
ethReceiverAddr1
}
"
-s
bty
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLI
}
relayer ethereum prophecy
-i
"
${
prophecyTx0
}
"
-m
100
-a
"
${
chain33SenderAddr
}
"
-c
2
-r
"
${
ethReceiverAddr1
}
"
-s
coins.
bty
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"prophecy -m 1"
if
[[
${
name
}
==
"A"
||
${
name
}
==
"B"
]]
;
then
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
elif
[[
${
name
}
==
"C"
||
${
name
}
==
"D"
]]
;
then
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"100"
fi
done
...
...
@@ -137,10 +137,10 @@ TestChain33ToEth() {
result
=
$(${
CLIA
}
relayer ethereum transfer
-m
10
-k
"
${
ethReceiverAddrKey1
}
"
-r
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddr
}
"
)
cli_ret
"
${
result
}
"
"transfer"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"90"
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLIA
}
relayer ethereum balance
-o
"
${
ethReceiverAddr2
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"10"
# burn 90
...
...
plugin/dapp/x2Ethereum/testsh/x2ethereumTest.sh
View file @
fc3dafc5
...
...
@@ -153,15 +153,15 @@ function InitChain33Vilators() {
function
TestChain33ToEthAssets
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
# token4chain33 在 以太坊 上先有 bty
result
=
$(${
CLI
}
relayer ethereum token4chain33
-s
bty
)
result
=
$(${
CLI
}
relayer ethereum token4chain33
-s
coins.
bty
)
tokenAddr
=
$(
cli_ret
"
${
result
}
"
"token4chain33"
".addr"
)
# tokenAddr="0x9C3D40A44a2F61Ef8D46fa8C7A731C08FB16cCEF"
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
tokenAddr
}
"
)
result
=
$(${
CLI
}
relayer ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
coins.bty
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# chain33 lock bty
hash
=
$(${
Chain33Cli
}
send x2ethereum lock
-a
5
-t
bty
-r
${
ethReceiverAddr1
}
-q
${
tokenAddr
}
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
hash
=
$(${
Chain33Cli
}
send x2ethereum lock
-a
5
-t
coins.
bty
-r
${
ethReceiverAddr1
}
-q
${
tokenAddr
}
-k
12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv
)
block_wait
"
${
Chain33Cli
}
"
$((
maturityDegree
+
2
))
check_tx
"
${
Chain33Cli
}
"
"
${
hash
}
"
...
...
plugin/dapp/x2Ethereum/types/const.go
View file @
fc3dafc5
...
...
@@ -46,10 +46,10 @@ const (
TyTransferToExecAction
TyWithdrawFromExecAction
NameEth2Chain33Action
=
"Eth2Chain33
_l
ock"
NameWithdrawEthAction
=
"Eth2Chain33
_b
urn"
NameWithdrawChain33Action
=
"Chain33ToEth
_b
urn"
NameChain33ToEthAction
=
"Chain33ToEth
_l
ock"
NameEth2Chain33Action
=
"Eth2Chain33
L
ock"
NameWithdrawEthAction
=
"Eth2Chain33
B
urn"
NameWithdrawChain33Action
=
"Chain33ToEth
B
urn"
NameChain33ToEthAction
=
"Chain33ToEth
L
ock"
NameAddValidatorAction
=
"AddValidator"
NameRemoveValidatorAction
=
"RemoveValidator"
NameModifyPowerAction
=
"ModifyPower"
...
...
plugin/dapp/x2Ethereum/types/x2ethereum.go
View file @
fc3dafc5
...
...
@@ -109,14 +109,14 @@ func (x x2ethereumType) ActionName(tx *types.Transaction) string {
// GetActionName get action name
func
(
action
*
X2EthereumAction
)
GetActionName
()
string
{
if
action
.
Ty
==
TyEth2Chain33Action
&&
action
.
GetEth2Chain33
()
!=
nil
{
return
"Eth2Chain33
_l
ock"
}
else
if
action
.
Ty
==
TyWithdrawEthAction
&&
action
.
Get
WithdrawEth
()
!=
nil
{
return
"Eth2Chain33
_b
urn"
}
else
if
action
.
Ty
==
TyWithdrawChain33Action
&&
action
.
Get
WithdrawChain33
()
!=
nil
{
return
"Chain33ToEth
_b
urn"
}
else
if
action
.
Ty
==
TyChain33ToEthAction
&&
action
.
GetChain33ToEth
()
!=
nil
{
return
"Chain33ToEth
_l
ock"
if
action
.
Ty
==
TyEth2Chain33Action
&&
action
.
GetEth2Chain33
Lock
()
!=
nil
{
return
"Eth2Chain33
L
ock"
}
else
if
action
.
Ty
==
TyWithdrawEthAction
&&
action
.
Get
Eth2Chain33Burn
()
!=
nil
{
return
"Eth2Chain33
B
urn"
}
else
if
action
.
Ty
==
TyWithdrawChain33Action
&&
action
.
Get
Chain33ToEthBurn
()
!=
nil
{
return
"Chain33ToEth
B
urn"
}
else
if
action
.
Ty
==
TyChain33ToEthAction
&&
action
.
GetChain33ToEth
Lock
()
!=
nil
{
return
"Chain33ToEth
L
ock"
}
else
if
action
.
Ty
==
TyAddValidatorAction
&&
action
.
GetAddValidator
()
!=
nil
{
return
"AddValidator"
}
else
if
action
.
Ty
==
TyRemoveValidatorAction
&&
action
.
GetRemoveValidator
()
!=
nil
{
...
...
@@ -129,7 +129,7 @@ func (action *X2EthereumAction) GetActionName() string {
return
"Transfer"
}
else
if
action
.
Ty
==
TyTransferToExecAction
&&
action
.
GetTransferToExec
()
!=
nil
{
return
"TransferToExec"
}
else
if
action
.
Ty
==
TyWithdrawFromExecAction
&&
action
.
GetWithdraw
()
!=
nil
{
}
else
if
action
.
Ty
==
TyWithdrawFromExecAction
&&
action
.
GetWithdraw
FromExec
()
!=
nil
{
return
"WithdrawFromExec"
}
return
"unknown-x2ethereum"
...
...
plugin/dapp/x2Ethereum/types/x2ethereum.pb.go
View file @
fc3dafc5
This diff is collapsed.
Click to expand it.
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