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
d5ca6be9
Commit
d5ca6be9
authored
Dec 22, 2021
by
hezhengjun
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'withdraw_opt_1217' of github.com:zhengjunhe/plugin into withdraw_opt_1217
parents
a542afe7
8730b0c5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
46 deletions
+43
-46
dockerRelayerTest.sh
plugin/dapp/cross2eth/cmd/build/dockerRelayerTest.sh
+41
-45
ethereum.go
plugin/dapp/cross2eth/ebrelayer/relayer/ethereum/ethereum.go
+2
-1
No files found.
plugin/dapp/cross2eth/cmd/build/dockerRelayerTest.sh
View file @
d5ca6be9
...
@@ -43,14 +43,14 @@ function TestETH2Chain33Assets_proxy() {
...
@@ -43,14 +43,14 @@ function TestETH2Chain33Assets_proxy() {
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
# shellcheck disable=SC2154
# shellcheck disable=SC2154
result
=
$(${
CLIA
}
ethereum lock
-m
0.002
-k
"
${
ethTestAddrKey1
}
"
-r
"
${
chain33ReceiverAddr
}
"
)
result
=
$(${
CLIA
}
ethereum lock
-m
20
-k
"
${
ethTestAddrKey1
}
"
-r
"
${
chain33ReceiverAddr
}
"
)
cli_ret
"
${
result
}
"
"lock"
cli_ret
"
${
result
}
"
"lock"
# eth 等待 2 个区块
# eth 等待 2 个区块
sleep
4
sleep
4
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethBridgeBank
}
"
)
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethBridgeBank
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"
0.002
"
cli_ret
"
${
result
}
"
"balance"
".balance"
"
20
"
# shellcheck disable=SC2086
# shellcheck disable=SC2086
sleep
"
${
maturityDegree
}
"
sleep
"
${
maturityDegree
}
"
...
@@ -58,42 +58,40 @@ function TestETH2Chain33Assets_proxy() {
...
@@ -58,42 +58,40 @@ function TestETH2Chain33Assets_proxy() {
# chain33 chain33EthBridgeTokenAddr(ETH合约中)查询 lock 金额
# chain33 chain33EthBridgeTokenAddr(ETH合约中)查询 lock 金额
# shellcheck disable=SC2154
# shellcheck disable=SC2154
result
=
$(${
Chain33Cli
}
evm query
-a
"
${
chain33EthBridgeTokenAddr
}
"
-c
"
${
chain33DeployAddr
}
"
-b
"balanceOf(
${
chain33ReceiverAddr
}
)"
)
result
=
$(${
Chain33Cli
}
evm query
-a
"
${
chain33EthBridgeTokenAddr
}
"
-c
"
${
chain33DeployAddr
}
"
-b
"balanceOf(
${
chain33ReceiverAddr
}
)"
)
# is_equal "${result}" "2000000
000000000"
is_equal
"
${
result
}
"
"2
000000000"
result
=
$(${
Chain33Cli
}
evm query
-a
"
${
chain33EthBridgeTokenAddr
}
"
-c
"
${
chain33DeployAddr
}
"
-b
"balanceOf(
${
chain33Validatorsp
}
)"
)
is_equal
"
${
result
}
"
"0"
# 原来的数额
# 原来的数额
# shellcheck disable=SC2154
# shellcheck disable=SC2154
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethTestAddr2
}
"
)
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethTestAddr2
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"1000"
# shellcheck disable=SC2154
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethValidatorAddrp
}
"
)
echo
'#5.burn ETH from Chain33 ETH(Chain33)-----> Ethereum'
echo
'#5.burn ETH from Chain33 ETH(Chain33)-----> Ethereum'
# shellcheck disable=SC2154
# shellcheck disable=SC2154
result
=
$(${
CLIA
}
chain33 withdraw
-m
0.0003
-k
"
${
chain33ReceiverAddrKey
}
"
-r
"
${
ethTestAddr2
}
"
-t
"
${
chain33EthBridgeTokenAddr
}
"
)
result
=
$(${
CLIA
}
chain33 withdraw
-m
20
-k
"
${
chain33ReceiverAddrKey
}
"
-r
"
${
ethTestAddr2
}
"
-t
"
${
chain33EthBridgeTokenAddr
}
"
)
cli_ret
"
${
result
}
"
"
burn
"
cli_ret
"
${
result
}
"
"
withdraw
"
sleep
"
${
maturityDegree
}
"
sleep
"
${
maturityDegree
}
"
echo
"check the balance on chain33"
result
=
$(${
Chain33Cli
}
evm query
-a
"
${
chain33EthBridgeTokenAddr
}
"
-c
"
${
chain33DeployAddr
}
"
-b
"balanceOf(
${
chain33ReceiverAddr
}
)"
)
# is_equal "${result}" "1700000000000000"
# 查询 ETH 这端 bridgeBank 地址 0
# 查询 ETH 这端 bridgeBank 地址 0
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethBridgeBank
}
"
)
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethBridgeBank
}
"
)
# cli_ret "${result}" "balance" ".balance" "0.0017"
cli_ret
"
${
result
}
"
"balance"
".balance"
"20"
echo
'#5.burn ETH from Chain33 ETH(Chain33)-----> Ethereum 6'
result
=
$(${
CLIA
}
chain33 burn
-m
0.0017
-k
"
${
chain33ReceiverAddrKey
}
"
-r
"
${
ethTestAddr2
}
"
-t
"
${
chain33EthBridgeTokenAddr
}
"
)
cli_ret
"
${
result
}
"
"burn"
sleep
"
${
maturityDegree
}
"
echo
"check the balance on chain33"
echo
"check the balance on chain33"
result
=
$(${
Chain33Cli
}
evm query
-a
"
${
chain33EthBridgeTokenAddr
}
"
-c
"
${
chain33DeployAddr
}
"
-b
"balanceOf(
${
chain33ReceiverAddr
}
)"
)
result
=
$(${
Chain33Cli
}
evm query
-a
"
${
chain33EthBridgeTokenAddr
}
"
-c
"
${
chain33DeployAddr
}
"
-b
"balanceOf(
${
chain33ReceiverAddr
}
)"
)
#
is_equal "${result}" "0"
is_equal
"
${
result
}
"
"0"
# 查询 ETH 这端 bridgeBank 地址 0
result
=
$(${
Chain33Cli
}
evm query
-a
"
${
chain33EthBridgeTokenAddr
}
"
-c
"
${
chain33DeployAddr
}
"
-b
"balanceOf(
${
chain33Validatorsp
}
)"
)
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethBridgeBank
}
"
)
is_equal
"
${
result
}
"
"2000000000"
# cli_ret "${result}" "balance" ".balance" "0"
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethTestAddr2
}
"
)
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethTestAddr2
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"1019"
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethValidatorAddrp
}
"
)
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
}
...
@@ -101,6 +99,13 @@ function TestETH2Chain33Assets_proxy() {
...
@@ -101,6 +99,13 @@ function TestETH2Chain33Assets_proxy() {
function
TestETH2Chain33USDT_proxy
()
{
function
TestETH2Chain33USDT_proxy
()
{
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
begin ===========
${
NOC
}
"
echo
-e
"
${
GRE
}
=========== eth to chain33 在以太坊上锁定 USDT 资产,然后在 chain33 上 burn ===========
${
NOC
}
"
echo
-e
"
${
GRE
}
=========== eth to chain33 在以太坊上锁定 USDT 资产,然后在 chain33 上 burn ===========
${
NOC
}
"
# shellcheck disable=SC2154
${
CLIA
}
ethereum token token_transfer
-k
"
${
ethTestAddrKey1
}
"
-m
20
-r
"
${
ethValidatorAddrp
}
"
-t
"
${
ethereumUSDTERC20TokenAddr
}
"
sleep
2
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethValidatorAddrp
}
"
-t
"
${
ethereumUSDTERC20TokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"20"
# 查询 ETH 这端 bridgeBank 地址原来是 0
# 查询 ETH 这端 bridgeBank 地址原来是 0
# shellcheck disable=SC2154
# shellcheck disable=SC2154
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethBridgeBank
}
"
-t
"
${
ethereumUSDTERC20TokenAddr
}
"
)
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethBridgeBank
}
"
-t
"
${
ethereumUSDTERC20TokenAddr
}
"
)
...
@@ -125,47 +130,38 @@ function TestETH2Chain33USDT_proxy() {
...
@@ -125,47 +130,38 @@ function TestETH2Chain33USDT_proxy() {
# 结果是 12 * le8
# 结果是 12 * le8
is_equal
"
${
result
}
"
"1200000000"
is_equal
"
${
result
}
"
"1200000000"
result
=
$(${
Chain33Cli
}
evm query
-a
"
${
chain33USDTBridgeTokenAddr
}
"
-c
"
${
chain33TestAddr1
}
"
-b
"balanceOf(
${
chain33Validatorsp
}
)"
)
is_equal
"
${
result
}
"
"0"
# 原来的数额 0
# 原来的数额 0
# shellcheck disable=SC2154
# shellcheck disable=SC2154
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
ethereumUSDTERC20TokenAddr
}
"
)
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
ethereumUSDTERC20TokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
echo
'#5.burn YCC from Chain33 YCC(Chain33)-----> Ethereum'
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethValidatorAddrp
}
"
-t
"
${
ethereumUSDTERC20TokenAddr
}
"
)
result
=
$(${
CLIA
}
chain33 burn
-m
5
-k
"
${
chain33ReceiverAddrKey
}
"
-r
"
${
ethReceiverAddr1
}
"
-t
"
${
chain33USDTBridgeTokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"20"
cli_ret
"
${
result
}
"
"burn"
sleep
"
${
maturityDegree
}
"
echo
"check the balance on chain33"
result
=
$(${
Chain33Cli
}
evm query
-a
"
${
chain33USDTBridgeTokenAddr
}
"
-c
"
${
chain33TestAddr1
}
"
-b
"balanceOf(
${
chain33ReceiverAddr
}
)"
)
# 结果是 12-5 * le8
is_equal
"
${
result
}
"
"700000000"
# 查询 ETH 这端 bridgeBank 地址 7
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethBridgeBank
}
"
-t
"
${
ethereumUSDTERC20TokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"7"
# 更新后的金额 5
echo
'#5.burn YCC from Chain33 YCC(Chain33)-----> Ethereum'
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
ethereumUSDTERC20TokenAddr
}
"
)
result
=
$(${
CLIA
}
chain33 withdraw
-m
12
-k
"
${
chain33ReceiverAddrKey
}
"
-r
"
${
ethReceiverAddr1
}
"
-t
"
${
chain33USDTBridgeTokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"5"
cli_ret
"
${
result
}
"
"withdraw"
echo
'#5.burn USDT from Chain33 USDT(Chain33)-----> Ethereum'
result
=
$(${
CLIA
}
chain33 burn
-m
7
-k
"
${
chain33ReceiverAddrKey
}
"
-r
"
${
ethReceiverAddr1
}
"
-t
"
${
chain33USDTBridgeTokenAddr
}
"
)
cli_ret
"
${
result
}
"
"burn"
sleep
"
${
maturityDegree
}
"
sleep
"
${
maturityDegree
}
"
echo
"check the balance on chain33"
echo
"check the balance on chain33"
result
=
$(${
Chain33Cli
}
evm query
-a
"
${
chain33USDTBridgeTokenAddr
}
"
-c
"
${
chain33TestAddr1
}
"
-b
"balanceOf(
${
chain33ReceiverAddr
}
)"
)
result
=
$(${
Chain33Cli
}
evm query
-a
"
${
chain33USDTBridgeTokenAddr
}
"
-c
"
${
chain33TestAddr1
}
"
-b
"balanceOf(
${
chain33ReceiverAddr
}
)"
)
is_equal
"
${
result
}
"
"0"
is_equal
"
${
result
}
"
"0"
result
=
$(${
Chain33Cli
}
evm query
-a
"
${
chain33USDTBridgeTokenAddr
}
"
-c
"
${
chain33TestAddr1
}
"
-b
"balanceOf(
${
chain33Validatorsp
}
)"
)
is_equal
"
${
result
}
"
"1200000000"
# 查询 ETH 这端 bridgeBank 地址 0
# 查询 ETH 这端 bridgeBank 地址 0
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethBridgeBank
}
"
-t
"
${
ethereumUSDTERC20TokenAddr
}
"
)
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethBridgeBank
}
"
-t
"
${
ethereumUSDTERC20TokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"0"
cli_ret
"
${
result
}
"
"balance"
".balance"
"12"
# 更新后的金额 12
# 更新后的金额 12
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
ethereumUSDTERC20TokenAddr
}
"
)
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethReceiverAddr1
}
"
-t
"
${
ethereumUSDTERC20TokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"12"
cli_ret
"
${
result
}
"
"balance"
".balance"
"11"
result
=
$(${
CLIA
}
ethereum balance
-o
"
${
ethValidatorAddrp
}
"
-t
"
${
ethereumUSDTERC20TokenAddr
}
"
)
cli_ret
"
${
result
}
"
"balance"
".balance"
"8"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
}
...
@@ -175,7 +171,7 @@ function TestRelayerProxy() {
...
@@ -175,7 +171,7 @@ function TestRelayerProxy() {
setWithdraw
setWithdraw
TestETH2Chain33Assets_proxy
TestETH2Chain33Assets_proxy
#
TestETH2Chain33USDT_proxy
TestETH2Chain33USDT_proxy
}
}
function
AllRelayerMainTest
()
{
function
AllRelayerMainTest
()
{
...
...
plugin/dapp/cross2eth/ebrelayer/relayer/ethereum/ethereum.go
View file @
d5ca6be9
...
@@ -644,7 +644,7 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33
...
@@ -644,7 +644,7 @@ func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33
return
return
}
}
//用签名的账户地址作为pack参数,toAddr作为合约地址
//用签名的账户地址作为pack参数,toAddr作为合约地址
balanceOfData
,
err
=
ethRelayer
.
packBalanceOfData
(
chain33Msg
.
EthereumReceiv
er
)
balanceOfData
,
err
=
ethRelayer
.
packBalanceOfData
(
ethRelayer
.
ethSend
er
)
if
err
!=
nil
{
if
err
!=
nil
{
relayerLog
.
Error
(
"handleLogWithdraw"
,
"callEvmBalanceData err"
,
err
)
relayerLog
.
Error
(
"handleLogWithdraw"
,
"callEvmBalanceData err"
,
err
)
err
=
errors
.
New
(
"ErrPackBalanceOfData"
)
err
=
errors
.
New
(
"ErrPackBalanceOfData"
)
...
@@ -730,6 +730,7 @@ func (ethRelayer *Relayer4Ethereum) checkBalanceEnough(addr common.Address, amou
...
@@ -730,6 +730,7 @@ func (ethRelayer *Relayer4Ethereum) checkBalanceEnough(addr common.Address, amou
if
balance
.
Cmp
(
amount
)
>
0
{
if
balance
.
Cmp
(
amount
)
>
0
{
return
true
,
nil
return
true
,
nil
}
}
relayerLog
.
Error
(
"Insufficient balance"
,
"balance"
,
balance
,
"amount"
,
amount
)
return
false
,
errors
.
New
(
"Insufficient balance"
)
return
false
,
errors
.
New
(
"Insufficient balance"
)
}
}
...
...
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