Commit 7b6d3277 authored by hezhengjun's avatar hezhengjun

Merge branch 'x2eth_200507' of github.com:zhengjunhe/plugin into x2eth_200507

parents b290939c 2cefc412
...@@ -115,6 +115,10 @@ function base_init() { ...@@ -115,6 +115,10 @@ function base_init() {
#autonomy #autonomy
sed -i $sedfix 's/^useBalance=.*/useBalance=true/g' chain33.toml sed -i $sedfix 's/^useBalance=.*/useBalance=true/g' chain33.toml
sed -i $sedfix 's/^total="16htvcBNS.*/total="1Q9sQwothzM1gKSzkVZ8Dt1tqKX1uzSagx"/g' chain33.toml sed -i $sedfix 's/^total="16htvcBNS.*/total="1Q9sQwothzM1gKSzkVZ8Dt1tqKX1uzSagx"/g' chain33.toml
if [ "$DAPP" == "x2Ethereum" ]; then
sed -i $sedfix 's/^enableReduceLocaldb=.*/enableReduceLocaldb=false/g' chain33.toml
fi
} }
function start() { function start() {
......
package chain33
import (
"context"
"encoding/hex"
"flag"
"fmt"
"os"
"os/signal"
"sync"
"sync/atomic"
"syscall"
"testing"
"time"
dbm "github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/types"
"github.com/33cn/chain33/util/testnode"
"github.com/33cn/plugin/plugin/dapp/x2Ethereum/ebrelayer/ethcontract/generated"
"github.com/33cn/plugin/plugin/dapp/x2Ethereum/ebrelayer/ethcontract/test/setup"
"github.com/33cn/plugin/plugin/dapp/x2Ethereum/ebrelayer/ethtxs"
syncTx "github.com/33cn/plugin/plugin/dapp/x2Ethereum/ebrelayer/relayer/chain33/transceiver/sync"
ebTypes "github.com/33cn/plugin/plugin/dapp/x2Ethereum/ebrelayer/types"
relayerTypes "github.com/33cn/plugin/plugin/dapp/x2Ethereum/ebrelayer/types"
tml "github.com/BurntSushi/toml"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/suite"
// 需要显示引用系统插件,以加载系统内置合约
"github.com/33cn/chain33/client/mocks"
_ "github.com/33cn/chain33/system"
"github.com/stretchr/testify/mock"
)
var (
configPath = flag.String("f", "./../../relayer.toml", "configfile")
chainTestCfg = types.NewChain33Config(types.GetDefaultCfgstring())
privateKeyStr = "0x3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
accountAddr = "0x92c8b16afd6d423652559c6e266cbe1c29bfd84f"
passphrase = "123456hzj"
test = "0ac3050aa3020a0a7832657468657265756d126d60671a690a2a3078303030303030303030303030303030303030303030303030303030303030303030303030303030301a2a307830633035626135633233306664616135303362353337303261663139363265303864306336306266220831303030303030302a0365746838121a6e080112210320bbac09528e19c55b0f89cb37ab265e7e856b1a8c388780322dbbfd194b52ba1a473045022100c403d9a6e531292336b44d52e4f4dbb9b8ab1e16335383954583728b909478da022031d8a29efcbcea8df648c4054f3c09ab1ab7a330797cf79fd891a3d9336922e920a08d0628e0f193f60530a1d7ad93e5ebc28e253a22314c7538586d537459765777664e716951336e4e4b33345239466648346b5270425612ce0208021a5e0802125a0a2b10c0d59294bb192222313271796f6361794e46374c7636433971573461767873324537553431664b536676122b10a0c88c94bb192222313271796f6361794e46374c7636433971573461767873324537553431664b5366761a55080f12510a291080ade2042222313271796f6361794e46374c7636433971573461767873324537553431664b53667612242222313271796f6361794e46374c7636433971573461767873324537553431664b5366761a92010867128d010a2a3078303030303030303030303030303030303030303030303030303030303030303030303030303030301222313271796f6361794e46374c7636433971573461767873324537553431664b5366761a2a307830633035626135633233306664616135303362353337303261663139363265303864306336306266220831303030303030302a03657468301220c4092a207a38e1da7de4444f2d34c7488293f3a2e01ce2561e720e9bbef355e83755ad833220e68d8418f69d5f18278a53dca53b101f26f76883337a60a5754d5f6d94e42e3c400148c409"
)
type suiteChain33Relayer struct {
suite.Suite
chain33Relayer *Relayer4Chain33
sim *backends.SimulatedBackend
x2EthContracts *ethtxs.X2EthContracts
x2EthDeployInfo *ethtxs.X2EthDeployInfo
para *ethtxs.DeployPara
}
func TestRunSuiteX2Ethereum(t *testing.T) {
log := new(suiteChain33Relayer)
suite.Run(t, log)
}
func (r *suiteChain33Relayer) SetupSuite() {
r.deployContracts()
r.chain33Relayer = r.newChain33Relayer()
}
func (r *suiteChain33Relayer) Test_1_ImportPrivateKey() {
addr, err := r.chain33Relayer.ImportPrivateKey(passphrase, privateKeyStr)
r.NoError(err)
r.Equal(addr, accountAddr)
time.Sleep(50 * time.Millisecond)
addr, err = r.chain33Relayer.GetAccountAddr()
r.NoError(err)
r.Equal(addr, accountAddr)
key, _, _ := r.chain33Relayer.GetAccount("123")
r.NotEqual(key, privateKeyStr)
key, _, _ = r.chain33Relayer.GetAccount(passphrase)
r.Equal(key, privateKeyStr)
}
func (r *suiteChain33Relayer) Test_2_HandleRequest() {
body, err := hex.DecodeString(test)
r.NoError(err)
r.chain33Relayer.statusCheckedIndex = 1220
err = syncTx.HandleRequest(body)
r.NoError(err)
//time.Sleep(50 * time.Second)
time.Sleep(50 * time.Millisecond)
}
func (r *suiteChain33Relayer) Test_3_QueryTxhashRelay2Eth() {
ret := r.chain33Relayer.QueryTxhashRelay2Eth()
r.NotEmpty(ret)
}
func (r *suiteChain33Relayer) Test_4_StoreAccountWithNewPassphase() {
err := r.chain33Relayer.StoreAccountWithNewPassphase(passphrase, passphrase)
r.NoError(err)
}
func (r *suiteChain33Relayer) Test_5_getEthTxhash() {
txIndex := atomic.LoadInt64(&r.chain33Relayer.totalTx4Chain33ToEth)
hash, err := r.chain33Relayer.getEthTxhash(txIndex)
r.NoError(err)
r.Equal(hash.String(), "0x6fa087c7a2a8a4421f6e269fbc6c0838e99fa59d5760155a71cd7eb1c01aafad")
}
func (r *suiteChain33Relayer) Test_7_RestorePrivateKeys() {
//err := r.chain33Relayer.RestorePrivateKeys("123") // 不会报错
//r.Error(err)
go func() {
time.Sleep(1 * time.Millisecond)
<-r.chain33Relayer.unlock
}()
err := r.chain33Relayer.RestorePrivateKeys(passphrase)
r.NoError(err)
}
func (r *suiteChain33Relayer) newChain33Relayer() *Relayer4Chain33 {
cfg := initCfg(*configPath)
cfg.SyncTxConfig.Chain33Host = "http://127.0.0.1:8801"
cfg.BridgeRegistry = r.x2EthDeployInfo.BridgeRegistry.Address.String()
cfg.SyncTxConfig.PushBind = "127.0.0.1:60000"
cfg.SyncTxConfig.FetchHeightPeriodMs = 50
cfg.SyncTxConfig.Dbdriver = "memdb"
db := dbm.NewDB("relayer_db_service", cfg.SyncTxConfig.Dbdriver, cfg.SyncTxConfig.DbPath, cfg.SyncTxConfig.DbCache)
ctx, cancel := context.WithCancel(context.Background())
relayer := &Relayer4Chain33{
rpcLaddr: cfg.SyncTxConfig.Chain33Host,
fetchHeightPeriodMs: cfg.SyncTxConfig.FetchHeightPeriodMs,
unlock: make(chan int),
db: db,
ctx: ctx,
}
err := relayer.setStatusCheckedIndex(1)
r.NoError(err)
relayer.ethBackend = r.sim
relayer.bridgeRegistryAddr = r.para.Deployer
relayer.totalTx4Chain33ToEth = relayer.getTotalTxAmount2Eth()
relayer.statusCheckedIndex = relayer.getStatusCheckedIndex()
r.Equal(relayer.statusCheckedIndex, int64(1))
syncCfg := &ebTypes.SyncTxReceiptConfig{
Chain33Host: cfg.SyncTxConfig.Chain33Host,
PushHost: cfg.SyncTxConfig.PushHost,
PushName: cfg.SyncTxConfig.PushName,
PushBind: cfg.SyncTxConfig.PushBind,
StartSyncHeight: cfg.SyncTxConfig.StartSyncHeight,
StartSyncSequence: cfg.SyncTxConfig.StartSyncSequence,
StartSyncHash: cfg.SyncTxConfig.StartSyncHash,
}
_ = syncCfg
go r.syncProc(syncCfg)
var wg sync.WaitGroup
ch := make(chan os.Signal, 1)
signal.Notify(ch, syscall.SIGTERM)
go func() {
<-ch
cancel()
wg.Wait()
os.Exit(0)
}()
return relayer
}
func (r *suiteChain33Relayer) deployContracts() {
ctx := context.Background()
var backend bind.ContractBackend
backend, r.para = setup.PrepareTestEnvironment()
r.sim = backend.(*backends.SimulatedBackend)
balance, _ := r.sim.BalanceAt(ctx, r.para.Deployer, nil)
fmt.Println("deployer addr,", r.para.Deployer.String(), "balance =", balance.String())
/////////////////////////EstimateGas///////////////////////////
callMsg := ethereum.CallMsg{
From: r.para.Deployer,
Data: common.FromHex(generated.BridgeBankBin),
}
gas, err := r.sim.EstimateGas(ctx, callMsg)
r.NoError(err)
fmt.Printf("\nThe estimated gas=%d\n", gas)
////////////////////////////////////////////////////
r.x2EthContracts, r.x2EthDeployInfo, err = ethtxs.DeployAndInit(backend, r.para)
r.NoError(err)
r.sim.Commit()
}
func (r *suiteChain33Relayer) syncProc(syncCfg *ebTypes.SyncTxReceiptConfig) {
var ret = types.ReplySubTxReceipt{IsOk: true}
var he = types.Header{Height: 10000}
mockapi := &mocks.QueueProtocolAPI{}
// 这里对需要mock的方法打桩,Close是必须的,其它方法根据需要
mockapi.On("Close").Return()
mockapi.On("AddSubscribeTxReceipt", mock.Anything).Return(&ret, nil)
mockapi.On("GetLastHeader", mock.Anything).Return(&he, nil)
mockapi.On("GetConfig", mock.Anything).Return(chainTestCfg, nil)
mock33 := testnode.New("", mockapi)
defer mock33.Close()
rpcCfg := mock33.GetCfg().RPC
// 这里必须设置监听端口,默认的是无效值
rpcCfg.JrpcBindAddr = "127.0.0.1:8801"
mock33.GetRPC().Listen()
fmt.Println("Pls unlock or import private key for Chain33 relayer")
<-r.chain33Relayer.unlock
fmt.Println("Chain33 relayer starts to run...")
r.chain33Relayer.syncTxReceipts = syncTx.StartSyncTxReceipt(syncCfg, r.chain33Relayer.db)
r.chain33Relayer.lastHeight4Tx = r.chain33Relayer.loadLastSyncHeight()
r.chain33Relayer.oracleInstance = r.x2EthContracts.Oracle
timer := time.NewTicker(time.Duration(r.chain33Relayer.fetchHeightPeriodMs) * time.Millisecond)
for {
select {
case <-timer.C:
height := r.chain33Relayer.getCurrentHeight()
relayerLog.Debug("syncProc", "getCurrentHeight", height)
r.chain33Relayer.onNewHeightProc(height)
case <-r.chain33Relayer.ctx.Done():
timer.Stop()
return
}
}
}
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
}
package sync
func HandleRequest(body []byte) error {
return handleRequest(body)
}
#!/bin/sh #!/usr/bin/env bash
# 官方ci集成脚本 # 官方ci集成脚本
strpwd=$(pwd) strpwd=$(pwd)
strcmd=${strpwd##*dapp/} strcmd=${strpwd##*dapp/}
...@@ -11,9 +12,13 @@ FLAG=$2 ...@@ -11,9 +12,13 @@ FLAG=$2
# shellcheck disable=SC2086,1072 # shellcheck disable=SC2086,1072
go build -i ${FLAG} -v -o "${OUT_DIR}/ebrelayer" "${SRC_EBRELAYER}" go build -i ${FLAG} -v -o "${OUT_DIR}/ebrelayer" "${SRC_EBRELAYER}"
# shellcheck disable=SC2086,1072
go build -i ${FLAG} -v -o "${OUT_DIR}/ebcli_A" "${SRC_EBCLI}" go build -i ${FLAG} -v -o "${OUT_DIR}/ebcli_A" "${SRC_EBCLI}"
# shellcheck disable=SC2086,1072
go build -i ${FLAG} -v -o "${OUT_DIR}/ebcli_B" -ldflags "-X ${SRC_EBCLI}/buildflags.RPCAddr=http://localhost:9902" "${SRC_EBCLI}" go build -i ${FLAG} -v -o "${OUT_DIR}/ebcli_B" -ldflags "-X ${SRC_EBCLI}/buildflags.RPCAddr=http://localhost:9902" "${SRC_EBCLI}"
# shellcheck disable=SC2086,1072
go build -i ${FLAG} -v -o "${OUT_DIR}/ebcli_C" -ldflags "-X ${SRC_EBCLI}/buildflags.RPCAddr=http://localhost:9903" "${SRC_EBCLI}" go build -i ${FLAG} -v -o "${OUT_DIR}/ebcli_C" -ldflags "-X ${SRC_EBCLI}/buildflags.RPCAddr=http://localhost:9903" "${SRC_EBCLI}"
# shellcheck disable=SC2086,1072
go build -i ${FLAG} -v -o "${OUT_DIR}/ebcli_D" -ldflags "-X ${SRC_EBCLI}/buildflags.RPCAddr=http://localhost:9904" "${SRC_EBCLI}" go build -i ${FLAG} -v -o "${OUT_DIR}/ebcli_D" -ldflags "-X ${SRC_EBCLI}/buildflags.RPCAddr=http://localhost:9904" "${SRC_EBCLI}"
cp ../ebrelayer/relayer.toml "${OUT_DIR}/relayer.toml" cp ../ebrelayer/relayer.toml "${OUT_DIR}/relayer.toml"
......
...@@ -14,14 +14,11 @@ CLIC="./ebcli_C" ...@@ -14,14 +14,11 @@ CLIC="./ebcli_C"
CLID="./ebcli_D" CLID="./ebcli_D"
chain33SenderAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt" chain33SenderAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
chain33SenderAddrKey="CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"
# validatorsAddr=["0x92c8b16afd6d423652559c6e266cbe1c29bfd84f", "0x0df9a824699bc5878232c9e612fe1a5346a5a368", "0xcb074cb21cdddf3ce9c3c0a7ac4497d633c9d9f1", "0xd9dab021e74ecf475788ed7b61356056b2095830"] # validatorsAddr=["0x92c8b16afd6d423652559c6e266cbe1c29bfd84f", "0x0df9a824699bc5878232c9e612fe1a5346a5a368", "0xcb074cb21cdddf3ce9c3c0a7ac4497d633c9d9f1", "0xd9dab021e74ecf475788ed7b61356056b2095830"]
ethValidatorAddrKeyA="3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e" ethValidatorAddrKeyA="3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
ethValidatorAddrKeyB="a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400" ethValidatorAddrKeyB="a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400"
ethValidatorAddrKeyC="bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e" ethValidatorAddrKeyC="bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e"
ethValidatorAddrKeyD="c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b" ethValidatorAddrKeyD="c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b"
# 新增地址 chain33 需要导入地址 转入 10 bty当收费费 # 新增地址 chain33 需要导入地址 转入 10 bty当收费费
chain33Validator1="1GTxrmuWiXavhcvsaH5w9whgVxUrWsUMdV" chain33Validator1="1GTxrmuWiXavhcvsaH5w9whgVxUrWsUMdV"
chain33Validator2="155ooMPBTF8QQsGAknkK7ei5D78rwDEFe6" chain33Validator2="155ooMPBTF8QQsGAknkK7ei5D78rwDEFe6"
...@@ -31,11 +28,11 @@ chain33ValidatorKey1="0xd627968e445f2a41c92173225791bae1ba42126ae96c32f28f97ff8f ...@@ -31,11 +28,11 @@ chain33ValidatorKey1="0xd627968e445f2a41c92173225791bae1ba42126ae96c32f28f97ff8f
chain33ValidatorKey2="0x9d539bc5fd084eb7fe86ad631dba9aa086dba38418725c38d9751459f567da66" chain33ValidatorKey2="0x9d539bc5fd084eb7fe86ad631dba9aa086dba38418725c38d9751459f567da66"
chain33ValidatorKey3="0x0a6671f101e30a2cc2d79d77436b62cdf2664ed33eb631a9c9e3f3dd348a23be" chain33ValidatorKey3="0x0a6671f101e30a2cc2d79d77436b62cdf2664ed33eb631a9c9e3f3dd348a23be"
chain33ValidatorKey4="0x3818b257b05ee75b6e43ee0e3cfc2d8502342cf67caed533e3756966690b62a5" chain33ValidatorKey4="0x3818b257b05ee75b6e43ee0e3cfc2d8502342cf67caed533e3756966690b62a5"
ethReceiverAddr1="0xa4ea64a583f6e51c3799335b28a8f0529570a635" ethReceiverAddr1="0xa4ea64a583f6e51c3799335b28a8f0529570a635"
ethReceiverAddrKey1="355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71" ethReceiverAddrKey1="355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71"
ethReceiverAddr2="0x0c05ba5c230fdaa503b53702af1962e08d0c60bf" ethReceiverAddr2="0x0c05ba5c230fdaa503b53702af1962e08d0c60bf"
ethReceiverAddrKey2="9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08" ethReceiverAddrKey2="9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08"
maturityDegree=10 maturityDegree=10
tokenAddrBty="" tokenAddrBty=""
...@@ -93,7 +90,7 @@ function StartRelayerAndDeploy() { ...@@ -93,7 +90,7 @@ function StartRelayerAndDeploy() {
kill_ebrelayer "./A/ebrelayer" kill_ebrelayer "./A/ebrelayer"
# 修改 relayer.toml 配置文件 # 修改 relayer.toml 配置文件
updata_relayer_toml_ropston ${BridgeRegistry} ${maturityDegree} "./A/relayer.toml" updata_relayer_toml_ropston "${BridgeRegistry}" ${maturityDegree} "./A/relayer.toml"
updata_all_relayer_toml2 updata_all_relayer_toml2
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
...@@ -128,7 +125,7 @@ function InitChain33Vilators() { ...@@ -128,7 +125,7 @@ function InitChain33Vilators() {
# query Validators # query Validators
totalPower=$(${Chain33Cli} send x2ethereum query totalpower -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv | jq .totalPower | sed 's/\"//g') totalPower=$(${Chain33Cli} send x2ethereum query totalpower -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv | jq .totalPower | sed 's/\"//g')
check_number 100 ${totalPower} check_number 100 "${totalPower}"
# cions 转帐到 x2ethereum 合约地址 # cions 转帐到 x2ethereum 合约地址
hash=$(${Chain33Cli} send coins send_exec -e x2ethereum -a 200 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv) hash=$(${Chain33Cli} send coins send_exec -e x2ethereum -a 200 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv)
...@@ -183,15 +180,6 @@ function EthImportKey() { ...@@ -183,15 +180,6 @@ function EthImportKey() {
result=$(${CLID} relayer ethereum import_chain33privatekey -k "${chain33ValidatorKey4}") result=$(${CLID} relayer ethereum import_chain33privatekey -k "${chain33ValidatorKey4}")
cli_ret "${result}" "import_chain33privatekey" cli_ret "${result}" "import_chain33privatekey"
result=$(${CLIA} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyA}")
cli_ret "${result}" "import_ethprivatekey"
result=$(${CLIB} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyB}")
cli_ret "${result}" "import_ethprivatekeyB"
result=$(${CLIC} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyC}")
cli_ret "${result}" "import_ethprivatekeyC"
result=$(${CLID} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyD}")
cli_ret "${result}" "import_ethprivatekeyD"
result=$(${CLIA} relayer chain33 import_privatekey -k "${ethValidatorAddrKeyA}") result=$(${CLIA} relayer chain33 import_privatekey -k "${ethValidatorAddrKeyA}")
cli_ret "${result}" "A relayer chain33 import_privatekey" cli_ret "${result}" "A relayer chain33 import_privatekey"
result=$(${CLIB} relayer chain33 import_privatekey -k "${ethValidatorAddrKeyB}") result=$(${CLIB} relayer chain33 import_privatekey -k "${ethValidatorAddrKeyB}")
...@@ -217,7 +205,7 @@ function TestChain33ToEthAssets() { ...@@ -217,7 +205,7 @@ function TestChain33ToEthAssets() {
cli_ret "${result}" "balance" ".balance" "0" cli_ret "${result}" "balance" ".balance" "0"
# chain33 lock bty # chain33 lock bty
hash=$(${Chain33Cli} send x2ethereum lock -a 5 -t "${tokenSymbol}" -r ${ethReceiverAddr1} -q ${tokenAddrBty} -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv) hash=$(${Chain33Cli} send x2ethereum lock -a 5 -t "${tokenSymbol}" -r ${ethReceiverAddr1} -q "${tokenAddrBty}" -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv)
block_wait "${Chain33Cli}" $((maturityDegree + 3)) block_wait "${Chain33Cli}" $((maturityDegree + 3))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
...@@ -286,7 +274,7 @@ function TestETH2Chain33Assets() { ...@@ -286,7 +274,7 @@ function TestETH2Chain33Assets() {
cli_ret "${result}" "balance" ".balance" "0" cli_ret "${result}" "balance" ".balance" "0"
result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}") result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}")
cli_ret "${result}" "balance" ".balance" $(echo "${balance}+0.1" | bc) cli_ret "${result}" "balance" ".balance" "$(echo "${balance}+0.1" | bc)"
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
} }
...@@ -331,7 +319,7 @@ function TestETH2Chain33Erc20() { ...@@ -331,7 +319,7 @@ function TestETH2Chain33Erc20() {
balance_ret "${result}" "100" balance_ret "${result}" "100"
# chain33 burn 100 # chain33 burn 100
hash=$(${Chain33Cli} send x2ethereum burn -a 100 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q ${tokenAddr} -k "${chain33Validator1}") hash=$(${Chain33Cli} send x2ethereum burn -a 100 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q "${tokenAddr}" -k "${chain33Validator1}")
block_wait "${Chain33Cli}" $((maturityDegree + 3)) block_wait "${Chain33Cli}" $((maturityDegree + 3))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
...@@ -368,7 +356,7 @@ function TestChain33ToEthAssetsKill() { ...@@ -368,7 +356,7 @@ function TestChain33ToEthAssetsKill() {
kill_ebrelayerD kill_ebrelayerD
# chain33 lock bty # chain33 lock bty
hash=$(${Chain33Cli} send x2ethereum lock -a 1.41 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q ${tokenAddrBty} -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv) hash=$(${Chain33Cli} send x2ethereum lock -a 1.41 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q "${tokenAddrBty}" -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv)
block_wait "${Chain33Cli}" $((maturityDegree + 3)) block_wait "${Chain33Cli}" $((maturityDegree + 3))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
...@@ -423,7 +411,7 @@ function TestETH2Chain33AssetsKill() { ...@@ -423,7 +411,7 @@ function TestETH2Chain33AssetsKill() {
cli_ret "${result}" "lock" cli_ret "${result}" "lock"
result=$(${CLIA} relayer ethereum balance -o "${bridgeBankAddr}") result=$(${CLIA} relayer ethereum balance -o "${bridgeBankAddr}")
cli_ret "${result}" "balance" ".balance" $(echo "${balance}+0.133" | bc) cli_ret "${result}" "balance" ".balance" "$(echo "${balance}+0.133" | bc)"
# eth 等待 10 个区块 # eth 等待 10 个区块
eth_block_wait $((maturityDegree + 3)) https://ropsten-rpc.linkpool.io/ eth_block_wait $((maturityDegree + 3)) https://ropsten-rpc.linkpool.io/
...@@ -459,7 +447,7 @@ function TestETH2Chain33AssetsKill() { ...@@ -459,7 +447,7 @@ function TestETH2Chain33AssetsKill() {
start_ebrelayerD start_ebrelayerD
result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}") result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}")
cli_ret "${result}" "balance" ".balance" $(echo "${balance}+0.133" | bc) cli_ret "${result}" "balance" ".balance" "$(echo "${balance}+0.133" | bc)"
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
} }
...@@ -515,7 +503,7 @@ function TestETH2Chain33Erc20Kill() { ...@@ -515,7 +503,7 @@ function TestETH2Chain33Erc20Kill() {
kill_ebrelayerD kill_ebrelayerD
# chain33 burn 100 # chain33 burn 100
hash=$(${Chain33Cli} send x2ethereum burn -a 100 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q ${tokenAddr} -k "${chain33Validator1}") hash=$(${Chain33Cli} send x2ethereum burn -a 100 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q "${tokenAddr}" -k "${chain33Validator1}")
block_wait "${Chain33Cli}" $((maturityDegree + 3)) block_wait "${Chain33Cli}" $((maturityDegree + 3))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
......
...@@ -11,21 +11,16 @@ CLIB="./ebcli_B" ...@@ -11,21 +11,16 @@ CLIB="./ebcli_B"
CLIC="./ebcli_C" CLIC="./ebcli_C"
CLID="./ebcli_D" CLID="./ebcli_D"
#docker_chain33_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' build_chain33_1)
#Chain33Cli="$GOPATH/src/github.com/33cn/plugin/build/chain33-cli --rpc_laddr http://${docker_chain33_ip}:8801"
docker_chain33_ip="" docker_chain33_ip=""
Chain33Cli="" Chain33Cli=""
Chain33Cli="docker exec ${NODE3} /root/chain33-cli" Chain33Cli="docker exec ${NODE3} /root/chain33-cli"
chain33SenderAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt" chain33SenderAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
chain33SenderAddrKey="CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"
# validatorsAddr=["0x92c8b16afd6d423652559c6e266cbe1c29bfd84f", "0x0df9a824699bc5878232c9e612fe1a5346a5a368", "0xcb074cb21cdddf3ce9c3c0a7ac4497d633c9d9f1", "0xd9dab021e74ecf475788ed7b61356056b2095830"] # validatorsAddr=["0x92c8b16afd6d423652559c6e266cbe1c29bfd84f", "0x0df9a824699bc5878232c9e612fe1a5346a5a368", "0xcb074cb21cdddf3ce9c3c0a7ac4497d633c9d9f1", "0xd9dab021e74ecf475788ed7b61356056b2095830"]
ethValidatorAddrKeyA="3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e" ethValidatorAddrKeyA="3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
ethValidatorAddrKeyB="a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400" ethValidatorAddrKeyB="a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400"
ethValidatorAddrKeyC="bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e" ethValidatorAddrKeyC="bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e"
ethValidatorAddrKeyD="c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b" ethValidatorAddrKeyD="c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b"
# 新增地址 chain33 需要导入地址 转入 10 bty当收费费 # 新增地址 chain33 需要导入地址 转入 10 bty当收费费
chain33Validator1="1GTxrmuWiXavhcvsaH5w9whgVxUrWsUMdV" chain33Validator1="1GTxrmuWiXavhcvsaH5w9whgVxUrWsUMdV"
chain33Validator2="155ooMPBTF8QQsGAknkK7ei5D78rwDEFe6" chain33Validator2="155ooMPBTF8QQsGAknkK7ei5D78rwDEFe6"
...@@ -35,11 +30,11 @@ chain33ValidatorKey1="0xd627968e445f2a41c92173225791bae1ba42126ae96c32f28f97ff8f ...@@ -35,11 +30,11 @@ chain33ValidatorKey1="0xd627968e445f2a41c92173225791bae1ba42126ae96c32f28f97ff8f
chain33ValidatorKey2="0x9d539bc5fd084eb7fe86ad631dba9aa086dba38418725c38d9751459f567da66" chain33ValidatorKey2="0x9d539bc5fd084eb7fe86ad631dba9aa086dba38418725c38d9751459f567da66"
chain33ValidatorKey3="0x0a6671f101e30a2cc2d79d77436b62cdf2664ed33eb631a9c9e3f3dd348a23be" chain33ValidatorKey3="0x0a6671f101e30a2cc2d79d77436b62cdf2664ed33eb631a9c9e3f3dd348a23be"
chain33ValidatorKey4="0x3818b257b05ee75b6e43ee0e3cfc2d8502342cf67caed533e3756966690b62a5" chain33ValidatorKey4="0x3818b257b05ee75b6e43ee0e3cfc2d8502342cf67caed533e3756966690b62a5"
ethReceiverAddr1="0xa4ea64a583f6e51c3799335b28a8f0529570a635" ethReceiverAddr1="0xa4ea64a583f6e51c3799335b28a8f0529570a635"
ethReceiverAddrKey1="355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71" ethReceiverAddrKey1="355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71"
ethReceiverAddr2="0x0c05ba5c230fdaa503b53702af1962e08d0c60bf" ethReceiverAddr2="0x0c05ba5c230fdaa503b53702af1962e08d0c60bf"
ethReceiverAddrKey2="9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08" ethReceiverAddrKey2="9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08"
maturityDegree=10 maturityDegree=10
tokenAddrBty="" tokenAddrBty=""
tokenAddr="" tokenAddr=""
...@@ -54,20 +49,20 @@ function start_ebrelayerC() { ...@@ -54,20 +49,20 @@ function start_ebrelayerC() {
start_ebrelayer "./C/ebrelayer" "./C/ebrelayer.log" start_ebrelayer "./C/ebrelayer" "./C/ebrelayer.log"
${CLIC} relayer unlock -p 123456hzj ${CLIC} relayer unlock -p 123456hzj
sleep 5 sleep 5
eth_block_wait 1 eth_block_wait $((maturityDegree + 2))
sleep 1 sleep 10
} }
function start_ebrelayerD() { function start_ebrelayerD() {
start_ebrelayer "./D/ebrelayer" "./D/ebrelayer.log" start_ebrelayer "./D/ebrelayer" "./D/ebrelayer.log"
${CLID} relayer unlock -p 123456hzj ${CLID} relayer unlock -p 123456hzj
sleep 5 sleep 5
eth_block_wait 1 eth_block_wait $((maturityDegree + 2))
sleep 1 sleep 10
} }
function InitAndDeploy() { function InitAndDeploy() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
result=$(${CLIA} relayer set_pwd -n 123456hzj -o kk) result=$(${CLIA} relayer set_pwd -p 123456hzj)
cli_ret "${result}" "set_pwd" cli_ret "${result}" "set_pwd"
result=$(${CLIA} relayer unlock -p 123456hzj) result=$(${CLIA} relayer unlock -p 123456hzj)
...@@ -83,12 +78,12 @@ function EthImportKey() { ...@@ -83,12 +78,12 @@ function EthImportKey() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
# 重启 ebrelayer 并解锁 # 重启 ebrelayer 并解锁
for name in A B C D; do for name in A B C D; do
start_ebrelayer "./"$name"/ebrelayer" "./"$name"/ebrelayer.log" start_ebrelayer "./$name/ebrelayer" "./$name/ebrelayer.log"
# 导入测试地址私钥 # 导入测试地址私钥
CLI="./ebcli_$name" CLI="./ebcli_$name"
result=$(${CLI} relayer set_pwd -n 123456hzj -o kk) result=$(${CLI} relayer set_pwd -p 123456hzj)
result=$(${CLI} relayer unlock -p 123456hzj) result=$(${CLI} relayer unlock -p 123456hzj)
cli_ret "${result}" "unlock" cli_ret "${result}" "unlock"
...@@ -103,15 +98,6 @@ function EthImportKey() { ...@@ -103,15 +98,6 @@ function EthImportKey() {
result=$(${CLID} relayer ethereum import_chain33privatekey -k "${chain33ValidatorKey4}") result=$(${CLID} relayer ethereum import_chain33privatekey -k "${chain33ValidatorKey4}")
cli_ret "${result}" "import_chain33privatekey" cli_ret "${result}" "import_chain33privatekey"
result=$(${CLIA} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyA}")
cli_ret "${result}" "import_ethprivatekey"
result=$(${CLIB} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyB}")
cli_ret "${result}" "import_ethprivatekeyB"
result=$(${CLIC} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyC}")
cli_ret "${result}" "import_ethprivatekeyC"
result=$(${CLID} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyD}")
cli_ret "${result}" "import_ethprivatekeyD"
result=$(${CLIA} relayer chain33 import_privatekey -k "${ethValidatorAddrKeyA}") result=$(${CLIA} relayer chain33 import_privatekey -k "${ethValidatorAddrKeyA}")
cli_ret "${result}" "A relayer chain33 import_privatekey" cli_ret "${result}" "A relayer chain33 import_privatekey"
result=$(${CLIB} relayer chain33 import_privatekey -k "${ethValidatorAddrKeyB}") result=$(${CLIB} relayer chain33 import_privatekey -k "${ethValidatorAddrKeyB}")
...@@ -150,7 +136,7 @@ function StartRelayerAndDeploy() { ...@@ -150,7 +136,7 @@ function StartRelayerAndDeploy() {
kill_ebrelayer "./A/ebrelayer" kill_ebrelayer "./A/ebrelayer"
# 修改 relayer.toml 配置文件 # 修改 relayer.toml 配置文件
updata_relayer_toml ${BridgeRegistry} ${maturityDegree} "./A/relayer.toml" updata_relayer_toml "${BridgeRegistry}" ${maturityDegree} "./A/relayer.toml"
updata_all_relayer_toml2 updata_all_relayer_toml2
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
...@@ -185,7 +171,7 @@ function InitChain33Vilators() { ...@@ -185,7 +171,7 @@ function InitChain33Vilators() {
# query Validators # query Validators
totalPower=$(${Chain33Cli} send x2ethereum query totalpower -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv | jq .totalPower | sed 's/\"//g') totalPower=$(${Chain33Cli} send x2ethereum query totalpower -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv | jq .totalPower | sed 's/\"//g')
check_number 100 ${totalPower} check_number 100 "${totalPower}"
# cions 转帐到 x2ethereum 合约地址 # cions 转帐到 x2ethereum 合约地址
hash=$(${Chain33Cli} send coins send_exec -e x2ethereum -a 200 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv) hash=$(${Chain33Cli} send coins send_exec -e x2ethereum -a 200 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv)
...@@ -228,7 +214,7 @@ function TestChain33ToEthAssets() { ...@@ -228,7 +214,7 @@ function TestChain33ToEthAssets() {
cli_ret "${result}" "balance" ".balance" "0" cli_ret "${result}" "balance" ".balance" "0"
# chain33 lock bty # chain33 lock bty
hash=$(${Chain33Cli} send x2ethereum lock -a 5 -t coins.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)) block_wait "${Chain33Cli}" $((maturityDegree + 2))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
...@@ -297,7 +283,7 @@ function TestETH2Chain33Assets() { ...@@ -297,7 +283,7 @@ function TestETH2Chain33Assets() {
cli_ret "${result}" "balance" ".balance" "0" cli_ret "${result}" "balance" ".balance" "0"
result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}") result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}")
cli_ret "${result}" "balance" ".balance" $(echo "${balance}+0.1" | bc) cli_ret "${result}" "balance" ".balance" "$(echo "${balance}+0.1" | bc)"
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
} }
...@@ -341,7 +327,7 @@ function TestETH2Chain33Erc20() { ...@@ -341,7 +327,7 @@ function TestETH2Chain33Erc20() {
balance_ret "${result}" "100" balance_ret "${result}" "100"
# chain33 burn 100 # chain33 burn 100
hash=$(${Chain33Cli} send x2ethereum burn -a 100 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q ${tokenAddr} -k "${chain33Validator1}") hash=$(${Chain33Cli} send x2ethereum burn -a 100 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q "${tokenAddr}" -k "${chain33Validator1}")
block_wait "${Chain33Cli}" $((maturityDegree + 2)) block_wait "${Chain33Cli}" $((maturityDegree + 2))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
...@@ -368,32 +354,32 @@ function TestChain33ToEthAssetsKill() { ...@@ -368,32 +354,32 @@ function TestChain33ToEthAssetsKill() {
tokenAddrBty=$(cli_ret "${result}" "token4chain33" ".addr") tokenAddrBty=$(cli_ret "${result}" "token4chain33" ".addr")
fi fi
result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr1}" -t "coins.bty") result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr1}" -t "${tokenAddrBty}")
cli_ret "${result}" "balance" ".balance" "0" cli_ret "${result}" "balance" ".balance" "0"
kill_ebrelayerC kill_ebrelayerC
kill_ebrelayerD kill_ebrelayerD
# chain33 lock bty # chain33 lock bty
hash=$(${Chain33Cli} send x2ethereum lock -a 5 -t bty -r ${ethReceiverAddr2} -q ${tokenAddrBty} -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv) hash=$(${Chain33Cli} send x2ethereum lock -a 5 -t coins.bty -r ${ethReceiverAddr2} -q "${tokenAddrBty}" -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv)
block_wait "${Chain33Cli}" $((maturityDegree + 2)) block_wait "${Chain33Cli}" $((maturityDegree + 2))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
eth_block_wait $((maturityDegree + 2)) eth_block_wait $((maturityDegree + 2))
result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}" -t "coins.bty") result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}" -t "${tokenAddrBty}")
cli_ret "${result}" "balance" ".balance" "0" cli_ret "${result}" "balance" ".balance" "0"
start_ebrelayerC start_ebrelayerC
result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}" -t "coins.bty") result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}" -t "${tokenAddrBty}")
cli_ret "${result}" "balance" ".balance" "5" cli_ret "${result}" "balance" ".balance" "5"
# eth burn # eth burn
result=$(${CLIA} relayer ethereum burn -m 5 -k "${ethReceiverAddrKey2}" -r "${chain33Validator1}" -t "${tokenAddrBty}") result=$(${CLIA} relayer ethereum burn -m 5 -k "${ethReceiverAddrKey2}" -r "${chain33Validator1}" -t "${tokenAddrBty}")
cli_ret "${result}" "burn" cli_ret "${result}" "burn"
result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}" -t "coins.bty") result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}" -t "${tokenAddrBty}")
cli_ret "${result}" "balance" ".balance" "0" cli_ret "${result}" "balance" ".balance" "0"
# eth 等待 10 个区块 # eth 等待 10 个区块
...@@ -466,7 +452,7 @@ function TestETH2Chain33AssetsKill() { ...@@ -466,7 +452,7 @@ function TestETH2Chain33AssetsKill() {
start_ebrelayerD start_ebrelayerD
result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}") result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}")
cli_ret "${result}" "balance" ".balance" $(echo "${balance}+0.1" | bc) cli_ret "${result}" "balance" ".balance" "$(echo "${balance}+0.1" | bc)"
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
} }
...@@ -522,7 +508,7 @@ function TestETH2Chain33Erc20Kill() { ...@@ -522,7 +508,7 @@ function TestETH2Chain33Erc20Kill() {
kill_ebrelayerD kill_ebrelayerD
# chain33 burn 100 # chain33 burn 100
hash=$(${Chain33Cli} send x2ethereum burn -a 100 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q ${tokenAddr} -k "${chain33Validator1}") hash=$(${Chain33Cli} send x2ethereum burn -a 100 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q "${tokenAddr}" -k "${chain33Validator1}")
block_wait "${Chain33Cli}" $((maturityDegree + 2)) block_wait "${Chain33Cli}" $((maturityDegree + 2))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
...@@ -532,6 +518,7 @@ function TestETH2Chain33Erc20Kill() { ...@@ -532,6 +518,7 @@ function TestETH2Chain33Erc20Kill() {
eth_block_wait 2 eth_block_wait 2
start_ebrelayerC start_ebrelayerC
start_ebrelayerD
result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}" -t "${tokenAddr}") result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}" -t "${tokenAddr}")
cli_ret "${result}" "balance" ".balance" "100" cli_ret "${result}" "balance" ".balance" "100"
...@@ -565,9 +552,9 @@ function AllRelayerMainTest() { ...@@ -565,9 +552,9 @@ function AllRelayerMainTest() {
TestETH2Chain33Erc20 TestETH2Chain33Erc20
# kill relayer and start relayer # kill relayer and start relayer
# TestChain33ToEthAssetsKill # TestChain33ToEthAssetsKill
# TestETH2Chain33AssetsKill # TestETH2Chain33AssetsKill
# TestETH2Chain33Erc20Kill # TestETH2Chain33Erc20Kill
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
} }
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck disable=SC2128
# shellcheck source=/dev/null
# shellcheck disable=SC2178
set -x set -x
source "./publicTest.sh" source "./publicTest.sh"
...@@ -9,8 +12,6 @@ Chain33_CLI="" ...@@ -9,8 +12,6 @@ Chain33_CLI=""
Ethsender="0xa4ea64a583f6e51c3799335b28a8f0529570a635" Ethsender="0xa4ea64a583f6e51c3799335b28a8f0529570a635"
ethSender0PrivateKey="3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
privateKeys[0]="8656d2bc732a8a816a461ba5e2d8aac7c7f85c26a813df30d5327210465eb230" privateKeys[0]="8656d2bc732a8a816a461ba5e2d8aac7c7f85c26a813df30d5327210465eb230"
privateKeys[1]="3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e" privateKeys[1]="3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
privateKeys[2]="1385016736f7379884763f4a39811d1391fa156a7ca017be6afffa52bb327695" privateKeys[2]="1385016736f7379884763f4a39811d1391fa156a7ca017be6afffa52bb327695"
...@@ -28,6 +29,8 @@ ethAddress[5]="0xA4Ea64a583F6e51C3799335b28a8F0529570A635" ...@@ -28,6 +29,8 @@ ethAddress[5]="0xA4Ea64a583F6e51C3799335b28a8F0529570A635"
ethAddress[6]="0x0C05bA5c230fDaA503b53702aF1962e08D0C60BF" ethAddress[6]="0x0C05bA5c230fDaA503b53702aF1962e08D0C60BF"
maturityDegree=10 maturityDegree=10
tokenAddr=""
tokenAddrBty=""
loop_send_lock_eth() { loop_send_lock_eth() {
#while 遍历数组 #while 遍历数组
...@@ -39,7 +42,8 @@ loop_send_lock_eth() { ...@@ -39,7 +42,8 @@ loop_send_lock_eth() {
while [[ i -lt ${#privateKeys[@]} ]]; do while [[ i -lt ${#privateKeys[@]} ]]; do
preEthBalance[$i]=$(curl -ksd '{"jsonrpc":"2.0","method":"eth_getBalance","params":["'${ethAddress[i]}'", "latest"],"id":1}' http://localhost:7545 | jq -r ".result") preEthBalance[$i]=$(curl -ksd '{"jsonrpc":"2.0","method":"eth_getBalance","params":["'${ethAddress[i]}'", "latest"],"id":1}' http://localhost:7545 | jq -r ".result")
ethTxHash=$(${CLIA} relayer ethereum lock-async -m 1 -k "${privateKeys[i]}" -r 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv) ethTxHash=$(${CLIA} relayer ethereum lock-async -m 1 -k "${privateKeys[i]}" -r 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv)
echo ${i} "lock-async tx hash:" ${ethTxHash} echo ${i} "lock-async tx hash:" "${ethTxHash}"
# shellcheck disable=SC2219
let i++ let i++
done done
...@@ -49,11 +53,12 @@ loop_send_lock_eth() { ...@@ -49,11 +53,12 @@ loop_send_lock_eth() {
while [[ i -lt ${#privateKeys[@]} ]]; do while [[ i -lt ${#privateKeys[@]} ]]; do
nowEthBalance=$(curl -ksd '{"jsonrpc":"2.0","method":"eth_getBalance","params":["'${ethAddress[i]}'", "latest"],"id":1}' http://localhost:7545 | jq -r ".result") nowEthBalance=$(curl -ksd '{"jsonrpc":"2.0","method":"eth_getBalance","params":["'${ethAddress[i]}'", "latest"],"id":1}' http://localhost:7545 | jq -r ".result")
res=$((preEthBalance[i] - nowEthBalance)) res=$((preEthBalance[i] - nowEthBalance))
echo ${i} "preBalance" ${preEthBalance[i]} "nowBalance" ${nowEthBalance} "diff" ${res} echo ${i} "preBalance" "${preEthBalance[i]}" "nowBalance" "${nowEthBalance}" "diff" ${res}
if [[ $res -le 100000000000000000 ]]; then if [[ $res -le 100000000000000000 ]]; then
echo -e "${RED}error number, expect greater than 100000000000000000, get ${res}${NOC}" echo -e "${RED}error number, expect greater than 100000000000000000, get ${res}${NOC}"
exit 1 exit 1
fi fi
# shellcheck disable=SC2219
let i++ let i++
done done
...@@ -72,7 +77,8 @@ loop_send_burn_eth() { ...@@ -72,7 +77,8 @@ loop_send_burn_eth() {
while [[ i -lt ${#privateKeys[@]} ]]; do while [[ i -lt ${#privateKeys[@]} ]]; do
preEthBalance[$i]=$(curl -ksd '{"jsonrpc":"2.0","method":"eth_getBalance","params":["'${ethAddress[i]}'", "latest"],"id":1}' http://localhost:7545 | jq -r ".result") preEthBalance[$i]=$(curl -ksd '{"jsonrpc":"2.0","method":"eth_getBalance","params":["'${ethAddress[i]}'", "latest"],"id":1}' http://localhost:7545 | jq -r ".result")
ethTxHash=$(${Chain33_CLI} send x2ethereum burn -a 1 -r ${ethAddress[i]} -t eth -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv) ethTxHash=$(${Chain33_CLI} send x2ethereum burn -a 1 -r ${ethAddress[i]} -t eth -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv)
echo ${i} "burn chain33 tx hash:" ${ethTxHash} echo ${i} "burn chain33 tx hash:" "${ethTxHash}"
# shellcheck disable=SC2219
let i++ let i++
done done
...@@ -82,11 +88,12 @@ loop_send_burn_eth() { ...@@ -82,11 +88,12 @@ loop_send_burn_eth() {
while [[ i -lt ${#privateKeys[@]} ]]; do while [[ i -lt ${#privateKeys[@]} ]]; do
nowEthBalance=$(curl -ksd '{"jsonrpc":"2.0","method":"eth_getBalance","params":["'${ethAddress[i]}'", "latest"],"id":1}' http://localhost:7545 | jq -r ".result") nowEthBalance=$(curl -ksd '{"jsonrpc":"2.0","method":"eth_getBalance","params":["'${ethAddress[i]}'", "latest"],"id":1}' http://localhost:7545 | jq -r ".result")
res=$((nowEthBalance - preEthBalance[i])) res=$((nowEthBalance - preEthBalance[i]))
echo ${i} "preBalance" ${preEthBalance[i]} "nowBalance" ${nowEthBalance} "diff" ${res} echo ${i} "preBalance" "${preEthBalance[i]}" "nowBalance" "${nowEthBalance}" "diff" ${res}
if [[ $res -gt 1000000000000000000 ]]; then if [[ $res -gt 1000000000000000000 ]]; then
echo -e "${RED}error number, expect greater than 1000000000000000000, get ${res}${NOC}" echo -e "${RED}error number, expect greater than 1000000000000000000, get ${res}${NOC}"
exit 1 exit 1
fi fi
# shellcheck disable=SC2219
let i++ let i++
done done
nowChain33Balance=$(${Chain33_CLI} x2ethereum balance -s 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -t eth | jq ".res" | jq ".[]" | jq ".balance" | sed 's/\"//g') nowChain33Balance=$(${Chain33_CLI} x2ethereum balance -s 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -t eth | jq ".res" | jq ".[]" | jq ".balance" | sed 's/\"//g')
...@@ -106,7 +113,8 @@ loop_send_lock_bty() { ...@@ -106,7 +113,8 @@ loop_send_lock_bty() {
while [[ i -lt ${#privateKeys[@]} ]]; do 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 "${tokenAddrBty}" | jq -r ".balance")
ethTxHash=$(${Chain33_CLI} send x2ethereum lock -q "${tokenAddrBty}" -a 1 -r ${ethAddress[i]} -t coins.bty -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv) 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} echo ${i} "lock chain33 tx hash:" "${ethTxHash}"
# shellcheck disable=SC2219
let i++ let i++
done done
...@@ -116,8 +124,9 @@ loop_send_lock_bty() { ...@@ -116,8 +124,9 @@ loop_send_lock_bty() {
while [[ i -lt ${#privateKeys[@]} ]]; do 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 "${tokenAddrBty}" | jq -r ".balance")
res=$((nowEthBalance - preEthBalance[i])) res=$((nowEthBalance - preEthBalance[i]))
echo ${i} "preBalance" ${preEthBalance[i]} "nowBalance" ${nowEthBalance} "diff" ${res} echo ${i} "preBalance" "${preEthBalance[i]}" "nowBalance" "${nowEthBalance}" "diff" ${res}
check_number "${res}" 1 check_number "${res}" 1
# shellcheck disable=SC2219
let i++ let i++
done done
nowChain33Balance=$(${Chain33_CLI} account balance -a 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -e x2ethereum | jq -r ".balance" | sed 's/\"//g') nowChain33Balance=$(${Chain33_CLI} account balance -a 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -e x2ethereum | jq -r ".balance" | sed 's/\"//g')
...@@ -139,7 +148,8 @@ loop_send_burn_bty() { ...@@ -139,7 +148,8 @@ loop_send_burn_bty() {
preEthBalance[$i]=$(${CLIA} relayer ethereum balance -o "${ethAddress[i]}" -t "${tokenAddrBty}" | jq -r ".balance") preEthBalance[$i]=$(${CLIA} relayer ethereum balance -o "${ethAddress[i]}" -t "${tokenAddrBty}" | jq -r ".balance")
approveTxHash=$(${CLIA} relayer ethereum approve -m 1 -k "${privateKeys[i]}" -t "${tokenAddrBty}") 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}") ethTxHash=$(${CLIA} relayer ethereum burn-async -m 1 -k "${privateKeys[i]}" -r 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -t "${tokenAddrBty}")
echo ${i} "burn-async tx hash:" ${ethTxHash} echo ${i} "burn-async tx hash:" "${ethTxHash}"
# shellcheck disable=SC2219
let i++ let i++
done done
...@@ -149,8 +159,9 @@ loop_send_burn_bty() { ...@@ -149,8 +159,9 @@ loop_send_burn_bty() {
while [[ i -lt ${#privateKeys[@]} ]]; do 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 "${tokenAddrBty}" | jq -r ".balance")
res=$((preEthBalance[i] - nowEthBalance)) res=$((preEthBalance[i] - nowEthBalance))
echo ${i} "preBalance" ${preEthBalance[i]} "nowBalance" ${nowEthBalance} "diff" ${res} echo ${i} "preBalance" "${preEthBalance[i]}" "nowBalance" "${nowEthBalance}" "diff" ${res}
check_number "${res}" 1 check_number "${res}" 1
# shellcheck disable=SC2219
let i++ let i++
done done
nowChain33Balance=$(${Chain33_CLI} account balance -a 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -e x2ethereum | jq -r ".balance" | sed 's/\"//g') nowChain33Balance=$(${Chain33_CLI} account balance -a 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -e x2ethereum | jq -r ".balance" | sed 's/\"//g')
...@@ -170,11 +181,12 @@ loop_send_lock_erc20() { ...@@ -170,11 +181,12 @@ loop_send_lock_erc20() {
preEthBalance=$(${CLIA} relayer ethereum balance -o "${Ethsender}" -t "${tokenAddr}" | jq -r ".balance") preEthBalance=$(${CLIA} relayer ethereum balance -o "${Ethsender}" -t "${tokenAddr}" | jq -r ".balance")
approveTxHash=$(${CLIA} relayer ethereum approve -m 10 -k "${privateKeys[5]}" -t "${tokenAddr}") approveTxHash=$(${CLIA} relayer ethereum approve -m 10 -k "${privateKeys[5]}" -t "${tokenAddr}")
echo ${i} "lock-async erc20 approve tx hash:" ${approveTxHash} echo ${i} "lock-async erc20 approve tx hash:" "${approveTxHash}"
while [[ i -lt ${#privateKeys[@]} ]]; do while [[ i -lt ${#privateKeys[@]} ]]; do
ethTxHash=$(${CLIA} relayer ethereum lock-async -m 1 -k "${privateKeys[5]}" -r 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -t "${tokenAddr}") ethTxHash=$(${CLIA} relayer ethereum lock-async -m 1 -k "${privateKeys[5]}" -r 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -t "${tokenAddr}")
echo ${i} "lock-async erc20 tx hash:" ${ethTxHash} echo ${i} "lock-async erc20 tx hash:" "${ethTxHash}"
# shellcheck disable=SC2219
let i++ let i++
done done
...@@ -182,7 +194,7 @@ loop_send_lock_erc20() { ...@@ -182,7 +194,7 @@ loop_send_lock_erc20() {
nowEthBalance=$(${CLIA} relayer ethereum balance -o "${Ethsender}" -t "${tokenAddr}" | jq -r ".balance") nowEthBalance=$(${CLIA} relayer ethereum balance -o "${Ethsender}" -t "${tokenAddr}" | jq -r ".balance")
res=$((preEthBalance - nowEthBalance)) res=$((preEthBalance - nowEthBalance))
echo ${i} "preBalance" ${preEthBalance} "nowBalance" ${nowEthBalance} "diff" ${res} echo ${i} "preBalance" "${preEthBalance}" "nowBalance" "${nowEthBalance}" "diff" ${res}
check_number "${diff}" 7 check_number "${diff}" 7
nowChain33Balance=$(${Chain33_CLI} x2ethereum balance -s 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -t testc | jq ".res" | jq ".[]" | jq ".balance" | sed 's/\"//g') nowChain33Balance=$(${Chain33_CLI} x2ethereum balance -s 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -t testc | jq ".res" | jq ".[]" | jq ".balance" | sed 's/\"//g')
...@@ -202,7 +214,8 @@ loop_send_burn_erc20() { ...@@ -202,7 +214,8 @@ loop_send_burn_erc20() {
while [[ i -lt ${#privateKeys[@]} ]]; do 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 "${tokenAddr}" | jq -r ".balance")
ethTxHash=$(${Chain33_CLI} send x2ethereum burn -a 1 -r ${ethAddress[i]} -t testc -q "${tokenAddr}" -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv) ethTxHash=$(${Chain33_CLI} send x2ethereum burn -a 1 -r ${ethAddress[i]} -t testc -q "${tokenAddr}" -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv)
echo ${i} "burn chain33 tx hash:" ${ethTxHash} echo ${i} "burn chain33 tx hash:" "${ethTxHash}"
# shellcheck disable=SC2219
let i++ let i++
done done
...@@ -212,8 +225,9 @@ loop_send_burn_erc20() { ...@@ -212,8 +225,9 @@ loop_send_burn_erc20() {
while [[ i -lt ${#privateKeys[@]} ]]; do 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 "${tokenAddr}" | jq -r ".balance")
res=$((nowEthBalance - preEthBalance[i])) res=$((nowEthBalance - preEthBalance[i]))
echo ${i} "preBalance" ${preEthBalance[i]} "nowBalance" ${nowEthBalance} "diff" ${res} echo ${i} "preBalance" "${preEthBalance[i]}" "nowBalance" "${nowEthBalance}" "diff" ${res}
check_number "${res}" 1 check_number "${res}" 1
# shellcheck disable=SC2219
let i++ let i++
done done
......
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck disable=SC2128
# shellcheck source=/dev/null
source "./allRelayerTest.sh" source "./allRelayerTest.sh"
source "./perf_test.sh" source "./perf_test.sh"
......
...@@ -21,7 +21,6 @@ func Chain33RelayerCmd() *cobra.Command { ...@@ -21,7 +21,6 @@ func Chain33RelayerCmd() *cobra.Command {
ImportPrivateKeyCmd(), ImportPrivateKeyCmd(),
ShowValidatorAddrCmd(), ShowValidatorAddrCmd(),
ShowTxsHashCmd(), ShowTxsHashCmd(),
ShowChain33RelayerStatusCmd(),
) )
return cmd return cmd
...@@ -94,20 +93,3 @@ func showChain33Relayer2EthTxs(cmd *cobra.Command, args []string) { ...@@ -94,20 +93,3 @@ func showChain33Relayer2EthTxs(cmd *cobra.Command, args []string) {
fmt.Println(hash) fmt.Println(hash)
} }
} }
func ShowChain33RelayerStatusCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "status",
Short: "show chain33-relayer status",
Run: showChain33RelayerStatus,
}
return cmd
}
func showChain33RelayerStatus(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
var res ebTypes.RelayerRunStatus
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Manager.ShowChain33RelayerStatus", nil, &res)
ctx.Run()
}
...@@ -20,6 +20,7 @@ func RelayerCmd() *cobra.Command { ...@@ -20,6 +20,7 @@ func RelayerCmd() *cobra.Command {
cmd.AddCommand( cmd.AddCommand(
SetPwdCmd(), SetPwdCmd(),
ChangePwdCmd(),
LockCmd(), LockCmd(),
UnlockCmd(), UnlockCmd(),
Chain33RelayerCmd(), Chain33RelayerCmd(),
...@@ -41,6 +42,33 @@ func SetPwdCmd() *cobra.Command { ...@@ -41,6 +42,33 @@ func SetPwdCmd() *cobra.Command {
} }
func addSetPwdFlags(cmd *cobra.Command) { func addSetPwdFlags(cmd *cobra.Command) {
cmd.Flags().StringP("password", "p", "", "password,[8-30]letter and digit")
cmd.MarkFlagRequired("password")
}
func setPwd(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
newPwd, _ := cmd.Flags().GetString("password")
params := relayerTypes.ReqSetPasswd{
Passphase: newPwd,
}
var res rpctypes.Reply
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Manager.SetPassphase", params, &res)
ctx.Run()
}
// ChangePwdCmd set password
func ChangePwdCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "change_pwd",
Short: "Change password",
Run: changePwd,
}
addChangePwdFlags(cmd)
return cmd
}
func addChangePwdFlags(cmd *cobra.Command) {
cmd.Flags().StringP("old", "o", "", "old password") cmd.Flags().StringP("old", "o", "", "old password")
cmd.MarkFlagRequired("old") cmd.MarkFlagRequired("old")
...@@ -48,16 +76,16 @@ func addSetPwdFlags(cmd *cobra.Command) { ...@@ -48,16 +76,16 @@ func addSetPwdFlags(cmd *cobra.Command) {
cmd.MarkFlagRequired("new") cmd.MarkFlagRequired("new")
} }
func setPwd(cmd *cobra.Command, args []string) { func changePwd(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr") rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
oldPwd, _ := cmd.Flags().GetString("old") oldPwd, _ := cmd.Flags().GetString("old")
newPwd, _ := cmd.Flags().GetString("new") newPwd, _ := cmd.Flags().GetString("new")
params := relayerTypes.ReqSetPasswd{ params := relayerTypes.ReqChangePasswd{
OldPassphase: oldPwd, OldPassphase: oldPwd,
NewPassphase: newPwd, NewPassphase: newPwd,
} }
var res rpctypes.Reply var res rpctypes.Reply
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Manager.SetPassphase", params, &res) ctx := jsonclient.NewRPCCtx(rpcLaddr, "Manager.ChangePassphase", params, &res)
ctx.Run() ctx.Run()
} }
......
...@@ -23,12 +23,10 @@ func EthereumRelayerCmd() *cobra.Command { ...@@ -23,12 +23,10 @@ func EthereumRelayerCmd() *cobra.Command {
cmd.AddCommand( cmd.AddCommand(
ImportChain33PrivateKeyCmd(), ImportChain33PrivateKeyCmd(),
ImportEthValidatorPrivateKeyCmd(),
GenEthPrivateKeyCmd(), GenEthPrivateKeyCmd(),
ShowValidatorsAddrCmd(), ShowValidatorsAddrCmd(),
ShowChain33TxsHashCmd(), ShowChain33TxsHashCmd(),
ShowEthereumTxsHashCmd(), ShowEthereumTxsHashCmd(),
ShowEthRelayerStatusCmd(),
IsValidatorActiveCmd(), IsValidatorActiveCmd(),
ShowOperatorCmd(), ShowOperatorCmd(),
DeployContrctsCmd(), DeployContrctsCmd(),
...@@ -36,7 +34,6 @@ func EthereumRelayerCmd() *cobra.Command { ...@@ -36,7 +34,6 @@ func EthereumRelayerCmd() *cobra.Command {
//////auxiliary/////// //////auxiliary///////
CreateBridgeTokenCmd(), CreateBridgeTokenCmd(),
CreateEthereumTokenCmd(), CreateEthereumTokenCmd(),
MakeNewProphecyClaimCmd(),
GetBalanceCmd(), GetBalanceCmd(),
IsProphecyPendingCmd(), IsProphecyPendingCmd(),
MintErc20Cmd(), MintErc20Cmd(),
...@@ -80,26 +77,6 @@ func importChain33Privatekey(cmd *cobra.Command, args []string) { ...@@ -80,26 +77,6 @@ func importChain33Privatekey(cmd *cobra.Command, args []string) {
ctx.Run() ctx.Run()
} }
func ImportEthValidatorPrivateKeyCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "import_ethprivatekey",
Short: "import ethereum's validator private key ",
Run: importEthValidtorPrivatekey,
}
addImportPrivateKeyFlags(cmd)
return cmd
}
func importEthValidtorPrivatekey(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
privateKey, _ := cmd.Flags().GetString("key")
params := privateKey
var res rpctypes.Reply
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Manager.ImportEthValidatorPrivateKey", params, &res)
ctx.Run()
}
func GenEthPrivateKeyCmd() *cobra.Command { func GenEthPrivateKeyCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "create_eth_key", Use: "create_eth_key",
...@@ -181,23 +158,6 @@ func showEthTxs(cmd *cobra.Command, args []string) { ...@@ -181,23 +158,6 @@ func showEthTxs(cmd *cobra.Command, args []string) {
} }
} }
func ShowEthRelayerStatusCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "status",
Short: "show ethereum-relayer status",
Run: showEthRelayerStatus,
}
return cmd
}
func showEthRelayerStatus(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
var res ebTypes.RelayerRunStatus
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Manager.ShowEthRelayerStatus", nil, &res)
ctx.Run()
}
func IsValidatorActiveCmd() *cobra.Command { func IsValidatorActiveCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "active", Use: "active",
...@@ -607,70 +567,6 @@ func ShowBridgeRegistryAddr(cmd *cobra.Command, args []string) { ...@@ -607,70 +567,6 @@ func ShowBridgeRegistryAddr(cmd *cobra.Command, args []string) {
ctx.Run() ctx.Run()
} }
func MakeNewProphecyClaimCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "prophecy",
Short: "Make New Prophecy Claim",
Run: MakeNewProphecyClaim,
}
MakeNewProphecyClaimFlags(cmd)
return cmd
}
func MakeNewProphecyClaimFlags(cmd *cobra.Command) {
cmd.Flags().Uint32P("claim", "c", uint32(1), "claim type, 1 denote burn, and 2 denotes lock")
_ = cmd.MarkFlagRequired("claim")
cmd.Flags().StringP("chain33Sender", "a", "", "Chain33Sender")
_ = cmd.MarkFlagRequired("chain33Sender")
cmd.Flags().StringP("token", "t", "", "token address,optional, nil for ETH")
cmd.Flags().StringP("symbol", "s", "", "token symbol")
_ = cmd.MarkFlagRequired("symbol")
cmd.Flags().StringP("ethReceiver", "r", "", "eth Receiver")
_ = cmd.MarkFlagRequired("ethReceiver")
cmd.Flags().Float64P("amount", "m", 0, "amount")
_ = cmd.MarkFlagRequired("amount")
cmd.Flags().StringP("hash", "i", "", "chain33 tx hash")
_ = cmd.MarkFlagRequired("hash")
}
func MakeNewProphecyClaim(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
claimType, _ := cmd.Flags().GetUint32("claim")
if claimType != uint32(1) && claimType != uint32(2) {
fmt.Println("Wrong claim type")
return
}
chain33Sender, _ := cmd.Flags().GetString("chain33Sender")
tokenAddr, _ := cmd.Flags().GetString("token")
symbol, _ := cmd.Flags().GetString("symbol")
ethReceiver, _ := cmd.Flags().GetString("ethReceiver")
amount, _ := cmd.Flags().GetFloat64("amount")
txhash, _ := cmd.Flags().GetString("hash")
nodeAddr, _ := cmd.Flags().GetString("node_addr")
d, err := utils.GetDecimalsFromNode(tokenAddr, nodeAddr)
if err != nil {
fmt.Println("get decimals error")
return
}
realAmount := types.ToWei(amount, d)
para := ebTypes.NewProphecyClaim{
ClaimType: claimType,
Chain33Sender: chain33Sender,
TokenAddr: tokenAddr,
Symbol: symbol,
EthReceiver: ethReceiver,
Amount: realAmount.String(),
TxHash: txhash,
}
var res rpctypes.Reply
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Manager.MakeNewProphecyClaim", para, &res)
ctx.Run()
}
func GetBalanceCmd() *cobra.Command { func GetBalanceCmd() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "balance", Use: "balance",
......
...@@ -53,3 +53,57 @@ func PrepareTestEnv() (bind.ContractBackend, *ethtxs.DeployPara) { ...@@ -53,3 +53,57 @@ func PrepareTestEnv() (bind.ContractBackend, *ethtxs.DeployPara) {
return sim, para return sim, para
} }
func PrepareTestEnvironment() (bind.ContractBackend, *ethtxs.DeployPara) {
var deployerPrivateKey = "8656d2bc732a8a816a461ba5e2d8aac7c7f85c26a813df30d5327210465eb230"
var ethValidatorAddrKeyA = "3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
var ethValidatorAddrKeyB = "a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400"
var ethValidatorAddrKeyC = "bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e"
var ethValidatorAddrKeyD = "c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b"
genesiskey, _ := crypto.HexToECDSA(deployerPrivateKey)
alloc := make(core.GenesisAlloc)
genesisAddr := crypto.PubkeyToAddress(genesiskey.PublicKey)
genesisAccount := core.GenesisAccount{
Balance: big.NewInt(10000000000 * 10000),
PrivateKey: crypto.FromECDSA(genesiskey),
}
alloc[genesisAddr] = genesisAccount
ethValidatorAddrKey := make([]string, 0)
ethValidatorAddrKey = append(ethValidatorAddrKey, ethValidatorAddrKeyA)
ethValidatorAddrKey = append(ethValidatorAddrKey, ethValidatorAddrKeyB)
ethValidatorAddrKey = append(ethValidatorAddrKey, ethValidatorAddrKeyC)
ethValidatorAddrKey = append(ethValidatorAddrKey, ethValidatorAddrKeyD)
var InitValidators []common.Address
var ValidatorPriKey []*ecdsa.PrivateKey
for _, v := range ethValidatorAddrKey {
key, _ := crypto.HexToECDSA(v)
addr := crypto.PubkeyToAddress(key.PublicKey)
InitValidators = append(InitValidators, addr)
ValidatorPriKey = append(ValidatorPriKey, key)
account := core.GenesisAccount{
Balance: big.NewInt(100000000 * 100),
PrivateKey: crypto.FromECDSA(key),
}
alloc[addr] = account
}
gasLimit := uint64(100000000)
sim := backends.NewSimulatedBackend(alloc, gasLimit)
InitPowers := []*big.Int{big.NewInt(80), big.NewInt(10), big.NewInt(10), big.NewInt(10)}
para := &ethtxs.DeployPara{
DeployPrivateKey: genesiskey,
Deployer: genesisAddr,
Operator: genesisAddr,
InitValidators: InitValidators,
ValidatorPriKey: ValidatorPriKey,
InitPowers: InitPowers,
}
return sim, para
}
...@@ -2,7 +2,6 @@ package ethtxs ...@@ -2,7 +2,6 @@ package ethtxs
import ( import (
"context" "context"
"crypto/ecdsa"
"errors" "errors"
"math/big" "math/big"
...@@ -442,42 +441,3 @@ func LockEthErc20AssetAsync(ownerPrivateKeyStr, tokenAddrStr, chain33Receiver st ...@@ -442,42 +441,3 @@ func LockEthErc20AssetAsync(ownerPrivateKeyStr, tokenAddrStr, chain33Receiver st
} }
return tx.Hash().String(), nil return tx.Hash().String(), nil
} }
/////////////////NewProphecyClaim////////////////
func MakeNewProphecyClaim(newProphecyClaimPara *NewProphecyClaimPara, backend bind.ContractBackend, privateKey *ecdsa.PrivateKey, transactor common.Address, x2EthContracts *X2EthContracts) (string, error) {
var prepareDone bool
authVali, err := PrepareAuth(backend, privateKey, transactor)
if nil != err {
return "", err
}
prepareDone = true
defer func() {
if err != nil && prepareDone {
_, _ = revokeNonce(transactor)
}
}()
amount := newProphecyClaimPara.Amount
ethReceiver := newProphecyClaimPara.EthReceiver
// Generate rawHash using ProphecyClaim data
claimID := crypto.Keccak256Hash(newProphecyClaimPara.Txhash, newProphecyClaimPara.Chain33Sender, newProphecyClaimPara.EthReceiver.Bytes(), newProphecyClaimPara.TokenAddr.Bytes(), amount.Bytes())
// Sign the hash using the active validator's private key
signature, err := SignClaim4Eth(claimID, privateKey)
if nil != err {
return "", err
}
tx, err := x2EthContracts.Oracle.NewOracleClaim(authVali, newProphecyClaimPara.ClaimType, newProphecyClaimPara.Chain33Sender, ethReceiver, newProphecyClaimPara.TokenAddr, newProphecyClaimPara.Symbol, amount, claimID, signature)
if nil != err {
return "", err
}
err = waitEthTxFinished(backend.(*ethclient.Client), tx.Hash(), "MakeNewProphecyClaim")
if nil != err {
return "", err
}
return tx.Hash().String(), nil
}
...@@ -165,9 +165,9 @@ func DeployAndInit(backend bind.ContractBackend, para *DeployPara) (*X2EthContra ...@@ -165,9 +165,9 @@ func DeployAndInit(backend bind.ContractBackend, para *DeployPara) (*X2EthContra
///////////////////////////////////// /////////////////////////////////////
sim, isSim := backend.(*backends.SimulatedBackend) sim, isSim := backend.(*backends.SimulatedBackend)
if isSim { if isSim {
fmt.Print("Use the simulator") fmt.Println("Use the simulator")
} else { } else {
fmt.Print("Use the actual Ethereum") fmt.Println("Use the actual Ethereum")
} }
x2EthContracts.Valset, deployInfo.Valset, err = DeployValset(backend, para.DeployPrivateKey, para.Deployer, para.Operator, para.InitValidators, para.InitPowers) x2EthContracts.Valset, deployInfo.Valset, err = DeployValset(backend, para.DeployPrivateKey, para.Deployer, para.Operator, para.InitValidators, para.InitPowers)
......
...@@ -7,8 +7,6 @@ import ( ...@@ -7,8 +7,6 @@ import (
"math/big" "math/big"
"sync" "sync"
"time" "time"
ebrelayerTypes "github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer/types"
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
...@@ -65,19 +63,6 @@ func prefixMessage(message common.Hash, key *ecdsa.PrivateKey) ([]byte, []byte) ...@@ -65,19 +63,6 @@ func prefixMessage(message common.Hash, key *ecdsa.PrivateKey) ([]byte, []byte)
return sig, prefixed return sig, prefixed
} }
// LoadSender : uses the validator's private key to load the validator's address
func LoadSender(privateKey *ecdsa.PrivateKey) (address common.Address, err error) {
// Parse public key
publicKey := privateKey.Public()
publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey)
if !ok {
return common.Address{}, ebrelayerTypes.ErrPublicKeyType
}
fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA)
return fromAddress, nil
}
func getNonce(sender common.Address, backend bind.ContractBackend) (*big.Int, error) { func getNonce(sender common.Address, backend bind.ContractBackend) (*big.Int, error) {
if nonceMutex, exist := addr2Nonce[sender]; exist { if nonceMutex, exist := addr2Nonce[sender]; exist {
nonceMutex.rw.Lock() nonceMutex.rw.Lock()
......
...@@ -75,7 +75,7 @@ func (chain33Relayer *Relayer4Chain33) StoreAccountWithNewPassphase(newPassphras ...@@ -75,7 +75,7 @@ func (chain33Relayer *Relayer4Chain33) StoreAccountWithNewPassphase(newPassphras
accountInfo, err := chain33Relayer.db.Get(chain33AccountKey) accountInfo, err := chain33Relayer.db.Get(chain33AccountKey)
if nil != err { if nil != err {
relayerLog.Info("StoreAccountWithNewPassphase", "pls check account is created already, err", err) relayerLog.Info("StoreAccountWithNewPassphase", "pls check account is created already, err", err)
return nil return err
} }
ethAccount := &x2ethTypes.Account4Relayer{} ethAccount := &x2ethTypes.Account4Relayer{}
if err := chain33Types.Decode(accountInfo, ethAccount); nil != err { if err := chain33Types.Decode(accountInfo, ethAccount); nil != err {
...@@ -114,7 +114,6 @@ func (chain33Relayer *Relayer4Chain33) RestorePrivateKeys(passphrase string) err ...@@ -114,7 +114,6 @@ func (chain33Relayer *Relayer4Chain33) RestorePrivateKeys(passphrase string) err
return nil return nil
} }
func (chain33Relayer *Relayer4Chain33) UpdatePrivateKey(Passphrase, privateKey string) error { //func (chain33Relayer *Relayer4Chain33) UpdatePrivateKey(Passphrase, privateKey string) error {
// return nil
return nil //}
}
...@@ -32,14 +32,14 @@ import ( ...@@ -32,14 +32,14 @@ import (
var relayerLog = log.New("module", "chain33_relayer") var relayerLog = log.New("module", "chain33_relayer")
type Relayer4Chain33 struct { type Relayer4Chain33 struct {
syncTxReceipts *syncTx.TxReceipts syncTxReceipts *syncTx.TxReceipts
ethBackend bind.ContractBackend ethBackend bind.ContractBackend
rpcLaddr string //用户向指定的blockchain节点进行rpc调用 rpcLaddr string //用户向指定的blockchain节点进行rpc调用
fetchHeightPeriodMs int64 fetchHeightPeriodMs int64
db dbm.DB db dbm.DB
lastHeight4Tx int64 //等待被处理的具有相应的交易回执的高度 lastHeight4Tx int64 //等待被处理的具有相应的交易回执的高度
matDegree int32 //成熟度 heightSync2App matDegress height matDegree int32 //成熟度 heightSync2App matDegress height
passphase string //passphase string
privateKey4Ethereum *ecdsa.PrivateKey privateKey4Ethereum *ecdsa.PrivateKey
ethSender ethCommon.Address ethSender ethCommon.Address
bridgeRegistryAddr ethCommon.Address bridgeRegistryAddr ethCommon.Address
...@@ -49,7 +49,6 @@ type Relayer4Chain33 struct { ...@@ -49,7 +49,6 @@ type Relayer4Chain33 struct {
ctx context.Context ctx context.Context
rwLock sync.RWMutex rwLock sync.RWMutex
unlock chan int unlock chan int
status int32
} }
// StartChain33Relayer : initializes a relayer which witnesses events on the chain33 network and relays them to Ethereum // StartChain33Relayer : initializes a relayer which witnesses events on the chain33 network and relays them to Ethereum
...@@ -85,32 +84,11 @@ func StartChain33Relayer(ctx context.Context, syncTxConfig *ebTypes.SyncTxConfig ...@@ -85,32 +84,11 @@ func StartChain33Relayer(ctx context.Context, syncTxConfig *ebTypes.SyncTxConfig
return relayer return relayer
} }
func (chain33Relayer *Relayer4Chain33) SetPassphase(passphase string) {
chain33Relayer.rwLock.Lock()
chain33Relayer.passphase = passphase
chain33Relayer.rwLock.Unlock()
}
func (chain33Relayer *Relayer4Chain33) QueryTxhashRelay2Eth() ebTypes.Txhashes { func (chain33Relayer *Relayer4Chain33) QueryTxhashRelay2Eth() ebTypes.Txhashes {
txhashs := utils.QueryTxhashes([]byte(chain33ToEthBurnLockTxHashPrefix), chain33Relayer.db) txhashs := utils.QueryTxhashes([]byte(chain33ToEthBurnLockTxHashPrefix), chain33Relayer.db)
return ebTypes.Txhashes{Txhash: txhashs} return ebTypes.Txhashes{Txhash: txhashs}
} }
func (chain33Relayer *Relayer4Chain33) GetRunningStatus() (relayerRunStatus *ebTypes.RelayerRunStatus) {
relayerRunStatus = &ebTypes.RelayerRunStatus{}
chain33Relayer.rwLock.RLock()
relayerRunStatus.Status = chain33Relayer.status
chain33Relayer.rwLock.RUnlock()
if relayerRunStatus.Status == ebTypes.StatusPending {
if nil == chain33Relayer.privateKey4Ethereum {
relayerRunStatus.Details = "Ethereum's private key not imported"
}
return
}
relayerRunStatus.Details = "Running"
return
}
func (chain33Relayer *Relayer4Chain33) syncProc(syncCfg *ebTypes.SyncTxReceiptConfig) { func (chain33Relayer *Relayer4Chain33) syncProc(syncCfg *ebTypes.SyncTxReceiptConfig) {
_, _ = fmt.Fprintln(os.Stdout, "Pls unlock or import private key for Chain33 relayer") _, _ = fmt.Fprintln(os.Stdout, "Pls unlock or import private key for Chain33 relayer")
<-chain33Relayer.unlock <-chain33Relayer.unlock
......
...@@ -23,7 +23,6 @@ import ( ...@@ -23,7 +23,6 @@ import (
) )
var ( var (
ethAccountKey = []byte("EthAccount4EthRelayer")
chain33AccountKey = []byte("Chain33Account4EthRelayer") chain33AccountKey = []byte("Chain33Account4EthRelayer")
start = int(1) start = int(1)
) )
...@@ -38,42 +37,31 @@ type Key struct { ...@@ -38,42 +37,31 @@ type Key struct {
} }
func (ethRelayer *Relayer4Ethereum) NewAccount(passphrase string) (privateKeystr, addr string, err error) { func (ethRelayer *Relayer4Ethereum) NewAccount(passphrase string) (privateKeystr, addr string, err error) {
var privateKey *ecdsa.PrivateKey _, privateKeystr, addr, err = newKeyAndStore(ethRelayer.db, crand.Reader, passphrase)
privateKey, privateKeystr, addr, err = newKeyAndStore(ethRelayer.db, crand.Reader, passphrase)
if err != nil { if err != nil {
return "", "", err return "", "", err
} }
ethRelayer.SetPrivateKey4Ethereum(privateKey)
return return
} }
func (ethRelayer *Relayer4Ethereum) GetAccount(passphrase string) (privateKey, addr string, err error) { func (ethRelayer *Relayer4Ethereum) GetAccount(passphrase string) (privateKey, addr string, err error) {
accountInfo, err := ethRelayer.db.Get(ethAccountKey) accountInfo, err := ethRelayer.db.Get(chain33AccountKey)
if nil != err { if nil != err {
return "", "", err return "", "", err
} }
ethAccount := &x2ethTypes.Account4Relayer{} Chain33Account := &x2ethTypes.Account4Relayer{}
if err := chain33Types.Decode(accountInfo, ethAccount); nil != err { if err := chain33Types.Decode(accountInfo, Chain33Account); nil != err {
return "", "", err return "", "", err
} }
decryptered := wcom.CBCDecrypterPrivkey([]byte(passphrase), ethAccount.Privkey) decryptered := wcom.CBCDecrypterPrivkey([]byte(passphrase), Chain33Account.Privkey)
privateKey = chain33Common.ToHex(decryptered) privateKey = chain33Common.ToHex(decryptered)
addr = ethAccount.Addr addr = Chain33Account.Addr
return return
} }
func (ethRelayer *Relayer4Ethereum) GetValidatorAddr() (validators x2ethTypes.ValidatorAddr4EthRelayer, err error) { func (ethRelayer *Relayer4Ethereum) GetValidatorAddr() (validators x2ethTypes.ValidatorAddr4EthRelayer, err error) {
var ethAccountAddr string
var chain33AccountAddr string var chain33AccountAddr string
accountInfo, err := ethRelayer.db.Get(ethAccountKey) accountInfo, err := ethRelayer.db.Get(chain33AccountKey)
if nil == err {
ethAccount := &x2ethTypes.Account4Relayer{}
if err := chain33Types.Decode(accountInfo, ethAccount); nil == err {
ethAccountAddr = ethAccount.Addr
}
}
accountInfo, err = ethRelayer.db.Get(chain33AccountKey)
if nil == err { if nil == err {
ethAccount := &x2ethTypes.Account4Relayer{} ethAccount := &x2ethTypes.Account4Relayer{}
if err := chain33Types.Decode(accountInfo, ethAccount); nil == err { if err := chain33Types.Decode(accountInfo, ethAccount); nil == err {
...@@ -81,40 +69,22 @@ func (ethRelayer *Relayer4Ethereum) GetValidatorAddr() (validators x2ethTypes.Va ...@@ -81,40 +69,22 @@ func (ethRelayer *Relayer4Ethereum) GetValidatorAddr() (validators x2ethTypes.Va
} }
} }
if 0 == len(chain33AccountAddr) && 0 == len(ethAccountAddr) { if 0 == len(chain33AccountAddr) {
return x2ethTypes.ValidatorAddr4EthRelayer{}, x2ethTypes.ErrNoValidatorConfigured return x2ethTypes.ValidatorAddr4EthRelayer{}, x2ethTypes.ErrNoValidatorConfigured
} }
validators = x2ethTypes.ValidatorAddr4EthRelayer{ validators = x2ethTypes.ValidatorAddr4EthRelayer{
EthValidator: ethAccountAddr,
Chain33Validator: chain33AccountAddr, Chain33Validator: chain33AccountAddr,
} }
return return
} }
func (ethRelayer *Relayer4Ethereum) RestorePrivateKeys(passPhase string) (err error) { func (ethRelayer *Relayer4Ethereum) RestorePrivateKeys(passPhase string) (err error) {
accountInfo, err := ethRelayer.db.Get(ethAccountKey) accountInfo, err := ethRelayer.db.Get(chain33AccountKey)
if nil == err {
ethAccount := &x2ethTypes.Account4Relayer{}
if err := chain33Types.Decode(accountInfo, ethAccount); nil == err {
decryptered := wcom.CBCDecrypterPrivkey([]byte(passPhase), ethAccount.Privkey)
privateKey, err := crypto.ToECDSA(decryptered)
if nil != err {
errInfo := fmt.Sprintf("Failed to ToECDSA due to:%s", err.Error())
relayerLog.Info("RestorePrivateKeys", "Failed to ToECDSA:", err.Error())
return errors.New(errInfo)
}
ethRelayer.rwLock.Lock()
ethRelayer.privateKey4Ethereum = privateKey
ethRelayer.rwLock.Unlock()
}
}
accountInfo, err = ethRelayer.db.Get(chain33AccountKey)
if nil == err { if nil == err {
ethAccount := &x2ethTypes.Account4Relayer{} Chain33Account := &x2ethTypes.Account4Relayer{}
if err := chain33Types.Decode(accountInfo, ethAccount); nil == err { if err := chain33Types.Decode(accountInfo, Chain33Account); nil == err {
decryptered := wcom.CBCDecrypterPrivkey([]byte(passPhase), ethAccount.Privkey) decryptered := wcom.CBCDecrypterPrivkey([]byte(passPhase), Chain33Account.Privkey)
var driver secp256k1.Driver var driver secp256k1.Driver
priKey, err := driver.PrivKeyFromBytes(decryptered) priKey, err := driver.PrivKeyFromBytes(decryptered)
if nil != err { if nil != err {
...@@ -128,7 +98,7 @@ func (ethRelayer *Relayer4Ethereum) RestorePrivateKeys(passPhase string) (err er ...@@ -128,7 +98,7 @@ func (ethRelayer *Relayer4Ethereum) RestorePrivateKeys(passPhase string) (err er
} }
} }
if ethRelayer.privateKey4Ethereum != nil && nil != ethRelayer.privateKey4Chain33 { if nil != ethRelayer.privateKey4Chain33 {
ethRelayer.unlockchan <- start ethRelayer.unlockchan <- start
} }
...@@ -136,20 +106,20 @@ func (ethRelayer *Relayer4Ethereum) RestorePrivateKeys(passPhase string) (err er ...@@ -136,20 +106,20 @@ func (ethRelayer *Relayer4Ethereum) RestorePrivateKeys(passPhase string) (err er
} }
func (ethRelayer *Relayer4Ethereum) StoreAccountWithNewPassphase(newPassphrase, oldPassphrase string) error { func (ethRelayer *Relayer4Ethereum) StoreAccountWithNewPassphase(newPassphrase, oldPassphrase string) error {
accountInfo, err := ethRelayer.db.Get(ethAccountKey) accountInfo, err := ethRelayer.db.Get(chain33AccountKey)
if nil != err { if nil != err {
relayerLog.Info("StoreAccountWithNewPassphase", "pls check account is created already, err", err) relayerLog.Info("StoreAccountWithNewPassphase", "pls check account is created already, err", err)
return nil return err
} }
ethAccount := &x2ethTypes.Account4Relayer{} Chain33Account := &x2ethTypes.Account4Relayer{}
if err := chain33Types.Decode(accountInfo, ethAccount); nil != err { if err := chain33Types.Decode(accountInfo, Chain33Account); nil != err {
return err return err
} }
decryptered := wcom.CBCDecrypterPrivkey([]byte(oldPassphrase), ethAccount.Privkey) decryptered := wcom.CBCDecrypterPrivkey([]byte(oldPassphrase), Chain33Account.Privkey)
encryptered := wcom.CBCEncrypterPrivkey([]byte(newPassphrase), decryptered) encryptered := wcom.CBCEncrypterPrivkey([]byte(newPassphrase), decryptered)
ethAccount.Privkey = encryptered Chain33Account.Privkey = encryptered
encodedInfo := chain33Types.Encode(ethAccount) encodedInfo := chain33Types.Encode(Chain33Account)
return ethRelayer.db.SetSync(ethAccountKey, encodedInfo) return ethRelayer.db.SetSync(chain33AccountKey, encodedInfo)
} }
func (ethRelayer *Relayer4Ethereum) ImportChain33PrivateKey(passphrase, privateKeyStr string) error { func (ethRelayer *Relayer4Ethereum) ImportChain33PrivateKey(passphrase, privateKeyStr string) error {
...@@ -164,9 +134,7 @@ func (ethRelayer *Relayer4Ethereum) ImportChain33PrivateKey(passphrase, privateK ...@@ -164,9 +134,7 @@ func (ethRelayer *Relayer4Ethereum) ImportChain33PrivateKey(passphrase, privateK
} }
ethRelayer.privateKey4Chain33 = priKey ethRelayer.privateKey4Chain33 = priKey
if nil != ethRelayer.privateKey4Ethereum { ethRelayer.unlockchan <- start
ethRelayer.unlockchan <- start
}
addr, err := pubKeyToAddress4Bty(priKey.PubKey().Bytes()) addr, err := pubKeyToAddress4Bty(priKey.PubKey().Bytes())
if nil != err { if nil != err {
return err return err
...@@ -181,33 +149,6 @@ func (ethRelayer *Relayer4Ethereum) ImportChain33PrivateKey(passphrase, privateK ...@@ -181,33 +149,6 @@ func (ethRelayer *Relayer4Ethereum) ImportChain33PrivateKey(passphrase, privateK
return ethRelayer.db.SetSync(chain33AccountKey, encodedInfo) return ethRelayer.db.SetSync(chain33AccountKey, encodedInfo)
} }
func (ethRelayer *Relayer4Ethereum) ImportEthValidatorPrivateKey(passphrase, privateKeyStr string) error {
privateKeySli, err := chain33Common.FromHex(privateKeyStr)
if nil != err {
return err
}
privateKeyECDSA, err := crypto.ToECDSA(privateKeySli)
if nil != err {
errInfo := fmt.Sprintf("Failed to ToECDSA due to:%s", err.Error())
relayerLog.Info("RestorePrivateKeys", "Failed to ToECDSA:", err.Error())
return errors.New(errInfo)
}
ethRelayer.rwLock.Lock()
ethRelayer.privateKey4Ethereum = privateKeyECDSA
ethRelayer.rwLock.Unlock()
if nil != ethRelayer.privateKey4Chain33 {
ethRelayer.unlockchan <- start
}
Encryptered := wcom.CBCEncrypterPrivkey([]byte(passphrase), privateKeySli)
ethAccount := &x2ethTypes.Account4Relayer{
Privkey: Encryptered,
Addr: crypto.PubkeyToAddress(privateKeyECDSA.PublicKey).String(),
}
encodedInfo := chain33Types.Encode(ethAccount)
return ethRelayer.db.SetSync(ethAccountKey, encodedInfo)
}
//checksum: first four bytes of double-SHA256. //checksum: first four bytes of double-SHA256.
func checksum(input []byte) (cksum [4]byte) { func checksum(input []byte) (cksum [4]byte) {
h := sha256.New() h := sha256.New()
...@@ -266,8 +207,7 @@ func newKeyAndStore(db dbm.DB, rand io.Reader, passphrase string) (privateKey *e ...@@ -266,8 +207,7 @@ func newKeyAndStore(db dbm.DB, rand io.Reader, passphrase string) (privateKey *e
Privkey: Encryptered, Privkey: Encryptered,
Addr: key.Address.Hex(), Addr: key.Address.Hex(),
} }
encodedInfo := chain33Types.Encode(ethAccount) _ = db
_ = db.SetSync(ethAccountKey, encodedInfo)
privateKeyStr = chain33Common.ToHex(privateKeyBytes) privateKeyStr = chain33Common.ToHex(privateKeyBytes)
addr = ethAccount.Addr addr = ethAccount.Addr
......
...@@ -39,15 +39,12 @@ import ( ...@@ -39,15 +39,12 @@ import (
) )
type Relayer4Ethereum struct { type Relayer4Ethereum struct {
provider string provider string
clientChainID *big.Int clientChainID *big.Int
bridgeRegistryAddr common.Address bridgeRegistryAddr common.Address
//validatorName string db dbm.DB
db dbm.DB
//passphase string
rwLock sync.RWMutex rwLock sync.RWMutex
privateKey4Chain33 chain33Crypto.PrivKey privateKey4Chain33 chain33Crypto.PrivKey
privateKey4Ethereum *ecdsa.PrivateKey
ethValidator common.Address ethValidator common.Address
totalTx4Eth2Chain33 int64 totalTx4Eth2Chain33 int64
totalTx4Chain33ToEth int64 totalTx4Chain33ToEth int64
...@@ -56,7 +53,6 @@ type Relayer4Ethereum struct { ...@@ -56,7 +53,6 @@ type Relayer4Ethereum struct {
maturityDegree int32 maturityDegree int32
fetchHeightPeriodMs int32 fetchHeightPeriodMs int32
eventLogIndex ebTypes.EventLogIndex eventLogIndex ebTypes.EventLogIndex
status int32
backend bind.ContractBackend backend bind.ContractBackend
bridgeBankAddr common.Address bridgeBankAddr common.Address
bridgeBankSub ethereum.Subscription bridgeBankSub ethereum.Subscription
...@@ -88,7 +84,6 @@ func StartEthereumRelayer(rpcURL2Chain33 string, db dbm.DB, provider, registryAd ...@@ -88,7 +84,6 @@ func StartEthereumRelayer(rpcURL2Chain33 string, db dbm.DB, provider, registryAd
db: db, db: db,
unlockchan: make(chan int, 2), unlockchan: make(chan int, 2),
rpcURL2Chain33: rpcURL2Chain33, rpcURL2Chain33: rpcURL2Chain33,
status: ebTypes.StatusPending,
bridgeRegistryAddr: common.HexToAddress(registryAddress), bridgeRegistryAddr: common.HexToAddress(registryAddress),
deployInfo: deploy, deployInfo: deploy,
maturityDegree: degree, maturityDegree: degree,
...@@ -112,34 +107,6 @@ func StartEthereumRelayer(rpcURL2Chain33 string, db dbm.DB, provider, registryAd ...@@ -112,34 +107,6 @@ func StartEthereumRelayer(rpcURL2Chain33 string, db dbm.DB, provider, registryAd
return relayer return relayer
} }
func (ethRelayer *Relayer4Ethereum) SetPrivateKey4Ethereum(privateKey4Ethereum *ecdsa.PrivateKey) {
ethRelayer.rwLock.Lock()
defer ethRelayer.rwLock.Unlock()
ethRelayer.privateKey4Ethereum = privateKey4Ethereum
if ethRelayer.privateKey4Chain33 != nil {
ethRelayer.unlockchan <- start
}
}
func (ethRelayer *Relayer4Ethereum) GetRunningStatus() (relayerRunStatus *ebTypes.RelayerRunStatus) {
relayerRunStatus = &ebTypes.RelayerRunStatus{}
ethRelayer.rwLock.RLock()
relayerRunStatus.Status = ethRelayer.status
ethRelayer.rwLock.RUnlock()
if relayerRunStatus.Status == ebTypes.StatusPending {
if nil == ethRelayer.privateKey4Ethereum {
relayerRunStatus.Details = "Ethereum's private key not imported"
}
if nil == ethRelayer.privateKey4Chain33 {
relayerRunStatus.Details += "\nChain33's private key not imported"
}
return
}
relayerRunStatus.Details = "Running"
return
}
func (ethRelayer *Relayer4Ethereum) recoverDeployPara() (err error) { func (ethRelayer *Relayer4Ethereum) recoverDeployPara() (err error) {
if nil == ethRelayer.deployInfo { if nil == ethRelayer.deployInfo {
return nil return nil
...@@ -162,24 +129,24 @@ func (ethRelayer *Relayer4Ethereum) recoverDeployPara() (err error) { ...@@ -162,24 +129,24 @@ func (ethRelayer *Relayer4Ethereum) recoverDeployPara() (err error) {
func (ethRelayer *Relayer4Ethereum) DeployContrcts() (bridgeRegistry string, err error) { func (ethRelayer *Relayer4Ethereum) DeployContrcts() (bridgeRegistry string, err error) {
bridgeRegistry = "" bridgeRegistry = ""
if nil == ethRelayer.deployInfo { if nil == ethRelayer.deployInfo {
return bridgeRegistry, errors.New("No deploy info configured yet") return bridgeRegistry, errors.New("no deploy info configured yet")
} }
deployPrivateKey, err := crypto.ToECDSA(common.FromHex(ethRelayer.deployInfo.DeployerPrivateKey)) deployPrivateKey, err := crypto.ToECDSA(common.FromHex(ethRelayer.deployInfo.DeployerPrivateKey))
if nil != err { if nil != err {
return bridgeRegistry, err return bridgeRegistry, err
} }
if len(ethRelayer.deployInfo.ValidatorsAddr) != len(ethRelayer.deployInfo.InitPowers) { if len(ethRelayer.deployInfo.ValidatorsAddr) != len(ethRelayer.deployInfo.InitPowers) {
return bridgeRegistry, errors.New("Not same number for validator address and power") return bridgeRegistry, errors.New("not same number for validator address and power")
} }
if len(ethRelayer.deployInfo.ValidatorsAddr) < 3 { if len(ethRelayer.deployInfo.ValidatorsAddr) < 3 {
return bridgeRegistry, errors.New("The number of validator must be not less than 3") return bridgeRegistry, errors.New("the number of validator must be not less than 3")
} }
nilAddr := common.Address{} nilAddr := common.Address{}
//已经设置了注册合约地址,说明已经部署了相关的合约,不再重复部署 //已经设置了注册合约地址,说明已经部署了相关的合约,不再重复部署
if ethRelayer.bridgeRegistryAddr != nilAddr { if ethRelayer.bridgeRegistryAddr != nilAddr {
return bridgeRegistry, errors.New("Contract deployed already") return bridgeRegistry, errors.New("contract deployed already")
} }
var validators []common.Address var validators []common.Address
...@@ -232,7 +199,7 @@ func (ethRelayer *Relayer4Ethereum) GetBalance(tokenAddr, owner string) (string, ...@@ -232,7 +199,7 @@ func (ethRelayer *Relayer4Ethereum) GetBalance(tokenAddr, owner string) (string,
func (ethRelayer *Relayer4Ethereum) ShowBridgeBankAddr() (string, error) { func (ethRelayer *Relayer4Ethereum) ShowBridgeBankAddr() (string, error) {
if nil == ethRelayer.x2EthDeployInfo { if nil == ethRelayer.x2EthDeployInfo {
return "", errors.New("The relayer is not started yes") return "", errors.New("the relayer is not started yes")
} }
return ethRelayer.x2EthDeployInfo.BridgeBank.Address.String(), nil return ethRelayer.x2EthDeployInfo.BridgeBank.Address.String(), nil
...@@ -240,7 +207,7 @@ func (ethRelayer *Relayer4Ethereum) ShowBridgeBankAddr() (string, error) { ...@@ -240,7 +207,7 @@ func (ethRelayer *Relayer4Ethereum) ShowBridgeBankAddr() (string, error) {
func (ethRelayer *Relayer4Ethereum) ShowBridgeRegistryAddr() (string, error) { func (ethRelayer *Relayer4Ethereum) ShowBridgeRegistryAddr() (string, error) {
if nil == ethRelayer.x2EthDeployInfo { if nil == ethRelayer.x2EthDeployInfo {
return "", errors.New("The relayer is not started yes") return "", errors.New("the relayer is not started yes")
} }
return ethRelayer.x2EthDeployInfo.BridgeRegistry.Address.String(), nil return ethRelayer.x2EthDeployInfo.BridgeRegistry.Address.String(), nil
...@@ -262,10 +229,6 @@ func (ethRelayer *Relayer4Ethereum) IsProphecyPending(claimID [32]byte) (bool, e ...@@ -262,10 +229,6 @@ func (ethRelayer *Relayer4Ethereum) IsProphecyPending(claimID [32]byte) (bool, e
return ethtxs.IsProphecyPending(claimID, ethRelayer.ethValidator, ethRelayer.x2EthContracts.Chain33Bridge) return ethtxs.IsProphecyPending(claimID, ethRelayer.ethValidator, ethRelayer.x2EthContracts.Chain33Bridge)
} }
func (ethRelayer *Relayer4Ethereum) MakeNewProphecyClaim(newProphecyClaimPara *ethtxs.NewProphecyClaimPara) (string, error) {
return ethtxs.MakeNewProphecyClaim(newProphecyClaimPara, ethRelayer.backend, ethRelayer.privateKey4Ethereum, ethRelayer.ethValidator, ethRelayer.x2EthContracts)
}
func (ethRelayer *Relayer4Ethereum) CreateBridgeToken(symbol string) (string, error) { func (ethRelayer *Relayer4Ethereum) CreateBridgeToken(symbol string) (string, error) {
return ethtxs.CreateBridgeToken(symbol, ethRelayer.backend, ethRelayer.operatorInfo, ethRelayer.x2EthDeployInfo, ethRelayer.x2EthContracts) return ethtxs.CreateBridgeToken(symbol, ethRelayer.backend, ethRelayer.operatorInfo, ethRelayer.x2EthDeployInfo, ethRelayer.x2EthContracts)
} }
...@@ -370,12 +333,7 @@ func (ethRelayer *Relayer4Ethereum) proc() { ...@@ -370,12 +333,7 @@ func (ethRelayer *Relayer4Ethereum) proc() {
continueFailCount := int32(0) continueFailCount := int32(0)
for range ethRelayer.unlockchan { for range ethRelayer.unlockchan {
relayerLog.Info("Received ethRelayer.unlockchan") relayerLog.Info("Received ethRelayer.unlockchan")
if nil != ethRelayer.privateKey4Ethereum && nil != ethRelayer.privateKey4Chain33 && nilAddr != ethRelayer.bridgeRegistryAddr { if nil != ethRelayer.privateKey4Chain33 && nilAddr != ethRelayer.bridgeRegistryAddr {
ethRelayer.ethValidator, err = ethtxs.LoadSender(ethRelayer.privateKey4Ethereum)
if nil != err {
errinfo := fmt.Sprintf("Failed to load validator for ethereum due to:%s", err.Error())
panic(errinfo)
}
relayerLog.Info("Ethereum relayer starts to run...") relayerLog.Info("Ethereum relayer starts to run...")
ethRelayer.prePareSubscribeEvent() ethRelayer.prePareSubscribeEvent()
//向bridgeBank订阅事件 //向bridgeBank订阅事件
...@@ -592,14 +550,14 @@ func (ethRelayer *Relayer4Ethereum) filterLogEventsProc(logchan chan<- types.Log ...@@ -592,14 +550,14 @@ func (ethRelayer *Relayer4Ethereum) filterLogEventsProc(logchan chan<- types.Log
relayerLog.Info(title, "received logs with number", len(logs), relayerLog.Info(title, "received logs with number", len(logs),
"start height", query.FromBlock.String(), "stop height", query.ToBlock.String()) "start height", query.FromBlock.String(), "stop height", query.ToBlock.String())
for _, log := range logs { for _, logv := range logs {
relayerLog.Info(title, "received log with topics", log.Topics[0].Hex(), "BlockNumber", log.BlockNumber) relayerLog.Info(title, "received log with topics", logv.Topics[0].Hex(), "BlockNumber", logv.BlockNumber)
if _, exist := eventSig[log.Topics[0].Hex()]; !exist { if _, exist := eventSig[logv.Topics[0].Hex()]; !exist {
continue continue
} }
logchan <- log logchan <- logv
relayerLog.Info(title, "get unprocessed log with topic:", log.Topics[0].String(), relayerLog.Info(title, "get unprocessed log with topic:", logv.Topics[0].String(),
"BlockNumber", log.BlockNumber) "BlockNumber", logv.BlockNumber)
} }
if query.ToBlock.Int64() == curHeight { if query.ToBlock.Int64() == curHeight {
......
...@@ -3,7 +3,6 @@ package relayer ...@@ -3,7 +3,6 @@ package relayer
import ( import (
"errors" "errors"
"fmt" "fmt"
"math/big"
"strconv" "strconv"
"sync" "sync"
"sync/atomic" "sync/atomic"
...@@ -12,13 +11,11 @@ import ( ...@@ -12,13 +11,11 @@ import (
"github.com/33cn/chain33/common/log/log15" "github.com/33cn/chain33/common/log/log15"
rpctypes "github.com/33cn/chain33/rpc/types" rpctypes "github.com/33cn/chain33/rpc/types"
chain33Types "github.com/33cn/chain33/types" chain33Types "github.com/33cn/chain33/types"
"github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer/ethtxs"
"github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer/relayer/chain33" "github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer/relayer/chain33"
"github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer/relayer/ethereum" "github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer/relayer/ethereum"
relayerTypes "github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer/types" relayerTypes "github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer/types"
"github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer/utils" "github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer/utils"
"github.com/33cn/plugin/plugin/dapp/x2ethereum/types" "github.com/33cn/plugin/plugin/dapp/x2ethereum/types"
"github.com/ethereum/go-ethereum/common"
lru "github.com/hashicorp/golang-lru" lru "github.com/hashicorp/golang-lru"
) )
...@@ -66,6 +63,52 @@ func NewRelayerManager(chain33Relayer *chain33.Relayer4Chain33, ethRelayer *ethe ...@@ -66,6 +63,52 @@ func NewRelayerManager(chain33Relayer *chain33.Relayer4Chain33, ethRelayer *ethe
func (manager *Manager) SetPassphase(setPasswdReq relayerTypes.ReqSetPasswd, result *interface{}) error { func (manager *Manager) SetPassphase(setPasswdReq relayerTypes.ReqSetPasswd, result *interface{}) error {
manager.mtx.Lock() manager.mtx.Lock()
defer manager.mtx.Unlock() defer manager.mtx.Unlock()
// 第一次设置密码的时候才使用 后面用 ChangePasswd
if EncryptEnable == manager.encryptFlag {
return errors.New("passphase alreade exists")
}
// 密码合法性校验
if !utils.IsValidPassWord(setPasswdReq.Passphase) {
return chain33Types.ErrInvalidPassWord
}
//使用密码生成passwdhash用于下次密码的验证
newBatch := manager.store.NewBatch(true)
err := manager.store.SetPasswordHash(setPasswdReq.Passphase, newBatch)
if err != nil {
mlog.Error("SetPassphase", "SetPasswordHash err", err)
return err
}
//设置钱包加密标志位
err = manager.store.SetEncryptionFlag(newBatch)
if err != nil {
mlog.Error("SetPassphase", "SetEncryptionFlag err", err)
return err
}
err = newBatch.Write()
if err != nil {
mlog.Error("ProcWalletSetPasswd newBatch.Write", "err", err)
return err
}
manager.passphase = setPasswdReq.Passphase
atomic.StoreInt64(&manager.encryptFlag, EncryptEnable)
*result = rpctypes.Reply{
IsOk: true,
Msg: "Succeed to set passphase",
}
return nil
}
func (manager *Manager) ChangePassphase(setPasswdReq relayerTypes.ReqChangePasswd, result *interface{}) error {
manager.mtx.Lock()
defer manager.mtx.Unlock()
if setPasswdReq.OldPassphase == setPasswdReq.NewPassphase {
return errors.New("the old password is the same as the new one")
}
// 新密码合法性校验 // 新密码合法性校验
if !utils.IsValidPassWord(setPasswdReq.NewPassphase) { if !utils.IsValidPassWord(setPasswdReq.NewPassphase) {
return chain33Types.ErrInvalidPassWord return chain33Types.ErrInvalidPassWord
...@@ -80,16 +123,16 @@ func (manager *Manager) SetPassphase(setPasswdReq relayerTypes.ReqSetPasswd, res ...@@ -80,16 +123,16 @@ func (manager *Manager) SetPassphase(setPasswdReq relayerTypes.ReqSetPasswd, res
}() }()
// 钱包已经加密需要验证oldpass的正确性 // 钱包已经加密需要验证oldpass的正确性
if len(manager.passphase) == 0 && manager.encryptFlag == 1 { if len(manager.passphase) == 0 && manager.encryptFlag == EncryptEnable {
isok := manager.store.VerifyPasswordHash(setPasswdReq.OldPassphase) isok := manager.store.VerifyPasswordHash(setPasswdReq.OldPassphase)
if !isok { if !isok {
mlog.Error("SetPassphase Verify Oldpasswd fail!") mlog.Error("ChangePassphase Verify Oldpasswd fail!")
return chain33Types.ErrVerifyOldpasswdFail return chain33Types.ErrVerifyOldpasswdFail
} }
} }
if len(manager.passphase) != 0 && setPasswdReq.OldPassphase != manager.passphase { if len(manager.passphase) != 0 && setPasswdReq.OldPassphase != manager.passphase {
mlog.Error("SetPassphase Oldpass err!") mlog.Error("ChangePassphase Oldpass err!")
return chain33Types.ErrVerifyOldpasswdFail return chain33Types.ErrVerifyOldpasswdFail
} }
...@@ -97,25 +140,25 @@ func (manager *Manager) SetPassphase(setPasswdReq relayerTypes.ReqSetPasswd, res ...@@ -97,25 +140,25 @@ func (manager *Manager) SetPassphase(setPasswdReq relayerTypes.ReqSetPasswd, res
newBatch := manager.store.NewBatch(true) newBatch := manager.store.NewBatch(true)
err := manager.store.SetPasswordHash(setPasswdReq.NewPassphase, newBatch) err := manager.store.SetPasswordHash(setPasswdReq.NewPassphase, newBatch)
if err != nil { if err != nil {
mlog.Error("SetPassphase", "SetPasswordHash err", err) mlog.Error("ChangePassphase", "SetPasswordHash err", err)
return err return err
} }
//设置钱包加密标志位 //设置钱包加密标志位
err = manager.store.SetEncryptionFlag(newBatch) err = manager.store.SetEncryptionFlag(newBatch)
if err != nil { if err != nil {
mlog.Error("SetPassphase", "SetEncryptionFlag err", err) mlog.Error("ChangePassphase", "SetEncryptionFlag err", err)
return err return err
} }
err = manager.ethRelayer.StoreAccountWithNewPassphase(setPasswdReq.NewPassphase, setPasswdReq.OldPassphase) err = manager.ethRelayer.StoreAccountWithNewPassphase(setPasswdReq.NewPassphase, setPasswdReq.OldPassphase)
if err != nil { if err != nil {
mlog.Error("SetPassphase", "StoreAccountWithNewPassphase err", err) mlog.Error("ChangePassphase", "StoreAccountWithNewPassphase err", err)
return err return err
} }
err = manager.chain33Relayer.StoreAccountWithNewPassphase(setPasswdReq.NewPassphase, setPasswdReq.OldPassphase) err = manager.chain33Relayer.StoreAccountWithNewPassphase(setPasswdReq.NewPassphase, setPasswdReq.OldPassphase)
if err != nil { if err != nil {
mlog.Error("SetPassphase", "StoreAccountWithNewPassphase err", err) mlog.Error("ChangePassphase", "StoreAccountWithNewPassphase err", err)
return err return err
} }
...@@ -129,7 +172,7 @@ func (manager *Manager) SetPassphase(setPasswdReq relayerTypes.ReqSetPasswd, res ...@@ -129,7 +172,7 @@ func (manager *Manager) SetPassphase(setPasswdReq relayerTypes.ReqSetPasswd, res
*result = rpctypes.Reply{ *result = rpctypes.Reply{
IsOk: true, IsOk: true,
Msg: "Succeed to set passphase", Msg: "Succeed to change passphase",
} }
return nil return nil
} }
...@@ -239,23 +282,6 @@ func (manager *Manager) ImportChain33PrivateKey4EthRelayer(privateKey string, re ...@@ -239,23 +282,6 @@ func (manager *Manager) ImportChain33PrivateKey4EthRelayer(privateKey string, re
return nil return nil
} }
//为ethrelayer导入chain33私钥,为向chain33发送交易时进行签名使用
func (manager *Manager) ImportEthValidatorPrivateKey(privateKey string, result *interface{}) error {
manager.mtx.Lock()
defer manager.mtx.Unlock()
if err := manager.checkPermission(); nil != err {
return err
}
if err := manager.ethRelayer.ImportEthValidatorPrivateKey(manager.passphase, privateKey); nil != err {
return err
}
*result = rpctypes.Reply{
IsOk: true,
Msg: "Succeed to import ethereum private key for validator",
}
return nil
}
//显示在chain33中以验证人validator身份进行登录的地址 //显示在chain33中以验证人validator身份进行登录的地址
func (manager *Manager) ShowChain33RelayerValidator(param interface{}, result *interface{}) error { func (manager *Manager) ShowChain33RelayerValidator(param interface{}, result *interface{}) error {
manager.mtx.Lock() manager.mtx.Lock()
...@@ -459,38 +485,6 @@ func (manager *Manager) LockEthErc20Asset(lockEthErc20Asset relayerTypes.LockEth ...@@ -459,38 +485,6 @@ func (manager *Manager) LockEthErc20Asset(lockEthErc20Asset relayerTypes.LockEth
return nil return nil
} }
func (manager *Manager) MakeNewProphecyClaim(newProphecyClaim relayerTypes.NewProphecyClaim, result *interface{}) error {
manager.mtx.Lock()
defer manager.mtx.Unlock()
if err := manager.checkPermission(); nil != err {
return err
}
var tokenAddress common.Address
if "" != newProphecyClaim.TokenAddr {
tokenAddress = common.HexToAddress(newProphecyClaim.TokenAddr)
}
bn := big.NewInt(1)
bn, _ = bn.SetString(types.TrimZeroAndDot(newProphecyClaim.Amount), 10)
newProphecyClaimPara := &ethtxs.NewProphecyClaimPara{
ClaimType: uint8(newProphecyClaim.ClaimType),
Chain33Sender: []byte(newProphecyClaim.Chain33Sender),
TokenAddr: tokenAddress,
EthReceiver: common.HexToAddress(newProphecyClaim.EthReceiver),
Symbol: newProphecyClaim.Symbol,
Amount: bn,
Txhash: common.FromHex(newProphecyClaim.TxHash),
}
txhash, err := manager.ethRelayer.MakeNewProphecyClaim(newProphecyClaimPara)
if nil != err {
return err
}
*result = rpctypes.Reply{
IsOk: true,
Msg: fmt.Sprintf("Tx:%s", txhash),
}
return nil
}
func (manager *Manager) IsProphecyPending(claimID [32]byte, result *interface{}) error { func (manager *Manager) IsProphecyPending(claimID [32]byte, result *interface{}) error {
manager.mtx.Lock() manager.mtx.Lock()
defer manager.mtx.Unlock() defer manager.mtx.Unlock()
...@@ -637,20 +631,6 @@ func (manager *Manager) checkPermission() error { ...@@ -637,20 +631,6 @@ func (manager *Manager) checkPermission() error {
return nil return nil
} }
func (manager *Manager) ShowEthRelayerStatus(param interface{}, result *interface{}) error {
manager.mtx.Lock()
defer manager.mtx.Unlock()
*result = manager.ethRelayer.GetRunningStatus()
return nil
}
func (manager *Manager) ShowChain33RelayerStatus(param interface{}, result *interface{}) error {
manager.mtx.Lock()
defer manager.mtx.Unlock()
*result = manager.chain33Relayer.GetRunningStatus()
return nil
}
func (manager *Manager) ShowEthRelayer2EthTxs(param interface{}, result *interface{}) error { func (manager *Manager) ShowEthRelayer2EthTxs(param interface{}, result *interface{}) error {
*result = manager.ethRelayer.QueryTxhashRelay2Eth() *result = manager.ethRelayer.QueryTxhashRelay2Eth()
return nil return nil
......
...@@ -11,19 +11,22 @@ message Account4Relayer { ...@@ -11,19 +11,22 @@ message Account4Relayer {
} }
message ValidatorAddr4EthRelayer { message ValidatorAddr4EthRelayer {
string ethValidator = 1; string chain33Validator = 1;
string chain33Validator = 2;
} }
message Txhashes { message Txhashes {
repeated string txhash = 1; repeated string txhash = 1;
} }
message ReqSetPasswd { message ReqChangePasswd {
string oldPassphase = 1; string oldPassphase = 1;
string newPassphase = 2; string newPassphase = 2;
} }
message ReqSetPasswd {
string Passphase = 1;
}
message Account4Show { message Account4Show {
string privkey = 1; string privkey = 1;
string addr = 2; string addr = 2;
......
...@@ -170,14 +170,14 @@ func (x *suiteX2Ethereum) Test_4_Eth2Chain33() { ...@@ -170,14 +170,14 @@ func (x *suiteX2Ethereum) Test_4_Eth2Chain33() {
payload := &types2.Eth2Chain33{ payload := &types2.Eth2Chain33{
EthereumChainID: 0, EthereumChainID: 0,
BridgeContractAddress: bridgeContractAddress, BridgeContractAddress: bridgeContractAddress,
Nonce: 0, Nonce: 0,
IssuerDotSymbol: symbol, IssuerDotSymbol: symbol,
TokenContractAddress: tokenContractAddress, TokenContractAddress: tokenContractAddress,
EthereumSender: ethereumAddr, EthereumSender: ethereumAddr,
Chain33Receiver: chain33Receiver, Chain33Receiver: chain33Receiver,
ValidatorAddress: addValidator1, ValidatorAddress: addValidator1,
Amount: "10", Amount: "10",
ClaimType: int64(types2.LockClaimType), ClaimType: int64(types2.LockClaimType),
} }
receipt, err := x.action.procEth2Chain33_lock(payload) receipt, err := x.action.procEth2Chain33_lock(payload)
......
...@@ -92,18 +92,18 @@ func (a *action) procEth2Chain33_lock(ethBridgeClaim *x2eTy.Eth2Chain33) (*types ...@@ -92,18 +92,18 @@ func (a *action) procEth2Chain33_lock(ethBridgeClaim *x2eTy.Eth2Chain33) (*types
execlog := &types.ReceiptLog{Ty: x2eTy.TyEth2Chain33Log, Log: types.Encode(&x2eTy.ReceiptEth2Chain33{ execlog := &types.ReceiptLog{Ty: x2eTy.TyEth2Chain33Log, Log: types.Encode(&x2eTy.ReceiptEth2Chain33{
EthereumChainID: ethBridgeClaim.EthereumChainID, EthereumChainID: ethBridgeClaim.EthereumChainID,
BridgeContractAddress: ethBridgeClaim.BridgeContractAddress, BridgeContractAddress: ethBridgeClaim.BridgeContractAddress,
Nonce: ethBridgeClaim.Nonce, Nonce: ethBridgeClaim.Nonce,
IssuerDotSymbol: ethBridgeClaim.IssuerDotSymbol, IssuerDotSymbol: ethBridgeClaim.IssuerDotSymbol,
EthereumSender: ethBridgeClaim.EthereumSender, EthereumSender: ethBridgeClaim.EthereumSender,
Chain33Receiver: ethBridgeClaim.Chain33Receiver, Chain33Receiver: ethBridgeClaim.Chain33Receiver,
ValidatorAddress: ethBridgeClaim.ValidatorAddress, ValidatorAddress: ethBridgeClaim.ValidatorAddress,
Amount: ethBridgeClaim.Amount, Amount: ethBridgeClaim.Amount,
ClaimType: ethBridgeClaim.ClaimType, ClaimType: ethBridgeClaim.ClaimType,
XTxHash: a.txhash, XTxHash: a.txhash,
XHeight: uint64(a.height), XHeight: uint64(a.height),
ProphecyID: ID, ProphecyID: ID,
Decimals: ethBridgeClaim.Decimals, Decimals: ethBridgeClaim.Decimals,
TokenAddress: ethBridgeClaim.TokenContractAddress, TokenAddress: ethBridgeClaim.TokenContractAddress,
})} })}
receipt.Logs = append(receipt.Logs, execlog) receipt.Logs = append(receipt.Logs, execlog)
...@@ -251,18 +251,18 @@ func (a *action) procEth2Chain33_burn(withdrawEth *x2eTy.Eth2Chain33) (*types.Re ...@@ -251,18 +251,18 @@ func (a *action) procEth2Chain33_burn(withdrawEth *x2eTy.Eth2Chain33) (*types.Re
execlog := &types.ReceiptLog{Ty: x2eTy.TyWithdrawEthLog, Log: types.Encode(&x2eTy.ReceiptEth2Chain33{ execlog := &types.ReceiptLog{Ty: x2eTy.TyWithdrawEthLog, Log: types.Encode(&x2eTy.ReceiptEth2Chain33{
EthereumChainID: withdrawEth.EthereumChainID, EthereumChainID: withdrawEth.EthereumChainID,
BridgeContractAddress: withdrawEth.BridgeContractAddress, BridgeContractAddress: withdrawEth.BridgeContractAddress,
Nonce: withdrawEth.Nonce, Nonce: withdrawEth.Nonce,
IssuerDotSymbol: withdrawEth.IssuerDotSymbol, IssuerDotSymbol: withdrawEth.IssuerDotSymbol,
EthereumSender: withdrawEth.EthereumSender, EthereumSender: withdrawEth.EthereumSender,
Chain33Receiver: withdrawEth.Chain33Receiver, Chain33Receiver: withdrawEth.Chain33Receiver,
ValidatorAddress: withdrawEth.ValidatorAddress, ValidatorAddress: withdrawEth.ValidatorAddress,
Amount: withdrawEth.Amount, Amount: withdrawEth.Amount,
ClaimType: withdrawEth.ClaimType, ClaimType: withdrawEth.ClaimType,
XTxHash: a.txhash, XTxHash: a.txhash,
XHeight: uint64(a.height), XHeight: uint64(a.height),
ProphecyID: ID, ProphecyID: ID,
Decimals: withdrawEth.Decimals, Decimals: withdrawEth.Decimals,
TokenAddress: withdrawEth.TokenContractAddress, TokenAddress: withdrawEth.TokenContractAddress,
})} })}
receipt.Logs = append(receipt.Logs, execlog) receipt.Logs = append(receipt.Logs, execlog)
......
...@@ -17,14 +17,11 @@ docker_chain33_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPA ...@@ -17,14 +17,11 @@ docker_chain33_ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPA
Chain33Cli="$GOPATH/src/github.com/33cn/plugin/build/chain33-cli --rpc_laddr http://${docker_chain33_ip}:8801" Chain33Cli="$GOPATH/src/github.com/33cn/plugin/build/chain33-cli --rpc_laddr http://${docker_chain33_ip}:8801"
chain33SenderAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt" chain33SenderAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
chain33SenderAddrKey="CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"
# validatorsAddr=["0x92c8b16afd6d423652559c6e266cbe1c29bfd84f", "0x0df9a824699bc5878232c9e612fe1a5346a5a368", "0xcb074cb21cdddf3ce9c3c0a7ac4497d633c9d9f1", "0xd9dab021e74ecf475788ed7b61356056b2095830"] # validatorsAddr=["0x92c8b16afd6d423652559c6e266cbe1c29bfd84f", "0x0df9a824699bc5878232c9e612fe1a5346a5a368", "0xcb074cb21cdddf3ce9c3c0a7ac4497d633c9d9f1", "0xd9dab021e74ecf475788ed7b61356056b2095830"]
ethValidatorAddrKeyA="3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e" ethValidatorAddrKeyA="3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
ethValidatorAddrKeyB="a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400" ethValidatorAddrKeyB="a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400"
ethValidatorAddrKeyC="bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e" ethValidatorAddrKeyC="bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e"
ethValidatorAddrKeyD="c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b" ethValidatorAddrKeyD="c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b"
# 新增地址 chain33 需要导入地址 转入 10 bty当收费费 # 新增地址 chain33 需要导入地址 转入 10 bty当收费费
chain33Validator1="1GTxrmuWiXavhcvsaH5w9whgVxUrWsUMdV" chain33Validator1="1GTxrmuWiXavhcvsaH5w9whgVxUrWsUMdV"
chain33Validator2="155ooMPBTF8QQsGAknkK7ei5D78rwDEFe6" chain33Validator2="155ooMPBTF8QQsGAknkK7ei5D78rwDEFe6"
...@@ -34,16 +31,16 @@ chain33ValidatorKey1="0xd627968e445f2a41c92173225791bae1ba42126ae96c32f28f97ff8f ...@@ -34,16 +31,16 @@ chain33ValidatorKey1="0xd627968e445f2a41c92173225791bae1ba42126ae96c32f28f97ff8f
chain33ValidatorKey2="0x9d539bc5fd084eb7fe86ad631dba9aa086dba38418725c38d9751459f567da66" chain33ValidatorKey2="0x9d539bc5fd084eb7fe86ad631dba9aa086dba38418725c38d9751459f567da66"
chain33ValidatorKey3="0x0a6671f101e30a2cc2d79d77436b62cdf2664ed33eb631a9c9e3f3dd348a23be" chain33ValidatorKey3="0x0a6671f101e30a2cc2d79d77436b62cdf2664ed33eb631a9c9e3f3dd348a23be"
chain33ValidatorKey4="0x3818b257b05ee75b6e43ee0e3cfc2d8502342cf67caed533e3756966690b62a5" chain33ValidatorKey4="0x3818b257b05ee75b6e43ee0e3cfc2d8502342cf67caed533e3756966690b62a5"
ethReceiverAddr1="0xa4ea64a583f6e51c3799335b28a8f0529570a635" ethReceiverAddr1="0xa4ea64a583f6e51c3799335b28a8f0529570a635"
ethReceiverAddrKey1="355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71" ethReceiverAddrKey1="355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71"
ethReceiverAddr2="0x0c05ba5c230fdaa503b53702af1962e08d0c60bf" ethReceiverAddr2="0x0c05ba5c230fdaa503b53702af1962e08d0c60bf"
ethReceiverAddrKey2="9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08" ethReceiverAddrKey2="9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08"
maturityDegree=10 maturityDegree=10
function InitAndDeploy() { function InitAndDeploy() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
result=$(${CLIA} relayer set_pwd -n 123456hzj -o kk) result=$(${CLIA} relayer set_pwd -p 123456hzj)
cli_ret "${result}" "set_pwd" cli_ret "${result}" "set_pwd"
result=$(${CLIA} relayer unlock -p 123456hzj) result=$(${CLIA} relayer unlock -p 123456hzj)
...@@ -59,12 +56,12 @@ function EthImportKey() { ...@@ -59,12 +56,12 @@ function EthImportKey() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
# 重启 ebrelayer 并解锁 # 重启 ebrelayer 并解锁
for name in A B C D; do for name in A B C D; do
start_ebrelayer "../build/"$name"/ebrelayer" "../build/"$name"/ebrelayer.log" start_ebrelayer "../build/$name/ebrelayer" "../build/$name/ebrelayer.log"
# 导入测试地址私钥 # 导入测试地址私钥
CLI="../build/ebcli_$name" CLI="../build/ebcli_$name"
result=$(${CLI} relayer set_pwd -n 123456hzj -o kk) result=$(${CLI} relayer set_pwd -p 123456hzj)
#cli_ret "${result}" "set_pwd" #cli_ret "${result}" "set_pwd"
result=$(${CLI} relayer unlock -p 123456hzj) result=$(${CLI} relayer unlock -p 123456hzj)
...@@ -80,15 +77,6 @@ function EthImportKey() { ...@@ -80,15 +77,6 @@ function EthImportKey() {
result=$(${CLID} relayer ethereum import_chain33privatekey -k "${chain33ValidatorKey4}") result=$(${CLID} relayer ethereum import_chain33privatekey -k "${chain33ValidatorKey4}")
cli_ret "${result}" "import_chain33privatekey" cli_ret "${result}" "import_chain33privatekey"
result=$(${CLIA} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyA}")
cli_ret "${result}" "import_ethprivatekey"
result=$(${CLIB} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyB}")
cli_ret "${result}" "import_ethprivatekeyB"
result=$(${CLIC} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyC}")
cli_ret "${result}" "import_ethprivatekeyC"
result=$(${CLID} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyD}")
cli_ret "${result}" "import_ethprivatekeyD"
result=$(${CLIA} relayer chain33 import_privatekey -k "${ethValidatorAddrKeyA}") result=$(${CLIA} relayer chain33 import_privatekey -k "${ethValidatorAddrKeyA}")
cli_ret "${result}" "A relayer chain33 import_privatekey" cli_ret "${result}" "A relayer chain33 import_privatekey"
result=$(${CLIB} relayer chain33 import_privatekey -k "${ethValidatorAddrKeyB}") result=$(${CLIB} relayer chain33 import_privatekey -k "${ethValidatorAddrKeyB}")
...@@ -129,7 +117,7 @@ function StartRelayerAndDeploy() { ...@@ -129,7 +117,7 @@ function StartRelayerAndDeploy() {
kill_ebrelayer "../build/A/ebrelayer" kill_ebrelayer "../build/A/ebrelayer"
# 修改 relayer.toml 配置文件 # 修改 relayer.toml 配置文件
updata_relayer_toml ${BridgeRegistry} ${maturityDegree} "../build/A/relayer.toml" updata_relayer_toml "${BridgeRegistry}" ${maturityDegree} "../build/A/relayer.toml"
updata_all_relayer_toml updata_all_relayer_toml
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
...@@ -164,7 +152,7 @@ function InitChain33Vilators() { ...@@ -164,7 +152,7 @@ function InitChain33Vilators() {
# query Validators # query Validators
totalPower=$(${Chain33Cli} send x2ethereum query totalpower -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv | jq .totalPower | sed 's/\"//g') totalPower=$(${Chain33Cli} send x2ethereum query totalpower -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv | jq .totalPower | sed 's/\"//g')
check_number 100 ${totalPower} check_number 100 "${totalPower}"
# cions 转帐到 x2ethereum 合约地址 # cions 转帐到 x2ethereum 合约地址
hash=$(${Chain33Cli} send coins send_exec -e x2ethereum -a 200 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv) hash=$(${Chain33Cli} send coins send_exec -e x2ethereum -a 200 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv)
...@@ -207,7 +195,7 @@ function TestChain33ToEthAssets() { ...@@ -207,7 +195,7 @@ function TestChain33ToEthAssets() {
cli_ret "${result}" "balance" ".balance" "0" cli_ret "${result}" "balance" ".balance" "0"
# chain33 lock bty # chain33 lock bty
hash=$(${Chain33Cli} send x2ethereum lock -a 5 -t coins.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)) block_wait "${Chain33Cli}" $((maturityDegree + 2))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
...@@ -276,7 +264,7 @@ function TestETH2Chain33Assets() { ...@@ -276,7 +264,7 @@ function TestETH2Chain33Assets() {
cli_ret "${result}" "balance" ".balance" "0" cli_ret "${result}" "balance" ".balance" "0"
result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}") result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}")
cli_ret "${result}" "balance" ".balance" $(echo "${balance}+10" | bc) cli_ret "${result}" "balance" ".balance" "$(echo "${balance}+10" | bc)"
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
} }
...@@ -320,7 +308,7 @@ function TestETH2Chain33Erc20() { ...@@ -320,7 +308,7 @@ function TestETH2Chain33Erc20() {
balance_ret "${result}" "100" balance_ret "${result}" "100"
# chain33 burn 100 # chain33 burn 100
hash=$(${Chain33Cli} send x2ethereum burn -a 100 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q ${tokenAddr} -k "${chain33Validator1}") hash=$(${Chain33Cli} send x2ethereum burn -a 100 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q "${tokenAddr}" -k "${chain33Validator1}")
block_wait "${Chain33Cli}" $((maturityDegree + 2)) block_wait "${Chain33Cli}" $((maturityDegree + 2))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
...@@ -354,7 +342,7 @@ function TestChain33ToEthAssetsKill() { ...@@ -354,7 +342,7 @@ function TestChain33ToEthAssetsKill() {
kill_ebrelayerD kill_ebrelayerD
# chain33 lock bty # chain33 lock bty
hash=$(${Chain33Cli} send x2ethereum lock -a 5 -t bty -r ${ethReceiverAddr2} -q ${tokenAddrBty} -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv) hash=$(${Chain33Cli} send x2ethereum lock -a 5 -t bty -r ${ethReceiverAddr2} -q "${tokenAddrBty}" -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv)
block_wait "${Chain33Cli}" $((maturityDegree + 2)) block_wait "${Chain33Cli}" $((maturityDegree + 2))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
...@@ -445,7 +433,7 @@ function TestETH2Chain33AssetsKill() { ...@@ -445,7 +433,7 @@ function TestETH2Chain33AssetsKill() {
start_ebrelayerD start_ebrelayerD
result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}") result=$(${CLIA} relayer ethereum balance -o "${ethReceiverAddr2}")
cli_ret "${result}" "balance" ".balance" $(echo "${balance}+0.1" | bc) cli_ret "${result}" "balance" ".balance" "$(echo "${balance}+0.1" | bc)"
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
} }
...@@ -501,7 +489,7 @@ function TestETH2Chain33Erc20Kill() { ...@@ -501,7 +489,7 @@ function TestETH2Chain33Erc20Kill() {
kill_ebrelayerD kill_ebrelayerD
# chain33 burn 100 # chain33 burn 100
hash=$(${Chain33Cli} send x2ethereum burn -a 100 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q ${tokenAddr} -k "${chain33Validator1}") hash=$(${Chain33Cli} send x2ethereum burn -a 100 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q "${tokenAddr}" -k "${chain33Validator1}")
block_wait "${Chain33Cli}" $((maturityDegree + 2)) block_wait "${Chain33Cli}" $((maturityDegree + 2))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
......
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck disable=SC2128
# shellcheck source=/dev/null
set -x set -x
# 只启动 eth 这一端的测试 # 只启动 eth 这一端的测试
# 只启动一个 relayer 第一个地址权重设置超过2/3 # 只启动一个 relayer 第一个地址权重设置超过2/3
...@@ -9,18 +11,11 @@ CLI="../build/ebcli_A" ...@@ -9,18 +11,11 @@ CLI="../build/ebcli_A"
chain33SenderAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt" chain33SenderAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
chain33SenderAddrKey="CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944" chain33SenderAddrKey="CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"
# 0x92C8b16aFD6d423652559C6E266cBE1c29Bfd84f
ethValidatorAddrKey="3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
ethReceiverAddr1="0xa4ea64a583f6e51c3799335b28a8f0529570a635" ethReceiverAddr1="0xa4ea64a583f6e51c3799335b28a8f0529570a635"
ethReceiverAddrKey1="355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71" ethReceiverAddrKey1="355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71"
ethReceiverAddr2="0x0c05ba5c230fdaa503b53702af1962e08d0c60bf" ethReceiverAddr2="0x0c05ba5c230fdaa503b53702af1962e08d0c60bf"
ethReceiverAddrKey2="9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08" ethReceiverAddrKey2="9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08"
ethReceiverAddr3="0x1919203bA8b325278d28Fb8fFeac49F2CD881A4e" ethReceiverAddr3="0x1919203bA8b325278d28Fb8fFeac49F2CD881A4e"
#ethReceiverAddrKey3="62ca4122aac0e6f35bed02fc15c7ddbdaa07f2f2a1821c8b8210b891051e3ee9"
prophecyTx0="0x112260c98aec81b3e235af47c355db720f60e751cce100fed6f334e1b1530bde" prophecyTx0="0x112260c98aec81b3e235af47c355db720f60e751cce100fed6f334e1b1530bde"
prophecyTx1="0x222260c98aec81b3e235af47c355db720f60e751cce100fed6f334e1b1530bde" prophecyTx1="0x222260c98aec81b3e235af47c355db720f60e751cce100fed6f334e1b1530bde"
...@@ -31,9 +26,9 @@ prophecyTx5="0x662260c98aec81b3e235af47c355db720f60e751cce100fed6f334e1b1530bde" ...@@ -31,9 +26,9 @@ prophecyTx5="0x662260c98aec81b3e235af47c355db720f60e751cce100fed6f334e1b1530bde"
prophecyTx6="0x772260c98aec81b3e235af47c355db720f60e751cce100fed6f334e1b1530bde" prophecyTx6="0x772260c98aec81b3e235af47c355db720f60e751cce100fed6f334e1b1530bde"
InitAndDeploy() { InitAndDeploy() {
echo "=========== $FUNCNAME begin ===========" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
result=$(${CLI} relayer set_pwd -n 123456hzj -o kk) result=$(${CLI} relayer set_pwd -p 123456hzj)
cli_ret "${result}" "set_pwd" cli_ret "${result}" "set_pwd"
result=$(${CLI} relayer unlock -p 123456hzj) result=$(${CLI} relayer unlock -p 123456hzj)
...@@ -45,17 +40,14 @@ InitAndDeploy() { ...@@ -45,17 +40,14 @@ InitAndDeploy() {
result=$(${CLI} relayer ethereum import_chain33privatekey -k "${chain33SenderAddrKey}") result=$(${CLI} relayer ethereum import_chain33privatekey -k "${chain33SenderAddrKey}")
cli_ret "${result}" "import_chain33privatekey" cli_ret "${result}" "import_chain33privatekey"
result=$(${CLI} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKey}") echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
cli_ret "${result}" "import_ethprivatekey"
echo "=========== $FUNCNAME end ==========="
} }
# eth to chain33 # eth to chain33
# 在以太坊上锁定资产,然后在 chain33 上铸币,针对 erc20 资产 # 在以太坊上锁定资产,然后在 chain33 上铸币,针对 erc20 资产
# 以太坊 brun 资产,balance 对比是否正确 # 以太坊 brun 资产,balance 对比是否正确
TestETH2Chain33Erc20() { TestETH2Chain33Erc20() {
echo "=========== $FUNCNAME begin ===========" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
${CLI} relayer unlock -p 123456hzj ${CLI} relayer unlock -p 123456hzj
# token4erc20 在 chain33 上先有 token,同时 mint # token4erc20 在 chain33 上先有 token,同时 mint
...@@ -116,11 +108,11 @@ TestETH2Chain33Erc20() { ...@@ -116,11 +108,11 @@ TestETH2Chain33Erc20() {
result=$(${CLI} relayer ethereum balance -o "${bridgeBankAddr}" -t "${tokenSymbol}") result=$(${CLI} relayer ethereum balance -o "${bridgeBankAddr}" -t "${tokenSymbol}")
cli_ret "${result}" "balance" ".balance" "0" cli_ret "${result}" "balance" ".balance" "0"
echo "=========== $FUNCNAME end ===========" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
} }
TestETH2Chain33Erc20_err() { TestETH2Chain33Erc20_err() {
echo "=========== $FUNCNAME begin ===========" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
${CLI} relayer unlock -p 123456hzj ${CLI} relayer unlock -p 123456hzj
# token4erc20 在 chain33 上先有 token,同时 mint # token4erc20 在 chain33 上先有 token,同时 mint
...@@ -187,13 +179,13 @@ TestETH2Chain33Erc20_err() { ...@@ -187,13 +179,13 @@ TestETH2Chain33Erc20_err() {
result=$(${CLI} relayer ethereum balance -o "${bridgeBankAddr}" -t "${tokenSymbol}") result=$(${CLI} relayer ethereum balance -o "${bridgeBankAddr}" -t "${tokenSymbol}")
cli_ret "${result}" "balance" ".balance" "300" cli_ret "${result}" "balance" ".balance" "300"
echo "=========== $FUNCNAME end ===========" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
} }
# eth to chain33 # eth to chain33
# 在以太坊上锁定资产,然后在 chain33 上铸币,针对 eth 资产 # 在以太坊上锁定资产,然后在 chain33 上铸币,针对 eth 资产
TestETH2Chain33Assets() { TestETH2Chain33Assets() {
echo "=========== $FUNCNAME begin ===========" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
${CLI} relayer unlock -p 123456hzj ${CLI} relayer unlock -p 123456hzj
result=$(${CLI} relayer ethereum bridgeBankAddr) result=$(${CLI} relayer ethereum bridgeBankAddr)
...@@ -273,14 +265,14 @@ TestETH2Chain33Assets() { ...@@ -273,14 +265,14 @@ TestETH2Chain33Assets() {
result=$(${CLI} relayer ethereum balance -o "${bridgeBankAddr}") result=$(${CLI} relayer ethereum balance -o "${bridgeBankAddr}")
cli_ret "${result}" "balance" ".balance" "0" cli_ret "${result}" "balance" ".balance" "0"
echo "=========== $FUNCNAME end ===========" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
} }
# chain33 to eth # chain33 to eth
# 在 chain33 上锁定资产,然后在以太坊上铸币 # 在 chain33 上锁定资产,然后在以太坊上铸币
# chain33 brun 资产,balance 对比是否正确 # chain33 brun 资产,balance 对比是否正确
TestChain33ToEthAssets() { TestChain33ToEthAssets() {
echo "=========== $FUNCNAME begin ===========" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
result=$(${CLI} relayer unlock -p 123456hzj) result=$(${CLI} relayer unlock -p 123456hzj)
# token4chain33 在 以太坊 上先有 bty # token4chain33 在 以太坊 上先有 bty
result=$(${CLI} relayer ethereum token4chain33 -s coins.bty) result=$(${CLI} relayer ethereum token4chain33 -s coins.bty)
...@@ -334,7 +326,7 @@ TestChain33ToEthAssets() { ...@@ -334,7 +326,7 @@ TestChain33ToEthAssets() {
result=$(${CLI} relayer ethereum burn -m 10 -k "${ethReceiverAddrKey1}" -r "${chain33SenderAddr}" -t "${tokenAddr}") result=$(${CLI} relayer ethereum burn -m 10 -k "${ethReceiverAddrKey1}" -r "${chain33SenderAddr}" -t "${tokenAddr}")
cli_ret_err "${result}" cli_ret_err "${result}"
echo "=========== $FUNCNAME end ===========" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
} }
main() { main() {
......
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck disable=SC2128
# shellcheck source=/dev/null
set -x set -x
# 只启动 eth 这一端的测试 # 只启动 eth 这一端的测试
...@@ -6,9 +8,6 @@ set -x ...@@ -6,9 +8,6 @@ set -x
source "./publicTest.sh" source "./publicTest.sh"
CLIA="../build/ebcli_A" CLIA="../build/ebcli_A"
CLIB="../build/ebcli_B"
CLIC="../build/ebcli_C"
CLID="../build/ebcli_D"
tokenAddr="" tokenAddr=""
chain33SenderAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt" chain33SenderAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
...@@ -20,7 +19,7 @@ prophecyTx0="0x772260c98aec81b3e235af47c355db720f60e751cce100fed6f334e1b1530bde" ...@@ -20,7 +19,7 @@ prophecyTx0="0x772260c98aec81b3e235af47c355db720f60e751cce100fed6f334e1b1530bde"
# 初始化部署合约 # 初始化部署合约
InitAndDeploy() { InitAndDeploy() {
echo "=========== $FUNCNAME begin ===========" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
# 创建文件夹及拷贝 # 创建文件夹及拷贝
rm -rf '../build/A' '../build/B' '../build/C' '../build/D' rm -rf '../build/A' '../build/B' '../build/C' '../build/D'
mkdir '../build/A' '../build/B' '../build/C' '../build/D' mkdir '../build/A' '../build/B' '../build/C' '../build/D'
...@@ -28,7 +27,7 @@ InitAndDeploy() { ...@@ -28,7 +27,7 @@ InitAndDeploy() {
cp '../build/ebrelayer' '../build/A/ebrelayer' cp '../build/ebrelayer' '../build/A/ebrelayer'
start_ebrelayer "./../build/A/ebrelayer" "./../build/A/ebrelayer.log" start_ebrelayer "./../build/A/ebrelayer" "./../build/A/ebrelayer.log"
result=$(${CLIA} relayer set_pwd -n 123456hzj -o kk) result=$(${CLIA} relayer set_pwd -p 123456hzj)
cli_ret "${result}" "set_pwd" cli_ret "${result}" "set_pwd"
result=$(${CLIA} relayer unlock -p 123456hzj) result=$(${CLIA} relayer unlock -p 123456hzj)
...@@ -36,52 +35,47 @@ InitAndDeploy() { ...@@ -36,52 +35,47 @@ InitAndDeploy() {
result=$(${CLIA} relayer ethereum deploy) result=$(${CLIA} relayer ethereum deploy)
cli_ret "${result}" "deploy" cli_ret "${result}" "deploy"
echo "=========== $FUNCNAME end ===========" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
} }
# 初始化 B C D 文件夹下的文容 # 初始化 B C D 文件夹下的文容
function InitConfigFile() { function InitConfigFile() {
echo "=========== $FUNCNAME begin ===========" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
# 获取 BridgeRegistry 地址 # 获取 BridgeRegistry 地址
result=$(${CLIA} relayer ethereum bridgeRegistry) result=$(${CLIA} relayer ethereum bridgeRegistry)
BridgeRegistry=$(cli_ret "${result}" "bridgeRegistry" ".addr") BridgeRegistry=$(cli_ret "${result}" "bridgeRegistry" ".addr")
port=9901 port=9901
for name in B C D; do for name in B C D; do
file="../build/"$name"/relayer.toml" file="../build/$name/relayer.toml"
cp '../build/relayer.toml' "${file}" cp '../build/relayer.toml' "${file}"
cp '../build/ebrelayer' "../build/"$name"/ebrelayer" cp '../build/ebrelayer' "../build/$name/ebrelayer"
# 删除配置文件中不需要的字段 # 删除配置文件中不需要的字段
for deleteName in "BridgeRegistry" "deployerPrivateKey" "operatorAddr" "validatorsAddr" "initPowers" "deployerPrivateKey" "\[deploy\]"; do for deleteName in "BridgeRegistry" "deployerPrivateKey" "operatorAddr" "validatorsAddr" "initPowers" "deployerPrivateKey" "deploy"; do
delete_line "${file}" "${deleteName}" delete_line "${file}" "${deleteName}"
done done
# 在第 5 行后面 新增合约地址 # 在第 5 行后面 新增合约地址
sed -i '5 a BridgeRegistry="'${BridgeRegistry}'"' "${file}" sed -i '5 a BridgeRegistry="'"${BridgeRegistry}"'"' "${file}"
# 替换端口 # 替换端口
port=$((port + 1)) port=$((port + 1))
sed -i 's/localhost:9901/localhost:'${port}'/g' "${file}" sed -i 's/localhost:9901/localhost:'${port}'/g' "${file}"
done done
echo "=========== $FUNCNAME end ===========" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
} }
# 启动 B C D 的 ebrelayer 服务,导入私钥 # 启动 B C D 的 ebrelayer 服务,导入私钥
function ImportCBDKey() { function ImportCBDKey() {
echo "=========== $FUNCNAME begin ===========" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
local ethValidatorAddrKeyA="3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
local ethValidatorAddrKeyB="a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400"
local ethValidatorAddrKeyC="bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e"
local ethValidatorAddrKeyD="c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b"
for name in B C D; do for name in B C D; do
start_ebrelayer "./../build/"$name"/ebrelayer" "./../build/"$name"/ebrelayer.log" start_ebrelayer "./../build/$name/ebrelayer" "./../build/$name/ebrelayer.log"
# 导入测试地址私钥 # 导入测试地址私钥
CLI="../build/ebcli_$name" CLI="../build/ebcli_$name"
result=$(${CLI} relayer set_pwd -n 123456hzj -o kk) result=$(${CLI} relayer set_pwd -p 123456hzj)
cli_ret "${result}" "set_pwd" cli_ret "${result}" "set_pwd"
result=$(${CLI} relayer unlock -p 123456hzj) result=$(${CLI} relayer unlock -p 123456hzj)
...@@ -93,24 +87,12 @@ function ImportCBDKey() { ...@@ -93,24 +87,12 @@ function ImportCBDKey() {
result=$(${CLIA} relayer ethereum import_chain33privatekey -k "${chain33SenderAddrKey}") result=$(${CLIA} relayer ethereum import_chain33privatekey -k "${chain33SenderAddrKey}")
cli_ret "${result}" "import_chain33privatekey" cli_ret "${result}" "import_chain33privatekey"
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
result=$(${CLIA} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyA}")
cli_ret "${result}" "import_ethprivatekey"
result=$(${CLIB} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyB}")
cli_ret "${result}" "import_ethprivatekeyB"
result=$(${CLIC} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyC}")
cli_ret "${result}" "import_ethprivatekeyC"
result=$(${CLID} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKeyD}")
cli_ret "${result}" "import_ethprivatekeyD"
echo "=========== $FUNCNAME end ==========="
} }
# chain33 到 eth,chian33 lock 100,必须 A B C D 中有三个都lock,才能成功 # chain33 到 eth,chian33 lock 100,必须 A B C D 中有三个都lock,才能成功
TestChain33ToEth() { TestChain33ToEth() {
echo "=========== $FUNCNAME begin ===========" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
# token4chain33 在 以太坊 上先有 bty # token4chain33 在 以太坊 上先有 bty
result=$(${CLIA} relayer ethereum token4chain33 -s coins.bty) result=$(${CLIA} relayer ethereum token4chain33 -s coins.bty)
tokenAddr=$(cli_ret "${result}" "token4chain33" ".addr") tokenAddr=$(cli_ret "${result}" "token4chain33" ".addr")
...@@ -147,7 +129,7 @@ TestChain33ToEth() { ...@@ -147,7 +129,7 @@ TestChain33ToEth() {
result=$(${CLIA} relayer ethereum burn -m 90 -k "${ethReceiverAddrKey1}" -r "${chain33SenderAddr}" -t "${tokenAddr}") result=$(${CLIA} relayer ethereum burn -m 90 -k "${ethReceiverAddrKey1}" -r "${chain33SenderAddr}" -t "${tokenAddr}")
cli_ret "${result}" "burn" cli_ret "${result}" "burn"
echo "=========== $FUNCNAME end ===========" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
} }
main() { main() {
......
#!/usr/bin/env bash #!/usr/bin/env bash
# shellcheck disable=SC2128 # shellcheck disable=SC2128
# shellcheck source=/dev/null # shellcheck source=/dev/null
# shellcheck disable=SC2155
set -x set -x
set -e set -e
...@@ -39,7 +40,7 @@ function cli_ret() { ...@@ -39,7 +40,7 @@ function cli_ret() {
msg=$(echo "${1}" | jq -r "${jqMsg}") msg=$(echo "${1}" | jq -r "${jqMsg}")
if [[ $# -eq 4 ]]; then if [[ $# -eq 4 ]]; then
if [ $(echo "$msg < $4" | bc) -eq 1 ] || [ $(echo "$msg > $4" | bc) -eq 1 ]; then if [ "$(echo "$msg < $4" | bc)" -eq 1 ] || [ "$(echo "$msg > $4" | bc)" -eq 1 ]; then
echo -e "${RED}The balance is not correct${NOC}" echo -e "${RED}The balance is not correct${NOC}"
exit 1 exit 1
fi fi
...@@ -58,7 +59,7 @@ function balance_ret() { ...@@ -58,7 +59,7 @@ function balance_ret() {
fi fi
local balance=$(echo "${1}" | jq -r ".balance") local balance=$(echo "${1}" | jq -r ".balance")
if [ $(echo "$balance < $2" | bc) -eq 1 ] || [ $(echo "$balance > $2" | bc) -eq 1 ]; then if [ "$(echo "$balance < $2" | bc)" -eq 1 ] || [ "$(echo "$balance > $2" | bc)" -eq 1 ]; then
echo -e "${RED}The balance is not correct${NOC}" echo -e "${RED}The balance is not correct${NOC}"
exit 1 exit 1
fi fi
...@@ -115,6 +116,7 @@ function start_ebrelayer() { ...@@ -115,6 +116,7 @@ function start_ebrelayer() {
nohup "${1}" >"${2}" 2>&1 & nohup "${1}" >"${2}" 2>&1 &
sleep 2 sleep 2
# shellcheck disable=SC2009
pid=$(ps -ef | grep "${1}" | grep -v 'grep' | awk '{print $2}') pid=$(ps -ef | grep "${1}" | grep -v 'grep' | awk '{print $2}')
local count=0 local count=0
while [ "${pid}" == "" ]; do while [ "${pid}" == "" ]; do
...@@ -127,6 +129,7 @@ function start_ebrelayer() { ...@@ -127,6 +129,7 @@ function start_ebrelayer() {
exit 1 exit 1
fi fi
# shellcheck disable=SC2009
pid=$(ps -ef | grep "${1}" | grep -v 'grep' | awk '{print $2}') pid=$(ps -ef | grep "${1}" | grep -v 'grep' | awk '{print $2}')
done done
} }
...@@ -162,7 +165,7 @@ function start_ebrelayer_and_setpwd_unlock() { ...@@ -162,7 +165,7 @@ function start_ebrelayer_and_setpwd_unlock() {
local CLI="./ebcli_$1" local CLI="./ebcli_$1"
local count=0 local count=0
while true; do while true; do
result=$(${CLI} relayer set_pwd -n 123456hzj -o kk | jq -r .isOK) result=$(${CLI} relayer set_pwd -p 123456hzj | jq -r .isOK)
if [[ ${result} == "true" ]]; then if [[ ${result} == "true" ]]; then
break break
fi fi
...@@ -195,6 +198,7 @@ function start_ebrelayer_and_setpwd_unlock() { ...@@ -195,6 +198,7 @@ function start_ebrelayer_and_setpwd_unlock() {
# 杀死进程ebrelayer 进程 $1进程名称 # 杀死进程ebrelayer 进程 $1进程名称
function kill_ebrelayer() { function kill_ebrelayer() {
# shellcheck disable=SC2009
pid=$(ps -ef | grep "${1}" | grep -v 'grep' | awk '{print $2}') pid=$(ps -ef | grep "${1}" | grep -v 'grep' | awk '{print $2}')
if [ "${pid}" == "" ]; then if [ "${pid}" == "" ]; then
echo "not find ${1} pid" echo "not find ${1} pid"
...@@ -202,6 +206,7 @@ function kill_ebrelayer() { ...@@ -202,6 +206,7 @@ function kill_ebrelayer() {
fi fi
kill "${pid}" kill "${pid}"
# shellcheck disable=SC2009
pid=$(ps -ef | grep "${1}" | grep -v 'grep' | awk '{print $2}') pid=$(ps -ef | grep "${1}" | grep -v 'grep' | awk '{print $2}')
if [ "${pid}" != "" ]; then if [ "${pid}" != "" ]; then
echo "kill ${1} failed" echo "kill ${1} failed"
...@@ -255,7 +260,7 @@ function check_tx() { ...@@ -255,7 +260,7 @@ function check_tx() {
local count=0 local count=0
while true; do while true; do
ty=$(${CLI} tx query -s ${2} | jq .receipt.ty) ty=$(${CLI} tx query -s "${2}" | jq .receipt.ty)
if [[ ${ty} != "" ]]; then if [[ ${ty} != "" ]]; then
break break
fi fi
...@@ -271,7 +276,7 @@ function check_tx() { ...@@ -271,7 +276,7 @@ function check_tx() {
set -x set -x
ty=$(${CLI} tx query -s ${2} | jq .receipt.ty) ty=$(${CLI} tx query -s "${2}" | jq .receipt.ty)
if [[ ${ty} != 2 ]]; then if [[ ${ty} != 2 ]]; then
echo -e "${RED}check tx error, hash is ${2}${NOC}" echo -e "${RED}check tx error, hash is ${2}${NOC}"
exit 1 exit 1
...@@ -283,7 +288,7 @@ function check_number() { ...@@ -283,7 +288,7 @@ function check_number() {
echo -e "${RED}wrong check number parameters${NOC}" echo -e "${RED}wrong check number parameters${NOC}"
exit 1 exit 1
fi fi
if [[ ${1} != ${2} ]]; then if [[ ${1} != "${2}" ]]; then
echo -e "${RED}error number, expect ${1}, get ${2}${NOC}" echo -e "${RED}error number, expect ${1}, get ${2}${NOC}"
exit 1 exit 1
fi fi
...@@ -296,8 +301,8 @@ function check_addr() { ...@@ -296,8 +301,8 @@ function check_addr() {
exit 1 exit 1
fi fi
addr=$(echo ${1} | jq -r ".acc.addr") addr=$(echo "${1}" | jq -r ".acc.addr")
if [[ ${addr} != ${2} ]]; then if [[ ${addr} != "${2}" ]]; then
echo -e "${RED}error addr, expect ${1}, get ${2}${NOC}" echo -e "${RED}error addr, expect ${1}, get ${2}${NOC}"
exit 1 exit 1
fi fi
...@@ -331,18 +336,18 @@ function updata_relayer_toml() { ...@@ -331,18 +336,18 @@ function updata_relayer_toml() {
exit 1 exit 1
fi fi
local line=$(delete_line_show ${file} "chain33Host") local line=$(delete_line_show "${file}" "chain33Host")
# 在第 line 行后面 新增合约地址 # 在第 line 行后面 新增合约地址
sed -i ''${line}' a chain33Host="http://'${chain33Host}':8801"' "${file}" sed -i ''"${line}"' a chain33Host="http://'"${chain33Host}"':8801"' "${file}"
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} "BridgeRegistry") line=$(delete_line_show "${file}" "BridgeRegistry")
sed -i ''${line}' a BridgeRegistry="'${BridgeRegistry}'"' "${file}" sed -i ''"${line}"' a BridgeRegistry="'"${BridgeRegistry}"'"' "${file}"
sed -i 's/EthMaturityDegree=10/'EthMaturityDegree=${maturityDegree}'/g' "${file}" sed -i 's/EthMaturityDegree=10/'EthMaturityDegree="${maturityDegree}"'/g' "${file}"
sed -i 's/maturityDegree=10/'maturityDegree=${maturityDegree}'/g' "${file}" sed -i 's/maturityDegree=10/'maturityDegree="${maturityDegree}"'/g' "${file}"
#sed -i 's/#BridgeRegistry=\"0x40BFE5eD039A9a2Eb42ece2E2CA431bFa7Cf4c42\"/BridgeRegistry=\"'${BridgeRegistry}'\"/g' "../build/relayer.toml" #sed -i 's/#BridgeRegistry=\"0x40BFE5eD039A9a2Eb42ece2E2CA431bFa7Cf4c42\"/BridgeRegistry=\"'${BridgeRegistry}'\"/g' "../build/relayer.toml"
#sed -i 's/192.168.64.2/'${chain33Host}'/g' "../build/relayer.toml" #sed -i 's/192.168.64.2/'${chain33Host}'/g' "../build/relayer.toml"
...@@ -358,18 +363,18 @@ function updata_relayer_toml_ropston() { ...@@ -358,18 +363,18 @@ function updata_relayer_toml_ropston() {
local chain33Host=127.0.0.1 local chain33Host=127.0.0.1
local pushHost=127.0.0.1 local pushHost=127.0.0.1
local line=$(delete_line_show ${file} "chain33Host") local line=$(delete_line_show "${file}" "chain33Host")
# 在第 line 行后面 新增合约地址 # 在第 line 行后面 新增合约地址
sed -i ''${line}' a chain33Host="http://'${chain33Host}':8801"' "${file}" sed -i ''"${line}"' a chain33Host="http://'${chain33Host}':8801"' "${file}"
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} "BridgeRegistry") line=$(delete_line_show "${file}" "BridgeRegistry")
sed -i ''${line}' a BridgeRegistry="'${BridgeRegistry}'"' "${file}" sed -i ''"${line}"' a BridgeRegistry="'"${BridgeRegistry}"'"' "${file}"
sed -i 's/EthMaturityDegree=10/'EthMaturityDegree=${maturityDegree}'/g' "${file}" sed -i 's/EthMaturityDegree=10/'EthMaturityDegree="${maturityDegree}"'/g' "${file}"
sed -i 's/maturityDegree=10/'maturityDegree=${maturityDegree}'/g' "${file}" sed -i 's/maturityDegree=10/'maturityDegree="${maturityDegree}"'/g' "${file}"
#sed -i 's/#BridgeRegistry=\"0x40BFE5eD039A9a2Eb42ece2E2CA431bFa7Cf4c42\"/BridgeRegistry=\"'${BridgeRegistry}'\"/g' "../build/relayer.toml" #sed -i 's/#BridgeRegistry=\"0x40BFE5eD039A9a2Eb42ece2E2CA431bFa7Cf4c42\"/BridgeRegistry=\"'${BridgeRegistry}'\"/g' "../build/relayer.toml"
#sed -i 's/192.168.64.2/'${chain33Host}'/g' "../build/relayer.toml" #sed -i 's/192.168.64.2/'${chain33Host}'/g' "../build/relayer.toml"
...@@ -383,12 +388,12 @@ function updata_all_relayer_toml() { ...@@ -383,12 +388,12 @@ function updata_all_relayer_toml() {
# local dockername=30 # local dockername=30
for name in B C D; do for name in B C D; do
local file="../build/"$name"/relayer.toml" local file="../build/$name/relayer.toml"
cp '../build/A/relayer.toml' "${file}" cp '../build/A/relayer.toml' "${file}"
cp '../build/ebrelayer' "../build/"$name"/ebrelayer" cp '../build/ebrelayer' "../build/$name/ebrelayer"
# 删除配置文件中不需要的字段 # 删除配置文件中不需要的字段
for deleteName in "deployerPrivateKey" "operatorAddr" "validatorsAddr" "initPowers" "deployerPrivateKey" "\[deploy\]"; do for deleteName in "deployerPrivateKey" "operatorAddr" "validatorsAddr" "initPowers" "deployerPrivateKey" "deploy"; do
delete_line "${file}" "${deleteName}" delete_line "${file}" "${deleteName}"
done done
...@@ -421,12 +426,12 @@ function updata_all_relayer_toml2() { ...@@ -421,12 +426,12 @@ function updata_all_relayer_toml2() {
# local dockername=30 # local dockername=30
for name in B C D; do for name in B C D; do
local file="./"$name"/relayer.toml" local file="./$name/relayer.toml"
cp './A/relayer.toml' "${file}" cp './A/relayer.toml' "${file}"
cp './ebrelayer' "./"$name"/ebrelayer" cp './ebrelayer' "./$name/ebrelayer"
# 删除配置文件中不需要的字段 # 删除配置文件中不需要的字段
for deleteName in "deployerPrivateKey" "operatorAddr" "validatorsAddr" "initPowers" "deployerPrivateKey" "\[deploy\]"; do for deleteName in "deployerPrivateKey" "operatorAddr" "validatorsAddr" "initPowers" "deployerPrivateKey" "deploy"; do
delete_line "${file}" "${deleteName}" delete_line "${file}" "${deleteName}"
done done
...@@ -512,7 +517,7 @@ function eth_block_wait() { ...@@ -512,7 +517,7 @@ function eth_block_wait() {
if [ "${url}" == "" ]; then if [ "${url}" == "" ]; then
cur_height=$(curl -ksd '{"id":1,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' http://localhost:7545 | jq -r ".result") cur_height=$(curl -ksd '{"id":1,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' http://localhost:7545 | jq -r ".result")
else else
cur_height=$(curl -H "Content-Type: application/json" -X POST --data '{"id":1,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' ${url} | jq -r ".result") cur_height=$(curl -H "Content-Type: application/json" -X POST --data '{"id":1,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' "${url}" | jq -r ".result")
fi fi
local expect=$((cur_height + ${1} + 1)) local expect=$((cur_height + ${1} + 1))
...@@ -521,7 +526,7 @@ function eth_block_wait() { ...@@ -521,7 +526,7 @@ function eth_block_wait() {
if [ "${url}" == "" ]; then if [ "${url}" == "" ]; then
new_height=$(curl -ksd '{"id":1,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' http://localhost:7545 | jq -r ".result") new_height=$(curl -ksd '{"id":1,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' http://localhost:7545 | jq -r ".result")
else else
new_height=$(curl -H "Content-Type: application/json" -X POST --data '{"id":1,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' ${url} | jq -r ".result") new_height=$(curl -H "Content-Type: application/json" -X POST --data '{"id":1,"jsonrpc":"2.0","method":"eth_blockNumber","params":[]}' "${url}" | jq -r ".result")
fi fi
if [[ ${new_height} -ge ${expect} ]]; then if [[ ${new_height} -ge ${expect} ]]; then
......
...@@ -16,26 +16,20 @@ tokenAddr="" ...@@ -16,26 +16,20 @@ tokenAddr=""
BridgeRegistry="" BridgeRegistry=""
chain33SenderAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt" chain33SenderAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
chain33SenderAddrKey="CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944" chain33SenderAddrKey="CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"
ethValidatorAddrKey="3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e" ethValidatorAddrKey="3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
ethReceiverAddr1="0xa4ea64a583f6e51c3799335b28a8f0529570a635" ethReceiverAddr1="0xa4ea64a583f6e51c3799335b28a8f0529570a635"
ethReceiverAddrKey1="355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71" ethReceiverAddrKey1="355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71"
ethReceiverAddr2="0x0c05ba5c230fdaa503b53702af1962e08d0c60bf" ethReceiverAddr2="0x0c05ba5c230fdaa503b53702af1962e08d0c60bf"
ethReceiverAddrKey2="9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08" ethReceiverAddrKey2="9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08"
ethReceiverAddr3="0x1919203bA8b325278d28Fb8fFeac49F2CD881A4e"
ethReceiverAddrKey3="62ca4122aac0e6f35bed02fc15c7ddbdaa07f2f2a1821c8b8210b891051e3ee9"
chain33Validator1="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt" chain33Validator1="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
chain33Validator2="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv" #0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01 chain33Validator2="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv" #0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01
chain33Validator3="1BqP2vHkYNjSgdnTqm7pGbnphLhtEhuJFi" chain33Validator3="1BqP2vHkYNjSgdnTqm7pGbnphLhtEhuJFi"
BtyReceiever="1BqP2vHkYNjSgdnTqm7pGbnphLhtEhuJFi"
ETHContractAddr="0x0000000000000000000000000000000000000000"
maturityDegree=10 maturityDegree=10
function InitAndDeploy() { function InitAndDeploy() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
result=$(${CLI} relayer set_pwd -n 123456hzj -o kk) result=$(${CLI} relayer set_pwd -p 123456hzj)
cli_ret "${result}" "set_pwd" cli_ret "${result}" "set_pwd"
result=$(${CLI} relayer unlock -p 123456hzj) result=$(${CLI} relayer unlock -p 123456hzj)
...@@ -49,16 +43,13 @@ function InitAndDeploy() { ...@@ -49,16 +43,13 @@ function InitAndDeploy() {
function EthImportKey() { function EthImportKey() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
result=$(${CLI} relayer set_pwd -n 123456hzj -o kk) result=$(${CLI} relayer set_pwd -p 123456hzj)
result=$(${CLI} relayer unlock -p 123456hzj) result=$(${CLI} relayer unlock -p 123456hzj)
result=$(${CLI} relayer ethereum import_chain33privatekey -k "${chain33SenderAddrKey}") result=$(${CLI} relayer ethereum import_chain33privatekey -k "${chain33SenderAddrKey}")
cli_ret "${result}" "import_chain33privatekey" cli_ret "${result}" "import_chain33privatekey"
result=$(${CLI} relayer ethereum import_ethprivatekey -k "${ethValidatorAddrKey}")
cli_ret "${result}" "import_ethprivatekey"
result=$(${CLI} relayer chain33 import_privatekey -k "${ethValidatorAddrKey}") result=$(${CLI} relayer chain33 import_privatekey -k "${ethValidatorAddrKey}")
cli_ret "${result}" "import_ethprivatekey" cli_ret "${result}" "import_ethprivatekey"
...@@ -89,12 +80,12 @@ function StartRelayerAndDeploy() { ...@@ -89,12 +80,12 @@ function StartRelayerAndDeploy() {
kill_ebrelayer "../build/ebrelayer" kill_ebrelayer "../build/ebrelayer"
# 修改 relayer.toml 配置文件 # 修改 relayer.toml 配置文件
updata_relayer_toml ${BridgeRegistry} ${maturityDegree} "../build/relayer.toml" updata_relayer_toml "${BridgeRegistry}" ${maturityDegree} "../build/relayer.toml"
# 重启 ebrelayer 并解锁 # 重启 ebrelayer 并解锁
start_ebrelayer "../build/ebrelayer" "../build/ebrelayer.log" start_ebrelayer "../build/ebrelayer" "../build/ebrelayer.log"
${CLI} relayer set_pwd -n 123456hzj -o kk ${CLI} relayer set_pwd -p 123456hzj
${CLI} relayer unlock -p 123456hzj ${CLI} relayer unlock -p 123456hzj
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}" echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
...@@ -130,10 +121,10 @@ function InitChain33Vilators() { ...@@ -130,10 +121,10 @@ function InitChain33Vilators() {
# query Validators # query Validators
totalPower=$(${Chain33Cli} send x2ethereum query validators -v ${chain33Validator1} -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv | jq .totalPower | sed 's/\"//g') totalPower=$(${Chain33Cli} send x2ethereum query validators -v ${chain33Validator1} -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv | jq .totalPower | sed 's/\"//g')
check_number 87 ${totalPower} check_number 87 "${totalPower}"
totalPower=$(${Chain33Cli} send x2ethereum query totalpower -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv | jq .totalPower | sed 's/\"//g') totalPower=$(${Chain33Cli} send x2ethereum query totalpower -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv | jq .totalPower | sed 's/\"//g')
check_number 100 ${totalPower} check_number 100 "${totalPower}"
# cions 转帐到 x2ethereum 合约地址 # cions 转帐到 x2ethereum 合约地址
hash=$(${Chain33Cli} send coins send_exec -e x2ethereum -a 200 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv) hash=$(${Chain33Cli} send coins send_exec -e x2ethereum -a 200 -k 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv)
...@@ -161,7 +152,7 @@ function TestChain33ToEthAssets() { ...@@ -161,7 +152,7 @@ function TestChain33ToEthAssets() {
cli_ret "${result}" "balance" ".balance" "0" cli_ret "${result}" "balance" ".balance" "0"
# chain33 lock bty # chain33 lock bty
hash=$(${Chain33Cli} send x2ethereum lock -a 5 -t coins.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)) block_wait "${Chain33Cli}" $((maturityDegree + 2))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
...@@ -323,7 +314,7 @@ function TestETH2Chain33Erc20() { ...@@ -323,7 +314,7 @@ function TestETH2Chain33Erc20() {
balance_ret "${result}" "100" balance_ret "${result}" "100"
# chain33 burn 40 # chain33 burn 40
hash=$(${Chain33Cli} send x2ethereum burn -a 40 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q ${tokenAddr} -k "${chain33SenderAddr}") hash=$(${Chain33Cli} send x2ethereum burn -a 40 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q "${tokenAddr}" -k "${chain33SenderAddr}")
block_wait "${Chain33Cli}" $((maturityDegree + 2)) block_wait "${Chain33Cli}" $((maturityDegree + 2))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
...@@ -339,7 +330,7 @@ function TestETH2Chain33Erc20() { ...@@ -339,7 +330,7 @@ function TestETH2Chain33Erc20() {
cli_ret "${result}" "balance" ".balance" "60" cli_ret "${result}" "balance" ".balance" "60"
# burn 60 # burn 60
hash=$(${Chain33Cli} send x2ethereum burn -a 60 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q ${tokenAddr} -k "${chain33SenderAddr}") hash=$(${Chain33Cli} send x2ethereum burn -a 60 -t "${tokenSymbol}" -r ${ethReceiverAddr2} -q "${tokenAddr}" -k "${chain33SenderAddr}")
block_wait "${Chain33Cli}" $((maturityDegree + 2)) block_wait "${Chain33Cli}" $((maturityDegree + 2))
check_tx "${Chain33Cli}" "${hash}" check_tx "${Chain33Cli}" "${hash}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment