diff --git a/Dockerfile b/Dockerfile index 7f137779cb..2dc1bc5a2b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,6 +65,10 @@ go get -u github.com/golang/mock/mockgen; \ go get -u github.com/stamblerre/gocode; \ go get -u golang.org/x/tools/... + +RUN eval "$(~/bin/gimme ${GIMME_GO_VERSION})" ; . ~/.bash_profile; \ +go get -u honnef.co/go/tools/cmd/staticcheck/... + WORKDIR ${HMY_PATH}/harmony RUN eval "$(~/bin/gimme ${GIMME_GO_VERSION})" ; scripts/install_build_tools.sh diff --git a/cmd/harmony/main.go b/cmd/harmony/main.go index 1f50bdc27c..2438b4d41a 100644 --- a/cmd/harmony/main.go +++ b/cmd/harmony/main.go @@ -18,8 +18,6 @@ import ( "syscall" "time" - "github.com/harmony-one/harmony/numeric" - ethCommon "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/harmony-one/bls/ffi/go/bls" @@ -38,12 +36,12 @@ import ( "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/multibls" "github.com/harmony-one/harmony/node" + "github.com/harmony-one/harmony/numeric" "github.com/harmony-one/harmony/p2p" "github.com/harmony-one/harmony/p2p/p2pimpl" p2putils "github.com/harmony-one/harmony/p2p/utils" "github.com/harmony-one/harmony/shard" "github.com/harmony-one/harmony/webhooks" - golog "github.com/ipfs/go-log" "github.com/pkg/errors" gologging "github.com/whyrusleeping/go-logging" ) @@ -811,18 +809,22 @@ func main() { Str("BeaconGroupID", nodeConfig.GetBeaconGroupID().String()). Str("ClientGroupID", nodeConfig.GetClientGroupID().String()). Str("Role", currentNode.NodeConfig.Role().String()). - Str("multiaddress", fmt.Sprintf("/ip4/%s/tcp/%s/p2p/%s", *ip, *port, myHost.GetID().Pretty())). + Str("multiaddress", + fmt.Sprintf("/ip4/%s/tcp/%s/p2p/%s", *ip, *port, myHost.GetID().Pretty()), + ). Msg(startMsg) if *logP2P { - f, err := os.OpenFile(path.Join(*logFolder, "libp2p.log"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + f, err := os.OpenFile( + path.Join(*logFolder, "libp2p.log"), + os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644, + ) if err != nil { fmt.Fprintf(os.Stderr, "Failed to open libp2p.log. %v\n", err) } else { defer f.Close() backend1 := gologging.NewLogBackend(f, "", 0) gologging.SetBackend(backend1) - golog.SetAllLoggers(gologging.DEBUG) // Change to DEBUG for extra info } } diff --git a/go.mod b/go.mod index d9627b3e05..766ad651cd 100644 --- a/go.mod +++ b/go.mod @@ -11,6 +11,7 @@ require ( github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d github.com/cespare/cp v1.1.1 github.com/davecgh/go-spew v1.1.1 + github.com/davidlazar/go-crypto v0.0.0-20190912175916-7055855a373f // indirect github.com/deckarep/golang-set v1.7.1 github.com/edsrzf/mmap-go v1.0.0 // indirect github.com/ethereum/go-ethereum v1.8.27 @@ -22,6 +23,7 @@ require ( github.com/golangci/golangci-lint v1.22.2 github.com/gorilla/handlers v1.4.0 github.com/gorilla/mux v1.7.2 + github.com/gorilla/websocket v1.4.2 // indirect github.com/harmony-ek/gencodec v0.0.0-20190215044613-e6740dbdd846 github.com/harmony-one/bls v0.0.6 github.com/harmony-one/taggedrlp v0.1.4 @@ -29,21 +31,24 @@ require ( github.com/hashicorp/golang-lru v0.5.4 github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365 github.com/ipfs/go-ds-badger v0.2.1 - github.com/ipfs/go-log v0.0.1 + github.com/jackpal/gateway v1.0.6 // indirect + github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect github.com/karalabe/hid v1.0.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/libp2p/go-libp2p v0.5.2 - github.com/libp2p/go-libp2p-core v0.3.0 + github.com/libp2p/go-libp2p v0.7.3 + github.com/libp2p/go-libp2p-core v0.5.0 github.com/libp2p/go-libp2p-crypto v0.1.0 github.com/libp2p/go-libp2p-discovery v0.2.0 github.com/libp2p/go-libp2p-host v0.1.0 github.com/libp2p/go-libp2p-kad-dht v0.5.0 github.com/libp2p/go-libp2p-net v0.1.0 github.com/libp2p/go-libp2p-peer v0.2.0 - github.com/libp2p/go-libp2p-peerstore v0.1.4 - github.com/libp2p/go-libp2p-pubsub v0.2.6 - github.com/multiformats/go-multiaddr v0.2.0 - github.com/multiformats/go-multiaddr-net v0.1.2 + github.com/libp2p/go-libp2p-peerstore v0.2.2 + github.com/libp2p/go-libp2p-pubsub v0.2.7-0.20200325112436-d3d43e32bef3 + github.com/libp2p/go-nat v0.0.5 // indirect + github.com/libp2p/go-reuseport-transport v0.0.3 // indirect + github.com/multiformats/go-multiaddr v0.2.1 + github.com/multiformats/go-multiaddr-net v0.1.4 github.com/natefinch/lumberjack v2.0.0+incompatible github.com/pborman/uuid v1.2.0 github.com/pkg/errors v0.9.1 @@ -61,11 +66,13 @@ require ( github.com/uber/jaeger-client-go v2.20.1+incompatible // indirect github.com/uber/jaeger-lib v2.2.0+incompatible // indirect github.com/whyrusleeping/go-logging v0.0.1 - go.uber.org/atomic v1.5.1 // indirect - golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 - golang.org/x/lint v0.0.0-20190930215403-16217165b5de - golang.org/x/sync v0.0.0-20190423024810-112230192c58 - golang.org/x/tools v0.0.0-20191113232020-e2727e816f5a + go.uber.org/zap v1.14.1 // indirect + golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59 + golang.org/x/lint v0.0.0-20200302205851-738671d3881b + golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect + golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e + golang.org/x/sys v0.0.0-20200331124033-c3d80250170d // indirect + golang.org/x/tools v0.0.0-20200402223321-bcf690261a44 google.golang.org/grpc v1.22.0 gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 gopkg.in/ini.v1 v1.51.0 diff --git a/p2p/host/hostv2/hostv2.go b/p2p/host/hostv2/hostv2.go index 3b59a85c40..af9945839b 100644 --- a/p2p/host/hostv2/hostv2.go +++ b/p2p/host/hostv2/hostv2.go @@ -8,13 +8,9 @@ import ( "os" "sync" - "github.com/pkg/errors" - "github.com/rs/zerolog" - nodeconfig "github.com/harmony-one/harmony/internal/configs/node" "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/p2p" - libp2p "github.com/libp2p/go-libp2p" libp2p_crypto "github.com/libp2p/go-libp2p-crypto" libp2p_host "github.com/libp2p/go-libp2p-host" @@ -22,6 +18,8 @@ import ( libp2p_peerstore "github.com/libp2p/go-libp2p-peerstore" libp2p_pubsub "github.com/libp2p/go-libp2p-pubsub" ma "github.com/multiformats/go-multiaddr" + "github.com/pkg/errors" + "github.com/rs/zerolog" ) const ( @@ -147,6 +145,9 @@ func (r *GroupReceiverImpl) Receive(ctx context.Context) ( msg = m.Data sender = libp2p_peer.ID(m.From) } + + utils.Logger().Info().Int("size", len(msg)).Msg("receive p2p message") + return msg, sender, err } @@ -227,7 +228,15 @@ func New(self *p2p.Peer, priKey libp2p_crypto.PrivKey) (*HostV2, error) { return nil, errors.Wrapf(err, "cannot initialize libp2p host") } traceFile := os.Getenv("P2P_TRACEFILE") - options := []libp2p_pubsub.Option{libp2p_pubsub.WithPeerOutboundQueueSize(64)} + + // TODO first starting with some huge number to see update of libp2p + // and also to dump some values about the p2p message sizes + // 3MB + const MaxSize = 3_145_728 + options := []libp2p_pubsub.Option{ + libp2p_pubsub.WithPeerOutboundQueueSize(64), + libp2p_pubsub.WithMaxMessageSize(MaxSize), + } if len(traceFile) > 0 { tracer, _ := libp2p_pubsub.NewJSONTracer(traceFile) options = append(options, libp2p_pubsub.WithEventTracer(tracer)) diff --git a/test/cal_tps.sh b/test/cal_tps.sh deleted file mode 100755 index b206348671..0000000000 --- a/test/cal_tps.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash - -function usage -{ - ME=$(basename $0) - cat< ") - data, _ := stdReader.ReadString('\n') - ps.Publish("pubsubtestchannel", []byte(data)) - } -} - -// Harmony MIT License -func readPubsub(sub *pubsub.Subscription) { - ctx := context.Background() - for { - m, err := sub.Next(ctx) - - if err == nil { - msg := m.Data - sender := peer.ID(m.From) - fmt.Printf("Received pubsub: '%v' from: %v\n", string(msg), sender) - } - } -} - -func main() { - log.SetAllLoggers(logging.WARNING) - log.SetLogLevel("rendezvous", "info") - help := flag.Bool("h", false, "Display Help") - config, err := ParseFlags() - if err != nil { - panic(err) - } - - if *help { - fmt.Println("This program demonstrates a simple p2p chat application using libp2p") - fmt.Println() - fmt.Println("Usage: Run './p2pchat in two different terminals. Let them connect to the bootstrap nodes, announce themselves and connect to the peers") - flag.PrintDefaults() - return - } - - ctx := context.Background() - - // libp2p.New constructs a new libp2p Host. Other options can be added - // here. - host, err := libp2p.New(ctx, - libp2p.ListenAddrs([]multiaddr.Multiaddr(config.ListenAddresses)...), - ) - if err != nil { - panic(err) - } - logger.Info("Host created. We are:", host.ID()) - logger.Info(host.Addrs()) - - // Start a DHT, for use in peer discovery. We can't just make a new DHT - // client because we want each peer to maintain its own local copy of the - // DHT, so that the bootstrapping node of the DHT can go down without - // inhibiting future peer discovery. - kademliaDHT, err := libp2pdht.New(ctx, host) - if err != nil { - panic(err) - } - - // Bootstrap the DHT. In the default configuration, this spawns a Background - // thread that will refresh the peer table every five minutes. - logger.Debug("Bootstrapping the DHT") - if err = kademliaDHT.Bootstrap(ctx); err != nil { - panic(err) - } - - // Let's connect to the bootstrap nodes first. They will tell us about the - // other nodes in the network. - var wg sync.WaitGroup - for _, peerAddr := range config.BootstrapPeers { - peerinfo, _ := peerstore.InfoFromP2pAddr(peerAddr) - wg.Add(1) - go func() { - defer wg.Done() - if err := host.Connect(ctx, *peerinfo); err != nil { - logger.Warning(err) - } else { - logger.Info("Connection established with bootstrap node:", *peerinfo) - } - }() - } - wg.Wait() - - // We use a rendezvous point "meet me here" to announce our location. - // This is like telling your friends to meet you at the Eiffel Tower. - logger.Info("Announcing ourselves...") - routingDiscovery := discovery.NewRoutingDiscovery(kademliaDHT) - discovery.Advertise(ctx, routingDiscovery, config.RendezvousString) - logger.Debug("Successfully announced!") - - // Now, look for others who have announced - // This is like your friend telling you the location to meet you. - logger.Debug("Searching for other peers...") - peerChan, err := routingDiscovery.FindPeers(ctx, config.RendezvousString) - if err != nil { - panic(err) - } - - var ps *pubsub.PubSub - - switch config.PubSubImpl { - case "gossip": - ps, err = pubsub.NewGossipSub(ctx, host) - case "flood": - ps, err = pubsub.NewFloodSub(ctx, host) - default: - logger.Error("Unsupported Pubsub implementation") - return - } - - if err != nil { - fmt.Printf("pub error: %v", err) - panic(err) - } - - sub, err := ps.Subscribe("pubsubtestchannel") - - if err != nil { - fmt.Printf("sub error: %v", err) - panic(err) - } - - go writePubsub(ps) - go readPubsub(sub) - - for peer := range peerChan { - if peer.ID == host.ID() { - continue - } - logger.Debug("Found peer:", peer) - - if err := host.Connect(ctx, peer); err != nil { - logger.Warning("can't connect to peer", "error", err, "peer", peer) - } else { - logger.Info("connected to peer host", "node", peer) - } - } - - select {} -} diff --git a/test/p2pchat/flags.go b/test/p2pchat/flags.go deleted file mode 100644 index 18dcae9290..0000000000 --- a/test/p2pchat/flags.go +++ /dev/null @@ -1,76 +0,0 @@ -package main - -import ( - "flag" - "strings" - - maddr "github.com/multiformats/go-multiaddr" -) - -// A new type we need for writing a custom flag parser -type addrList []maddr.Multiaddr - -func (al *addrList) String() string { - strs := make([]string, len(*al)) - for i, addr := range *al { - strs[i] = addr.String() - } - return strings.Join(strs, ",") -} - -func (al *addrList) Set(value string) error { - addr, err := maddr.NewMultiaddr(value) - if err != nil { - return err - } - *al = append(*al, addr) - return nil -} - -// Harmony test bootstrap nodes. Used to find other peers in the network. -var defaultBootstrapAddrStrings = []string{ - "/ip4/127.0.0.1/tcp/9876/p2p/QmayB8NwxmfGE4Usb4H61M8uwbfc7LRbmXb3ChseJgbVuf", -} - -// StringsToAddrs ... -func StringsToAddrs(addrStrings []string) (maddrs []maddr.Multiaddr, err error) { - for _, addrString := range addrStrings { - addr, err := maddr.NewMultiaddr(addrString) - if err != nil { - return maddrs, err - } - maddrs = append(maddrs, addr) - } - return -} - -// Config ... -type Config struct { - RendezvousString string - BootstrapPeers addrList - ListenAddresses addrList - ProtocolID string - PubSubImpl string -} - -// ParseFlags ... -func ParseFlags() (Config, error) { - config := Config{} - flag.StringVar(&config.RendezvousString, "rendezvous", "meet me here", - "Unique string to identify group of nodes. Share this with your friends to let them connect with you") - flag.Var(&config.BootstrapPeers, "peer", "Adds a peer multiaddress to the bootstrap list") - flag.Var(&config.ListenAddresses, "listen", "Adds a multiaddress to the listen list") - flag.StringVar(&config.ProtocolID, "pid", "/chat/1.1.0", "Sets a protocol id for stream headers") - flag.StringVar(&config.PubSubImpl, "pubsub", "gossip", "Set the pubsub implementation: gossip, flood") - flag.Parse() - - if len(config.BootstrapPeers) == 0 { - bootstrapPeerAddrs, err := StringsToAddrs(defaultBootstrapAddrStrings) - if err != nil { - return config, err - } - config.BootstrapPeers = bootstrapPeerAddrs - } - - return config, nil -} diff --git a/test/send_txn.sh b/test/send_txn.sh deleted file mode 100755 index 5d84e13336..0000000000 --- a/test/send_txn.sh +++ /dev/null @@ -1,3 +0,0 @@ -# the hex is basically 0, 0034, 0, 0, 4, "9001 9002 9003 9004 9005 9006 9007 9008 9009 9010" -# explanation: p2p type, size(52 bytes), msg category, action type, StartConsensus, payload -echo -e '\x00\x00\x00\x00\x34\x00\x00\x04\x39\x30\x30\x31\x20\x39\x30\x30\x32\x20\x39\x30\x30\x33\x20\x39\x30\x30\x34\x20\x39\x30\x30\x35\x20\x39\x30\x30\x36\x20\x39\x30\x30\x37\x20\x39\x30\x30\x38\x20\x39\x30\x30\x39\x20\x39\x30\x31\x30' | nc 127.0.0.1 9000 diff --git a/test/test_sdk.sh b/test/test_sdk.sh deleted file mode 100755 index d26907b5a1..0000000000 --- a/test/test_sdk.sh +++ /dev/null @@ -1,7 +0,0 @@ -# to install gsed for MacOS: brew install gnu-sed -./test/kill_node.sh -rm -rf tmp_log* -gsed -i 's/GenesisShardNum = 4/GenesisShardNum = 1/' core/resharding.go -gsed -i 's/GenesisShardSize = 150/GenesisShardSize = 20/' core/resharding.go -gsed -i 's/GenesisShardHarmonyNodes = 112/GenesisShardHarmonyNodes = 20/' core/resharding.go -./test/deploy.sh -D -1 ./test/configs/beaconchain20.txt -network_type testnet diff --git a/test/txgen/main.go b/test/txgen/main.go deleted file mode 100644 index a8cf02f450..0000000000 --- a/test/txgen/main.go +++ /dev/null @@ -1,106 +0,0 @@ -package main - -import ( - "encoding/hex" - "flag" - "fmt" - "math/big" - - "github.com/ethereum/go-ethereum/crypto" - - "github.com/harmony-one/harmony/core/types" - "github.com/harmony-one/harmony/internal/common" -) - -// {Address: "0xd2Cb501B40D3a9a013A38267a4d2A4Cf6bD2CAa8", Private: "3c8642f7188e05acc4467d9e2aa7fd539e82aa90a5497257cf0ecbb98ed3b88f", Public: "0xd2Cb501B40D3a9a013A38267a4d2A4Cf6bD2CAa8"}, -// {Address: "0x10A02A0a6e95a676AE23e2db04BEa3D1B8b7ca2E", Private: "371cb68abe6a6101ac88603fc847e0c013a834253acee5315884d2c4e387ebca", Public: "0x10A02A0a6e95a676AE23e2db04BEa3D1B8b7ca2E"}, -// curl 'http://127.0.0.1:30000/balance?key=0xd2Cb501B40D3a9a013A38267a4d2A4Cf6bD2CAa8' - -var ( - fromPrivateKey = flag.String("private", "3c8642f7188e05acc4467d9e2aa7fd539e82aa90a5497257cf0ecbb98ed3b88f", "private key") - toAddress = flag.String("to_address", "0x10A02A0a6e95a676AE23e2db04BEa3D1B8b7ca2E", "address of to account.") - shardID = flag.Int64("shard_id", 0, "shard id") -) - -// DeployAccount is the accounts used for development. -type DeployAccount struct { - Address string - Private string - Public string -} - -// DemoAccounts is the accounts used for lottery demo. -var DemoAccounts = [...]DeployAccount{ - {Address: "0x1a3e7a44ee21101d7D64FBf29B0F6F1fc295F723", Private: "27978f895b11d9c737e1ab1623fde722c04b4f9ccb4ab776bf15932cc72d7c66", Public: "0x1a3e7a44ee21101d7D64FBf29B0F6F1fc295F723"}, - {Address: "0x10A02A0a6e95a676AE23e2db04BEa3D1B8b7ca2E", Private: "371cb68abe6a6101ac88603fc847e0c013a834253acee5315884d2c4e387ebca", Public: "0x10A02A0a6e95a676AE23e2db04BEa3D1B8b7ca2E"}, - {Address: "0x3e881F6C36A3A14a2D1816b0A5471d1caBB16F33", Private: "3f8af52063c6648be37d4b33559f784feb16d8e5ffaccf082b3657ea35b05977", Public: "0x3e881F6C36A3A14a2D1816b0A5471d1caBB16F33"}, - {Address: "0x9d72989b68777a1f3FfD6F1DB079f1928373eE52", Private: "df77927961152e6a080ac299e7af2135fc0fb02eb044d0d7bbb1e8c5ad523809", Public: "0x9d72989b68777a1f3FfD6F1DB079f1928373eE52"}, - {Address: "0x67957240b6eB045E17B47dcE98102f09aaC03435", Private: "fcff43741ad2dd0b232efb159dc47736bbb16f11a79aaeec39b388d06f91116d", Public: "0x67957240b6eB045E17B47dcE98102f09aaC03435"}, - {Address: "0xf70fBDB1AD002baDF19024785b1a4bf6F841F558", Private: "916d3d78b7f413452434e89f9c1f1d136995ef02d7dc8038e84cc9cef4a02b96", Public: "0xf70fBDB1AD002baDF19024785b1a4bf6F841F558"}, - {Address: "0x3f1A559be93C9456Ca75712535Fd522f5EC22c6B", Private: "f5967bd87fd2b9dbf51855a2a75ef0a811c84953b3b300ffe90c430a5c856303", Public: "0x3f1A559be93C9456Ca75712535Fd522f5EC22c6B"}, - {Address: "0xedD257B4e0F5e7d632c737f4277e93b64DC268FC", Private: "f02f7b3bb5aa03aa97f9e030020dd9ca306b209742fafe018104a3207a70a3c9", Public: "0xedD257B4e0F5e7d632c737f4277e93b64DC268FC"}, - {Address: "0x66A74477FC1dd0F4924ed943C1d2F1Dece3Ab138", Private: "0436864cc15772448f88dd40554592ff6c91a6c1a389d965ad26ee143db1234d", Public: "0x66A74477FC1dd0F4924ed943C1d2F1Dece3Ab138"}, - {Address: "0x04178CdbCe3a9Ff9Ea385777aFc4b78B3E745281", Private: "dea956e530073ab23d9cae704f5d068482b1977c3173c9efd697c48a7fd3ce83", Public: "0x04178CdbCe3a9Ff9Ea385777aFc4b78B3E745281"}, - {Address: "0x46C61d50874A7A06D29FF89a710AbBD0856265be", Private: "af539d4ace07a9f601a8d3a6ca6f914d5a9fabe09cfe7d62ebc2348fc95f03a4", Public: "0x46C61d50874A7A06D29FF89a710AbBD0856265be"}, - {Address: "0xfE9BABE6904C28E31971337738FBCBAF8c72873e", Private: "7d24797eeba0cdac9bf943f0d82c4b18eb206108d6e1b7f610471594c0c94306", Public: "0xfE9BABE6904C28E31971337738FBCBAF8c72873e"}, - {Address: "0x3f78622de8D8f87EAa0E8b28C2851e2450E91250", Private: "4fa2fecce1becfaf7e5fba5394caacb318333b04071462b5ca850ee5a406dcfe", Public: "0x3f78622de8D8f87EAa0E8b28C2851e2450E91250"}, - {Address: "0xd2Cb501B40D3a9a013A38267a4d2A4Cf6bD2CAa8", Private: "3c8642f7188e05acc4467d9e2aa7fd539e82aa90a5497257cf0ecbb98ed3b88f", Public: "0xd2Cb501B40D3a9a013A38267a4d2A4Cf6bD2CAa8"}, - {Address: "0x2676e6dd2d7618be14cb4c18a355c81bf7aac647", Private: "bf29f6a33b2c24a8b5182ef44cc35ce87534ef827c8dfbc1e6bb536aa52f8563", Public: "0x2676e6dd2d7618be14cb4c18a355c81bf7aac647"}, -} - -func generateTxnHarmony(PrivateKeyFrom string, ToAddress string, shardID uint32, amount int64) (*types.Transaction, *types.Transaction) { - privateKey, _ := crypto.HexToECDSA(PrivateKeyFrom) - nonce := uint64(0) - value := big.NewInt(1000000000000000000 * amount) - gasLimit := uint64(21000) - toAddress := common.ParseAddr(ToAddress) - var data []byte - - unsignedTx := types.NewTransaction(nonce, - toAddress, - shardID, - value, - gasLimit, nil, data) - signedTx, _ := types.SignTx( - unsignedTx, - types.HomesteadSigner{}, - privateKey, - ) - - // fmt.Println("signedTx.Hash().Hex(): ", signedTx.Hash().Hex()) - // ts := types.Transactions{signedTx} - // rawTxBytes := ts.GetRlp(0) - // fmt.Println(rawTxBytes) - // rawTxHex := hex.EncodeToString(rawTxBytes) - // fmt.Println("serialized: ", rawTxHex) - return unsignedTx, signedTx -} - -func serialized(tx *types.Transaction) string { - ts := types.Transactions{tx} - rawTxBytes := ts.GetRlp(0) - rawTxHex := hex.EncodeToString(rawTxBytes) - return rawTxHex -} - -func main() { - flag.Parse() - - generateTxnHarmony(*fromPrivateKey, *toAddress, uint32(*shardID), 1) - - for i := 0; i < len(DemoAccounts); i++ { - j := (i + 1) % len(DemoAccounts) - shardID := i % 4 - unsignedTx, signedTx := generateTxnHarmony(DemoAccounts[i].Private, DemoAccounts[j].Address, uint32(shardID), int64(shardID)) - fmt.Printf( - "{ \"fromPrivate\": \"%s\", \"toAddress\": \"%s\", \"shardID\": %d, \"amount\": %d, \"nonce\": 0, \"gasLimit\": 21000, \"unsignedTx\": \"%s\", \"signedTx\": \"%s\" },\n", - DemoAccounts[i].Private, - DemoAccounts[j].Address, - shardID, - shardID, - serialized(unsignedTx), - serialized(signedTx), - ) - } - -} diff --git a/test/txgen/tx.json b/test/txgen/tx.json deleted file mode 100644 index 65683834ec..0000000000 --- a/test/txgen/tx.json +++ /dev/null @@ -1,152 +0,0 @@ -[ - { - "fromPrivate": "27978f895b11d9c737e1ab1623fde722c04b4f9ccb4ab776bf15932cc72d7c66", - "toAddress": "0x10A02A0a6e95a676AE23e2db04BEa3D1B8b7ca2E", - "shardID": 0, - "amount": 0, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e08080825208809410a02a0a6e95a676ae23e2db04bea3d1b8b7ca2e8080808080", - "signedTx": "f8608080825208809410a02a0a6e95a676ae23e2db04bea3d1b8b7ca2e80801ca0da715d547791818390df18f6c1baf54d4369eba03f578f5f21199c7933d5a23ca06de1086983eb0fe1690e85e7df1108473699c81721376ba67fceaf78a4a2cdf2" - }, - { - "fromPrivate": "371cb68abe6a6101ac88603fc847e0c013a834253acee5315884d2c4e387ebca", - "toAddress": "0x3e881F6C36A3A14a2D1816b0A5471d1caBB16F33", - "shardID": 1, - "amount": 1, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e8808082520801943e881f6c36a3a14a2d1816b0a5471d1cabb16f33880de0b6b3a764000080808080", - "signedTx": "f868808082520801943e881f6c36a3a14a2d1816b0a5471d1cabb16f33880de0b6b3a7640000801ba0b43bcf2dd258777aa5ff536e268b5e345bf81191ee3278da099a97e63b841399a0728203815bf7d6d3bff2a52ea6904e1d8e26900284ad7a0d047b36d79fc7d751" - }, - { - "fromPrivate": "3f8af52063c6648be37d4b33559f784feb16d8e5ffaccf082b3657ea35b05977", - "toAddress": "0x9d72989b68777a1f3FfD6F1DB079f1928373eE52", - "shardID": 2, - "amount": 2, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e8808082520802949d72989b68777a1f3ffd6f1db079f1928373ee52881bc16d674ec8000080808080", - "signedTx": "f868808082520802949d72989b68777a1f3ffd6f1db079f1928373ee52881bc16d674ec80000801ca0da9f6416bc0d693966499c0765efd96aa44185dcb580cffcd8f3d6afd700f729a07b7369368d11db117bc287b0eb354dee12d4aa9ada62f96009c4a2a2ea832641" - }, - { - "fromPrivate": "df77927961152e6a080ac299e7af2135fc0fb02eb044d0d7bbb1e8c5ad523809", - "toAddress": "0x67957240b6eB045E17B47dcE98102f09aaC03435", - "shardID": 3, - "amount": 3, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e88080825208039467957240b6eb045e17b47dce98102f09aac034358829a2241af62c000080808080", - "signedTx": "f8688080825208039467957240b6eb045e17b47dce98102f09aac034358829a2241af62c0000801ba054f1b3ad63a950b3c8bfd2f70e9054a09437517332b501452f8c8519a2eb9a4da035a5f2a67795ddd81d2bf575aa6ed14266e716c5802529ced04c2e42240ec6b1" - }, - { - "fromPrivate": "fcff43741ad2dd0b232efb159dc47736bbb16f11a79aaeec39b388d06f91116d", - "toAddress": "0xf70fBDB1AD002baDF19024785b1a4bf6F841F558", - "shardID": 0, - "amount": 0, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e080808252088094f70fbdb1ad002badf19024785b1a4bf6f841f5588080808080", - "signedTx": "f86080808252088094f70fbdb1ad002badf19024785b1a4bf6f841f55880801ba03c8a0008ddb02551075b9ba2b92c6813e4d39a50487e608db3535290b11c1cb1a02696d31fd9aeace1065c4f878b7ceeda3352ce05bb32d59b36a5f7440a1eb8bc" - }, - { - "fromPrivate": "916d3d78b7f413452434e89f9c1f1d136995ef02d7dc8038e84cc9cef4a02b96", - "toAddress": "0x3f1A559be93C9456Ca75712535Fd522f5EC22c6B", - "shardID": 1, - "amount": 1, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e8808082520801943f1a559be93c9456ca75712535fd522f5ec22c6b880de0b6b3a764000080808080", - "signedTx": "f868808082520801943f1a559be93c9456ca75712535fd522f5ec22c6b880de0b6b3a7640000801ba09c86f5b54bb6b520781b107840eccba443084fb702056f67bde36010a4571d81a0532c1408096cd02e740b6c4793a89500f594f3647d0b8d6bf24c2a9c3c38f8bc" - }, - { - "fromPrivate": "f5967bd87fd2b9dbf51855a2a75ef0a811c84953b3b300ffe90c430a5c856303", - "toAddress": "0xedD257B4e0F5e7d632c737f4277e93b64DC268FC", - "shardID": 2, - "amount": 2, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e880808252080294edd257b4e0f5e7d632c737f4277e93b64dc268fc881bc16d674ec8000080808080", - "signedTx": "f86880808252080294edd257b4e0f5e7d632c737f4277e93b64dc268fc881bc16d674ec80000801ba0b5ef37d8a01ba077289d6333f48a241845aeaed0f2ed8e863f34ac3828c2d99da043601572bd0e559fd36fd58d5bbd667e1f0788ee3930c1fe9194a1035b15bef2" - }, - { - "fromPrivate": "f02f7b3bb5aa03aa97f9e030020dd9ca306b209742fafe018104a3207a70a3c9", - "toAddress": "0x66A74477FC1dd0F4924ed943C1d2F1Dece3Ab138", - "shardID": 3, - "amount": 3, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e88080825208039466a74477fc1dd0f4924ed943c1d2f1dece3ab1388829a2241af62c000080808080", - "signedTx": "f8688080825208039466a74477fc1dd0f4924ed943c1d2f1dece3ab1388829a2241af62c0000801ba011f5f18be759f168332f8913adec2f7a069658bb0f8a236dbee6cba9c4450d12a054dacc2be540c2779acabeced87abffaf0fe6a74cdbb75c6003d1cadbc89f11e" - }, - { - "fromPrivate": "0436864cc15772448f88dd40554592ff6c91a6c1a389d965ad26ee143db1234d", - "toAddress": "0x04178CdbCe3a9Ff9Ea385777aFc4b78B3E745281", - "shardID": 0, - "amount": 0, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e08080825208809404178cdbce3a9ff9ea385777afc4b78b3e7452818080808080", - "signedTx": "f8608080825208809404178cdbce3a9ff9ea385777afc4b78b3e74528180801ba08a19a111a85a018acb4c6edd7ddda0acdd0b7de0207eb93f7adad8cec59479d9a00d8bd7eea1b0c96c951a2e931ae6b0588d24f12d588f80a5d647e4c082413671" - }, - { - "fromPrivate": "dea956e530073ab23d9cae704f5d068482b1977c3173c9efd697c48a7fd3ce83", - "toAddress": "0x46C61d50874A7A06D29FF89a710AbBD0856265be", - "shardID": 1, - "amount": 1, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e88080825208019446c61d50874a7a06d29ff89a710abbd0856265be880de0b6b3a764000080808080", - "signedTx": "f8688080825208019446c61d50874a7a06d29ff89a710abbd0856265be880de0b6b3a7640000801ba0c2c77b032a4794c9603d60bb6371ac729403efdf88b595aac699d4e208c1a453a07f55088f81c372857d95a9dec8b0828e572bca56017e3a35ecd3c3f9143a12f4" - }, - { - "fromPrivate": "af539d4ace07a9f601a8d3a6ca6f914d5a9fabe09cfe7d62ebc2348fc95f03a4", - "toAddress": "0xfE9BABE6904C28E31971337738FBCBAF8c72873e", - "shardID": 2, - "amount": 2, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e880808252080294fe9babe6904c28e31971337738fbcbaf8c72873e881bc16d674ec8000080808080", - "signedTx": "f86880808252080294fe9babe6904c28e31971337738fbcbaf8c72873e881bc16d674ec80000801ba0d94f56e5e3eb497b0cb84035401e4ab0abea3ac35efb33ec0dbd80c1b82f5df5a0425834db5fee85ae7f783b691b583a2bc5ee54814d628f3e67f743a26157a0a8" - }, - { - "fromPrivate": "7d24797eeba0cdac9bf943f0d82c4b18eb206108d6e1b7f610471594c0c94306", - "toAddress": "0x3f78622de8D8f87EAa0E8b28C2851e2450E91250", - "shardID": 3, - "amount": 3, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e8808082520803943f78622de8d8f87eaa0e8b28c2851e2450e912508829a2241af62c000080808080", - "signedTx": "f868808082520803943f78622de8d8f87eaa0e8b28c2851e2450e912508829a2241af62c0000801ca0556df9dda0efa782e26e19a3a5026cf5c2f3a0c17fd17a3ba6b91ffcd16dc312a01a406d707b2702551d2ef6fa7f157a956c5fdbbdd0438cf881a84256e2f32e84" - }, - { - "fromPrivate": "4fa2fecce1becfaf7e5fba5394caacb318333b04071462b5ca850ee5a406dcfe", - "toAddress": "0xd2Cb501B40D3a9a013A38267a4d2A4Cf6bD2CAa8", - "shardID": 0, - "amount": 0, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e080808252088094d2cb501b40d3a9a013a38267a4d2a4cf6bd2caa88080808080", - "signedTx": "f86080808252088094d2cb501b40d3a9a013a38267a4d2a4cf6bd2caa880801ca01df595c0ff3ae65408e206436ea0b6b58ecb3338c60c96adc6e64e7d0833569ba03a6ae5835ed4e9dcc88375e59e8306c8be49a8424f4137d97cc71cf29bb9333d" - }, - { - "fromPrivate": "3c8642f7188e05acc4467d9e2aa7fd539e82aa90a5497257cf0ecbb98ed3b88f", - "toAddress": "0x2676e6dd2d7618be14cb4c18a355c81bf7aac647", - "shardID": 1, - "amount": 1, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e8808082520801942676e6dd2d7618be14cb4c18a355c81bf7aac647880de0b6b3a764000080808080", - "signedTx": "f868808082520801942676e6dd2d7618be14cb4c18a355c81bf7aac647880de0b6b3a7640000801ca06c20c3a0862f59644bbed846a610db4a98a52901ba34c4f0ba722a8d5144a44fa0121020d3704926c479b7c12f68897f1d6ce0d53b96fd0739584af78aca4b2e2b" - }, - { - "fromPrivate": "bf29f6a33b2c24a8b5182ef44cc35ce87534ef827c8dfbc1e6bb536aa52f8563", - "toAddress": "0x1a3e7a44ee21101d7D64FBf29B0F6F1fc295F723", - "shardID": 2, - "amount": 2, - "nonce": 0, - "gasLimit": 21000, - "unsignedTx": "e8808082520802941a3e7a44ee21101d7d64fbf29b0f6f1fc295f723881bc16d674ec8000080808080", - "signedTx": "f868808082520802941a3e7a44ee21101d7d64fbf29b0f6f1fc295f723881bc16d674ec80000801ba0fdfdb231fd424f9ed1a70f3810a1bf1b2208e0969e403b328631146034d2ae0aa043170676fe14fbfdd6ee772d4ad6feac931921cac2c3b31a4c7708ced5518560" - } -]