Unverified Commit dbb60dcf authored by vipwzw's avatar vipwzw Committed by GitHub

Merge pull request #1123 from zhengjunhe/withdraw_opt_1217

Withdraw opt 1217
parents 960cd88a d940ed32
......@@ -210,3 +210,37 @@ func CreateNewBridgeToken(cmd *cobra.Command, _ []string) {
}
callContractAndSignWrite(cmd, packData, contract, "create_bridge_token")
}
func SetWithdrawProxyCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "set_withdraw_proxy",
Short: "set withdraw proxy on chain33, and it's should be done by operator",
Run: SetWithdrawProxy,
}
addSetWithdrawProxyFlags(cmd)
return cmd
}
func addSetWithdrawProxyFlags(cmd *cobra.Command) {
cmd.Flags().StringP("address", "a", "", "withdraw address")
_ = cmd.MarkFlagRequired("address")
cmd.Flags().StringP("contract", "c", "", "bridgebank contract address")
_ = cmd.MarkFlagRequired("contract")
cmd.Flags().StringP("key", "k", "", "the deployer private key")
_ = cmd.MarkFlagRequired("key")
cmd.Flags().StringP("note", "n", "", "transaction note info (optional)")
cmd.Flags().Float64P("fee", "f", 0, "contract gas fee (optional)")
}
func SetWithdrawProxy(cmd *cobra.Command, _ []string) {
contract, _ := cmd.Flags().GetString("contract")
withdrawAddr, _ := cmd.Flags().GetString("address")
parameter := fmt.Sprintf("setWithdrawProxy(%s)", withdrawAddr)
_, packData, err := evmAbi.Pack(parameter, generated.BridgeBankABI, false)
if nil != err {
fmt.Println("setWithdrawProxy", "Failed to do abi.Pack due to:", err.Error())
return
}
callContractAndSignWrite(cmd, packData, contract, "set_withdraw_proxy")
}
......@@ -146,10 +146,6 @@ multisignAddrs=["168Sn1DXnLrZHTcAM9stD6t2P49fNuJfJ9", "13KTf57aCkVVJYNJBXBBveiA5
15XsGjTbV6SxQtDE1SC5oaHx8HbseQ4Lf9 -- bridge_token 地址
```
***
***
#### 离线多签设置
* 离线创建交易
......
......@@ -35,6 +35,7 @@ func Boss4xOfflineCmd() *cobra.Command {
ConfigLockedTokenOfflineSaveCmd(),
CreateMultisignTransferCmd(),
MultisignTransferCmd(),
SetWithdrawProxyCmd(),
)
return cmd
}
......
......@@ -7,4 +7,4 @@ initPowers=[25, 25, 25, 25]
# 主链symbol
symbol="ETH"
# 离线多签地址
multisignAddrs=["0x4c85848a7E2985B76f06a7Ed338FCB3aF94a7DCf", "0x6F163E6daf0090D897AD7016484f10e0cE844994", "0xbc333839E37bc7fAAD0137aBaE2275030555101f", "0x495953A743ef169EC5D4aC7b5F786BF2Bd56aFd5"]
\ No newline at end of file
multisignAddrs=["0x4c85848a7E2985B76f06a7Ed338FCB3aF94a7DCf", "0x6F163E6daf0090D897AD7016484f10e0cE844994", "0x0921948C0d25BBbe85285CB5975677503319F02A", "0x69921517970a28b73ac5E4C8ac8Fd135A80D2be1"]
\ No newline at end of file
......@@ -34,6 +34,7 @@ func ConfigplatformTokenSymbol(cmd *cobra.Command, _ []string) {
symbol, _ := cmd.Flags().GetString("symbol")
deployAddr, _ := cmd.Flags().GetString("deployAddr")
contract, _ := cmd.Flags().GetString("contract")
chainEthId, _ := cmd.Flags().GetInt64("chainEthId")
bridgeAbi, err := abi.JSON(strings.NewReader(generated.BridgeBankABI))
if err != nil {
......@@ -46,5 +47,5 @@ func ConfigplatformTokenSymbol(cmd *cobra.Command, _ []string) {
panic(err)
}
CreateTxInfoAndWrite(abiData, deployAddr, contract, "set_symbol", url)
CreateTxInfoAndWrite(abiData, deployAddr, contract, "set_symbol", url, chainEthId)
}
......@@ -6,6 +6,7 @@ import (
"math/big"
"strings"
bep20 "github.com/33cn/plugin/plugin/dapp/cross2eth/contracts/bep20/generated"
"github.com/33cn/plugin/plugin/dapp/cross2eth/contracts/contracts4eth/generated"
erc20 "github.com/33cn/plugin/plugin/dapp/cross2eth/contracts/erc20/generated"
tetherUSDT "github.com/33cn/plugin/plugin/dapp/cross2eth/contracts/usdt/generated"
......@@ -31,6 +32,86 @@ import (
./boss4x ethereum offline send -f deploysigntxs.txt
*/
func DeployBEP20Cmd() *cobra.Command {
cmd := &cobra.Command{
Use: "deploy_bep20",
Short: "deploy BEP20 contracts",
Run: DeployBEP20,
}
DeployBEP20Flags(cmd)
return cmd
}
func DeployBEP20Flags(cmd *cobra.Command) {
cmd.Flags().StringP("deployAddr", "a", "", "addr to deploy contract ")
_ = cmd.MarkFlagRequired("deployAddr")
cmd.Flags().StringP("owner", "o", "", "owner address")
_ = cmd.MarkFlagRequired("owner")
cmd.Flags().StringP("symbol", "s", "", "BEP20 symbol")
_ = cmd.MarkFlagRequired("symbol")
cmd.Flags().StringP("totalSupply", "m", "0", "total supply")
_ = cmd.MarkFlagRequired("totalSupply")
cmd.Flags().IntP("decimal", "d", 8, "decimal")
_ = cmd.MarkFlagRequired("decimal")
}
func DeployBEP20(cmd *cobra.Command, _ []string) {
url, _ := cmd.Flags().GetString("rpc_laddr_ethereum")
deployerAddr, _ := cmd.Flags().GetString("deployAddr")
owner, _ := cmd.Flags().GetString("owner")
symbol, _ := cmd.Flags().GetString("symbol")
totalSupply, _ := cmd.Flags().GetString("totalSupply")
decimal, _ := cmd.Flags().GetInt("decimal")
bnAmount := big.NewInt(1)
bnAmount, _ = bnAmount.SetString(utils.TrimZeroAndDot(totalSupply), 10)
client, err := ethclient.Dial(url)
if err != nil {
fmt.Println("ethclient Dial error", err.Error())
return
}
symbol = strings.ToUpper(symbol)
ctx := context.Background()
startNonce, err := client.PendingNonceAt(ctx, common.HexToAddress(deployerAddr))
if nil != err {
fmt.Println("PendingNonceAt error", err.Error())
return
}
var infos []*DeployInfo
parsed, err := abi.JSON(strings.NewReader(bep20.BEP20TokenABI))
if err != nil {
fmt.Println("abi.JSON(strings.NewReader(erc20.ERC20ABI)) error", err.Error())
return
}
bin := common.FromHex(bep20.BEP20TokenBin)
BEP20OwnerAddr := common.HexToAddress(owner)
//constructor (string memory name_, string memory symbol_,uint256 totalSupply_, uint8 decimals_, address owner_) public {
tokenName := symbol + " Token"
packdata, err := parsed.Pack("", tokenName, symbol, bnAmount, uint8(decimal), BEP20OwnerAddr)
if err != nil {
fmt.Println("Pack error", err.Error())
return
}
BEP20Addr := crypto.CreateAddress(common.HexToAddress(deployerAddr), startNonce)
deployInfo := DeployInfo{
PackData: append(bin, packdata...),
ContractorAddr: BEP20Addr,
Name: "BEP20: " + symbol,
Nonce: startNonce,
To: nil,
}
infos = append(infos, &deployInfo)
fileName := fmt.Sprintf("deployBEP20%s.txt", symbol)
err = NewTxWrite(infos, common.HexToAddress(deployerAddr), url, fileName)
if err != nil {
fmt.Println("NewTxWrite error", err.Error())
return
}
}
func DeployERC20Cmd() *cobra.Command {
cmd := &cobra.Command{
Use: "create_erc20",
......@@ -201,6 +282,7 @@ func AddToken2LockListTx(cmd *cobra.Command, _ []string) {
deployAddr, _ := cmd.Flags().GetString("deployAddr")
token, _ := cmd.Flags().GetString("token")
contract, _ := cmd.Flags().GetString("contract")
chainEthId, _ := cmd.Flags().GetInt64("chainEthId")
bridgeAbi, err := abi.JSON(strings.NewReader(generated.BridgeBankABI))
if err != nil {
......@@ -214,7 +296,7 @@ func AddToken2LockListTx(cmd *cobra.Command, _ []string) {
return
}
CreateTxInfoAndWrite(abiData, deployAddr, contract, "create_add_lock_list", url)
CreateTxInfoAndWrite(abiData, deployAddr, contract, "create_add_lock_list", url, chainEthId)
}
func CreateBridgeTokenTxCmd() *cobra.Command {
......@@ -241,6 +323,7 @@ func CreateBridgeTokenTx(cmd *cobra.Command, _ []string) {
symbol, _ := cmd.Flags().GetString("symbol")
deployAddr, _ := cmd.Flags().GetString("deployAddr")
contract, _ := cmd.Flags().GetString("contract")
chainEthId, _ := cmd.Flags().GetInt64("chainEthId")
bridgeAbi, err := abi.JSON(strings.NewReader(generated.BridgeBankABI))
if err != nil {
......@@ -253,5 +336,5 @@ func CreateBridgeTokenTx(cmd *cobra.Command, _ []string) {
fmt.Println("bridgeAbi.Pack createNewBridgeToken Err:", err)
return
}
CreateTxInfoAndWrite(abiData, deployAddr, contract, "create_bridge_token", url)
CreateTxInfoAndWrite(abiData, deployAddr, contract, "create_bridge_token", url, chainEthId)
}
......@@ -58,6 +58,7 @@ func cfgAccountTx(cmd *cobra.Command, _ []string) {
address, _ := cmd.Flags().GetString("address")
deployAddr, _ := cmd.Flags().GetString("deployAddr")
contract, _ := cmd.Flags().GetString("contract")
chainEthId, _ := cmd.Flags().GetInt64("chainEthId")
bridgeAbi, err := abi.JSON(strings.NewReader(generated.BridgeBankABI))
if err != nil {
......@@ -70,7 +71,7 @@ func cfgAccountTx(cmd *cobra.Command, _ []string) {
panic(err)
}
CreateTxInfoAndWrite(abiData, deployAddr, contract, "set_offline_addr", url)
CreateTxInfoAndWrite(abiData, deployAddr, contract, "set_offline_addr", url, chainEthId)
}
func SetupCmd() *cobra.Command {
......@@ -96,6 +97,7 @@ func SetupOwner(cmd *cobra.Command, _ []string) {
url, _ := cmd.Flags().GetString("rpc_laddr_ethereum")
multisign, _ := cmd.Flags().GetString("multisign")
deployAddr, _ := cmd.Flags().GetString("deployAddr")
chainEthId, _ := cmd.Flags().GetInt64("chainEthId")
owner, _ := cmd.Flags().GetString("owner")
owners := strings.Split(owner, ",")
......@@ -118,6 +120,6 @@ func SetupOwner(cmd *cobra.Command, _ []string) {
return
}
CreateTxInfoAndWrite(abiData, deployAddr, multisign, "multisign_setup", url)
CreateTxInfoAndWrite(abiData, deployAddr, multisign, "multisign_setup", url, chainEthId)
}
......@@ -53,6 +53,7 @@ func ConfigLockedTokenOfflineSave(cmd *cobra.Command, _ []string) {
percents, _ := cmd.Flags().GetUint8("percents")
deployAddr, _ := cmd.Flags().GetString("deployAddr")
contract, _ := cmd.Flags().GetString("contract")
chainEthId, _ := cmd.Flags().GetInt64("chainEthId")
d, err := utils.GetDecimalsFromNode(token, url)
if err != nil {
......@@ -86,5 +87,5 @@ func ConfigLockedTokenOfflineSave(cmd *cobra.Command, _ []string) {
panic(err)
}
CreateTxInfoAndWrite(abiData, deployAddr, contract, "set_offline_token", url)
CreateTxInfoAndWrite(abiData, deployAddr, contract, "set_offline_token", url, chainEthId)
}
......@@ -34,6 +34,7 @@ func DeployOfflineContractsCmd() *cobra.Command {
CreateCmd(), //构造交易
CreateWithFileCmd(),
DeployERC20Cmd(),
DeployBEP20Cmd(),
DeployTetherUSDTCmd(),
//CreateCfgAccountTxCmd(), // set_offline_addr 设置离线多签地址
//SetupCmd(),
......@@ -71,7 +72,7 @@ type DeployConfigInfo struct {
MultisignAddrs []string `toml:"multisignAddrs"`
}
func CreateTxInfoAndWrite(abiData []byte, deployAddr, contract, name, url string) {
func CreateTxInfoAndWrite(abiData []byte, deployAddr, contract, name, url string, chainEthId int64) {
client, err := ethclient.Dial(url)
if err != nil {
fmt.Println("Dial Err:", err)
......@@ -96,14 +97,21 @@ func CreateTxInfoAndWrite(abiData []byte, deployAddr, contract, name, url string
msg.To = &contracAddr
msg.Value = big.NewInt(0)
//估算gas
gasLimit, err := client.EstimateGas(context.Background(), msg)
var gasLimit uint64
// 模拟节点测试
if chainEthId == 1337 {
gasLimit = uint64(500 * 10000)
} else {
gasLimit, err = client.EstimateGas(context.Background(), msg)
if err != nil {
fmt.Println("EstimateGas Err:", err)
return
}
gasLimit = uint64(1.2 * float64(gasLimit))
if gasLimit < 100*10000 {
gasLimit = 100 * 10000
}
}
ntx := types.NewTx(&types.LegacyTx{
Nonce: nonce,
......
......@@ -246,6 +246,7 @@ func addCreateMultisignTransferTxFlags(cmd *cobra.Command) {
func CreateMultisignTransferTx(cmd *cobra.Command, _ []string) {
url, _ := cmd.Flags().GetString("rpc_laddr_ethereum")
chainEthId, _ := cmd.Flags().GetInt64("chainEthId")
txFilePath, _ := cmd.Flags().GetString("file")
client, err := ethclient.Dial(url)
......@@ -282,7 +283,7 @@ func CreateMultisignTransferTx(cmd *cobra.Command, _ []string) {
return
}
CreateTxInfoAndWrite(gnoData, txinfo.SendAddr, txinfo.CrontractAddr, "create_multisign_tx", url)
CreateTxInfoAndWrite(gnoData, txinfo.SendAddr, txinfo.CrontractAddr, "create_multisign_tx", url, chainEthId)
}
func buildSigs(data []byte, privateKeys []string) ([]byte, error) {
......
[{"inputs":[{"internalType":"address","name":"_operatorAddress","type":"address"},{"internalType":"address","name":"_oracleAddress","type":"address"},{"internalType":"address","name":"_ethereumBridgeAddress","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"string","name":"_symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"_beneficiary","type":"address"}],"name":"LogBridgeTokenMint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"string","name":"_symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"_ownerFrom","type":"address"},{"indexed":false,"internalType":"bytes","name":"_ethereumReceiver","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"LogEthereumTokenBurn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_from","type":"address"},{"indexed":false,"internalType":"bytes","name":"_to","type":"bytes"},{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"string","name":"_symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"LogLock","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"string","name":"_symbol","type":"string"}],"name":"LogNewBridgeToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"string","name":"_symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"LogUnlock","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":false,"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"string","name":"_symbol","type":"string"}],"name":"addToken2LockList","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"bridgeTokenCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"bridgeTokenCreated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"bridgeTokenWhitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"_ethereumReceiver","type":"bytes"},{"internalType":"address","name":"_ethereumTokenAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"burnBridgeTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint256","name":"_threshold","type":"uint256"},{"internalType":"uint8","name":"_percents","type":"uint8"}],"name":"configLockedTokenOfflineSave","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"addresspayable","name":"_offlineSave","type":"address"}],"name":"configOfflineSaveAccount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"string","name":"_symbol","type":"string"}],"name":"createNewBridgeToken","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"ethereumBridge","outputs":[{"internalType":"contractEthereumBridge","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"}],"name":"getEthereumDepositStatus","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"string","name":"_symbol","type":"string"}],"name":"getLockedTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"string","name":"_symbol","type":"string"}],"name":"getToken2address","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getofflineSaveCfg","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"string","name":"_symbol","type":"string"}],"name":"hasBridgeTokenCreated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"highThreshold","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"_recipient","type":"bytes"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"lock","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"lockNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lockedFunds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lowThreshold","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"_ethereumSender","type":"bytes"},{"internalType":"addresspayable","name":"_intendedRecipient","type":"address"},{"internalType":"address","name":"_bridgeTokenAddress","type":"address"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mintBridgeTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"offlineSave","outputs":[{"internalType":"addresspayable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"offlineSaveCfgs","outputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"_threshold","type":"uint256"},{"internalType":"uint8","name":"_percents","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"operator","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"oracle","outputs":[{"internalType":"contractOracle","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"token2address","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"tokenAllow2Lock","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"addresspayable","name":"_recipient","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unlock","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"}],"name":"viewEthereumDeposit","outputs":[{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"addresspayable","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]
\ No newline at end of file
[{"inputs":[{"internalType":"address","name":"_operatorAddress","type":"address"},{"internalType":"address","name":"_oracleAddress","type":"address"},{"internalType":"address","name":"_ethereumBridgeAddress","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"string","name":"_symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"_beneficiary","type":"address"}],"name":"LogBridgeTokenMint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"string","name":"_symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"_ownerFrom","type":"address"},{"indexed":false,"internalType":"bytes","name":"_ethereumReceiver","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"LogEthereumTokenBurn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_bridgeToken","type":"address"},{"indexed":false,"internalType":"string","name":"_symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"_ownerFrom","type":"address"},{"indexed":false,"internalType":"bytes","name":"_ethereumReceiver","type":"bytes"},{"indexed":false,"internalType":"address","name":"_proxyReceiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"LogEthereumTokenWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_from","type":"address"},{"indexed":false,"internalType":"bytes","name":"_to","type":"bytes"},{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"string","name":"_symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"LogLock","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"string","name":"_symbol","type":"string"}],"name":"LogNewBridgeToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"string","name":"_symbol","type":"string"},{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"LogUnlock","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":false,"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"string","name":"_symbol","type":"string"}],"name":"addToken2LockList","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"bridgeTokenCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"bridgeTokenCreated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"bridgeTokenWhitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"_ethereumReceiver","type":"bytes"},{"internalType":"address","name":"_ethereumTokenAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"burnBridgeTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint256","name":"_threshold","type":"uint256"},{"internalType":"uint8","name":"_percents","type":"uint8"}],"name":"configLockedTokenOfflineSave","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"addresspayable","name":"_offlineSave","type":"address"}],"name":"configOfflineSaveAccount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"string","name":"_symbol","type":"string"}],"name":"createNewBridgeToken","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"ethereumBridge","outputs":[{"internalType":"contractEthereumBridge","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"}],"name":"getEthereumDepositStatus","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"string","name":"_symbol","type":"string"}],"name":"getLockedTokenAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"string","name":"_symbol","type":"string"}],"name":"getToken2address","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getofflineSaveCfg","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"string","name":"_symbol","type":"string"}],"name":"hasBridgeTokenCreated","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"highThreshold","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"_recipient","type":"bytes"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"lock","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"lockNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lockedFunds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lowThreshold","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"_ethereumSender","type":"bytes"},{"internalType":"addresspayable","name":"_intendedRecipient","type":"address"},{"internalType":"address","name":"_bridgeTokenAddress","type":"address"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mintBridgeTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"offlineSave","outputs":[{"internalType":"addresspayable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"offlineSaveCfgs","outputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"_threshold","type":"uint256"},{"internalType":"uint8","name":"_percents","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"operator","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"oracle","outputs":[{"internalType":"contractOracle","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"addresspayable","name":"_proxyReceiver","type":"address"}],"name":"setWithdrawProxy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"token2address","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"tokenAllow2Lock","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"addresspayable","name":"_recipient","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unlock","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"_id","type":"bytes32"}],"name":"viewEthereumDeposit","outputs":[{"internalType":"bytes","name":"","type":"bytes"},{"internalType":"addresspayable","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"_ethereumReceiver","type":"bytes"},{"internalType":"address","name":"_bridgeTokenAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdrawViaProxy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
\ No newline at end of file
......@@ -5,6 +5,11 @@ services:
entrypoint: ["node", "/app/ganache-core.docker.cli.js", "-a", "20", "-b", "2", "--debug", "-m", "coast bar giraffe art venue decide symbol law visual crater vital fold", "-e", "1000"]
image: trufflesuite/ganache-cli:latest
ebrelayerproxy:
build:
context: .
dockerfile: Dockerfile-cross2eth
ebrelayera:
build:
context: .
......
......@@ -7,6 +7,401 @@ set +e
# 主要在平行链上测试
source "./mainPubilcRelayerTest.sh"
IYellow="\033[0;93m"
le8=100000000
function start_docker_ebrelayerProxy() {
updata_toml proxy
# 代理转账中继器中的标志位ProcessWithDraw设置为true
sed -i 's/^ProcessWithDraw=.*/ProcessWithDraw=true/g' "./relayerproxy.toml"
# shellcheck disable=SC2154
docker cp "./relayerproxy.toml" "${dockerNamePrefix}_ebrelayerproxy_1":/root/relayer.toml
start_docker_ebrelayer "${dockerNamePrefix}_ebrelayerproxy_1" "/root/ebrelayer" "./ebrelayerproxy.log"
sleep 1
# shellcheck disable=SC2154
init_validator_relayer "${CLIP}" "${validatorPwd}" "${chain33ValidatorKeyp}" "${ethValidatorAddrKeyp}"
}
function setWithdraw() {
result=$(${CLIP} ethereum cfgWithdraw -f 1 -s ETH -a 100 -d 18)
cli_ret "${result}" "cfgWithdraw"
result=$(${CLIP} ethereum cfgWithdraw -f 1 -s USDT -a 100 -d 6)
cli_ret "${result}" "cfgWithdraw"
# 在chain33上的bridgeBank合约中设置proxyReceiver
# shellcheck disable=SC2154
${Boss4xCLI} chain33 offline set_withdraw_proxy -c "${chain33BridgeBank}" -a "${chain33Validatorsp}" -k "${chain33DeployKey}" -n "set_withdraw_proxy:${chain33Validatorsp}"
chain33_offline_send "set_withdraw_proxy.txt"
}
# eth to chain33 在以太坊上锁定 ETH 资产,然后在 chain33 上 withdraw
function TestETH2Chain33Assets_proxy() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
echo -e "${GRE}=========== eth to chain33 在以太坊上锁定 ETH 资产,然后在 chain33 上 withdraw ===========${NOC}"
echo -e "${IYellow} lockAmount1 $1 ${NOC}"
local lockAmount1=$1
echo -e "${IYellow} ethBridgeBank 初始金额 ${NOC}"
# shellcheck disable=SC2154
ethBridgeBankBalancebf=$(${CLIP} ethereum balance -o "${ethBridgeBank}" | jq -r ".balance")
echo -e "${IYellow} chain33ReceiverAddr chain33 端 lock 后接收地址初始金额 ${NOC}"
# shellcheck disable=SC2154
chain33RBalancebf=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})")
echo -e "${IYellow} chain33Validatorsp chain33 代理地址初始金额 ${NOC}"
chain33VspBalancebf=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33Validatorsp})")
echo -e "${IYellow} lock ${NOC}"
# shellcheck disable=SC2154
result=$(${CLIP} ethereum lock -m "${lockAmount1}" -k "${ethTestAddrKey1}" -r "${chain33ReceiverAddr}")
cli_ret "${result}" "lock"
# eth 等待 2 个区块
sleep 4
echo -e "${IYellow} ethBridgeBank lock 后金额 ${NOC}"
result=$(${CLIP} ethereum balance -o "${ethBridgeBank}")
# shellcheck disable=SC2219
let ethBridgeBankBalanceEnd=ethBridgeBankBalancebf+lockAmount1
cli_ret "${result}" "balance" ".balance" "${ethBridgeBankBalanceEnd}"
# shellcheck disable=SC2086
sleep "${maturityDegree}"
# chain33 chain33EthBridgeTokenAddr(ETH合约中)查询 lock 金额
echo -e "${IYellow} chain33ReceiverAddr chain33 端 lock 后接收地址 lock 后金额 ${NOC}"
# shellcheck disable=SC2154
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})")
# shellcheck disable=SC2219
let chain33RBalancelock=lockAmount1*le8+chain33RBalancebf
is_equal "${result}" "${chain33RBalancelock}"
echo -e "${IYellow} chain33Validatorsp chain33 代理地址 lock 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33Validatorsp})")
is_equal "${result}" "${chain33VspBalancebf}"
echo -e "${IYellow} ethTestAddr2 ethereum withdraw 接收地址初始金额 ${NOC}"
# shellcheck disable=SC2154
ethT2Balancebf=$(${CLIP} ethereum balance -o "${ethTestAddr2}" | jq -r ".balance")
echo -e "${IYellow} ethValidatorAddrp ethereum 代理地址初始金额 ${NOC}"
# shellcheck disable=SC2154
ethPBalancebf=$(${CLIP} ethereum balance -o "${ethValidatorAddrp}" | jq -r ".balance")
echo -e "${IYellow} withdraw ${NOC}"
# shellcheck disable=SC2154
result=$(${CLIP} chain33 withdraw -m "${lockAmount1}" -k "${chain33ReceiverAddrKey}" -r "${ethTestAddr2}" -t "${chain33EthBridgeTokenAddr}")
cli_ret "${result}" "withdraw"
sleep "${maturityDegree}"
# 查询 ETH 这端 bridgeBank 地址 0
result=$(${CLIP} ethereum balance -o "${ethBridgeBank}")
cli_ret "${result}" "balance" ".balance" "${ethBridgeBankBalanceEnd}"
echo -e "${IYellow} chain33ReceiverAddr chain33 端 lock 后接收地址 withdraw 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})")
is_equal "${result}" "${chain33RBalancebf}"
echo -e "${IYellow} chain33Validatorsp chain33 代理地址 withdraw 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33Validatorsp})")
# shellcheck disable=SC2219
let chain33VspBalancewithdraw=lockAmount1*le8+chain33VspBalancebf
is_equal "${result}" "${chain33VspBalancewithdraw}"
echo -e "${IYellow} ethTestAddr2 ethereum withdraw 接收地址 withdraw 后金额 ${NOC}"
result=$(${CLIP} ethereum balance -o "${ethTestAddr2}" | jq -r ".balance")
ethT2BalanceEnd=$(echo "${ethT2Balancebf}+${lockAmount1}-1" | bc)
is_equal "${result}" "${ethT2BalanceEnd}"
echo -e "${IYellow} ethValidatorAddrp ethereum 代理地址 withdraw 后金额 ${NOC}"
result=$(${CLIP} ethereum balance -o "${ethValidatorAddrp}" | jq -r ".balance")
if [[ $(echo "${ethPBalancebf}-${lockAmount1}+1 < $result" | bc) == 1 ]]; then
echo -e "${RED}error $ethPBalanceEnd 小于 $result, 应该大于 $ethPBalanceEnd 扣了一点点手续费 ${NOC}"
exit 1
fi
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
}
# eth to chain33 在以太坊上锁定 ETH 资产,然后在 chain33 上 withdraw
function TestETH2Chain33Assets_proxy_excess() {
echo -e "${GRE}=========== $FUNCNAME 超额 begin ===========${NOC}"
echo -e "${GRE}=========== eth to chain33 在以太坊上锁定 ETH 资产,然后在 chain33 上 withdraw ===========${NOC}"
echo -e "${IYellow} lockAmount1 $1 ${NOC}"
local lockAmount1=$1
echo -e "${IYellow} ethBridgeBank 初始金额 ${NOC}"
# shellcheck disable=SC2154
ethBridgeBankBalancebf=$(${CLIP} ethereum balance -o "${ethBridgeBank}" | jq -r ".balance")
echo -e "${IYellow} chain33ReceiverAddr chain33 端 lock 后接收地址初始金额 ${NOC}"
# shellcheck disable=SC2154
chain33RBalancebf=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})")
echo -e "${IYellow} chain33Validatorsp chain33 代理地址初始金额 ${NOC}"
chain33VspBalancebf=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33Validatorsp})")
echo -e "${IYellow} lock ${NOC}"
# shellcheck disable=SC2154
result=$(${CLIP} ethereum lock -m "${lockAmount1}" -k "${ethTestAddrKey1}" -r "${chain33ReceiverAddr}")
cli_ret "${result}" "lock"
# eth 等待 2 个区块
sleep 4
echo -e "${IYellow} ethBridgeBank lock 后金额 ${NOC}"
result=$(${CLIP} ethereum balance -o "${ethBridgeBank}")
# shellcheck disable=SC2219
let ethBridgeBankBalanceEnd=ethBridgeBankBalancebf+lockAmount1
cli_ret "${result}" "balance" ".balance" "${ethBridgeBankBalanceEnd}"
# shellcheck disable=SC2086
sleep "${maturityDegree}"
# chain33 chain33EthBridgeTokenAddr(ETH合约中)查询 lock 金额
echo -e "${IYellow} chain33ReceiverAddr chain33 端 lock 后接收地址 lock 后金额 ${NOC}"
# shellcheck disable=SC2154
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})")
# shellcheck disable=SC2219
let chain33RBalancelock=lockAmount1*le8+chain33RBalancebf
is_equal "${result}" "${chain33RBalancelock}"
echo -e "${IYellow} chain33Validatorsp chain33 代理地址 lock 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33Validatorsp})")
is_equal "${result}" "${chain33VspBalancebf}"
echo -e "${IYellow} ethTestAddr2 ethereum withdraw 接收地址初始金额 ${NOC}"
# shellcheck disable=SC2154
ethT2Balancebf=$(${CLIP} ethereum balance -o "${ethTestAddr2}" | jq -r ".balance")
echo -e "${IYellow} ethValidatorAddrp ethereum 代理地址初始金额 ${NOC}"
# shellcheck disable=SC2154
ethPBalancebf=$(${CLIP} ethereum balance -o "${ethValidatorAddrp}" | jq -r ".balance")
echo -e "${IYellow} withdraw ${NOC}"
# shellcheck disable=SC2154
result=$(${CLIP} chain33 withdraw -m "${lockAmount1}" -k "${chain33ReceiverAddrKey}" -r "${ethTestAddr2}" -t "${chain33EthBridgeTokenAddr}")
cli_ret "${result}" "withdraw"
sleep "${maturityDegree}"
# 查询 ETH 这端 bridgeBank 地址 0
result=$(${CLIP} ethereum balance -o "${ethBridgeBank}")
cli_ret "${result}" "balance" ".balance" "${ethBridgeBankBalanceEnd}"
echo -e "${IYellow} chain33ReceiverAddr chain33 端 lock 后接收地址 withdraw 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})")
is_equal "${result}" "${chain33RBalancebf}"
echo -e "${IYellow} chain33Validatorsp chain33 代理地址 withdraw 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33Validatorsp})")
# shellcheck disable=SC2219
let chain33VspBalancewithdraw=lockAmount1*le8+chain33VspBalancebf
is_equal "${result}" "${chain33VspBalancewithdraw}"
echo -e "${IYellow} ethTestAddr2 ethereum withdraw 接收地址 withdraw 后金额 超额了金额跟之前一样${NOC}"
result=$(${CLIP} ethereum balance -o "${ethTestAddr2}" | jq -r ".balance")
is_equal "${result}" "${ethT2Balancebf}"
echo -e "${IYellow} ethValidatorAddrp ethereum 代理地址 withdraw 后金额 超额了金额跟之前一样${NOC}"
result=$(${CLIP} ethereum balance -o "${ethValidatorAddrp}" | jq -r ".balance")
is_equal "${result}" "${ethPBalancebf}"
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
}
function TestETH2Chain33USDT_proxy() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
echo -e "${GRE}=========== eth to chain33 在以太坊上锁定 USDT 资产,然后在 chain33 上 withdraw ===========${NOC}"
echo -e "${IYellow} lockAmount1 $1 ${NOC}"
local lockAmount1=$1
echo -e "${IYellow} ethBridgeBank 初始金额 ${NOC}"
# shellcheck disable=SC2154
ethBridgeBankBalancebf=$(${CLIP} ethereum balance -o "${ethBridgeBank}" -t "${ethereumUSDTERC20TokenAddr}" | jq -r ".balance")
echo -e "${IYellow} chain33ReceiverAddr chain33 端 lock 后接收地址初始金额 ${NOC}"
# shellcheck disable=SC2154
chain33RBalancebf=$(${Chain33Cli} evm query -a "${chain33USDTBridgeTokenAddr}" -c "${chain33TestAddr1}" -b "balanceOf(${chain33ReceiverAddr})")
echo -e "${IYellow} chain33Validatorsp chain33 代理地址初始金额 ${NOC}"
chain33VspBalancebf=$(${Chain33Cli} evm query -a "${chain33USDTBridgeTokenAddr}" -c "${chain33TestAddr1}" -b "balanceOf(${chain33Validatorsp})")
echo -e "${IYellow} ETH 这端 lock $lockAmount1 个 USDT ${NOC}"
result=$(${CLIP} ethereum lock -m "${lockAmount1}" -k "${ethTestAddrKey1}" -r "${chain33ReceiverAddr}" -t "${ethereumUSDTERC20TokenAddr}")
cli_ret "${result}" "lock"
# eth 等待 2 个区块
sleep 4
echo -e "${IYellow} 查询 ETH 这端 ethBridgeBank lock 后金额 ${NOC}"
result=$(${CLIP} ethereum balance -o "${ethBridgeBank}" -t "${ethereumUSDTERC20TokenAddr}")
# shellcheck disable=SC2219
let ethBridgeBankBalanceEnd=ethBridgeBankBalancebf+lockAmount1
cli_ret "${result}" "balance" ".balance" "${ethBridgeBankBalanceEnd}"
sleep "${maturityDegree}"
# chain33 chain33EthBridgeTokenAddr(ETH合约中)查询 lock 金额
echo -e "${IYellow} chain33ReceiverAddr chain33 端 lock 后接收地址 lock 后金额 ${NOC}"
# shellcheck disable=SC2154
result=$(${Chain33Cli} evm query -a "${chain33USDTBridgeTokenAddr}" -c "${chain33TestAddr1}" -b "balanceOf(${chain33ReceiverAddr})")
# shellcheck disable=SC2219
let chain33RBalancelock=lockAmount1*le8+chain33RBalancebf
is_equal "${result}" "${chain33RBalancelock}"
echo -e "${IYellow} chain33Validatorsp chain33 代理地址 lock 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33USDTBridgeTokenAddr}" -c "${chain33TestAddr1}" -b "balanceOf(${chain33Validatorsp})")
is_equal "${result}" "${chain33VspBalancebf}"
echo -e "${IYellow} ethTestAddr2 ethereum withdraw 接收地址初始金额 ${NOC}"
# shellcheck disable=SC2154
ethT2Balancebf=$(${CLIP} ethereum balance -o "${ethReceiverAddr1}" -t "${ethereumUSDTERC20TokenAddr}" | jq -r ".balance")
echo -e "${IYellow} ethValidatorAddrp ethereum 代理地址初始金额 ${NOC}"
# shellcheck disable=SC2154
ethPBalancebf=$(${CLIP} ethereum balance -o "${ethValidatorAddrp}" -t "${ethereumUSDTERC20TokenAddr}" | jq -r ".balance")
echo -e "${IYellow} withdraw ${NOC}"
result=$(${CLIP} chain33 withdraw -m "${lockAmount1}" -k "${chain33ReceiverAddrKey}" -r "${ethReceiverAddr1}" -t "${chain33USDTBridgeTokenAddr}")
cli_ret "${result}" "withdraw"
sleep "${maturityDegree}"
# 查询 ETH 这端 bridgeBank 地址 0
result=$(${CLIP} ethereum balance -o "${ethBridgeBank}" -t "${ethereumUSDTERC20TokenAddr}")
cli_ret "${result}" "balance" ".balance" "${ethBridgeBankBalanceEnd}"
echo -e "${IYellow} chain33ReceiverAddr chain33 端 lock 后接收地址 withdraw 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33USDTBridgeTokenAddr}" -c "${chain33TestAddr1}" -b "balanceOf(${chain33ReceiverAddr})")
is_equal "${result}" "${chain33RBalancebf}"
echo -e "${IYellow} chain33Validatorsp chain33 代理地址 withdraw 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33USDTBridgeTokenAddr}" -c "${chain33TestAddr1}" -b "balanceOf(${chain33Validatorsp})")
# shellcheck disable=SC2219
let chain33VspBalancewithdraw=lockAmount1*le8+chain33VspBalancebf
is_equal "${result}" "${chain33VspBalancewithdraw}"
echo -e "${IYellow} ethTestAddr2 ethereum withdraw 接收地址 withdraw 后金额 ${NOC}"
result=$(${CLIP} ethereum balance -o "${ethReceiverAddr1}" -t "${ethereumUSDTERC20TokenAddr}" | jq -r ".balance")
ethT2BalanceEnd=$(echo "${ethT2Balancebf}+${lockAmount1}-1" | bc)
is_equal "${result}" "${ethT2BalanceEnd}"
echo -e "${IYellow} ethValidatorAddrp ethereum 代理地址 withdraw 后金额 ${NOC}"
result=$(${CLIP} ethereum balance -o "${ethValidatorAddrp}" -t "${ethereumUSDTERC20TokenAddr}" | jq -r ".balance")
# shellcheck disable=SC2219
let ethPBalanceEnd=ethPBalancebf-lockAmount1+1
is_equal "${result}" "${ethPBalanceEnd}"
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
}
function TestETH2Chain33USDT_proxy_excess() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
echo -e "${GRE}=========== eth to chain33 在以太坊上锁定 USDT 资产,然后在 chain33 上 withdraw ===========${NOC}"
echo -e "${IYellow} lockAmount1 $1 ${NOC}"
local lockAmount1=$1
echo -e "${IYellow} ethBridgeBank 初始金额 ${NOC}"
# shellcheck disable=SC2154
ethBridgeBankBalancebf=$(${CLIP} ethereum balance -o "${ethBridgeBank}" -t "${ethereumUSDTERC20TokenAddr}" | jq -r ".balance")
echo -e "${IYellow} chain33ReceiverAddr chain33 端 lock 后接收地址初始金额 ${NOC}"
# shellcheck disable=SC2154
chain33RBalancebf=$(${Chain33Cli} evm query -a "${chain33USDTBridgeTokenAddr}" -c "${chain33TestAddr1}" -b "balanceOf(${chain33ReceiverAddr})")
echo -e "${IYellow} chain33Validatorsp chain33 代理地址初始金额 ${NOC}"
chain33VspBalancebf=$(${Chain33Cli} evm query -a "${chain33USDTBridgeTokenAddr}" -c "${chain33TestAddr1}" -b "balanceOf(${chain33Validatorsp})")
echo -e "${IYellow} ETH 这端 lock $lockAmount1 个 USDT ${NOC}"
result=$(${CLIP} ethereum lock -m "${lockAmount1}" -k "${ethTestAddrKey1}" -r "${chain33ReceiverAddr}" -t "${ethereumUSDTERC20TokenAddr}")
cli_ret "${result}" "lock"
# eth 等待 2 个区块
sleep 4
echo -e "${IYellow} 查询 ETH 这端 ethBridgeBank lock 后金额 ${NOC}"
result=$(${CLIP} ethereum balance -o "${ethBridgeBank}" -t "${ethereumUSDTERC20TokenAddr}")
# shellcheck disable=SC2219
let ethBridgeBankBalanceEnd=ethBridgeBankBalancebf+lockAmount1
cli_ret "${result}" "balance" ".balance" "${ethBridgeBankBalanceEnd}"
sleep "${maturityDegree}"
# chain33 chain33EthBridgeTokenAddr(ETH合约中)查询 lock 金额
echo -e "${IYellow} chain33ReceiverAddr chain33 端 lock 后接收地址 lock 后金额 ${NOC}"
# shellcheck disable=SC2154
result=$(${Chain33Cli} evm query -a "${chain33USDTBridgeTokenAddr}" -c "${chain33TestAddr1}" -b "balanceOf(${chain33ReceiverAddr})")
# shellcheck disable=SC2219
let chain33RBalancelock=lockAmount1*le8+chain33RBalancebf
is_equal "${result}" "${chain33RBalancelock}"
echo -e "${IYellow} chain33Validatorsp chain33 代理地址 lock 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33USDTBridgeTokenAddr}" -c "${chain33TestAddr1}" -b "balanceOf(${chain33Validatorsp})")
is_equal "${result}" "${chain33VspBalancebf}"
echo -e "${IYellow} ethTestAddr2 ethereum withdraw 接收地址初始金额 ${NOC}"
# shellcheck disable=SC2154
ethT2Balancebf=$(${CLIP} ethereum balance -o "${ethReceiverAddr1}" -t "${ethereumUSDTERC20TokenAddr}" | jq -r ".balance")
echo -e "${IYellow} ethValidatorAddrp ethereum 代理地址初始金额 ${NOC}"
# shellcheck disable=SC2154
ethPBalancebf=$(${CLIP} ethereum balance -o "${ethValidatorAddrp}" -t "${ethereumUSDTERC20TokenAddr}" | jq -r ".balance")
echo -e "${IYellow} withdraw ${NOC}"
result=$(${CLIP} chain33 withdraw -m "${lockAmount1}" -k "${chain33ReceiverAddrKey}" -r "${ethReceiverAddr1}" -t "${chain33USDTBridgeTokenAddr}")
cli_ret "${result}" "withdraw"
sleep "${maturityDegree}"
# 查询 ETH 这端 bridgeBank 地址 0
result=$(${CLIP} ethereum balance -o "${ethBridgeBank}" -t "${ethereumUSDTERC20TokenAddr}")
cli_ret "${result}" "balance" ".balance" "${ethBridgeBankBalanceEnd}"
echo -e "${IYellow} chain33ReceiverAddr chain33 端 lock 后接收地址 withdraw 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33USDTBridgeTokenAddr}" -c "${chain33TestAddr1}" -b "balanceOf(${chain33ReceiverAddr})")
is_equal "${result}" "${chain33RBalancebf}"
echo -e "${IYellow} chain33Validatorsp chain33 代理地址 withdraw 后金额 ${NOC}"
result=$(${Chain33Cli} evm query -a "${chain33USDTBridgeTokenAddr}" -c "${chain33TestAddr1}" -b "balanceOf(${chain33Validatorsp})")
# shellcheck disable=SC2219
let chain33VspBalancewithdraw=lockAmount1*le8+chain33VspBalancebf
is_equal "${result}" "${chain33VspBalancewithdraw}"
echo -e "${IYellow} ethTestAddr2 ethereum withdraw 接收地址 withdraw 后金额 超额了金额跟之前一样 ${NOC}"
result=$(${CLIP} ethereum balance -o "${ethReceiverAddr1}" -t "${ethereumUSDTERC20TokenAddr}" | jq -r ".balance")
is_equal "${result}" "${ethT2Balancebf}"
echo -e "${IYellow} ethValidatorAddrp ethereum 代理地址 withdraw 后金额 超额了金额跟之前一样 ${NOC}"
result=$(${CLIP} ethereum balance -o "${ethValidatorAddrp}" -t "${ethereumUSDTERC20TokenAddr}" | jq -r ".balance")
is_equal "${result}" "${ethPBalancebf}"
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
}
function TestRelayerProxy() {
start_docker_ebrelayerProxy
setWithdraw
TestETH2Chain33Assets_proxy 20
TestETH2Chain33Assets_proxy 30
TestETH2Chain33Assets_proxy_excess 100
# shellcheck disable=SC2154
${CLIP} ethereum token token_transfer -k "${ethTestAddrKey1}" -m 500 -r "${ethValidatorAddrp}" -t "${ethereumUSDTERC20TokenAddr}"
TestETH2Chain33USDT_proxy 20
TestETH2Chain33USDT_proxy 40
TestETH2Chain33USDT_proxy_excess 100
}
function AllRelayerMainTest() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
......@@ -34,9 +429,10 @@ function AllRelayerMainTest() {
initPara
StartDockerRelayerDeploy
test_all
TestRelayerProxy
echo_addrs
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
}
......@@ -23,9 +23,6 @@ source "./offlinePublic.sh"
ethereumUSDTERC20TokenAddr=""
chain33USDTBridgeTokenAddr=""
chain33ID=0
maturityDegree=10
# ETH 部署合约者的私钥 用于部署合约时签名使用
ethDeployAddr="0x8AFDADFC88a1087c9A1D6c0F5Dd04634b87F303a"
ethDeployKey="0x8656d2bc732a8a816a461ba5e2d8aac7c7f85c26a813df30d5327210465eb230"
......@@ -70,6 +67,18 @@ source "./offlinePublic.sh"
chain33ReceiverAddr="12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv"
chain33ReceiverAddrKey="4257d8692ef7fe13c68b65d6a52f03933db2fa5ce8faf210b5b8b80c721ced01"
ethValidatorAddrp="0x0c05ba5c230fdaa503b53702af1962e08d0c60bf"
ethValidatorAddrKeyp="9dc6df3a8ab139a54d8a984f54958ae0661f880229bf3bdbb886b87d58b56a08"
chain33Validatorp="1GTxrmuWiXavhcvsaH5w9whgVxUrWsUMdV"
chain33ValidatorKeyp="0xd627968e445f2a41c92173225791bae1ba42126ae96c32f28f97ff8f226e5c68"
chain33Validatorsp="1Hf1wnnr6XaYy5Sf3HhAfT4N8JYV4sMh9J"
chain33ValidatorKeysp="0x1dadb7cbad8ea3f968cfad40ac32981def6215690618e62c48e816e7c732a8c2"
chain33ID=0
maturityDegree=10
validatorPwd="123456fzm"
}
function start_docker_ebrelayerA() {
......@@ -79,9 +88,8 @@ function start_docker_ebrelayerA() {
sleep 5
}
# start ebrelayer B C D
function updata_toml_start_bcd() {
for name in b c d; do
function updata_toml() {
local name=$1
local file="./relayer$name.toml"
cp './relayer.toml' "${file}"
......@@ -98,26 +106,23 @@ function updata_toml_start_bcd() {
line=$(delete_line_show "${file}" "pushBind")
sed -i ''"${line}"' a pushBind="'"${pushHost}"':20000"' "${file}"
}
# start ebrelayer B C D
function updata_toml_start_bcd() {
for name in b c d; do
updata_toml $name
local file="./relayer$name.toml"
docker cp "${file}" "${dockerNamePrefix}_ebrelayer${name}_1":/root/relayer.toml
start_docker_ebrelayer "${dockerNamePrefix}_ebrelayer${name}_1" "/root/ebrelayer" "./ebrelayer${name}.log"
# shellcheck disable=SC2034
CLI="docker exec ${dockerNamePrefix}_ebrelayer${name}_1 /root/ebcli_A"
result=$(${CLI} set_pwd -p 123456hzj)
cli_ret "${result}" "set_pwd"
result=$(${CLI} unlock -p 123456hzj)
cli_ret "${result}" "unlock"
eval chain33ValidatorKey=\$chain33ValidatorKey${name}
# shellcheck disable=SC2154
result=$(${CLI} chain33 import_privatekey -k "${chain33ValidatorKey}")
cli_ret "${result}" "chain33 import_privatekey"
eval ethValidatorAddrKey=\$ethValidatorAddrKey${name}
# shellcheck disable=SC2154
result=$(${CLI} ethereum import_privatekey -k "${ethValidatorAddrKey}")
cli_ret "${result}" "ethereum import_privatekey"
init_validator_relayer "${CLI}" "${validatorPwd}" "${chain33ValidatorKey}" "${ethValidatorAddrKey}"
done
}
......@@ -127,7 +132,7 @@ function restart_ebrelayerA() {
sleep 1
start_docker_ebrelayerA
result=$(${CLIA} unlock -p 123456hzj)
result=$(${CLIA} unlock -p "${validatorPwd}")
cli_ret "${result}" "unlock"
}
......@@ -252,73 +257,59 @@ function TestChain33ToEthAssets() {
#}
# eth to chain33 在以太坊上锁定 ETH 资产,然后在 chain33 上 burn
function TestETH2Chain33Assets() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
echo -e "${GRE}=========== eth to chain33 在以太坊上锁定 ETH 资产,然后在 chain33 上 burn ===========${NOC}"
# 查询 ETH 这端 bridgeBank 地址原来是 0
result=$(${CLIA} ethereum balance -o "${ethBridgeBank}")
cli_ret "${result}" "balance" ".balance" "0"
# ETH 这端 lock 11个
result=$(${CLIA} ethereum lock -m 11 -k "${ethTestAddrKey1}" -r "${chain33ReceiverAddr}")
result=$(${CLIA} ethereum lock -m 0.002 -k "${ethTestAddrKey1}" -r "${chain33ReceiverAddr}")
cli_ret "${result}" "lock"
# eth 等待 2 个区块
sleep 4
# 查询 ETH 这端 bridgeBank 地址 11
result=$(${CLIA} ethereum balance -o "${ethBridgeBank}")
cli_ret "${result}" "balance" ".balance" "11"
cli_ret "${result}" "balance" ".balance" "0.002"
sleep ${maturityDegree}
# chain33 chain33EthBridgeTokenAddr(ETH合约中)查询 lock 金额
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})")
# 结果是 11 * le8
is_equal "${result}" "1100000000"
# is_equal "${result}" "2000000000000000"
# 原来的数额
result=$(${CLIA} ethereum balance -o "${ethTestAddr2}")
cli_ret "${result}" "balance" ".balance" "1000"
echo '#5.burn ETH from Chain33 ETH(Chain33)-----> Ethereum'
result=$(${CLIA} chain33 burn -m 5 -k "${chain33ReceiverAddrKey}" -r "${ethTestAddr2}" -t "${chain33EthBridgeTokenAddr}")
result=$(${CLIA} chain33 burn -m 0.0003 -k "${chain33ReceiverAddrKey}" -r "${ethTestAddr2}" -t "${chain33EthBridgeTokenAddr}")
cli_ret "${result}" "burn"
sleep ${maturityDegree}
echo "check the balance on chain33"
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})")
# 结果是 11-5 * le8
is_equal "${result}" "600000000"
# is_equal "${result}" "1700000000000000"
# 查询 ETH 这端 bridgeBank 地址 0
result=$(${CLIA} ethereum balance -o "${ethBridgeBank}")
cli_ret "${result}" "balance" ".balance" "6"
# 比之前多 5
result=$(${CLIA} ethereum balance -o "${ethTestAddr2}")
cli_ret "${result}" "balance" ".balance" "1005"
cli_ret "${result}" "balance" ".balance" "0.0017"
echo '#5.burn ETH from Chain33 ETH(Chain33)-----> Ethereum 6'
result=$(${CLIA} chain33 burn -m 6 -k "${chain33ReceiverAddrKey}" -r "${ethTestAddr2}" -t "${chain33EthBridgeTokenAddr}")
result=$(${CLIA} chain33 burn -m 0.0017 -k "${chain33ReceiverAddrKey}" -r "${ethTestAddr2}" -t "${chain33EthBridgeTokenAddr}")
cli_ret "${result}" "burn"
sleep ${maturityDegree}
echo "check the balance on chain33"
result=$(${Chain33Cli} evm query -a "${chain33EthBridgeTokenAddr}" -c "${chain33DeployAddr}" -b "balanceOf(${chain33ReceiverAddr})")
# 结果是 11-5 * le8
is_equal "${result}" "0"
# 查询 ETH 这端 bridgeBank 地址 0
result=$(${CLIA} ethereum balance -o "${ethBridgeBank}")
cli_ret "${result}" "balance" ".balance" "0"
# 比之前多 5
result=$(${CLIA} ethereum balance -o "${ethTestAddr2}")
cli_ret "${result}" "balance" ".balance" "1011"
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
}
......@@ -854,6 +845,7 @@ function get_cli() {
Para8801Cli="./chain33-cli --rpc_laddr http://${docker_chain33_ip}:8901 --paraName user.p.para."
Para8901Cli="./chain33-cli --rpc_laddr http://${docker_chain33_ip}:8901 --paraName user.p.para."
CLIP="docker exec ${dockerNamePrefix}_ebrelayerproxy_1 /root/ebcli_A"
CLIA="docker exec ${dockerNamePrefix}_ebrelayera_1 /root/ebcli_A"
CLIB="docker exec ${dockerNamePrefix}_ebrelayerb_1 /root/ebcli_A"
CLIC="docker exec ${dockerNamePrefix}_ebrelayerc_1 /root/ebcli_A"
......
......@@ -73,23 +73,31 @@ function OfflineDeploy() {
echo -e "${GRE}=========== $FUNCNAME end ===========${NOC}"
}
# shellcheck disable=SC2120
function InitRelayerA() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
result=$(${CLIA} set_pwd -p 123456hzj)
# init $1 CLI $2 pwd $3 chain33ValidatorKey $4 ethValidatorAddrKey
function init_validator_relayer() {
local CLI=$1
local pwd=$2
local chain33ValidatorKey=$3
local ethValidatorAddrKey=$4
result=$(${CLI} set_pwd -p "${pwd}")
cli_ret "${result}" "set_pwd"
result=$(${CLIA} unlock -p 123456hzj)
result=$(${CLI} unlock -p "${pwd}")
cli_ret "${result}" "unlock"
# shellcheck disable=SC2154
result=$(${CLIA} chain33 import_privatekey -k "${chain33ValidatorKeya}")
result=$(${CLI} chain33 import_privatekey -k "${chain33ValidatorKey}")
cli_ret "${result}" "chain33 import_privatekey"
# shellcheck disable=SC2154
result=$(${CLIA} ethereum import_privatekey -k "${ethValidatorAddrKeya}")
result=$(${CLI} ethereum import_privatekey -k "${ethValidatorAddrKey}")
cli_ret "${result}" "ethereum import_privatekey"
}
# shellcheck disable=SC2120
function InitRelayerA() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
# shellcheck disable=SC2154
init_validator_relayer "${CLIA}" "${validatorPwd}" "${chain33ValidatorKeya}" "${ethValidatorAddrKeya}"
${CLIA} chain33 multisign set_multiSign -a "${multisignChain33Addr}"
......
......@@ -202,7 +202,8 @@ function start_ebrelayer_and_unlock() {
local CLI="./ebcli_$1"
local count=0
while true; do
result=$(${CLI} relayer unlock -p 123456hzj | jq -r .isOK)
# shellcheck disable=SC2154
result=$(${CLI} relayer unlock -p "${validatorPwd}" | jq -r .isOK)
if [[ ${result} == "true" ]]; then
break
fi
......@@ -225,7 +226,7 @@ function start_ebrelayer_and_setpwd_unlock() {
local CLI="./ebcli_$1"
local count=0
while true; do
result=$(${CLI} relayer set_pwd -p 123456hzj | jq -r .isOK)
result=$(${CLI} relayer set_pwd -p "${validatorPwd}" | jq -r .isOK)
if [[ ${result} == "true" ]]; then
break
fi
......@@ -241,7 +242,7 @@ function start_ebrelayer_and_setpwd_unlock() {
count=0
while true; do
result=$(${CLI} relayer unlock -p 123456hzj | jq -r .isOK)
result=$(${CLI} relayer unlock -p "${validatorPwd}" | jq -r .isOK)
if [[ ${result} == "true" ]]; then
break
fi
......
......@@ -19,12 +19,12 @@ source "./publicTest.sh"
ethMultisignA=0x4c85848a7E2985B76f06a7Ed338FCB3aF94a7DCf
ethMultisignB=0x6F163E6daf0090D897AD7016484f10e0cE844994
ethMultisignC=0xbc333839E37bc7fAAD0137aBaE2275030555101f
ethMultisignD=0x495953A743ef169EC5D4aC7b5F786BF2Bd56aFd5
ethMultisignC=0x0921948C0d25BBbe85285CB5975677503319F02A
ethMultisignD=0x69921517970a28b73ac5E4C8ac8Fd135A80D2be1
ethMultisignKeyA=0x5e8aadb91eaa0fce4df0bcc8bd1af9e703a1d6db78e7a4ebffd6cf045e053574
ethMultisignKeyB=0x0504bcb22b21874b85b15f1bfae19ad62fc2ad89caefc5344dc669c57efa60db
ethMultisignKeyC=0x0c61f5a879d70807686e43eccc1f52987a15230ae0472902834af4d1933674f2
ethMultisignKeyD=0x2809477ede1261da21270096776ba7dc68b89c9df5f029965eaa5fe7f0b80697
ethMultisignKeyC=0x5a43f2c8724f60ea5d6b87ad424daa73639a5fc76702edd3e5eaed37aaffdf49
ethMultisignKeyD=0x03b28c0fc78c6ebae719b559b0781db24644b655d4bd58e5cf2311c9f03baa3d
}
maturityDegree=10
......@@ -66,7 +66,8 @@ function kill_ebrelayerD() {
function start_ebrelayerC() {
nohup ./relayer_C/ebrelayer ./relayer_C/relayer.toml >./relayer_C/cross2eth_C.log 2>&1 &
sleep 2
${CLIC} unlock -p 123456hzj
# shellcheck disable=SC2154
${CLIC} unlock -p "${validatorPwd}"
${Chain33Cli} send coins transfer -a 1 -n note -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 14KEKbYtKKQm4wMthSK9J4La4nAiidGozt
${Chain33Cli} send coins transfer -a 1 -n note -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 14KEKbYtKKQm4wMthSK9J4La4nAiidGozt
sleep ${maturityDegree}
......@@ -76,7 +77,7 @@ function start_ebrelayerC() {
function start_ebrelayerD() {
nohup ./relayer_D/ebrelayer ./relayer_D/relayer.toml >./relayer_D/cross2eth_D.log 2>&1 &
sleep 2
${CLID} unlock -p 123456hzj
${CLID} unlock -p "${validatorPwd}"
${Chain33Cli} send coins transfer -a 1 -n note -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 14KEKbYtKKQm4wMthSK9J4La4nAiidGozt
${Chain33Cli} send coins transfer -a 1 -n note -t 12qyocayNF7Lv6C9qW4avxs2E7U41fKSfv -k 14KEKbYtKKQm4wMthSK9J4La4nAiidGozt
sleep ${maturityDegree}
......@@ -86,10 +87,10 @@ function start_ebrelayerD() {
function InitAndDeploy() {
echo -e "${GRE}=========== $FUNCNAME begin ===========${NOC}"
result=$(${CLIA} set_pwd -p 123456hzj)
result=$(${CLIA} set_pwd -p "${validatorPwd}")
cli_ret "${result}" "set_pwd"
result=$(${CLIA} unlock -p 123456hzj)
result=$(${CLIA} unlock -p "${validatorPwd}")
cli_ret "${result}" "unlock"
# shellcheck disable=SC2154
......@@ -287,10 +288,10 @@ function updata_toml_start_BCD() {
sleep 2
CLI="./ebcli_$name"
result=$(${CLI} set_pwd -p 123456hzj)
result=$(${CLI} set_pwd -p "${validatorPwd}")
cli_ret "${result}" "set_pwd"
result=$(${CLI} unlock -p 123456hzj)
result=$(${CLI} unlock -p "${validatorPwd}")
cli_ret "${result}" "unlock"
eval chain33ValidatorKey=\$chain33ValidatorKey${name}
......@@ -358,7 +359,7 @@ function StartRelayerAndDeploy() {
kill_ebrelayer ebrelayer
start_ebrelayerA
result=$(${CLIA} unlock -p 123456hzj)
result=$(${CLIA} unlock -p "${validatorPwd}")
cli_ret "${result}" "unlock"
# start ebrelayer B C D
......@@ -424,7 +425,7 @@ function InitChain33Validator() {
}
# 导入 chain33Validators 私钥生成地址
for name in a b c d; do
for name in a b c d p sp; do
eval chain33ValidatorKey=\$chain33ValidatorKey${name}
eval chain33Validator=\$chain33Validator${name}
result=$(${Chain33Cli} account import_key -k "${chain33ValidatorKey}" -l validator$name)
......@@ -526,7 +527,7 @@ function StartOneRelayer() {
kill_ebrelayer ebrelayer
start_ebrelayerA
result=$(${CLIA} unlock -p 123456hzj)
result=$(${CLIA} unlock -p "${validatorPwd}")
cli_ret "${result}" "unlock"
# 设置 token 地址
......
......@@ -352,14 +352,24 @@ contract BEP20Token is Context, IBEP20, Ownable {
string private _symbol;
string private _name;
constructor() public {
_name = "BUSD Token";
_symbol = "BUSD";
_decimals = 18;
_totalSupply = 31000000000000000000000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
// constructor() public {
// _name = "BUSD Token";
// _symbol = "BUSD";
// _decimals = 18;
// _totalSupply = 31000000000000000000000000;
// _balances[msg.sender] = _totalSupply;
//
// emit Transfer(address(0), msg.sender, _totalSupply);
// }
constructor (string memory name_, string memory symbol_,uint256 totalSupply_, uint8 decimals_, address owner_) public {
_name = name_;
_symbol = symbol_;
_decimals = decimals_;
_totalSupply = totalSupply_;
_balances[owner_] = totalSupply_;
emit Transfer(address(0), owner_, totalSupply_);
}
/**
......
......@@ -27,7 +27,7 @@ var (
)
// BEP20TokenABI is the input ABI used to generate the binding from.
const BEP20TokenABI = "[{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
const BEP20TokenABI = "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name_\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol_\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"totalSupply_\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"decimals_\",\"type\":\"uint8\"},{\"internalType\":\"address\",\"name\":\"owner_\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"burn\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getOwner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
// BEP20TokenFuncSigs maps the 4-byte function signature to its string representation.
var BEP20TokenFuncSigs = map[string]string{
......@@ -51,16 +51,16 @@ var BEP20TokenFuncSigs = map[string]string{
}
// BEP20TokenBin is the compiled bytecode used for deploying new contracts.
var BEP20TokenBin = "0x60806040523480156200001157600080fd5b506000620000276001600160e01b036200014016565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a35060408051808201909152600a80825269212aa9a2102a37b5b2b760b11b6020909201918252620000a49160069162000145565b5060408051808201909152600480825263109554d160e21b6020909201918252620000d29160059162000145565b506004805460ff191660121790556a19a4815e0ad0c67f0000006003819055336000818152600160209081526040808320859055805194855251929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a3620001e7565b335b90565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106200018857805160ff1916838001178555620001b8565b82800160010185558215620001b8579182015b82811115620001b85782518255916020019190600101906200019b565b50620001c6929150620001ca565b5090565b6200014291905b80821115620001c65760008155600101620001d1565b61101280620001f76000396000f3fe608060405234801561001057600080fd5b506004361061010b5760003560e01c8063715018a6116100a2578063a0712d6811610071578063a0712d68146102e8578063a457c2d714610305578063a9059cbb14610331578063dd62ed3e1461035d578063f2fde38b1461038b5761010b565b8063715018a6146102aa578063893d20e8146102b45780638da5cb5b146102d857806395d89b41146102e05761010b565b8063313ce567116100de578063313ce5671461021d578063395093511461023b57806342966c681461026757806370a08231146102845761010b565b806306fdde0314610110578063095ea7b31461018d57806318160ddd146101cd57806323b872dd146101e7575b600080fd5b6101186103b1565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561015257818101518382015260200161013a565b50505050905090810190601f16801561017f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101b9600480360360408110156101a357600080fd5b506001600160a01b038135169060200135610447565b604080519115158252519081900360200190f35b6101d5610464565b60408051918252519081900360200190f35b6101b9600480360360608110156101fd57600080fd5b506001600160a01b0381358116916020810135909116906040013561046a565b6102256104f7565b6040805160ff9092168252519081900360200190f35b6101b96004803603604081101561025157600080fd5b506001600160a01b038135169060200135610500565b6101b96004803603602081101561027d57600080fd5b5035610554565b6101d56004803603602081101561029a57600080fd5b50356001600160a01b031661056f565b6102b261058a565b005b6102bc61063e565b604080516001600160a01b039092168252519081900360200190f35b6102bc61064d565b61011861065c565b6101b9600480360360208110156102fe57600080fd5b50356106bd565b6101b96004803603604081101561031b57600080fd5b506001600160a01b03813516906020013561073a565b6101b96004803603604081101561034757600080fd5b506001600160a01b0381351690602001356107a8565b6101d56004803603604081101561037357600080fd5b506001600160a01b03813581169160200135166107bc565b6102b2600480360360208110156103a157600080fd5b50356001600160a01b03166107e7565b60068054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561043d5780601f106104125761010080835404028352916020019161043d565b820191906000526020600020905b81548152906001019060200180831161042057829003601f168201915b5050505050905090565b600061045b61045461085d565b8484610861565b50600192915050565b60035490565b600061047784848461094d565b6104ed8461048361085d565b6104e885604051806060016040528060288152602001610ee3602891396001600160a01b038a166000908152600260205260408120906104c161085d565b6001600160a01b03168152602081019190915260400160002054919063ffffffff610aab16565b610861565b5060019392505050565b60045460ff1690565b600061045b61050d61085d565b846104e8856002600061051e61085d565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff610b4216565b600061056761056161085d565b83610ba3565b506001919050565b6001600160a01b031660009081526001602052604090205490565b61059261085d565b6000546001600160a01b039081169116146105f4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600061064861064d565b905090565b6000546001600160a01b031690565b60058054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561043d5780601f106104125761010080835404028352916020019161043d565b60006106c761085d565b6000546001600160a01b03908116911614610729576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61056761073461085d565b83610c9f565b600061045b61074761085d565b846104e885604051806060016040528060258152602001610f54602591396002600061077161085d565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff610aab16565b600061045b6107b561085d565b848461094d565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6107ef61085d565b6000546001600160a01b03908116911614610851576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61085a81610d91565b50565b3390565b6001600160a01b0383166108a65760405162461bcd60e51b8152600401808060200182810382526024815260200180610e996024913960400191505060405180910390fd5b6001600160a01b0382166108eb5760405162461bcd60e51b8152600401808060200182810382526022815260200180610fbc6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166109925760405162461bcd60e51b8152600401808060200182810382526025815260200180610e746025913960400191505060405180910390fd5b6001600160a01b0382166109d75760405162461bcd60e51b8152600401808060200182810382526023815260200180610f316023913960400191505060405180910390fd5b610a1a81604051806060016040528060268152602001610f0b602691396001600160a01b038616600090815260016020526040902054919063ffffffff610aab16565b6001600160a01b038085166000908152600160205260408082209390935590841681522054610a4f908263ffffffff610b4216565b6001600160a01b0380841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008184841115610b3a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610aff578181015183820152602001610ae7565b50505050905090810190601f168015610b2c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610b9c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b038216610be85760405162461bcd60e51b8152600401808060200182810382526021815260200180610f796021913960400191505060405180910390fd5b610c2b81604051806060016040528060228152602001610f9a602291396001600160a01b038516600090815260016020526040902054919063ffffffff610aab16565b6001600160a01b038316600090815260016020526040902055600354610c57908263ffffffff610e3116565b6003556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6001600160a01b038216610cfa576040805162461bcd60e51b815260206004820152601f60248201527f42455032303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b600354610d0d908263ffffffff610b4216565b6003556001600160a01b038216600090815260016020526040902054610d39908263ffffffff610b4216565b6001600160a01b03831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b038116610dd65760405162461bcd60e51b8152600401808060200182810382526026815260200180610ebd6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000610b9c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610aab56fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737342455032303a20617070726f76652066726f6d20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737342455032303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737342455032303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f42455032303a206275726e2066726f6d20746865207a65726f206164647265737342455032303a206275726e20616d6f756e7420657863656564732062616c616e636542455032303a20617070726f766520746f20746865207a65726f2061646472657373a265627a7a72315820b5c2e5f64b095feb67d61703a6522b27d72f78a18e409e741e42ca40a08d724864736f6c63430005100032"
var BEP20TokenBin = "0x60806040523480156200001157600080fd5b506040516200137638038062001376833981810160405260a08110156200003757600080fd5b81019080805160405193929190846401000000008211156200005857600080fd5b9083019060208201858111156200006e57600080fd5b82516401000000008111828201881017156200008957600080fd5b82525081516020918201929091019080838360005b83811015620000b85781810151838201526020016200009e565b50505050905090810190601f168015620000e65780820380516001836020036101000a031916815260200191505b50604052602001805160405193929190846401000000008211156200010a57600080fd5b9083019060208201858111156200012057600080fd5b82516401000000008111828201881017156200013b57600080fd5b82525081516020918201929091019080838360005b838110156200016a57818101518382015260200162000150565b50505050905090810190601f168015620001985780820380516001836020036101000a031916815260200191505b5060409081526020820151908201516060909201519093509091506000620001c86001600160e01b03620002ad16565b600080546001600160a01b0319166001600160a01b0383169081178255604051929350917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a350845162000227906006906020880190620002b2565b5083516200023d906005906020870190620002b2565b506004805460ff191660ff841617905560038390556001600160a01b0381166000818152600160209081526040808320879055805187815290517fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef929181900390910190a3505050505062000354565b335b90565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10620002f557805160ff191683800117855562000325565b8280016001018555821562000325579182015b828111156200032557825182559160200191906001019062000308565b506200033392915062000337565b5090565b620002af91905b808211156200033357600081556001016200033e565b61101280620003646000396000f3fe608060405234801561001057600080fd5b506004361061010b5760003560e01c8063715018a6116100a2578063a0712d6811610071578063a0712d68146102e8578063a457c2d714610305578063a9059cbb14610331578063dd62ed3e1461035d578063f2fde38b1461038b5761010b565b8063715018a6146102aa578063893d20e8146102b45780638da5cb5b146102d857806395d89b41146102e05761010b565b8063313ce567116100de578063313ce5671461021d578063395093511461023b57806342966c681461026757806370a08231146102845761010b565b806306fdde0314610110578063095ea7b31461018d57806318160ddd146101cd57806323b872dd146101e7575b600080fd5b6101186103b1565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561015257818101518382015260200161013a565b50505050905090810190601f16801561017f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101b9600480360360408110156101a357600080fd5b506001600160a01b038135169060200135610447565b604080519115158252519081900360200190f35b6101d5610464565b60408051918252519081900360200190f35b6101b9600480360360608110156101fd57600080fd5b506001600160a01b0381358116916020810135909116906040013561046a565b6102256104f7565b6040805160ff9092168252519081900360200190f35b6101b96004803603604081101561025157600080fd5b506001600160a01b038135169060200135610500565b6101b96004803603602081101561027d57600080fd5b5035610554565b6101d56004803603602081101561029a57600080fd5b50356001600160a01b031661056f565b6102b261058a565b005b6102bc61063e565b604080516001600160a01b039092168252519081900360200190f35b6102bc61064d565b61011861065c565b6101b9600480360360208110156102fe57600080fd5b50356106bd565b6101b96004803603604081101561031b57600080fd5b506001600160a01b03813516906020013561073a565b6101b96004803603604081101561034757600080fd5b506001600160a01b0381351690602001356107a8565b6101d56004803603604081101561037357600080fd5b506001600160a01b03813581169160200135166107bc565b6102b2600480360360208110156103a157600080fd5b50356001600160a01b03166107e7565b60068054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561043d5780601f106104125761010080835404028352916020019161043d565b820191906000526020600020905b81548152906001019060200180831161042057829003601f168201915b5050505050905090565b600061045b61045461085d565b8484610861565b50600192915050565b60035490565b600061047784848461094d565b6104ed8461048361085d565b6104e885604051806060016040528060288152602001610ee3602891396001600160a01b038a166000908152600260205260408120906104c161085d565b6001600160a01b03168152602081019190915260400160002054919063ffffffff610aab16565b610861565b5060019392505050565b60045460ff1690565b600061045b61050d61085d565b846104e8856002600061051e61085d565b6001600160a01b03908116825260208083019390935260409182016000908120918c16815292529020549063ffffffff610b4216565b600061056761056161085d565b83610ba3565b506001919050565b6001600160a01b031660009081526001602052604090205490565b61059261085d565b6000546001600160a01b039081169116146105f4576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b600061064861064d565b905090565b6000546001600160a01b031690565b60058054604080516020601f600260001961010060018816150201909516949094049384018190048102820181019092528281526060939092909183018282801561043d5780601f106104125761010080835404028352916020019161043d565b60006106c761085d565b6000546001600160a01b03908116911614610729576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61056761073461085d565b83610c9f565b600061045b61074761085d565b846104e885604051806060016040528060258152602001610f54602591396002600061077161085d565b6001600160a01b03908116825260208083019390935260409182016000908120918d1681529252902054919063ffffffff610aab16565b600061045b6107b561085d565b848461094d565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6107ef61085d565b6000546001600160a01b03908116911614610851576040805162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015290519081900360640190fd5b61085a81610d91565b50565b3390565b6001600160a01b0383166108a65760405162461bcd60e51b8152600401808060200182810382526024815260200180610e996024913960400191505060405180910390fd5b6001600160a01b0382166108eb5760405162461bcd60e51b8152600401808060200182810382526022815260200180610fbc6022913960400191505060405180910390fd5b6001600160a01b03808416600081815260026020908152604080832094871680845294825291829020859055815185815291517f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259281900390910190a3505050565b6001600160a01b0383166109925760405162461bcd60e51b8152600401808060200182810382526025815260200180610e746025913960400191505060405180910390fd5b6001600160a01b0382166109d75760405162461bcd60e51b8152600401808060200182810382526023815260200180610f316023913960400191505060405180910390fd5b610a1a81604051806060016040528060268152602001610f0b602691396001600160a01b038616600090815260016020526040902054919063ffffffff610aab16565b6001600160a01b038085166000908152600160205260408082209390935590841681522054610a4f908263ffffffff610b4216565b6001600160a01b0380841660008181526001602090815260409182902094909455805185815290519193928716927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a3505050565b60008184841115610b3a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015610aff578181015183820152602001610ae7565b50505050905090810190601f168015610b2c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600082820183811015610b9c576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b9392505050565b6001600160a01b038216610be85760405162461bcd60e51b8152600401808060200182810382526021815260200180610f796021913960400191505060405180910390fd5b610c2b81604051806060016040528060228152602001610f9a602291396001600160a01b038516600090815260016020526040902054919063ffffffff610aab16565b6001600160a01b038316600090815260016020526040902055600354610c57908263ffffffff610e3116565b6003556040805182815290516000916001600160a01b038516917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9181900360200190a35050565b6001600160a01b038216610cfa576040805162461bcd60e51b815260206004820152601f60248201527f42455032303a206d696e7420746f20746865207a65726f206164647265737300604482015290519081900360640190fd5b600354610d0d908263ffffffff610b4216565b6003556001600160a01b038216600090815260016020526040902054610d39908263ffffffff610b4216565b6001600160a01b03831660008181526001602090815260408083209490945583518581529351929391927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a35050565b6001600160a01b038116610dd65760405162461bcd60e51b8152600401808060200182810382526026815260200180610ebd6026913960400191505060405180910390fd5b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b6000610b9c83836040518060400160405280601e81526020017f536166654d6174683a207375627472616374696f6e206f766572666c6f770000815250610aab56fe42455032303a207472616e736665722066726f6d20746865207a65726f206164647265737342455032303a20617070726f76652066726f6d20746865207a65726f20616464726573734f776e61626c653a206e6577206f776e657220697320746865207a65726f206164647265737342455032303a207472616e7366657220616d6f756e74206578636565647320616c6c6f77616e636542455032303a207472616e7366657220616d6f756e7420657863656564732062616c616e636542455032303a207472616e7366657220746f20746865207a65726f206164647265737342455032303a2064656372656173656420616c6c6f77616e63652062656c6f77207a65726f42455032303a206275726e2066726f6d20746865207a65726f206164647265737342455032303a206275726e20616d6f756e7420657863656564732062616c616e636542455032303a20617070726f766520746f20746865207a65726f2061646472657373a265627a7a7231582025416cdbf9b945005934d675f191045f10aa19e01a092d62f0408f9bb68dcccc64736f6c63430005100032"
// DeployBEP20Token deploys a new Ethereum contract, binding an instance of BEP20Token to it.
func DeployBEP20Token(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *BEP20Token, error) {
func DeployBEP20Token(auth *bind.TransactOpts, backend bind.ContractBackend, name_ string, symbol_ string, totalSupply_ *big.Int, decimals_ uint8, owner_ common.Address) (common.Address, *types.Transaction, *BEP20Token, error) {
parsed, err := abi.JSON(strings.NewReader(BEP20TokenABI))
if err != nil {
return common.Address{}, nil, nil, err
}
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(BEP20TokenBin), backend)
address, tx, contract, err := bind.DeployContract(auth, parsed, common.FromHex(BEP20TokenBin), backend, name_, symbol_, totalSupply_, decimals_, owner_)
if err != nil {
return common.Address{}, nil, nil, err
}
......@@ -2381,7 +2381,7 @@ func (_Ownable *OwnableFilterer) ParseOwnershipTransferred(log types.Log) (*Owna
const SafeMathABI = "[]"
// SafeMathBin is the compiled bytecode used for deploying new contracts.
var SafeMathBin = "0x60556023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea265627a7a7231582014d153f6b8d9f2ffce41ada85af7f4fd578c027480fe15c51aa8363b7a71e4e164736f6c63430005100032"
var SafeMathBin = "0x60556023600b82828239805160001a607314601657fe5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea265627a7a723158206928e77ad1c66c3c933485749c27b8dfb6b4722468e9fe79228443c548dc39ef64736f6c63430005100032"
// DeploySafeMath deploys a new Ethereum contract, binding an instance of SafeMath to it.
func DeploySafeMath(auth *bind.TransactOpts, backend bind.ContractBackend) (common.Address, *types.Transaction, *SafeMath, error) {
......
......@@ -106,6 +106,17 @@ contract BridgeBank is EthereumBank, Chain33Bank {
}
/*
* @dev: set a proxy address to receive and it's transfer asset on Ethereum
*
* @param _proxyReceiver: The address to receive asset
* @return: indicate whether set successfully or not
*/
function setWithdrawProxy(address payable _proxyReceiver) public onlyOperator
{
proxyReceiver = _proxyReceiver;
}
/*
* @dev: Mints new BankTokens
*
* @param _ethereumSender: The sender's Ethereum address in bytes.
......@@ -137,7 +148,7 @@ contract BridgeBank is EthereumBank, Chain33Bank {
* @dev: Burns bank tokens
*
* @param _ethereumReceiver: The _ethereum receiver address in bytes.
* @param _ethereumTokenAddress: The currency type
* @param _ethereumTokenAddress: The token address mint on chain33 and it's origin from Ethereum
* @param _amount: number of ethereum tokens to be burned
*/
function burnBridgeTokens(
......@@ -156,6 +167,28 @@ contract BridgeBank is EthereumBank, Chain33Bank {
}
/*
* @dev: withdraw asset via Proxy
*
* @param _ethereumReceiver: The _ethereum receiver address in bytes.
* @param _bridgeTokenAddress: The bridge Token Address issued in chain33 and it's origin from Ethereum/BSC
* @param _amount: number of bridge tokens to be transferred to proxy address
*/
function withdrawViaProxy(
bytes memory _ethereumReceiver,
address _bridgeTokenAddress,
uint256 _amount
)
public
{
return withdrawEthereumTokens(
msg.sender,
_ethereumReceiver,
_bridgeTokenAddress,
_amount
);
}
/*
* @dev: addToken2LockList used to add token with the specified address to be
* allowed locked from Ethereum
*
......
......@@ -14,11 +14,12 @@ contract EthereumBank {
using SafeMath for uint256;
uint256 public bridgeTokenCount;
address payable proxyReceiver;
mapping(address => bool) public bridgeTokenWhitelist;
mapping(bytes32 => bool) public bridgeTokenCreated;
mapping(bytes32 => EthereumDeposit) ethereumDeposits;
mapping(bytes32 => EthereumBurn) ethereumBurns;
mapping(address => DepositBurnCount) depositBurnCounts;
mapping(address => DepositBurnWithdrawCount) depositBurnWithdrawCounts;
mapping(bytes32 => address) public token2address;
struct EthereumDeposit {
......@@ -30,9 +31,11 @@ contract EthereumBank {
uint256 nonce;
}
struct DepositBurnCount {
struct DepositBurnWithdrawCount {
uint256 depositCount;
uint256 burnCount;
uint256 withdrawCount;
}
struct EthereumBurn {
......@@ -67,6 +70,16 @@ contract EthereumBank {
uint256 _nonce
);
event LogEthereumTokenWithdraw(
address _bridgeToken,
string _symbol,
uint256 _amount,
address _ownerFrom,
bytes _ethereumReceiver,
address _proxyReceiver,
uint256 _nonce
);
/*
* @dev: Modifier to make sure this symbol not created now
*/
......@@ -127,9 +140,9 @@ contract EthereumBank {
internal
returns(bytes32)
{
DepositBurnCount memory depositBurnCount = depositBurnCounts[_token];
DepositBurnWithdrawCount memory depositBurnCount = depositBurnWithdrawCounts[_token];
depositBurnCount.depositCount = depositBurnCount.depositCount.add(1);
depositBurnCounts[_token] = depositBurnCount;
depositBurnWithdrawCounts[_token] = depositBurnCount;
bytes32 depositID = keccak256(
abi.encodePacked(
......@@ -217,7 +230,8 @@ contract EthereumBank {
bridgeTokenWhitelist[newBridgeTokenAddress] = true;
bytes32 symHash = keccak256(abi.encodePacked(_symbol));
bridgeTokenCreated[symHash] = true;
depositBurnCounts[newBridgeTokenAddress] = DepositBurnCount(
depositBurnWithdrawCounts[newBridgeTokenAddress] = DepositBurnWithdrawCount(
uint256(0),
uint256(0),
uint256(0));
token2address[symHash] = newBridgeTokenAddress;
......@@ -284,7 +298,7 @@ contract EthereumBank {
* @param _from: The address to be burned from
* @param _ethereumReceiver: The receiver's Ethereum address in bytes.
* @param _ethereumTokenAddress: The token address of ethereum asset issued on chain33
* @param _amount: number of ethereum tokens to be minted
* @param _amount: number of ethereum tokens to be burned
*/
function burnEthereumTokens(
address payable _from,
......@@ -304,13 +318,13 @@ contract EthereumBank {
BridgeToken bridgeTokenInstance = BridgeToken(_ethereumTokenAddress);
bridgeTokenInstance.burnFrom(_from, _amount);
DepositBurnCount memory depositBurnCount = depositBurnCounts[_ethereumTokenAddress];
DepositBurnWithdrawCount memory depositBurnCount = depositBurnWithdrawCounts[_ethereumTokenAddress];
require(
depositBurnCount.burnCount + 1 > depositBurnCount.burnCount,
"burn nonce is not available"
);
depositBurnCount.burnCount = depositBurnCount.burnCount.add(1);
depositBurnCounts[_ethereumTokenAddress] = depositBurnCount;
depositBurnWithdrawCounts[_ethereumTokenAddress] = depositBurnCount;
newEthereumBurn(
_ethereumReceiver,
......@@ -331,6 +345,49 @@ contract EthereumBank {
}
/*
* @dev: withdraw ethereum tokens
*
* @param _from: The address to be withdrew from
* @param _ethereumReceiver: The receiver's Ethereum address in bytes.
* @param _bridgeTokenAddress: The token address of ethereum asset issued on chain33
* @param _amount: number of ethereum tokens to be withdrew
*/
function withdrawEthereumTokens(
address payable _from,
bytes memory _ethereumReceiver,
address _bridgeTokenAddress,
uint256 _amount
)
internal
{
require(proxyReceiver != address(0), "proxy receiver hasn't been set");
// Must be whitelisted bridge token
require(bridgeTokenWhitelist[_bridgeTokenAddress], "Token must be a whitelisted bridge token");
// burn bridge tokens
BridgeToken bridgeTokenInstance = BridgeToken(_bridgeTokenAddress);
bridgeTokenInstance.transferFrom(_from, proxyReceiver, _amount);
DepositBurnWithdrawCount memory wdCount = depositBurnWithdrawCounts[_bridgeTokenAddress];
require(
wdCount.withdrawCount + 1 > wdCount.withdrawCount,
"withdraw nonce is not available"
);
wdCount.withdrawCount = wdCount.withdrawCount.add(1);
depositBurnWithdrawCounts[_bridgeTokenAddress] = wdCount;
emit LogEthereumTokenWithdraw(
_bridgeTokenAddress,
bridgeTokenInstance.symbol(),
_amount,
_from,
_ethereumReceiver,
proxyReceiver,
wdCount.withdrawCount
);
}
/*
* @dev: Checks if an individual EthereumDeposit exists.
*
* @param _id: The unique EthereumDeposit's id.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -31,6 +31,7 @@ func Chain33RelayerCmd() *cobra.Command {
TokenAddressCmd(),
MultiSignCmd(),
ResendChain33EventCmd(),
WithdrawFromChain33Cmd(),
)
return cmd
......@@ -415,3 +416,48 @@ func resendChain33Event(cmd *cobra.Command, args []string) {
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Manager.ResendChain33Event", resendChain33EventReq, &res)
ctx.Run()
}
func WithdrawFromChain33Cmd() *cobra.Command {
cmd := &cobra.Command{
Use: "withdraw",
Short: "async withdraw the asset from chain33 to make it unlocked on ethereum",
Run: WithdrawFromChain33,
}
addWithdrawFromChain33Flags(cmd)
return cmd
}
//addWithdrawFromChain33CmdFlags ...
func addWithdrawFromChain33Flags(cmd *cobra.Command) {
cmd.Flags().StringP("key", "k", "", "owner private key for chain33")
_ = cmd.MarkFlagRequired("key")
cmd.Flags().StringP("token", "t", "", "token address")
_ = cmd.MarkFlagRequired("token")
cmd.Flags().StringP("receiver", "r", "", "receiver address on Ethereum")
_ = cmd.MarkFlagRequired("receiver")
cmd.Flags().Float64P("amount", "m", float64(0), "amount")
_ = cmd.MarkFlagRequired("amount")
}
func WithdrawFromChain33(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
key, _ := cmd.Flags().GetString("key")
tokenAddr, _ := cmd.Flags().GetString("token")
amount, _ := cmd.Flags().GetFloat64("amount")
receiver, _ := cmd.Flags().GetString("receiver")
d, err := utils.SimpleGetDecimals(tokenAddr)
if err != nil {
fmt.Println("get decimals err")
return
}
para := ebTypes.WithdrawFromChain33{
OwnerKey: key,
TokenAddr: tokenAddr,
Amount: utils.ToWei(amount, d).String(),
EthereumReceiver: receiver,
}
var res rpctypes.Reply
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Manager.WithdrawFromChain33", para, &res)
ctx.Run()
}
......@@ -51,6 +51,7 @@ func EthereumRelayerCmd() *cobra.Command {
MultiSignEthCmd(),
TransferEthCmd(),
ConfigplatformTokenSymbolCmd(),
CfgWithdrawCmd(),
)
return cmd
......@@ -1161,3 +1162,42 @@ func SetEthMultiSignAddr(cmd *cobra.Command, _ []string) {
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Manager.SetEthMultiSignAddr", address, &res)
ctx.Run()
}
func CfgWithdrawCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "cfgWithdraw",
Short: "cfg withdraw fee",
Run: CfgWithdraw,
}
addCfgWithdrawFlags(cmd)
return cmd
}
func addCfgWithdrawFlags(cmd *cobra.Command) {
cmd.Flags().StringP("symbol", "s", "", "symbol")
_ = cmd.MarkFlagRequired("symbol")
cmd.Flags().Float64P("fee", "f", 0, "fee amount")
_ = cmd.MarkFlagRequired("fee")
cmd.Flags().Float64P("amount", "a", 0, "accumulative amount allowed to be withdrew per day")
_ = cmd.MarkFlagRequired("amount")
cmd.Flags().Int8P("decimal", "d", 0, "token decimal")
_ = cmd.MarkFlagRequired("decimal")
}
func CfgWithdraw(cmd *cobra.Command, _ []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
symbol, _ := cmd.Flags().GetString("symbol")
fee, _ := cmd.Flags().GetFloat64("fee")
amount, _ := cmd.Flags().GetFloat64("amount")
decimal, _ := cmd.Flags().GetInt8("decimal")
req := &ebTypes.CfgWithdrawReq{
Symbol: symbol,
FeeAmount: utils.ToWei(fee, int64(decimal)).String(),
AmountPerDay: utils.ToWei(amount, int64(decimal)).String(),
}
var res rpctypes.Reply
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Manager.CfgWithdraw", req, &res)
ctx.Run()
}
......@@ -25,7 +25,7 @@ func ShowStaticsFlags(cmd *cobra.Command) {
cmd.Flags().StringP("symbol", "s", "", "token symbol(optional)")
cmd.Flags().Int32P("from", "f", 0, "source chain, 0=ethereum, and 1=chain33")
_ = cmd.MarkFlagRequired("from")
cmd.Flags().Int32P("operation", "o", 0, "operation type, 1=burn, and 2=lock")
cmd.Flags().Int32P("operation", "o", 0, "operation type, 1=burn, 2=lock, 3=withdraw")
_ = cmd.MarkFlagRequired("operation")
cmd.Flags().Int32P("status", "u", 0, "show with specified status, default to show all, 1=pending, 2=successful, 3=failed")
cmd.Flags().Int32P("count", "n", 0, "count to show, default to show all")
......
......@@ -64,7 +64,6 @@ done
```
***
### 启动 relayer B C D
......@@ -91,4 +90,41 @@ done
./ebcli_A ethereum import_privatekey -k "${ethValidatorAddrKeya}"
```
#### 运行持续启动 relayer B C D
\ No newline at end of file
***
### 启动代理 relayer proxy
#### 修改 relayer.toml 配置文件
先 cp relayerA 的配置文件, 然后修改以下字段:
|字段|说明|
|----|----|
|pushName|4 个 relayer 不同相同, `sed -i 's/^pushName=.*/pushName="XXX"/g' relayer.toml`|
|ProcessWithDraw|改为 true|
|chain33Host|平行链的 host 地址, 默认: http://localhost:8801, 选任意一个 chain33 平行链地址就可以|
|deploy4chain33|[deploy4chain33] 下字段全部删除, 只需 relayer A 配置一次就可以|
|deploy|[deploy] 下字段全部删除, 只需 relayer A 配置一次就可以|
#### 首次启动 relayer 进行设置
同上...
#### 设置 chain33 代理地址, 及手续费设置
```shell
# 设置 withdraw 的手续费及每日转帐最大值
result=$(${CLIP} ethereum cfgWithdraw -f 1 -s ETH -a 100 -d 18)
Flags:
-a, --amount float 每日最大值
-d, --decimal int8 token 精度
-f, --fee float 手续费
-s, --symbol string symbol
# 设置 chain33 代理地址
${Boss4xCLI} chain33 offline set_withdraw_proxy -c "${chain33BridgeBank}" -a "${chain33Validatorsp}" -k "${chain33DeployKey}" -n "set_withdraw_proxy:${chain33Validatorsp}"
Flags:
-a, --address string withdraw address
-c, --contract string bridgebank contract address
-f, --fee float contract gas fee (optional)
-k, --key string the deployer private key
-n, --note string transaction note info (optional)
```
\ No newline at end of file
......@@ -98,6 +98,7 @@ func main() {
BlockInterval: cfg.EthBlockFetchPeriod,
EthBridgeClaimChan: ethBridgeClaimChan,
Chain33MsgChan: chain33MsgChan,
ProcessWithDraw: cfg.ProcessWithDraw,
}
ethRelayerService := ethRelayer.StartEthereumRelayer(ethStartPara)
......
......@@ -46,6 +46,7 @@ message RelayerConfig {
string bridgeRegistryOnChain33 = 12;
string chainName = 13;
int32 chainID4Chain33 = 14;
bool processWithDraw = 15;
}
message SyncTxReceiptConfig {
......
......@@ -246,3 +246,42 @@ message ResendChain33EventReq {
int64 height = 1;
}
message CfgWithdrawReq {
string symbol = 1;
string feeAmount = 2;
string amountPerDay = 3;
}
message withdrawPara {
string fee = 1;
string amountPerDay = 2;
}
message WithdrawSymbol2Para {
map<string, withdrawPara> symbol2Para = 1;
}
message WithdrawTx {
string chain33Sender = 1;
string ethereumReceiver = 2;
string symbol = 4;
string amount = 5;
int64 nonce = 6;
string txHashOnChain33 = 7;
string txHashOnEthereum = 8;
int32 year = 9;
int32 month = 10;
int32 day = 11;
int32 status = 12;
string statusDescription = 13;
string errorDescription = 14;
}
message WithdrawFromChain33 {
string ownerKey = 1;
string tokenAddr = 2;
string amount = 3;
string ethereumReceiver = 4;
}
......@@ -9,6 +9,7 @@ EthMaturityDegree=10
EthBlockFetchPeriod=5000
BridgeRegistryOnChain33=""
BridgeRegistry=""
ProcessWithDraw=false
[SyncTxConfig]
chain33Host="http://localhost:8801"
......@@ -28,7 +29,7 @@ startSyncHash=""
[deploy4chain33]
#合约部署人员私钥,用于部署合约时签名使用
operatorAddr="14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
#验证人地址,至少配置3个以上,即大于等于3
#验证人地址,至少配置3个以上,即大于等于3
validatorsAddr=["14KEKbYtKKQm4wMthSK9J4La4nAiidGozt", "13KTf57aCkVVJYNJBXBBveiA5V811SrLcT", "1JQwQWsShTHC4zxHzbUfYQK4kRBriUQdEe", "1NHuKqoKe3hyv52PF8XBAyaTmJWAqA2Jbb"]
#验证人权重
initPowers=[96, 1, 1, 1]
......@@ -36,7 +37,7 @@ initPowers=[96, 1, 1, 1]
[deploy]
#合约部署人员私钥,用于部署合约时签名使用
operatorAddr="0x8afdadfc88a1087c9a1d6c0f5dd04634b87f303a"
#验证人地址,至少配置3个以上,即大于等于3
#验证人地址,至少配置3个以上,即大于等于3
validatorsAddr=["0x92C8b16aFD6d423652559C6E266cBE1c29Bfd84f", "0x0df9a824699bc5878232c9e612fe1a5346a5a368", "0xcb074cb21cdddf3ce9c3c0a7ac4497d633c9d9f1", "0xd9dab021e74ecf475788ed7b61356056b2095830"]
#验证人权重
initPowers=[96, 1, 1, 1]
......
......@@ -51,6 +51,7 @@ type Relayer4Chain33 struct {
unlockChan chan int
bridgeBankEventLockSig string
bridgeBankEventBurnSig string
bridgeBankEventWithdrawSig string
bridgeBankAbi abi.ABI
deployInfo *ebTypes.Deploy
totalTx4RelayEth2chai33 int64
......@@ -235,12 +236,14 @@ func (chain33Relayer *Relayer4Chain33) onNewHeightProc(currentHeight int64) {
evmEventType = events.Chain33EventLogBurn
} else if chain33Relayer.bridgeBankEventLockSig == common.ToHex(evmlog.Topic[0]) {
evmEventType = events.Chain33EventLogLock
} else if chain33Relayer.bridgeBankEventWithdrawSig == common.ToHex(evmlog.Topic[0]) {
evmEventType = events.Chain33EventLogWithdraw
} else {
continue
}
if err := chain33Relayer.handleBurnLockEvent(evmEventType, evmlog.Data, tx.Hash()); nil != err {
errInfo := fmt.Sprintf("Failed to handleBurnLockEvent due to:%s", err.Error())
if err := chain33Relayer.handleBurnLockWithdrawEvent(evmEventType, evmlog.Data, tx.Hash()); nil != err {
errInfo := fmt.Sprintf("Failed to handleBurnLockWithdrawEvent due to:%s", err.Error())
panic(errInfo)
}
}
......@@ -251,8 +254,8 @@ func (chain33Relayer *Relayer4Chain33) onNewHeightProc(currentHeight int64) {
}
// handleBurnLockMsg : parse event data as a Chain33Msg, package it into a ProphecyClaim, then relay tx to the Ethereum Network
func (chain33Relayer *Relayer4Chain33) handleBurnLockEvent(evmEventType events.Chain33EvmEvent, data []byte, chain33TxHash []byte) error {
relayerLog.Info("handleBurnLockEvent", "Received tx with hash", ethCommon.Bytes2Hex(chain33TxHash))
func (chain33Relayer *Relayer4Chain33) handleBurnLockWithdrawEvent(evmEventType events.Chain33EvmEvent, data []byte, chain33TxHash []byte) error {
relayerLog.Info("handleBurnLockWithdrawEvent", "Received tx with hash", ethCommon.Bytes2Hex(chain33TxHash))
// Parse the witnessed event's data into a new Chain33Msg
chain33Msg, err := events.ParseBurnLock4chain33(evmEventType, data, chain33Relayer.bridgeBankAbi, chain33TxHash)
......@@ -306,11 +309,13 @@ func (chain33Relayer *Relayer4Chain33) ResendChain33Event(height int64) (err err
evmEventType = events.Chain33EventLogBurn
} else if chain33Relayer.bridgeBankEventLockSig == common.ToHex(evmlog.Topic[0]) {
evmEventType = events.Chain33EventLogLock
} else if chain33Relayer.bridgeBankEventWithdrawSig == common.ToHex(evmlog.Topic[0]) {
evmEventType = events.Chain33EventLogWithdraw
} else {
continue
}
if err := chain33Relayer.handleBurnLockEvent(evmEventType, evmlog.Data, tx.Hash()); nil != err {
if err := chain33Relayer.handleBurnLockWithdrawEvent(evmEventType, evmlog.Data, tx.Hash()); nil != err {
return err
}
}
......@@ -634,3 +639,9 @@ func (chain33Relayer *Relayer4Chain33) SetMultiSignAddr(address string) {
chain33Relayer.setMultiSignAddress(address)
}
func (chain33Relayer *Relayer4Chain33) WithdrawFromChain33(ownerPrivateKey, tokenAddr, ethereumReceiver, amount string) (string, error) {
bn := big.NewInt(1)
bn, _ = bn.SetString(utils.TrimZeroAndDot(amount), 10)
return withdrawAsync(ownerPrivateKey, tokenAddr, ethereumReceiver, bn.Int64(), chain33Relayer.bridgeBankAddr, chain33Relayer.chainName, chain33Relayer.rpcLaddr)
}
......@@ -20,8 +20,11 @@ func (relayer *Relayer4Chain33) prePareSubscribeEvent() {
relayer.bridgeBankEventLockSig = contractABI.Events[eventName].ID.Hex()
eventName = events.Chain33EventLogBurn.String()
relayer.bridgeBankEventBurnSig = contractABI.Events[eventName].ID.Hex()
eventName = events.Chain33EventLogWithdraw.String()
relayer.bridgeBankEventWithdrawSig = contractABI.Events[eventName].ID.Hex()
relayer.bridgeBankAbi = contractABI
relayerLog.Info("prePareSubscribeEvent", "bridgeBankEventLockSig", relayer.bridgeBankEventLockSig,
"bridgeBankEventBurnSig", relayer.bridgeBankEventBurnSig)
"bridgeBankEventBurnSig", relayer.bridgeBankEventBurnSig, "bridgeBankEventWithdrawSig", relayer.bridgeBankEventWithdrawSig)
}
......@@ -8,7 +8,6 @@ import (
dbm "github.com/33cn/chain33/common/db"
"github.com/33cn/chain33/types"
"github.com/33cn/plugin/plugin/dapp/cross2eth/ebrelayer/utils"
"github.com/pkg/errors"
)
// SeqType
......@@ -106,13 +105,17 @@ func (syncTx *EVMTxLogs) SaveAndSyncTxs2Relayer() {
// 处理输入流程
func (syncTx *EVMTxLogs) dealEVMTxLogs(evmTxLogsInBlks *types.EVMTxLogsInBlks) {
count, start, evmTxLogsParsed, err := parseEvmTxLogsInBlks(evmTxLogsInBlks, syncTx.seqNum)
if err != nil {
resultCh <- err
count, start, evmTxLogsParsed := parseEvmTxLogsInBlks(evmTxLogsInBlks, syncTx.seqNum)
txReceiptCount := len(evmTxLogsParsed)
//重复注册推送接收保护,允许同一个中继服务在使用一段时间后,使用不同的推送名字重新进行注册,这样重复推送忽略就可以
//需要进行ack,否则该节点的推送将会停止
if 0 == txReceiptCount {
resultCh <- nil
return
}
var height int64
for i := 0; i < count; i++ {
for i := 0; i < txReceiptCount; i++ {
txsPerBlock := evmTxLogsParsed[i]
if txsPerBlock.AddDelType == SeqTypeAdd {
syncTx.setTxLogsPerBlock(txsPerBlock)
......@@ -206,7 +209,7 @@ func (syncTx *EVMTxLogs) delTxReceipts(height int64) {
}
// 检查输入是否有问题, 并解析输入
func parseEvmTxLogsInBlks(evmTxLogs *types.EVMTxLogsInBlks, seqNumLast int64) (count int, start int64, txsWithReceipt []*types.EVMTxLogPerBlk, err error) {
func parseEvmTxLogsInBlks(evmTxLogs *types.EVMTxLogsInBlks, seqNumLast int64) (count int, start int64, txsWithReceipt []*types.EVMTxLogPerBlk) {
count = len(evmTxLogs.Logs4EVMPerBlk)
txsWithReceipt = make([]*types.EVMTxLogPerBlk, 0)
start = math.MaxInt64
......@@ -230,9 +233,9 @@ func parseEvmTxLogsInBlks(evmTxLogs *types.EVMTxLogsInBlks, seqNumLast int64) (c
"height", evmTxLogs.Logs4EVMPerBlk[i].Height, "seqOpType", seqOperationType[evmTxLogs.Logs4EVMPerBlk[i].AddDelType-1])
}
if len(txsWithReceipt) != count {
err = errors.New("duplicate block's tx logs")
return
if 0 == len(txsWithReceipt) {
log.Error("parseEvmTxLogsInBlks", "the valid number of tx receipt is", 0)
}
return
}
......@@ -646,3 +646,48 @@ func sendQuery(rpcAddr, funcName string, request types.Message, result proto.Mes
}
return true
}
func withdrawAsync(ownerPrivateKeyStr, tokenAddrstr, ethereumReceiver string, amount int64, bridgeBankAddr string, chainName, rpcURL string) (string, error) {
var driver secp256k1.Driver
privateKeySli, err := chain33Common.FromHex(ownerPrivateKeyStr)
if nil != err {
return "", err
}
ownerPrivateKey, err := driver.PrivKeyFromBytes(privateKeySli)
if nil != err {
return "", err
}
approveTxHash, err := approve(ownerPrivateKey, tokenAddrstr, bridgeBankAddr, chainName, rpcURL, amount)
if err != nil {
chain33txLog.Error("withdrawAsync", "failed to send approve tx due to:", err.Error())
return "", err
}
chain33txLog.Debug("withdrawAsync", "approve with tx hash", approveTxHash)
withdrawTxHash, err := withdrawViaProxy(ownerPrivateKey, bridgeBankAddr, ethereumReceiver, tokenAddrstr, chainName, rpcURL, amount)
if err != nil {
chain33txLog.Error("withdrawAsync", "failed to send withdraw tx due to:", err.Error())
return "", err
}
chain33txLog.Debug("withdrawAsync", "withdraw with tx hash", withdrawTxHash)
return withdrawTxHash, err
}
func withdrawViaProxy(privateKey chain33Crypto.PrivKey, contractAddr, ethereumReceiver, ethereumTokenAddress, chainName, rpcURL string, amount int64) (string, error) {
//function withdrawViaProxy(
// bytes memory _ethereumReceiver,
// address _bridgeTokenAddress,
// uint256 _amount
//)
parameter := fmt.Sprintf("withdrawViaProxy(%s, %s, %d)", ethereumReceiver, ethereumTokenAddress, amount)
note := parameter
_, packData, err := evmAbi.Pack(parameter, generated.BridgeBankABI, false)
if nil != err {
chain33txLog.Info("withdraw", "Failed to do abi.Pack due to:", err.Error())
return "", err
}
return sendEvmTx(privateKey, contractAddr, chainName, rpcURL, note, packData, 0)
}
......@@ -14,8 +14,10 @@ import (
"crypto/ecdsa"
"errors"
"fmt"
"math"
"math/big"
"regexp"
"strings"
"sync"
"sync/atomic"
"time"
......@@ -50,8 +52,8 @@ type Relayer4Ethereum struct {
privateKey4Ethereum *ecdsa.PrivateKey
ethSender common.Address
processWithDraw bool
ethValidator common.Address
unlockchan chan int
maturityDegree int32
fetchHeightPeriodMs int32
......@@ -75,6 +77,7 @@ type Relayer4Ethereum struct {
symbol2Addr map[string]common.Address
symbol2LockAddr map[string]ebTypes.TokenAddress
mulSignAddr string
withdrawFee map[string]*WithdrawFeeAndQuota
}
var (
......@@ -95,6 +98,12 @@ type EthereumStartPara struct {
BlockInterval int32
EthBridgeClaimChan chan<- *ebTypes.EthBridgeClaim
Chain33MsgChan <-chan *events.Chain33Msg
ProcessWithDraw bool
}
type WithdrawFeeAndQuota struct {
Fee *big.Int
AmountPerDay *big.Int
}
//StartEthereumRelayer ///
......@@ -108,6 +117,7 @@ func StartEthereumRelayer(startPara *EthereumStartPara) *Relayer4Ethereum {
db: startPara.DbHandle,
unlockchan: make(chan int, 2),
bridgeRegistryAddr: common.HexToAddress(startPara.BridgeRegistryAddr),
processWithDraw: startPara.ProcessWithDraw,
deployInfo: startPara.DeployInfo,
maturityDegree: startPara.Degree,
fetchHeightPeriodMs: startPara.BlockInterval,
......@@ -130,9 +140,10 @@ func StartEthereumRelayer(startPara *EthereumStartPara) *Relayer4Ethereum {
ethRelayer.eventLogIndex = ethRelayer.getLastBridgeBankProcessedHeight()
ethRelayer.initBridgeBankTx()
ethRelayer.mulSignAddr = ethRelayer.getMultiSignAddress()
ethRelayer.withdrawFee = ethRelayer.restoreWithdrawFeeInINt()
// Start clientSpec with infura ropsten provider
relayerLog.Info("Relayer4Ethereum proc", "Started Ethereum websocket with provider:", ethRelayer.provider)
relayerLog.Info("Relayer4Ethereum proc", "Started Ethereum websocket with provider:", ethRelayer.provider, "processWithDraw", ethRelayer.processWithDraw)
client, err := ethtxs.SetupWebsocketEthClient(ethRelayer.providerHttp)
if err != nil {
panic(err)
......@@ -157,6 +168,7 @@ func StartEthereumRelayer(startPara *EthereumStartPara) *Relayer4Ethereum {
data := chain33Types.Encode(statics)
_ = ethRelayer.setLastestStatics(int32(events.ClaimTypeLock), 0, data)
_ = ethRelayer.setLastestStatics(int32(events.ClaimTypeBurn), 0, data)
_ = ethRelayer.setLastestStatics(int32(events.ClaimTypeWithdraw), 0, data)
}
go ethRelayer.proc()
......@@ -278,7 +290,7 @@ func (ethRelayer *Relayer4Ethereum) GetBalance(tokenAddr, owner string) (string,
func (ethRelayer *Relayer4Ethereum) ShowMultiBalance(tokenAddr, owner string) (string, error) {
relayerLog.Info("ShowMultiBalance", "tokenAddr", tokenAddr, "owner", owner)
opts := &bind.CallOpts{
From: ethRelayer.ethValidator,
From: ethRelayer.ethSender,
Context: context.Background(),
}
......@@ -334,7 +346,7 @@ func (ethRelayer *Relayer4Ethereum) ShowLockedTokenAddress(tokenSymbol string) (
//IsProphecyPending ...
func (ethRelayer *Relayer4Ethereum) IsProphecyPending(claimID [32]byte) (bool, error) {
return ethtxs.IsProphecyPending(claimID, ethRelayer.ethValidator, ethRelayer.x2EthContracts.Chain33Bridge)
return ethtxs.IsProphecyPending(claimID, ethRelayer.ethSender, ethRelayer.x2EthContracts.Chain33Bridge)
}
//CreateBridgeToken ...
......@@ -453,15 +465,12 @@ func (ethRelayer *Relayer4Ethereum) proc() {
}
ethRelayer.rwLock.Unlock()
relayerLog.Info("^-^ ^-^ Succeed to recover corresponding solidity contract handler")
//if nil != ethRelayer.recoverDeployPara() {
// panic("Failed to recoverDeployPara")
//}
ethRelayer.unlockchan <- start
}
var timer *time.Ticker
ctx := context.Background()
continueFailCount := int32(0)
for range ethRelayer.unlockchan {
relayerLog.Info("Received ethRelayer.unlockchan")
ethRelayer.rwLock.RLock()
......@@ -475,15 +484,15 @@ func (ethRelayer *Relayer4Ethereum) proc() {
ethRelayer.filterLogEvents()
relayerLog.Info("Ethereum relayer starts to process online log event...")
timer = time.NewTicker(time.Duration(ethRelayer.fetchHeightPeriodMs) * time.Millisecond)
goto latter
goto burnLockWithdrawProc
}
}
latter:
burnLockWithdrawProc:
for {
select {
case <-timer.C:
ethRelayer.procNewHeight(ctx, &continueFailCount)
ethRelayer.procNewHeight(ctx)
case err := <-ethRelayer.bridgeBankSub.Err():
relayerLog.Error("proc", "bridgeBankSub err", err.Error())
ethRelayer.subscribeEvent()
......@@ -494,10 +503,310 @@ latter:
ethRelayer.handleChain33Msg(chain33Msg)
}
}
//withdrawProc:
// for {
// select {
// case <-timer.C:
// ethRelayer.procNewHeight4Withdraw(ctx)
// case chain33Msg := <-ethRelayer.chain33MsgChan:
// ethRelayer.handleChain33Msg(chain33Msg)
// }
// }
}
func (ethRelayer *Relayer4Ethereum) handleChain33Msg(chain33Msg *events.Chain33Msg) {
relayerLog.Info("handleChain33Msg", "Received chain33Msg", chain33Msg, "tx hash string", common.Bytes2Hex(chain33Msg.TxHash))
if chain33Msg.ClaimType == events.ClaimTypeWithdraw {
ethRelayer.handleLogWithdraw(chain33Msg)
return
}
ethRelayer.handleLogLockBurn(chain33Msg)
return
}
func (ethRelayer *Relayer4Ethereum) checkPermissionWithinOneDay(withdrawTx *ebTypes.WithdrawTx) (*big.Int, error) {
totalAlready, err := ethRelayer.getWithdrawsWithinSameDay(withdrawTx)
if nil != err {
relayerLog.Error("checkPermissionWithinOneDay", "Failed to getWithdrawsWithinSameDay due to", err.Error())
return nil, errors.New("ErrGetWithdrawsWithinSameDay")
}
withdrawPara, ok := ethRelayer.withdrawFee[withdrawTx.Symbol]
if !ok {
relayerLog.Error("checkPermissionWithinOneDay", "No withdraw parameter configured for symbol ", withdrawTx.Symbol)
return nil, errors.New("ErrNoWithdrawParaCfged")
}
AmountInt, _ := big.NewInt(0).SetString(withdrawTx.Amount, 0)
totalAlready.Add(totalAlready, AmountInt)
if totalAlready.Cmp(withdrawPara.AmountPerDay) > 0 {
relayerLog.Error("checkPermissionWithinOneDay", "No withdraw parameter configured for symbol ", withdrawTx.Symbol)
return nil, errors.New("ErrWithdrawAmountBigThanQuota")
}
relayerLog.Info("checkPermissionWithinOneDay", "total withdraw already", totalAlready, "Chain33Sender", withdrawTx.Chain33Sender,
"Symbol", withdrawTx.Symbol)
return withdrawPara.Fee, nil
}
func (ethRelayer *Relayer4Ethereum) handleLogWithdraw(chain33Msg *events.Chain33Msg) {
//只有通过代理人登录的中继器,才处理提币事件
var err error
now := time.Now()
year, month, day := now.Date()
withdrawTx := &ebTypes.WithdrawTx{
Chain33Sender: chain33Msg.Chain33Sender.String(),
EthereumReceiver: chain33Msg.EthereumReceiver.String(),
Symbol: chain33Msg.Symbol,
TxHashOnChain33: common.Bytes2Hex(chain33Msg.TxHash),
Nonce: chain33Msg.Nonce,
Year: int32(year),
Month: int32(month),
Day: int32(day),
}
//非代理提币人模式,则不处理代理提币
if !ethRelayer.processWithDraw {
relayerLog.Info("handleLogWithdraw", "Needn't process withdraw for this relay validator", ethRelayer.ethSender)
return
}
defer func() {
if err != nil {
withdrawTx.Status = int32(ethtxs.WDError)
withdrawTx.StatusDescription = ethtxs.WDError.String()
withdrawTx.ErrorDescription = err.Error()
relayerLog.Error("handleLogWithdraw", "Failed to withdraw due to:", err.Error())
}
err := ethRelayer.setWithdraw(withdrawTx)
if nil != err {
relayerLog.Error("handleLogWithdraw", "Failed to setWithdraw due to:", err.Error())
}
}()
relayerLog.Info("handleLogWithdraw", "Received chain33Msg", chain33Msg, "tx hash string", common.Bytes2Hex(chain33Msg.TxHash))
withdrawFromChain33TokenInfo, exist := ethRelayer.symbol2LockAddr[chain33Msg.Symbol]
if !exist {
//因为是withdraw操作,必须从允许lock的token地址中进行查询
relayerLog.Error("handleLogWithdraw", "Failed to fetch locked Token Info for symbol", chain33Msg.Symbol)
err = errors.New("ErrFetchLockedTokenInfo")
return
}
tokenAddr := common.HexToAddress(withdrawFromChain33TokenInfo.Address)
//从chain33进行withdraw回来的token需要根据精度进行相应的缩放
if 8 != withdrawFromChain33TokenInfo.Decimal {
dist := math.Abs(float64(withdrawFromChain33TokenInfo.Decimal - 8))
value, exist := utils.Decimal2value[int(dist)]
if !exist {
relayerLog.Error("handleLogWithdraw", "does support for decimal, %d", withdrawFromChain33TokenInfo.Decimal)
err = errors.New("ErrDecimalNotSupport")
return
}
if withdrawFromChain33TokenInfo.Decimal > 8 {
chain33Msg.Amount.Mul(chain33Msg.Amount, big.NewInt(value))
} else {
chain33Msg.Amount.Div(chain33Msg.Amount, big.NewInt(value))
}
}
withdrawTx.Amount = chain33Msg.Amount.String()
relayerLog.Info("handleLogWithdraw", "token address", tokenAddr.String(), "amount", withdrawTx.Amount,
"Receiver on Ethereum", chain33Msg.EthereumReceiver.String())
//检查用户提币权限是否得到满足:比如是否超过累计提币额度
var feeAmount *big.Int
if feeAmount, err = ethRelayer.checkPermissionWithinOneDay(withdrawTx); nil != err {
return
}
if chain33Msg.Amount.Cmp(feeAmount) < 0 {
relayerLog.Error("handleLogWithdraw", "ErrWithdrawAmountLessThanFee feeAmount", feeAmount.String(), "Withdraw Amount", chain33Msg.Amount.String())
err = errors.New("ErrWithdrawAmountCan'tPay4Fee")
return
}
amount2transfer := chain33Msg.Amount.Sub(chain33Msg.Amount, feeAmount)
value := big.NewInt(0)
//此处需要完成在以太坊发送以太或者ERC20数字资产的操作
ctx := context.Background()
timeout, cancel := context.WithTimeout(ctx, time.Second*2)
defer cancel()
var intputData []byte // ERC20 or BEP20 token transfer pack data
var toAddr common.Address
var balanceOfData []byte // ERC20 or BEP20 token balanceof pack data
if tokenAddr.String() != ethtxs.EthNullAddr { //判断是否要Pack EVM数据
toAddr = tokenAddr
intputData, err = ethRelayer.packTransferData(chain33Msg.EthereumReceiver, amount2transfer)
if err != nil {
relayerLog.Error("handleLogWithdraw", "CallEvmData err", err)
err = errors.New("ErrPackTransferData")
return
}
//用签名的账户地址作为pack参数,toAddr作为合约地址
balanceOfData, err = ethRelayer.packBalanceOfData(ethRelayer.ethSender)
if err != nil {
relayerLog.Error("handleLogWithdraw", "callEvmBalanceData err", err)
err = errors.New("ErrPackBalanceOfData")
return
}
} else {
//如果tokenAddr为空,则把toAddr设置为用户指定的地址
toAddr = chain33Msg.EthereumReceiver
value = amount2transfer
}
//校验余额是否充足
if ok, err := ethRelayer.checkBalanceEnough(toAddr, amount2transfer, balanceOfData); !ok {
relayerLog.Error("handleLogWithdraw", "Failed to checkBalanceEnough:", err.Error())
err = errors.New("ErrBalanceNotEnough")
return
}
//param: from,to,evm-packdata,amount
//交易构造
tx, err := ethtxs.NewTransferTx(ethRelayer.clientSpec, ethRelayer.ethSender, toAddr, intputData, value)
if err != nil {
relayerLog.Error("handleLogWithdraw", "newTx err", err)
err = errors.New("ErrNewTx")
return
}
//交易签名
signedTx, err := ethRelayer.signTx(tx, ethRelayer.privateKey4Ethereum)
if err != nil {
relayerLog.Error("handleLogWithdraw", "SignTx err", err)
err = errors.New("ErrSignTx")
return
}
//交易发送
err = ethRelayer.clientSpec.SendTransaction(timeout, signedTx)
if err != nil {
relayerLog.Error("handleLogWithdraw", "SendTransaction err", err)
err = errors.New("ErrSendTransaction")
return
}
relayerLog.Info("handleLogWithdraw", "SendTransaction Hash", signedTx.Hash())
withdrawTx.Status = int32(ethtxs.WDPending)
withdrawTx.StatusDescription = ethtxs.WDPending.String()
withdrawTx.TxHashOnEthereum = signedTx.Hash().String()
txIndex := atomic.AddInt64(&ethRelayer.totalTxRelayFromChain33, 1)
operationType := chain33Msg.ClaimType.String()
statics := &ebTypes.Chain33ToEthereumStatics{
EthTxstatus: ebTypes.Tx_Status_Pending,
Chain33Txhash: common.Bytes2Hex(chain33Msg.TxHash),
EthereumTxhash: withdrawTx.TxHashOnEthereum,
BurnLock: int32(chain33Msg.ClaimType),
Chain33Sender: chain33Msg.Chain33Sender.String(),
EthereumReceiver: chain33Msg.EthereumReceiver.String(),
Symbol: chain33Msg.Symbol,
Amount: chain33Msg.Amount.String(),
Nonce: chain33Msg.Nonce,
TxIndex: txIndex,
OperationType: operationType,
}
data := chain33Types.Encode(statics)
if err = ethRelayer.setLastestStatics(int32(chain33Msg.ClaimType), txIndex, data); nil != err {
relayerLog.Error("handleLogLockBurn", "Failed to RelayLockToChain33 due to:", err.Error())
return
}
relayerLog.Info("RelayOracleClaimToEthereum::successful",
"txIndex", txIndex,
"Chain33Txhash", statics.Chain33Txhash,
"EthereumTxhash", statics.EthereumTxhash,
"type", operationType,
"Symbol", chain33Msg.Symbol,
"Amount", chain33Msg.Amount,
"EthereumReceiver", statics.EthereumReceiver,
"Chain33Sender", statics.Chain33Sender)
return
}
func (ethRelayer *Relayer4Ethereum) checkBalanceEnough(addr common.Address, amount *big.Int, inputdata []byte) (bool, error) {
//检测地址余额
var balance *big.Int
var err error
if inputdata == nil {
balance, err = ethRelayer.clientSpec.BalanceAt(context.Background(), addr, nil)
if err != nil {
//retry
balance, err = ethRelayer.clientSpec.BalanceAt(context.Background(), addr, nil)
if err != nil {
return false, err
}
}
} else {
var msg ethereum.CallMsg
msg.To = &addr //合约地址
msg.Data = inputdata
result, err := ethRelayer.clientSpec.CallContract(context.Background(), msg, nil)
if err != nil {
//retry
result, err = ethRelayer.clientSpec.CallContract(context.Background(), msg, nil)
if err != nil {
return false, err
}
}
var ok bool
balance, ok = big.NewInt(1).SetString(common.Bytes2Hex(result), 16)
if !ok {
return false, errors.New(fmt.Sprintf("token balance err:%v", common.Bytes2Hex(result)))
}
}
//与要发动的金额大小进行比较
if balance.Cmp(amount) > 0 {
return true, nil
}
relayerLog.Error("Insufficient balance", "balance", balance, "amount", amount)
return false, errors.New("Insufficient balance")
}
func (ethRelayer *Relayer4Ethereum) signTx(tx *types.Transaction, key *ecdsa.PrivateKey) (*types.Transaction, error) {
signer := types.NewEIP155Signer(ethRelayer.clientChainID)
txhash := signer.Hash(tx)
signature, err := crypto.Sign(txhash.Bytes(), key)
if err != nil {
return nil, err
}
tx, err = tx.WithSignature(signer, signature)
if err != nil {
return nil, err
}
return tx, nil
}
func (ethRelayer *Relayer4Ethereum) packTransferData(_to common.Address, _value *big.Int) ([]byte, error) {
parsed, err := abi.JSON(strings.NewReader(generated.ERC20ABI))
if err != nil {
return nil, err
}
abidata, err := parsed.Pack("transfer", _to, _value)
if err != nil {
return nil, err
}
return abidata, nil
}
func (ethRelayer *Relayer4Ethereum) packBalanceOfData(_to common.Address) ([]byte, error) {
parsed, err := abi.JSON(strings.NewReader(generated.ERC20ABI))
if err != nil {
return nil, err
}
abidata, err := parsed.Pack("balanceOf", _to)
if err != nil {
return nil, err
}
return abidata, nil
}
func (ethRelayer *Relayer4Ethereum) handleLogLockBurn(chain33Msg *events.Chain33Msg) {
//对于通过代理人登录的中继器,不处理lock和burn事件
if ethRelayer.processWithDraw {
relayerLog.Info("handleLogLockBurn", "Needn't process lock and burn for this withdraw process specified validator", ethRelayer.ethSender)
return
}
relayerLog.Info("handleLogLockBurn", "Received chain33Msg", chain33Msg, "tx hash string", common.Bytes2Hex(chain33Msg.TxHash))
// Parse the Chain33Msg into a ProphecyClaim for relay to Ethereum
prophecyClaim := ethtxs.Chain33MsgToProphecyClaim(*chain33Msg)
......@@ -507,7 +816,7 @@ func (ethRelayer *Relayer4Ethereum) handleChain33Msg(chain33Msg *events.Chain33M
if chain33Msg.ClaimType == events.ClaimTypeLock {
tokenAddr, exist = ethRelayer.symbol2Addr[prophecyClaim.Symbol]
if !exist {
relayerLog.Info("handleChain33Msg", "Query address from ethereum for symbol", prophecyClaim.Symbol)
relayerLog.Info("handleLogLockBurn", "Query address from ethereum for symbol", prophecyClaim.Symbol)
//因为是lock操作,则需要从创建的bridgeToken中进行查询
addr, err := ethRelayer.ShowTokenAddrBySymbol(prophecyClaim.Symbol)
if err != nil {
......@@ -521,7 +830,7 @@ func (ethRelayer *Relayer4Ethereum) handleChain33Msg(chain33Msg *events.Chain33M
err = ethRelayer.SetTokenAddress(token2set)
if nil != err {
// 尽管设置数据失败,但是不影响运行,只是relayer启动时,每次从节点远程获取bridge token地址而已
relayerLog.Error("handleChain33Msg", "Failed to SetTokenAddress due to", err.Error())
relayerLog.Error("handleLogLockBurn", "Failed to SetTokenAddress due to", err.Error())
}
tokenAddr = common.HexToAddress(addr)
}
......@@ -529,14 +838,11 @@ func (ethRelayer *Relayer4Ethereum) handleChain33Msg(chain33Msg *events.Chain33M
burnFromChain33TokenInfo, exist := ethRelayer.symbol2LockAddr[prophecyClaim.Symbol]
if !exist {
//因为是burn操作,必须从允许lock的token地址中进行查询
relayerLog.Error("handleChain33Msg", "Failed to fetch locked Token Info for symbol", prophecyClaim.Symbol)
relayerLog.Error("handleLogLockBurn", "Failed to fetch locked Token Info for symbol", prophecyClaim.Symbol)
return
}
tokenAddr = common.HexToAddress(burnFromChain33TokenInfo.Address)
//if lockedTokenInfo.Decimal == 18 {
// prophecyClaim.Amount = prophecyClaim.Amount.Mul(prophecyClaim.Amount, big.NewInt(int64(1e10)))
//}
//从chain33进行withdraw回来的token需要根据精度进行相应的缩放
if 8 != burnFromChain33TokenInfo.Decimal {
if burnFromChain33TokenInfo.Decimal > 8 {
......@@ -562,12 +868,12 @@ func (ethRelayer *Relayer4Ethereum) handleChain33Msg(chain33Msg *events.Chain33M
if nil != err {
panic("RelayOracleClaimToEthereum failed due to" + err.Error())
}
relayerLog.Info("handleChain33Msg", "RelayOracleClaimToEthereum with tx hash", txhash)
relayerLog.Info("handleLogLockBurn", "RelayOracleClaimToEthereum with tx hash", txhash)
//保存交易hash,方便查询
txIndex := atomic.AddInt64(&ethRelayer.totalTxRelayFromChain33, 1)
if err = ethRelayer.updateTotalTxAmount2chain33(txIndex); nil != err {
relayerLog.Error("handleChain33Msg", "Failed to RelayLockToChain33 due to:", err.Error())
relayerLog.Error("handleLogLockBurn", "Failed to RelayLockToChain33 due to:", err.Error())
return
}
statics := &ebTypes.Chain33ToEthereumStatics{
......@@ -585,7 +891,7 @@ func (ethRelayer *Relayer4Ethereum) handleChain33Msg(chain33Msg *events.Chain33M
}
data := chain33Types.Encode(statics)
if err = ethRelayer.setLastestStatics(int32(chain33Msg.ClaimType), txIndex, data); nil != err {
relayerLog.Error("handleChain33Msg", "Failed to RelayLockToChain33 due to:", err.Error())
relayerLog.Error("handleLogLockBurn", "Failed to RelayLockToChain33 due to:", err.Error())
return
}
relayerLog.Info("RelayOracleClaimToEthereum::successful",
......@@ -599,30 +905,38 @@ func (ethRelayer *Relayer4Ethereum) handleChain33Msg(chain33Msg *events.Chain33M
"Chain33Sender", statics.Chain33Sender)
}
func (ethRelayer *Relayer4Ethereum) procNewHeight(ctx context.Context, continueFailCount *int32) {
func (ethRelayer *Relayer4Ethereum) getCurrentHeight(ctx context.Context) (uint64, error) {
head, err := ethRelayer.clientSpec.HeaderByNumber(ctx, nil)
if nil != err {
*continueFailCount++
if *continueFailCount >= 5 {
if nil == err {
return head.Number.Uint64(), nil
}
//TODO: 需要在下面添加报警处理
for {
time.Sleep(5 * time.Second)
ethRelayer.clientSpec, err = ethtxs.SetupWebsocketEthClient(ethRelayer.providerHttp)
if err != nil {
relayerLog.Error("SetupWebsocketEthClient", "err", err)
return
relayerLog.Error("getCurrentHeight", "Failed to SetupWebsocketEthClient due to:", err.Error())
continue
}
head, err := ethRelayer.clientSpec.HeaderByNumber(ctx, nil)
if nil != err {
relayerLog.Error("getCurrentHeight", "Failed to HeaderByNumber due to:", err.Error())
continue
}
//retry
head, err = ethRelayer.clientSpec.HeaderByNumber(ctx, nil)
if err != nil {
relayerLog.Error("Failed to get ethereum height", "provider", ethRelayer.provider,
"continueFailCount", continueFailCount, "err", err.Error())
return
return head.Number.Uint64(), nil
}
}
}
func (ethRelayer *Relayer4Ethereum) procNewHeight4Withdraw(ctx context.Context) {
currentHeight, _ := ethRelayer.getCurrentHeight(ctx)
relayerLog.Info("procNewHeight4Withdraw", "currentHeight", currentHeight)
}
func (ethRelayer *Relayer4Ethereum) procNewHeight(ctx context.Context) {
currentHeight, _ := ethRelayer.getCurrentHeight(ctx)
ethRelayer.updateTxStatus()
*continueFailCount = 0
currentHeight := head.Number.Uint64()
//currentHeight := head.Number.Uint64()
relayerLog.Info("procNewHeight", "currentHeight", currentHeight, "ethRelayer.eventLogIndex.Height", ethRelayer.eventLogIndex.Height, "uint64(ethRelayer.maturityDegree)", uint64(ethRelayer.maturityDegree))
//一次最大只获取10个logEvent进行处理
......@@ -746,12 +1060,8 @@ func (ethRelayer *Relayer4Ethereum) filterLogEvents() {
height4BridgeBankLogAt = deployHeight
}
header, err := ethRelayer.clientSpec.HeaderByNumber(context.Background(), nil)
if err != nil {
errinfo := fmt.Sprintf("Failed to get HeaderByNumbers due to:%s", err.Error())
panic(errinfo)
}
curHeight := int64(header.Number.Uint64())
curHeightUint64, _ := ethRelayer.getCurrentHeight(context.Background())
curHeight := int64(curHeightUint64)
relayerLog.Info("filterLogEvents", "curHeight:", curHeight)
bridgeBankSig := make(map[string]bool)
......@@ -876,7 +1186,7 @@ func (ethRelayer *Relayer4Ethereum) IsValidatorActive(addr string) (bool, error)
//ShowOperator ...
func (ethRelayer *Relayer4Ethereum) ShowOperator() (string, error) {
operator, err := ethtxs.GetOperator(ethRelayer.clientSpec, ethRelayer.ethValidator, ethRelayer.bridgeBankAddr)
operator, err := ethtxs.GetOperator(ethRelayer.clientSpec, ethRelayer.ethSender, ethRelayer.bridgeBankAddr)
if nil != err {
return "", err
}
......@@ -898,6 +1208,9 @@ func (ethRelayer *Relayer4Ethereum) handleLogLockEvent(clientChainID *big.Int, c
}
var decimal uint8
tokenLocked, err := ethRelayer.GetLockedTokenAddress(event.Symbol)
if nil == tokenLocked {
//如果在本地没有找到该币种,则进行信息的收集和保存
if event.Token.String() == "" || event.Token.String() == "0x0000000000000000000000000000000000000000" {
decimal = 18
} else {
......@@ -907,15 +1220,12 @@ func (ethRelayer *Relayer4Ethereum) handleLogLockEvent(clientChainID *big.Int, c
Context: context.Background(),
}
bridgeToken, _ := generated.NewBridgeToken(common.HexToAddress(event.Token.String()), ethRelayer.clientSpec)
decimal, err = bridgeToken.Decimals(opts)
if err != nil {
return err
}
}
tokenLocked, err := ethRelayer.GetLockedTokenAddress(event.Symbol)
if nil == tokenLocked {
token2set := &ebTypes.TokenAddress{
Address: event.Token.String(),
Symbol: event.Symbol,
......@@ -927,6 +1237,13 @@ func (ethRelayer *Relayer4Ethereum) handleLogLockEvent(clientChainID *big.Int, c
relayerLog.Error("handleChain33Msg", "Failed to SetLockedTokenAddress due to", err.Error())
return errors.New("Failed ")
}
} else {
decimal = uint8(tokenLocked.Decimal)
}
if ethRelayer.processWithDraw {
//如果是代理提币中继器,则不进行消息的转发,该中继器只需要collect info related to locked token
return nil
}
// Parse the LogLock event's payload into a struct
......@@ -942,6 +1259,10 @@ func (ethRelayer *Relayer4Ethereum) handleLogLockEvent(clientChainID *big.Int, c
// handleLogBurnEvent : unpacks a burn event, converts it to a ProphecyClaim, and relays a tx to chain33
func (ethRelayer *Relayer4Ethereum) handleLogBurnEvent(clientChainID *big.Int, contractABI abi.ABI, eventName string, log types.Log) error {
if ethRelayer.processWithDraw {
//如果是代理提币中继器,则不进行消息的转发
return nil
}
event, err := events.UnpackLogBurn(contractABI, eventName, log.Data)
if nil != err {
return err
......@@ -1000,6 +1321,7 @@ func (ethRelayer *Relayer4Ethereum) ShowStatics(request *ebTypes.TokenStaticsReq
func (ethRelayer *Relayer4Ethereum) updateTxStatus() {
ethRelayer.updateSingleTxStatus(events.ClaimTypeBurn)
ethRelayer.updateSingleTxStatus(events.ClaimTypeLock)
ethRelayer.updateSingleTxStatus(events.ClaimTypeWithdraw)
}
func (ethRelayer *Relayer4Ethereum) updateSingleTxStatus(claimType events.ClaimType) {
......@@ -1083,3 +1405,23 @@ func (ethRelayer *Relayer4Ethereum) SetMultiSignAddr(address string) {
ethRelayer.setMultiSignAddress(address)
}
func (ethRelayer *Relayer4Ethereum) CfgWithdraw(symbol string, feeAmount, amountPerDay string) error {
fee, _ := big.NewInt(0).SetString(feeAmount, 10)
amountPerDayInt, _ := big.NewInt(0).SetString(amountPerDay, 10)
withdrawPara := &WithdrawFeeAndQuota{
Fee: fee,
AmountPerDay: amountPerDayInt,
}
ethRelayer.rwLock.Lock()
ethRelayer.withdrawFee[symbol] = withdrawPara
ethRelayer.rwLock.Unlock()
WithdrawPara := ethRelayer.restoreWithdrawFee()
WithdrawPara[symbol] = &ebTypes.WithdrawPara{
Fee: feeAmount,
AmountPerDay: amountPerDay,
}
return ethRelayer.setWithdrawFee(WithdrawPara)
}
......@@ -29,7 +29,7 @@ import (
var (
chain33Addr = "14KEKbYtKKQm4wMthSK9J4La4nAiidGozt"
//ethAddr = "0x92C8b16aFD6d423652559C6E266cBE1c29Bfd84f"
ethTokenAddr = "0x0000000000000000000000000000000000000000"
//EthNullAddr = "0x0000000000000000000000000000000000000000"
)
type suiteContracts struct {
......@@ -81,7 +81,7 @@ func (c *suiteContracts) Test_LogLockToEthBridgeClaim() {
event := &events.LockEvent{
From: c.para.InitValidators[0],
To: to,
Token: common.HexToAddress(ethTokenAddr),
Token: common.HexToAddress(EthNullAddr),
Symbol: "eth",
Value: big.NewInt(10000 * 10000 * 10000),
Nonce: big.NewInt(1),
......@@ -91,7 +91,7 @@ func (c *suiteContracts) Test_LogLockToEthBridgeClaim() {
assert.NotEmpty(c.T(), witnessClaim)
assert.Equal(c.T(), witnessClaim.EthereumChainID, int64(1))
assert.Equal(c.T(), witnessClaim.BridgeBrankAddr, c.x2EthDeployInfo.BridgeBank.Address.String())
assert.Equal(c.T(), witnessClaim.TokenAddr, ethTokenAddr)
assert.Equal(c.T(), witnessClaim.TokenAddr, EthNullAddr)
assert.Equal(c.T(), witnessClaim.Symbol, event.Symbol)
assert.Equal(c.T(), witnessClaim.EthereumSender, event.From.String())
//assert.Equal(c.T(), witnessClaim.Chain33Receiver, string(event.To))
......@@ -110,7 +110,7 @@ func (c *suiteContracts) Test_LogBurnToEthBridgeClaim() {
event := &events.BurnEvent{
OwnerFrom: c.para.InitValidators[0],
Chain33Receiver: to,
Token: common.HexToAddress(ethTokenAddr),
Token: common.HexToAddress(EthNullAddr),
Symbol: "bty",
Amount: big.NewInt(100),
Nonce: big.NewInt(2),
......@@ -120,7 +120,7 @@ func (c *suiteContracts) Test_LogBurnToEthBridgeClaim() {
assert.NotEmpty(c.T(), witnessClaim)
assert.Equal(c.T(), witnessClaim.EthereumChainID, int64(1))
assert.Equal(c.T(), witnessClaim.BridgeBrankAddr, c.x2EthDeployInfo.BridgeBank.Address.String())
assert.Equal(c.T(), witnessClaim.TokenAddr, ethTokenAddr)
assert.Equal(c.T(), witnessClaim.TokenAddr, EthNullAddr)
assert.Equal(c.T(), witnessClaim.Symbol, event.Symbol)
assert.Equal(c.T(), witnessClaim.EthereumSender, event.OwnerFrom.String())
//assert.Equal(c.T(), witnessClaim.Chain33Receiver, string(event.Chain33Receiver))
......
......@@ -9,9 +9,7 @@ import (
//const ...
const (
X2Eth = "x2ethereum"
BurnAction = "Chain33ToEthBurn"
LockAction = "Chain33ToEthLock"
EthNullAddr = "0x0000000000000000000000000000000000000000"
)
// OracleClaim : contains data required to make an OracleClaim
......@@ -31,3 +29,17 @@ type ProphecyClaim struct {
Amount *big.Int
chain33TxHash []byte
}
type WithdrawStatus int32
const (
WDError = WithdrawStatus(1)
WDPending = WithdrawStatus(2)
WDFailed = WithdrawStatus(3)
WDSuccess = WithdrawStatus(4)
)
// 此处的名字命令不能随意改动,需要与合约event中的命名完全一致
func (d WithdrawStatus) String() string {
return [...]string{"undefined", "Error,not submitted to ethereum", "Pending", "Submitted to ethereum, but Failed", "Success"}[d]
}
......@@ -8,6 +8,8 @@ import (
"sync"
"time"
"github.com/ethereum/go-ethereum/core/types"
"github.com/33cn/plugin/plugin/dapp/cross2eth/ebrelayer/relayer/ethereum/ethinterface"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
......@@ -145,3 +147,40 @@ func GetEthTxStatus(client ethinterface.EthClientSpec, txhash common.Hash) strin
return status
}
func NewTransferTx(clientSpec ethinterface.EthClientSpec, from, to common.Address, input []byte, value *big.Int) (*types.Transaction, error) {
price, err := clientSpec.SuggestGasPrice(context.Background())
if err != nil {
return nil, err
}
nonce, err := getNonce(from, clientSpec)
if err != nil {
return nil, err
}
var gas uint64 = 21000
if input != nil {
//var msg ethereum.CallMsg
//msg.To = &to
//msg.Data = input
//gas, err = clientSpec.EstimateGas(context.Background(), msg)
//if err != nil {
// //return nil,err
// txslog.Error("handleLogWithdraw", "EstimateGas err", err)
// gas = 80000
//}
//实际测试"cumulativeGasUsed": "0xdc82",
gas = uint64(80000)
}
ntx := types.NewTx(&types.LegacyTx{
Nonce: nonce.Uint64(),
GasPrice: price,
To: &to,
Data: input,
Value: value,
Gas: gas,
})
return ntx, nil
}
......@@ -4,6 +4,7 @@ import (
"encoding/json"
"errors"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
......@@ -27,6 +28,9 @@ var (
ethLockTxUpdateTxIndex = []byte("eth-ethLockTxUpdateTxIndex")
ethBurnTxUpdateTxIndex = []byte("eth-ethBurnTxUpdateTxIndex")
multiSignAddressPrefix = []byte("eth-multiSignAddress")
withdrawParaKey = []byte("eth-withdrawPara")
withdrawTokenPrefix = []byte("eth-withdrawToken")
withdrawTokenListPrefix = []byte("eth-withdrawTokenList")
)
func ethTokenSymbol2AddrKey(symbol string) []byte {
......@@ -383,3 +387,102 @@ func (ethRelayer *Relayer4Ethereum) getMultiSignAddress() string {
}
return string(bytes)
}
func (ethRelayer *Relayer4Ethereum) setWithdrawFee(symbol2Para map[string]*ebTypes.WithdrawPara) error {
withdrawSymbol2Fee := &ebTypes.WithdrawSymbol2Para{
Symbol2Para: symbol2Para,
}
bytes := chain33Types.Encode(withdrawSymbol2Fee)
return ethRelayer.db.Set(withdrawParaKey, bytes)
}
func (ethRelayer *Relayer4Ethereum) restoreWithdrawFee() map[string]*ebTypes.WithdrawPara {
bytes, _ := ethRelayer.db.Get(withdrawParaKey)
if 0 == len(bytes) {
result := make(map[string]*ebTypes.WithdrawPara)
return result
}
var withdrawSymbol2Para ebTypes.WithdrawSymbol2Para
if err := chain33Types.Decode(bytes, &withdrawSymbol2Para); nil != err {
result := make(map[string]*ebTypes.WithdrawPara)
return result
}
return withdrawSymbol2Para.Symbol2Para
}
func (ethRelayer *Relayer4Ethereum) restoreWithdrawFeeInINt() map[string]*WithdrawFeeAndQuota {
withdrawPara := ethRelayer.restoreWithdrawFee()
res := make(map[string]*WithdrawFeeAndQuota)
for symbol, para := range withdrawPara {
feeInt, _ := big.NewInt(0).SetString(para.Fee, 10)
amountPerDayInt, _ := big.NewInt(0).SetString(para.AmountPerDay, 10)
res[symbol] = &WithdrawFeeAndQuota{
Fee: feeInt,
AmountPerDay: amountPerDayInt,
}
}
return res
}
func calcWithdrawKey(chain33Sender, symbol string, year, month, day int, nonce int64) []byte {
return []byte(fmt.Sprintf("%s-%s-%s-%d-%d-%d-%d", withdrawTokenPrefix, chain33Sender, symbol, year, month, day, nonce))
}
func calcWithdrawKeyPrefix(chain33Sender, symbol string, year, month, day int) []byte {
return []byte(fmt.Sprintf("%s-%s-%s-%d-%d-%d", withdrawTokenPrefix, chain33Sender, symbol, year, month, day))
}
func calcWithdrawListKey(nonce int64) []byte {
return []byte(fmt.Sprintf("%s-%d", withdrawTokenListPrefix, nonce))
}
func (ethRelayer *Relayer4Ethereum) setWithdraw(withdrawTx *ebTypes.WithdrawTx) error {
chain33Sender := withdrawTx.Chain33Sender
symbol := withdrawTx.Symbol
year := withdrawTx.Year
month := withdrawTx.Month
day := withdrawTx.Day
key := calcWithdrawKey(chain33Sender, symbol, int(year), int(month), int(day), withdrawTx.Nonce)
bytes := chain33Types.Encode(withdrawTx)
if err := ethRelayer.db.Set(key, bytes); nil != err {
return err
}
//保存按照次序提币的交易,方便查询
listKey := calcWithdrawListKey(withdrawTx.Nonce)
listData := key
return ethRelayer.db.Set(listKey, listData)
}
func (ethRelayer *Relayer4Ethereum) getWithdrawsWithinSameDay(withdrawTx *ebTypes.WithdrawTx) (*big.Int, error) {
chain33Sender := withdrawTx.Chain33Sender
symbol := withdrawTx.Symbol
year := withdrawTx.Year
month := withdrawTx.Month
day := withdrawTx.Day
prefix := calcWithdrawKeyPrefix(chain33Sender, symbol, int(year), int(month), int(day))
helper := dbm.NewListHelper(ethRelayer.db)
datas := helper.List(prefix, nil, 100, dbm.ListASC)
if nil == datas {
return big.NewInt(0), nil
}
withdrawTotal := big.NewInt(0)
for _, data := range datas {
var info ebTypes.WithdrawTx
err := chain33Types.Decode(data, &info)
if nil != err {
return big.NewInt(0), err
}
AmountInt, _ := big.NewInt(0).SetString(info.Amount, 0)
withdrawTotal.Add(withdrawTotal, AmountInt)
}
return withdrawTotal, nil
}
......@@ -18,11 +18,13 @@ const (
Chain33EventLogLock
//在chain33的evm合约中产生了burn事件
Chain33EventLogBurn
//在chain33的evm合约中产生了withdraw事件
Chain33EventLogWithdraw
)
// String : returns the event type as a string
func (d Chain33EvmEvent) String() string {
return [...]string{"unknown-event", "LogLock", "LogEthereumTokenBurn"}[d]
return [...]string{"unknown-event", "LogLock", "LogEthereumTokenBurn", "LogEthereumTokenWithdraw"}[d]
}
// Chain33Msg : contains data from MsgBurn and MsgLock events
......@@ -47,6 +49,17 @@ type LockEventOnChain33 struct {
Nonce *big.Int
}
// 发生在chain33 evm上的withdraw事件,当用户发起通过代理人提币交易时,则弹射出该事件信息
type WithdrawEventOnChain33 struct {
BridgeToken chain33EvmCommon.Hash160Address
Symbol string
Amount *big.Int
OwnerFrom chain33EvmCommon.Hash160Address
EthereumReceiver []byte
ProxyReceiver chain33EvmCommon.Hash160Address
Nonce *big.Int
}
// 发生在chain33evm上的burn事件,当eth/erc20资产需要提币回到以太坊链上时,会发生该种事件
type BurnEventOnChain33 struct {
Token chain33EvmCommon.Hash160Address
......@@ -94,12 +107,29 @@ func UnpackChain33LogBurn(contractAbi abi.ABI, eventName string, eventData []byt
return burnEvent, nil
}
// ParseBurnLock4chain33 ParseBurnLockTxReceipt : parses data from a Burn/Lock event witnessed on chain33 into a Chain33Msg struct
func UnpackLogWithdraw(contractAbi abi.ABI, eventName string, eventData []byte) (withdrawEvent *WithdrawEventOnChain33, err error) {
withdrawEvent = &WithdrawEventOnChain33{}
err = contractAbi.UnpackIntoInterface(withdrawEvent, eventName, eventData)
if err != nil {
eventsLog.Error("UnpackLogWithdraw", "Failed to unpack abi due to:", err.Error())
return nil, err
}
eventsLog.Info("UnpackLogWithdraw", "bridge token addr on chain33 evm", withdrawEvent.BridgeToken.ToAddress().String(),
"symbol", withdrawEvent.Symbol,
"Amount", withdrawEvent.Amount.String(),
"Owner address from chain33", withdrawEvent.OwnerFrom.ToAddress().String(),
"EthereumReceiver", common.BytesToAddress(withdrawEvent.EthereumReceiver).String(),
"ProxyReceiver", withdrawEvent.ProxyReceiver.ToAddress().String(),
"nonce", withdrawEvent.Nonce.String())
return withdrawEvent, nil
}
// ParseBurnLock4chain33 ParseBurnLockTxReceipt : parses data from a Burn/Lock/Withdraw event witnessed on chain33 into a Chain33Msg struct
func ParseBurnLock4chain33(evmEventType Chain33EvmEvent, data []byte, bridgeBankAbi abi.ABI, chain33TxHash []byte) (*Chain33Msg, error) {
if Chain33EventLogLock == evmEventType {
lockEvent, err := UnpackChain33LogLock(bridgeBankAbi, evmEventType.String(), data)
if nil != err {
eventsLog.Error("UnpackChain33LogLock", "failed due to", err.Error())
return nil, err
}
......@@ -118,7 +148,6 @@ func ParseBurnLock4chain33(evmEventType Chain33EvmEvent, data []byte, bridgeBank
} else if Chain33EventLogBurn == evmEventType {
burnEvent, err := UnpackChain33LogBurn(bridgeBankAbi, evmEventType.String(), data)
if nil != err {
eventsLog.Error("UnpackChain33LogBurn", "failed due to", err.Error())
return nil, err
}
......@@ -133,6 +162,24 @@ func ParseBurnLock4chain33(evmEventType Chain33EvmEvent, data []byte, bridgeBank
Nonce: burnEvent.Nonce.Int64(),
}
return chain33Msg, nil
} else if Chain33EventLogWithdraw == evmEventType {
burnEvent, err := UnpackLogWithdraw(bridgeBankAbi, evmEventType.String(), data)
if nil != err {
return nil, err
}
chain33Msg := &Chain33Msg{
ClaimType: ClaimTypeWithdraw,
Chain33Sender: burnEvent.OwnerFrom.ToAddress(),
EthereumReceiver: common.BytesToAddress(burnEvent.EthereumReceiver),
TokenContractAddress: burnEvent.BridgeToken.ToAddress(),
Symbol: burnEvent.Symbol,
Amount: burnEvent.Amount,
TxHash: chain33TxHash,
Nonce: burnEvent.Nonce.Int64(),
}
return chain33Msg, nil
}
return nil, errors.New("unknown-event")
......
......@@ -13,6 +13,7 @@ const (
ClaimTypeUnknown = ClaimType(0)
ClaimTypeBurn = ClaimType(1)
ClaimTypeLock = ClaimType(2)
ClaimTypeWithdraw = ClaimType(3)
)
const (
......@@ -30,5 +31,5 @@ func (d Event) String() string {
}
func (d ClaimType) String() string {
return [...]string{"unknown-LOG", "burn", "lock"}[d]
return [...]string{"unknown-LOG", "burn", "lock", "withdraw"}[d]
}
......@@ -1075,3 +1075,37 @@ func (manager *Manager) SetEthMultiSignAddr(multiSignAddr string, result *interf
}
return nil
}
func (manager *Manager) CfgWithdraw(cfgWithdrawReq *relayerTypes.CfgWithdrawReq, result *interface{}) error {
manager.mtx.Lock()
defer manager.mtx.Unlock()
if err := manager.checkPermission(); nil != err {
return err
}
err := manager.ethRelayer.CfgWithdraw(cfgWithdrawReq.Symbol, cfgWithdrawReq.FeeAmount, cfgWithdrawReq.AmountPerDay)
resultCfg := true
if err != nil {
resultCfg = false
}
*result = rpctypes.Reply{
IsOk: resultCfg,
}
return nil
}
func (manager *Manager) WithdrawFromChain33(burn relayerTypes.BurnFromChain33, result *interface{}) error {
manager.mtx.Lock()
defer manager.mtx.Unlock()
if err := manager.checkPermission(); nil != err {
return err
}
txhash, err := manager.chain33Relayer.WithdrawFromChain33(burn.OwnerKey, burn.TokenAddr, burn.EthereumReceiver, burn.Amount)
if nil != err {
return err
}
*result = rpctypes.Reply{
IsOk: true,
Msg: txhash,
}
return nil
}
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.23.0
// protoc v3.9.1
// source: config.proto
package types
import (
fmt "fmt"
math "math"
reflect "reflect"
sync "sync"
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type SyncTxConfig struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Chain33Host string `protobuf:"bytes,1,opt,name=chain33host,proto3" json:"chain33host,omitempty"`
PushHost string `protobuf:"bytes,2,opt,name=pushHost,proto3" json:"pushHost,omitempty"`
PushName string `protobuf:"bytes,3,opt,name=pushName,proto3" json:"pushName,omitempty"`
PushBind string `protobuf:"bytes,4,opt,name=pushBind,proto3" json:"pushBind,omitempty"`
MaturityDegree int32 `protobuf:"varint,5,opt,name=maturityDegree,proto3" json:"maturityDegree,omitempty"`
Dbdriver string `protobuf:"bytes,6,opt,name=dbdriver,proto3" json:"dbdriver,omitempty"`
DbPath string `protobuf:"bytes,7,opt,name=dbPath,proto3" json:"dbPath,omitempty"`
DbCache int32 `protobuf:"varint,8,opt,name=dbCache,proto3" json:"dbCache,omitempty"`
Dbdriver string `protobuf:"bytes,6,opt,name=dbdriver,proto3" json:"dbdriver,omitempty"` //数据库类型
DbPath string `protobuf:"bytes,7,opt,name=dbPath,proto3" json:"dbPath,omitempty"` //数据库存储目录
DbCache int32 `protobuf:"varint,8,opt,name=dbCache,proto3" json:"dbCache,omitempty"` //数据库缓存大小
FetchHeightPeriodMs int64 `protobuf:"varint,9,opt,name=fetchHeightPeriodMs,proto3" json:"fetchHeightPeriodMs,omitempty"`
StartSyncHeight int64 `protobuf:"varint,10,opt,name=startSyncHeight,proto3" json:"startSyncHeight,omitempty"`
StartSyncSequence int64 `protobuf:"varint,11,opt,name=startSyncSequence,proto3" json:"startSyncSequence,omitempty"`
StartSyncHash string `protobuf:"bytes,12,opt,name=startSyncHash,proto3" json:"startSyncHash,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SyncTxConfig) Reset() { *m = SyncTxConfig{} }
func (m *SyncTxConfig) String() string { return proto.CompactTextString(m) }
func (*SyncTxConfig) ProtoMessage() {}
func (*SyncTxConfig) Descriptor() ([]byte, []int) {
return fileDescriptor_3eaf2c85e69e9ea4, []int{0}
func (x *SyncTxConfig) Reset() {
*x = SyncTxConfig{}
if protoimpl.UnsafeEnabled {
mi := &file_config_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (m *SyncTxConfig) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SyncTxConfig.Unmarshal(m, b)
}
func (m *SyncTxConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SyncTxConfig.Marshal(b, m, deterministic)
func (x *SyncTxConfig) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (m *SyncTxConfig) XXX_Merge(src proto.Message) {
xxx_messageInfo_SyncTxConfig.Merge(m, src)
}
func (m *SyncTxConfig) XXX_Size() int {
return xxx_messageInfo_SyncTxConfig.Size(m)
}
func (m *SyncTxConfig) XXX_DiscardUnknown() {
xxx_messageInfo_SyncTxConfig.DiscardUnknown(m)
func (*SyncTxConfig) ProtoMessage() {}
func (x *SyncTxConfig) ProtoReflect() protoreflect.Message {
mi := &file_config_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
var xxx_messageInfo_SyncTxConfig proto.InternalMessageInfo
// Deprecated: Use SyncTxConfig.ProtoReflect.Descriptor instead.
func (*SyncTxConfig) Descriptor() ([]byte, []int) {
return file_config_proto_rawDescGZIP(), []int{0}
}
func (m *SyncTxConfig) GetChain33Host() string {
if m != nil {
return m.Chain33Host
func (x *SyncTxConfig) GetChain33Host() string {
if x != nil {
return x.Chain33Host
}
return ""
}
func (m *SyncTxConfig) GetPushHost() string {
if m != nil {
return m.PushHost
func (x *SyncTxConfig) GetPushHost() string {
if x != nil {
return x.PushHost
}
return ""
}
func (m *SyncTxConfig) GetPushName() string {
if m != nil {
return m.PushName
func (x *SyncTxConfig) GetPushName() string {
if x != nil {
return x.PushName
}
return ""
}
func (m *SyncTxConfig) GetPushBind() string {
if m != nil {
return m.PushBind
func (x *SyncTxConfig) GetPushBind() string {
if x != nil {
return x.PushBind
}
return ""
}
func (m *SyncTxConfig) GetMaturityDegree() int32 {
if m != nil {
return m.MaturityDegree
func (x *SyncTxConfig) GetMaturityDegree() int32 {
if x != nil {
return x.MaturityDegree
}
return 0
}
func (m *SyncTxConfig) GetDbdriver() string {
if m != nil {
return m.Dbdriver
func (x *SyncTxConfig) GetDbdriver() string {
if x != nil {
return x.Dbdriver
}
return ""
}
func (m *SyncTxConfig) GetDbPath() string {
if m != nil {
return m.DbPath
func (x *SyncTxConfig) GetDbPath() string {
if x != nil {
return x.DbPath
}
return ""
}
func (m *SyncTxConfig) GetDbCache() int32 {
if m != nil {
return m.DbCache
func (x *SyncTxConfig) GetDbCache() int32 {
if x != nil {
return x.DbCache
}
return 0
}
func (m *SyncTxConfig) GetFetchHeightPeriodMs() int64 {
if m != nil {
return m.FetchHeightPeriodMs
func (x *SyncTxConfig) GetFetchHeightPeriodMs() int64 {
if x != nil {
return x.FetchHeightPeriodMs
}
return 0
}
func (m *SyncTxConfig) GetStartSyncHeight() int64 {
if m != nil {
return m.StartSyncHeight
func (x *SyncTxConfig) GetStartSyncHeight() int64 {
if x != nil {
return x.StartSyncHeight
}
return 0
}
func (m *SyncTxConfig) GetStartSyncSequence() int64 {
if m != nil {
return m.StartSyncSequence
func (x *SyncTxConfig) GetStartSyncSequence() int64 {
if x != nil {
return x.StartSyncSequence
}
return 0
}
func (m *SyncTxConfig) GetStartSyncHash() string {
if m != nil {
return m.StartSyncHash
func (x *SyncTxConfig) GetStartSyncHash() string {
if x != nil {
return x.StartSyncHash
}
return ""
}
type Log struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Loglevel string `protobuf:"bytes,1,opt,name=loglevel,proto3" json:"loglevel,omitempty"`
LogConsoleLevel string `protobuf:"bytes,2,opt,name=logConsoleLevel,proto3" json:"logConsoleLevel,omitempty"`
LogFile string `protobuf:"bytes,3,opt,name=logFile,proto3" json:"logFile,omitempty"`
......@@ -159,111 +176,119 @@ type Log struct {
Compress bool `protobuf:"varint,8,opt,name=compress,proto3" json:"compress,omitempty"`
CallerFile bool `protobuf:"varint,9,opt,name=callerFile,proto3" json:"callerFile,omitempty"`
CallerFunction bool `protobuf:"varint,10,opt,name=callerFunction,proto3" json:"callerFunction,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Log) Reset() { *m = Log{} }
func (m *Log) String() string { return proto.CompactTextString(m) }
func (*Log) ProtoMessage() {}
func (*Log) Descriptor() ([]byte, []int) {
return fileDescriptor_3eaf2c85e69e9ea4, []int{1}
func (x *Log) Reset() {
*x = Log{}
if protoimpl.UnsafeEnabled {
mi := &file_config_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (m *Log) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Log.Unmarshal(m, b)
}
func (m *Log) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Log.Marshal(b, m, deterministic)
}
func (m *Log) XXX_Merge(src proto.Message) {
xxx_messageInfo_Log.Merge(m, src)
func (x *Log) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (m *Log) XXX_Size() int {
return xxx_messageInfo_Log.Size(m)
}
func (m *Log) XXX_DiscardUnknown() {
xxx_messageInfo_Log.DiscardUnknown(m)
func (*Log) ProtoMessage() {}
func (x *Log) ProtoReflect() protoreflect.Message {
mi := &file_config_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
var xxx_messageInfo_Log proto.InternalMessageInfo
// Deprecated: Use Log.ProtoReflect.Descriptor instead.
func (*Log) Descriptor() ([]byte, []int) {
return file_config_proto_rawDescGZIP(), []int{1}
}
func (m *Log) GetLoglevel() string {
if m != nil {
return m.Loglevel
func (x *Log) GetLoglevel() string {
if x != nil {
return x.Loglevel
}
return ""
}
func (m *Log) GetLogConsoleLevel() string {
if m != nil {
return m.LogConsoleLevel
func (x *Log) GetLogConsoleLevel() string {
if x != nil {
return x.LogConsoleLevel
}
return ""
}
func (m *Log) GetLogFile() string {
if m != nil {
return m.LogFile
func (x *Log) GetLogFile() string {
if x != nil {
return x.LogFile
}
return ""
}
func (m *Log) GetMaxFileSize() uint32 {
if m != nil {
return m.MaxFileSize
func (x *Log) GetMaxFileSize() uint32 {
if x != nil {
return x.MaxFileSize
}
return 0
}
func (m *Log) GetMaxBackups() uint32 {
if m != nil {
return m.MaxBackups
func (x *Log) GetMaxBackups() uint32 {
if x != nil {
return x.MaxBackups
}
return 0
}
func (m *Log) GetMaxAge() uint32 {
if m != nil {
return m.MaxAge
func (x *Log) GetMaxAge() uint32 {
if x != nil {
return x.MaxAge
}
return 0
}
func (m *Log) GetLocalTime() bool {
if m != nil {
return m.LocalTime
func (x *Log) GetLocalTime() bool {
if x != nil {
return x.LocalTime
}
return false
}
func (m *Log) GetCompress() bool {
if m != nil {
return m.Compress
func (x *Log) GetCompress() bool {
if x != nil {
return x.Compress
}
return false
}
func (m *Log) GetCallerFile() bool {
if m != nil {
return m.CallerFile
func (x *Log) GetCallerFile() bool {
if x != nil {
return x.CallerFile
}
return false
}
func (m *Log) GetCallerFunction() bool {
if m != nil {
return m.CallerFunction
func (x *Log) GetCallerFunction() bool {
if x != nil {
return x.CallerFunction
}
return false
}
type RelayerConfig struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
SyncTxConfig *SyncTxConfig `protobuf:"bytes,2,opt,name=syncTxConfig,proto3" json:"syncTxConfig,omitempty"`
Log *Log `protobuf:"bytes,3,opt,name=log,proto3" json:"log,omitempty"`
JrpcBindAddr string `protobuf:"bytes,4,opt,name=jrpcBindAddr,proto3" json:"jrpcBindAddr,omitempty"`
JrpcBindAddr string `protobuf:"bytes,4,opt,name=jrpcBindAddr,proto3" json:"jrpcBindAddr,omitempty"` // Jrpc服务地址
EthProvider string `protobuf:"bytes,5,opt,name=ethProvider,proto3" json:"ethProvider,omitempty"`
BridgeRegistry string `protobuf:"bytes,6,opt,name=bridgeRegistry,proto3" json:"bridgeRegistry,omitempty"`
Deploy *Deploy `protobuf:"bytes,7,opt,name=deploy,proto3" json:"deploy,omitempty"`
......@@ -274,135 +299,151 @@ type RelayerConfig struct {
BridgeRegistryOnChain33 string `protobuf:"bytes,12,opt,name=bridgeRegistryOnChain33,proto3" json:"bridgeRegistryOnChain33,omitempty"`
ChainName string `protobuf:"bytes,13,opt,name=chainName,proto3" json:"chainName,omitempty"`
ChainID4Chain33 int32 `protobuf:"varint,14,opt,name=chainID4Chain33,proto3" json:"chainID4Chain33,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
ProcessWithDraw bool `protobuf:"varint,15,opt,name=processWithDraw,proto3" json:"processWithDraw,omitempty"`
}
func (m *RelayerConfig) Reset() { *m = RelayerConfig{} }
func (m *RelayerConfig) String() string { return proto.CompactTextString(m) }
func (*RelayerConfig) ProtoMessage() {}
func (*RelayerConfig) Descriptor() ([]byte, []int) {
return fileDescriptor_3eaf2c85e69e9ea4, []int{2}
func (x *RelayerConfig) Reset() {
*x = RelayerConfig{}
if protoimpl.UnsafeEnabled {
mi := &file_config_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (m *RelayerConfig) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_RelayerConfig.Unmarshal(m, b)
}
func (m *RelayerConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_RelayerConfig.Marshal(b, m, deterministic)
}
func (m *RelayerConfig) XXX_Merge(src proto.Message) {
xxx_messageInfo_RelayerConfig.Merge(m, src)
}
func (m *RelayerConfig) XXX_Size() int {
return xxx_messageInfo_RelayerConfig.Size(m)
func (x *RelayerConfig) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (m *RelayerConfig) XXX_DiscardUnknown() {
xxx_messageInfo_RelayerConfig.DiscardUnknown(m)
func (*RelayerConfig) ProtoMessage() {}
func (x *RelayerConfig) ProtoReflect() protoreflect.Message {
mi := &file_config_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
var xxx_messageInfo_RelayerConfig proto.InternalMessageInfo
// Deprecated: Use RelayerConfig.ProtoReflect.Descriptor instead.
func (*RelayerConfig) Descriptor() ([]byte, []int) {
return file_config_proto_rawDescGZIP(), []int{2}
}
func (m *RelayerConfig) GetTitle() string {
if m != nil {
return m.Title
func (x *RelayerConfig) GetTitle() string {
if x != nil {
return x.Title
}
return ""
}
func (m *RelayerConfig) GetSyncTxConfig() *SyncTxConfig {
if m != nil {
return m.SyncTxConfig
func (x *RelayerConfig) GetSyncTxConfig() *SyncTxConfig {
if x != nil {
return x.SyncTxConfig
}
return nil
}
func (m *RelayerConfig) GetLog() *Log {
if m != nil {
return m.Log
func (x *RelayerConfig) GetLog() *Log {
if x != nil {
return x.Log
}
return nil
}
func (m *RelayerConfig) GetJrpcBindAddr() string {
if m != nil {
return m.JrpcBindAddr
func (x *RelayerConfig) GetJrpcBindAddr() string {
if x != nil {
return x.JrpcBindAddr
}
return ""
}
func (m *RelayerConfig) GetEthProvider() string {
if m != nil {
return m.EthProvider
func (x *RelayerConfig) GetEthProvider() string {
if x != nil {
return x.EthProvider
}
return ""
}
func (m *RelayerConfig) GetBridgeRegistry() string {
if m != nil {
return m.BridgeRegistry
func (x *RelayerConfig) GetBridgeRegistry() string {
if x != nil {
return x.BridgeRegistry
}
return ""
}
func (m *RelayerConfig) GetDeploy() *Deploy {
if m != nil {
return m.Deploy
func (x *RelayerConfig) GetDeploy() *Deploy {
if x != nil {
return x.Deploy
}
return nil
}
func (m *RelayerConfig) GetDeploy4Chain33() *Deploy {
if m != nil {
return m.Deploy4Chain33
func (x *RelayerConfig) GetDeploy4Chain33() *Deploy {
if x != nil {
return x.Deploy4Chain33
}
return nil
}
func (m *RelayerConfig) GetEthMaturityDegree() int32 {
if m != nil {
return m.EthMaturityDegree
func (x *RelayerConfig) GetEthMaturityDegree() int32 {
if x != nil {
return x.EthMaturityDegree
}
return 0
}
func (m *RelayerConfig) GetEthBlockFetchPeriod() int32 {
if m != nil {
return m.EthBlockFetchPeriod
func (x *RelayerConfig) GetEthBlockFetchPeriod() int32 {
if x != nil {
return x.EthBlockFetchPeriod
}
return 0
}
func (m *RelayerConfig) GetEthProviderCli() string {
if m != nil {
return m.EthProviderCli
func (x *RelayerConfig) GetEthProviderCli() string {
if x != nil {
return x.EthProviderCli
}
return ""
}
func (m *RelayerConfig) GetBridgeRegistryOnChain33() string {
if m != nil {
return m.BridgeRegistryOnChain33
func (x *RelayerConfig) GetBridgeRegistryOnChain33() string {
if x != nil {
return x.BridgeRegistryOnChain33
}
return ""
}
func (m *RelayerConfig) GetChainName() string {
if m != nil {
return m.ChainName
func (x *RelayerConfig) GetChainName() string {
if x != nil {
return x.ChainName
}
return ""
}
func (m *RelayerConfig) GetChainID4Chain33() int32 {
if m != nil {
return m.ChainID4Chain33
func (x *RelayerConfig) GetChainID4Chain33() int32 {
if x != nil {
return x.ChainID4Chain33
}
return 0
}
func (x *RelayerConfig) GetProcessWithDraw() bool {
if x != nil {
return x.ProcessWithDraw
}
return false
}
type SyncTxReceiptConfig struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Chain33Host string `protobuf:"bytes,1,opt,name=chain33host,proto3" json:"chain33host,omitempty"`
PushHost string `protobuf:"bytes,2,opt,name=pushHost,proto3" json:"pushHost,omitempty"`
PushName string `protobuf:"bytes,3,opt,name=pushName,proto3" json:"pushName,omitempty"`
......@@ -411,93 +452,101 @@ type SyncTxReceiptConfig struct {
StartSyncSequence int64 `protobuf:"varint,6,opt,name=startSyncSequence,proto3" json:"startSyncSequence,omitempty"`
StartSyncHash string `protobuf:"bytes,7,opt,name=startSyncHash,proto3" json:"startSyncHash,omitempty"`
Contracts []string `protobuf:"bytes,8,rep,name=contracts,proto3" json:"contracts,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *SyncTxReceiptConfig) Reset() { *m = SyncTxReceiptConfig{} }
func (m *SyncTxReceiptConfig) String() string { return proto.CompactTextString(m) }
func (*SyncTxReceiptConfig) ProtoMessage() {}
func (*SyncTxReceiptConfig) Descriptor() ([]byte, []int) {
return fileDescriptor_3eaf2c85e69e9ea4, []int{3}
func (x *SyncTxReceiptConfig) Reset() {
*x = SyncTxReceiptConfig{}
if protoimpl.UnsafeEnabled {
mi := &file_config_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (m *SyncTxReceiptConfig) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_SyncTxReceiptConfig.Unmarshal(m, b)
}
func (m *SyncTxReceiptConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_SyncTxReceiptConfig.Marshal(b, m, deterministic)
}
func (m *SyncTxReceiptConfig) XXX_Merge(src proto.Message) {
xxx_messageInfo_SyncTxReceiptConfig.Merge(m, src)
func (x *SyncTxReceiptConfig) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (m *SyncTxReceiptConfig) XXX_Size() int {
return xxx_messageInfo_SyncTxReceiptConfig.Size(m)
}
func (m *SyncTxReceiptConfig) XXX_DiscardUnknown() {
xxx_messageInfo_SyncTxReceiptConfig.DiscardUnknown(m)
func (*SyncTxReceiptConfig) ProtoMessage() {}
func (x *SyncTxReceiptConfig) ProtoReflect() protoreflect.Message {
mi := &file_config_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
var xxx_messageInfo_SyncTxReceiptConfig proto.InternalMessageInfo
// Deprecated: Use SyncTxReceiptConfig.ProtoReflect.Descriptor instead.
func (*SyncTxReceiptConfig) Descriptor() ([]byte, []int) {
return file_config_proto_rawDescGZIP(), []int{3}
}
func (m *SyncTxReceiptConfig) GetChain33Host() string {
if m != nil {
return m.Chain33Host
func (x *SyncTxReceiptConfig) GetChain33Host() string {
if x != nil {
return x.Chain33Host
}
return ""
}
func (m *SyncTxReceiptConfig) GetPushHost() string {
if m != nil {
return m.PushHost
func (x *SyncTxReceiptConfig) GetPushHost() string {
if x != nil {
return x.PushHost
}
return ""
}
func (m *SyncTxReceiptConfig) GetPushName() string {
if m != nil {
return m.PushName
func (x *SyncTxReceiptConfig) GetPushName() string {
if x != nil {
return x.PushName
}
return ""
}
func (m *SyncTxReceiptConfig) GetPushBind() string {
if m != nil {
return m.PushBind
func (x *SyncTxReceiptConfig) GetPushBind() string {
if x != nil {
return x.PushBind
}
return ""
}
func (m *SyncTxReceiptConfig) GetStartSyncHeight() int64 {
if m != nil {
return m.StartSyncHeight
func (x *SyncTxReceiptConfig) GetStartSyncHeight() int64 {
if x != nil {
return x.StartSyncHeight
}
return 0
}
func (m *SyncTxReceiptConfig) GetStartSyncSequence() int64 {
if m != nil {
return m.StartSyncSequence
func (x *SyncTxReceiptConfig) GetStartSyncSequence() int64 {
if x != nil {
return x.StartSyncSequence
}
return 0
}
func (m *SyncTxReceiptConfig) GetStartSyncHash() string {
if m != nil {
return m.StartSyncHash
func (x *SyncTxReceiptConfig) GetStartSyncHash() string {
if x != nil {
return x.StartSyncHash
}
return ""
}
func (m *SyncTxReceiptConfig) GetContracts() []string {
if m != nil {
return m.Contracts
func (x *SyncTxReceiptConfig) GetContracts() []string {
if x != nil {
return x.Contracts
}
return nil
}
type Deploy struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
//操作管理员地址
OperatorAddr string `protobuf:"bytes,1,opt,name=operatorAddr,proto3" json:"operatorAddr,omitempty"`
//合约部署人员私钥,用于部署合约时签名使用
......@@ -506,123 +555,307 @@ type Deploy struct {
ValidatorsAddr []string `protobuf:"bytes,3,rep,name=validatorsAddr,proto3" json:"validatorsAddr,omitempty"`
//验证人权重
InitPowers []int64 `protobuf:"varint,4,rep,packed,name=initPowers,proto3" json:"initPowers,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Deploy) Reset() { *m = Deploy{} }
func (m *Deploy) String() string { return proto.CompactTextString(m) }
func (*Deploy) ProtoMessage() {}
func (*Deploy) Descriptor() ([]byte, []int) {
return fileDescriptor_3eaf2c85e69e9ea4, []int{4}
func (x *Deploy) Reset() {
*x = Deploy{}
if protoimpl.UnsafeEnabled {
mi := &file_config_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (m *Deploy) XXX_Unmarshal(b []byte) error {
return xxx_messageInfo_Deploy.Unmarshal(m, b)
func (x *Deploy) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (m *Deploy) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
return xxx_messageInfo_Deploy.Marshal(b, m, deterministic)
}
func (m *Deploy) XXX_Merge(src proto.Message) {
xxx_messageInfo_Deploy.Merge(m, src)
}
func (m *Deploy) XXX_Size() int {
return xxx_messageInfo_Deploy.Size(m)
}
func (m *Deploy) XXX_DiscardUnknown() {
xxx_messageInfo_Deploy.DiscardUnknown(m)
func (*Deploy) ProtoMessage() {}
func (x *Deploy) ProtoReflect() protoreflect.Message {
mi := &file_config_proto_msgTypes[4]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
var xxx_messageInfo_Deploy proto.InternalMessageInfo
// Deprecated: Use Deploy.ProtoReflect.Descriptor instead.
func (*Deploy) Descriptor() ([]byte, []int) {
return file_config_proto_rawDescGZIP(), []int{4}
}
func (m *Deploy) GetOperatorAddr() string {
if m != nil {
return m.OperatorAddr
func (x *Deploy) GetOperatorAddr() string {
if x != nil {
return x.OperatorAddr
}
return ""
}
func (m *Deploy) GetDeployerPrivateKey() string {
if m != nil {
return m.DeployerPrivateKey
func (x *Deploy) GetDeployerPrivateKey() string {
if x != nil {
return x.DeployerPrivateKey
}
return ""
}
func (m *Deploy) GetValidatorsAddr() []string {
if m != nil {
return m.ValidatorsAddr
func (x *Deploy) GetValidatorsAddr() []string {
if x != nil {
return x.ValidatorsAddr
}
return nil
}
func (m *Deploy) GetInitPowers() []int64 {
if m != nil {
return m.InitPowers
func (x *Deploy) GetInitPowers() []int64 {
if x != nil {
return x.InitPowers
}
return nil
}
func init() {
proto.RegisterType((*SyncTxConfig)(nil), "types.SyncTxConfig")
proto.RegisterType((*Log)(nil), "types.Log")
proto.RegisterType((*RelayerConfig)(nil), "types.RelayerConfig")
proto.RegisterType((*SyncTxReceiptConfig)(nil), "types.SyncTxReceiptConfig")
proto.RegisterType((*Deploy)(nil), "types.Deploy")
}
func init() { proto.RegisterFile("config.proto", fileDescriptor_3eaf2c85e69e9ea4) }
var fileDescriptor_3eaf2c85e69e9ea4 = []byte{
// 772 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xc1, 0x6e, 0xdb, 0x46,
0x10, 0x85, 0x4c, 0x4b, 0x96, 0x56, 0x92, 0x8b, 0xae, 0x8b, 0x96, 0x28, 0x8c, 0x42, 0x10, 0xda,
0x42, 0x87, 0x42, 0x2d, 0x6c, 0x17, 0xc9, 0xd5, 0x92, 0x61, 0x38, 0x88, 0x9d, 0x08, 0x6b, 0x9f,
0x72, 0x5b, 0x2d, 0xc7, 0xe4, 0xc6, 0x2b, 0x2e, 0xb3, 0x5c, 0x29, 0x52, 0xbe, 0x27, 0x40, 0x80,
0xfc, 0x45, 0x7e, 0x21, 0x5f, 0x14, 0xec, 0x90, 0x94, 0x28, 0x5a, 0x01, 0x92, 0x53, 0x6e, 0x9c,
0xf7, 0x06, 0xa3, 0x9d, 0x37, 0xf3, 0x46, 0xa4, 0x23, 0x74, 0x7c, 0x2f, 0xc3, 0x61, 0x62, 0xb4,
0xd5, 0xb4, 0x6e, 0x57, 0x09, 0xa4, 0xfd, 0x8f, 0x1e, 0xe9, 0xdc, 0xae, 0x62, 0x71, 0xb7, 0x1c,
0x23, 0x4b, 0x7b, 0xa4, 0x2d, 0x22, 0x2e, 0xe3, 0xd3, 0xd3, 0x48, 0xa7, 0xd6, 0xaf, 0xf5, 0x6a,
0x83, 0x16, 0x2b, 0x43, 0xf4, 0x77, 0xd2, 0x4c, 0xe6, 0x69, 0x74, 0xe5, 0xe8, 0x3d, 0xa4, 0xd7,
0x71, 0xc1, 0xbd, 0xe0, 0x33, 0xf0, 0xbd, 0x0d, 0xe7, 0xe2, 0x82, 0x1b, 0xc9, 0x38, 0xf0, 0xf7,
0x37, 0x9c, 0x8b, 0xe9, 0xdf, 0xe4, 0x70, 0xc6, 0xed, 0xdc, 0x48, 0xbb, 0xba, 0x80, 0xd0, 0x00,
0xf8, 0xf5, 0x5e, 0x6d, 0x50, 0x67, 0x15, 0xd4, 0xd5, 0x08, 0xa6, 0x81, 0x91, 0x0b, 0x30, 0x7e,
0x23, 0xab, 0x51, 0xc4, 0xf4, 0x57, 0xd2, 0x08, 0xa6, 0x13, 0x6e, 0x23, 0xff, 0x00, 0x99, 0x3c,
0xa2, 0x3e, 0x39, 0x08, 0xa6, 0x63, 0x2e, 0x22, 0xf0, 0x9b, 0x58, 0xb4, 0x08, 0xe9, 0x7f, 0xe4,
0xe8, 0x1e, 0xac, 0x88, 0xae, 0x40, 0x86, 0x91, 0x9d, 0x80, 0x91, 0x3a, 0xb8, 0x49, 0xfd, 0x56,
0xaf, 0x36, 0xf0, 0xd8, 0x2e, 0x8a, 0x0e, 0xc8, 0x4f, 0xa9, 0xe5, 0xc6, 0x3a, 0xc9, 0x32, 0xca,
0x27, 0x98, 0x5d, 0x85, 0xe9, 0x3f, 0xe4, 0xe7, 0x35, 0x74, 0x0b, 0x6f, 0xe6, 0x10, 0x0b, 0xf0,
0xdb, 0x98, 0xfb, 0x98, 0xa0, 0x7f, 0x92, 0xee, 0xa6, 0x00, 0x4f, 0x23, 0xbf, 0x83, 0x2d, 0x6c,
0x83, 0xfd, 0x4f, 0x7b, 0xc4, 0xbb, 0xd6, 0xa1, 0x53, 0x41, 0xe9, 0x50, 0xc1, 0x02, 0x54, 0x3e,
0xa0, 0x75, 0xec, 0x5e, 0xa8, 0x74, 0x38, 0xd6, 0x71, 0xaa, 0x15, 0x5c, 0x63, 0x4a, 0x36, 0xa4,
0x2a, 0xec, 0x74, 0x51, 0x3a, 0xbc, 0x94, 0xaa, 0x18, 0x55, 0x11, 0xba, 0x1d, 0x98, 0xf1, 0xa5,
0xfb, 0xbc, 0x95, 0xef, 0x00, 0x87, 0xd5, 0x65, 0x65, 0x88, 0xfe, 0x41, 0xc8, 0x8c, 0x2f, 0x47,
0x5c, 0x3c, 0xcc, 0x93, 0x14, 0x67, 0xd5, 0x65, 0x25, 0xc4, 0xcd, 0x62, 0xc6, 0x97, 0xe7, 0x21,
0xe0, 0x94, 0xba, 0x2c, 0x8f, 0xe8, 0x31, 0x69, 0x29, 0x2d, 0xb8, 0xba, 0x93, 0x33, 0xc0, 0x31,
0x35, 0xd9, 0x06, 0x70, 0x7d, 0x09, 0x3d, 0x4b, 0x0c, 0xa4, 0x29, 0x8e, 0xaa, 0xc9, 0xd6, 0xb1,
0xfb, 0x45, 0xc1, 0x95, 0x02, 0x83, 0x0f, 0x6e, 0x21, 0x5b, 0x42, 0xdc, 0x06, 0xe5, 0xd1, 0x3c,
0x16, 0x56, 0xea, 0x18, 0x07, 0xd3, 0x64, 0x15, 0xb4, 0xff, 0x79, 0x9f, 0x74, 0x19, 0x28, 0xbe,
0x02, 0x93, 0x6f, 0xfc, 0x2f, 0xa4, 0x6e, 0xa5, 0x55, 0x90, 0x4b, 0x99, 0x05, 0xf4, 0x09, 0xe9,
0xa4, 0x25, 0x5f, 0xa0, 0x88, 0xed, 0x93, 0xa3, 0x21, 0xda, 0x66, 0x58, 0xb6, 0x0c, 0xdb, 0x4a,
0xa4, 0xc7, 0xc4, 0x53, 0x3a, 0x44, 0x49, 0xdb, 0x27, 0x24, 0xcf, 0xbf, 0xd6, 0x21, 0x73, 0x30,
0xed, 0x93, 0xce, 0x6b, 0x93, 0x08, 0xb7, 0xf4, 0xe7, 0x41, 0x60, 0x72, 0x23, 0x6c, 0x61, 0x4e,
0x7e, 0xb0, 0xd1, 0xc4, 0xe8, 0x85, 0x0c, 0xc0, 0xa0, 0xba, 0x2d, 0x56, 0x86, 0x5c, 0xb3, 0x53,
0x23, 0x83, 0x10, 0x18, 0x84, 0x32, 0xb5, 0x66, 0x95, 0x9b, 0xa1, 0x82, 0xd2, 0xbf, 0x48, 0x23,
0x80, 0x44, 0xe9, 0x15, 0x6a, 0xdd, 0x3e, 0xe9, 0xe6, 0xcf, 0xb9, 0x40, 0x90, 0xe5, 0x24, 0xfd,
0x9f, 0x1c, 0x66, 0x5f, 0x67, 0xb9, 0xcf, 0x51, 0xfd, 0x47, 0xe9, 0x95, 0x24, 0xb7, 0xe2, 0x60,
0xa3, 0x9b, 0x6d, 0xdf, 0xb6, 0xd0, 0x62, 0x8f, 0x09, 0x67, 0x36, 0xb0, 0xd1, 0x48, 0x69, 0xf1,
0x70, 0xe9, 0x9c, 0x95, 0x79, 0x0a, 0xa7, 0x54, 0x67, 0xbb, 0x28, 0xd7, 0x65, 0xa9, 0xe9, 0xb1,
0x92, 0xe8, 0x9f, 0x16, 0xab, 0xa0, 0xf4, 0x29, 0xf9, 0x6d, 0xbb, 0xef, 0x97, 0xf1, 0x38, 0xef,
0x23, 0xb3, 0xd1, 0xd7, 0x68, 0xb7, 0x8e, 0xd8, 0x0c, 0xde, 0xab, 0x2e, 0xe6, 0x6e, 0x00, 0x67,
0x25, 0x0c, 0x9e, 0x5d, 0x9c, 0x15, 0xf5, 0x0e, 0xf1, 0xb5, 0x55, 0xb8, 0xff, 0x61, 0x8f, 0x1c,
0x65, 0x2b, 0xc1, 0x40, 0x80, 0x4c, 0xec, 0x0f, 0x3d, 0xa6, 0x3b, 0x8e, 0x54, 0xfd, 0x3b, 0x8e,
0x54, 0xe3, 0x9b, 0x8f, 0xd4, 0xc1, 0x8e, 0x23, 0x85, 0x9a, 0xea, 0xd8, 0x1a, 0x2e, 0xac, 0x73,
0xb1, 0x87, 0x9a, 0x16, 0x40, 0xff, 0x7d, 0x8d, 0x34, 0xb2, 0x75, 0x72, 0x56, 0xd0, 0x09, 0x18,
0x6e, 0xb5, 0x41, 0x2b, 0x64, 0xea, 0x6c, 0x61, 0x74, 0x48, 0x68, 0xb6, 0x74, 0x60, 0x26, 0x46,
0x2e, 0xb8, 0x85, 0xe7, 0xb0, 0xca, 0x85, 0xda, 0xc1, 0xb8, 0x95, 0x59, 0x70, 0x25, 0x03, 0x57,
0x20, 0xc5, 0xaa, 0x1e, 0xbe, 0xa0, 0x82, 0xba, 0x6b, 0x22, 0x63, 0x69, 0x27, 0xfa, 0x2d, 0x98,
0xd4, 0xdf, 0xef, 0x79, 0x03, 0x8f, 0x95, 0x90, 0x11, 0x79, 0xd5, 0x1c, 0x0e, 0xff, 0xc5, 0xed,
0x9f, 0x36, 0xf0, 0x0f, 0xf3, 0xf4, 0x4b, 0x00, 0x00, 0x00, 0xff, 0xff, 0x54, 0x92, 0x59, 0xbb,
0x40, 0x07, 0x00, 0x00,
var File_config_proto protoreflect.FileDescriptor
var file_config_proto_rawDesc = []byte{
0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x05,
0x74, 0x79, 0x70, 0x65, 0x73, 0x22, 0xaa, 0x03, 0x0a, 0x0c, 0x53, 0x79, 0x6e, 0x63, 0x54, 0x78,
0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x20, 0x0a, 0x0b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x33,
0x33, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x68, 0x61,
0x69, 0x6e, 0x33, 0x33, 0x68, 0x6f, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x75, 0x73, 0x68,
0x48, 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x73, 0x68,
0x48, 0x6f, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x75, 0x73, 0x68, 0x4e, 0x61, 0x6d, 0x65,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x73, 0x68, 0x4e, 0x61, 0x6d, 0x65,
0x12, 0x1a, 0x0a, 0x08, 0x70, 0x75, 0x73, 0x68, 0x42, 0x69, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01,
0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x73, 0x68, 0x42, 0x69, 0x6e, 0x64, 0x12, 0x26, 0x0a, 0x0e,
0x6d, 0x61, 0x74, 0x75, 0x72, 0x69, 0x74, 0x79, 0x44, 0x65, 0x67, 0x72, 0x65, 0x65, 0x18, 0x05,
0x20, 0x01, 0x28, 0x05, 0x52, 0x0e, 0x6d, 0x61, 0x74, 0x75, 0x72, 0x69, 0x74, 0x79, 0x44, 0x65,
0x67, 0x72, 0x65, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x62, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72,
0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x64, 0x62, 0x64, 0x72, 0x69, 0x76, 0x65, 0x72,
0x12, 0x16, 0x0a, 0x06, 0x64, 0x62, 0x50, 0x61, 0x74, 0x68, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09,
0x52, 0x06, 0x64, 0x62, 0x50, 0x61, 0x74, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x62, 0x43, 0x61,
0x63, 0x68, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x64, 0x62, 0x43, 0x61, 0x63,
0x68, 0x65, 0x12, 0x30, 0x0a, 0x13, 0x66, 0x65, 0x74, 0x63, 0x68, 0x48, 0x65, 0x69, 0x67, 0x68,
0x74, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x4d, 0x73, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52,
0x13, 0x66, 0x65, 0x74, 0x63, 0x68, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x50, 0x65, 0x72, 0x69,
0x6f, 0x64, 0x4d, 0x73, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x53, 0x79, 0x6e,
0x63, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x73,
0x74, 0x61, 0x72, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x2c,
0x0a, 0x11, 0x73, 0x74, 0x61, 0x72, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x53, 0x65, 0x71, 0x75, 0x65,
0x6e, 0x63, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x11, 0x73, 0x74, 0x61, 0x72, 0x74,
0x53, 0x79, 0x6e, 0x63, 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x24, 0x0a, 0x0d,
0x73, 0x74, 0x61, 0x72, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x48, 0x61, 0x73, 0x68, 0x18, 0x0c, 0x20,
0x01, 0x28, 0x09, 0x52, 0x0d, 0x73, 0x74, 0x61, 0x72, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x48, 0x61,
0x73, 0x68, 0x22, 0xc1, 0x02, 0x0a, 0x03, 0x4c, 0x6f, 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x6c, 0x6f,
0x67, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, 0x6f,
0x67, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x28, 0x0a, 0x0f, 0x6c, 0x6f, 0x67, 0x43, 0x6f, 0x6e,
0x73, 0x6f, 0x6c, 0x65, 0x4c, 0x65, 0x76, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0f, 0x6c, 0x6f, 0x67, 0x43, 0x6f, 0x6e, 0x73, 0x6f, 0x6c, 0x65, 0x4c, 0x65, 0x76, 0x65, 0x6c,
0x12, 0x18, 0x0a, 0x07, 0x6c, 0x6f, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28,
0x09, 0x52, 0x07, 0x6c, 0x6f, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x6d, 0x61,
0x78, 0x46, 0x69, 0x6c, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52,
0x0b, 0x6d, 0x61, 0x78, 0x46, 0x69, 0x6c, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1e, 0x0a, 0x0a,
0x6d, 0x61, 0x78, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d,
0x52, 0x0a, 0x6d, 0x61, 0x78, 0x42, 0x61, 0x63, 0x6b, 0x75, 0x70, 0x73, 0x12, 0x16, 0x0a, 0x06,
0x6d, 0x61, 0x78, 0x41, 0x67, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x6d, 0x61,
0x78, 0x41, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x54, 0x69, 0x6d,
0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x54, 0x69,
0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x18, 0x08,
0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x70, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1e,
0x0a, 0x0a, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x46, 0x69, 0x6c, 0x65, 0x18, 0x09, 0x20, 0x01,
0x28, 0x08, 0x52, 0x0a, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x26,
0x0a, 0x0e, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e,
0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0e, 0x63, 0x61, 0x6c, 0x6c, 0x65, 0x72, 0x46, 0x75,
0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xfc, 0x04, 0x0a, 0x0d, 0x52, 0x65, 0x6c, 0x61, 0x79,
0x65, 0x72, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x37,
0x0a, 0x0c, 0x73, 0x79, 0x6e, 0x63, 0x54, 0x78, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x53, 0x79, 0x6e,
0x63, 0x54, 0x78, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x0c, 0x73, 0x79, 0x6e, 0x63, 0x54,
0x78, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x1c, 0x0a, 0x03, 0x6c, 0x6f, 0x67, 0x18, 0x03,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x4c, 0x6f, 0x67,
0x52, 0x03, 0x6c, 0x6f, 0x67, 0x12, 0x22, 0x0a, 0x0c, 0x6a, 0x72, 0x70, 0x63, 0x42, 0x69, 0x6e,
0x64, 0x41, 0x64, 0x64, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6a, 0x72, 0x70,
0x63, 0x42, 0x69, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x65, 0x74, 0x68,
0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b,
0x65, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x0e, 0x62,
0x72, 0x69, 0x64, 0x67, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x18, 0x06, 0x20,
0x01, 0x28, 0x09, 0x52, 0x0e, 0x62, 0x72, 0x69, 0x64, 0x67, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73,
0x74, 0x72, 0x79, 0x12, 0x25, 0x0a, 0x06, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x18, 0x07, 0x20,
0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x44, 0x65, 0x70, 0x6c,
0x6f, 0x79, 0x52, 0x06, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x12, 0x35, 0x0a, 0x0e, 0x64, 0x65,
0x70, 0x6c, 0x6f, 0x79, 0x34, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x33, 0x33, 0x18, 0x08, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x44, 0x65, 0x70, 0x6c, 0x6f,
0x79, 0x52, 0x0e, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x34, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x33,
0x33, 0x12, 0x2c, 0x0a, 0x11, 0x65, 0x74, 0x68, 0x4d, 0x61, 0x74, 0x75, 0x72, 0x69, 0x74, 0x79,
0x44, 0x65, 0x67, 0x72, 0x65, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x11, 0x65, 0x74,
0x68, 0x4d, 0x61, 0x74, 0x75, 0x72, 0x69, 0x74, 0x79, 0x44, 0x65, 0x67, 0x72, 0x65, 0x65, 0x12,
0x30, 0x0a, 0x13, 0x65, 0x74, 0x68, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x65, 0x74, 0x63, 0x68,
0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x13, 0x65, 0x74,
0x68, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x46, 0x65, 0x74, 0x63, 0x68, 0x50, 0x65, 0x72, 0x69, 0x6f,
0x64, 0x12, 0x26, 0x0a, 0x0e, 0x65, 0x74, 0x68, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72,
0x43, 0x6c, 0x69, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x65, 0x74, 0x68, 0x50, 0x72,
0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x43, 0x6c, 0x69, 0x12, 0x38, 0x0a, 0x17, 0x62, 0x72, 0x69,
0x64, 0x67, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x4f, 0x6e, 0x43, 0x68, 0x61,
0x69, 0x6e, 0x33, 0x33, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x17, 0x62, 0x72, 0x69, 0x64,
0x67, 0x65, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x72, 0x79, 0x4f, 0x6e, 0x43, 0x68, 0x61, 0x69,
0x6e, 0x33, 0x33, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4e, 0x61, 0x6d, 0x65,
0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x4e, 0x61, 0x6d,
0x65, 0x12, 0x28, 0x0a, 0x0f, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x44, 0x34, 0x43, 0x68, 0x61,
0x69, 0x6e, 0x33, 0x33, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0f, 0x63, 0x68, 0x61, 0x69,
0x6e, 0x49, 0x44, 0x34, 0x43, 0x68, 0x61, 0x69, 0x6e, 0x33, 0x33, 0x12, 0x28, 0x0a, 0x0f, 0x70,
0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x57, 0x69, 0x74, 0x68, 0x44, 0x72, 0x61, 0x77, 0x18, 0x0f,
0x20, 0x01, 0x28, 0x08, 0x52, 0x0f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x57, 0x69, 0x74,
0x68, 0x44, 0x72, 0x61, 0x77, 0x22, 0xa7, 0x02, 0x0a, 0x13, 0x53, 0x79, 0x6e, 0x63, 0x54, 0x78,
0x52, 0x65, 0x63, 0x65, 0x69, 0x70, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x12, 0x20, 0x0a,
0x0b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x33, 0x33, 0x68, 0x6f, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0b, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x33, 0x33, 0x68, 0x6f, 0x73, 0x74, 0x12,
0x1a, 0x0a, 0x08, 0x70, 0x75, 0x73, 0x68, 0x48, 0x6f, 0x73, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x08, 0x70, 0x75, 0x73, 0x68, 0x48, 0x6f, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x70,
0x75, 0x73, 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70,
0x75, 0x73, 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x75, 0x73, 0x68, 0x42,
0x69, 0x6e, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x75, 0x73, 0x68, 0x42,
0x69, 0x6e, 0x64, 0x12, 0x28, 0x0a, 0x0f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x53, 0x79, 0x6e, 0x63,
0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0f, 0x73, 0x74,
0x61, 0x72, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x2c, 0x0a,
0x11, 0x73, 0x74, 0x61, 0x72, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e,
0x63, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x11, 0x73, 0x74, 0x61, 0x72, 0x74, 0x53,
0x79, 0x6e, 0x63, 0x53, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x24, 0x0a, 0x0d, 0x73,
0x74, 0x61, 0x72, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x48, 0x61, 0x73, 0x68, 0x18, 0x07, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0d, 0x73, 0x74, 0x61, 0x72, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x48, 0x61, 0x73,
0x68, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x73, 0x18, 0x08,
0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x61, 0x63, 0x74, 0x73, 0x22,
0xa4, 0x01, 0x0a, 0x06, 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x12, 0x22, 0x0a, 0x0c, 0x6f, 0x70,
0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x0c, 0x6f, 0x70, 0x65, 0x72, 0x61, 0x74, 0x6f, 0x72, 0x41, 0x64, 0x64, 0x72, 0x12, 0x2e,
0x0a, 0x12, 0x64, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x65, 0x72, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74,
0x65, 0x4b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x64, 0x65, 0x70, 0x6c,
0x6f, 0x79, 0x65, 0x72, 0x50, 0x72, 0x69, 0x76, 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x12, 0x26,
0x0a, 0x0e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x41, 0x64, 0x64, 0x72,
0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f,
0x72, 0x73, 0x41, 0x64, 0x64, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x69, 0x6e, 0x69, 0x74, 0x50, 0x6f,
0x77, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0a, 0x69, 0x6e, 0x69, 0x74,
0x50, 0x6f, 0x77, 0x65, 0x72, 0x73, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2e, 0x2f, 0x74, 0x79, 0x70,
0x65, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_config_proto_rawDescOnce sync.Once
file_config_proto_rawDescData = file_config_proto_rawDesc
)
func file_config_proto_rawDescGZIP() []byte {
file_config_proto_rawDescOnce.Do(func() {
file_config_proto_rawDescData = protoimpl.X.CompressGZIP(file_config_proto_rawDescData)
})
return file_config_proto_rawDescData
}
var file_config_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_config_proto_goTypes = []interface{}{
(*SyncTxConfig)(nil), // 0: types.SyncTxConfig
(*Log)(nil), // 1: types.Log
(*RelayerConfig)(nil), // 2: types.RelayerConfig
(*SyncTxReceiptConfig)(nil), // 3: types.SyncTxReceiptConfig
(*Deploy)(nil), // 4: types.Deploy
}
var file_config_proto_depIdxs = []int32{
0, // 0: types.RelayerConfig.syncTxConfig:type_name -> types.SyncTxConfig
1, // 1: types.RelayerConfig.log:type_name -> types.Log
4, // 2: types.RelayerConfig.deploy:type_name -> types.Deploy
4, // 3: types.RelayerConfig.deploy4chain33:type_name -> types.Deploy
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
}
func init() { file_config_proto_init() }
func file_config_proto_init() {
if File_config_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_config_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SyncTxConfig); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_config_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Log); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_config_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RelayerConfig); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_config_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*SyncTxReceiptConfig); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_config_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Deploy); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_config_proto_rawDesc,
NumEnums: 0,
NumMessages: 5,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_config_proto_goTypes,
DependencyIndexes: file_config_proto_depIdxs,
MessageInfos: file_config_proto_msgTypes,
}.Build()
File_config_proto = out.File
file_config_proto_rawDesc = nil
file_config_proto_goTypes = nil
file_config_proto_depIdxs = nil
}
This source diff could not be displayed because it is too large. You can view the blob instead.
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