Commit 28715397 authored by hezhengjun's avatar hezhengjun Committed by vipwzw

update ethereum to 1.10

parent bba7112c
......@@ -17,13 +17,13 @@ require (
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/davecgh/go-spew v1.1.1
github.com/ethereum/go-ethereum v1.9.9
github.com/ethereum/go-ethereum v1.10.0
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/protobuf v1.4.3
github.com/hashicorp/golang-lru v0.5.4
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d
github.com/holiman/uint256 v1.1.1
github.com/huin/goupnp v1.0.0
github.com/huin/goupnp v1.0.1-0.20200620063722-49508fba0031
github.com/jackpal/go-nat-pmp v1.0.2
github.com/miguelmota/go-solidity-sha3 v0.1.0
github.com/mr-tron/base58 v1.2.0
......@@ -31,12 +31,11 @@ require (
github.com/perlin-network/life v0.0.0-20191203030451-05c0e0f7eaea
github.com/phoreproject/bls v0.0.0-20200525203911-a88a5ae26844
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v0.9.2 // indirect
github.com/prometheus/common v0.4.1
github.com/prometheus/common v0.6.0
github.com/prometheus/procfs v0.0.3 // indirect
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d
github.com/rs/cors v1.6.0
github.com/spf13/cobra v0.0.5
github.com/rs/cors v1.7.0
github.com/spf13/cobra v1.1.1
github.com/stretchr/testify v1.7.0
github.com/tjfoc/gmsm v1.3.2
github.com/valyala/fasthttp v1.5.0
......@@ -46,5 +45,6 @@ require (
golang.org/x/sys v0.0.0-20210426080607-c94f62235c83
golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0 // indirect
google.golang.org/grpc v1.33.2
gopkg.in/sourcemap.v1 v1.0.5 // indirect
gopkg.in/yaml.v2 v2.3.0
)
This diff is collapsed.
......@@ -34,5 +34,4 @@ import (
_ "github.com/33cn/plugin/plugin/dapp/valnode" //auto gen
_ "github.com/33cn/plugin/plugin/dapp/vote" //auto gen
_ "github.com/33cn/plugin/plugin/dapp/wasm" //auto gen
_ "github.com/33cn/plugin/plugin/dapp/x2ethereum" //auto gen
)
......@@ -5,25 +5,26 @@ strpwd=$(pwd)
strcmd=${strpwd##*dapp/}
strapp=${strcmd%/cmd*}
SRC_EBCLI=github.com/33cn/plugin/plugin/dapp/x2ethereum/ebcli
SRC_EBRELAYER=github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer
OUT_DIR="${1}/$strapp"
FLAG=$2
# shellcheck disable=SC2086,1072
go build ${FLAG} -v -o "${OUT_DIR}/ebrelayer" "${SRC_EBRELAYER}"
# shellcheck disable=SC2086,1072
go build ${FLAG} -v -o "${OUT_DIR}/ebcli_A" "${SRC_EBCLI}"
# shellcheck disable=SC2086,1072
go build ${FLAG} -v -o "${OUT_DIR}/ebcli_B" -ldflags "-X ${SRC_EBCLI}/buildflags.RPCAddr=http://localhost:9902" "${SRC_EBCLI}"
# shellcheck disable=SC2086,1072
go build ${FLAG} -v -o "${OUT_DIR}/ebcli_C" -ldflags "-X ${SRC_EBCLI}/buildflags.RPCAddr=http://localhost:9903" "${SRC_EBCLI}"
# shellcheck disable=SC2086,1072
go build ${FLAG} -v -o "${OUT_DIR}/ebcli_D" -ldflags "-X ${SRC_EBCLI}/buildflags.RPCAddr=http://localhost:9904" "${SRC_EBCLI}"
cp ../ebrelayer/relayer.toml "${OUT_DIR}/relayer.toml"
cp ./build/* "${OUT_DIR}"
#SRC_EBCLI=github.com/33cn/plugin/plugin/dapp/x2ethereum/ebcli
#SRC_EBRELAYER=github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer
#OUT_DIR="${1}/$strapp"
#FLAG=$2
#
## shellcheck disable=SC2086,1072
#go build -i ${FLAG} -v -o "${OUT_DIR}/ebrelayer" "${SRC_EBRELAYER}"
## shellcheck disable=SC2086,1072
#go build -i ${FLAG} -v -o "${OUT_DIR}/ebcli_A" "${SRC_EBCLI}"
## shellcheck disable=SC2086,1072
#go build -i ${FLAG} -v -o "${OUT_DIR}/ebcli_B" -ldflags "-X ${SRC_EBCLI}/buildflags.RPCAddr=http://localhost:9902" "${SRC_EBCLI}"
## shellcheck disable=SC2086,1072
#go build -i ${FLAG} -v -o "${OUT_DIR}/ebcli_C" -ldflags "-X ${SRC_EBCLI}/buildflags.RPCAddr=http://localhost:9903" "${SRC_EBCLI}"
## shellcheck disable=SC2086,1072
#go build -i ${FLAG} -v -o "${OUT_DIR}/ebcli_D" -ldflags "-X ${SRC_EBCLI}/buildflags.RPCAddr=http://localhost:9904" "${SRC_EBCLI}"
#
#cp ../ebrelayer/relayer.toml "${OUT_DIR}/relayer.toml"
#cp ./build/* "${OUT_DIR}"
OUT_TESTDIR="${1}/dapptest/$strapp"
mkdir -p "${OUT_TESTDIR}"
cp ./test/* "${OUT_TESTDIR}"
This diff is collapsed.
......@@ -29,7 +29,8 @@ func EthereumRelayerCmd() *cobra.Command {
ShowEthereumTxsHashCmd(),
IsValidatorActiveCmd(),
ShowOperatorCmd(),
DeployContrctsCmd(),
DeployContrcts2Chain33Cmd(),
DeployContrcts2EthCmd(),
ShowTxReceiptCmd(),
//////auxiliary///////
CreateBridgeTokenCmd(),
......@@ -209,11 +210,20 @@ func ShowOperator(cmd *cobra.Command, args []string) {
ctx.Run()
}
func DeployContrcts2Chain33Cmd() *cobra.Command {
cmd := &cobra.Command{
Use: "deploy2chain33",
Short: "deploy contracts to chain33",
Run: DeployContrcts2Chain33,
}
return cmd
}
//DeployContrctsCmd ...
func DeployContrctsCmd() *cobra.Command {
func DeployContrcts2EthCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "deploy",
Short: "deploy the corresponding Ethereum contracts",
Use: "deploy2eth",
Short: "deploy contracts to ethereum",
Run: DeployContrcts,
}
return cmd
......@@ -227,6 +237,13 @@ func DeployContrcts(cmd *cobra.Command, args []string) {
ctx.Run()
}
func DeployContrcts2Chain33(cmd *cobra.Command, args []string) {
rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
var res rpctypes.Reply
ctx := jsonclient.NewRPCCtx(rpcLaddr, "Manager.Deploy2Chain33", nil, &res)
ctx.Run()
}
//ShowTxReceiptCmd ...
func ShowTxReceiptCmd() *cobra.Command {
cmd := &cobra.Command{
......
This source diff could not be displayed because it is too large. You can view the blob instead.
package test
import (
"encoding/hex"
"fmt"
"math/big"
"strings"
"testing"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
)
func TestUnpackEvent(t *testing.T) {
const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"}]`
abi, err := abi.JSON(strings.NewReader(abiJSON))
if err != nil {
t.Fatal(err)
}
const hexdata = `000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158`
data, err := hex.DecodeString(hexdata)
if err != nil {
t.Fatal(err)
}
if len(data)%32 == 0 {
t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
}
type ReceivedEvent struct {
Sender common.Address
Amount *big.Int
Memo []byte
}
var ev ReceivedEvent
err = abi.Unpack(&ev, "received", data)
if err != nil {
t.Error(err)
}
fmt.Printf("\nReceivedEvent sender:%s", ev.Sender.String())
type ReceivedAddrEvent struct {
Sender common.Address
}
var receivedAddrEv ReceivedAddrEvent
err = abi.Unpack(&receivedAddrEv, "receivedAddr", data)
if err != nil {
t.Error(err)
}
fmt.Printf("\nreceivedAddrEv=%s\n\n\n", receivedAddrEv.Sender.String())
}
//
//import (
// "encoding/hex"
// "fmt"
// "math/big"
// "strings"
// "testing"
//
// "github.com/ethereum/go-ethereum/accounts/abi"
// "github.com/ethereum/go-ethereum/common"
//)
//
//func TestUnpackEvent(t *testing.T) {
// const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"}]`
// abiData, err := abi.JSON(strings.NewReader(abiJSON))
// if err != nil {
// t.Fatal(err)
// }
//
// const hexdata = `000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158`
// data, err := hex.DecodeString(hexdata)
// if err != nil {
// t.Fatal(err)
// }
// if len(data)%32 == 0 {
// t.Errorf("len(data) is %d, want a non-multiple of 32", len(data))
// }
//
// type ReceivedEvent struct {
// Sender common.Address
// Amount *big.Int
// Memo []byte
// }
// var ev ReceivedEvent
//
// ret, err := abiData.Unpack("received", data)
// if err != nil {
// t.Error(err)
// }
// fmt.Println(ret)
//
// fmt.Printf("\nReceivedEvent sender:%s", ev.Sender.String())
//
// type ReceivedAddrEvent struct {
// Sender common.Address
// }
// var receivedAddrEv ReceivedAddrEvent
// ret2, err := abiData.Unpack("receivedAddr", data)
// if err != nil {
// t.Error(err)
// }
// fmt.Println(ret2)
// fmt.Printf("\nreceivedAddrEv=%s\n\n\n", receivedAddrEv.Sender.String())
//}
......@@ -34,7 +34,7 @@ func CreateBridgeToken(symbol string, client ethinterface.EthClientSpec, para *O
//订阅事件
eventName := "LogNewBridgeToken"
bridgeBankABI := LoadABI(BridgeBankABI)
logNewBridgeTokenSig := bridgeBankABI.Events[eventName].ID().Hex()
logNewBridgeTokenSig := bridgeBankABI.Events[eventName].ID.Hex()
query := ethereum.FilterQuery{
Addresses: []common.Address{x2EthDeployInfo.BridgeBank.Address},
}
......@@ -90,7 +90,7 @@ func CreateBridgeToken(symbol string, client ethinterface.EthClientSpec, para *O
if vLog.Topics[0].Hex() == logNewBridgeTokenSig {
txslog.Debug("CreateBrigeToken", "Witnessed new event", eventName, "Block number", vLog.BlockNumber)
err = bridgeBankABI.Unpack(logEvent, eventName, vLog.Data)
err = bridgeBankABI.UnpackIntoInterface(logEvent, eventName, vLog.Data)
if nil != err {
return "", err
}
......
......@@ -8,6 +8,7 @@ import (
"sync"
"time"
"github.com/33cn/plugin/plugin/dapp/cross2eth/ebrelayer/utils"
"github.com/33cn/plugin/plugin/dapp/x2ethereum/ebrelayer/ethinterface"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
......@@ -15,7 +16,6 @@ import (
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/crypto/secp256k1"
solsha3 "github.com/miguelmota/go-solidity-sha3"
)
//EthTxStatus ...
......@@ -47,7 +47,7 @@ func SignClaim4Eth(hash common.Hash, privateKey *ecdsa.PrivateKey) ([]byte, erro
}
func prefixMessage(message common.Hash, key *ecdsa.PrivateKey) ([]byte, []byte) {
prefixed := solsha3.SoliditySHA3WithPrefix(message[:])
prefixed := utils.SoliditySHA3WithPrefix(message[:])
sig, err := secp256k1.Sign(prefixed, math.PaddedBigBytes(key.D, 32))
if err != nil {
panic(err)
......
......@@ -55,7 +55,7 @@ type LogNewBridgeToken struct {
func UnpackLogLock(contractAbi abi.ABI, eventName string, eventData []byte) (lockEvent *LockEvent, err error) {
event := &LockEvent{}
// Parse the event's attributes as Ethereum network variables
err = contractAbi.Unpack(event, eventName, eventData)
err = contractAbi.UnpackIntoInterface(event, eventName, eventData)
if err != nil {
eventsLog.Error("UnpackLogLock", "Failed to unpack abi due to:", err.Error())
return nil, ebrelayerTypes.ErrUnpack
......@@ -72,7 +72,7 @@ func UnpackLogLock(contractAbi abi.ABI, eventName string, eventData []byte) (loc
func UnpackLogBurn(contractAbi abi.ABI, eventName string, eventData []byte) (burnEvent *BurnEvent, err error) {
event := &BurnEvent{}
// Parse the event's attributes as Ethereum network variables
err = contractAbi.Unpack(event, eventName, eventData)
err = contractAbi.UnpackIntoInterface(event, eventName, eventData)
if err != nil {
eventsLog.Error("UnpackLogBurn", "Failed to unpack abi due to:", err.Error())
return nil, ebrelayerTypes.ErrUnpack
......
......@@ -607,9 +607,9 @@ func (ethRelayer *Relayer4Ethereum) prePareSubscribeEvent() {
contactAbi := ethtxs.LoadABI(ethtxs.BridgeBankABI)
ethRelayer.bridgeBankAbi = contactAbi
eventName = events.LogLock.String()
ethRelayer.bridgeBankEventLockSig = contactAbi.Events[eventName].ID().Hex()
ethRelayer.bridgeBankEventLockSig = contactAbi.Events[eventName].ID.Hex()
eventName = events.LogChain33TokenBurn.String()
ethRelayer.bridgeBankEventBurnSig = contactAbi.Events[eventName].ID().Hex()
ethRelayer.bridgeBankEventBurnSig = contactAbi.Events[eventName].ID.Hex()
ethRelayer.bridgeBankAddr = ethRelayer.x2EthDeployInfo.BridgeBank.Address
}
......
......@@ -159,12 +159,11 @@ func (a *action) procChain33ToEth_lock(msgLock *x2eTy.Chain33ToEth) (*types.Rece
var accDB *account.DB
exec, symbol, _ := x2eTy.DivideDot(msgLock.IssuerDotSymbol)
cfg := a.api.GetConfig()
if exec == cfg.GetCoinExec() {
accDB = account.NewCoinsAccount(cfg)
if exec == "coins" {
accDB = account.NewCoinsAccount(a.api.GetConfig())
accDB.SetDB(a.db)
} else {
accDB, err = account.NewAccountDB(cfg, exec, strings.ToLower(symbol), a.db)
accDB, err = account.NewAccountDB(a.api.GetConfig(), exec, strings.ToLower(symbol), a.db)
if err != nil {
return nil, errors.Wrap(err, "newAccountDB")
}
......@@ -234,12 +233,11 @@ func (a *action) procEth2Chain33_burn(withdrawEth *x2eTy.Eth2Chain33) (*types.Re
var accDB *account.DB
exec, symbol, _ := x2eTy.DivideDot(withdrawEth.IssuerDotSymbol)
cfg := a.api.GetConfig()
if exec == cfg.GetCoinExec() {
accDB = account.NewCoinsAccount(cfg)
if exec == "coins" {
accDB = account.NewCoinsAccount(a.api.GetConfig())
accDB.SetDB(a.db)
} else {
accDB, err = account.NewAccountDB(cfg, exec, strings.ToLower(symbol), a.db)
accDB, err = account.NewAccountDB(a.api.GetConfig(), exec, strings.ToLower(symbol), a.db)
if err != nil {
return nil, errors.Wrap(err, "newAccountDB")
}
......
......@@ -6,11 +6,10 @@ package types
import (
context "context"
fmt "fmt"
math "math"
types "github.com/33cn/chain33/types"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
math "math"
)
// Reference imports to suppress errors if they are not otherwise used.
......
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