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
b375d231
Unverified
Commit
b375d231
authored
Aug 14, 2020
by
33cn
Committed by
GitHub
Aug 14, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #900 from YingQm/fix-x2eth-test
Fix x2eth test
parents
d484af83
39056dfa
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
261 additions
and
55 deletions
+261
-55
dapp-test-rpc.sh
build/dapp-test-rpc.sh
+3
-3
docker-compose-down.sh
build/docker-compose-down.sh
+0
-7
docker-compose-pre.sh
build/docker-compose-pre.sh
+1
-3
docker-compose.sh
build/docker-compose.sh
+6
-6
Dockerfile-x2ethrelay
plugin/dapp/x2ethereum/cmd/build/Dockerfile-x2ethrelay
+10
-0
allRelayerTest.sh
plugin/dapp/x2ethereum/cmd/build/allRelayerTest.sh
+0
-0
docker-compose-ebrelayer.yml
...in/dapp/x2ethereum/cmd/build/docker-compose-ebrelayer.yml
+11
-0
docker-compose-x2Ethereum.yml
...n/dapp/x2ethereum/cmd/build/docker-compose-x2Ethereum.yml
+0
-7
docker-compose-x2ethereum.yml
...n/dapp/x2ethereum/cmd/build/docker-compose-x2ethereum.yml
+27
-0
perf_test.sh
plugin/dapp/x2ethereum/cmd/build/perf_test.sh
+0
-0
publicTest.sh
plugin/dapp/x2ethereum/cmd/build/publicTest.sh
+174
-21
test-rpc.sh
plugin/dapp/x2ethereum/cmd/test/test-rpc.sh
+0
-0
commands.go
plugin/dapp/x2ethereum/commands/commands.go
+0
-1
main.go
plugin/dapp/x2ethereum/ebcli/main.go
+26
-6
relayer.toml
plugin/dapp/x2ethereum/ebrelayer/relayer.toml
+1
-1
config.pb.go
plugin/dapp/x2ethereum/ebrelayer/types/config.pb.go
+1
-0
config.proto
plugin/dapp/x2ethereum/ebrelayer/types/protos/config.proto
+1
-0
No files found.
build/dapp-test-rpc.sh
View file @
b375d231
...
@@ -6,7 +6,7 @@ DAPP_TEST_COMMON=dapp-test-common.sh
...
@@ -6,7 +6,7 @@ DAPP_TEST_COMMON=dapp-test-common.sh
function
dapp_test_rpc
()
{
function
dapp_test_rpc
()
{
local
ip
=
$1
local
ip
=
$1
local
node3
=
$2
local
dockerNamePrefix
=
$2
echo
"============ # dapp rpc test begin ============="
echo
"============ # dapp rpc test begin ============="
if
[
-d
dapptest
]
;
then
if
[
-d
dapptest
]
;
then
cp
"
$DAPP_TEST_COMMON
"
dapptest/
cp
"
$DAPP_TEST_COMMON
"
dapptest/
...
@@ -15,10 +15,10 @@ function dapp_test_rpc() {
...
@@ -15,10 +15,10 @@ function dapp_test_rpc() {
rm
-f
"jobsTicket.log"
rm
-f
"jobsTicket.log"
rm
-rf
"outdir"
rm
-rf
"outdir"
dapps
=
$(
find
.
-maxdepth
1
-type
d
!
-name
dapptest
!
-name
ticket
!
-name
x2ethereum
!
-name
.
|
sed
's/^\.\///'
|
sort
)
dapps
=
$(
find
.
-maxdepth
1
-type
d
!
-name
dapptest
!
-name
ticket
!
-name
.
|
sed
's/^\.\///'
|
sort
)
echo
"dapps list:
$dapps
"
echo
"dapps list:
$dapps
"
set
+e
set
+e
parallel
-k
--jobs
40
--results
outdir
--joblog
./jobs.log ./
{}
/
"
${
RPC_TESTFILE
}
"
"
$ip
"
"
$
node3
"
:::
"
$dapps
"
parallel
-k
--jobs
40
--results
outdir
--joblog
./jobs.log ./
{}
/
"
${
RPC_TESTFILE
}
"
"
$ip
"
"
$
dockerNamePrefix
"
:::
"
$dapps
"
local
ret
=
$?
local
ret
=
$?
parallel
-k
--jobs
1
--results
outdir
--joblog
./jobsTicket.log ./
{}
/
"
${
RPC_TESTFILE
}
"
"
$ip
"
:::
"ticket"
parallel
-k
--jobs
1
--results
outdir
--joblog
./jobsTicket.log ./
{}
/
"
${
RPC_TESTFILE
}
"
"
$ip
"
:::
"ticket"
local
retTicket
=
$?
local
retTicket
=
$?
...
...
build/docker-compose-down.sh
View file @
b375d231
...
@@ -41,13 +41,6 @@ function down() {
...
@@ -41,13 +41,6 @@ function down() {
echo
"=========== # docker-compose down ============="
echo
"=========== # docker-compose down ============="
docker-compose down
--rmi
local
docker-compose down
--rmi
local
fi
fi
# shellcheck disable=SC2155
local
isGanacheExit
=
$(
docker ps |
grep
ganachetest
)
if
[[
${
isGanacheExit
}
!=
""
]]
;
then
docker stop ganachetest
docker
rm
ganachetest
fi
}
}
# run script
# run script
...
...
build/docker-compose-pre.sh
View file @
b375d231
...
@@ -67,7 +67,6 @@ function run_dapp() {
...
@@ -67,7 +67,6 @@ function run_dapp() {
fi
fi
cd
..
cd
..
echo
"============ run dapp=
$app
end ================="
echo
"============ run dapp=
$app
end ================="
}
}
function
run_single_app
()
{
function
run_single_app
()
{
...
@@ -101,7 +100,7 @@ function main() {
...
@@ -101,7 +100,7 @@ function main() {
echo
"============ run main end ================="
echo
"============ run main end ================="
find
.
-maxdepth
1
-type
d
-name
"*-ci"
-exec
rm
-rf
{}
\;
find
.
-maxdepth
1
-type
d
-name
"*-ci"
-exec
rm
-rf
{}
\;
dir
=
$(
find
.
-maxdepth
1
-type
d
!
-name
system
!
-name
x2ethereum
!
-name
.
|
sed
's/^\.\///'
)
dir
=
$(
find
.
-maxdepth
1
-type
d
!
-name
system
!
-name
.
|
sed
's/^\.\///'
)
for
app
in
$dir
;
do
for
app
in
$dir
;
do
run_single_app
"
${
app
}
"
"
$TESTCASEFILE
"
"down"
run_single_app
"
${
app
}
"
"
$TESTCASEFILE
"
"down"
done
done
...
@@ -145,7 +144,6 @@ function main() {
...
@@ -145,7 +144,6 @@ function main() {
elif
[
"
${
OP
}
"
==
"modify"
]
;
then
elif
[
"
${
OP
}
"
==
"modify"
]
;
then
sed
-i
$sedfix
'/^useGithub=.*/a version=1'
chain33.toml
sed
-i
$sedfix
'/^useGithub=.*/a version=1'
chain33.toml
fi
fi
}
}
# run script
# run script
...
...
build/docker-compose.sh
View file @
b375d231
...
@@ -15,6 +15,9 @@ set -o pipefail
...
@@ -15,6 +15,9 @@ set -o pipefail
PWD
=
$(
cd
"
$(
dirname
"
$0
"
)
"
&&
pwd
)
PWD
=
$(
cd
"
$(
dirname
"
$0
"
)
"
&&
pwd
)
export
PATH
=
"
$PWD
:
$PATH
"
export
PATH
=
"
$PWD
:
$PATH
"
dockerNamePrefix
=
"
${
1
}
"
echo
"dockerNamePrefix :
${
dockerNamePrefix
}
"
NODE3
=
"
${
1
}
_chain33_1"
NODE3
=
"
${
1
}
_chain33_1"
CLI
=
"docker exec
${
NODE3
}
/root/chain33-cli"
CLI
=
"docker exec
${
NODE3
}
/root/chain33-cli"
...
@@ -58,9 +61,7 @@ if [ -n "${DAPP}" ]; then
...
@@ -58,9 +61,7 @@ if [ -n "${DAPP}" ]; then
DAPP_COMPOSE_FILE
=
"docker-compose-
${
DAPP
}
.yml"
DAPP_COMPOSE_FILE
=
"docker-compose-
${
DAPP
}
.yml"
if
[
-e
"
$DAPP_COMPOSE_FILE
"
]
;
then
if
[
-e
"
$DAPP_COMPOSE_FILE
"
]
;
then
export
COMPOSE_FILE
=
"docker-compose.yml:
${
DAPP_COMPOSE_FILE
}
"
export
COMPOSE_FILE
=
"docker-compose.yml:
${
DAPP_COMPOSE_FILE
}
"
fi
fi
fi
fi
if
[
-z
"
$DAPP
"
]
||
[
"
$DAPP
"
==
"paracross"
]
;
then
if
[
-z
"
$DAPP
"
]
||
[
"
$DAPP
"
==
"paracross"
]
;
then
...
@@ -462,29 +463,28 @@ function dapp_test_address() {
...
@@ -462,29 +463,28 @@ function dapp_test_address() {
function
base_config
()
{
function
base_config
()
{
# sync
# sync
transfer
"
${
CLI
}
"
transfer
"
${
CLI
}
"
# transfer "${CLI4}"
}
}
function
rpc_test
()
{
function
rpc_test
()
{
if
[
"
$DAPP
"
==
""
]
;
then
if
[
"
$DAPP
"
==
""
]
;
then
system_test_rpc
"http://
${
1
}
:8801"
system_test_rpc
"http://
${
1
}
:8801"
dapp_test_address
"
${
CLI
}
"
dapp_test_address
"
${
CLI
}
"
dapp_test_rpc
"http://
${
1
}
:8801"
"
${
NODE3
}
"
dapp_test_rpc
"http://
${
1
}
:8801"
"
${
dockerNamePrefix
}
"
fi
fi
if
[
"
$DAPP
"
==
"paracross"
]
;
then
if
[
"
$DAPP
"
==
"paracross"
]
;
then
system_test_rpc
"http://
${
1
}
:8901"
system_test_rpc
"http://
${
1
}
:8901"
dapp_test_address
"
${
CLI
}
"
dapp_test_address
"
${
CLI
}
"
dapp_test_rpc
"http://
${
1
}
:8901"
dapp_test_rpc
"http://
${
1
}
:8901"
fi
fi
}
}
function
dapp_run
()
{
function
dapp_run
()
{
if
[
-e
"
$DAPP_TEST_FILE
"
]
;
then
if
[
-e
"
$DAPP_TEST_FILE
"
]
;
then
${
DAPP
}
"
${
CLI
}
"
"
${
1
}
"
"
${
2
}
"
${
DAPP
}
"
${
CLI
}
"
"
${
1
}
"
"
${
2
}
"
fi
fi
}
}
function
main
()
{
function
main
()
{
echo
"==============================DAPP=
$DAPP
main begin========================================================"
echo
"==============================DAPP=
$DAPP
main begin========================================================"
### init para ####
### init para ####
...
...
plugin/dapp/x2ethereum/cmd/build/Dockerfile-x2ethrelay
0 → 100644
View file @
b375d231
FROM ubuntu:16.04
WORKDIR /root
COPY relayer.toml relayer.toml
COPY ebrelayer ebrelayer
COPY ebcli_A ebcli_A
EXPOSE 20000
CMD ["/root/ebrelayer"]
plugin/dapp/x2ethereum/cmd/build/allRelayerTest.sh
View file @
b375d231
This diff is collapsed.
Click to expand it.
plugin/dapp/x2ethereum/cmd/build/docker-compose-ebrelayer.yml
0 → 100644
View file @
b375d231
version
:
'
3'
services
:
ebrelayera
:
build
:
context
:
.
dockerfile
:
Dockerfile-x2ethrelay
ports
:
-
"
20000:20000"
plugin/dapp/x2ethereum/cmd/build/docker-compose-x2Ethereum.yml
deleted
100644 → 0
View file @
d484af83
version
:
'
3'
#services:
# ganachetest:
# build:
# context: .
plugin/dapp/x2ethereum/cmd/build/docker-compose-x2ethereum.yml
0 → 100644
View file @
b375d231
version
:
'
3'
services
:
ganachetest
:
entrypoint
:
[
"
node"
,
"
/app/ganache-core.docker.cli.js"
,
"
-a"
,
"
10"
,
"
-b"
,
"
2"
,
"
--debug"
,
"
-m"
,
"
coast
bar
giraffe
art
venue
decide
symbol
law
visual
crater
vital
fold"
]
image
:
trufflesuite/ganache-cli:latest
ebrelayera
:
build
:
context
:
.
dockerfile
:
Dockerfile-x2ethrelay
ebrelayerb
:
build
:
context
:
.
dockerfile
:
Dockerfile-x2ethrelay
ebrelayerc
:
build
:
context
:
.
dockerfile
:
Dockerfile-x2ethrelay
ebrelayerd
:
build
:
context
:
.
dockerfile
:
Dockerfile-x2ethrelay
\ No newline at end of file
plugin/dapp/x2ethereum/cmd/build/perf_test.sh
View file @
b375d231
This diff is collapsed.
Click to expand it.
plugin/dapp/x2ethereum/cmd/build/publicTest.sh
View file @
b375d231
...
@@ -12,6 +12,8 @@ RED='\033[1;31m'
...
@@ -12,6 +12,8 @@ RED='\033[1;31m'
GRE
=
'\033[1;32m'
GRE
=
'\033[1;32m'
NOC
=
'\033[0m'
NOC
=
'\033[0m'
inetAddr
=
""
# 出错退出前拷贝日志文件
# 出错退出前拷贝日志文件
function
exit_cp_file
()
{
function
exit_cp_file
()
{
# shellcheck disable=SC2116
# shellcheck disable=SC2116
...
@@ -23,14 +25,35 @@ function exit_cp_file() {
...
@@ -23,14 +25,35 @@ function exit_cp_file() {
mkdir
-p
${
dirName
}
mkdir
-p
${
dirName
}
fi
fi
for
name
in
A B C D
;
do
for
name
in
a b c d
;
do
cp
"./
$name
/ebrelayer.log"
"
$dirName
/ebrelayer
$name
.log"
# shellcheck disable=SC2154
docker
cp
"
${
dockerNamePrefix
}
_ebrelayer
${
name
}
_1"
:/root/logs/x2Ethereum_relayer.log
"
${
dirName
}
/ebrelayer
${
name
}
.log"
done
done
docker
cp
"
${
NODE3
}
"
:/root/logs/chain33.log
"
$dirName
/chain33.log"
docker
cp
"
${
dockerNamePrefix
}
_chain33_1"
:/root/logs/chain33.log
"
${
dirName
}
/chain33.log"
exit
1
exit
1
}
}
function
copyErrLogs
()
{
if
[
-n
"
$CASE_ERR
"
]
;
then
# /var/lib/jenkins
# shellcheck disable=SC2116
dirNameFa
=
$(
echo
~
)
dirName
=
"
$dirNameFa
/x2ethereumlogs"
if
[
!
-d
"
${
dirName
}
"
]
;
then
# shellcheck disable=SC2086
mkdir
-p
${
dirName
}
fi
for
name
in
a b c d
;
do
# shellcheck disable=SC2154
docker
cp
"
${
dockerNamePrefix
}
_ebrelayer
${
name
}
_rpc_1"
:/root/logs/x2Ethereum_relayer.log
"
${
dirName
}
/ebrelayer
${
name
}
_rpc.log"
done
docker
cp
"
${
dockerNamePrefix
}
_chain33_1"
:/root/logs/chain33.log
"
${
dirName
}
/chain33_rpc.log"
fi
}
function
kill_all_ebrelayer
()
{
function
kill_all_ebrelayer
()
{
for
name
in
A B C D
;
do
for
name
in
A B C D
;
do
local
ebrelayer
=
"./../build/
$name
/ebrelayer"
local
ebrelayer
=
"./../build/
$name
/ebrelayer"
...
@@ -328,34 +351,45 @@ function check_addr() {
...
@@ -328,34 +351,45 @@ function check_addr() {
fi
fi
}
}
function
get_inet_addr
()
{
inetAddr
=
$(
ifconfig wlp2s0 |
grep
"inet "
|
awk
'{ print $2}'
|
awk
-F
:
'{print $2}'
)
if
[[
${
inetAddr
}
==
""
]]
;
then
inetAddr
=
$(
ifconfig wlp2s0 |
grep
"inet "
|
awk
'{ print $2}'
)
if
[[
${
inetAddr
}
==
""
]]
;
then
inetAddr
=
$(
ifconfig eth0 |
grep
"inet "
|
awk
'{ print $2}'
|
awk
-F
:
'{print $2}'
)
if
[[
${
inetAddr
}
==
""
]]
;
then
inetAddr
=
$(
ifconfig eth0 |
grep
"inet "
|
awk
'{ print $2}'
)
if
[[
${
inetAddr
}
==
""
]]
;
then
ip addr show eth0
inetAddr
=
$(
ip addr show eth0 |
grep
"inet "
|
awk
'{ print $2}'
|
head
-c-4
)
fi
fi
fi
fi
echo
"
${
inetAddr
}
"
}
# $1 dockerName
function
get_docker_addr
()
{
local
dockerAddr
=
$(
docker inspect
"
${
1
}
"
| jq
".[].NetworkSettings.Networks"
|
grep
"IPAddress"
|
awk
'{ print $2}'
|
sed
's/\"//g'
|
sed
's/,//g'
)
echo
"
${
dockerAddr
}
"
}
# 更新配置文件 $1 为 BridgeRegistry 合约地址; $2 等待区块 默认10; $3 relayer.toml 地址
# 更新配置文件 $1 为 BridgeRegistry 合约地址; $2 等待区块 默认10; $3 relayer.toml 地址
function
updata_relayer_toml
()
{
function
updata_relayer_toml
()
{
local
BridgeRegistry
=
${
1
}
local
BridgeRegistry
=
${
1
}
local
maturityDegree
=
${
2
}
local
maturityDegree
=
${
2
}
local
file
=
${
3
}
local
file
=
${
3
}
# local chain33Host=$(docker inspect "${NODE3}" | jq ".[].NetworkSettings.Networks.${PROJ}_default.IPAddress" | sed 's/\"//g')
local
chain33Host
=
$(
get_docker_addr
"
${
dockerNamePrefix
}
_chain33_1"
)
local
chain33Host
=
$(
docker inspect
"
${
NODE3
}
"
| jq
".[].NetworkSettings.Networks"
|
grep
"IPAddress"
|
awk
'{ print $2}'
|
sed
's/\"//g'
|
sed
's/,//g'
)
if
[[
${
chain33Host
}
==
""
]]
;
then
if
[[
${
chain33Host
}
==
""
]]
;
then
echo
-e
"
${
RED
}
chain33Host is empty
${
NOC
}
"
echo
-e
"
${
RED
}
chain33Host is empty
${
NOC
}
"
exit_cp_file
exit_cp_file
fi
fi
local
pushHost
=
$(
ifconfig wlp2s0 |
grep
"inet "
|
awk
'{ print $2}'
|
awk
-F
:
'{print $2}'
)
get_inet_addr
if
[[
${
pushHost
}
==
""
]]
;
then
local
pushHost
=
"
${
inetAddr
}
"
pushHost
=
$(
ifconfig wlp2s0 |
grep
"inet "
|
awk
'{ print $2}'
)
if
[[
${
pushHost
}
==
""
]]
;
then
pushHost
=
$(
ifconfig eth0 |
grep
"inet "
|
awk
'{ print $2}'
|
awk
-F
:
'{print $2}'
)
if
[[
${
pushHost
}
==
""
]]
;
then
pushHost
=
$(
ifconfig eth0 |
grep
"inet "
|
awk
'{ print $2}'
)
if
[[
${
pushHost
}
==
""
]]
;
then
ip addr show eth0
pushHost
=
$(
ip addr show eth0 |
grep
"inet "
|
awk
'{ print $2}'
|
head
-c-4
)
fi
fi
fi
fi
if
[[
${
pushHost
}
==
""
]]
;
then
if
[[
${
pushHost
}
==
""
]]
;
then
echo
-e
"
${
RED
}
pushHost is empty
${
NOC
}
"
echo
-e
"
${
RED
}
pushHost is empty
${
NOC
}
"
exit_cp_file
exit_cp_file
...
@@ -368,6 +402,9 @@ function updata_relayer_toml() {
...
@@ -368,6 +402,9 @@ function updata_relayer_toml() {
line
=
$(
delete_line_show
"
${
file
}
"
"pushHost"
)
line
=
$(
delete_line_show
"
${
file
}
"
"pushHost"
)
sed
-i
''
"
${
line
}
"
' a pushHost="http://'
"
${
pushHost
}
"
':20000"'
"
${
file
}
"
sed
-i
''
"
${
line
}
"
' a pushHost="http://'
"
${
pushHost
}
"
':20000"'
"
${
file
}
"
# line=$(delete_line_show "${file}" "pushBind")
# sed -i ''"${line}"' a pushBind="'"${pushHost}"':20000"' "${file}"
line
=
$(
delete_line_show
"
${
file
}
"
"BridgeRegistry"
)
line
=
$(
delete_line_show
"
${
file
}
"
"BridgeRegistry"
)
sed
-i
''
"
${
line
}
"
' a BridgeRegistry="'
"
${
BridgeRegistry
}
"
'"'
"
${
file
}
"
sed
-i
''
"
${
line
}
"
' a BridgeRegistry="'
"
${
BridgeRegistry
}
"
'"'
"
${
file
}
"
...
@@ -401,6 +438,121 @@ function updata_relayer_toml_ropston() {
...
@@ -401,6 +438,121 @@ function updata_relayer_toml_ropston() {
sed
-i
's/maturityDegree=10/'
maturityDegree
=
"
${
maturityDegree
}
"
'/g'
"
${
file
}
"
sed
-i
's/maturityDegree=10/'
maturityDegree
=
"
${
maturityDegree
}
"
'/g'
"
${
file
}
"
}
}
# $1 portRelayer
function
updata_docker_relayer_toml
()
{
local
port
=
$1
local
portRelayer
=
$1
if
[
"
${
portRelayer
}
"
!=
"20000"
]
;
then
sed
-i
's/20000/'
"
${
portRelayer
}
"
'/g'
"./relayer.toml"
sed
-i
's/20000/'
"
${
portRelayer
}
"
'/g'
"./Dockerfile-x2ethrelay"
fi
for
name
in
b c d
;
do
local
file
=
"./relayer
$name
.toml"
cp
'./relayer.toml'
"
${
file
}
"
# 删除配置文件中不需要的字段
for
deleteName
in
"deployerPrivateKey"
"operatorAddr"
"validatorsAddr"
"initPowers"
"deployerPrivateKey"
"deploy"
;
do
delete_line
"
${
file
}
"
"
${
deleteName
}
"
done
port
=
$((
port
+
1
))
sed
-i
's/'
"
${
portRelayer
}
"
'/'
${
port
}
'/g'
"
${
file
}
"
sed
-i
's/x2ethereum/x2ethereum'
${
name
}
'/g'
"
${
file
}
"
local
dockerfile
=
"./Dockerfile-x2ethrelay
$name
"
cp
"./Dockerfile-x2ethrelay"
"
${
dockerfile
}
"
# shellcheck disable=SC2155
local
line
=
$(
delete_line_show
"
${
dockerfile
}
"
"COPY relayer.toml relayer.toml"
)
sed
-i
''
"
${
line
}
"
' a COPY relayer'
$name
'.toml relayer.toml'
"
${
dockerfile
}
"
sed
-i
's/'
"
${
portRelayer
}
"
'/'
"
${
port
}
"
'/g'
"
${
dockerfile
}
"
local
dockeryml
=
"./docker-compose-ebrelayer
$name
.yml"
cp
"./docker-compose-ebrelayer.yml"
"
${
dockeryml
}
"
line
=
$(
delete_line_show
"
${
dockeryml
}
"
"ebrelayera"
)
sed
-i
''
"
${
line
}
"
' a \ \ ebrelayer'
$name
':'
"
${
dockeryml
}
"
line
=
$(
delete_line_show
"
${
dockeryml
}
"
"dockerfile: Dockerfile-x2ethrelay"
)
sed
-i
''
"
${
line
}
"
' a \ \ \ \ \ \ dockerfile: Dockerfile-x2ethrelay'
$name
''
"
${
dockeryml
}
"
sed
-i
's/'
"
${
portRelayer
}
"
'/'
${
port
}
'/g'
"
${
dockeryml
}
"
done
}
# 更新配置文件 $1 为 BridgeRegistry 合约地址; $2 等待区块 默认10; $3 MAIN_HTTP; $4 relayer.toml 地址
function
updata_relayer_toml_rpc
()
{
local
BridgeRegistry
=
${
1
}
local
maturityDegree
=
${
2
}
local
MAIN_HTTP
=
${
3
}
local
file
=
${
4
}
get_inet_addr
local
pushHost
=
"
${
inetAddr
}
"
if
[[
${
pushHost
}
==
""
]]
;
then
echo
-e
"
${
RED
}
pushHost is empty
${
NOC
}
"
fi
# shellcheck disable=SC2155
local
line
=
$(
delete_line_show
"
${
file
}
"
"chain33Host"
)
# 在第 line 行后面 新增合约地址
sed
-i
''
"
${
line
}
"
' a chain33Host="'
"
${
MAIN_HTTP
}
"
'"'
"
${
file
}
"
line
=
$(
delete_line_show
"
${
file
}
"
"pushHost"
)
sed
-i
''
"
${
line
}
"
' a pushHost="http://'
"
${
pushHost
}
"
':20000"'
"
${
file
}
"
line
=
$(
delete_line_show
"
${
file
}
"
"BridgeRegistry"
)
sed
-i
''
"
${
line
}
"
' a BridgeRegistry="'
"
${
BridgeRegistry
}
"
'"'
"
${
file
}
"
sed
-i
's/EthMaturityDegree=10/'
EthMaturityDegree
=
"
${
maturityDegree
}
"
'/g'
"
${
file
}
"
sed
-i
's/maturityDegree=10/'
maturityDegree
=
"
${
maturityDegree
}
"
'/g'
"
${
file
}
"
sed
-i
's/^EthBlockFetchPeriod=.*/EthBlockFetchPeriod=500/g'
"
${
file
}
"
sed
-i
's/^fetchHeightPeriodMs=.*/fetchHeightPeriodMs=500/g'
"
${
file
}
"
}
# $1 portRelayer
function
updata_docker_relayer_toml_rpc
()
{
local
portRelayer
=
$1
local
port
=
$1
sed
-i
's/20000/'
"
${
portRelayer
}
"
'/g'
"./x2ethereum/relayer.toml"
sed
-i
's/20000/'
"
${
portRelayer
}
"
'/g'
"./x2ethereum/Dockerfile-x2ethrelay"
for
name
in
b c d
;
do
local
file
=
"./x2ethereum/relayer
$name
.toml"
cp
'./x2ethereum/relayer.toml'
"
${
file
}
"
# 删除配置文件中不需要的字段
for
deleteName
in
"deployerPrivateKey"
"operatorAddr"
"validatorsAddr"
"initPowers"
"deployerPrivateKey"
"deploy"
;
do
delete_line
"
${
file
}
"
"
${
deleteName
}
"
done
port
=
$((
port
-
1
))
sed
-i
's/'
"
${
portRelayer
}
"
'/'
${
port
}
'/g'
"
${
file
}
"
sed
-i
's/x2ethereum/x2ethereum'
${
name
}
'/g'
"
${
file
}
"
local
dockerfile
=
"./x2ethereum/Dockerfile-x2ethrelay
$name
"
cp
"./x2ethereum/Dockerfile-x2ethrelay"
"
${
dockerfile
}
"
# shellcheck disable=SC2155
local
line
=
$(
delete_line_show
"
${
dockerfile
}
"
"COPY relayer.toml relayer.toml"
)
sed
-i
''
"
${
line
}
"
' a COPY relayer'
$name
'.toml relayer.toml'
"
${
dockerfile
}
"
sed
-i
's/'
"
${
portRelayer
}
"
'/'
"
${
port
}
"
'/g'
"
${
dockerfile
}
"
local
dockeryml
=
"./x2ethereum/docker-compose-ebrelayer
$name
.yml"
cp
"./x2ethereum/docker-compose-ebrelayer.yml"
"
${
dockeryml
}
"
sed
-i
's/ebrelayera/ebrelayer'
${
name
}
'/g'
"
${
dockeryml
}
"
sed
-i
's/Dockerfile-x2ethrelay/Dockerfile-x2ethrelay'
${
name
}
'/g'
"
${
dockeryml
}
"
sed
-i
's/'
"
${
portRelayer
}
"
'/'
${
port
}
'/g'
"
${
dockeryml
}
"
done
}
# 更新 B C D 的配置文件
# 更新 B C D 的配置文件
function
updata_all_relayer_toml
()
{
function
updata_all_relayer_toml
()
{
local
port
=
9901
local
port
=
9901
...
@@ -465,6 +617,7 @@ function wait_prophecy_finish() {
...
@@ -465,6 +617,7 @@ function wait_prophecy_finish() {
fi
fi
count
=
$((
count
+
1
))
count
=
$((
count
+
1
))
if
[[
${
count
}
==
30
]]
;
then
if
[[
${
count
}
==
30
]]
;
then
set
-x
echo
-e
"
${
RED
}
failed to get balance
${
NOC
}
"
echo
-e
"
${
RED
}
failed to get balance
${
NOC
}
"
exit_cp_file
exit_cp_file
fi
fi
...
@@ -474,7 +627,7 @@ function wait_prophecy_finish() {
...
@@ -474,7 +627,7 @@ function wait_prophecy_finish() {
set
-x
set
-x
}
}
# eth 区块等待 $1:等待高度 $2:url地址,默认为 http://localhost:7545,测试网络用 https://ropsten-rpc.linkpool.io/
# eth 区块等待 $1:等待高度
$2:url地址,默认为 http://localhost:7545,测试网络用 https://ropsten-rpc.linkpool.io/
function
eth_block_wait
()
{
function
eth_block_wait
()
{
set
+x
set
+x
if
[[
$#
-lt
0
]]
;
then
if
[[
$#
-lt
0
]]
;
then
...
...
plugin/dapp/x2ethereum/cmd/test/test-rpc.sh
View file @
b375d231
This diff is collapsed.
Click to expand it.
plugin/dapp/x2ethereum/commands/commands.go
View file @
b375d231
...
@@ -72,7 +72,6 @@ func addChain33ToEthFlags(cmd *cobra.Command) {
...
@@ -72,7 +72,6 @@ func addChain33ToEthFlags(cmd *cobra.Command) {
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
float64
(
0
),
"the amount of this contract want to lock"
)
cmd
.
Flags
()
.
Float64P
(
"amount"
,
"a"
,
float64
(
0
),
"the amount of this contract want to lock"
)
_
=
cmd
.
MarkFlagRequired
(
"amount"
)
_
=
cmd
.
MarkFlagRequired
(
"amount"
)
}
}
func
burn
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
func
burn
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
...
...
plugin/dapp/x2ethereum/ebcli/main.go
View file @
b375d231
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
package
main
package
main
import
(
import
(
"flag"
"fmt"
"fmt"
"net/http"
"net/http"
"os"
"os"
...
@@ -13,13 +14,18 @@ import (
...
@@ -13,13 +14,18 @@ import (
"github.com/33cn/chain33/common/log"
"github.com/33cn/chain33/common/log"
"github.com/33cn/chain33/pluginmgr"
"github.com/33cn/chain33/pluginmgr"
"github.com/33cn/plugin/plugin/dapp/x2ethereum/ebcli/buildflags"
"github.com/33cn/plugin/plugin/dapp/x2ethereum/ebcli/buildflags"
relayerTypes
"github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer/types"
tml
"github.com/BurntSushi/toml"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
)
)
var
rootCmd
=
&
cobra
.
Command
{
var
(
Use
:
"chain33xEth-relayer"
+
"-cli"
,
rootCmd
=
&
cobra
.
Command
{
Short
:
"chain33xEth-relayer"
+
"client tools"
,
Use
:
"chain33xEth-relayer"
+
"-cli"
,
}
Short
:
"chain33xEth-relayer"
+
"client tools"
,
}
configPath
=
flag
.
String
(
"f"
,
""
,
"configfile"
)
)
func
init
()
{
func
init
()
{
rootCmd
.
AddCommand
(
rootCmd
.
AddCommand
(
...
@@ -59,19 +65,33 @@ func run(RPCAddr, NodeAddr string) {
...
@@ -59,19 +65,33 @@ func run(RPCAddr, NodeAddr string) {
log
.
SetLogLevel
(
"error"
)
log
.
SetLogLevel
(
"error"
)
rootCmd
.
PersistentFlags
()
.
String
(
"rpc_laddr"
,
RPCAddr
,
"http url"
)
rootCmd
.
PersistentFlags
()
.
String
(
"rpc_laddr"
,
RPCAddr
,
"http url"
)
rootCmd
.
PersistentFlags
()
.
String
(
"node_addr"
,
NodeAddr
,
"eth node url"
)
rootCmd
.
PersistentFlags
()
.
String
(
"node_addr"
,
NodeAddr
,
"eth node url"
)
//rootCmd.PersistentFlags().String("rpc_laddr", "", "http url")
if
err
:=
rootCmd
.
Execute
();
err
!=
nil
{
if
err
:=
rootCmd
.
Execute
();
err
!=
nil
{
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
os
.
Exit
(
1
)
os
.
Exit
(
1
)
}
}
}
}
func
initCfg
(
path
string
)
*
relayerTypes
.
RelayerConfig
{
var
cfg
relayerTypes
.
RelayerConfig
if
_
,
err
:=
tml
.
DecodeFile
(
path
,
&
cfg
);
err
!=
nil
{
fmt
.
Println
(
err
)
os
.
Exit
(
-
1
)
}
return
&
cfg
}
func
main
()
{
func
main
()
{
if
*
configPath
==
""
{
*
configPath
=
"relayer.toml"
}
cfg
:=
initCfg
(
*
configPath
)
if
buildflags
.
RPCAddr
==
""
{
if
buildflags
.
RPCAddr
==
""
{
buildflags
.
RPCAddr
=
"http://localhost:9901"
buildflags
.
RPCAddr
=
"http://localhost:9901"
}
}
if
buildflags
.
NodeAddr
==
""
{
if
buildflags
.
NodeAddr
==
""
{
buildflags
.
NodeAddr
=
"http://127.0.0.1:7545"
buildflags
.
NodeAddr
=
cfg
.
EthProviderCli
}
}
run
(
buildflags
.
RPCAddr
,
buildflags
.
NodeAddr
)
run
(
buildflags
.
RPCAddr
,
buildflags
.
NodeAddr
)
}
}
plugin/dapp/x2ethereum/ebrelayer/relayer.toml
View file @
b375d231
# 本配置文件专门用于33复杂美闪电网络使用,即lns33
title
=
"x2Ethereum_relayer"
title
=
"x2Ethereum_relayer"
#用于cli向该relayer进行配置
#用于cli向该relayer进行配置
JrpcBindAddr
=
"localhost:9901"
JrpcBindAddr
=
"localhost:9901"
EthProviderCli
=
"http://127.0.0.1:7545"
EthProvider
=
"ws://127.0.0.1:7545/"
EthProvider
=
"ws://127.0.0.1:7545/"
#EthProvider="wss://rinkeby.infura.io/ws/v3/404eb4acc421426ebeb6e92c7ce9a270"
#EthProvider="wss://rinkeby.infura.io/ws/v3/404eb4acc421426ebeb6e92c7ce9a270"
#EthProvider="wss://ropsten.infura.io/ws/v3/404eb4acc421426ebeb6e92c7ce9a270"
#EthProvider="wss://ropsten.infura.io/ws/v3/404eb4acc421426ebeb6e92c7ce9a270"
...
...
plugin/dapp/x2ethereum/ebrelayer/types/config.pb.go
View file @
b375d231
...
@@ -69,6 +69,7 @@ type RelayerConfig struct {
...
@@ -69,6 +69,7 @@ type RelayerConfig struct {
Deploy
*
Deploy
`protobuf:"bytes,7,opt,name=deploy" json:"deploy,omitempty"`
Deploy
*
Deploy
`protobuf:"bytes,7,opt,name=deploy" json:"deploy,omitempty"`
EthMaturityDegree
int32
`protobuf:"varint,8,opt,name=ethMaturityDegree" json:"ethMaturityDegree,omitempty"`
EthMaturityDegree
int32
`protobuf:"varint,8,opt,name=ethMaturityDegree" json:"ethMaturityDegree,omitempty"`
EthBlockFetchPeriod
int32
`protobuf:"varint,9,opt,name=ethBlockFetchPeriod" json:"ethBlockFetchPeriod,omitempty"`
EthBlockFetchPeriod
int32
`protobuf:"varint,9,opt,name=ethBlockFetchPeriod" json:"ethBlockFetchPeriod,omitempty"`
EthProviderCli
string
`protobuf:"bytes,10,opt,name=ethProviderCli" json:"ethProviderCli,omitempty"`
}
}
func
(
m
*
RelayerConfig
)
Reset
()
{
*
m
=
RelayerConfig
{}
}
func
(
m
*
RelayerConfig
)
Reset
()
{
*
m
=
RelayerConfig
{}
}
...
...
plugin/dapp/x2ethereum/ebrelayer/types/protos/config.proto
View file @
b375d231
...
@@ -40,6 +40,7 @@ message RelayerConfig {
...
@@ -40,6 +40,7 @@ message RelayerConfig {
Deploy
deploy
=
7
;
Deploy
deploy
=
7
;
int32
ethMaturityDegree
=
8
;
int32
ethMaturityDegree
=
8
;
int32
ethBlockFetchPeriod
=
9
;
int32
ethBlockFetchPeriod
=
9
;
string
ethProviderCli
=
10
;
}
}
message
SyncTxReceiptConfig
{
message
SyncTxReceiptConfig
{
...
...
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