Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
82ca30f8
Commit
82ca30f8
authored
May 27, 2020
by
QM
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete ImportEthValidatorPrivateKey MakeNewProphecyClaim
parent
1b8b3721
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
411 additions
and
394 deletions
+411
-394
RopstenTest.sh
plugin/dapp/x2Ethereum/cmd/build/RopstenTest.sh
+1
-13
allRelayerTest.sh
plugin/dapp/x2Ethereum/cmd/build/allRelayerTest.sh
+1
-15
perf_test.sh
plugin/dapp/x2Ethereum/cmd/build/perf_test.sh
+0
-2
ethereumRelayerCmd.go
plugin/dapp/x2Ethereum/ebcli/ethereumRelayerCmd.go
+0
-86
auxiliary.go
plugin/dapp/x2Ethereum/ebrelayer/ethtxs/auxiliary.go
+0
-40
utils.go
plugin/dapp/x2Ethereum/ebrelayer/ethtxs/utils.go
+0
-14
account.go
plugin/dapp/x2Ethereum/ebrelayer/relayer/ethereum/account.go
+21
-81
ethereum.go
...in/dapp/x2Ethereum/ebrelayer/relayer/ethereum/ethereum.go
+13
-34
ethereum_test.go
...pp/x2Ethereum/ebrelayer/relayer/ethereum/ethereum_test.go
+368
-0
manager.go
plugin/dapp/x2Ethereum/ebrelayer/relayer/manager.go
+3
-52
relayer.proto
plugin/dapp/x2Ethereum/ebrelayer/types/protos/relayer.proto
+1
-2
relayer.pb.go
plugin/dapp/x2Ethereum/ebrelayer/types/relayer.pb.go
+1
-2
allRelayerTest.sh
plugin/dapp/x2Ethereum/testsh/allRelayerTest.sh
+1
-13
bridgeBankTest.sh
plugin/dapp/x2Ethereum/testsh/bridgeBankTest.sh
+0
-10
ebrelayerTest.sh
plugin/dapp/x2Ethereum/testsh/ebrelayerTest.sh
+0
-20
x2ethereumTest.sh
plugin/dapp/x2Ethereum/testsh/x2ethereumTest.sh
+1
-10
No files found.
plugin/dapp/x2Ethereum/cmd/build/RopstenTest.sh
View file @
82ca30f8
...
...
@@ -14,14 +14,11 @@ CLIC="./ebcli_C"
CLID
=
"./ebcli_D"
chain33SenderAddr
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
#chain33SenderAddrKey="CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"
# validatorsAddr=["0x92c8b16afd6d423652559c6e266cbe1c29bfd84f", "0x0df9a824699bc5878232c9e612fe1a5346a5a368", "0xcb074cb21cdddf3ce9c3c0a7ac4497d633c9d9f1", "0xd9dab021e74ecf475788ed7b61356056b2095830"]
ethValidatorAddrKeyA
=
"3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
ethValidatorAddrKeyB
=
"a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400"
ethValidatorAddrKeyC
=
"bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e"
ethValidatorAddrKeyD
=
"c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b"
# 新增地址 chain33 需要导入地址 转入 10 bty当收费费
chain33Validator1
=
"1GTxrmuWiXavhcvsaH5w9whgVxUrWsUMdV"
chain33Validator2
=
"155ooMPBTF8QQsGAknkK7ei5D78rwDEFe6"
...
...
@@ -31,11 +28,11 @@ chain33ValidatorKey1="0xd627968e445f2a41c92173225791bae1ba42126ae96c32f28f97ff8f
chain33ValidatorKey2
=
"0x9d539bc5fd084eb7fe86ad631dba9aa086dba38418725c38d9751459f567da66"
chain33ValidatorKey3
=
"0x0a6671f101e30a2cc2d79d77436b62cdf2664ed33eb631a9c9e3f3dd348a23be"
chain33ValidatorKey4
=
"0x3818b257b05ee75b6e43ee0e3cfc2d8502342cf67caed533e3756966690b62a5"
ethReceiverAddr1
=
"0xa4ea64a583f6e51c3799335b28a8f0529570a635"
ethReceiverAddrKey1
=
"355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71"
ethReceiverAddr2
=
"0x0c05ba5c230fdaa503b53702af1962e08d0c60bf"
ethReceiverAddrKey2
=
"9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08"
maturityDegree
=
10
tokenAddrBty
=
""
...
...
@@ -183,15 +180,6 @@ function EthImportKey() {
result
=
$(${
CLID
}
relayer ethereum import_chain33privatekey
-k
"
${
chain33ValidatorKey4
}
"
)
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
}
"
)
cli_ret
"
${
result
}
"
"A relayer chain33 import_privatekey"
result
=
$(${
CLIB
}
relayer chain33 import_privatekey
-k
"
${
ethValidatorAddrKeyB
}
"
)
...
...
plugin/dapp/x2Ethereum/cmd/build/allRelayerTest.sh
View file @
82ca30f8
...
...
@@ -11,21 +11,16 @@ CLIB="./ebcli_B"
CLIC
=
"./ebcli_C"
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
=
""
Chain33Cli
=
""
Chain33Cli
=
"docker exec
${
NODE3
}
/root/chain33-cli"
chain33SenderAddr
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
#chain33SenderAddrKey="CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"
# validatorsAddr=["0x92c8b16afd6d423652559c6e266cbe1c29bfd84f", "0x0df9a824699bc5878232c9e612fe1a5346a5a368", "0xcb074cb21cdddf3ce9c3c0a7ac4497d633c9d9f1", "0xd9dab021e74ecf475788ed7b61356056b2095830"]
ethValidatorAddrKeyA
=
"3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
ethValidatorAddrKeyB
=
"a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400"
ethValidatorAddrKeyC
=
"bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e"
ethValidatorAddrKeyD
=
"c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b"
# 新增地址 chain33 需要导入地址 转入 10 bty当收费费
chain33Validator1
=
"1GTxrmuWiXavhcvsaH5w9whgVxUrWsUMdV"
chain33Validator2
=
"155ooMPBTF8QQsGAknkK7ei5D78rwDEFe6"
...
...
@@ -35,11 +30,11 @@ chain33ValidatorKey1="0xd627968e445f2a41c92173225791bae1ba42126ae96c32f28f97ff8f
chain33ValidatorKey2
=
"0x9d539bc5fd084eb7fe86ad631dba9aa086dba38418725c38d9751459f567da66"
chain33ValidatorKey3
=
"0x0a6671f101e30a2cc2d79d77436b62cdf2664ed33eb631a9c9e3f3dd348a23be"
chain33ValidatorKey4
=
"0x3818b257b05ee75b6e43ee0e3cfc2d8502342cf67caed533e3756966690b62a5"
ethReceiverAddr1
=
"0xa4ea64a583f6e51c3799335b28a8f0529570a635"
ethReceiverAddrKey1
=
"355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71"
ethReceiverAddr2
=
"0x0c05ba5c230fdaa503b53702af1962e08d0c60bf"
ethReceiverAddrKey2
=
"9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08"
maturityDegree
=
10
tokenAddrBty
=
""
tokenAddr
=
""
...
...
@@ -103,15 +98,6 @@ function EthImportKey() {
result
=
$(${
CLID
}
relayer ethereum import_chain33privatekey
-k
"
${
chain33ValidatorKey4
}
"
)
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
}
"
)
cli_ret
"
${
result
}
"
"A relayer chain33 import_privatekey"
result
=
$(${
CLIB
}
relayer chain33 import_privatekey
-k
"
${
ethValidatorAddrKeyB
}
"
)
...
...
plugin/dapp/x2Ethereum/cmd/build/perf_test.sh
View file @
82ca30f8
...
...
@@ -12,8 +12,6 @@ Chain33_CLI=""
Ethsender
=
"0xa4ea64a583f6e51c3799335b28a8f0529570a635"
#ethSender0PrivateKey="3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
privateKeys[0]
=
"8656d2bc732a8a816a461ba5e2d8aac7c7f85c26a813df30d5327210465eb230"
privateKeys[1]
=
"3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
privateKeys[2]
=
"1385016736f7379884763f4a39811d1391fa156a7ca017be6afffa52bb327695"
...
...
plugin/dapp/x2Ethereum/ebcli/ethereumRelayerCmd.go
View file @
82ca30f8
...
...
@@ -23,7 +23,6 @@ func EthereumRelayerCmd() *cobra.Command {
cmd
.
AddCommand
(
ImportChain33PrivateKeyCmd
(),
ImportEthValidatorPrivateKeyCmd
(),
GenEthPrivateKeyCmd
(),
ShowValidatorsAddrCmd
(),
ShowChain33TxsHashCmd
(),
...
...
@@ -35,7 +34,6 @@ func EthereumRelayerCmd() *cobra.Command {
//////auxiliary///////
CreateBridgeTokenCmd
(),
CreateEthereumTokenCmd
(),
MakeNewProphecyClaimCmd
(),
GetBalanceCmd
(),
IsProphecyPendingCmd
(),
MintErc20Cmd
(),
...
...
@@ -79,26 +77,6 @@ func importChain33Privatekey(cmd *cobra.Command, args []string) {
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
{
cmd
:=
&
cobra
.
Command
{
Use
:
"create_eth_key"
,
...
...
@@ -589,70 +567,6 @@ func ShowBridgeRegistryAddr(cmd *cobra.Command, args []string) {
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
{
cmd
:=
&
cobra
.
Command
{
Use
:
"balance"
,
...
...
plugin/dapp/x2Ethereum/ebrelayer/ethtxs/auxiliary.go
View file @
82ca30f8
...
...
@@ -2,7 +2,6 @@ package ethtxs
import
(
"context"
"crypto/ecdsa"
"errors"
"math/big"
...
...
@@ -442,42 +441,3 @@ func LockEthErc20AssetAsync(ownerPrivateKeyStr, tokenAddrStr, chain33Receiver st
}
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
}
plugin/dapp/x2Ethereum/ebrelayer/ethtxs/utils.go
View file @
82ca30f8
...
...
@@ -8,7 +8,6 @@ import (
"sync"
"time"
ebrelayerTypes
"github.com/33cn/plugin/plugin/dapp/x2Ethereum/ebrelayer/types"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
...
...
@@ -65,19 +64,6 @@ func prefixMessage(message common.Hash, key *ecdsa.PrivateKey) ([]byte, []byte)
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
)
{
if
nonceMutex
,
exist
:=
addr2Nonce
[
sender
];
exist
{
nonceMutex
.
rw
.
Lock
()
...
...
plugin/dapp/x2Ethereum/ebrelayer/relayer/ethereum/account.go
View file @
82ca30f8
...
...
@@ -23,7 +23,6 @@ import (
)
var
(
ethAccountKey
=
[]
byte
(
"EthAccount4EthRelayer"
)
chain33AccountKey
=
[]
byte
(
"Chain33Account4EthRelayer"
)
start
=
int
(
1
)
)
...
...
@@ -38,42 +37,31 @@ type Key struct {
}
func
(
ethRelayer
*
Relayer4Ethereum
)
NewAccount
(
passphrase
string
)
(
privateKeystr
,
addr
string
,
err
error
)
{
var
privateKey
*
ecdsa
.
PrivateKey
privateKey
,
privateKeystr
,
addr
,
err
=
newKeyAndStore
(
ethRelayer
.
db
,
crand
.
Reader
,
passphrase
)
_
,
privateKeystr
,
addr
,
err
=
newKeyAndStore
(
ethRelayer
.
db
,
crand
.
Reader
,
passphrase
)
if
err
!=
nil
{
return
""
,
""
,
err
}
ethRelayer
.
SetPrivateKey4Ethereum
(
privateKey
)
return
}
func
(
ethRelayer
*
Relayer4Ethereum
)
GetAccount
(
passphrase
string
)
(
privateKey
,
addr
string
,
err
error
)
{
accountInfo
,
err
:=
ethRelayer
.
db
.
Get
(
eth
AccountKey
)
accountInfo
,
err
:=
ethRelayer
.
db
.
Get
(
chain33
AccountKey
)
if
nil
!=
err
{
return
""
,
""
,
err
}
eth
Account
:=
&
x2ethTypes
.
Account4Relayer
{}
if
err
:=
chain33Types
.
Decode
(
accountInfo
,
eth
Account
);
nil
!=
err
{
Chain33
Account
:=
&
x2ethTypes
.
Account4Relayer
{}
if
err
:=
chain33Types
.
Decode
(
accountInfo
,
Chain33
Account
);
nil
!=
err
{
return
""
,
""
,
err
}
decryptered
:=
wcom
.
CBCDecrypterPrivkey
([]
byte
(
passphrase
),
eth
Account
.
Privkey
)
decryptered
:=
wcom
.
CBCDecrypterPrivkey
([]
byte
(
passphrase
),
Chain33
Account
.
Privkey
)
privateKey
=
chain33Common
.
ToHex
(
decryptered
)
addr
=
eth
Account
.
Addr
addr
=
Chain33
Account
.
Addr
return
}
func
(
ethRelayer
*
Relayer4Ethereum
)
GetValidatorAddr
()
(
validators
x2ethTypes
.
ValidatorAddr4EthRelayer
,
err
error
)
{
var
ethAccountAddr
string
var
chain33AccountAddr
string
accountInfo
,
err
:=
ethRelayer
.
db
.
Get
(
ethAccountKey
)
if
nil
==
err
{
ethAccount
:=
&
x2ethTypes
.
Account4Relayer
{}
if
err
:=
chain33Types
.
Decode
(
accountInfo
,
ethAccount
);
nil
==
err
{
ethAccountAddr
=
ethAccount
.
Addr
}
}
accountInfo
,
err
=
ethRelayer
.
db
.
Get
(
chain33AccountKey
)
accountInfo
,
err
:=
ethRelayer
.
db
.
Get
(
chain33AccountKey
)
if
nil
==
err
{
ethAccount
:=
&
x2ethTypes
.
Account4Relayer
{}
if
err
:=
chain33Types
.
Decode
(
accountInfo
,
ethAccount
);
nil
==
err
{
...
...
@@ -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
}
validators
=
x2ethTypes
.
ValidatorAddr4EthRelayer
{
EthValidator
:
ethAccountAddr
,
Chain33Validator
:
chain33AccountAddr
,
}
return
}
func
(
ethRelayer
*
Relayer4Ethereum
)
RestorePrivateKeys
(
passPhase
string
)
(
err
error
)
{
accountInfo
,
err
:=
ethRelayer
.
db
.
Get
(
ethAccountKey
)
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
)
accountInfo
,
err
:=
ethRelayer
.
db
.
Get
(
chain33AccountKey
)
if
nil
==
err
{
eth
Account
:=
&
x2ethTypes
.
Account4Relayer
{}
if
err
:=
chain33Types
.
Decode
(
accountInfo
,
eth
Account
);
nil
==
err
{
decryptered
:=
wcom
.
CBCDecrypterPrivkey
([]
byte
(
passPhase
),
eth
Account
.
Privkey
)
Chain33
Account
:=
&
x2ethTypes
.
Account4Relayer
{}
if
err
:=
chain33Types
.
Decode
(
accountInfo
,
Chain33
Account
);
nil
==
err
{
decryptered
:=
wcom
.
CBCDecrypterPrivkey
([]
byte
(
passPhase
),
Chain33
Account
.
Privkey
)
var
driver
secp256k1
.
Driver
priKey
,
err
:=
driver
.
PrivKeyFromBytes
(
decryptered
)
if
nil
!=
err
{
...
...
@@ -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
}
...
...
@@ -136,20 +106,20 @@ func (ethRelayer *Relayer4Ethereum) RestorePrivateKeys(passPhase string) (err er
}
func
(
ethRelayer
*
Relayer4Ethereum
)
StoreAccountWithNewPassphase
(
newPassphrase
,
oldPassphrase
string
)
error
{
accountInfo
,
err
:=
ethRelayer
.
db
.
Get
(
eth
AccountKey
)
accountInfo
,
err
:=
ethRelayer
.
db
.
Get
(
chain33
AccountKey
)
if
nil
!=
err
{
relayerLog
.
Info
(
"StoreAccountWithNewPassphase"
,
"pls check account is created already, err"
,
err
)
return
err
}
eth
Account
:=
&
x2ethTypes
.
Account4Relayer
{}
if
err
:=
chain33Types
.
Decode
(
accountInfo
,
eth
Account
);
nil
!=
err
{
Chain33
Account
:=
&
x2ethTypes
.
Account4Relayer
{}
if
err
:=
chain33Types
.
Decode
(
accountInfo
,
Chain33
Account
);
nil
!=
err
{
return
err
}
decryptered
:=
wcom
.
CBCDecrypterPrivkey
([]
byte
(
oldPassphrase
),
eth
Account
.
Privkey
)
decryptered
:=
wcom
.
CBCDecrypterPrivkey
([]
byte
(
oldPassphrase
),
Chain33
Account
.
Privkey
)
encryptered
:=
wcom
.
CBCEncrypterPrivkey
([]
byte
(
newPassphrase
),
decryptered
)
eth
Account
.
Privkey
=
encryptered
encodedInfo
:=
chain33Types
.
Encode
(
eth
Account
)
return
ethRelayer
.
db
.
SetSync
(
eth
AccountKey
,
encodedInfo
)
Chain33
Account
.
Privkey
=
encryptered
encodedInfo
:=
chain33Types
.
Encode
(
Chain33
Account
)
return
ethRelayer
.
db
.
SetSync
(
chain33
AccountKey
,
encodedInfo
)
}
func
(
ethRelayer
*
Relayer4Ethereum
)
ImportChain33PrivateKey
(
passphrase
,
privateKeyStr
string
)
error
{
...
...
@@ -164,9 +134,7 @@ func (ethRelayer *Relayer4Ethereum) ImportChain33PrivateKey(passphrase, privateK
}
ethRelayer
.
privateKey4Chain33
=
priKey
if
nil
!=
ethRelayer
.
privateKey4Ethereum
{
ethRelayer
.
unlockchan
<-
start
}
addr
,
err
:=
pubKeyToAddress4Bty
(
priKey
.
PubKey
()
.
Bytes
())
if
nil
!=
err
{
return
err
...
...
@@ -181,33 +149,6 @@ func (ethRelayer *Relayer4Ethereum) ImportChain33PrivateKey(passphrase, privateK
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.
func
checksum
(
input
[]
byte
)
(
cksum
[
4
]
byte
)
{
h
:=
sha256
.
New
()
...
...
@@ -266,8 +207,7 @@ func newKeyAndStore(db dbm.DB, rand io.Reader, passphrase string) (privateKey *e
Privkey
:
Encryptered
,
Addr
:
key
.
Address
.
Hex
(),
}
encodedInfo
:=
chain33Types
.
Encode
(
ethAccount
)
_
=
db
.
SetSync
(
ethAccountKey
,
encodedInfo
)
_
=
db
privateKeyStr
=
chain33Common
.
ToHex
(
privateKeyBytes
)
addr
=
ethAccount
.
Addr
...
...
plugin/dapp/x2Ethereum/ebrelayer/relayer/ethereum/ethereum.go
View file @
82ca30f8
...
...
@@ -42,12 +42,9 @@ type Relayer4Ethereum struct {
provider
string
clientChainID
*
big
.
Int
bridgeRegistryAddr
common
.
Address
//validatorName string
db
dbm
.
DB
//passphase string
rwLock
sync
.
RWMutex
privateKey4Chain33
chain33Crypto
.
PrivKey
privateKey4Ethereum
*
ecdsa
.
PrivateKey
ethValidator
common
.
Address
totalTx4Eth2Chain33
int64
totalTx4Chain33ToEth
int64
...
...
@@ -110,15 +107,6 @@ func StartEthereumRelayer(rpcURL2Chain33 string, db dbm.DB, provider, registryAd
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
)
recoverDeployPara
()
(
err
error
)
{
if
nil
==
ethRelayer
.
deployInfo
{
return
nil
...
...
@@ -141,24 +129,24 @@ func (ethRelayer *Relayer4Ethereum) recoverDeployPara() (err error) {
func
(
ethRelayer
*
Relayer4Ethereum
)
DeployContrcts
()
(
bridgeRegistry
string
,
err
error
)
{
bridgeRegistry
=
""
if
nil
==
ethRelayer
.
deployInfo
{
return
bridgeRegistry
,
errors
.
New
(
"
N
o deploy info configured yet"
)
return
bridgeRegistry
,
errors
.
New
(
"
n
o deploy info configured yet"
)
}
deployPrivateKey
,
err
:=
crypto
.
ToECDSA
(
common
.
FromHex
(
ethRelayer
.
deployInfo
.
DeployerPrivateKey
))
if
nil
!=
err
{
return
bridgeRegistry
,
err
}
if
len
(
ethRelayer
.
deployInfo
.
ValidatorsAddr
)
!=
len
(
ethRelayer
.
deployInfo
.
InitPowers
)
{
return
bridgeRegistry
,
errors
.
New
(
"
N
ot same number for validator address and power"
)
return
bridgeRegistry
,
errors
.
New
(
"
n
ot same number for validator address and power"
)
}
if
len
(
ethRelayer
.
deployInfo
.
ValidatorsAddr
)
<
3
{
return
bridgeRegistry
,
errors
.
New
(
"
T
he number of validator must be not less than 3"
)
return
bridgeRegistry
,
errors
.
New
(
"
t
he number of validator must be not less than 3"
)
}
nilAddr
:=
common
.
Address
{}
//已经设置了注册合约地址,说明已经部署了相关的合约,不再重复部署
if
ethRelayer
.
bridgeRegistryAddr
!=
nilAddr
{
return
bridgeRegistry
,
errors
.
New
(
"
C
ontract deployed already"
)
return
bridgeRegistry
,
errors
.
New
(
"
c
ontract deployed already"
)
}
var
validators
[]
common
.
Address
...
...
@@ -211,7 +199,7 @@ func (ethRelayer *Relayer4Ethereum) GetBalance(tokenAddr, owner string) (string,
func
(
ethRelayer
*
Relayer4Ethereum
)
ShowBridgeBankAddr
()
(
string
,
error
)
{
if
nil
==
ethRelayer
.
x2EthDeployInfo
{
return
""
,
errors
.
New
(
"
T
he relayer is not started yes"
)
return
""
,
errors
.
New
(
"
t
he relayer is not started yes"
)
}
return
ethRelayer
.
x2EthDeployInfo
.
BridgeBank
.
Address
.
String
(),
nil
...
...
@@ -219,7 +207,7 @@ func (ethRelayer *Relayer4Ethereum) ShowBridgeBankAddr() (string, error) {
func
(
ethRelayer
*
Relayer4Ethereum
)
ShowBridgeRegistryAddr
()
(
string
,
error
)
{
if
nil
==
ethRelayer
.
x2EthDeployInfo
{
return
""
,
errors
.
New
(
"
T
he relayer is not started yes"
)
return
""
,
errors
.
New
(
"
t
he relayer is not started yes"
)
}
return
ethRelayer
.
x2EthDeployInfo
.
BridgeRegistry
.
Address
.
String
(),
nil
...
...
@@ -241,10 +229,6 @@ func (ethRelayer *Relayer4Ethereum) IsProphecyPending(claimID [32]byte) (bool, e
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
)
{
return
ethtxs
.
CreateBridgeToken
(
symbol
,
ethRelayer
.
backend
,
ethRelayer
.
operatorInfo
,
ethRelayer
.
x2EthDeployInfo
,
ethRelayer
.
x2EthContracts
)
}
...
...
@@ -349,12 +333,7 @@ func (ethRelayer *Relayer4Ethereum) proc() {
continueFailCount
:=
int32
(
0
)
for
range
ethRelayer
.
unlockchan
{
relayerLog
.
Info
(
"Received ethRelayer.unlockchan"
)
if
nil
!=
ethRelayer
.
privateKey4Ethereum
&&
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
)
}
if
nil
!=
ethRelayer
.
privateKey4Chain33
&&
nilAddr
!=
ethRelayer
.
bridgeRegistryAddr
{
relayerLog
.
Info
(
"Ethereum relayer starts to run..."
)
ethRelayer
.
prePareSubscribeEvent
()
//向bridgeBank订阅事件
...
...
@@ -571,14 +550,14 @@ func (ethRelayer *Relayer4Ethereum) filterLogEventsProc(logchan chan<- types.Log
relayerLog
.
Info
(
title
,
"received logs with number"
,
len
(
logs
),
"start height"
,
query
.
FromBlock
.
String
(),
"stop height"
,
query
.
ToBlock
.
String
())
for
_
,
log
:=
range
logs
{
relayerLog
.
Info
(
title
,
"received log with topics"
,
log
.
Topics
[
0
]
.
Hex
(),
"BlockNumber"
,
log
.
BlockNumber
)
if
_
,
exist
:=
eventSig
[
log
.
Topics
[
0
]
.
Hex
()];
!
exist
{
for
_
,
log
v
:=
range
logs
{
relayerLog
.
Info
(
title
,
"received log with topics"
,
log
v
.
Topics
[
0
]
.
Hex
(),
"BlockNumber"
,
logv
.
BlockNumber
)
if
_
,
exist
:=
eventSig
[
log
v
.
Topics
[
0
]
.
Hex
()];
!
exist
{
continue
}
logchan
<-
log
relayerLog
.
Info
(
title
,
"get unprocessed log with topic:"
,
log
.
Topics
[
0
]
.
String
(),
"BlockNumber"
,
log
.
BlockNumber
)
logchan
<-
log
v
relayerLog
.
Info
(
title
,
"get unprocessed log with topic:"
,
log
v
.
Topics
[
0
]
.
String
(),
"BlockNumber"
,
log
v
.
BlockNumber
)
}
if
query
.
ToBlock
.
Int64
()
==
curHeight
{
...
...
plugin/dapp/x2Ethereum/ebrelayer/relayer/ethereum/ethereum_test.go
0 → 100644
View file @
82ca30f8
package
ethereum
import
(
"context"
"flag"
"fmt"
"math/big"
"os"
"testing"
"time"
dbm
"github.com/33cn/chain33/common/db"
"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"
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"
)
var
(
configPath
=
flag
.
String
(
"f"
,
"./../../relayer.toml"
,
"configfile"
)
ethPrivateKeyStr
=
"0x3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
ethAccountAddr
=
"0x92C8b16aFD6d423652559C6E266cBE1c29Bfd84f"
chain33PrivateKeyStr
=
"0xd627968e445f2a41c92173225791bae1ba42126ae96c32f28f97ff8f226e5c68"
chain33AccountAddr
=
"1GTxrmuWiXavhcvsaH5w9whgVxUrWsUMdV"
passphrase
=
"123456hzj"
)
type
suiteEthRelayer
struct
{
suite
.
Suite
ethRelayer
*
Relayer4Ethereum
sim
*
backends
.
SimulatedBackend
x2EthContracts
*
ethtxs
.
X2EthContracts
x2EthDeployInfo
*
ethtxs
.
X2EthDeployInfo
para
*
ethtxs
.
DeployPara
}
func
TestRunSuiteX2Ethereum
(
t
*
testing
.
T
)
{
log
:=
new
(
suiteEthRelayer
)
suite
.
Run
(
t
,
log
)
}
func
(
r
*
suiteEthRelayer
)
SetupSuite
()
{
r
.
deployContracts
()
r
.
ethRelayer
=
r
.
newEthRelayer
()
}
func
(
r
*
suiteEthRelayer
)
Test_1_ImportPrivateKey
()
{
validators
,
err
:=
r
.
ethRelayer
.
GetValidatorAddr
()
r
.
Error
(
err
)
r
.
Empty
(
validators
)
//a, b, c := r.ethRelayer.NewAccount("123")
//fmt.Println("++++++++++", a, b, c)
err
=
r
.
ethRelayer
.
ImportChain33PrivateKey
(
passphrase
,
chain33PrivateKeyStr
)
r
.
NoError
(
err
)
privateKey
,
addr
,
err
:=
r
.
ethRelayer
.
GetAccount
(
"123"
)
r
.
NoError
(
err
)
r
.
NotEqual
(
privateKey
,
ethPrivateKeyStr
)
privateKey
,
addr
,
err
=
r
.
ethRelayer
.
GetAccount
(
passphrase
)
r
.
NoError
(
err
)
r
.
Equal
(
privateKey
,
ethPrivateKeyStr
)
r
.
Equal
(
addr
,
ethAccountAddr
)
validators
,
err
=
r
.
ethRelayer
.
GetValidatorAddr
()
r
.
NoError
(
err
)
//r.Equal(validators.EthValidator, ethAccountAddr)
r
.
Equal
(
validators
.
Chain33Validator
,
chain33AccountAddr
)
}
func
(
r
*
suiteEthRelayer
)
Test_2_RestorePrivateKeys
()
{
// 错误的密码 也不报错
err
:=
r
.
ethRelayer
.
RestorePrivateKeys
(
passphrase
)
r
.
NoError
(
err
)
//err = r.ethRelayer.StoreAccountWithNewPassphase(passphrase, passphrase)
//r.NoError(err)
}
func
(
r
*
suiteEthRelayer
)
Test_Relayer4Ethereum_GetAccount
()
{
}
//func (r *suiteEthRelayer) TestRelayer4Ethereum_ApproveAllowance(t *testing.T) {
// r.ethRelayer.ApproveAllowance()
//}
//
//func TestEthRelayerNewRelayerManager(t *testing.T) {
// ctx := context.Background()
// println("TEST:BridgeToken creation (Chain33 assets)")
// //1st部署相关合约
// backend, para := setup.PrepareTestEnv()
// sim := backend.(*backends.SimulatedBackend)
//
// balance, _ := sim.BalanceAt(ctx, para.Deployer, nil)
// fmt.Println("deployer addr,", para.Deployer.String(), "balance =", balance.String())
//
// /////////////////////////EstimateGas///////////////////////////
// callMsg := ethereum.CallMsg{
// From: para.Deployer,
// Data: common.FromHex(generated.BridgeBankBin),
// }
//
// gas, err := sim.EstimateGas(ctx, callMsg)
// if nil != err {
// panic("failed to estimate gas due to:" + err.Error())
// }
// fmt.Printf("\nThe estimated gas=%d", gas)
// ////////////////////////////////////////////////////
//
// x2EthContracts, x2EthDeployInfo, err := ethtxs.DeployAndInit(backend, para)
// if nil != err {
// t.Fatalf("DeployAndInit failed due to:%s", err.Error())
// }
// sim.Commit()
// fmt.Println("x2EthDeployInfo.BridgeBank.Address is:", x2EthDeployInfo.BridgeBank.Address.String(), x2EthContracts.BridgeBank)
// fmt.Println("x2EthDeployInfo.BridgeRegistry.Address is:", x2EthDeployInfo.BridgeRegistry.Address.String())
// ///////////////////////
//
// //defer func() {
// fmt.Println("defer remove datadir")
// err4 := os.RemoveAll("./datadir")
// if err4 != nil {
// fmt.Println(err4)
// }
// //}()
//
// 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()
//
// if *configPath == "" {
// *configPath = "./../relayer.toml"
// }
// cfg := initCfg(*configPath)
// db := dbm.NewDB("relayer_db_service", cfg.SyncTxConfig.Dbdriver, cfg.SyncTxConfig.DbPath, cfg.SyncTxConfig.DbCache)
// cfg.SyncTxConfig.Chain33Host = "http://127.0.0.1:8801"
// cfg.SyncTxConfig.PushBind = "127.0.0.1:20000"
// cfg.SyncTxConfig.FetchHeightPeriodMs = 50
// cfg.BridgeRegistry = "" //x2EthDeployInfo.BridgeRegistry.Address.String()
//
// //cfg.EthProvider = "http://127.0.0.1:1080/"
// //_, err = ethtxs.SetupWebsocketEthClient(cfg.EthProvider)
// //assert.NoError(t, err)
// //return
//
// ctx, cancel := context.WithCancel(context.Background())
//
// chain33RelayerService := ethRelayer.StartChain33Relayer(ctx, cfg.SyncTxConfig, cfg.BridgeRegistry, cfg.EthProvider, db)
// ethRelayerService := ethRelayer.StartEthereumRelayer(cfg.SyncTxConfig.Chain33Host, db, cfg.EthProvider, cfg.BridgeRegistry, cfg.Deploy, cfg.EthMaturityDegree, cfg.EthBlockFetchPeriod)
// //ethRelayer.SetClient(ethRelayerService, sim)
// relayerManager := NewRelayerManager(chain33RelayerService, ethRelayerService, db)
//
// var result interface{}
//
// setPasswdReq := relayerTypes.ReqChangePasswd{
// OldPassphase: "kk",
// NewPassphase: "123456hzj",
// }
//
// err = relayerManager.SetPassphase(setPasswdReq, &result)
// //assert.NoError(t, err)
//
// err = relayerManager.Unlock("123456hzj", &result)
// assert.NoError(t, err)
// fmt.Println(result)
//
// err = relayerManager.ImportChain33PrivateKey4EthRelayer("0xd627968e445f2a41c92173225791bae1ba42126ae96c32f28f97ff8f226e5c68", &result)
// assert.NoError(t, err)
//
// time.Sleep(1 * time.Second)
// ethRelayer.Setx2EthContractsDeployInfo(ethRelayerService, x2EthContracts, x2EthDeployInfo)
// fmt.Println("***************")
// // do something
// {
// bridgeBankBalance, err := sim.BalanceAt(ctx, x2EthDeployInfo.BridgeBank.Address, nil)
// require.Nil(t, err)
// t.Logf("origin eth bridgeBankBalance is:%d", bridgeBankBalance.Int64())
//
// userOneAuth, err := ethtxs.PrepareAuth(backend, para.ValidatorPriKey[0], para.InitValidators[0])
// require.Nil(t, err)
// ethAmount := big.NewInt(50)
// userOneAuth.Value = ethAmount
//
// fmt.Println("origin eth bridgeBankBalance is:", bridgeBankBalance.Int64())
// //lock 50 eth
// chain33Sender := []byte("14KEKbYtKKQm4wMthSK9J4La4nAiidGozt")
// _, err = x2EthContracts.BridgeBank.Lock(userOneAuth, chain33Sender, common.Address{}, ethAmount)
// require.Nil(t, err)
// sim.Commit()
//
// bridgeBankBalance, err = sim.BalanceAt(ctx, x2EthDeployInfo.BridgeBank.Address, nil)
// require.Nil(t, err)
// require.Equal(t, bridgeBankBalance.Int64(), ethAmount.Int64())
// t.Logf("eth bridgeBankBalance changes to:%d", bridgeBankBalance.Int64())
// fmt.Println("eth bridgeBankBalance is:", bridgeBankBalance.Int64())
// }
//
// time.Sleep(5000 * time.Second)
//
// //os.Exit(0)
//
// var wg sync.WaitGroup
//
// ch := make(chan os.Signal, 1)
// signal.Notify(ch, syscall.SIGTERM)
// go func() {
// <-ch
// cancel()
// wg.Wait()
// os.Exit(0)
// }()
//}
func
(
r
*
suiteEthRelayer
)
newEthRelayer
()
*
Relayer4Ethereum
{
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
)
relayer
:=
&
Relayer4Ethereum
{
provider
:
cfg
.
EthProvider
,
db
:
db
,
unlockchan
:
make
(
chan
int
,
2
),
rpcURL2Chain33
:
cfg
.
SyncTxConfig
.
Chain33Host
,
bridgeRegistryAddr
:
r
.
x2EthDeployInfo
.
BridgeRegistry
.
Address
,
deployInfo
:
cfg
.
Deploy
,
maturityDegree
:
cfg
.
EthMaturityDegree
,
fetchHeightPeriodMs
:
cfg
.
EthBlockFetchPeriod
,
}
registrAddrInDB
,
err
:=
relayer
.
getBridgeRegistryAddr
()
//如果输入的registry地址非空,且和数据库保存地址不一致,则直接使用输入注册地址
if
cfg
.
BridgeRegistry
!=
""
&&
nil
==
err
&&
registrAddrInDB
!=
cfg
.
BridgeRegistry
{
relayerLog
.
Error
(
"StartEthereumRelayer"
,
"BridgeRegistry is setted already with value"
,
registrAddrInDB
,
"but now setting to"
,
cfg
.
BridgeRegistry
)
_
=
relayer
.
setBridgeRegistryAddr
(
cfg
.
BridgeRegistry
)
}
else
if
cfg
.
BridgeRegistry
==
""
&&
registrAddrInDB
!=
""
{
//输入地址为空,且数据库中保存地址不为空,则直接使用数据库中的地址
relayer
.
bridgeRegistryAddr
=
common
.
HexToAddress
(
registrAddrInDB
)
}
relayer
.
eventLogIndex
=
relayer
.
getLastBridgeBankProcessedHeight
()
relayer
.
initBridgeBankTx
()
go
r
.
proc
()
//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
*
suiteEthRelayer
)
proc
()
{
r
.
ethRelayer
.
backend
=
r
.
sim
r
.
ethRelayer
.
clientChainID
=
new
(
big
.
Int
)
//等待用户导入
relayerLog
.
Info
(
"Please unlock or import private key for Ethereum relayer"
)
nilAddr
:=
common
.
Address
{}
if
nilAddr
!=
r
.
ethRelayer
.
bridgeRegistryAddr
{
r
.
ethRelayer
.
x2EthContracts
=
r
.
x2EthContracts
r
.
ethRelayer
.
x2EthDeployInfo
=
r
.
x2EthDeployInfo
relayerLog
.
Info
(
"^-^ ^-^ Succeed to recover corresponding solidity contract handler"
)
if
nil
!=
r
.
ethRelayer
.
recoverDeployPara
()
{
panic
(
"Failed to recoverDeployPara"
)
}
r
.
ethRelayer
.
unlockchan
<-
start
}
ctx
:=
context
.
Background
()
var
timer
*
time
.
Ticker
//var err error
continueFailCount
:=
int32
(
0
)
for
range
r
.
ethRelayer
.
unlockchan
{
relayerLog
.
Info
(
"Received ethRelayer.unlockchan"
)
if
nil
!=
r
.
ethRelayer
.
privateKey4Chain33
&&
nilAddr
!=
r
.
ethRelayer
.
bridgeRegistryAddr
{
relayerLog
.
Info
(
"Ethereum relayer starts to run..."
)
r
.
ethRelayer
.
prePareSubscribeEvent
()
//向bridgeBank订阅事件
r
.
ethRelayer
.
subscribeEvent
()
//r.ethRelayer.filterLogEvents()
relayerLog
.
Info
(
"Ethereum relayer starts to process online log event..."
)
timer
=
time
.
NewTicker
(
time
.
Duration
(
r
.
ethRelayer
.
fetchHeightPeriodMs
)
*
time
.
Millisecond
)
goto
latter
}
}
latter
:
for
{
select
{
case
<-
timer
.
C
:
r
.
ethRelayer
.
procNewHeight
(
ctx
,
&
continueFailCount
)
case
err
:=
<-
r
.
ethRelayer
.
bridgeBankSub
.
Err
()
:
panic
(
"bridgeBankSub"
+
err
.
Error
())
case
vLog
:=
<-
r
.
ethRelayer
.
bridgeBankLog
:
r
.
ethRelayer
.
storeBridgeBankLogs
(
vLog
,
true
)
}
}
}
func
(
r
*
suiteEthRelayer
)
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
(
"
\n
The estimated gas=%d
\n
"
,
gas
)
////////////////////////////////////////////////////
r
.
x2EthContracts
,
r
.
x2EthDeployInfo
,
err
=
ethtxs
.
DeployAndInit
(
backend
,
r
.
para
)
r
.
NoError
(
err
)
r
.
sim
.
Commit
()
}
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
}
plugin/dapp/x2Ethereum/ebrelayer/relayer/manager.go
View file @
82ca30f8
...
...
@@ -3,7 +3,6 @@ package relayer
import
(
"errors"
"fmt"
"math/big"
"strconv"
"sync"
"sync/atomic"
...
...
@@ -12,13 +11,11 @@ import (
"github.com/33cn/chain33/common/log/log15"
rpctypes
"github.com/33cn/chain33/rpc/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/ethereum"
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/types"
"github.com/ethereum/go-ethereum/common"
lru
"github.com/hashicorp/golang-lru"
)
...
...
@@ -109,6 +106,9 @@ func (manager *Manager) SetPassphase(setPasswdReq relayerTypes.ReqSetPasswd, res
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
)
{
return
chain33Types
.
ErrInvalidPassWord
...
...
@@ -282,23 +282,6 @@ func (manager *Manager) ImportChain33PrivateKey4EthRelayer(privateKey string, re
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身份进行登录的地址
func
(
manager
*
Manager
)
ShowChain33RelayerValidator
(
param
interface
{},
result
*
interface
{})
error
{
manager
.
mtx
.
Lock
()
...
...
@@ -502,38 +485,6 @@ func (manager *Manager) LockEthErc20Asset(lockEthErc20Asset relayerTypes.LockEth
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
{
manager
.
mtx
.
Lock
()
defer
manager
.
mtx
.
Unlock
()
...
...
plugin/dapp/x2Ethereum/ebrelayer/types/protos/relayer.proto
View file @
82ca30f8
...
...
@@ -11,8 +11,7 @@ message Account4Relayer {
}
message
ValidatorAddr4EthRelayer
{
string
ethValidator
=
1
;
string
chain33Validator
=
2
;
string
chain33Validator
=
1
;
}
message
Txhashes
{
...
...
plugin/dapp/x2Ethereum/ebrelayer/types/relayer.pb.go
View file @
82ca30f8
...
...
@@ -22,8 +22,7 @@ func (m *Account4Relayer) String() string { return proto.CompactTextString(m) }
func
(
*
Account4Relayer
)
ProtoMessage
()
{}
type
ValidatorAddr4EthRelayer
struct
{
EthValidator
string
`protobuf:"bytes,1,opt,name=ethValidator" json:"ethValidator,omitempty"`
Chain33Validator
string
`protobuf:"bytes,2,opt,name=chain33Validator" json:"chain33Validator,omitempty"`
Chain33Validator
string
`protobuf:"bytes,1,opt,name=chain33Validator" json:"chain33Validator,omitempty"`
}
func
(
m
*
ValidatorAddr4EthRelayer
)
Reset
()
{
*
m
=
ValidatorAddr4EthRelayer
{}
}
...
...
plugin/dapp/x2Ethereum/testsh/allRelayerTest.sh
View file @
82ca30f8
...
...
@@ -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"
chain33SenderAddr
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
#chain33SenderAddrKey="CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"
# validatorsAddr=["0x92c8b16afd6d423652559c6e266cbe1c29bfd84f", "0x0df9a824699bc5878232c9e612fe1a5346a5a368", "0xcb074cb21cdddf3ce9c3c0a7ac4497d633c9d9f1", "0xd9dab021e74ecf475788ed7b61356056b2095830"]
ethValidatorAddrKeyA
=
"3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
ethValidatorAddrKeyB
=
"a5f3063552f4483cfc20ac4f40f45b798791379862219de9e915c64722c1d400"
ethValidatorAddrKeyC
=
"bbf5e65539e9af0eb0cfac30bad475111054b09c11d668fc0731d54ea777471e"
ethValidatorAddrKeyD
=
"c9fa31d7984edf81b8ef3b40c761f1847f6fcd5711ab2462da97dc458f1f896b"
# 新增地址 chain33 需要导入地址 转入 10 bty当收费费
chain33Validator1
=
"1GTxrmuWiXavhcvsaH5w9whgVxUrWsUMdV"
chain33Validator2
=
"155ooMPBTF8QQsGAknkK7ei5D78rwDEFe6"
...
...
@@ -34,11 +31,11 @@ chain33ValidatorKey1="0xd627968e445f2a41c92173225791bae1ba42126ae96c32f28f97ff8f
chain33ValidatorKey2
=
"0x9d539bc5fd084eb7fe86ad631dba9aa086dba38418725c38d9751459f567da66"
chain33ValidatorKey3
=
"0x0a6671f101e30a2cc2d79d77436b62cdf2664ed33eb631a9c9e3f3dd348a23be"
chain33ValidatorKey4
=
"0x3818b257b05ee75b6e43ee0e3cfc2d8502342cf67caed533e3756966690b62a5"
ethReceiverAddr1
=
"0xa4ea64a583f6e51c3799335b28a8f0529570a635"
ethReceiverAddrKey1
=
"355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71"
ethReceiverAddr2
=
"0x0c05ba5c230fdaa503b53702af1962e08d0c60bf"
ethReceiverAddrKey2
=
"9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08"
maturityDegree
=
10
function
InitAndDeploy
()
{
...
...
@@ -80,15 +77,6 @@ function EthImportKey() {
result
=
$(${
CLID
}
relayer ethereum import_chain33privatekey
-k
"
${
chain33ValidatorKey4
}
"
)
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
}
"
)
cli_ret
"
${
result
}
"
"A relayer chain33 import_privatekey"
result
=
$(${
CLIB
}
relayer chain33 import_privatekey
-k
"
${
ethValidatorAddrKeyB
}
"
)
...
...
plugin/dapp/x2Ethereum/testsh/bridgeBankTest.sh
View file @
82ca30f8
...
...
@@ -11,18 +11,11 @@ CLI="../build/ebcli_A"
chain33SenderAddr
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
chain33SenderAddrKey
=
"CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"
# 0x92C8b16aFD6d423652559C6E266cBE1c29Bfd84f
ethValidatorAddrKey
=
"3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
ethReceiverAddr1
=
"0xa4ea64a583f6e51c3799335b28a8f0529570a635"
ethReceiverAddrKey1
=
"355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71"
ethReceiverAddr2
=
"0x0c05ba5c230fdaa503b53702af1962e08d0c60bf"
ethReceiverAddrKey2
=
"9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08"
ethReceiverAddr3
=
"0x1919203bA8b325278d28Fb8fFeac49F2CD881A4e"
#ethReceiverAddrKey3="62ca4122aac0e6f35bed02fc15c7ddbdaa07f2f2a1821c8b8210b891051e3ee9"
prophecyTx0
=
"0x112260c98aec81b3e235af47c355db720f60e751cce100fed6f334e1b1530bde"
prophecyTx1
=
"0x222260c98aec81b3e235af47c355db720f60e751cce100fed6f334e1b1530bde"
...
...
@@ -47,9 +40,6 @@ InitAndDeploy() {
result
=
$(${
CLI
}
relayer ethereum import_chain33privatekey
-k
"
${
chain33SenderAddrKey
}
"
)
cli_ret
"
${
result
}
"
"import_chain33privatekey"
result
=
$(${
CLI
}
relayer ethereum import_ethprivatekey
-k
"
${
ethValidatorAddrKey
}
"
)
cli_ret
"
${
result
}
"
"import_ethprivatekey"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
...
...
plugin/dapp/x2Ethereum/testsh/ebrelayerTest.sh
View file @
82ca30f8
...
...
@@ -8,9 +8,6 @@ set -x
source
"./publicTest.sh"
CLIA
=
"../build/ebcli_A"
CLIB
=
"../build/ebcli_B"
CLIC
=
"../build/ebcli_C"
CLID
=
"../build/ebcli_D"
tokenAddr
=
""
chain33SenderAddr
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
...
...
@@ -72,11 +69,6 @@ function InitConfigFile() {
# 启动 B C D 的 ebrelayer 服务,导入私钥
function
ImportCBDKey
()
{
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
start_ebrelayer
"./../build/
$name
/ebrelayer"
"./../build/
$name
/ebrelayer.log"
...
...
@@ -95,18 +87,6 @@ function ImportCBDKey() {
result
=
$(${
CLIA
}
relayer ethereum import_chain33privatekey
-k
"
${
chain33SenderAddrKey
}
"
)
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"
echo
-e
"
${
GRE
}
===========
$FUNCNAME
end ===========
${
NOC
}
"
}
...
...
plugin/dapp/x2Ethereum/testsh/x2ethereumTest.sh
View file @
82ca30f8
...
...
@@ -16,21 +16,15 @@ tokenAddr=""
BridgeRegistry
=
""
chain33SenderAddr
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
chain33SenderAddrKey
=
"CC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944"
ethValidatorAddrKey
=
"3fa21584ae2e4fd74db9b58e2386f5481607dfa4d7ba0617aaa7858e5025dc1e"
ethReceiverAddr1
=
"0xa4ea64a583f6e51c3799335b28a8f0529570a635"
ethReceiverAddrKey1
=
"355b876d7cbcb930d5dfab767f66336ce327e082cbaa1877210c1bae89b1df71"
ethReceiverAddr2
=
"0x0c05ba5c230fdaa503b53702af1962e08d0c60bf"
ethReceiverAddrKey2
=
"9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08"
#ethReceiverAddr3="0x1919203bA8b325278d28Fb8fFeac49F2CD881A4e"
#ethReceiverAddrKey3="62ca4122aac0e6f35bed02fc15c7ddbdaa07f2f2a1821c8b8210b891051e3ee9"
chain33Validator1
=
"14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
chain33Validator2
=
"12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
#0x4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01
chain33Validator3
=
"1BqP2vHkYNjSgdnTqm7pGbnphLhtEhuJFi"
#BtyReceiever="1BqP2vHkYNjSgdnTqm7pGbnphLhtEhuJFi"
#ETHContractAddr="0x0000000000000000000000000000000000000000"
maturityDegree
=
10
function
InitAndDeploy
()
{
...
...
@@ -56,9 +50,6 @@ function EthImportKey() {
result
=
$(${
CLI
}
relayer ethereum import_chain33privatekey
-k
"
${
chain33SenderAddrKey
}
"
)
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
}
"
)
cli_ret
"
${
result
}
"
"import_ethprivatekey"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment