From 249bc066e91d68592cc326c08d952f5186b812ce Mon Sep 17 00:00:00 2001 From: capossele Date: Wed, 20 Nov 2019 12:09:13 +0000 Subject: [PATCH 001/184] :sparkles: adds new autopeering --- go.mod | 24 +- go.sum | 182 +++++++++++++ packages/accountability/accountability.go | 32 +-- packages/daemon/events.go | 2 +- packages/identity/constants.go | 18 +- packages/identity/errors.go | 8 + packages/identity/identity.go | 137 ++++++---- packages/network/events.go | 2 +- packages/network/managed_connection.go | 2 +- packages/network/tcp/server.go | 2 +- packages/network/tcp/server_events.go | 2 +- packages/network/udp/events.go | 2 +- packages/network/udp/server.go | 2 +- packages/node/events.go | 2 +- packages/node/plugin.go | 2 +- packages/parameter/events.go | 2 +- plugins/analysis/client/plugin.go | 61 ++--- plugins/analysis/plugin.go | 2 +- plugins/analysis/server/events.go | 2 +- plugins/analysis/server/plugin.go | 2 +- .../webinterface/httpserver/data_stream.go | 2 +- .../webinterface/httpserver/plugin.go | 2 +- .../recordedevents/recorded_events.go | 2 +- plugins/autopeering/autopeering.go | 138 ++++++++++ .../instances/acceptedneighbors/distance.go | 32 --- .../acceptedneighbors/furthest_neighbor.go | 45 ---- .../instances/acceptedneighbors/instance.go | 5 - .../instances/acceptedneighbors/plugin.go | 8 - .../instances/chosenneighbors/candidates.go | 20 -- .../instances/chosenneighbors/distance.go | 31 --- .../chosenneighbors/furthest_neighbor.go | 45 ---- .../instances/chosenneighbors/instance.go | 5 - .../instances/chosenneighbors/plugin.go | 11 - .../instances/entrynodes/instance.go | 83 ------ .../instances/knownpeers/instance.go | 22 -- .../instances/neighborhood/events.go | 31 --- .../instances/neighborhood/instance.go | 54 ---- .../instances/outgoingrequest/instance.go | 23 -- .../autopeering/instances/ownpeer/instance.go | 24 -- plugins/autopeering/instances/plugin.go | 26 -- plugins/autopeering/parameters/parameters.go | 11 - .../autopeering/peerstorage/peerstorage.go | 88 ------- plugins/autopeering/plugin.go | 76 ++---- .../protocol/accepted_neighbor_dropper.go | 40 --- .../protocol/chosen_neighbor_dropper.go | 40 --- .../protocol/constants/constants.go | 18 -- plugins/autopeering/protocol/error_handler.go | 14 - .../protocol/incoming_drop_processor.go | 18 -- .../protocol/incoming_ping_processor.go | 19 -- .../protocol/incoming_request_processor.go | 78 ------ .../protocol/incoming_response_processor.go | 34 --- .../protocol/outgoing_ping_processor.go | 86 ------ .../protocol/outgoing_request_processor.go | 85 ------ plugins/autopeering/protocol/plugin.go | 32 --- .../autopeering/protocol/types/constants.go | 9 - plugins/autopeering/protocol/types/types.go | 5 - plugins/autopeering/saltmanager/constants.go | 13 - plugins/autopeering/saltmanager/errors.go | 8 - plugins/autopeering/saltmanager/events.go | 18 -- .../autopeering/saltmanager/saltmanager.go | 88 ------- plugins/autopeering/saltmanager/utils.go | 19 -- plugins/autopeering/server/server.go | 22 -- plugins/autopeering/server/tcp/constants.go | 12 - plugins/autopeering/server/tcp/events.go | 35 --- plugins/autopeering/server/tcp/server.go | 225 ---------------- plugins/autopeering/server/udp/events.go | 41 --- plugins/autopeering/server/udp/server.go | 98 ------- plugins/autopeering/types/drop/constants.go | 23 -- plugins/autopeering/types/drop/drop.go | 60 ----- plugins/autopeering/types/drop/errors.go | 8 - plugins/autopeering/types/peer/constants.go | 31 --- plugins/autopeering/types/peer/peer.go | 246 ------------------ plugins/autopeering/types/peer/peer_test.go | 38 --- .../autopeering/types/peerlist/peer_list.go | 94 ------- .../autopeering/types/peerregister/events.go | 16 -- .../autopeering/types/peerregister/peerMap.go | 81 ------ .../types/peerregister/peer_register.go | 87 ------- plugins/autopeering/types/ping/constants.go | 29 --- plugins/autopeering/types/ping/errors.go | 8 - plugins/autopeering/types/ping/ping.go | 104 -------- .../autopeering/types/request/constants.go | 23 -- plugins/autopeering/types/request/errors.go | 10 - plugins/autopeering/types/request/request.go | 116 --------- .../autopeering/types/response/constants.go | 35 --- plugins/autopeering/types/response/errors.go | 7 - .../autopeering/types/response/response.go | 110 -------- .../types/response/response_test.go | 56 ---- plugins/autopeering/types/response/types.go | 3 - plugins/autopeering/types/salt/constants.go | 14 - plugins/autopeering/types/salt/salt.go | 92 ------- .../bundleprocessor/bundleprocessor_test.go | 2 +- plugins/bundleprocessor/events.go | 2 +- plugins/bundleprocessor/plugin.go | 2 +- plugins/cli/plugin.go | 2 +- plugins/dashboard/plugin.go | 2 +- plugins/dashboard/tps.go | 21 +- plugins/gossip-on-solidification/plugin.go | 2 +- plugins/gossip/events.go | 2 +- plugins/gossip/neighbors.go | 27 +- plugins/gossip/protocol.go | 2 +- plugins/gossip/protocol_v1.go | 79 +++--- plugins/gossip/send_queue.go | 2 +- plugins/gossip/server.go | 2 +- plugins/metrics/events.go | 2 +- plugins/metrics/plugin.go | 2 +- plugins/statusscreen-tps/plugin.go | 2 +- plugins/statusscreen/statusscreen.go | 2 +- plugins/statusscreen/ui_header_bar.go | 24 +- plugins/tangle/events.go | 2 +- plugins/tangle/solidifier.go | 2 +- plugins/tangle/solidifier_test.go | 2 +- plugins/tipselection/plugin.go | 2 +- plugins/ui/nodeInfo.go | 13 +- plugins/ui/ui.go | 2 +- plugins/validator/plugin.go | 2 +- plugins/webapi/plugin.go | 2 +- plugins/zeromq/plugin.go | 2 +- 117 files changed, 622 insertions(+), 3206 deletions(-) create mode 100644 packages/identity/errors.go create mode 100644 plugins/autopeering/autopeering.go delete mode 100644 plugins/autopeering/instances/acceptedneighbors/distance.go delete mode 100644 plugins/autopeering/instances/acceptedneighbors/furthest_neighbor.go delete mode 100644 plugins/autopeering/instances/acceptedneighbors/instance.go delete mode 100644 plugins/autopeering/instances/acceptedneighbors/plugin.go delete mode 100644 plugins/autopeering/instances/chosenneighbors/candidates.go delete mode 100644 plugins/autopeering/instances/chosenneighbors/distance.go delete mode 100644 plugins/autopeering/instances/chosenneighbors/furthest_neighbor.go delete mode 100644 plugins/autopeering/instances/chosenneighbors/instance.go delete mode 100644 plugins/autopeering/instances/chosenneighbors/plugin.go delete mode 100644 plugins/autopeering/instances/entrynodes/instance.go delete mode 100644 plugins/autopeering/instances/knownpeers/instance.go delete mode 100644 plugins/autopeering/instances/neighborhood/events.go delete mode 100644 plugins/autopeering/instances/neighborhood/instance.go delete mode 100644 plugins/autopeering/instances/outgoingrequest/instance.go delete mode 100644 plugins/autopeering/instances/ownpeer/instance.go delete mode 100644 plugins/autopeering/instances/plugin.go delete mode 100644 plugins/autopeering/parameters/parameters.go delete mode 100644 plugins/autopeering/peerstorage/peerstorage.go delete mode 100644 plugins/autopeering/protocol/accepted_neighbor_dropper.go delete mode 100644 plugins/autopeering/protocol/chosen_neighbor_dropper.go delete mode 100644 plugins/autopeering/protocol/constants/constants.go delete mode 100644 plugins/autopeering/protocol/error_handler.go delete mode 100644 plugins/autopeering/protocol/incoming_drop_processor.go delete mode 100644 plugins/autopeering/protocol/incoming_ping_processor.go delete mode 100644 plugins/autopeering/protocol/incoming_request_processor.go delete mode 100644 plugins/autopeering/protocol/incoming_response_processor.go delete mode 100644 plugins/autopeering/protocol/outgoing_ping_processor.go delete mode 100644 plugins/autopeering/protocol/outgoing_request_processor.go delete mode 100644 plugins/autopeering/protocol/plugin.go delete mode 100644 plugins/autopeering/protocol/types/constants.go delete mode 100644 plugins/autopeering/protocol/types/types.go delete mode 100644 plugins/autopeering/saltmanager/constants.go delete mode 100644 plugins/autopeering/saltmanager/errors.go delete mode 100644 plugins/autopeering/saltmanager/events.go delete mode 100644 plugins/autopeering/saltmanager/saltmanager.go delete mode 100644 plugins/autopeering/saltmanager/utils.go delete mode 100644 plugins/autopeering/server/server.go delete mode 100644 plugins/autopeering/server/tcp/constants.go delete mode 100644 plugins/autopeering/server/tcp/events.go delete mode 100644 plugins/autopeering/server/tcp/server.go delete mode 100644 plugins/autopeering/server/udp/events.go delete mode 100644 plugins/autopeering/server/udp/server.go delete mode 100644 plugins/autopeering/types/drop/constants.go delete mode 100644 plugins/autopeering/types/drop/drop.go delete mode 100644 plugins/autopeering/types/drop/errors.go delete mode 100644 plugins/autopeering/types/peer/constants.go delete mode 100644 plugins/autopeering/types/peer/peer.go delete mode 100644 plugins/autopeering/types/peer/peer_test.go delete mode 100644 plugins/autopeering/types/peerlist/peer_list.go delete mode 100644 plugins/autopeering/types/peerregister/events.go delete mode 100644 plugins/autopeering/types/peerregister/peerMap.go delete mode 100644 plugins/autopeering/types/peerregister/peer_register.go delete mode 100644 plugins/autopeering/types/ping/constants.go delete mode 100644 plugins/autopeering/types/ping/errors.go delete mode 100644 plugins/autopeering/types/ping/ping.go delete mode 100644 plugins/autopeering/types/request/constants.go delete mode 100644 plugins/autopeering/types/request/errors.go delete mode 100644 plugins/autopeering/types/request/request.go delete mode 100644 plugins/autopeering/types/response/constants.go delete mode 100644 plugins/autopeering/types/response/errors.go delete mode 100644 plugins/autopeering/types/response/response.go delete mode 100644 plugins/autopeering/types/response/response_test.go delete mode 100644 plugins/autopeering/types/response/types.go delete mode 100644 plugins/autopeering/types/salt/constants.go delete mode 100644 plugins/autopeering/types/salt/salt.go diff --git a/go.mod b/go.mod index b5b30299db..9bc9742cb2 100644 --- a/go.mod +++ b/go.mod @@ -3,27 +3,27 @@ module github.com/iotaledger/goshimmer go 1.13 require ( - github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect github.com/dgraph-io/badger v1.6.0 github.com/dgrijalva/jwt-go v3.2.0+incompatible + github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b // indirect github.com/ethereum/go-ethereum v1.9.3 github.com/gdamore/tcell v1.2.0 github.com/go-zeromq/zmq4 v0.5.0 - github.com/golang/protobuf v1.3.2 // indirect - github.com/google/open-location-code/go v0.0.0-20190723034300-2c7115db77a3 + github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/iota.go v1.0.0-beta.7 - github.com/kr/pretty v0.1.0 // indirect + github.com/iotaledger/autopeering-sim v0.0.0-20191120103907-203d7715f04c + github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb + github.com/iotaledger/iota.go v1.0.0-beta.9 github.com/labstack/echo v3.3.10+incompatible - github.com/labstack/gommon v0.3.0 // indirect github.com/magiconair/properties v1.8.1 github.com/pkg/errors v0.8.1 github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341 - github.com/rivo/uniseg v0.1.0 // indirect + go.uber.org/atomic v1.5.1 // indirect + go.uber.org/multierr v1.4.0 // indirect + go.uber.org/zap v1.13.0 // indirect golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 - golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 - golang.org/x/sys v0.0.0-20190904154756-749cb33beabd // indirect - golang.org/x/text v0.3.2 // indirect - gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect - gopkg.in/zeromq/goczmq.v4 v4.1.0 // indirect + golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 + golang.org/x/sys v0.0.0-20191119195528-f068ffe820e4 // indirect + golang.org/x/tools v0.0.0-20191120001058-ad01d5993d97 // indirect + google.golang.org/grpc v1.21.0 ) diff --git a/go.sum b/go.sum index 3df102786a..2372f44c50 100644 --- a/go.sum +++ b/go.sum @@ -1,112 +1,262 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DATA-DOG/go-sqlmock v1.3.3 h1:CWUqKXe0s8A2z6qCgkP4Kru7wC11YoAnoupUKFDnH08= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0= +github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/apsdehal/go-logger v0.0.0-20190506062552-f85330a4b532/go.mod h1:U3/8D6R9+bVpX0ORZjV+3mU9pQ86m7h1lESgJbXNvXA= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgraph-io/badger v1.5.4/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ= +github.com/dgraph-io/badger v1.6.0 h1:DshxFxZWXUcO0xX476VJC07Xsr6ZCBVRHKZ93Oh7Evo= github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190323231341-8198c7b169ec/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b h1:SeiGBzKrEtuDddnBABHkp4kq9sBGE9nuYmk6FPTg0zg= +github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/ethereum/go-ethereum v1.9.3 h1:v3bE4abkXknLcyWCf4TRFn+Ecmm9thPtfLFvTEQ+1+U= github.com/ethereum/go-ethereum v1.9.3/go.mod h1:PwpWDrCLZrV+tfrhqqF6kPknbISMHaJv9Ln3kPCZLwY= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/tcell v1.1.2/go.mod h1:h3kq4HO9l2On+V9ed8w8ewqQEmGCSSHOgQ+2h8uzurE= +github.com/gdamore/tcell v1.2.0 h1:ikixzsxc8K8o3V2/CEmyoEW8mJZaNYQQ3NP3VIQdUe4= github.com/gdamore/tcell v1.2.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-zeromq/zmq4 v0.5.0 h1:DijriKlrr2b48mymvAsZApiPzrbxQodYKG1aDH1rz8c= github.com/go-zeromq/zmq4 v0.5.0/go.mod h1:6p7pjNlkfrQQVipmEuZDk7fakLZCqPPVK+Iq3jfbDg8= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/open-location-code/go v0.0.0-20190723034300-2c7115db77a3/go.mod h1:eJfRN6aj+kR/rnua/rw9jAgYhqoMHldQkdTi+sePRKk= +github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 h1:OdVal38kmXn0U3M3CYmPF4cpMLLvD4ioshwrooNfmxs= +github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51/go.mod h1:eJfRN6aj+kR/rnua/rw9jAgYhqoMHldQkdTi+sePRKk= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/iotaledger/autopeering-sim v0.0.0-20191115173310-317faa63cf9c h1:1rTNwCmbnt16oL4wwvvaftvEpOLjiBafftAjvsc5GRs= +github.com/iotaledger/autopeering-sim v0.0.0-20191115173310-317faa63cf9c/go.mod h1:cRYqXkJh2PDyW9voFcTOqvCPJaZOmA4u78yb3zuFJNw= +github.com/iotaledger/autopeering-sim v0.0.0-20191118112632-0056a04132b5 h1:VdX7IbHWdi6bPboVschNmzY4tKLMuqYuvF1s/c/RQS8= +github.com/iotaledger/autopeering-sim v0.0.0-20191118112632-0056a04132b5/go.mod h1:LDtLLYVjSuwAH2k3onNt9qhm0EPHLMXRnslsTzn7Yu8= +github.com/iotaledger/autopeering-sim v0.0.0-20191120093237-9e81a790d189 h1:JF1Ky6w0vNk53yMHtW4OgBinE8ZDftPS4LwAs1yJXhY= +github.com/iotaledger/autopeering-sim v0.0.0-20191120093237-9e81a790d189/go.mod h1:/vE248gYTjvoSQ/oL/EIO8sxIDEM/H/n1B9Oubg8C34= +github.com/iotaledger/autopeering-sim v0.0.0-20191120103907-203d7715f04c h1:S8UKkR+lbYVquuQE9nvmjYGLvHrWU3HFBcjxmlRbJ5I= +github.com/iotaledger/autopeering-sim v0.0.0-20191120103907-203d7715f04c/go.mod h1:/vE248gYTjvoSQ/oL/EIO8sxIDEM/H/n1B9Oubg8C34= +github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= +github.com/iotaledger/hive.go v0.0.0-20191115134440-92f05839b6e0/go.mod h1:Ks2y/bEyfvb7nUA7l69a+8Epsv16UlGev0BvxggHius= +github.com/iotaledger/hive.go v0.0.0-20191116130349-b8be71b827be h1:8aE2Pv9Z2db42CscDf78Yt/uHzHnkAOLmaXvzFqlX7o= +github.com/iotaledger/hive.go v0.0.0-20191116130349-b8be71b827be/go.mod h1:Ks2y/bEyfvb7nUA7l69a+8Epsv16UlGev0BvxggHius= +github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= +github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= github.com/iotaledger/iota.go v1.0.0-beta.7 h1:OaUNahPvOdQz2nKcgeAfcUdxlEDlEV3xwLIkwzZ1B/U= github.com/iotaledger/iota.go v1.0.0-beta.7/go.mod h1:dMps6iMVU1pf5NDYNKIw4tRsPeC8W3ZWjOvYHOO1PMg= +github.com/iotaledger/iota.go v1.0.0-beta.9 h1:c654s9pkdhMBkABUvWg+6k91MEBbdtmZXP1xDfQpajg= +github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= +github.com/lucasb-eyer/go-colorful v1.0.2 h1:mCMFu6PgSozg9tDNMMK3g18oJBX7oYGrC09mS6CXfO4= github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= +github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= +github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= +github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341 h1:d2Z5U4d3fenPRFFweaMCogbXiRywM5kgYtu20/hol3M= github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341/go.mod h1:+rKjP5+h9HMwWRpAfhIkkQ9KE3m3Nz5rwn7YtUpwgqk= github.com/rivo/uniseg v0.0.0-20190513083848-b9f5b9457d44/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y= +github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= +github.com/simia-tech/env v0.1.0/go.mod h1:eVRQ7W5NXXHifpPAcTJ3r5EmoGgMn++dXfSVbZv3Opo= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/spf13/viper v1.5.0/go.mod h1:AkYRkVJF8TkSG/xet6PzXX+l39KhhXa2pdqVSxnTcn4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.mongodb.org/mongo-driver v1.0.0/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0 h1:OI5t8sDa1Or+q8AeE+yKeB/SDYioSHAgcVljj9JIETY= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.5.1 h1:rsqfU5vBkVknbhUGbAUwQKR2H4ItV8tjJ+6kJX4cxHM= +go.uber.org/atomic v1.5.1/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.4.0 h1:f3WCSC2KzAcBXGATIxAB1E2XuCpNU255wNKZ505qi3E= +go.uber.org/multierr v1.4.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0 h1:nR6NoDBgAf67s68NhaXbsojM+2gxp3S1hWkHDl27pVU= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 h1:Gv7RPwsi3eZ2Fgewe3CBsuOebPwO27PoXzRpJPsvSSM= golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191116160921-f9c825593386 h1:ktbWvQrW08Txdxno1PiDpSxPXG6ndGsfnJjRRtkM0LQ= +golang.org/x/net v0.0.0-20191116160921-f9c825593386/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4= +golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -115,19 +265,51 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd h1:DBH9mDw0zluJT/R+nGuV3jWFWLFaHyYZWD4tOT+cjn0= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191118090420-b5d5184f72d2 h1:LEXoa2mfx+ZHKVuyzu3/fnknuCCoTfywJVHMkWECH3Y= +golang.org/x/sys v0.0.0-20191118090420-b5d5184f72d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191119195528-f068ffe820e4 h1:FjhQftcbpdYXneEYSWZO7+6Bu+Bi1A8VPvGYWOIzIbw= +golang.org/x/sys v0.0.0-20191119195528-f068ffe820e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191118051429-5a76f03bc7c3 h1:3gzOmNy3PLCZ+3Ru/n5Gh7pPjsieiytYSDxFj6QY/oI= +golang.org/x/tools v0.0.0-20191118051429-5a76f03bc7c3/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191120001058-ad01d5993d97 h1:u8hSFDulpuhoY0GHMbG6Rp23PzphtTnZrQX3dOvEae0= +golang.org/x/tools v0.0.0-20191120001058-ad01d5993d97/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.21.0 h1:G+97AoqBnmZIT91cLG/EkCoK9NSelj64P8bOHHNmGn0= +google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/h2non/gock.v1 v1.0.14/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/zeromq/goczmq.v4 v4.1.0 h1:CE+FE81mGVs2aSlnbfLuS1oAwdcVywyMM2AC1g33imI= gopkg.in/zeromq/goczmq.v4 v4.1.0/go.mod h1:h4IlfePEYMpFdywGr5gAwKhBBj+hiBl/nF4VoSE4k+0= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/packages/accountability/accountability.go b/packages/accountability/accountability.go index c8d66002a9..6eff4ddd1e 100644 --- a/packages/accountability/accountability.go +++ b/packages/accountability/accountability.go @@ -3,13 +3,15 @@ package accountability import ( "sync" - "github.com/iotaledger/goshimmer/packages/database" + "github.com/dgraph-io/badger" "github.com/iotaledger/goshimmer/packages/identity" "github.com/iotaledger/goshimmer/packages/settings" ) -var ownId *identity.Identity +// Name of the key under which the node identity is stored. +const identityKey = "IDENTITY" +var ownId *identity.Identity var lazyInit sync.Once func OwnId() *identity.Identity { @@ -23,13 +25,13 @@ func initOwnId() { } func generateNewIdentity() *identity.Identity { - newIdentity := identity.GenerateRandomIdentity() - if err := settings.Set([]byte("ACCOUNTABILITY_PUBLIC_KEY"), newIdentity.PublicKey); err != nil { - panic(err) - } + newIdentity := identity.GeneratePrivateIdentity() + + key := []byte(identityKey) + value := newIdentity.Marshal() - if err := settings.Set([]byte("ACCOUNTABILITY_PRIVATE_KEY"), newIdentity.PrivateKey); err != nil { + if err := settings.Set(key, value); err != nil { panic(err) } @@ -37,23 +39,21 @@ func generateNewIdentity() *identity.Identity { } func getIdentity() *identity.Identity { - publicKey, err := settings.Get([]byte("ACCOUNTABILITY_PUBLIC_KEY")) + key := []byte(identityKey) + + value, err := settings.Get(key) if err != nil { - if err == database.ErrKeyNotFound { + if err == badger.ErrKeyNotFound { return generateNewIdentity() } else { panic(err) } } - privateKey, err := settings.Get([]byte("ACCOUNTABILITY_PRIVATE_KEY")) + result, err := identity.Unmarshal(value) if err != nil { - if err == database.ErrKeyNotFound { - return generateNewIdentity() - } else { - panic(err) - } + panic(err) } - return identity.NewIdentity(publicKey, privateKey) + return result } diff --git a/packages/daemon/events.go b/packages/daemon/events.go index dd3953287d..256d4c43f4 100644 --- a/packages/daemon/events.go +++ b/packages/daemon/events.go @@ -1,7 +1,7 @@ package daemon import ( - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" ) var Events = struct { diff --git a/packages/identity/constants.go b/packages/identity/constants.go index e7440a45d0..0e23d6ede9 100644 --- a/packages/identity/constants.go +++ b/packages/identity/constants.go @@ -1,8 +1,20 @@ package identity +import "crypto/ed25519" + const ( - PRIVATE_TYPE = IdentityType(0) - PUBLIC_TYPE = IdentityType(1) + IDENTIFIER_BYTE_LENGTH = 20 + PUBLIC_KEY_BYTE_LENGTH = ed25519.PublicKeySize + SIGNATURE_BYTE_LENGTH = ed25519.PublicKeySize + ed25519.SignatureSize + + MARSHALED_IDENTITY_PUBLIC_KEY_START = 0 + MARSHALED_IDENTITY_PRIVATE_KEY_START = MARSHALED_IDENTITY_PUBLIC_KEY_END + + MARSHALED_IDENTITY_PUBLIC_KEY_SIZE = PUBLIC_KEY_BYTE_LENGTH + MARSHALED_IDENTITY_PRIVATE_KEY_SIZE = ed25519.PrivateKeySize + + MARSHALED_IDENTITY_PUBLIC_KEY_END = MARSHALED_IDENTITY_PUBLIC_KEY_START + MARSHALED_IDENTITY_PUBLIC_KEY_SIZE + MARSHALED_IDENTITY_PRIVATE_KEY_END = MARSHALED_IDENTITY_PRIVATE_KEY_START + MARSHALED_IDENTITY_PRIVATE_KEY_SIZE - PUBLIC_KEY_BYTE_LENGTH = 65 + MARSHALED_IDENTITY_TOTAL_SIZE = MARSHALED_IDENTITY_PRIVATE_KEY_END ) diff --git a/packages/identity/errors.go b/packages/identity/errors.go new file mode 100644 index 0000000000..60f5d59b12 --- /dev/null +++ b/packages/identity/errors.go @@ -0,0 +1,8 @@ +package identity + +import "errors" + +var ( + ErrInvalidDataLen = errors.New("identity: invalid input data length") + ErrInvalidSignature = errors.New("identity: invalid signature") +) diff --git a/packages/identity/identity.go b/packages/identity/identity.go index 022af16258..14fc16fa9f 100644 --- a/packages/identity/identity.go +++ b/packages/identity/identity.go @@ -1,89 +1,120 @@ package identity import ( - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" + "crypto/ed25519" "crypto/sha256" - "fmt" + "encoding/hex" - "github.com/ethereum/go-ethereum/crypto/secp256k1" - "github.com/iotaledger/goshimmer/packages/crypto" + "github.com/iotaledger/autopeering-sim/peer" ) type Identity struct { - Type IdentityType - Identifier []byte + Identifier peer.ID StringIdentifier string - PublicKey []byte - PrivateKey []byte + PublicKey ed25519.PublicKey + privateKey ed25519.PrivateKey } -func NewIdentity(publicKey []byte, optionalPrivateKey ...[]byte) *Identity { - this := &Identity{ - Identifier: crypto.Hash20(publicKey), - PublicKey: make([]byte, len(publicKey)), +// Creates a new identity based on the given public key. +func NewPublicIdentity(publicKey ed25519.PublicKey) *Identity { + identifier := sha256.Sum256(publicKey) + + return &Identity{ + Identifier: identifier, + StringIdentifier: hex.EncodeToString(identifier[:8]), + PublicKey: publicKey, + privateKey: nil, } +} + +// Generates a identity based on a newly generated public/private key pair. +// It will panic if no such pair could be generated. +func GeneratePrivateIdentity() *Identity { + publicKey, privateKey, err := ed25519.GenerateKey(nil) + if err != nil { + panic("identity: failed generating key: " + err.Error()) + } + + return newPrivateIdentity(publicKey, privateKey) +} - copy(this.PublicKey, publicKey) +// Sign signs the message with privateKey and returns the message plus the signature. +func (id *Identity) AddSignature(msg []byte) []byte { + signatureStart := len(msg) - this.StringIdentifier = fmt.Sprintf("%x", this.Identifier) + signature := ed25519.Sign(id.privateKey, msg) - if len(optionalPrivateKey) == 1 { - this.Type = PRIVATE_TYPE - this.PrivateKey = optionalPrivateKey[0] - } else { - this.Type = PUBLIC_TYPE + data := make([]byte, signatureStart+SIGNATURE_BYTE_LENGTH) + + copy(data[:signatureStart], msg) + + // add public key and signature + copy(data[signatureStart:signatureStart+ed25519.PublicKeySize], id.PublicKey) + copy(data[signatureStart+ed25519.PublicKeySize:], signature) + + return data +} + +// Verifies whether the data contains a valid signature of the message. +func (id *Identity) VerifySignature(data []byte) error { + signatureStart := len(data) - SIGNATURE_BYTE_LENGTH + if signatureStart <= 0 { + return ErrInvalidDataLen } - return this + msg := data[:signatureStart] + + // ignore the public key + sig := data[signatureStart+ed25519.PublicKeySize:] + + if !ed25519.Verify(id.PublicKey, msg, sig) { + return ErrInvalidSignature + } + + return nil } -func (this *Identity) Sign(data []byte) ([]byte, error) { - sha256Hasher := sha256.New() - sha256Hasher.Write(data) +// Returns the identitiy derived from the signed message. +func FromSignedData(data []byte) (*Identity, error) { + signatureStart := len(data) - SIGNATURE_BYTE_LENGTH + if signatureStart <= 0 { + return nil, ErrInvalidDataLen + } - sig, err := secp256k1.Sign(sha256Hasher.Sum(nil), this.PrivateKey) - if err != nil { + pubKey := data[signatureStart : signatureStart+ed25519.PublicKeySize] + + identity := NewPublicIdentity(pubKey) + if err := identity.VerifySignature(data); err != nil { return nil, err } - return sig, nil + return identity, nil } -func (this *Identity) VerifySignature(data []byte, signature []byte) bool { - sha256Hasher := sha256.New() - sha256Hasher.Write(data) +func (id *Identity) Marshal() []byte { + data := make([]byte, MARSHALED_IDENTITY_TOTAL_SIZE) - return secp256k1.VerifySignature(this.PublicKey, sha256Hasher.Sum(nil), signature[:64]) + copy(data[MARSHALED_IDENTITY_PUBLIC_KEY_START:MARSHALED_IDENTITY_PUBLIC_KEY_END], id.PublicKey) + copy(data[MARSHALED_IDENTITY_PRIVATE_KEY_START:MARSHALED_IDENTITY_PRIVATE_KEY_END], id.privateKey) + + return data } -func GenerateRandomIdentity() *Identity { - // generate key pair - keyPair, err := ecdsa.GenerateKey(secp256k1.S256(), rand.Reader) - if err != nil { - panic(err) +func Unmarshal(data []byte) (*Identity, error) { + if len(data) != MARSHALED_IDENTITY_TOTAL_SIZE { + return nil, ErrInvalidDataLen } - // build public key bytes - publicKey := elliptic.Marshal(secp256k1.S256(), keyPair.X, keyPair.Y) - - // build private key bytes - privkey := make([]byte, 32) - blob := keyPair.D.Bytes() - copy(privkey[32-len(blob):], blob) + publicKey := data[MARSHALED_IDENTITY_PUBLIC_KEY_START:MARSHALED_IDENTITY_PUBLIC_KEY_END] + privateKey := data[MARSHALED_IDENTITY_PRIVATE_KEY_START:MARSHALED_IDENTITY_PRIVATE_KEY_END] - return NewIdentity(publicKey, privkey) + return newPrivateIdentity(publicKey, privateKey), nil } -func FromSignedData(data []byte, signature []byte) (*Identity, error) { - sha256Hasher := sha256.New() - sha256Hasher.Write(data) +func newPrivateIdentity(publicKey []byte, privateKey []byte) *Identity { - pubKey, err := secp256k1.RecoverPubkey(sha256Hasher.Sum(nil), signature) - if err != nil { - return nil, err - } + identity := NewPublicIdentity(publicKey) + identity.privateKey = privateKey - return NewIdentity(pubKey), nil + return identity } diff --git a/packages/network/events.go b/packages/network/events.go index 0096c1b59f..7903376b6b 100644 --- a/packages/network/events.go +++ b/packages/network/events.go @@ -1,7 +1,7 @@ package network import ( - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" ) type BufferedConnectionEvents struct { diff --git a/packages/network/managed_connection.go b/packages/network/managed_connection.go index 30b48a894c..012a59d8a7 100644 --- a/packages/network/managed_connection.go +++ b/packages/network/managed_connection.go @@ -6,7 +6,7 @@ import ( "sync" "time" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" ) type ManagedConnection struct { diff --git a/packages/network/tcp/server.go b/packages/network/tcp/server.go index 67b70b26a8..5bef906f4d 100644 --- a/packages/network/tcp/server.go +++ b/packages/network/tcp/server.go @@ -5,7 +5,7 @@ import ( "strconv" "sync" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/network" ) diff --git a/packages/network/tcp/server_events.go b/packages/network/tcp/server_events.go index b5f3fbbeab..3ce91184bd 100644 --- a/packages/network/tcp/server_events.go +++ b/packages/network/tcp/server_events.go @@ -1,7 +1,7 @@ package tcp import ( - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/network" ) diff --git a/packages/network/udp/events.go b/packages/network/udp/events.go index dc797d0e5c..590c6c256b 100644 --- a/packages/network/udp/events.go +++ b/packages/network/udp/events.go @@ -3,7 +3,7 @@ package udp import ( "net" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" ) type serverEvents struct { diff --git a/packages/network/udp/server.go b/packages/network/udp/server.go index 3c77a0e8ab..00fe86864c 100644 --- a/packages/network/udp/server.go +++ b/packages/network/udp/server.go @@ -5,7 +5,7 @@ import ( "strconv" "sync" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" ) type Server struct { diff --git a/packages/node/events.go b/packages/node/events.go index 4b5a8e80d1..820be882c8 100644 --- a/packages/node/events.go +++ b/packages/node/events.go @@ -1,7 +1,7 @@ package node import ( - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" ) type pluginEvents struct { diff --git a/packages/node/plugin.go b/packages/node/plugin.go index bb7efa8494..c7d1af3d5f 100644 --- a/packages/node/plugin.go +++ b/packages/node/plugin.go @@ -4,7 +4,7 @@ import ( "strings" "sync" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/parameter" ) diff --git a/packages/parameter/events.go b/packages/parameter/events.go index b755a03848..dea861ea56 100644 --- a/packages/parameter/events.go +++ b/packages/parameter/events.go @@ -1,7 +1,7 @@ package parameter import ( - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" ) var Events = struct { diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index 7bd42836dc..fa7099e652 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -4,9 +4,10 @@ import ( "net" "time" + "github.com/iotaledger/autopeering-sim/discover" + "github.com/iotaledger/autopeering-sim/selection" "github.com/iotaledger/goshimmer/packages/accountability" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/timeutil" @@ -14,10 +15,7 @@ import ( "github.com/iotaledger/goshimmer/plugins/analysis/types/connectnodes" "github.com/iotaledger/goshimmer/plugins/analysis/types/disconnectnodes" "github.com/iotaledger/goshimmer/plugins/analysis/types/ping" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" + "github.com/iotaledger/hive.go/events" ) func Run(plugin *node.Plugin) { @@ -63,7 +61,7 @@ func getEventDispatchers(conn *network.ManagedConnection) *EventDispatchers { } func reportCurrentStatus(eventDispatchers *EventDispatchers) { - eventDispatchers.AddNode(accountability.OwnId().Identifier) + eventDispatchers.AddNode(accountability.OwnId().Identifier.Bytes()) reportChosenNeighbors(eventDispatchers) } @@ -71,43 +69,38 @@ func reportCurrentStatus(eventDispatchers *EventDispatchers) { func setupHooks(conn *network.ManagedConnection, eventDispatchers *EventDispatchers) { // define hooks //////////////////////////////////////////////////////////////////////////////////////////////////// - onDiscoverPeer := events.NewClosure(func(p *peer.Peer) { - go eventDispatchers.AddNode(p.GetIdentity().Identifier) + onDiscoverPeer := events.NewClosure(func(ev *discover.DiscoveredEvent) { + go eventDispatchers.AddNode(ev.Peer.ID().Bytes()) }) - onAddAcceptedNeighbor := events.NewClosure(func(p *peer.Peer) { - eventDispatchers.ConnectNodes(p.GetIdentity().Identifier, accountability.OwnId().Identifier) + onAddAcceptedNeighbor := events.NewClosure(func(ev *selection.PeeringEvent) { + eventDispatchers.ConnectNodes(ev.Peer.ID().Bytes(), accountability.OwnId().Identifier.Bytes()) }) - onRemoveAcceptedNeighbor := events.NewClosure(func(p *peer.Peer) { - eventDispatchers.DisconnectNodes(p.GetIdentity().Identifier, accountability.OwnId().Identifier) + onRemoveNeighbor := events.NewClosure(func(ev *selection.DroppedEvent) { + eventDispatchers.DisconnectNodes(ev.DroppedID.Bytes(), accountability.OwnId().Identifier.Bytes()) + eventDispatchers.DisconnectNodes(accountability.OwnId().Identifier.Bytes(), ev.DroppedID.Bytes()) }) - onAddChosenNeighbor := events.NewClosure(func(p *peer.Peer) { - eventDispatchers.ConnectNodes(accountability.OwnId().Identifier, p.GetIdentity().Identifier) - }) - - onRemoveChosenNeighbor := events.NewClosure(func(p *peer.Peer) { - eventDispatchers.DisconnectNodes(accountability.OwnId().Identifier, p.GetIdentity().Identifier) + onAddChosenNeighbor := events.NewClosure(func(ev *selection.PeeringEvent) { + eventDispatchers.ConnectNodes(accountability.OwnId().Identifier.Bytes(), ev.Peer.ID().Bytes()) }) // setup hooks ///////////////////////////////////////////////////////////////////////////////////////////////////// - knownpeers.INSTANCE.Events.Add.Attach(onDiscoverPeer) - acceptedneighbors.INSTANCE.Events.Add.Attach(onAddAcceptedNeighbor) - acceptedneighbors.INSTANCE.Events.Remove.Attach(onRemoveAcceptedNeighbor) - chosenneighbors.INSTANCE.Events.Add.Attach(onAddChosenNeighbor) - chosenneighbors.INSTANCE.Events.Remove.Attach(onRemoveChosenNeighbor) + discover.Events.PeerDiscovered.Attach(onDiscoverPeer) + selection.Events.IncomingPeering.Attach(onAddAcceptedNeighbor) + selection.Events.OutgoingPeering.Attach(onAddChosenNeighbor) + selection.Events.Dropped.Attach(onRemoveNeighbor) // clean up hooks on close ///////////////////////////////////////////////////////////////////////////////////////// var onClose *events.Closure onClose = events.NewClosure(func() { - knownpeers.INSTANCE.Events.Add.Detach(onDiscoverPeer) - acceptedneighbors.INSTANCE.Events.Add.Detach(onAddAcceptedNeighbor) - acceptedneighbors.INSTANCE.Events.Remove.Detach(onRemoveAcceptedNeighbor) - chosenneighbors.INSTANCE.Events.Add.Detach(onAddChosenNeighbor) - chosenneighbors.INSTANCE.Events.Remove.Detach(onRemoveChosenNeighbor) + discover.Events.PeerDiscovered.Detach(onDiscoverPeer) + selection.Events.IncomingPeering.Detach(onAddAcceptedNeighbor) + selection.Events.OutgoingPeering.Detach(onAddChosenNeighbor) + selection.Events.Dropped.Detach(onRemoveNeighbor) conn.Events.Close.Detach(onClose) }) @@ -115,12 +108,12 @@ func setupHooks(conn *network.ManagedConnection, eventDispatchers *EventDispatch } func reportChosenNeighbors(dispatchers *EventDispatchers) { - for _, chosenNeighbor := range chosenneighbors.INSTANCE.Peers.GetMap() { - dispatchers.AddNode(chosenNeighbor.GetIdentity().Identifier) - } - for _, chosenNeighbor := range chosenneighbors.INSTANCE.Peers.GetMap() { - dispatchers.ConnectNodes(accountability.OwnId().Identifier, chosenNeighbor.GetIdentity().Identifier) - } + // for _, chosenNeighbor := range chosenneighbors.INSTANCE.Peers.GetMap() { + // dispatchers.AddNode(chosenNeighbor.GetIdentity().Identifier) + // } + // for _, chosenNeighbor := range chosenneighbors.INSTANCE.Peers.GetMap() { + // dispatchers.ConnectNodes(accountability.OwnId().Identifier, chosenNeighbor.GetIdentity().Identifier) + // } } func keepConnectionAlive(conn *network.ManagedConnection) bool { diff --git a/plugins/analysis/plugin.go b/plugins/analysis/plugin.go index 44268dd0c0..54ca295475 100644 --- a/plugins/analysis/plugin.go +++ b/plugins/analysis/plugin.go @@ -2,7 +2,7 @@ package analysis import ( "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/analysis/client" "github.com/iotaledger/goshimmer/plugins/analysis/server" diff --git a/plugins/analysis/server/events.go b/plugins/analysis/server/events.go index e66359ff38..979dddec56 100644 --- a/plugins/analysis/server/events.go +++ b/plugins/analysis/server/events.go @@ -1,7 +1,7 @@ package server import ( - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" ) var Events = struct { diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index cbcbb7259b..36b8670843 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -6,7 +6,7 @@ import ( "strconv" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/network/tcp" "github.com/iotaledger/goshimmer/packages/node" diff --git a/plugins/analysis/webinterface/httpserver/data_stream.go b/plugins/analysis/webinterface/httpserver/data_stream.go index 66f6112797..2548064908 100644 --- a/plugins/analysis/webinterface/httpserver/data_stream.go +++ b/plugins/analysis/webinterface/httpserver/data_stream.go @@ -3,7 +3,7 @@ package httpserver import ( "fmt" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/plugins/analysis/server" "github.com/iotaledger/goshimmer/plugins/analysis/webinterface/recordedevents" "github.com/iotaledger/goshimmer/plugins/analysis/webinterface/types" diff --git a/plugins/analysis/webinterface/httpserver/plugin.go b/plugins/analysis/webinterface/httpserver/plugin.go index a6b62cbb12..a7c8daf9ff 100644 --- a/plugins/analysis/webinterface/httpserver/plugin.go +++ b/plugins/analysis/webinterface/httpserver/plugin.go @@ -5,7 +5,7 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/node" "golang.org/x/net/context" "golang.org/x/net/websocket" diff --git a/plugins/analysis/webinterface/recordedevents/recorded_events.go b/plugins/analysis/webinterface/recordedevents/recorded_events.go index 3110aa6a70..882696997b 100644 --- a/plugins/analysis/webinterface/recordedevents/recorded_events.go +++ b/plugins/analysis/webinterface/recordedevents/recorded_events.go @@ -3,7 +3,7 @@ package recordedevents import ( "sync" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/analysis/server" "github.com/iotaledger/goshimmer/plugins/analysis/webinterface/types" diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go new file mode 100644 index 0000000000..bd0ae9ef4b --- /dev/null +++ b/plugins/autopeering/autopeering.go @@ -0,0 +1,138 @@ +package autopeering + +import ( + "encoding/base64" + "fmt" + "log" + "net" + "strings" + + "github.com/iotaledger/autopeering-sim/discover" + "github.com/iotaledger/autopeering-sim/logger" + "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/autopeering-sim/selection" + "github.com/iotaledger/autopeering-sim/server" + "github.com/iotaledger/autopeering-sim/transport" + "github.com/iotaledger/goshimmer/packages/errors" + "github.com/iotaledger/goshimmer/packages/node" +) + +var ( + PLUGIN = node.NewPlugin("Auto Peering", node.Enabled, configure, run) + close = make(chan struct{}, 1) + srv *server.Server + Discovery *discover.Protocol + Selection *selection.Protocol +) + +const defaultZLC = `{ + "level": "info", + "development": false, + "outputPaths": ["stdout"], + "errorOutputPaths": ["stderr"], + "encoding": "console", + "encoderConfig": { + "timeKey": "ts", + "levelKey": "level", + "nameKey": "logger", + "callerKey": "caller", + "messageKey": "msg", + "stacktraceKey": "stacktrace", + "lineEnding": "", + "levelEncoder": "", + "timeEncoder": "iso8601", + "durationEncoder": "", + "callerEncoder": "" + } + }` + +func start() { + var ( + listenAddr = "127.0.0.1:14626" //flag.String("addr", "127.0.0.1:14626", "listen address") + gossipAddr = "127.0.0.1:14666" + masterPeer = "" //flag.String("master", "", "master node as 'pubKey@address' where pubKey is in Base64") + + err error + ) + // flag.Parse() + + logger := logger.NewLogger(defaultZLC, "debug") + defer func() { _ = logger.Sync() }() // ignore the returned error + + addr, err := net.ResolveUDPAddr("udp", listenAddr) + if err != nil { + log.Fatalf("ResolveUDPAddr: %v", err) + } + conn, err := net.ListenUDP("udp", addr) + if err != nil { + log.Fatalf("ListenUDP: %v", err) + } + defer conn.Close() + + var masterPeers []*peer.Peer + master, err := parseMaster(masterPeer) + if err != nil { + log.Printf("Ignoring master: %v\n", err) + } else if master != nil { + masterPeers = []*peer.Peer{master} + } + + // use the UDP connection for transport + trans := transport.Conn(conn, func(network, address string) (net.Addr, error) { return net.ResolveUDPAddr(network, address) }) + defer trans.Close() + + // create a new local node + db := peer.NewPersistentDB(logger.Named("db")) + defer db.Close() + local, err := peer.NewLocal(db) + if err != nil { + log.Fatalf("ListenUDP: %v", err) + } + // add a service for the peering + local.Services()["peering"] = peer.NetworkAddress{Network: "udp", Address: listenAddr} + // add a service for the gossip + local.Services()["gossip"] = peer.NetworkAddress{Network: "tcp", Address: gossipAddr} + + Discovery = discover.New(local, discover.Config{ + Log: logger.Named("disc"), + MasterPeers: masterPeers, + }) + Selection = selection.New(local, Discovery, selection.Config{ + Log: logger.Named("sel"), + SaltLifetime: selection.DefaultSaltLifetime, + }) + + // start a server doing discovery and peering + srv = server.Listen(local, trans, logger.Named("srv"), Discovery, Selection) + defer srv.Close() + + // start the discovery on that connection + Discovery.Start(srv) + defer Discovery.Close() + + // start the peering on that connection + Selection.Start(srv) + defer Selection.Close() + + id := base64.StdEncoding.EncodeToString(local.PublicKey()) + fmt.Println("Discovery protocol started: ID=" + id + ", address=" + srv.LocalAddr()) + + <-close +} + +func parseMaster(s string) (*peer.Peer, error) { + if len(s) == 0 { + return nil, nil + } + + parts := strings.Split(s, "@") + if len(parts) != 2 { + return nil, errors.New("parseMaster") + } + pubKey, err := base64.StdEncoding.DecodeString(parts[0]) + if err != nil { + return nil, errors.Wrap(err, "parseMaster") + } + + return peer.NewPeer(pubKey, parts[1]), nil +} diff --git a/plugins/autopeering/instances/acceptedneighbors/distance.go b/plugins/autopeering/instances/acceptedneighbors/distance.go deleted file mode 100644 index b2b8dae55a..0000000000 --- a/plugins/autopeering/instances/acceptedneighbors/distance.go +++ /dev/null @@ -1,32 +0,0 @@ -package acceptedneighbors - -import ( - "hash/fnv" - - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/ownpeer" - "github.com/iotaledger/goshimmer/plugins/autopeering/saltmanager" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" -) - -var DISTANCE = func(anchor *peer.Peer) func(p *peer.Peer) uint64 { - return func(p *peer.Peer) uint64 { - saltedIdentifier := make([]byte, len(anchor.GetIdentity().Identifier)+len(saltmanager.PRIVATE_SALT.GetBytes())) - copy(saltedIdentifier[0:], anchor.GetIdentity().Identifier) - copy(saltedIdentifier[len(anchor.GetIdentity().Identifier):], saltmanager.PRIVATE_SALT.GetBytes()) - - return hash(saltedIdentifier) ^ hash(p.GetIdentity().Identifier) - } -} - -var OWN_DISTANCE func(p *peer.Peer) uint64 - -func configureOwnDistance() { - OWN_DISTANCE = DISTANCE(ownpeer.INSTANCE) -} - -func hash(data []byte) uint64 { - h := fnv.New64a() - h.Write(data) - - return h.Sum64() -} diff --git a/plugins/autopeering/instances/acceptedneighbors/furthest_neighbor.go b/plugins/autopeering/instances/acceptedneighbors/furthest_neighbor.go deleted file mode 100644 index 201b4827b1..0000000000 --- a/plugins/autopeering/instances/acceptedneighbors/furthest_neighbor.go +++ /dev/null @@ -1,45 +0,0 @@ -package acceptedneighbors - -import ( - "sync" - - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" -) - -var FURTHEST_NEIGHBOR *peer.Peer - -var FURTHEST_NEIGHBOR_DISTANCE = uint64(0) - -var FurthestNeighborLock sync.RWMutex - -func configureFurthestNeighbor() { - INSTANCE.Events.Add.Attach(events.NewClosure(func(p *peer.Peer) { - FurthestNeighborLock.Lock() - defer FurthestNeighborLock.Unlock() - - updateFurthestNeighbor(p) - })) - - INSTANCE.Events.Remove.Attach(events.NewClosure(func(p *peer.Peer) { - FurthestNeighborLock.Lock() - defer FurthestNeighborLock.Unlock() - - if p.GetIdentity().StringIdentifier == FURTHEST_NEIGHBOR.GetIdentity().StringIdentifier { - FURTHEST_NEIGHBOR_DISTANCE = uint64(0) - FURTHEST_NEIGHBOR = nil - - for _, furthestNeighborCandidate := range INSTANCE.Peers.GetMap() { - updateFurthestNeighbor(furthestNeighborCandidate) - } - } - })) -} - -func updateFurthestNeighbor(p *peer.Peer) { - distance := OWN_DISTANCE(p) - if distance > FURTHEST_NEIGHBOR_DISTANCE { - FURTHEST_NEIGHBOR = p - FURTHEST_NEIGHBOR_DISTANCE = distance - } -} diff --git a/plugins/autopeering/instances/acceptedneighbors/instance.go b/plugins/autopeering/instances/acceptedneighbors/instance.go deleted file mode 100644 index 1990c8a3a0..0000000000 --- a/plugins/autopeering/instances/acceptedneighbors/instance.go +++ /dev/null @@ -1,5 +0,0 @@ -package acceptedneighbors - -import "github.com/iotaledger/goshimmer/plugins/autopeering/types/peerregister" - -var INSTANCE = peerregister.New() diff --git a/plugins/autopeering/instances/acceptedneighbors/plugin.go b/plugins/autopeering/instances/acceptedneighbors/plugin.go deleted file mode 100644 index 9870c182bb..0000000000 --- a/plugins/autopeering/instances/acceptedneighbors/plugin.go +++ /dev/null @@ -1,8 +0,0 @@ -package acceptedneighbors - -import "github.com/iotaledger/goshimmer/packages/node" - -func Configure(plugin *node.Plugin) { - configureOwnDistance() - configureFurthestNeighbor() -} diff --git a/plugins/autopeering/instances/chosenneighbors/candidates.go b/plugins/autopeering/instances/chosenneighbors/candidates.go deleted file mode 100644 index a993e5adc6..0000000000 --- a/plugins/autopeering/instances/chosenneighbors/candidates.go +++ /dev/null @@ -1,20 +0,0 @@ -package chosenneighbors - -import ( - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/neighborhood" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/ownpeer" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peerlist" -) - -var CANDIDATES *peerlist.PeerList - -func configureCandidates() { - CANDIDATES = peerlist.NewPeerList() - updateNeighborCandidates() - - neighborhood.Events.Update.Attach(updateNeighborCandidates) -} - -func updateNeighborCandidates() { - CANDIDATES.Update(neighborhood.LIST_INSTANCE.Sort(DISTANCE(ownpeer.INSTANCE)).GetPeers()) -} diff --git a/plugins/autopeering/instances/chosenneighbors/distance.go b/plugins/autopeering/instances/chosenneighbors/distance.go deleted file mode 100644 index 384e29ca27..0000000000 --- a/plugins/autopeering/instances/chosenneighbors/distance.go +++ /dev/null @@ -1,31 +0,0 @@ -package chosenneighbors - -import ( - "hash/fnv" - - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/ownpeer" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" -) - -var DISTANCE = func(anchor *peer.Peer) func(p *peer.Peer) uint64 { - return func(p *peer.Peer) uint64 { - saltedIdentifier := make([]byte, len(anchor.GetIdentity().Identifier)+len(anchor.GetSalt().GetBytes())) - copy(saltedIdentifier[0:], anchor.GetIdentity().Identifier) - copy(saltedIdentifier[len(anchor.GetIdentity().Identifier):], anchor.GetSalt().GetBytes()) - - return hash(anchor.GetIdentity().Identifier) ^ hash(p.GetIdentity().Identifier) - } -} - -var OWN_DISTANCE func(p *peer.Peer) uint64 - -func configureOwnDistance() { - OWN_DISTANCE = DISTANCE(ownpeer.INSTANCE) -} - -func hash(data []byte) uint64 { - h := fnv.New64a() - h.Write(data) - - return h.Sum64() -} diff --git a/plugins/autopeering/instances/chosenneighbors/furthest_neighbor.go b/plugins/autopeering/instances/chosenneighbors/furthest_neighbor.go deleted file mode 100644 index 5040a89af9..0000000000 --- a/plugins/autopeering/instances/chosenneighbors/furthest_neighbor.go +++ /dev/null @@ -1,45 +0,0 @@ -package chosenneighbors - -import ( - "sync" - - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" -) - -var FURTHEST_NEIGHBOR *peer.Peer - -var FURTHEST_NEIGHBOR_DISTANCE = uint64(0) - -var FurthestNeighborLock sync.RWMutex - -func configureFurthestNeighbor() { - INSTANCE.Events.Add.Attach(events.NewClosure(func(p *peer.Peer) { - FurthestNeighborLock.Lock() - defer FurthestNeighborLock.Unlock() - - distance := OWN_DISTANCE(p) - if distance > FURTHEST_NEIGHBOR_DISTANCE { - FURTHEST_NEIGHBOR = p - FURTHEST_NEIGHBOR_DISTANCE = distance - } - })) - - INSTANCE.Events.Remove.Attach(events.NewClosure(func(p *peer.Peer) { - FurthestNeighborLock.Lock() - defer FurthestNeighborLock.Unlock() - - if p == FURTHEST_NEIGHBOR { - FURTHEST_NEIGHBOR_DISTANCE = uint64(0) - FURTHEST_NEIGHBOR = nil - - for _, furthestNeighborCandidate := range INSTANCE.Peers.GetMap() { - distance := OWN_DISTANCE(furthestNeighborCandidate) - if distance > FURTHEST_NEIGHBOR_DISTANCE { - FURTHEST_NEIGHBOR = furthestNeighborCandidate - FURTHEST_NEIGHBOR_DISTANCE = distance - } - } - } - })) -} diff --git a/plugins/autopeering/instances/chosenneighbors/instance.go b/plugins/autopeering/instances/chosenneighbors/instance.go deleted file mode 100644 index c7deb649fb..0000000000 --- a/plugins/autopeering/instances/chosenneighbors/instance.go +++ /dev/null @@ -1,5 +0,0 @@ -package chosenneighbors - -import "github.com/iotaledger/goshimmer/plugins/autopeering/types/peerregister" - -var INSTANCE = peerregister.New() diff --git a/plugins/autopeering/instances/chosenneighbors/plugin.go b/plugins/autopeering/instances/chosenneighbors/plugin.go deleted file mode 100644 index 0e1224fc75..0000000000 --- a/plugins/autopeering/instances/chosenneighbors/plugin.go +++ /dev/null @@ -1,11 +0,0 @@ -package chosenneighbors - -import ( - "github.com/iotaledger/goshimmer/packages/node" -) - -func Configure(plugin *node.Plugin) { - configureCandidates() - configureOwnDistance() - configureFurthestNeighbor() -} diff --git a/plugins/autopeering/instances/entrynodes/instance.go b/plugins/autopeering/instances/entrynodes/instance.go deleted file mode 100644 index 31e94076f4..0000000000 --- a/plugins/autopeering/instances/entrynodes/instance.go +++ /dev/null @@ -1,83 +0,0 @@ -package entrynodes - -import ( - "encoding/hex" - "net" - "strconv" - "strings" - - "github.com/iotaledger/goshimmer/packages/identity" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peerlist" -) - -var INSTANCE *peerlist.PeerList - -func Configure(node *node.Plugin) { - INSTANCE = parseEntryNodes() -} - -func parseEntryNodes() *peerlist.PeerList { - result := peerlist.NewPeerList() - - for _, entryNodeDefinition := range strings.Fields(*parameters.ENTRY_NODES.Value) { - if entryNodeDefinition == "" { - continue - } - - entryNode := &peer.Peer{} - - identityBits := strings.Split(entryNodeDefinition, "@") - if len(identityBits) != 2 { - panic("error while parsing identity of entry node: " + entryNodeDefinition) - } - if decodedIdentifier, err := hex.DecodeString(identityBits[0]); err != nil { - panic("error while parsing identity of entry node: " + entryNodeDefinition) - } else { - entryNode.SetIdentity(&identity.Identity{ - Identifier: decodedIdentifier, - StringIdentifier: identityBits[0], - }) - } - - addressBits := strings.Split(identityBits[1], ":") - switch len(addressBits) { - case 2: - host := addressBits[0] - port, err := strconv.Atoi(addressBits[1]) - if err != nil { - panic("error while parsing port of entry in list of entry nodes") - } - - ip := net.ParseIP(host) - if ip == nil { - panic("error while parsing ip of entry in list of entry nodes") - } - - entryNode.SetAddress(ip) - entryNode.SetPeeringPort(uint16(port)) - case 6: - host := strings.Join(addressBits[:5], ":") - port, err := strconv.Atoi(addressBits[5]) - if err != nil { - panic("error while parsing port of entry in list of entry nodes") - } - - ip := net.ParseIP(host) - if ip == nil { - panic("error while parsing ip of entry in list of entry nodes") - } - - entryNode.SetAddress(ip) - entryNode.SetPeeringPort(uint16(port)) - default: - panic("invalid entry in list of trusted entry nodes: " + entryNodeDefinition) - } - - result.AddPeer(entryNode) - } - - return result -} diff --git a/plugins/autopeering/instances/knownpeers/instance.go b/plugins/autopeering/instances/knownpeers/instance.go deleted file mode 100644 index 1cf3c56db7..0000000000 --- a/plugins/autopeering/instances/knownpeers/instance.go +++ /dev/null @@ -1,22 +0,0 @@ -package knownpeers - -import ( - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/entrynodes" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peerregister" -) - -var INSTANCE *peerregister.PeerRegister - -func Configure(plugin *node.Plugin) { - INSTANCE = initKnownPeers() -} - -func initKnownPeers() *peerregister.PeerRegister { - knownPeers := peerregister.New() - for _, entryNode := range entrynodes.INSTANCE.GetPeers() { - knownPeers.AddOrUpdate(entryNode) - } - - return knownPeers -} diff --git a/plugins/autopeering/instances/neighborhood/events.go b/plugins/autopeering/instances/neighborhood/events.go deleted file mode 100644 index b748822f60..0000000000 --- a/plugins/autopeering/instances/neighborhood/events.go +++ /dev/null @@ -1,31 +0,0 @@ -package neighborhood - -import "reflect" - -var Events = moduleEvents{ - Update: &callbackEvent{make(map[uintptr]Callback)}, -} - -type moduleEvents struct { - Update *callbackEvent -} - -type callbackEvent struct { - callbacks map[uintptr]Callback -} - -func (this *callbackEvent) Attach(callback Callback) { - this.callbacks[reflect.ValueOf(callback).Pointer()] = callback -} - -func (this *callbackEvent) Detach(callback Callback) { - delete(this.callbacks, reflect.ValueOf(callback).Pointer()) -} - -func (this *callbackEvent) Trigger() { - for _, callback := range this.callbacks { - callback() - } -} - -type Callback = func() diff --git a/plugins/autopeering/instances/neighborhood/instance.go b/plugins/autopeering/instances/neighborhood/instance.go deleted file mode 100644 index 8c693d0ffa..0000000000 --- a/plugins/autopeering/instances/neighborhood/instance.go +++ /dev/null @@ -1,54 +0,0 @@ -package neighborhood - -import ( - "time" - - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/packages/timeutil" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/outgoingrequest" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peerlist" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peerregister" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/request" -) - -var INSTANCE *peerregister.PeerRegister - -var LIST_INSTANCE *peerlist.PeerList - -// Selects a fixed neighborhood from all known peers - this allows nodes to "stay in the same circles" that share their -// view on the ledger an is a preparation for economic clustering -var NEIGHBORHOOD_SELECTOR = func(this *peerregister.PeerRegister, req *request.Request) *peerregister.PeerRegister { - filteredPeers := peerregister.New() - for id, peer := range this.Peers.GetMap() { - filteredPeers.Peers.Store(id, peer) - } - - return filteredPeers -} - -var lastUpdate = time.Now() - -func Configure(plugin *node.Plugin) { - LIST_INSTANCE = peerlist.NewPeerList() - updateNeighborHood() -} - -func Run(plugin *node.Plugin) { - daemon.BackgroundWorker("Neighborhood Updater", func() { - timeutil.Ticker(updateNeighborHood, 1*time.Second) - }) -} - -func updateNeighborHood() { - if INSTANCE == nil || float64(INSTANCE.Peers.Len())*1.2 <= float64(knownpeers.INSTANCE.Peers.Len()) || lastUpdate.Before(time.Now().Add(-300*time.Second)) { - INSTANCE = knownpeers.INSTANCE.Filter(NEIGHBORHOOD_SELECTOR, outgoingrequest.INSTANCE) - - LIST_INSTANCE.Update(INSTANCE.List()) - - lastUpdate = time.Now() - - Events.Update.Trigger() - } -} diff --git a/plugins/autopeering/instances/outgoingrequest/instance.go b/plugins/autopeering/instances/outgoingrequest/instance.go deleted file mode 100644 index 6fdf7a79e3..0000000000 --- a/plugins/autopeering/instances/outgoingrequest/instance.go +++ /dev/null @@ -1,23 +0,0 @@ -package outgoingrequest - -import ( - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/ownpeer" - "github.com/iotaledger/goshimmer/plugins/autopeering/saltmanager" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/request" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/salt" -) - -var INSTANCE *request.Request - -func Configure(plugin *node.Plugin) { - INSTANCE = &request.Request{ - Issuer: ownpeer.INSTANCE, - } - INSTANCE.Sign() - - saltmanager.Events.UpdatePublicSalt.Attach(events.NewClosure(func(salt *salt.Salt) { - INSTANCE.Sign() - })) -} diff --git a/plugins/autopeering/instances/ownpeer/instance.go b/plugins/autopeering/instances/ownpeer/instance.go deleted file mode 100644 index 39f7cc552a..0000000000 --- a/plugins/autopeering/instances/ownpeer/instance.go +++ /dev/null @@ -1,24 +0,0 @@ -package ownpeer - -import ( - "net" - - "github.com/iotaledger/goshimmer/packages/accountability" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" - "github.com/iotaledger/goshimmer/plugins/autopeering/saltmanager" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" - "github.com/iotaledger/goshimmer/plugins/gossip" -) - -var INSTANCE *peer.Peer - -func Configure(plugin *node.Plugin) { - INSTANCE = &peer.Peer{} - INSTANCE.SetIdentity(accountability.OwnId()) - INSTANCE.SetPeeringPort(uint16(*parameters.PORT.Value)) - INSTANCE.SetGossipPort(uint16(*gossip.PORT.Value)) - INSTANCE.SetAddress(net.IPv4(0, 0, 0, 0)) - INSTANCE.SetSalt(saltmanager.PUBLIC_SALT) - -} diff --git a/plugins/autopeering/instances/plugin.go b/plugins/autopeering/instances/plugin.go deleted file mode 100644 index ed02fdf6ab..0000000000 --- a/plugins/autopeering/instances/plugin.go +++ /dev/null @@ -1,26 +0,0 @@ -package instances - -import ( - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/entrynodes" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/neighborhood" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/outgoingrequest" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/ownpeer" -) - -func Configure(plugin *node.Plugin) { - ownpeer.Configure(plugin) - entrynodes.Configure(plugin) - knownpeers.Configure(plugin) - neighborhood.Configure(plugin) - outgoingrequest.Configure(plugin) - chosenneighbors.Configure(plugin) - acceptedneighbors.Configure(plugin) -} - -func Run(plugin *node.Plugin) { - neighborhood.Run(plugin) -} diff --git a/plugins/autopeering/parameters/parameters.go b/plugins/autopeering/parameters/parameters.go deleted file mode 100644 index 8332389119..0000000000 --- a/plugins/autopeering/parameters/parameters.go +++ /dev/null @@ -1,11 +0,0 @@ -package parameters - -import "github.com/iotaledger/goshimmer/packages/parameter" - -var ( - ADDRESS = parameter.AddString("AUTOPEERING/ADDRESS", "0.0.0.0", "address to bind for incoming peering requests") - ENTRY_NODES = parameter.AddString("AUTOPEERING/ENTRY_NODES", "7f7a876a4236091257e650da8dcf195fbe3cb625@159.69.158.51:14626", "list of trusted entry nodes for auto peering") - PORT = parameter.AddInt("AUTOPEERING/PORT", 14626, "tcp port for incoming peering requests") - ACCEPT_REQUESTS = parameter.AddBool("AUTOPEERING/ACCEPT_REQUESTS", true, "accept incoming autopeering requests") - SEND_REQUESTS = parameter.AddBool("AUTOPEERING/SEND_REQUESTS", true, "send autopeering requests") -) diff --git a/plugins/autopeering/peerstorage/peerstorage.go b/plugins/autopeering/peerstorage/peerstorage.go deleted file mode 100644 index 5f205decee..0000000000 --- a/plugins/autopeering/peerstorage/peerstorage.go +++ /dev/null @@ -1,88 +0,0 @@ -package peerstorage - -import ( - "bytes" - "strconv" - "sync" - - "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" -) - -const peerDbName string = "peers" - -var peerDb database.Database -var once sync.Once - -func initDb() { - db, err := database.Get(peerDbName) - if err != nil { - panic(err) - } - - peerDb = db -} - -func getDb() database.Database { - once.Do(initDb) - - return peerDb -} - -func storePeer(p *peer.Peer) { - err := getDb().Set(p.GetIdentity().Identifier, p.Marshal()) - if err != nil { - panic(err) - } -} - -func removePeer(p *peer.Peer) { - err := getDb().Delete(p.GetIdentity().Identifier) - if err != nil { - panic(err) - } -} - -func loadPeers(plugin *node.Plugin) { - var count int - - err := getDb().ForEach(func(key []byte, value []byte) { - peer, err := peer.Unmarshal(value) - if err != nil { - panic(err) - } - // the peers are stored by identifier in the db - if !bytes.Equal(key, peer.GetIdentity().Identifier) { - panic("Invalid item in '" + peerDbName + "' database") - } - - knownpeers.INSTANCE.AddOrUpdate(peer) - count++ - plugin.LogDebug("Added stored peer: " + peer.GetAddress().String() + " / " + peer.GetIdentity().StringIdentifier) - }) - if err != nil { - panic(err) - } - - plugin.LogSuccess("Restored " + strconv.Itoa(count) + " peers from database") -} - -func Configure(plugin *node.Plugin) { - // do not store the entry nodes by ignoring all peers currently contained in konwnpeers - // add peers from db - loadPeers(plugin) - - // subscribe to all known peers' events - knownpeers.INSTANCE.Events.Add.Attach(events.NewClosure(func(p *peer.Peer) { - storePeer(p) - })) - knownpeers.INSTANCE.Events.Update.Attach(events.NewClosure(func(p *peer.Peer) { - storePeer(p) - })) - knownpeers.INSTANCE.Events.Remove.Attach(events.NewClosure(func(p *peer.Peer) { - removePeer(p) - })) -} diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 430e3a7a25..b5e9e5ffad 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -1,83 +1,53 @@ package autopeering import ( + "net" + + "github.com/iotaledger/autopeering-sim/discover" + "github.com/iotaledger/autopeering-sim/selection" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" - "github.com/iotaledger/goshimmer/plugins/autopeering/peerstorage" - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol" - "github.com/iotaledger/goshimmer/plugins/autopeering/saltmanager" - "github.com/iotaledger/goshimmer/plugins/autopeering/server" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" "github.com/iotaledger/goshimmer/plugins/gossip" + "github.com/iotaledger/hive.go/events" ) -var PLUGIN = node.NewPlugin("Auto Peering", node.Enabled, configure, run) - func configure(plugin *node.Plugin) { - saltmanager.Configure(plugin) - instances.Configure(plugin) - server.Configure(plugin) - protocol.Configure(plugin) - peerstorage.Configure(plugin) - daemon.Events.Shutdown.Attach(events.NewClosure(func() { - server.Shutdown(plugin) + close <- struct{}{} })) configureLogging(plugin) } func run(plugin *node.Plugin) { - instances.Run(plugin) - server.Run(plugin) - protocol.Run(plugin) + go start() } func configureLogging(plugin *node.Plugin) { gossip.Events.RemoveNeighbor.Attach(events.NewClosure(func(peer *gossip.Neighbor) { - chosenneighbors.INSTANCE.Remove(peer.GetIdentity().StringIdentifier) - acceptedneighbors.INSTANCE.Remove(peer.GetIdentity().StringIdentifier) - })) - - acceptedneighbors.INSTANCE.Events.Add.Attach(events.NewClosure(func(p *peer.Peer) { - plugin.LogDebug("accepted neighbor added: " + p.GetAddress().String() + " / " + p.GetIdentity().StringIdentifier) - - gossip.AddNeighbor(gossip.NewNeighbor(p.GetIdentity(), p.GetAddress(), p.GetGossipPort())) + Selection.DropPeer(peer.Peer) })) - acceptedneighbors.INSTANCE.Events.Remove.Attach(events.NewClosure(func(p *peer.Peer) { - plugin.LogDebug("accepted neighbor removed: " + p.GetAddress().String() + " / " + p.GetIdentity().StringIdentifier) - gossip.RemoveNeighbor(p.GetIdentity().StringIdentifier) + selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) { + plugin.LogDebug("neighbor removed: " + ev.DroppedID.String()) + gossip.RemoveNeighbor(ev.DroppedID.String()) })) - chosenneighbors.INSTANCE.Events.Add.Attach(events.NewClosure(func(p *peer.Peer) { - plugin.LogDebug("chosen neighbor added: " + p.GetAddress().String() + " / " + p.GetIdentity().StringIdentifier) - - gossip.AddNeighbor(gossip.NewNeighbor(p.GetIdentity(), p.GetAddress(), p.GetGossipPort())) + selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { + plugin.LogDebug("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) + address, _, _ := net.SplitHostPort(ev.Peer.Address()) + port := ev.Services["gossip"].Address + gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port)) })) - chosenneighbors.INSTANCE.Events.Remove.Attach(events.NewClosure(func(p *peer.Peer) { - plugin.LogDebug("chosen neighbor removed: " + p.GetAddress().String() + " / " + p.GetIdentity().StringIdentifier) - - gossip.RemoveNeighbor(p.GetIdentity().StringIdentifier) - })) - - knownpeers.INSTANCE.Events.Add.Attach(events.NewClosure(func(p *peer.Peer) { - plugin.LogInfo("new peer discovered: " + p.GetAddress().String() + " / " + p.GetIdentity().StringIdentifier) - if _, exists := gossip.GetNeighbor(p.GetIdentity().StringIdentifier); exists { - gossip.AddNeighbor(gossip.NewNeighbor(p.GetIdentity(), p.GetAddress(), p.GetGossipPort())) - } + selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { + plugin.LogDebug("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) + address, _, _ := net.SplitHostPort(ev.Peer.Address()) + port := ev.Services["gossip"].Address + gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port)) })) - knownpeers.INSTANCE.Events.Update.Attach(events.NewClosure(func(p *peer.Peer) { - plugin.LogDebug("peer updated: " + p.GetAddress().String() + " / " + p.GetIdentity().StringIdentifier) - if _, exists := gossip.GetNeighbor(p.GetIdentity().StringIdentifier); exists { - gossip.AddNeighbor(gossip.NewNeighbor(p.GetIdentity(), p.GetAddress(), p.GetGossipPort())) - } + discover.Events.PeerDiscovered.Attach(events.NewClosure(func(ev *discover.DiscoveredEvent) { + plugin.LogInfo("new peer discovered: " + ev.Peer.Address() + " / " + ev.Peer.ID().String()) })) } diff --git a/plugins/autopeering/protocol/accepted_neighbor_dropper.go b/plugins/autopeering/protocol/accepted_neighbor_dropper.go deleted file mode 100644 index f11c9169cd..0000000000 --- a/plugins/autopeering/protocol/accepted_neighbor_dropper.go +++ /dev/null @@ -1,40 +0,0 @@ -package protocol - -import ( - "time" - - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/packages/timeutil" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/ownpeer" - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants" - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/types" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/drop" -) - -func createAcceptedNeighborDropper(plugin *node.Plugin) func() { - return func() { - timeutil.Ticker(func() { - if acceptedneighbors.INSTANCE.Peers.Len() > constants.NEIGHBOR_COUNT/2 { - defer acceptedneighbors.INSTANCE.Lock()() - for acceptedneighbors.INSTANCE.Peers.Len() > constants.NEIGHBOR_COUNT/2 { - acceptedneighbors.FurthestNeighborLock.RLock() - furthestNeighbor := acceptedneighbors.FURTHEST_NEIGHBOR - acceptedneighbors.FurthestNeighborLock.RUnlock() - - if furthestNeighbor != nil { - dropMessage := &drop.Drop{Issuer: ownpeer.INSTANCE} - dropMessage.Sign() - - acceptedneighbors.INSTANCE.Remove(furthestNeighbor.GetIdentity().StringIdentifier) - go func() { - if _, err := furthestNeighbor.Send(dropMessage.Marshal(), types.PROTOCOL_TYPE_UDP, false); err != nil { - plugin.LogDebug("error when sending drop message to" + acceptedneighbors.FURTHEST_NEIGHBOR.String()) - } - }() - } - } - } - }, 1*time.Second) - } -} diff --git a/plugins/autopeering/protocol/chosen_neighbor_dropper.go b/plugins/autopeering/protocol/chosen_neighbor_dropper.go deleted file mode 100644 index 23d2353302..0000000000 --- a/plugins/autopeering/protocol/chosen_neighbor_dropper.go +++ /dev/null @@ -1,40 +0,0 @@ -package protocol - -import ( - "time" - - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/packages/timeutil" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/ownpeer" - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants" - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/types" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/drop" -) - -func createChosenNeighborDropper(plugin *node.Plugin) func() { - return func() { - timeutil.Ticker(func() { - if chosenneighbors.INSTANCE.Peers.Len() > constants.NEIGHBOR_COUNT/2 { - defer chosenneighbors.INSTANCE.Lock()() - for chosenneighbors.INSTANCE.Peers.Len() > constants.NEIGHBOR_COUNT/2 { - chosenneighbors.FurthestNeighborLock.RLock() - furthestNeighbor := chosenneighbors.FURTHEST_NEIGHBOR - chosenneighbors.FurthestNeighborLock.RUnlock() - - if furthestNeighbor != nil { - dropMessage := &drop.Drop{Issuer: ownpeer.INSTANCE} - dropMessage.Sign() - - chosenneighbors.INSTANCE.Remove(furthestNeighbor.GetIdentity().StringIdentifier) - go func() { - if _, err := furthestNeighbor.Send(dropMessage.Marshal(), types.PROTOCOL_TYPE_UDP, false); err != nil { - plugin.LogDebug("error when sending drop message to" + chosenneighbors.FURTHEST_NEIGHBOR.String()) - } - }() - } - } - } - }, 1*time.Second) - } -} diff --git a/plugins/autopeering/protocol/constants/constants.go b/plugins/autopeering/protocol/constants/constants.go deleted file mode 100644 index 10e60f30ca..0000000000 --- a/plugins/autopeering/protocol/constants/constants.go +++ /dev/null @@ -1,18 +0,0 @@ -package constants - -import "time" - -const ( - NEIGHBOR_COUNT = 8 - - FIND_NEIGHBOR_INTERVAL = 10 * time.Second - - // How often does the outgoing ping processor check if new pings should be sent. - PING_PROCESS_INTERVAL = 1 * time.Second - - // The amount of times each neighbor should be contacted in this cycle. - PING_CONTACT_COUNT_PER_CYCLE = 2 - - // The length of a ping cycle (after this time we have sent randomized pings to all of our neighbors). - PING_CYCLE_LENGTH = 900 * time.Second -) diff --git a/plugins/autopeering/protocol/error_handler.go b/plugins/autopeering/protocol/error_handler.go deleted file mode 100644 index a97e5bf762..0000000000 --- a/plugins/autopeering/protocol/error_handler.go +++ /dev/null @@ -1,14 +0,0 @@ -package protocol - -import ( - "net" - - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/packages/node" -) - -func createErrorHandler(plugin *node.Plugin) *events.Closure { - return events.NewClosure(func(ip net.IP, err error) { - plugin.LogDebug("error when communicating with " + ip.String() + ": " + err.Error()) - }) -} diff --git a/plugins/autopeering/protocol/incoming_drop_processor.go b/plugins/autopeering/protocol/incoming_drop_processor.go deleted file mode 100644 index 60909e0a81..0000000000 --- a/plugins/autopeering/protocol/incoming_drop_processor.go +++ /dev/null @@ -1,18 +0,0 @@ -package protocol - -import ( - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/drop" -) - -func createIncomingDropProcessor(plugin *node.Plugin) *events.Closure { - return events.NewClosure(func(drop *drop.Drop) { - plugin.LogDebug("received drop message from " + drop.Issuer.String()) - - chosenneighbors.INSTANCE.Remove(drop.Issuer.GetIdentity().StringIdentifier) - acceptedneighbors.INSTANCE.Remove(drop.Issuer.GetIdentity().StringIdentifier) - }) -} diff --git a/plugins/autopeering/protocol/incoming_ping_processor.go b/plugins/autopeering/protocol/incoming_ping_processor.go deleted file mode 100644 index 39124bfa6d..0000000000 --- a/plugins/autopeering/protocol/incoming_ping_processor.go +++ /dev/null @@ -1,19 +0,0 @@ -package protocol - -import ( - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/ping" -) - -func createIncomingPingProcessor(plugin *node.Plugin) *events.Closure { - return events.NewClosure(func(ping *ping.Ping) { - plugin.LogDebug("received ping from " + ping.Issuer.String()) - - knownpeers.INSTANCE.AddOrUpdate(ping.Issuer) - for _, neighbor := range ping.Neighbors.GetPeers() { - knownpeers.INSTANCE.AddOrUpdate(neighbor) - } - }) -} diff --git a/plugins/autopeering/protocol/incoming_request_processor.go b/plugins/autopeering/protocol/incoming_request_processor.go deleted file mode 100644 index dcad375195..0000000000 --- a/plugins/autopeering/protocol/incoming_request_processor.go +++ /dev/null @@ -1,78 +0,0 @@ -package protocol - -import ( - "math/rand" - - "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" - - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/neighborhood" - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peerlist" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/request" -) - -func createIncomingRequestProcessor(plugin *node.Plugin) *events.Closure { - return events.NewClosure(func(req *request.Request) { - go processIncomingRequest(plugin, req) - }) -} - -func processIncomingRequest(plugin *node.Plugin, req *request.Request) { - plugin.LogDebug("received peering request from " + req.Issuer.String()) - - knownpeers.INSTANCE.AddOrUpdate(req.Issuer) - - if *parameters.ACCEPT_REQUESTS.Value && requestShouldBeAccepted(req) { - defer acceptedneighbors.INSTANCE.Lock()() - - if requestShouldBeAccepted(req) { - acceptedneighbors.INSTANCE.AddOrUpdate(req.Issuer) - - acceptRequest(plugin, req) - - return - } - } - - rejectRequest(plugin, req) -} - -func requestShouldBeAccepted(req *request.Request) bool { - return acceptedneighbors.INSTANCE.Peers.Len() < constants.NEIGHBOR_COUNT/2 || - acceptedneighbors.INSTANCE.Contains(req.Issuer.GetIdentity().StringIdentifier) || - acceptedneighbors.OWN_DISTANCE(req.Issuer) < acceptedneighbors.FURTHEST_NEIGHBOR_DISTANCE -} - -func acceptRequest(plugin *node.Plugin, req *request.Request) { - if err := req.Accept(generateProposedPeeringCandidates(req).GetPeers()); err != nil { - plugin.LogDebug("error when sending response to" + req.Issuer.String()) - } - - plugin.LogDebug("sent positive peering response to " + req.Issuer.String()) - - acceptedneighbors.INSTANCE.AddOrUpdate(req.Issuer) -} - -func rejectRequest(plugin *node.Plugin, req *request.Request) { - if err := req.Reject(generateProposedPeeringCandidates(req).GetPeers()); err != nil { - plugin.LogDebug("error when sending response to" + req.Issuer.String()) - } - - plugin.LogDebug("sent negative peering response to " + req.Issuer.String()) -} - -func generateProposedPeeringCandidates(req *request.Request) *peerlist.PeerList { - proposedPeers := neighborhood.LIST_INSTANCE.Filter(func(p *peer.Peer) bool { - return p.GetIdentity().PublicKey != nil - }) - rand.Shuffle(proposedPeers.Len(), func(i, j int) { - proposedPeers.SwapPeers(i, j) - }) - - return proposedPeers -} diff --git a/plugins/autopeering/protocol/incoming_response_processor.go b/plugins/autopeering/protocol/incoming_response_processor.go deleted file mode 100644 index 56324d540b..0000000000 --- a/plugins/autopeering/protocol/incoming_response_processor.go +++ /dev/null @@ -1,34 +0,0 @@ -package protocol - -import ( - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/response" -) - -func createIncomingResponseProcessor(plugin *node.Plugin) *events.Closure { - return events.NewClosure(func(peeringResponse *response.Response) { - go processIncomingResponse(plugin, peeringResponse) - }) -} - -func processIncomingResponse(plugin *node.Plugin, peeringResponse *response.Response) { - plugin.LogDebug("received peering response from " + peeringResponse.Issuer.String()) - - if conn := peeringResponse.Issuer.GetConn(); conn != nil { - _ = conn.Close() - } - - knownpeers.INSTANCE.AddOrUpdate(peeringResponse.Issuer) - for _, peer := range peeringResponse.Peers { - knownpeers.INSTANCE.AddOrUpdate(peer) - } - - if peeringResponse.Type == response.TYPE_ACCEPT { - defer chosenneighbors.INSTANCE.Lock()() - - chosenneighbors.INSTANCE.AddOrUpdate(peeringResponse.Issuer) - } -} diff --git a/plugins/autopeering/protocol/outgoing_ping_processor.go b/plugins/autopeering/protocol/outgoing_ping_processor.go deleted file mode 100644 index 2ac0d02dcd..0000000000 --- a/plugins/autopeering/protocol/outgoing_ping_processor.go +++ /dev/null @@ -1,86 +0,0 @@ -package protocol - -import ( - "math/rand" - "time" - - "github.com/iotaledger/goshimmer/packages/accountability" - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/neighborhood" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/ownpeer" - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants" - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/types" - "github.com/iotaledger/goshimmer/plugins/autopeering/saltmanager" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/ping" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/salt" -) - -var lastPing time.Time - -func createOutgoingPingProcessor(plugin *node.Plugin) func() { - return func() { - plugin.LogInfo("Starting Ping Processor ...") - plugin.LogSuccess("Starting Ping Processor ... done") - - lastPing = time.Now().Add(-constants.PING_CYCLE_LENGTH) - - outgoingPing := &ping.Ping{ - Issuer: ownpeer.INSTANCE, - } - outgoingPing.Sign() - - saltmanager.Events.UpdatePublicSalt.Attach(events.NewClosure(func(salt *salt.Salt) { - outgoingPing.Sign() - })) - - pingPeers(plugin, outgoingPing) - - ticker := time.NewTicker(constants.PING_PROCESS_INTERVAL) - ticker: - for { - select { - case <-daemon.ShutdownSignal: - plugin.LogInfo("Stopping Ping Processor ...") - - break ticker - case <-ticker.C: - pingPeers(plugin, outgoingPing) - } - } - - plugin.LogSuccess("Stopping Ping Processor ... done") - } -} - -func pingPeers(plugin *node.Plugin, outgoingPing *ping.Ping) { - if neighborhood.LIST_INSTANCE.Len() >= 1 { - pingDelay := constants.PING_CYCLE_LENGTH / time.Duration(neighborhood.LIST_INSTANCE.Len()) - - if lastPing.Add(pingDelay).Before(time.Now()) { - chosenPeers := make(map[string]*peer.Peer) - - for i := 0; i < constants.PING_CONTACT_COUNT_PER_CYCLE; i++ { - randomNeighborHoodPeer := neighborhood.LIST_INSTANCE.GetPeers()[rand.Intn(neighborhood.LIST_INSTANCE.Len())] - - if randomNeighborHoodPeer.GetIdentity().StringIdentifier != accountability.OwnId().StringIdentifier { - chosenPeers[randomNeighborHoodPeer.GetIdentity().StringIdentifier] = randomNeighborHoodPeer - } - } - - for _, chosenPeer := range chosenPeers { - go func(chosenPeer *peer.Peer) { - if _, err := chosenPeer.Send(outgoingPing.Marshal(), types.PROTOCOL_TYPE_UDP, false); err != nil { - plugin.LogDebug("error when sending ping to " + chosenPeer.String() + ": " + err.Error()) - } else { - plugin.LogDebug("sent ping to " + chosenPeer.String()) - } - }(chosenPeer) - } - - lastPing = time.Now() - } - } -} diff --git a/plugins/autopeering/protocol/outgoing_request_processor.go b/plugins/autopeering/protocol/outgoing_request_processor.go deleted file mode 100644 index f36c08af7c..0000000000 --- a/plugins/autopeering/protocol/outgoing_request_processor.go +++ /dev/null @@ -1,85 +0,0 @@ -package protocol - -import ( - "time" - - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/outgoingrequest" - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/types" - "github.com/iotaledger/goshimmer/plugins/autopeering/server/tcp" - - "github.com/iotaledger/goshimmer/packages/timeutil" - - "github.com/iotaledger/goshimmer/packages/accountability" - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" -) - -func createOutgoingRequestProcessor(plugin *node.Plugin) func() { - return func() { - plugin.LogInfo("Starting Chosen Neighbor Processor ...") - plugin.LogSuccess("Starting Chosen Neighbor Processor ... done") - - sendOutgoingRequests(plugin) - - ticker := time.NewTicker(constants.FIND_NEIGHBOR_INTERVAL) - ticker: - for { - select { - case <-daemon.ShutdownSignal: - plugin.LogInfo("Stopping Chosen Neighbor Processor ...") - - break ticker - case <-ticker.C: - sendOutgoingRequests(plugin) - } - } - - plugin.LogSuccess("Stopping Chosen Neighbor Processor ... done") - } -} - -func sendOutgoingRequests(plugin *node.Plugin) { - for _, chosenNeighborCandidate := range chosenneighbors.CANDIDATES.GetPeers() { - timeutil.Sleep(5 * time.Second) - - if candidateShouldBeContacted(chosenNeighborCandidate) { - doneChan := make(chan int, 1) - - go func(doneChan chan int) { - if dialed, err := chosenNeighborCandidate.Send(outgoingrequest.INSTANCE.Marshal(), types.PROTOCOL_TYPE_TCP, true); err != nil { - plugin.LogDebug(err.Error()) - } else { - plugin.LogDebug("sent peering request to " + chosenNeighborCandidate.String()) - - if dialed { - tcp.HandleConnection(chosenNeighborCandidate.GetConn()) - } - } - - close(doneChan) - }(doneChan) - - select { - case <-daemon.ShutdownSignal: - return - case <-doneChan: - continue - } - } - } -} - -func candidateShouldBeContacted(candidate *peer.Peer) bool { - nodeId := candidate.GetIdentity().StringIdentifier - - chosenneighbors.FurthestNeighborLock.RLock() - defer chosenneighbors.FurthestNeighborLock.RUnlock() - - return (!acceptedneighbors.INSTANCE.Contains(nodeId) && !chosenneighbors.INSTANCE.Contains(nodeId) && - accountability.OwnId().StringIdentifier != nodeId) && (chosenneighbors.INSTANCE.Peers.Len() < constants.NEIGHBOR_COUNT/2 || - chosenneighbors.OWN_DISTANCE(candidate) < chosenneighbors.FURTHEST_NEIGHBOR_DISTANCE) -} diff --git a/plugins/autopeering/protocol/plugin.go b/plugins/autopeering/protocol/plugin.go deleted file mode 100644 index a72f522d80..0000000000 --- a/plugins/autopeering/protocol/plugin.go +++ /dev/null @@ -1,32 +0,0 @@ -package protocol - -import ( - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" - "github.com/iotaledger/goshimmer/plugins/autopeering/server/tcp" - "github.com/iotaledger/goshimmer/plugins/autopeering/server/udp" -) - -func Configure(plugin *node.Plugin) { - errorHandler := createErrorHandler(plugin) - - udp.Events.ReceiveDrop.Attach(createIncomingDropProcessor(plugin)) - udp.Events.ReceivePing.Attach(createIncomingPingProcessor(plugin)) - udp.Events.Error.Attach(errorHandler) - - tcp.Events.ReceiveRequest.Attach(createIncomingRequestProcessor(plugin)) - tcp.Events.ReceiveResponse.Attach(createIncomingResponseProcessor(plugin)) - tcp.Events.Error.Attach(errorHandler) -} - -func Run(plugin *node.Plugin) { - daemon.BackgroundWorker("Autopeering Chosen Neighbor Dropper", createChosenNeighborDropper(plugin)) - daemon.BackgroundWorker("Autopeering Accepted Neighbor Dropper", createAcceptedNeighborDropper(plugin)) - - if *parameters.SEND_REQUESTS.Value { - daemon.BackgroundWorker("Autopeering Outgoing Request Processor", createOutgoingRequestProcessor(plugin)) - } - - daemon.BackgroundWorker("Autopeering Outgoing Ping Processor", createOutgoingPingProcessor(plugin)) -} diff --git a/plugins/autopeering/protocol/types/constants.go b/plugins/autopeering/protocol/types/constants.go deleted file mode 100644 index a4dc301c99..0000000000 --- a/plugins/autopeering/protocol/types/constants.go +++ /dev/null @@ -1,9 +0,0 @@ -package types - -const ( - PROTOCOL_TYPE_TCP = ProtocolType(0) - PROTOCOL_TYPE_UDP = ProtocolType(1) - - ADDRESS_TYPE_IPV4 = AddressType(0) - ADDRESS_TYPE_IPV6 = AddressType(1) -) diff --git a/plugins/autopeering/protocol/types/types.go b/plugins/autopeering/protocol/types/types.go deleted file mode 100644 index 3b68f5dae3..0000000000 --- a/plugins/autopeering/protocol/types/types.go +++ /dev/null @@ -1,5 +0,0 @@ -package types - -type AddressType = byte - -type ProtocolType = byte diff --git a/plugins/autopeering/saltmanager/constants.go b/plugins/autopeering/saltmanager/constants.go deleted file mode 100644 index 4fe475f401..0000000000 --- a/plugins/autopeering/saltmanager/constants.go +++ /dev/null @@ -1,13 +0,0 @@ -package saltmanager - -import "time" - -const ( - PUBLIC_SALT_LIFETIME = 1800 * time.Second - PRIVATE_SALT_LIFETIME = 1800 * time.Second -) - -var ( - PUBLIC_SALT_SETTINGS_KEY = []byte("PUBLIC_SALT") - PRIVATE_SALT_SETTINGS_KEY = []byte("PRIVATE_SALT") -) diff --git a/plugins/autopeering/saltmanager/errors.go b/plugins/autopeering/saltmanager/errors.go deleted file mode 100644 index 4436630107..0000000000 --- a/plugins/autopeering/saltmanager/errors.go +++ /dev/null @@ -1,8 +0,0 @@ -package saltmanager - -import "github.com/pkg/errors" - -var ( - ErrPublicSaltExpired = errors.New("expired public salt in ping") - ErrPublicSaltInvalidLifetime = errors.New("invalid public salt lifetime in ping") -) diff --git a/plugins/autopeering/saltmanager/events.go b/plugins/autopeering/saltmanager/events.go deleted file mode 100644 index 26f207e738..0000000000 --- a/plugins/autopeering/saltmanager/events.go +++ /dev/null @@ -1,18 +0,0 @@ -package saltmanager - -import ( - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/salt" -) - -var Events = struct { - UpdatePublicSalt *events.Event - UpdatePrivateSalt *events.Event -}{ - UpdatePublicSalt: events.NewEvent(saltCaller), - UpdatePrivateSalt: events.NewEvent(saltCaller), -} - -func saltCaller(handler interface{}, params ...interface{}) { - handler.(func(*salt.Salt))(params[0].(*salt.Salt)) -} diff --git a/plugins/autopeering/saltmanager/saltmanager.go b/plugins/autopeering/saltmanager/saltmanager.go deleted file mode 100644 index 6cb06a9a13..0000000000 --- a/plugins/autopeering/saltmanager/saltmanager.go +++ /dev/null @@ -1,88 +0,0 @@ -package saltmanager - -import ( - "time" - - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/packages/settings" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/salt" -) - -var ( - PRIVATE_SALT *salt.Salt - PUBLIC_SALT *salt.Salt -) - -func Configure(plugin *node.Plugin) { - PRIVATE_SALT = createSalt(PRIVATE_SALT_SETTINGS_KEY, PRIVATE_SALT_LIFETIME, Events.UpdatePrivateSalt.Trigger) - PUBLIC_SALT = createSalt(PUBLIC_SALT_SETTINGS_KEY, PUBLIC_SALT_LIFETIME, Events.UpdatePublicSalt.Trigger) -} - -func generateNewSalt(key []byte, lifetime time.Duration) *salt.Salt { - newSalt := salt.New(lifetime) - - if err := settings.Set(key, newSalt.Marshal()); err != nil { - panic(err) - } - - return newSalt -} - -func getSalt(key []byte, lifetime time.Duration) *salt.Salt { - saltBytes, err := settings.Get(key) - if err != nil { - if err == database.ErrKeyNotFound { - return generateNewSalt(key, lifetime) - } else { - panic(err) - } - } - - if resultingSalt, err := salt.Unmarshal(saltBytes); err != nil { - panic(err) - } else { - return resultingSalt - } -} - -func updatePublicSalt(saltToUpdate *salt.Salt, settingsKey []byte, lifeSpan time.Duration, updateCallback func(params ...interface{})) { - newSalt := salt.New(lifeSpan) - - saltToUpdate.SetBytes(newSalt.GetBytes()) - saltToUpdate.SetExpirationTime(newSalt.GetExpirationTime()) - - if err := settings.Set(settingsKey, saltToUpdate.Marshal()); err != nil { - panic(err) - } - - updateCallback(saltToUpdate) - - scheduleUpdateForSalt(saltToUpdate, settingsKey, lifeSpan, updateCallback) -} - -func scheduleUpdateForSalt(saltToUpdate *salt.Salt, settingsKey []byte, lifeSpan time.Duration, callback func(params ...interface{})) { - now := time.Now() - - if saltToUpdate.GetExpirationTime().Before(now) { - updatePublicSalt(saltToUpdate, settingsKey, lifeSpan, callback) - } else { - daemon.BackgroundWorker("Salt Updater", func() { - select { - case <-time.After(saltToUpdate.GetExpirationTime().Sub(now)): - updatePublicSalt(saltToUpdate, settingsKey, lifeSpan, callback) - case <-daemon.ShutdownSignal: - return - } - }) - } -} - -func createSalt(settingsKey []byte, lifeSpan time.Duration, updateCallback func(params ...interface{})) *salt.Salt { - newSalt := getSalt(settingsKey, lifeSpan) - - scheduleUpdateForSalt(newSalt, settingsKey, lifeSpan, updateCallback) - - return newSalt -} diff --git a/plugins/autopeering/saltmanager/utils.go b/plugins/autopeering/saltmanager/utils.go deleted file mode 100644 index cdbfca9581..0000000000 --- a/plugins/autopeering/saltmanager/utils.go +++ /dev/null @@ -1,19 +0,0 @@ -package saltmanager - -import ( - "time" - - "github.com/iotaledger/goshimmer/plugins/autopeering/types/salt" -) - -func CheckSalt(saltToCheck *salt.Salt) error { - now := time.Now() - if saltToCheck.GetExpirationTime().Before(now.Add(-1 * time.Minute)) { - return ErrPublicSaltExpired - } - if saltToCheck.GetExpirationTime().After(now.Add(PUBLIC_SALT_LIFETIME + 1*time.Minute)) { - return ErrPublicSaltInvalidLifetime - } - - return nil -} diff --git a/plugins/autopeering/server/server.go b/plugins/autopeering/server/server.go deleted file mode 100644 index cf51cd303e..0000000000 --- a/plugins/autopeering/server/server.go +++ /dev/null @@ -1,22 +0,0 @@ -package server - -import ( - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/server/tcp" - "github.com/iotaledger/goshimmer/plugins/autopeering/server/udp" -) - -func Configure(plugin *node.Plugin) { - udp.ConfigureServer(plugin) - tcp.ConfigureServer(plugin) -} - -func Run(plugin *node.Plugin) { - udp.RunServer(plugin) - tcp.RunServer(plugin) -} - -func Shutdown(plugin *node.Plugin) { - udp.ShutdownUDPServer(plugin) - tcp.ShutdownServer(plugin) -} diff --git a/plugins/autopeering/server/tcp/constants.go b/plugins/autopeering/server/tcp/constants.go deleted file mode 100644 index c108d820e1..0000000000 --- a/plugins/autopeering/server/tcp/constants.go +++ /dev/null @@ -1,12 +0,0 @@ -package tcp - -import "time" - -const ( - IDLE_TIMEOUT = 5 * time.Second - - STATE_INITIAL = byte(0) - STATE_REQUEST = byte(1) - STATE_RESPONSE = byte(2) - STATE_PING = byte(3) -) diff --git a/plugins/autopeering/server/tcp/events.go b/plugins/autopeering/server/tcp/events.go deleted file mode 100644 index 2b9110fa40..0000000000 --- a/plugins/autopeering/server/tcp/events.go +++ /dev/null @@ -1,35 +0,0 @@ -package tcp - -import ( - "net" - - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/ping" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/request" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/response" -) - -var Events = struct { - ReceivePing *events.Event - ReceiveRequest *events.Event - ReceiveResponse *events.Event - Error *events.Event -}{ - events.NewEvent(pingCaller), - events.NewEvent(requestCaller), - events.NewEvent(responseCaller), - events.NewEvent(errorCaller), -} - -func pingCaller(handler interface{}, params ...interface{}) { - handler.(func(*ping.Ping))(params[0].(*ping.Ping)) -} -func requestCaller(handler interface{}, params ...interface{}) { - handler.(func(*request.Request))(params[0].(*request.Request)) -} -func responseCaller(handler interface{}, params ...interface{}) { - handler.(func(*response.Response))(params[0].(*response.Response)) -} -func errorCaller(handler interface{}, params ...interface{}) { - handler.(func(net.IP, error))(params[0].(net.IP), params[1].(error)) -} diff --git a/plugins/autopeering/server/tcp/server.go b/plugins/autopeering/server/tcp/server.go deleted file mode 100644 index 71d965b8dc..0000000000 --- a/plugins/autopeering/server/tcp/server.go +++ /dev/null @@ -1,225 +0,0 @@ -package tcp - -import ( - "math" - "net" - "strconv" - - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/packages/network" - "github.com/iotaledger/goshimmer/packages/network/tcp" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/ping" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/request" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/response" - "github.com/pkg/errors" -) - -var server = tcp.NewServer() - -func ConfigureServer(plugin *node.Plugin) { - server.Events.Connect.Attach(events.NewClosure(HandleConnection)) - server.Events.Error.Attach(events.NewClosure(func(err error) { - plugin.LogFailure("error in tcp server: " + err.Error()) - })) - server.Events.Start.Attach(events.NewClosure(func() { - if *parameters.ADDRESS.Value == "0.0.0.0" { - plugin.LogSuccess("Starting TCP Server (port " + strconv.Itoa(*parameters.PORT.Value) + ") ... done") - } else { - plugin.LogSuccess("Starting TCP Server (" + *parameters.ADDRESS.Value + ":" + strconv.Itoa(*parameters.PORT.Value) + ") ... done") - } - })) - server.Events.Shutdown.Attach(events.NewClosure(func() { - plugin.LogSuccess("Stopping TCP Server ... done") - })) -} - -func RunServer(plugin *node.Plugin) { - daemon.BackgroundWorker("Autopeering TCP Server", func() { - if *parameters.ADDRESS.Value == "0.0.0.0" { - plugin.LogInfo("Starting TCP Server (port " + strconv.Itoa(*parameters.PORT.Value) + ") ...") - } else { - plugin.LogInfo("Starting TCP Server (" + *parameters.ADDRESS.Value + ":" + strconv.Itoa(*parameters.PORT.Value) + ") ...") - } - - server.Listen(*parameters.PORT.Value) - }) -} - -func ShutdownServer(plugin *node.Plugin) { - plugin.LogInfo("Stopping TCP Server ...") - - server.Shutdown() -} - -func HandleConnection(conn *network.ManagedConnection) { - conn.SetTimeout(IDLE_TIMEOUT) - - var connectionState = STATE_INITIAL - var receiveBuffer []byte - var offset int - - conn.Events.ReceiveData.Attach(events.NewClosure(func(data []byte) { - ProcessIncomingPacket(&connectionState, &receiveBuffer, conn, data, &offset) - })) - - go conn.Read(make([]byte, int(math.Max(ping.MARSHALED_TOTAL_SIZE, math.Max(request.MARSHALED_TOTAL_SIZE, response.MARSHALED_TOTAL_SIZE))))) -} - -func ProcessIncomingPacket(connectionState *byte, receiveBuffer *[]byte, conn *network.ManagedConnection, data []byte, offset *int) { - if *connectionState == STATE_INITIAL { - var err error - if *connectionState, *receiveBuffer, err = parsePackageHeader(data); err != nil { - Events.Error.Trigger(conn.RemoteAddr().(*net.TCPAddr).IP, err) - - conn.Close() - - return - } - - *offset = 0 - - switch *connectionState { - case STATE_REQUEST: - *receiveBuffer = make([]byte, request.MARSHALED_TOTAL_SIZE) - case STATE_RESPONSE: - *receiveBuffer = make([]byte, response.MARSHALED_TOTAL_SIZE) - case STATE_PING: - *receiveBuffer = make([]byte, ping.MARSHALED_TOTAL_SIZE) - } - } - - switch *connectionState { - case STATE_REQUEST: - processIncomingRequestPacket(connectionState, receiveBuffer, conn, data, offset) - case STATE_RESPONSE: - processIncomingResponsePacket(connectionState, receiveBuffer, conn, data, offset) - case STATE_PING: - processIncomingPingPacket(connectionState, receiveBuffer, conn, data, offset) - } -} - -func parsePackageHeader(data []byte) (byte, []byte, error) { - var connectionState byte - var receiveBuffer []byte - - switch data[0] { - case request.MARSHALED_PACKET_HEADER: - receiveBuffer = make([]byte, request.MARSHALED_TOTAL_SIZE) - - connectionState = STATE_REQUEST - case response.MARHSALLED_PACKET_HEADER: - receiveBuffer = make([]byte, response.MARSHALED_TOTAL_SIZE) - - connectionState = STATE_RESPONSE - case ping.MARSHALED_PACKET_HEADER: - receiveBuffer = make([]byte, ping.MARSHALED_TOTAL_SIZE) - - connectionState = STATE_PING - default: - return 0, nil, errors.New("invalid package header") - } - - return connectionState, receiveBuffer, nil -} - -func processIncomingRequestPacket(connectionState *byte, receiveBuffer *[]byte, conn *network.ManagedConnection, data []byte, offset *int) { - remainingCapacity := int(math.Min(float64(request.MARSHALED_TOTAL_SIZE-*offset), float64(len(data)))) - - copy((*receiveBuffer)[*offset:], data[:remainingCapacity]) - - if *offset+len(data) < request.MARSHALED_TOTAL_SIZE { - *offset += len(data) - } else { - if req, err := request.Unmarshal(*receiveBuffer); err != nil { - Events.Error.Trigger(conn.RemoteAddr().(*net.TCPAddr).IP, err) - - conn.Close() - - return - } else { - req.Issuer.SetConn(conn) - req.Issuer.SetAddress(conn.RemoteAddr().(*net.TCPAddr).IP) - - conn.Events.Close.Attach(events.NewClosure(func() { - req.Issuer.SetConn(nil) - })) - - Events.ReceiveRequest.Trigger(req) - } - - *connectionState = STATE_INITIAL - - if *offset+len(data) > request.MARSHALED_TOTAL_SIZE { - ProcessIncomingPacket(connectionState, receiveBuffer, conn, data[remainingCapacity:], offset) - } - } -} - -func processIncomingResponsePacket(connectionState *byte, receiveBuffer *[]byte, conn *network.ManagedConnection, data []byte, offset *int) { - remainingCapacity := int(math.Min(float64(response.MARSHALED_TOTAL_SIZE-*offset), float64(len(data)))) - - copy((*receiveBuffer)[*offset:], data[:remainingCapacity]) - - if *offset+len(data) < response.MARSHALED_TOTAL_SIZE { - *offset += len(data) - } else { - if res, err := response.Unmarshal(*receiveBuffer); err != nil { - Events.Error.Trigger(conn.RemoteAddr().(*net.TCPAddr).IP, err) - - conn.Close() - - return - } else { - res.Issuer.SetConn(conn) - res.Issuer.SetAddress(conn.RemoteAddr().(*net.TCPAddr).IP) - - conn.Events.Close.Attach(events.NewClosure(func() { - res.Issuer.SetConn(nil) - })) - - Events.ReceiveResponse.Trigger(res) - } - - *connectionState = STATE_INITIAL - - if *offset+len(data) > response.MARSHALED_TOTAL_SIZE { - ProcessIncomingPacket(connectionState, receiveBuffer, conn, data[remainingCapacity:], offset) - } - } -} - -func processIncomingPingPacket(connectionState *byte, receiveBuffer *[]byte, conn *network.ManagedConnection, data []byte, offset *int) { - remainingCapacity := int(math.Min(float64(ping.MARSHALED_TOTAL_SIZE-*offset), float64(len(data)))) - - copy((*receiveBuffer)[*offset:], data[:remainingCapacity]) - - if *offset+len(data) < ping.MARSHALED_TOTAL_SIZE { - *offset += len(data) - } else { - if ping, err := ping.Unmarshal(*receiveBuffer); err != nil { - Events.Error.Trigger(conn.RemoteAddr().(*net.TCPAddr).IP, err) - - conn.Close() - - return - } else { - ping.Issuer.SetConn(conn) - ping.Issuer.SetAddress(conn.RemoteAddr().(*net.TCPAddr).IP) - - conn.Events.Close.Attach(events.NewClosure(func() { - ping.Issuer.SetConn(nil) - })) - - Events.ReceivePing.Trigger(ping) - } - - *connectionState = STATE_INITIAL - - if *offset+len(data) > ping.MARSHALED_TOTAL_SIZE { - ProcessIncomingPacket(connectionState, receiveBuffer, conn, data[remainingCapacity:], offset) - } - } -} diff --git a/plugins/autopeering/server/udp/events.go b/plugins/autopeering/server/udp/events.go deleted file mode 100644 index 6db7f3fc96..0000000000 --- a/plugins/autopeering/server/udp/events.go +++ /dev/null @@ -1,41 +0,0 @@ -package udp - -import ( - "net" - - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/drop" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/ping" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/request" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/response" -) - -var Events = struct { - ReceiveDrop *events.Event - ReceivePing *events.Event - ReceiveRequest *events.Event - ReceiveResponse *events.Event - Error *events.Event -}{ - events.NewEvent(dropCaller), - events.NewEvent(pingCaller), - events.NewEvent(requestCaller), - events.NewEvent(responseCaller), - events.NewEvent(errorCaller), -} - -func dropCaller(handler interface{}, params ...interface{}) { - handler.(func(*drop.Drop))(params[0].(*drop.Drop)) -} -func pingCaller(handler interface{}, params ...interface{}) { - handler.(func(*ping.Ping))(params[0].(*ping.Ping)) -} -func requestCaller(handler interface{}, params ...interface{}) { - handler.(func(*request.Request))(params[0].(*request.Request)) -} -func responseCaller(handler interface{}, params ...interface{}) { - handler.(func(*response.Response))(params[0].(*response.Response)) -} -func errorCaller(handler interface{}, params ...interface{}) { - handler.(func(net.IP, error))(params[0].(net.IP), params[1].(error)) -} diff --git a/plugins/autopeering/server/udp/server.go b/plugins/autopeering/server/udp/server.go deleted file mode 100644 index d79928e17d..0000000000 --- a/plugins/autopeering/server/udp/server.go +++ /dev/null @@ -1,98 +0,0 @@ -package udp - -import ( - "math" - "net" - "strconv" - - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/packages/network/udp" - "github.com/iotaledger/goshimmer/packages/node" - "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/drop" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/ping" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/request" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/response" - "github.com/pkg/errors" -) - -var udpServer = udp.NewServer(int(math.Max(float64(request.MARSHALED_TOTAL_SIZE), float64(response.MARSHALED_TOTAL_SIZE)))) - -func ConfigureServer(plugin *node.Plugin) { - Events.Error.Attach(events.NewClosure(func(ip net.IP, err error) { - plugin.LogFailure(err.Error()) - })) - - udpServer.Events.ReceiveData.Attach(events.NewClosure(processReceivedData)) - udpServer.Events.Error.Attach(events.NewClosure(func(err error) { - plugin.LogFailure("error in udp server: " + err.Error()) - })) - udpServer.Events.Start.Attach(events.NewClosure(func() { - if *parameters.ADDRESS.Value == "0.0.0.0" { - plugin.LogSuccess("Starting UDP Server (port " + strconv.Itoa(*parameters.PORT.Value) + ") ... done") - } else { - plugin.LogSuccess("Starting UDP Server (" + *parameters.ADDRESS.Value + ":" + strconv.Itoa(*parameters.PORT.Value) + ") ... done") - } - })) - udpServer.Events.Shutdown.Attach(events.NewClosure(func() { - plugin.LogSuccess("Stopping UDP Server ... done") - })) -} - -func RunServer(plugin *node.Plugin) { - daemon.BackgroundWorker("Autopeering UDP Server", func() { - if *parameters.ADDRESS.Value == "0.0.0.0" { - plugin.LogInfo("Starting UDP Server (port " + strconv.Itoa(*parameters.PORT.Value) + ") ...") - } else { - plugin.LogInfo("Starting UDP Server (" + *parameters.ADDRESS.Value + ":" + strconv.Itoa(*parameters.PORT.Value) + ") ...") - } - - udpServer.Listen(*parameters.ADDRESS.Value, *parameters.PORT.Value) - }) -} - -func ShutdownUDPServer(plugin *node.Plugin) { - plugin.LogInfo("Stopping UDP Server ...") - - udpServer.Shutdown() -} - -func processReceivedData(addr *net.UDPAddr, data []byte) { - switch data[0] { - case request.MARSHALED_PACKET_HEADER: - if peeringRequest, err := request.Unmarshal(data); err != nil { - Events.Error.Trigger(addr.IP, err) - } else { - peeringRequest.Issuer.SetAddress(addr.IP) - - Events.ReceiveRequest.Trigger(peeringRequest) - } - case response.MARHSALLED_PACKET_HEADER: - if peeringResponse, err := response.Unmarshal(data); err != nil { - Events.Error.Trigger(addr.IP, err) - } else { - peeringResponse.Issuer.SetAddress(addr.IP) - - Events.ReceiveResponse.Trigger(peeringResponse) - } - case ping.MARSHALED_PACKET_HEADER: - if ping, err := ping.Unmarshal(data); err != nil { - Events.Error.Trigger(addr.IP, err) - } else { - ping.Issuer.SetAddress(addr.IP) - - Events.ReceivePing.Trigger(ping) - } - case drop.MARSHALED_PACKET_HEADER: - if drop, err := drop.Unmarshal(data); err != nil { - Events.Error.Trigger(addr.IP, err) - } else { - drop.Issuer.SetAddress(addr.IP) - - Events.ReceiveDrop.Trigger(drop) - } - default: - Events.Error.Trigger(addr.IP, errors.New("invalid UDP peering packet from "+addr.IP.String())) - } -} diff --git a/plugins/autopeering/types/drop/constants.go b/plugins/autopeering/types/drop/constants.go deleted file mode 100644 index b12728d748..0000000000 --- a/plugins/autopeering/types/drop/constants.go +++ /dev/null @@ -1,23 +0,0 @@ -package drop - -import ( - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" -) - -const ( - MARSHALED_PACKET_HEADER = 0x05 - - PACKET_HEADER_START = 0 - MARSHALED_ISSUER_START = PACKET_HEADER_END - MARSHALED_SIGNATURE_START = MARSHALED_ISSUER_END - - PACKET_HEADER_END = PACKET_HEADER_START + PACKET_HEADER_SIZE - MARSHALED_ISSUER_END = MARSHALED_ISSUER_START + MARSHALED_ISSUER_SIZE - MARSHALED_SIGNATURE_END = MARSHALED_SIGNATURE_START + MARSHALED_SIGNATURE_SIZE - - PACKET_HEADER_SIZE = 1 - MARSHALED_ISSUER_SIZE = peer.MARSHALED_TOTAL_SIZE - MARSHALED_SIGNATURE_SIZE = 65 - - MARSHALED_TOTAL_SIZE = MARSHALED_SIGNATURE_END -) diff --git a/plugins/autopeering/types/drop/drop.go b/plugins/autopeering/types/drop/drop.go deleted file mode 100644 index 99ebf8773c..0000000000 --- a/plugins/autopeering/types/drop/drop.go +++ /dev/null @@ -1,60 +0,0 @@ -package drop - -import ( - "bytes" - - "github.com/iotaledger/goshimmer/packages/identity" - "github.com/iotaledger/goshimmer/plugins/autopeering/saltmanager" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" -) - -type Drop struct { - Issuer *peer.Peer - Signature [MARSHALED_SIGNATURE_SIZE]byte -} - -func Unmarshal(data []byte) (*Drop, error) { - if data[0] != MARSHALED_PACKET_HEADER || len(data) != MARSHALED_TOTAL_SIZE { - return nil, ErrMalformedDropMessage - } - - ping := &Drop{} - - if unmarshaledPeer, err := peer.Unmarshal(data[MARSHALED_ISSUER_START:MARSHALED_ISSUER_END]); err != nil { - return nil, err - } else { - ping.Issuer = unmarshaledPeer - } - if err := saltmanager.CheckSalt(ping.Issuer.GetSalt()); err != nil { - return nil, err - } - - if issuer, err := identity.FromSignedData(data[:MARSHALED_SIGNATURE_START], data[MARSHALED_SIGNATURE_START:]); err != nil { - return nil, err - } else { - if !bytes.Equal(issuer.Identifier, ping.Issuer.GetIdentity().Identifier) { - return nil, ErrInvalidSignature - } - } - copy(ping.Signature[:], data[MARSHALED_SIGNATURE_START:MARSHALED_SIGNATURE_END]) - - return ping, nil -} - -func (ping *Drop) Marshal() []byte { - result := make([]byte, MARSHALED_TOTAL_SIZE) - - result[PACKET_HEADER_START] = MARSHALED_PACKET_HEADER - copy(result[MARSHALED_ISSUER_START:MARSHALED_ISSUER_END], ping.Issuer.Marshal()) - copy(result[MARSHALED_SIGNATURE_START:MARSHALED_SIGNATURE_END], ping.Signature[:MARSHALED_SIGNATURE_SIZE]) - - return result -} - -func (this *Drop) Sign() { - if signature, err := this.Issuer.GetIdentity().Sign(this.Marshal()[:MARSHALED_SIGNATURE_START]); err != nil { - panic(err) - } else { - copy(this.Signature[:], signature) - } -} diff --git a/plugins/autopeering/types/drop/errors.go b/plugins/autopeering/types/drop/errors.go deleted file mode 100644 index d2878718dd..0000000000 --- a/plugins/autopeering/types/drop/errors.go +++ /dev/null @@ -1,8 +0,0 @@ -package drop - -import "github.com/pkg/errors" - -var ( - ErrInvalidSignature = errors.New("invalid signature in drop message") - ErrMalformedDropMessage = errors.New("malformed drop message") -) diff --git a/plugins/autopeering/types/peer/constants.go b/plugins/autopeering/types/peer/constants.go deleted file mode 100644 index a29c567c24..0000000000 --- a/plugins/autopeering/types/peer/constants.go +++ /dev/null @@ -1,31 +0,0 @@ -package peer - -import ( - "github.com/iotaledger/goshimmer/packages/identity" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/salt" -) - -const ( - MARSHALED_PUBLIC_KEY_START = 0 - MARSHALED_ADDRESS_TYPE_START = MARSHALED_PUBLIC_KEY_END - MARSHALED_ADDRESS_START = MARSHALED_ADDRESS_TYPE_END - MARSHALED_PEERING_PORT_START = MARSHALED_ADDRESS_END - MARSHALED_GOSSIP_PORT_START = MARSHALED_PEERING_PORT_END - MARSHALED_SALT_START = MARSHALED_GOSSIP_PORT_END - - MARSHALED_PUBLIC_KEY_END = MARSHALED_PUBLIC_KEY_START + MARSHALED_PUBLIC_KEY_SIZE - MARSHALED_ADDRESS_TYPE_END = MARSHALED_ADDRESS_TYPE_START + MARSHALED_ADDRESS_TYPE_SIZE - MARSHALED_ADDRESS_END = MARSHALED_ADDRESS_START + MARSHALED_ADDRESS_SIZE - MARSHALED_PEERING_PORT_END = MARSHALED_PEERING_PORT_START + MARSHALED_PEERING_PORT_SIZE - MARSHALED_GOSSIP_PORT_END = MARSHALED_GOSSIP_PORT_START + MARSHALED_GOSSIP_PORT_SIZE - MARSHALED_SALT_END = MARSHALED_SALT_START + MARSHALED_SALT_SIZE - - MARSHALED_PUBLIC_KEY_SIZE = identity.PUBLIC_KEY_BYTE_LENGTH - MARSHALED_ADDRESS_TYPE_SIZE = 1 - MARSHALED_ADDRESS_SIZE = 16 - MARSHALED_PEERING_PORT_SIZE = 2 - MARSHALED_GOSSIP_PORT_SIZE = 2 - MARSHALED_SALT_SIZE = salt.SALT_MARSHALED_SIZE - - MARSHALED_TOTAL_SIZE = MARSHALED_SALT_END -) diff --git a/plugins/autopeering/types/peer/peer.go b/plugins/autopeering/types/peer/peer.go deleted file mode 100644 index eba117c743..0000000000 --- a/plugins/autopeering/types/peer/peer.go +++ /dev/null @@ -1,246 +0,0 @@ -package peer - -import ( - "encoding/binary" - "net" - "strconv" - "sync" - "time" - - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/packages/identity" - "github.com/iotaledger/goshimmer/packages/network" - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/types" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/salt" - "github.com/pkg/errors" -) - -type Peer struct { - identity *identity.Identity - identityMutex sync.RWMutex - address net.IP - addressMutex sync.RWMutex - peeringPort uint16 - peeringPortMutex sync.RWMutex - gossipPort uint16 - gossipPortMutex sync.RWMutex - salt *salt.Salt - saltMutex sync.RWMutex - conn *network.ManagedConnection - connectMutex sync.RWMutex - firstSeen time.Time - firstSeenMutex sync.RWMutex - lastSeen time.Time - lastSeenMutex sync.RWMutex -} - -func (peer *Peer) GetIdentity() (result *identity.Identity) { - peer.identityMutex.RLock() - result = peer.identity - peer.identityMutex.RUnlock() - - return -} - -func (peer *Peer) SetIdentity(identity *identity.Identity) { - peer.identityMutex.Lock() - peer.identity = identity - peer.identityMutex.Unlock() -} - -func (peer *Peer) GetAddress() (result net.IP) { - peer.addressMutex.RLock() - result = peer.address - peer.addressMutex.RUnlock() - - return -} - -func (peer *Peer) SetAddress(address net.IP) { - peer.addressMutex.Lock() - peer.address = address - peer.addressMutex.Unlock() -} - -func (peer *Peer) GetPeeringPort() (result uint16) { - peer.peeringPortMutex.RLock() - result = peer.peeringPort - peer.peeringPortMutex.RUnlock() - - return -} - -func (peer *Peer) SetPeeringPort(port uint16) { - peer.peeringPortMutex.Lock() - peer.peeringPort = port - peer.peeringPortMutex.Unlock() -} - -func (peer *Peer) GetGossipPort() (result uint16) { - peer.gossipPortMutex.RLock() - result = peer.gossipPort - peer.gossipPortMutex.RUnlock() - - return -} - -func (peer *Peer) SetGossipPort(port uint16) { - peer.gossipPortMutex.Lock() - peer.gossipPort = port - peer.gossipPortMutex.Unlock() -} - -func (peer *Peer) GetSalt() (result *salt.Salt) { - peer.saltMutex.RLock() - result = peer.salt - peer.saltMutex.RUnlock() - - return -} - -func (peer *Peer) SetSalt(salt *salt.Salt) { - peer.saltMutex.Lock() - peer.salt = salt - peer.saltMutex.Unlock() -} - -func (peer *Peer) GetConn() (result *network.ManagedConnection) { - peer.connectMutex.RLock() - result = peer.conn - peer.connectMutex.RUnlock() - - return -} - -func (peer *Peer) SetConn(conn *network.ManagedConnection) { - peer.connectMutex.Lock() - peer.conn = conn - peer.connectMutex.Unlock() -} - -func Unmarshal(data []byte) (*Peer, error) { - if len(data) < MARSHALED_TOTAL_SIZE { - return nil, errors.New("size of marshaled peer is too small") - } - - peer := &Peer{ - identity: identity.NewIdentity(data[MARSHALED_PUBLIC_KEY_START:MARSHALED_PUBLIC_KEY_END]), - } - - switch data[MARSHALED_ADDRESS_TYPE_START] { - case types.ADDRESS_TYPE_IPV4: - peer.address = net.IP(data[MARSHALED_ADDRESS_START:MARSHALED_ADDRESS_END]).To4() - case types.ADDRESS_TYPE_IPV6: - peer.address = net.IP(data[MARSHALED_ADDRESS_START:MARSHALED_ADDRESS_END]).To16() - } - - peer.peeringPort = binary.BigEndian.Uint16(data[MARSHALED_PEERING_PORT_START:MARSHALED_PEERING_PORT_END]) - peer.gossipPort = binary.BigEndian.Uint16(data[MARSHALED_GOSSIP_PORT_START:MARSHALED_GOSSIP_PORT_END]) - - if unmarshaledSalt, err := salt.Unmarshal(data[MARSHALED_SALT_START:MARSHALED_SALT_END]); err != nil { - return nil, err - } else { - peer.salt = unmarshaledSalt - } - - return peer, nil -} - -// sends data and -func (peer *Peer) Send(data []byte, protocol types.ProtocolType, responseExpected bool) (bool, error) { - conn, dialed, err := peer.Connect(protocol) - if err != nil { - return false, err - } - - if _, err := conn.Write(data); err != nil { - return false, err - } - - if dialed && !responseExpected { - conn.Close() - } - - return dialed, nil -} - -func (peer *Peer) ConnectTCP() (*network.ManagedConnection, bool, error) { - peer.connectMutex.RLock() - - if peer.conn == nil { - peer.connectMutex.RUnlock() - peer.connectMutex.Lock() - defer peer.connectMutex.Unlock() - - if peer.conn == nil { - conn, err := net.Dial("tcp", peer.GetAddress().String()+":"+strconv.Itoa(int(peer.GetPeeringPort()))) - if err != nil { - return nil, false, errors.New("error when connecting to " + peer.String() + ": " + err.Error()) - } else { - peer.conn = network.NewManagedConnection(conn) - peer.conn.Events.Close.Attach(events.NewClosure(func() { - peer.SetConn(nil) - })) - - return peer.conn, true, nil - } - } - } else { - peer.connectMutex.RUnlock() - } - - return peer.conn, false, nil -} - -func (peer *Peer) ConnectUDP() (*network.ManagedConnection, bool, error) { - conn, err := net.Dial("udp", peer.GetAddress().String()+":"+strconv.Itoa(int(peer.GetPeeringPort()))) - if err != nil { - return nil, false, errors.New("error when connecting to " + peer.GetAddress().String() + ": " + err.Error()) - } - - return network.NewManagedConnection(conn), true, nil -} - -func (peer *Peer) Connect(protocol types.ProtocolType) (*network.ManagedConnection, bool, error) { - switch protocol { - case types.PROTOCOL_TYPE_TCP: - return peer.ConnectTCP() - case types.PROTOCOL_TYPE_UDP: - return peer.ConnectUDP() - default: - return nil, false, errors.New("unsupported peering protocol in peer " + peer.GetAddress().String()) - } -} - -func (peer *Peer) Marshal() []byte { - result := make([]byte, MARSHALED_TOTAL_SIZE) - - copy(result[MARSHALED_PUBLIC_KEY_START:MARSHALED_PUBLIC_KEY_END], - peer.GetIdentity().PublicKey[:MARSHALED_PUBLIC_KEY_SIZE]) - - switch len(peer.GetAddress()) { - case net.IPv4len: - result[MARSHALED_ADDRESS_TYPE_START] = types.ADDRESS_TYPE_IPV4 - case net.IPv6len: - result[MARSHALED_ADDRESS_TYPE_START] = types.ADDRESS_TYPE_IPV6 - default: - panic("invalid address in peer") - } - - copy(result[MARSHALED_ADDRESS_START:MARSHALED_ADDRESS_END], peer.GetAddress().To16()) - - binary.BigEndian.PutUint16(result[MARSHALED_PEERING_PORT_START:MARSHALED_PEERING_PORT_END], peer.GetPeeringPort()) - binary.BigEndian.PutUint16(result[MARSHALED_GOSSIP_PORT_START:MARSHALED_GOSSIP_PORT_END], peer.GetGossipPort()) - - copy(result[MARSHALED_SALT_START:MARSHALED_SALT_END], peer.GetSalt().Marshal()) - - return result -} - -func (peer *Peer) String() string { - if peer.GetIdentity() != nil { - return peer.GetAddress().String() + ":" + strconv.Itoa(int(peer.GetPeeringPort())) + " / " + peer.GetIdentity().StringIdentifier - } else { - return peer.GetAddress().String() + ":" + strconv.Itoa(int(peer.GetPeeringPort())) - } -} diff --git a/plugins/autopeering/types/peer/peer_test.go b/plugins/autopeering/types/peer/peer_test.go deleted file mode 100644 index be8838db94..0000000000 --- a/plugins/autopeering/types/peer/peer_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package peer - -import ( - "net" - "testing" - "time" - - "github.com/iotaledger/goshimmer/plugins/autopeering/types/salt" - - "github.com/iotaledger/goshimmer/packages/identity" - "github.com/magiconair/properties/assert" -) - -func TestPeer_MarshalUnmarshal(t *testing.T) { - peer := &Peer{ - address: net.IPv4(127, 0, 0, 1), - identity: identity.GenerateRandomIdentity(), - gossipPort: 123, - peeringPort: 456, - salt: salt.New(30 * time.Second), - } - - restoredPeer, err := Unmarshal(peer.Marshal()) - if err != nil { - t.Error(err) - } - - assert.Equal(t, peer.GetAddress(), restoredPeer.GetAddress()) - assert.Equal(t, peer.GetIdentity().StringIdentifier, restoredPeer.GetIdentity().StringIdentifier) - assert.Equal(t, peer.GetIdentity().PublicKey, restoredPeer.GetIdentity().PublicKey) - assert.Equal(t, peer.GetGossipPort(), restoredPeer.GetGossipPort()) - assert.Equal(t, peer.GetPeeringPort(), restoredPeer.GetPeeringPort()) - assert.Equal(t, peer.GetSalt().GetBytes(), restoredPeer.GetSalt().GetBytes()) - // time.time cannot be compared with reflect.DeepEqual, so we cannot use assert.Equal here - if !peer.GetSalt().GetExpirationTime().Equal(restoredPeer.GetSalt().GetExpirationTime()) { - t.Errorf("got %v want %v", restoredPeer.GetSalt().GetExpirationTime(), peer.GetSalt().GetExpirationTime()) - } -} diff --git a/plugins/autopeering/types/peerlist/peer_list.go b/plugins/autopeering/types/peerlist/peer_list.go deleted file mode 100644 index 557c14c86d..0000000000 --- a/plugins/autopeering/types/peerlist/peer_list.go +++ /dev/null @@ -1,94 +0,0 @@ -package peerlist - -import ( - "sort" - "sync" - - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" -) - -type PeerList struct { - sync.RWMutex - internal []*peer.Peer -} - -func NewPeerList(list ...[]*peer.Peer) *PeerList { - if list != nil { - return &PeerList{ - internal: list[0], - } - } - return &PeerList{ - internal: make([]*peer.Peer, 0), - } -} - -func (pl *PeerList) Len() int { - pl.RLock() - defer pl.RUnlock() - return len(pl.internal) -} - -func (pl *PeerList) AddPeer(peer *peer.Peer) { - pl.Lock() - pl.internal = append(pl.internal, peer) - pl.Unlock() -} - -func (pl *PeerList) GetPeers() (result []*peer.Peer) { - pl.RLock() - result = pl.internal - pl.RUnlock() - - return -} - -func (pl *PeerList) Update(list []*peer.Peer) { - pl.Lock() - pl.internal = list - pl.Unlock() - - return -} - -func (pl *PeerList) SwapPeers(i, j int) { - pl.Lock() - pl.internal[i], pl.internal[j] = pl.internal[j], pl.internal[i] - pl.Unlock() -} - -func (pl *PeerList) Clone() *PeerList { - list := make([]*peer.Peer, pl.Len()) - pl.RLock() - copy(list, pl.internal) - pl.RUnlock() - - return NewPeerList(list) -} - -func (pl *PeerList) Filter(predicate func(p *peer.Peer) bool) *PeerList { - peerList := make([]*peer.Peer, pl.Len()) - - counter := 0 - pl.RLock() - for _, peer := range pl.internal { - if predicate(peer) { - peerList[counter] = peer - counter++ - } - } - pl.RUnlock() - - return NewPeerList(peerList[:counter]) -} - -// Sorts the PeerRegister by their distance to an anchor. -func (pl *PeerList) Sort(distance func(p *peer.Peer) uint64) *PeerList { - pl.Lock() - defer pl.Unlock() - sort.Slice(pl.internal, func(i, j int) bool { - return distance(pl.internal[i]) < distance(pl.internal[j]) - }) - - return pl -} diff --git a/plugins/autopeering/types/peerregister/events.go b/plugins/autopeering/types/peerregister/events.go deleted file mode 100644 index ee34796737..0000000000 --- a/plugins/autopeering/types/peerregister/events.go +++ /dev/null @@ -1,16 +0,0 @@ -package peerregister - -import ( - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" -) - -type peerRegisterEvents struct { - Add *events.Event - Update *events.Event - Remove *events.Event -} - -func peerCaller(handler interface{}, params ...interface{}) { - handler.(func(*peer.Peer))(params[0].(*peer.Peer)) -} diff --git a/plugins/autopeering/types/peerregister/peerMap.go b/plugins/autopeering/types/peerregister/peerMap.go deleted file mode 100644 index 2e1460bf85..0000000000 --- a/plugins/autopeering/types/peerregister/peerMap.go +++ /dev/null @@ -1,81 +0,0 @@ -package peerregister - -import ( - "sync" - - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" -) - -// PeerMap is the mapping of peer identifier and their peer struct -// It uses a mutex to handle concurrent access to its internal map -type PeerMap struct { - sync.RWMutex - internal map[string]*peer.Peer -} - -// NewPeerMap returns a new PeerMap -func NewPeerMap() *PeerMap { - return &PeerMap{ - internal: make(map[string]*peer.Peer), - } -} - -// Len returns the number of peers stored in a PeerMap -func (pm *PeerMap) Len() int { - pm.RLock() - defer pm.RUnlock() - return len(pm.internal) -} - -// GetMap returns the content of the entire internal map -func (pm *PeerMap) GetMap() map[string]*peer.Peer { - newMap := make(map[string]*peer.Peer) - pm.RLock() - defer pm.RUnlock() - for k, v := range pm.internal { - newMap[k] = v - } - return newMap -} - -// GetMap returns the content of the entire internal map -func (pm *PeerMap) GetSlice() []*peer.Peer { - newSlice := make([]*peer.Peer, pm.Len()) - pm.RLock() - defer pm.RUnlock() - i := 0 - for _, v := range pm.internal { - newSlice[i] = v - i++ - } - return newSlice -} - -// Load returns the peer for a given key. -// It also return a bool to communicate the presence of the given -// peer into the internal map -func (pm *PeerMap) Load(key string) (value *peer.Peer, ok bool) { - pm.RLock() - defer pm.RUnlock() - result, ok := pm.internal[key] - return result, ok -} - -// Delete removes the entire entry for a given key and return true if successful -func (pm *PeerMap) Delete(key string) (deletedPeer *peer.Peer, ok bool) { - deletedPeer, ok = pm.Load(key) - if !ok { - return nil, false - } - pm.Lock() - defer pm.Unlock() - delete(pm.internal, key) - return deletedPeer, true -} - -// Store adds a new peer to the PeerMap -func (pm *PeerMap) Store(key string, value *peer.Peer) { - pm.Lock() - defer pm.Unlock() - pm.internal[key] = value -} diff --git a/plugins/autopeering/types/peerregister/peer_register.go b/plugins/autopeering/types/peerregister/peer_register.go deleted file mode 100644 index d6dd79d601..0000000000 --- a/plugins/autopeering/types/peerregister/peer_register.go +++ /dev/null @@ -1,87 +0,0 @@ -package peerregister - -import ( - "bytes" - "sync" - - "github.com/iotaledger/goshimmer/packages/accountability" - "github.com/iotaledger/goshimmer/packages/events" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/request" -) - -type PeerRegister struct { - Peers *PeerMap - Events peerRegisterEvents - lock sync.RWMutex -} - -func New() *PeerRegister { - return &PeerRegister{ - Peers: NewPeerMap(), - Events: peerRegisterEvents{ - Add: events.NewEvent(peerCaller), - Update: events.NewEvent(peerCaller), - Remove: events.NewEvent(peerCaller), - }, - } -} - -// returns true if a new entry was added -func (this *PeerRegister) AddOrUpdate(peer *peer.Peer) bool { - if peer.GetIdentity() == nil || bytes.Equal(peer.GetIdentity().Identifier, accountability.OwnId().Identifier) { - return false - } - - if existingPeer, exists := this.Peers.Load(peer.GetIdentity().StringIdentifier); exists { - existingPeer.SetAddress(peer.GetAddress()) - existingPeer.SetGossipPort(peer.GetGossipPort()) - existingPeer.SetPeeringPort(peer.GetPeeringPort()) - existingPeer.SetSalt(peer.GetSalt()) - - // also update the public key if not yet present - if existingPeer.GetIdentity().PublicKey == nil { - existingPeer.SetIdentity(peer.GetIdentity()) - } - - this.Events.Update.Trigger(existingPeer) - - return false - } else { - this.Peers.Store(peer.GetIdentity().StringIdentifier, peer) - - this.Events.Add.Trigger(peer) - - return true - } -} - -// by calling defer peerRegister.Lock()() we can auto-lock AND unlock (note: two parentheses) -func (this *PeerRegister) Lock() func() { - this.lock.Lock() - - return this.lock.Unlock -} - -func (this *PeerRegister) Remove(key string) { - if peerEntry, exists := this.Peers.Delete(key); exists { - this.Events.Remove.Trigger(peerEntry) - } -} - -func (this *PeerRegister) Contains(key string) bool { - _, exists := this.Peers.Load(key) - return exists -} - -func (this *PeerRegister) Filter(filterFn func(this *PeerRegister, req *request.Request) *PeerRegister, req *request.Request) *PeerRegister { - return filterFn(this, req) -} - -// func (this *PeerRegister) List() *peerlist.PeerList { -// return peerlist.NewPeerList(this.Peers.GetSlice()) -// } - -func (this *PeerRegister) List() []*peer.Peer { - return this.Peers.GetSlice() -} diff --git a/plugins/autopeering/types/ping/constants.go b/plugins/autopeering/types/ping/constants.go deleted file mode 100644 index 22b17d9d54..0000000000 --- a/plugins/autopeering/types/ping/constants.go +++ /dev/null @@ -1,29 +0,0 @@ -package ping - -import ( - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" -) - -const ( - MARSHALED_PACKET_HEADER = 0x04 - - PACKET_HEADER_START = 0 - MARSHALED_ISSUER_START = PACKET_HEADER_END - MARSHALED_PEERS_START = MARSHALED_ISSUER_END - MARSHALED_SIGNATURE_START = MARSHALED_PEERS_END - - PACKET_HEADER_END = PACKET_HEADER_START + PACKET_HEADER_SIZE - MARSHALED_ISSUER_END = MARSHALED_ISSUER_START + MARSHALED_ISSUER_SIZE - MARSHALED_PEERS_END = MARSHALED_PEERS_START + MARSHALED_PEERS_SIZE - MARSHALED_SIGNATURE_END = MARSHALED_SIGNATURE_START + MARSHALED_SIGNATURE_SIZE - - PACKET_HEADER_SIZE = 1 - MARSHALED_ISSUER_SIZE = peer.MARSHALED_TOTAL_SIZE - MARSHALED_PEER_ENTRY_FLAG_SIZE = 1 - MARSHALED_PEER_ENTRY_SIZE = MARSHALED_PEER_ENTRY_FLAG_SIZE + peer.MARSHALED_TOTAL_SIZE - MARSHALED_PEERS_SIZE = MARSHALED_PEER_ENTRY_SIZE * constants.NEIGHBOR_COUNT - MARSHALED_SIGNATURE_SIZE = 65 - - MARSHALED_TOTAL_SIZE = MARSHALED_SIGNATURE_END -) diff --git a/plugins/autopeering/types/ping/errors.go b/plugins/autopeering/types/ping/errors.go deleted file mode 100644 index 51825205c4..0000000000 --- a/plugins/autopeering/types/ping/errors.go +++ /dev/null @@ -1,8 +0,0 @@ -package ping - -import "github.com/pkg/errors" - -var ( - ErrInvalidSignature = errors.New("invalid signature in ping") - ErrMalformedPing = errors.New("malformed ping") -) diff --git a/plugins/autopeering/types/ping/ping.go b/plugins/autopeering/types/ping/ping.go deleted file mode 100644 index e8492c0824..0000000000 --- a/plugins/autopeering/types/ping/ping.go +++ /dev/null @@ -1,104 +0,0 @@ -package ping - -import ( - "bytes" - "sync" - - "github.com/iotaledger/goshimmer/packages/identity" - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants" - "github.com/iotaledger/goshimmer/plugins/autopeering/saltmanager" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peerlist" -) - -type Ping struct { - Issuer *peer.Peer - Neighbors *peerlist.PeerList - signature [MARSHALED_SIGNATURE_SIZE]byte - signatureMutex sync.RWMutex -} - -func (ping *Ping) GetSignature() (result []byte) { - ping.signatureMutex.RLock() - result = make([]byte, len(ping.signature)) - copy(result[:], ping.signature[:]) - ping.signatureMutex.RUnlock() - - return -} - -func (ping *Ping) SetSignature(signature []byte) { - ping.signatureMutex.Lock() - copy(ping.signature[:], signature[:]) - ping.signatureMutex.Unlock() -} - -func Unmarshal(data []byte) (*Ping, error) { - if data[0] != MARSHALED_PACKET_HEADER || len(data) != MARSHALED_TOTAL_SIZE { - return nil, ErrMalformedPing - } - - ping := &Ping{ - Neighbors: peerlist.NewPeerList(), - } - - if unmarshaledPeer, err := peer.Unmarshal(data[MARSHALED_ISSUER_START:MARSHALED_ISSUER_END]); err != nil { - return nil, err - } else { - ping.Issuer = unmarshaledPeer - } - if err := saltmanager.CheckSalt(ping.Issuer.GetSalt()); err != nil { - return nil, err - } - - offset := MARSHALED_PEERS_START - for i := 0; i < constants.NEIGHBOR_COUNT; i++ { - if data[offset] == 1 { - if unmarshaledPing, err := peer.Unmarshal(data[offset+1 : offset+MARSHALED_PEER_ENTRY_SIZE]); err != nil { - return nil, err - } else { - ping.Neighbors.AddPeer(unmarshaledPing) - } - } - - offset += MARSHALED_PEER_ENTRY_SIZE - } - - if issuer, err := identity.FromSignedData(data[:MARSHALED_SIGNATURE_START], data[MARSHALED_SIGNATURE_START:]); err != nil { - return nil, err - } else { - if !bytes.Equal(issuer.Identifier, ping.Issuer.GetIdentity().Identifier) { - return nil, ErrInvalidSignature - } - } - ping.SetSignature(data[MARSHALED_SIGNATURE_START:MARSHALED_SIGNATURE_END]) - - return ping, nil -} - -func (ping *Ping) Marshal() []byte { - result := make([]byte, MARSHALED_TOTAL_SIZE) - - result[PACKET_HEADER_START] = MARSHALED_PACKET_HEADER - copy(result[MARSHALED_ISSUER_START:MARSHALED_ISSUER_END], ping.Issuer.Marshal()) - if ping.Neighbors != nil { - for i, neighbor := range ping.Neighbors.GetPeers() { - entryStartOffset := MARSHALED_PEERS_START + i*MARSHALED_PEER_ENTRY_SIZE - - result[entryStartOffset] = 1 - - copy(result[entryStartOffset+1:entryStartOffset+MARSHALED_PEER_ENTRY_SIZE], neighbor.Marshal()) - } - } - copy(result[MARSHALED_SIGNATURE_START:MARSHALED_SIGNATURE_END], ping.GetSignature()) - - return result -} - -func (this *Ping) Sign() { - if signature, err := this.Issuer.GetIdentity().Sign(this.Marshal()[:MARSHALED_SIGNATURE_START]); err != nil { - panic(err) - } else { - this.SetSignature(signature) - } -} diff --git a/plugins/autopeering/types/request/constants.go b/plugins/autopeering/types/request/constants.go deleted file mode 100644 index c1e707153f..0000000000 --- a/plugins/autopeering/types/request/constants.go +++ /dev/null @@ -1,23 +0,0 @@ -package request - -import ( - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" -) - -const ( - PACKET_HEADER_SIZE = 1 - ISSUER_SIZE = peer.MARSHALED_TOTAL_SIZE - SIGNATURE_SIZE = 65 - - PACKET_HEADER_START = 0 - ISSUER_START = PACKET_HEADER_END - SIGNATURE_START = ISSUER_END - - PACKET_HEADER_END = PACKET_HEADER_START + PACKET_HEADER_SIZE - ISSUER_END = ISSUER_START + ISSUER_SIZE - SIGNATURE_END = SIGNATURE_START + SIGNATURE_SIZE - - MARSHALED_TOTAL_SIZE = SIGNATURE_END - - MARSHALED_PACKET_HEADER = 0xBE -) diff --git a/plugins/autopeering/types/request/errors.go b/plugins/autopeering/types/request/errors.go deleted file mode 100644 index 34831a9420..0000000000 --- a/plugins/autopeering/types/request/errors.go +++ /dev/null @@ -1,10 +0,0 @@ -package request - -import "github.com/pkg/errors" - -var ( - ErrPublicSaltExpired = errors.New("expired public salt in peering request") - ErrPublicSaltInvalidLifetime = errors.New("invalid public salt lifetime") - ErrInvalidSignature = errors.New("invalid signature in peering request") - ErrMalformedPeeringRequest = errors.New("malformed peering request") -) diff --git a/plugins/autopeering/types/request/request.go b/plugins/autopeering/types/request/request.go deleted file mode 100644 index 98d9f1d5fe..0000000000 --- a/plugins/autopeering/types/request/request.go +++ /dev/null @@ -1,116 +0,0 @@ -package request - -import ( - "bytes" - "sync" - "time" - - "github.com/iotaledger/goshimmer/packages/identity" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/ownpeer" - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/types" - "github.com/iotaledger/goshimmer/plugins/autopeering/saltmanager" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/response" -) - -type Request struct { - Issuer *peer.Peer - signature [SIGNATURE_SIZE]byte - signatureMutex sync.RWMutex -} - -func (r *Request) GetSignature() (result []byte) { - r.signatureMutex.RLock() - result = make([]byte, len(r.signature)) - copy(result[:], r.signature[:]) - r.signatureMutex.RUnlock() - - return -} - -func (r *Request) SetSignature(signature []byte) { - r.signatureMutex.Lock() - copy(r.signature[:], signature[:]) - r.signatureMutex.Unlock() -} - -func Unmarshal(data []byte) (*Request, error) { - if data[0] != MARSHALED_PACKET_HEADER || len(data) != MARSHALED_TOTAL_SIZE { - return nil, ErrMalformedPeeringRequest - } - - peeringRequest := &Request{} - - if unmarshaledPeer, err := peer.Unmarshal(data[ISSUER_START:ISSUER_END]); err != nil { - return nil, err - } else { - peeringRequest.Issuer = unmarshaledPeer - } - - now := time.Now() - if peeringRequest.Issuer.GetSalt().GetExpirationTime().Before(now.Add(-1 * time.Minute)) { - return nil, ErrPublicSaltExpired - } - if peeringRequest.Issuer.GetSalt().GetExpirationTime().After(now.Add(saltmanager.PUBLIC_SALT_LIFETIME + 1*time.Minute)) { - return nil, ErrPublicSaltInvalidLifetime - } - - if issuer, err := identity.FromSignedData(data[:SIGNATURE_START], data[SIGNATURE_START:]); err != nil { - return nil, err - } else { - if !bytes.Equal(issuer.Identifier, peeringRequest.Issuer.GetIdentity().Identifier) { - return nil, ErrInvalidSignature - } - } - peeringRequest.SetSignature(data[SIGNATURE_START:SIGNATURE_END]) - - return peeringRequest, nil -} - -func (this *Request) Accept(peers []*peer.Peer) error { - peeringResponse := &response.Response{ - Type: response.TYPE_ACCEPT, - Issuer: ownpeer.INSTANCE, - Peers: peers, - } - peeringResponse.Sign() - - if _, err := this.Issuer.Send(peeringResponse.Marshal(), types.PROTOCOL_TYPE_TCP, false); err != nil { - return err - } - - return nil -} - -func (this *Request) Reject(peers []*peer.Peer) error { - peeringResponse := &response.Response{ - Type: response.TYPE_REJECT, - Issuer: ownpeer.INSTANCE, - Peers: peers, - } - peeringResponse.Sign() - - if _, err := this.Issuer.Send(peeringResponse.Marshal(), types.PROTOCOL_TYPE_TCP, false); err != nil { - return err - } - - return nil -} - -func (this *Request) Sign() { - if signature, err := this.Issuer.GetIdentity().Sign(this.Marshal()[:SIGNATURE_START]); err != nil { - panic(err) - } else { - this.SetSignature(signature) - } -} - -func (this *Request) Marshal() []byte { - result := make([]byte, MARSHALED_TOTAL_SIZE) - - result[PACKET_HEADER_START] = MARSHALED_PACKET_HEADER - copy(result[ISSUER_START:ISSUER_END], this.Issuer.Marshal()) - copy(result[SIGNATURE_START:SIGNATURE_END], this.GetSignature()[:SIGNATURE_SIZE]) - - return result -} diff --git a/plugins/autopeering/types/response/constants.go b/plugins/autopeering/types/response/constants.go deleted file mode 100644 index 9ef796feee..0000000000 --- a/plugins/autopeering/types/response/constants.go +++ /dev/null @@ -1,35 +0,0 @@ -package response - -import ( - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" -) - -const ( - TYPE_REJECT = Type(0) - TYPE_ACCEPT = Type(1) - - MARSHALED_PEERS_AMOUNT = constants.NEIGHBOR_COUNT + constants.NEIGHBOR_COUNT*constants.NEIGHBOR_COUNT - MARHSALLED_PACKET_HEADER = 0xBC - - MARSHALED_PACKET_HEADER_START = 0 - MARSHALED_TYPE_START = MARSHALED_PACKET_HEADER_END - MARSHALED_ISSUER_START = MARSHALED_TYPE_END - MARSHALED_PEERS_START = MARSHALED_ISSUER_END - MARSHALED_SIGNATURE_START = MARSHALED_PEERS_END - - MARSHALED_PACKET_HEADER_END = MARSHALED_PACKET_HEADER_START + MARSHALED_PACKET_HEADER_SIZE - MARSHALED_TYPE_END = MARSHALED_TYPE_START + MARSHALED_TYPE_SIZE - MARSHALED_PEERS_END = MARSHALED_PEERS_START + MARSHALED_PEERS_SIZE - MARSHALED_ISSUER_END = MARSHALED_ISSUER_START + MARSHALED_ISSUER_SIZE - MARSHALED_SIGNATURE_END = MARSHALED_SIGNATURE_START + MARSHALED_SIGNATURE_SIZE - - MARSHALED_PACKET_HEADER_SIZE = 1 - MARSHALED_TYPE_SIZE = 1 - MARSHALED_ISSUER_SIZE = peer.MARSHALED_TOTAL_SIZE - MARSHALED_PEER_FLAG_SIZE = 1 - MARSHALED_PEER_SIZE = MARSHALED_PEER_FLAG_SIZE + peer.MARSHALED_TOTAL_SIZE - MARSHALED_PEERS_SIZE = MARSHALED_PEERS_AMOUNT * MARSHALED_PEER_SIZE - MARSHALED_SIGNATURE_SIZE = 65 - MARSHALED_TOTAL_SIZE = MARSHALED_SIGNATURE_END -) diff --git a/plugins/autopeering/types/response/errors.go b/plugins/autopeering/types/response/errors.go deleted file mode 100644 index 34d823a866..0000000000 --- a/plugins/autopeering/types/response/errors.go +++ /dev/null @@ -1,7 +0,0 @@ -package response - -import "github.com/pkg/errors" - -var ( - ErrInvalidSignature = errors.New("invalid signature in peering request") -) diff --git a/plugins/autopeering/types/response/response.go b/plugins/autopeering/types/response/response.go deleted file mode 100644 index 6a398c4f06..0000000000 --- a/plugins/autopeering/types/response/response.go +++ /dev/null @@ -1,110 +0,0 @@ -package response - -import ( - "bytes" - "sync" - - "github.com/iotaledger/goshimmer/packages/identity" - "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" - "github.com/pkg/errors" -) - -type Response struct { - Type Type - Issuer *peer.Peer - Peers []*peer.Peer - signature [MARSHALED_SIGNATURE_SIZE]byte - signatureMutex sync.RWMutex -} - -func (r *Response) GetSignature() (result []byte) { - r.signatureMutex.RLock() - result = make([]byte, len(r.signature)) - copy(result[:], r.signature[:]) - r.signatureMutex.RUnlock() - - return -} - -func (r *Response) SetSignature(signature []byte) { - r.signatureMutex.Lock() - copy(r.signature[:], signature[:]) - r.signatureMutex.Unlock() -} - -func Unmarshal(data []byte) (*Response, error) { - if data[0] != MARHSALLED_PACKET_HEADER || len(data) < MARSHALED_TOTAL_SIZE { - return nil, errors.New("malformed peering response") - } - - peeringResponse := &Response{ - Type: data[MARSHALED_TYPE_START], - Peers: make([]*peer.Peer, 0), - } - - if unmarshaledPeer, err := peer.Unmarshal(data[MARSHALED_ISSUER_START:MARSHALED_ISSUER_END]); err != nil { - return nil, err - } else { - peeringResponse.Issuer = unmarshaledPeer - } - - for i := 0; i < MARSHALED_PEERS_AMOUNT; i++ { - PEERING_RESPONSE_MARSHALED_PEER_START := MARSHALED_PEERS_START + (i * MARSHALED_PEER_SIZE) - PEERING_RESPONSE_MARSHALED_PEER_END := PEERING_RESPONSE_MARSHALED_PEER_START + MARSHALED_PEER_SIZE - - if data[PEERING_RESPONSE_MARSHALED_PEER_START] == 1 { - peer, err := peer.Unmarshal(data[PEERING_RESPONSE_MARSHALED_PEER_START+1 : PEERING_RESPONSE_MARSHALED_PEER_END]) - if err != nil { - return nil, err - } - - peeringResponse.Peers = append(peeringResponse.Peers, peer) - } - } - - if issuer, err := identity.FromSignedData(data[:MARSHALED_SIGNATURE_START], data[MARSHALED_SIGNATURE_START:]); err != nil { - return nil, err - } else { - if !bytes.Equal(issuer.Identifier, peeringResponse.Issuer.GetIdentity().Identifier) { - return nil, ErrInvalidSignature - } - } - peeringResponse.SetSignature(data[MARSHALED_SIGNATURE_START:MARSHALED_SIGNATURE_END]) - - return peeringResponse, nil -} - -func (this *Response) Sign() *Response { - dataToSign := this.Marshal()[:MARSHALED_SIGNATURE_START] - if signature, err := this.Issuer.GetIdentity().Sign(dataToSign); err != nil { - panic(err) - } else { - this.SetSignature(signature) - } - - return this -} - -func (this *Response) Marshal() []byte { - result := make([]byte, MARSHALED_TOTAL_SIZE) - - result[MARSHALED_PACKET_HEADER_START] = MARHSALLED_PACKET_HEADER - result[MARSHALED_TYPE_START] = this.Type - - copy(result[MARSHALED_ISSUER_START:MARSHALED_ISSUER_END], this.Issuer.Marshal()) - - for i, peer := range this.Peers { - if i < constants.NEIGHBOR_COUNT { - PEERING_RESPONSE_MARSHALED_PEER_START := MARSHALED_PEERS_START + (i * MARSHALED_PEER_SIZE) - PEERING_RESPONSE_MARSHALED_PEER_END := PEERING_RESPONSE_MARSHALED_PEER_START + MARSHALED_PEER_SIZE - - result[PEERING_RESPONSE_MARSHALED_PEER_START] = 1 - copy(result[PEERING_RESPONSE_MARSHALED_PEER_START+1:PEERING_RESPONSE_MARSHALED_PEER_END], peer.Marshal()[:MARSHALED_PEER_SIZE-1]) - } - } - - copy(result[MARSHALED_SIGNATURE_START:MARSHALED_SIGNATURE_END], this.GetSignature()[:MARSHALED_SIGNATURE_SIZE]) - - return result -} diff --git a/plugins/autopeering/types/response/response_test.go b/plugins/autopeering/types/response/response_test.go deleted file mode 100644 index 1cfc178e93..0000000000 --- a/plugins/autopeering/types/response/response_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package response - -import ( - "net" - "testing" - "time" - - "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" - - "github.com/iotaledger/goshimmer/packages/identity" - "github.com/iotaledger/goshimmer/plugins/autopeering/types/salt" -) - -func TestPeer_MarshalUnmarshal(t *testing.T) { - issuer := &peer.Peer{} - issuer.SetAddress(net.IPv4(127, 0, 0, 1)) - issuer.SetIdentity(identity.GenerateRandomIdentity()) - issuer.SetGossipPort(123) - issuer.SetPeeringPort(456) - issuer.SetSalt(salt.New(30 * time.Second)) - - peers := make([]*peer.Peer, 3) - - peers[0] = &peer.Peer{} - peers[0].SetAddress(net.IPv4(127, 0, 0, 1)) - peers[0].SetIdentity(identity.GenerateRandomIdentity()) - peers[0].SetGossipPort(124) - peers[0].SetPeeringPort(457) - peers[0].SetSalt(salt.New(30 * time.Second)) - - peers[1] = &peer.Peer{} - peers[1].SetAddress(net.IPv4(127, 0, 0, 1)) - peers[1].SetIdentity(identity.GenerateRandomIdentity()) - peers[1].SetGossipPort(125) - peers[1].SetPeeringPort(458) - peers[1].SetSalt(salt.New(30 * time.Second)) - - peers[2] = &peer.Peer{} - peers[2].SetAddress(net.IPv4(127, 0, 0, 1)) - peers[2].SetIdentity(identity.GenerateRandomIdentity()) - peers[2].SetGossipPort(126) - peers[2].SetPeeringPort(459) - peers[2].SetSalt(salt.New(30 * time.Second)) - - response := &Response{ - Issuer: issuer, - Type: TYPE_ACCEPT, - Peers: peers, - } - response.Sign() - - _, err := Unmarshal(response.Marshal()) - if err != nil { - t.Error(err) - } -} diff --git a/plugins/autopeering/types/response/types.go b/plugins/autopeering/types/response/types.go deleted file mode 100644 index 64e48e6c2d..0000000000 --- a/plugins/autopeering/types/response/types.go +++ /dev/null @@ -1,3 +0,0 @@ -package response - -type Type = byte diff --git a/plugins/autopeering/types/salt/constants.go b/plugins/autopeering/types/salt/constants.go deleted file mode 100644 index 399d6a7283..0000000000 --- a/plugins/autopeering/types/salt/constants.go +++ /dev/null @@ -1,14 +0,0 @@ -package salt - -const ( - SALT_BYTES_SIZE = 20 - SALT_TIME_SIZE = 15 - - SALT_BYTES_START = 0 - SALT_TIME_START = SALT_BYTES_END - - SALT_BYTES_END = SALT_BYTES_START + SALT_BYTES_SIZE - SALT_TIME_END = SALT_TIME_START + SALT_TIME_SIZE - - SALT_MARSHALED_SIZE = SALT_TIME_END -) diff --git a/plugins/autopeering/types/salt/salt.go b/plugins/autopeering/types/salt/salt.go deleted file mode 100644 index c52a14b7d8..0000000000 --- a/plugins/autopeering/types/salt/salt.go +++ /dev/null @@ -1,92 +0,0 @@ -package salt - -import ( - "crypto/rand" - "sync" - "time" - - "github.com/pkg/errors" -) - -type Salt struct { - bytes []byte - bytesMutex sync.RWMutex - expirationTime time.Time - expirationTimeMutex sync.RWMutex -} - -func (salt *Salt) GetBytes() (result []byte) { - salt.bytesMutex.RLock() - result = make([]byte, len(salt.bytes)) - copy(result[:], salt.bytes[:]) - salt.bytesMutex.RUnlock() - - return -} - -func (salt *Salt) SetBytes(b []byte) { - salt.bytesMutex.Lock() - salt.bytes = make([]byte, len(b)) - copy(salt.bytes[:], b[:]) - salt.bytesMutex.Unlock() -} - -func (salt *Salt) GetExpirationTime() (result time.Time) { - salt.expirationTimeMutex.RLock() - result = salt.expirationTime - salt.expirationTimeMutex.RUnlock() - - return -} - -func (salt *Salt) SetExpirationTime(t time.Time) { - salt.expirationTimeMutex.Lock() - salt.expirationTime = t - salt.expirationTimeMutex.Unlock() -} - -func New(lifetime time.Duration) *Salt { - salt := &Salt{ - bytes: make([]byte, SALT_BYTES_SIZE), - expirationTime: time.Now().Add(lifetime), - } - - if _, err := rand.Read(salt.bytes); err != nil { - panic(err) - } - - return salt -} - -func Unmarshal(marshaledSalt []byte) (*Salt, error) { - if len(marshaledSalt) < SALT_MARSHALED_SIZE { - return nil, errors.New("marshaled salt bytes not long enough") - } - - salt := &Salt{ - bytes: make([]byte, SALT_BYTES_SIZE), - } - salt.SetBytes(marshaledSalt[SALT_BYTES_START:SALT_BYTES_END]) - - var expTime time.Time - if err := expTime.UnmarshalBinary(marshaledSalt[SALT_TIME_START:SALT_TIME_END]); err != nil { - return nil, err - } - salt.SetExpirationTime(expTime) - - return salt, nil -} - -func (this *Salt) Marshal() []byte { - result := make([]byte, SALT_BYTES_SIZE+SALT_TIME_SIZE) - - copy(result[SALT_BYTES_START:SALT_BYTES_END], this.GetBytes()) - expTime := this.GetExpirationTime() - if bytes, err := expTime.MarshalBinary(); err != nil { - panic(err) - } else { - copy(result[SALT_TIME_START:SALT_TIME_END], bytes) - } - - return result -} diff --git a/plugins/bundleprocessor/bundleprocessor_test.go b/plugins/bundleprocessor/bundleprocessor_test.go index 14834c67c2..fdb22a5d9c 100644 --- a/plugins/bundleprocessor/bundleprocessor_test.go +++ b/plugins/bundleprocessor/bundleprocessor_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/value_transaction" diff --git a/plugins/bundleprocessor/events.go b/plugins/bundleprocessor/events.go index 6deb5fbb85..fc7d52a6bf 100644 --- a/plugins/bundleprocessor/events.go +++ b/plugins/bundleprocessor/events.go @@ -2,7 +2,7 @@ package bundleprocessor import ( "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/value_transaction" ) diff --git a/plugins/bundleprocessor/plugin.go b/plugins/bundleprocessor/plugin.go index db1e1c28cf..c4592a6362 100644 --- a/plugins/bundleprocessor/plugin.go +++ b/plugins/bundleprocessor/plugin.go @@ -3,7 +3,7 @@ package bundleprocessor import ( "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/tangle" diff --git a/plugins/cli/plugin.go b/plugins/cli/plugin.go index ae97189d45..a8b3ea9513 100644 --- a/plugins/cli/plugin.go +++ b/plugins/cli/plugin.go @@ -5,7 +5,7 @@ import ( "fmt" "strings" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/parameter" ) diff --git a/plugins/dashboard/plugin.go b/plugins/dashboard/plugin.go index a292f80a9b..5b38ebed57 100644 --- a/plugins/dashboard/plugin.go +++ b/plugins/dashboard/plugin.go @@ -7,9 +7,9 @@ import ( "golang.org/x/net/context" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/metrics" + "github.com/iotaledger/hive.go/events" ) var server *http.Server diff --git a/plugins/dashboard/tps.go b/plugins/dashboard/tps.go index a35d4721c4..ac1f5ceb24 100644 --- a/plugins/dashboard/tps.go +++ b/plugins/dashboard/tps.go @@ -6,18 +6,15 @@ import ( "html/template" "math" "net/http" - "sync" "strconv" + "sync" "time" "github.com/gorilla/websocket" "github.com/iotaledger/goshimmer/packages/accountability" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/goshimmer/plugins/autopeering" "github.com/iotaledger/goshimmer/plugins/metrics" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/neighborhood" + "github.com/iotaledger/hive.go/events" ) var ( @@ -72,12 +69,12 @@ func GetStatus() *Status { } uptime += fmt.Sprintf("%02ds ", int(duration.Seconds())%60) - return &Status { - Id: accountability.OwnId().StringIdentifier, - Neighbor: "Neighbors: " + strconv.Itoa(chosenneighbors.INSTANCE.Peers.Len())+" chosen / "+strconv.Itoa(acceptedneighbors.INSTANCE.Peers.Len())+" accepted / "+strconv.Itoa(chosenneighbors.INSTANCE.Peers.Len()+acceptedneighbors.INSTANCE.Peers.Len())+" total", - KnownPeer: "Known Peers: "+ strconv.Itoa(knownpeers.INSTANCE.Peers.Len())+" total / "+strconv.Itoa(neighborhood.INSTANCE.Peers.Len())+" neighborhood", - Uptime: uptime, - } + return &Status{ + Id: accountability.OwnId().StringIdentifier, + Neighbor: "Neighbors: " + strconv.Itoa(len(autopeering.Selection.GetOutgoingNeighbors())) + " chosen / " + strconv.Itoa(len(autopeering.Selection.GetIncomingNeighbors())) + " accepted / " + strconv.Itoa(len(autopeering.Selection.GetNeighbors())) + " total", + KnownPeer: "Known Peers: " + strconv.Itoa(len(autopeering.Discovery.GetVerifiedPeers())) + " total", + Uptime: uptime, + } } // ServeWs websocket diff --git a/plugins/gossip-on-solidification/plugin.go b/plugins/gossip-on-solidification/plugin.go index bd040b9cae..fe112d806a 100644 --- a/plugins/gossip-on-solidification/plugin.go +++ b/plugins/gossip-on-solidification/plugin.go @@ -1,7 +1,7 @@ package gossip_on_solidification import ( - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/gossip" diff --git a/plugins/gossip/events.go b/plugins/gossip/events.go index 6d3183820d..4bcb484a1b 100644 --- a/plugins/gossip/events.go +++ b/plugins/gossip/events.go @@ -2,10 +2,10 @@ package gossip import ( "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/events" "github.com/iotaledger/goshimmer/packages/identity" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/network" + "github.com/iotaledger/hive.go/events" ) var Events = pluginEvents{ diff --git a/plugins/gossip/neighbors.go b/plugins/gossip/neighbors.go index 4e73bf27c1..f4374c517b 100644 --- a/plugins/gossip/neighbors.go +++ b/plugins/gossip/neighbors.go @@ -7,26 +7,27 @@ import ( "sync" "time" + "github.com/iotaledger/autopeering-sim/peer" "github.com/iotaledger/goshimmer/packages/accountability" "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/events" "github.com/iotaledger/goshimmer/packages/identity" "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/events" ) func configureNeighbors(plugin *node.Plugin) { Events.AddNeighbor.Attach(events.NewClosure(func(neighbor *Neighbor) { - plugin.LogSuccess("new neighbor added " + neighbor.GetIdentity().StringIdentifier + "@" + neighbor.GetAddress().String() + ":" + strconv.Itoa(int(neighbor.GetPort()))) + plugin.LogSuccess("new neighbor added " + neighbor.GetIdentity().StringIdentifier + "@" + neighbor.GetAddress().String() + ":" + neighbor.GetPort()) })) Events.UpdateNeighbor.Attach(events.NewClosure(func(neighbor *Neighbor) { - plugin.LogSuccess("existing neighbor updated " + neighbor.GetIdentity().StringIdentifier + "@" + neighbor.GetAddress().String() + ":" + strconv.Itoa(int(neighbor.GetPort()))) + plugin.LogSuccess("existing neighbor updated " + neighbor.GetIdentity().StringIdentifier + "@" + neighbor.GetAddress().String() + ":" + neighbor.GetPort()) })) Events.RemoveNeighbor.Attach(events.NewClosure(func(neighbor *Neighbor) { - plugin.LogSuccess("existing neighbor removed " + neighbor.GetIdentity().StringIdentifier + "@" + neighbor.GetAddress().String() + ":" + strconv.Itoa(int(neighbor.GetPort()))) + plugin.LogSuccess("existing neighbor removed " + neighbor.GetIdentity().StringIdentifier + "@" + neighbor.GetAddress().String() + ":" + neighbor.GetPort()) })) } @@ -98,20 +99,22 @@ type Neighbor struct { identityMutex sync.RWMutex address net.IP addressMutex sync.RWMutex - port uint16 + port string portMutex sync.RWMutex initiatedProtocol *protocol initiatedProtocolMutex sync.RWMutex acceptedProtocol *protocol Events neighborEvents acceptedProtocolMutex sync.RWMutex + Peer *peer.Peer } -func NewNeighbor(identity *identity.Identity, address net.IP, port uint16) *Neighbor { +func NewNeighbor(peer *peer.Peer, address, port string) *Neighbor { return &Neighbor{ - identity: identity, - address: address, + identity: identity.NewPublicIdentity(peer.ToProto().GetPublicKey()), + address: net.ParseIP(address), port: port, + Peer: peer, Events: neighborEvents{ ProtocolConnectionEstablished: events.NewEvent(protocolCaller), }, @@ -146,7 +149,7 @@ func (neighbor *Neighbor) SetAddress(address net.IP) { neighbor.addressMutex.Unlock() } -func (neighbor *Neighbor) GetPort() (result uint16) { +func (neighbor *Neighbor) GetPort() (result string) { neighbor.portMutex.RLock() result = neighbor.port neighbor.portMutex.RUnlock() @@ -154,7 +157,7 @@ func (neighbor *Neighbor) GetPort() (result uint16) { return result } -func (neighbor *Neighbor) SetPort(port uint16) { +func (neighbor *Neighbor) SetPort(port string) { neighbor.portMutex.Lock() neighbor.port = port neighbor.portMutex.Unlock() @@ -204,10 +207,10 @@ func (neighbor *Neighbor) Connect() (*protocol, bool, errors.IdentifiableError) } // otherwise try to dial - conn, err := net.Dial("tcp", neighbor.GetAddress().String()+":"+strconv.Itoa(int(neighbor.GetPort()))) + conn, err := net.Dial("tcp", neighbor.GetAddress().String()+":"+neighbor.GetPort()) if err != nil { return nil, false, ErrConnectionFailed.Derive(err, "error when connecting to neighbor "+ - neighbor.GetIdentity().StringIdentifier+"@"+neighbor.GetAddress().String()+":"+strconv.Itoa(int(neighbor.GetPort()))) + neighbor.GetIdentity().StringIdentifier+"@"+neighbor.GetAddress().String()+":"+neighbor.GetPort()) } neighbor.SetInitiatedProtocol(newProtocol(network.NewManagedConnection(conn))) diff --git a/plugins/gossip/protocol.go b/plugins/gossip/protocol.go index f51d11b718..5cda6f9988 100644 --- a/plugins/gossip/protocol.go +++ b/plugins/gossip/protocol.go @@ -5,7 +5,7 @@ import ( "sync" "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/network" ) diff --git a/plugins/gossip/protocol_v1.go b/plugins/gossip/protocol_v1.go index 196bc2c63e..ee6681dc86 100644 --- a/plugins/gossip/protocol_v1.go +++ b/plugins/gossip/protocol_v1.go @@ -1,13 +1,12 @@ package gossip import ( - "bytes" "strconv" "github.com/iotaledger/goshimmer/packages/accountability" "github.com/iotaledger/goshimmer/packages/byteutils" "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/identity" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/iota.go/consts" @@ -82,60 +81,46 @@ func (state *indentificationStateV1) Receive(data []byte, offset int, length int state.offset += bytesRead if state.offset == MARSHALED_IDENTITY_TOTAL_SIZE { - if receivedIdentity, err := unmarshalIdentity(state.buffer); err != nil { + receivedIdentity, err := identity.FromSignedData(state.buffer) + if err != nil { return bytesRead, ErrInvalidAuthenticationMessage.Derive(err, "invalid authentication message") - } else { - protocol := state.protocol + } + protocol := state.protocol - if neighbor, exists := neighbors.Load(receivedIdentity.StringIdentifier); exists { - protocol.Neighbor = neighbor - } else { - protocol.Neighbor = nil - } + if neighbor, exists := GetNeighbor(receivedIdentity.StringIdentifier); exists { + protocol.Neighbor = neighbor + } else { + protocol.Neighbor = nil + } - protocol.Events.ReceiveIdentification.Trigger(receivedIdentity) + protocol.Events.ReceiveIdentification.Trigger(receivedIdentity) - protocol.ReceivingState = newacceptanceStateV1(protocol) - state.offset = 0 - } + // switch to new state + protocol.ReceivingState = newacceptanceStateV1(protocol) + state.offset = 0 } return bytesRead, nil } func (state *indentificationStateV1) Send(param interface{}) errors.IdentifiableError { - if id, ok := param.(*identity.Identity); ok { - if signature, err := id.Sign(id.Identifier); err == nil { - protocol := state.protocol - - if _, err := protocol.Conn.Write(id.Identifier); err != nil { - return ErrSendFailed.Derive(err, "failed to send identifier") - } - if _, err := protocol.Conn.Write(signature); err != nil { - return ErrSendFailed.Derive(err, "failed to send signature") - } + id, ok := param.(*identity.Identity) + if !ok { + return ErrInvalidSendParam.Derive("parameter is not a valid identity") + } - protocol.SendState = newacceptanceStateV1(protocol) + msg := id.Identifier.Bytes() + data := id.AddSignature(msg) - return nil - } + protocol := state.protocol + if _, err := protocol.Conn.Write(data); err != nil { + return ErrSendFailed.Derive(err, "failed to send identification") } - return ErrInvalidSendParam.Derive("passed in parameter is not a valid identity") -} + // switch to new state + protocol.SendState = newacceptanceStateV1(protocol) -func unmarshalIdentity(data []byte) (*identity.Identity, error) { - identifier := data[MARSHALED_IDENTITY_START:MARSHALED_IDENTITY_END] - - if restoredIdentity, err := identity.FromSignedData(identifier, data[MARSHALED_IDENTITY_SIGNATURE_START:MARSHALED_IDENTITY_SIGNATURE_END]); err != nil { - return nil, err - } else { - if bytes.Equal(identifier, restoredIdentity.Identifier) { - return restoredIdentity, nil - } else { - return nil, errors.New("signature does not match claimed identity") - } - } + return nil } // endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -383,14 +368,14 @@ const ( DISPATCH_TRANSACTION = byte(1) DISPATCH_REQUEST = byte(2) - MARSHALED_IDENTITY_START = 0 - MARSHALED_IDENTITY_SIGNATURE_START = MARSHALED_IDENTITY_END + MARSHALED_IDENTITY_IDENTIFIER_START = 0 + MARSHALED_IDENTITY_SIGNATURE_START = MARSHALED_IDENTITY_IDENTIFIER_END - MARSHALED_IDENTITY_SIZE = 20 - MARSHALED_IDENTITY_SIGNATURE_SIZE = 65 + MARSHALED_IDENTITY_IDENTIFIER_SIZE = identity.IDENTIFIER_BYTE_LENGTH + MARSHALED_IDENTITY_SIGNATURE_SIZE = identity.SIGNATURE_BYTE_LENGTH - MARSHALED_IDENTITY_END = MARSHALED_IDENTITY_START + MARSHALED_IDENTITY_SIZE - MARSHALED_IDENTITY_SIGNATURE_END = MARSHALED_IDENTITY_SIGNATURE_START + MARSHALED_IDENTITY_SIGNATURE_SIZE + MARSHALED_IDENTITY_IDENTIFIER_END = MARSHALED_IDENTITY_IDENTIFIER_START + MARSHALED_IDENTITY_IDENTIFIER_SIZE + MARSHALED_IDENTITY_SIGNATURE_END = MARSHALED_IDENTITY_SIGNATURE_START + MARSHALED_IDENTITY_SIGNATURE_SIZE MARSHALED_IDENTITY_TOTAL_SIZE = MARSHALED_IDENTITY_SIGNATURE_END ) diff --git a/plugins/gossip/send_queue.go b/plugins/gossip/send_queue.go index 7edc3dd2e6..02ba941564 100644 --- a/plugins/gossip/send_queue.go +++ b/plugins/gossip/send_queue.go @@ -4,7 +4,7 @@ import ( "sync" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/node" ) diff --git a/plugins/gossip/server.go b/plugins/gossip/server.go index 7dc7cd67c7..cee62e7d5e 100644 --- a/plugins/gossip/server.go +++ b/plugins/gossip/server.go @@ -6,7 +6,7 @@ import ( "github.com/iotaledger/goshimmer/packages/accountability" "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/identity" "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/network/tcp" diff --git a/plugins/metrics/events.go b/plugins/metrics/events.go index 1818967461..03a51d819c 100644 --- a/plugins/metrics/events.go +++ b/plugins/metrics/events.go @@ -1,7 +1,7 @@ package metrics import ( - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" ) var Events = pluginEvents{ diff --git a/plugins/metrics/plugin.go b/plugins/metrics/plugin.go index 290b548fee..3a2b3b23be 100644 --- a/plugins/metrics/plugin.go +++ b/plugins/metrics/plugin.go @@ -4,7 +4,7 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/timeutil" diff --git a/plugins/statusscreen-tps/plugin.go b/plugins/statusscreen-tps/plugin.go index e91121a158..8981ad47d4 100644 --- a/plugins/statusscreen-tps/plugin.go +++ b/plugins/statusscreen-tps/plugin.go @@ -6,7 +6,7 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/node" diff --git a/plugins/statusscreen/statusscreen.go b/plugins/statusscreen/statusscreen.go index 7f13dc4ad4..f76e097e13 100644 --- a/plugins/statusscreen/statusscreen.go +++ b/plugins/statusscreen/statusscreen.go @@ -7,8 +7,8 @@ import ( "github.com/gdamore/tcell" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/events" "github.com/rivo/tview" "golang.org/x/crypto/ssh/terminal" ) diff --git a/plugins/statusscreen/ui_header_bar.go b/plugins/statusscreen/ui_header_bar.go index db3dfc6470..e1a1d17b88 100644 --- a/plugins/statusscreen/ui_header_bar.go +++ b/plugins/statusscreen/ui_header_bar.go @@ -4,14 +4,13 @@ import ( "fmt" "math" "strconv" + + //"strconv" "time" "github.com/gdamore/tcell" "github.com/iotaledger/goshimmer/packages/accountability" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/neighborhood" + "github.com/iotaledger/goshimmer/plugins/autopeering" "github.com/rivo/tview" ) @@ -78,11 +77,24 @@ func (headerBar *UIHeaderBar) Update() { fmt.Fprintln(headerBar.InfoContainer) } + outgoing := "0" + incoming := "0" + neighbors := "0" + total := "0" + if autopeering.Selection != nil { + outgoing = strconv.Itoa(len(autopeering.Selection.GetOutgoingNeighbors())) + incoming = strconv.Itoa(len(autopeering.Selection.GetIncomingNeighbors())) + neighbors = strconv.Itoa(len(autopeering.Selection.GetNeighbors())) + } + if autopeering.Discovery != nil { + total = strconv.Itoa(len(autopeering.Discovery.GetVerifiedPeers())) + } + fmt.Fprintf(headerBar.InfoContainer, "[::b]Node ID: [::d]%40v ", accountability.OwnId().StringIdentifier) fmt.Fprintln(headerBar.InfoContainer) - fmt.Fprintf(headerBar.InfoContainer, "[::b]Neighbors: [::d]%40v ", strconv.Itoa(chosenneighbors.INSTANCE.Peers.Len())+" chosen / "+strconv.Itoa(acceptedneighbors.INSTANCE.Peers.Len())+" accepted / "+strconv.Itoa(chosenneighbors.INSTANCE.Peers.Len()+acceptedneighbors.INSTANCE.Peers.Len())+" total") + fmt.Fprintf(headerBar.InfoContainer, "[::b]Neighbors: [::d]%40v ", outgoing+" chosen / "+incoming+" accepted / "+neighbors+" total") fmt.Fprintln(headerBar.InfoContainer) - fmt.Fprintf(headerBar.InfoContainer, "[::b]Known Peers: [::d]%40v ", strconv.Itoa(knownpeers.INSTANCE.Peers.Len())+" total / "+strconv.Itoa(neighborhood.INSTANCE.Peers.Len())+" neighborhood") + fmt.Fprintf(headerBar.InfoContainer, "[::b]Known Peers: [::d]%40v ", total+" total") fmt.Fprintln(headerBar.InfoContainer) fmt.Fprintf(headerBar.InfoContainer, "[::b]Uptime: [::d]") diff --git a/plugins/tangle/events.go b/plugins/tangle/events.go index e29ecd20c3..106e43d40a 100644 --- a/plugins/tangle/events.go +++ b/plugins/tangle/events.go @@ -1,7 +1,7 @@ package tangle import ( - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/value_transaction" ) diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index e0408a957a..0efba3f754 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -5,7 +5,7 @@ import ( "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/approvers" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" diff --git a/plugins/tangle/solidifier_test.go b/plugins/tangle/solidifier_test.go index 9db5e7c89e..cfb74d5fee 100644 --- a/plugins/tangle/solidifier_test.go +++ b/plugins/tangle/solidifier_test.go @@ -4,7 +4,7 @@ import ( "sync" "testing" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/gossip" diff --git a/plugins/tipselection/plugin.go b/plugins/tipselection/plugin.go index 745c1dad4c..b74ab6458a 100644 --- a/plugins/tipselection/plugin.go +++ b/plugins/tipselection/plugin.go @@ -1,7 +1,7 @@ package tipselection import ( - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/tangle" diff --git a/plugins/ui/nodeInfo.go b/plugins/ui/nodeInfo.go index f643e9f5de..a97ab5a19b 100644 --- a/plugins/ui/nodeInfo.go +++ b/plugins/ui/nodeInfo.go @@ -5,10 +5,7 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/accountability" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" - "github.com/iotaledger/goshimmer/plugins/autopeering/instances/neighborhood" + "github.com/iotaledger/goshimmer/plugins/autopeering" ) var start = time.Now() @@ -42,10 +39,10 @@ func gatherInfo() nodeInfo { // update neighbors chosenNeighbors := []string{} acceptedNeighbors := []string{} - for _, peer := range chosenneighbors.INSTANCE.Peers.GetMap() { + for _, peer := range autopeering.Selection.GetOutgoingNeighbors() { chosenNeighbors = append(chosenNeighbors, peer.String()) } - for _, peer := range acceptedneighbors.INSTANCE.Peers.GetMap() { + for _, peer := range autopeering.Selection.GetIncomingNeighbors() { acceptedNeighbors = append(acceptedNeighbors, peer.String()) } @@ -55,8 +52,8 @@ func gatherInfo() nodeInfo { ID: accountability.OwnId().StringIdentifier, ChosenNeighbors: chosenNeighbors, AcceptedNeighbors: acceptedNeighbors, - KnownPeersSize: knownpeers.INSTANCE.Peers.Len(), - NeighborhoodSize: neighborhood.INSTANCE.Peers.Len(), + KnownPeersSize: len(autopeering.Discovery.GetVerifiedPeers()), //knownpeers.INSTANCE.Peers.Len(), + NeighborhoodSize: len(autopeering.Selection.GetNeighbors()), //neighborhood.INSTANCE.Peers.Len(), Uptime: uint64(duration), ReceivedTps: receivedTps, SolidTps: solidTps, diff --git a/plugins/ui/ui.go b/plugins/ui/ui.go index 17d0c3d03e..383d360687 100644 --- a/plugins/ui/ui.go +++ b/plugins/ui/ui.go @@ -7,7 +7,7 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/node" diff --git a/plugins/validator/plugin.go b/plugins/validator/plugin.go index f5785b9869..410de706f7 100644 --- a/plugins/validator/plugin.go +++ b/plugins/validator/plugin.go @@ -1,7 +1,7 @@ package validator import ( - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/node" diff --git a/plugins/webapi/plugin.go b/plugins/webapi/plugin.go index f9de1de526..bc43cb7877 100644 --- a/plugins/webapi/plugin.go +++ b/plugins/webapi/plugin.go @@ -5,7 +5,7 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/node" "github.com/labstack/echo" ) diff --git a/plugins/zeromq/plugin.go b/plugins/zeromq/plugin.go index a94a0ce931..77149fe165 100644 --- a/plugins/zeromq/plugin.go +++ b/plugins/zeromq/plugin.go @@ -6,7 +6,7 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/events" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/tangle" From 832210dcdba76f7692f46e58185d58989ecd19c5 Mon Sep 17 00:00:00 2001 From: capossele Date: Wed, 20 Nov 2019 14:40:56 +0000 Subject: [PATCH 002/184] :construction: WIP --- go.mod | 2 -- go.sum | 19 +++--------- plugins/autopeering/autopeering.go | 32 ++++++++++++++++++-- plugins/autopeering/parameters/parameters.go | 11 +++++++ 4 files changed, 45 insertions(+), 19 deletions(-) create mode 100644 plugins/autopeering/parameters/parameters.go diff --git a/go.mod b/go.mod index 9bc9742cb2..4de3582e2d 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/dgraph-io/badger v1.6.0 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b // indirect - github.com/ethereum/go-ethereum v1.9.3 github.com/gdamore/tcell v1.2.0 github.com/go-zeromq/zmq4 v0.5.0 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 @@ -25,5 +24,4 @@ require ( golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 golang.org/x/sys v0.0.0-20191119195528-f068ffe820e4 // indirect golang.org/x/tools v0.0.0-20191120001058-ad01d5993d97 // indirect - google.golang.org/grpc v1.21.0 ) diff --git a/go.sum b/go.sum index 2372f44c50..1a4cf632f3 100644 --- a/go.sum +++ b/go.sum @@ -45,6 +45,7 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4 github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/ethereum/go-ethereum v1.9.3 h1:v3bE4abkXknLcyWCf4TRFn+Ecmm9thPtfLFvTEQ+1+U= github.com/ethereum/go-ethereum v1.9.3/go.mod h1:PwpWDrCLZrV+tfrhqqF6kPknbISMHaJv9Ln3kPCZLwY= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= @@ -86,18 +87,10 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/autopeering-sim v0.0.0-20191115173310-317faa63cf9c h1:1rTNwCmbnt16oL4wwvvaftvEpOLjiBafftAjvsc5GRs= -github.com/iotaledger/autopeering-sim v0.0.0-20191115173310-317faa63cf9c/go.mod h1:cRYqXkJh2PDyW9voFcTOqvCPJaZOmA4u78yb3zuFJNw= -github.com/iotaledger/autopeering-sim v0.0.0-20191118112632-0056a04132b5 h1:VdX7IbHWdi6bPboVschNmzY4tKLMuqYuvF1s/c/RQS8= -github.com/iotaledger/autopeering-sim v0.0.0-20191118112632-0056a04132b5/go.mod h1:LDtLLYVjSuwAH2k3onNt9qhm0EPHLMXRnslsTzn7Yu8= -github.com/iotaledger/autopeering-sim v0.0.0-20191120093237-9e81a790d189 h1:JF1Ky6w0vNk53yMHtW4OgBinE8ZDftPS4LwAs1yJXhY= -github.com/iotaledger/autopeering-sim v0.0.0-20191120093237-9e81a790d189/go.mod h1:/vE248gYTjvoSQ/oL/EIO8sxIDEM/H/n1B9Oubg8C34= github.com/iotaledger/autopeering-sim v0.0.0-20191120103907-203d7715f04c h1:S8UKkR+lbYVquuQE9nvmjYGLvHrWU3HFBcjxmlRbJ5I= github.com/iotaledger/autopeering-sim v0.0.0-20191120103907-203d7715f04c/go.mod h1:/vE248gYTjvoSQ/oL/EIO8sxIDEM/H/n1B9Oubg8C34= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= github.com/iotaledger/hive.go v0.0.0-20191115134440-92f05839b6e0/go.mod h1:Ks2y/bEyfvb7nUA7l69a+8Epsv16UlGev0BvxggHius= -github.com/iotaledger/hive.go v0.0.0-20191116130349-b8be71b827be h1:8aE2Pv9Z2db42CscDf78Yt/uHzHnkAOLmaXvzFqlX7o= -github.com/iotaledger/hive.go v0.0.0-20191116130349-b8be71b827be/go.mod h1:Ks2y/bEyfvb7nUA7l69a+8Epsv16UlGev0BvxggHius= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= github.com/iotaledger/iota.go v1.0.0-beta.7 h1:OaUNahPvOdQz2nKcgeAfcUdxlEDlEV3xwLIkwzZ1B/U= @@ -150,6 +143,7 @@ github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCr github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= @@ -183,9 +177,11 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.5.0/go.mod h1:AkYRkVJF8TkSG/xet6PzXX+l39KhhXa2pdqVSxnTcn4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= @@ -241,8 +237,6 @@ golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191116160921-f9c825593386 h1:ktbWvQrW08Txdxno1PiDpSxPXG6ndGsfnJjRRtkM0LQ= -golang.org/x/net v0.0.0-20191116160921-f9c825593386/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -267,8 +261,6 @@ golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd h1:DBH9mDw0zluJT/R+nGuV3jWFWLFaHyYZWD4tOT+cjn0= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191118090420-b5d5184f72d2 h1:LEXoa2mfx+ZHKVuyzu3/fnknuCCoTfywJVHMkWECH3Y= -golang.org/x/sys v0.0.0-20191118090420-b5d5184f72d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191119195528-f068ffe820e4 h1:FjhQftcbpdYXneEYSWZO7+6Bu+Bi1A8VPvGYWOIzIbw= golang.org/x/sys v0.0.0-20191119195528-f068ffe820e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -283,8 +275,6 @@ golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191118051429-5a76f03bc7c3 h1:3gzOmNy3PLCZ+3Ru/n5Gh7pPjsieiytYSDxFj6QY/oI= -golang.org/x/tools v0.0.0-20191118051429-5a76f03bc7c3/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191120001058-ad01d5993d97 h1:u8hSFDulpuhoY0GHMbG6Rp23PzphtTnZrQX3dOvEae0= golang.org/x/tools v0.0.0-20191120001058-ad01d5993d97/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -307,6 +297,7 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/zeromq/goczmq.v4 v4.1.0 h1:CE+FE81mGVs2aSlnbfLuS1oAwdcVywyMM2AC1g33imI= gopkg.in/zeromq/goczmq.v4 v4.1.0/go.mod h1:h4IlfePEYMpFdywGr5gAwKhBBj+hiBl/nF4VoSE4k+0= diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index bd0ae9ef4b..e064ac5fe4 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -3,8 +3,11 @@ package autopeering import ( "encoding/base64" "fmt" + "io/ioutil" "log" "net" + "net/http" + "strconv" "strings" "github.com/iotaledger/autopeering-sim/discover" @@ -15,6 +18,8 @@ import ( "github.com/iotaledger/autopeering-sim/transport" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" + "github.com/iotaledger/goshimmer/plugins/gossip" ) var ( @@ -48,17 +53,24 @@ const defaultZLC = `{ func start() { var ( - listenAddr = "127.0.0.1:14626" //flag.String("addr", "127.0.0.1:14626", "listen address") - gossipAddr = "127.0.0.1:14666" + //listenAddr = "0.0.0.0:14626" //flag.String("addr", "127.0.0.1:14626", "listen address") + //gossipAddr = "127.0.0.1:14666" masterPeer = "" //flag.String("master", "", "master node as 'pubKey@address' where pubKey is in Base64") err error ) - // flag.Parse() + + host := getMyIP() + apPort := strconv.Itoa(*parameters.PORT.Value) + gossipPort := strconv.Itoa(*gossip.PORT.Value) + listenAddr := host + ":" + apPort + gossipAddr := host + ":" + gossipPort logger := logger.NewLogger(defaultZLC, "debug") defer func() { _ = logger.Sync() }() // ignore the returned error + logger.Debug(host) + addr, err := net.ResolveUDPAddr("udp", listenAddr) if err != nil { log.Fatalf("ResolveUDPAddr: %v", err) @@ -136,3 +148,17 @@ func parseMaster(s string) (*peer.Peer, error) { return peer.NewPeer(pubKey, parts[1]), nil } + +func getMyIP() string { + url := "https://api.ipify.org?format=text" + resp, err := http.Get(url) + if err != nil { + return "" + } + defer resp.Body.Close() + ip, err := ioutil.ReadAll(resp.Body) + if err != nil { + return "" + } + return fmt.Sprintf("%s", ip) +} diff --git a/plugins/autopeering/parameters/parameters.go b/plugins/autopeering/parameters/parameters.go new file mode 100644 index 0000000000..15867abf66 --- /dev/null +++ b/plugins/autopeering/parameters/parameters.go @@ -0,0 +1,11 @@ +package parameters + +import "github.com/iotaledger/goshimmer/packages/parameter" + +var ( + ADDRESS = parameter.AddString("AUTOPEERING/ADDRESS", "0.0.0.0", "address to bind for incoming peering requests") + ENTRY_NODES = parameter.AddString("AUTOPEERING/ENTRY_NODES", "7f7a876a4236091257e650da8dcf195fbe3cb625@159.69.158.51:14626", "list of trusted entry nodes for auto peering") + PORT = parameter.AddInt("AUTOPEERING/PORT", 14626, "tcp port for incoming peering requests") + ACCEPT_REQUESTS = parameter.AddBool("AUTOPEERING/ACCEPT_REQUESTS", true, "accept incoming autopeering requests") + SEND_REQUESTS = parameter.AddBool("AUTOPEERING/SEND_REQUESTS", true, "send autopeering requests") +) \ No newline at end of file From 2c95e07db7ec5d739fff0495c88a9dbb4bab38cf Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 21 Nov 2019 19:05:02 +0000 Subject: [PATCH 003/184] :wrench: fixes parser for entry nodes and logs --- .gitignore | 3 + go.mod | 25 +++--- go.sum | 86 ++++++++++---------- plugins/autopeering/autopeering.go | 75 +++++++++-------- plugins/autopeering/entrynodes.go | 31 +++++++ plugins/autopeering/parameters/parameters.go | 4 +- plugins/autopeering/plugin.go | 6 +- 7 files changed, 129 insertions(+), 101 deletions(-) create mode 100644 plugins/autopeering/entrynodes.go diff --git a/.gitignore b/.gitignore index ba257a7c74..a18828787a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,9 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +# Logs +logs/* + # Project files .idea diff --git a/go.mod b/go.mod index 4de3582e2d..d7079bdf9d 100644 --- a/go.mod +++ b/go.mod @@ -5,23 +5,24 @@ go 1.13 require ( github.com/dgraph-io/badger v1.6.0 github.com/dgrijalva/jwt-go v3.2.0+incompatible - github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b // indirect - github.com/gdamore/tcell v1.2.0 - github.com/go-zeromq/zmq4 v0.5.0 + github.com/gdamore/tcell v1.3.0 + github.com/go-zeromq/zmq4 v0.6.2 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/autopeering-sim v0.0.0-20191120103907-203d7715f04c + github.com/iotaledger/autopeering-sim v0.0.0-20191121125328-c607091f6bc8 github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb - github.com/iotaledger/iota.go v1.0.0-beta.9 + github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible + github.com/lucasb-eyer/go-colorful v1.0.3 // indirect github.com/magiconair/properties v1.8.1 + github.com/mattn/go-colorable v0.1.4 // indirect + github.com/mattn/go-isatty v0.0.10 // indirect + github.com/mattn/go-runewidth v0.0.6 // indirect github.com/pkg/errors v0.8.1 - github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341 - go.uber.org/atomic v1.5.1 // indirect - go.uber.org/multierr v1.4.0 // indirect - go.uber.org/zap v1.13.0 // indirect - golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 + github.com/rivo/tview v0.0.0-20191018125527-685bf6da76c2 + github.com/valyala/fasttemplate v1.1.0 // indirect + golang.org/x/crypto v0.0.0-20191119213627-4f8c1d86b1ba golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 - golang.org/x/sys v0.0.0-20191119195528-f068ffe820e4 // indirect - golang.org/x/tools v0.0.0-20191120001058-ad01d5993d97 // indirect + golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect + golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect ) diff --git a/go.sum b/go.sum index 1a4cf632f3..bbfbf8db73 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,10 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9 h1:HD8gA2tkByhMAwYaFAX9w2l7vxvBQ5NMoxDrkhqhtn4= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DATA-DOG/go-sqlmock v1.3.3 h1:CWUqKXe0s8A2z6qCgkP4Kru7wC11YoAnoupUKFDnH08= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0= github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0= @@ -28,7 +28,6 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgraph-io/badger v1.5.4/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ= github.com/dgraph-io/badger v1.6.0 h1:DshxFxZWXUcO0xX476VJC07Xsr6ZCBVRHKZ93Oh7Evo= @@ -43,28 +42,31 @@ github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b/go.mod h1:SqUrOPUn github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/ethereum/go-ethereum v1.9.3 h1:v3bE4abkXknLcyWCf4TRFn+Ecmm9thPtfLFvTEQ+1+U= github.com/ethereum/go-ethereum v1.9.3/go.mod h1:PwpWDrCLZrV+tfrhqqF6kPknbISMHaJv9Ln3kPCZLwY= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/tcell v1.1.2/go.mod h1:h3kq4HO9l2On+V9ed8w8ewqQEmGCSSHOgQ+2h8uzurE= -github.com/gdamore/tcell v1.2.0 h1:ikixzsxc8K8o3V2/CEmyoEW8mJZaNYQQ3NP3VIQdUe4= github.com/gdamore/tcell v1.2.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM= +github.com/gdamore/tcell v1.3.0 h1:r35w0JBADPZCVQijYebl6YMWWtHRqVEGt7kL2eBADRM= +github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-zeromq/zmq4 v0.5.0 h1:DijriKlrr2b48mymvAsZApiPzrbxQodYKG1aDH1rz8c= +github.com/go-zeromq/goczmq/v4 v4.2.2 h1:HAJN+i+3NW55ijMJJhk7oWxHKXgAuSBkoFfvr8bYj4U= +github.com/go-zeromq/goczmq/v4 v4.2.2/go.mod h1:Sm/lxrfxP/Oxqs0tnHD6WAhwkWrx+S+1MRrKzcxoaYE= github.com/go-zeromq/zmq4 v0.5.0/go.mod h1:6p7pjNlkfrQQVipmEuZDk7fakLZCqPPVK+Iq3jfbDg8= +github.com/go-zeromq/zmq4 v0.6.2 h1:MjiFSwpiQax3LbErEV+H4eNOETGQNwbngq9MlebocbI= +github.com/go-zeromq/zmq4 v0.6.2/go.mod h1:fo1rWyfV/bsg7tq/F9LF1H0e2Cf3ovQFoge1G21AnWU= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -84,19 +86,21 @@ github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgf github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/autopeering-sim v0.0.0-20191120103907-203d7715f04c h1:S8UKkR+lbYVquuQE9nvmjYGLvHrWU3HFBcjxmlRbJ5I= -github.com/iotaledger/autopeering-sim v0.0.0-20191120103907-203d7715f04c/go.mod h1:/vE248gYTjvoSQ/oL/EIO8sxIDEM/H/n1B9Oubg8C34= +github.com/iotaledger/autopeering-sim v0.0.0-20191121110836-741411c1f072 h1:AaBKLhxKAHZomr84jTKVWNk5cj/AQTW2sf/fBScKdLA= +github.com/iotaledger/autopeering-sim v0.0.0-20191121110836-741411c1f072/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191121112351-05d62de2edf2 h1:CGGJVEQIU0PNTc8ZoH7kByH54OATbSXTBC+x2p+eOhY= +github.com/iotaledger/autopeering-sim v0.0.0-20191121112351-05d62de2edf2/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191121125328-c607091f6bc8 h1:4G8MSFJhykckV4n5nQ48lx/qg3sf4MqHP6X4yoii2sc= +github.com/iotaledger/autopeering-sim v0.0.0-20191121125328-c607091f6bc8/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= -github.com/iotaledger/hive.go v0.0.0-20191115134440-92f05839b6e0/go.mod h1:Ks2y/bEyfvb7nUA7l69a+8Epsv16UlGev0BvxggHius= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= -github.com/iotaledger/iota.go v1.0.0-beta.7 h1:OaUNahPvOdQz2nKcgeAfcUdxlEDlEV3xwLIkwzZ1B/U= github.com/iotaledger/iota.go v1.0.0-beta.7/go.mod h1:dMps6iMVU1pf5NDYNKIw4tRsPeC8W3ZWjOvYHOO1PMg= -github.com/iotaledger/iota.go v1.0.0-beta.9 h1:c654s9pkdhMBkABUvWg+6k91MEBbdtmZXP1xDfQpajg= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= +github.com/iotaledger/iota.go v1.0.0-beta.10 h1:PBRWEcBSw0UO7zqEHJLrHOUbjJj1eldlERzOyka/GJo= +github.com/iotaledger/iota.go v1.0.0-beta.10/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= @@ -104,27 +108,28 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= -github.com/lucasb-eyer/go-colorful v1.0.2 h1:mCMFu6PgSozg9tDNMMK3g18oJBX7oYGrC09mS6CXfO4= github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s= +github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac= +github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= -github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= +github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.6 h1:V2iyH+aX9C5fsYCpK60U8BYIvmhqxuOL3JZcqc1NB7k= +github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= @@ -133,9 +138,7 @@ github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uY github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= @@ -143,7 +146,6 @@ github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCr github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= @@ -154,8 +156,9 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341 h1:d2Z5U4d3fenPRFFweaMCogbXiRywM5kgYtu20/hol3M= github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341/go.mod h1:+rKjP5+h9HMwWRpAfhIkkQ9KE3m3Nz5rwn7YtUpwgqk= +github.com/rivo/tview v0.0.0-20191018125527-685bf6da76c2 h1:GVXSfgXOMAeLvFH7IrpY3yYM8H3YekZEFcZ14q9gQXM= +github.com/rivo/tview v0.0.0-20191018125527-685bf6da76c2/go.mod h1:/rBeY22VG2QprWnEqG57IBC8biVu3i0DOIjRLc9I8H0= github.com/rivo/uniseg v0.0.0-20190513083848-b9f5b9457d44/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -177,11 +180,9 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.5.0/go.mod h1:AkYRkVJF8TkSG/xet6PzXX+l39KhhXa2pdqVSxnTcn4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= @@ -190,28 +191,25 @@ github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGr github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= +github.com/valyala/fasttemplate v1.1.0 h1:RZqt0yGBsps8NGvLSGW804QQqCUYYLsaOjTVHy1Ocw4= +github.com/valyala/fasttemplate v1.1.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.mongodb.org/mongo-driver v1.0.0/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= -go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.5.0 h1:OI5t8sDa1Or+q8AeE+yKeB/SDYioSHAgcVljj9JIETY= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.5.1 h1:rsqfU5vBkVknbhUGbAUwQKR2H4ItV8tjJ+6kJX4cxHM= go.uber.org/atomic v1.5.1/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.4.0 h1:f3WCSC2KzAcBXGATIxAB1E2XuCpNU255wNKZ505qi3E= go.uber.org/multierr v1.4.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= -go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0 h1:nR6NoDBgAf67s68NhaXbsojM+2gxp3S1hWkHDl27pVU= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= @@ -220,8 +218,9 @@ golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 h1:Gv7RPwsi3eZ2Fgewe3CBsuOebPwO27PoXzRpJPsvSSM= golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191119213627-4f8c1d86b1ba h1:9bFeDpN3gTqNanMVqNcoR/pJQuP5uroC3t1D7eXozTE= +golang.org/x/crypto v0.0.0-20191119213627-4f8c1d86b1ba/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= @@ -235,7 +234,6 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -244,8 +242,9 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -259,10 +258,12 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd h1:DBH9mDw0zluJT/R+nGuV3jWFWLFaHyYZWD4tOT+cjn0= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191119195528-f068ffe820e4 h1:FjhQftcbpdYXneEYSWZO7+6Bu+Bi1A8VPvGYWOIzIbw= -golang.org/x/sys v0.0.0-20191119195528-f068ffe820e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191018095205-727590c5006e h1:ZtoklVMHQy6BFRHkbG6JzK+S6rX82//Yeok1vMlizfQ= +golang.org/x/sys v0.0.0-20191018095205-727590c5006e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -273,33 +274,28 @@ golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191120001058-ad01d5993d97 h1:u8hSFDulpuhoY0GHMbG6Rp23PzphtTnZrQX3dOvEae0= -golang.org/x/tools v0.0.0-20191120001058-ad01d5993d97/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191121040551-947d4aa89328 h1:t3X42h9e6xdbrCD/gPyWqAXr2BEpdJqRd1brThaaxII= +golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.21.0 h1:G+97AoqBnmZIT91cLG/EkCoK9NSelj64P8bOHHNmGn0= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/h2non/gock.v1 v1.0.14/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/zeromq/goczmq.v4 v4.1.0 h1:CE+FE81mGVs2aSlnbfLuS1oAwdcVywyMM2AC1g33imI= gopkg.in/zeromq/goczmq.v4 v4.1.0/go.mod h1:h4IlfePEYMpFdywGr5gAwKhBBj+hiBl/nF4VoSE4k+0= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index e064ac5fe4..2c98a22c93 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -8,7 +8,6 @@ import ( "net" "net/http" "strconv" - "strings" "github.com/iotaledger/autopeering-sim/discover" "github.com/iotaledger/autopeering-sim/logger" @@ -16,24 +15,24 @@ import ( "github.com/iotaledger/autopeering-sim/selection" "github.com/iotaledger/autopeering-sim/server" "github.com/iotaledger/autopeering-sim/transport" - "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" "github.com/iotaledger/goshimmer/plugins/gossip" ) var ( - PLUGIN = node.NewPlugin("Auto Peering", node.Enabled, configure, run) - close = make(chan struct{}, 1) - srv *server.Server - Discovery *discover.Protocol - Selection *selection.Protocol + PLUGIN = node.NewPlugin("Auto Peering", node.Enabled, configure, run) + debugLevel = "debug" + close = make(chan struct{}, 1) + srv *server.Server + Discovery *discover.Protocol + Selection *selection.Protocol ) const defaultZLC = `{ "level": "info", "development": false, - "outputPaths": ["stdout"], + "outputPaths": ["./logs/autopeering.log"], "errorOutputPaths": ["stderr"], "encoding": "console", "encoderConfig": { @@ -53,25 +52,24 @@ const defaultZLC = `{ func start() { var ( - //listenAddr = "0.0.0.0:14626" //flag.String("addr", "127.0.0.1:14626", "listen address") - //gossipAddr = "127.0.0.1:14666" - masterPeer = "" //flag.String("master", "", "master node as 'pubKey@address' where pubKey is in Base64") - err error ) - host := getMyIP() + host := *parameters.ADDRESS.Value + localhost := host apPort := strconv.Itoa(*parameters.PORT.Value) gossipPort := strconv.Itoa(*gossip.PORT.Value) + if host == "0.0.0.0" { + host = getMyIP() + } listenAddr := host + ":" + apPort gossipAddr := host + ":" + gossipPort - logger := logger.NewLogger(defaultZLC, "debug") - defer func() { _ = logger.Sync() }() // ignore the returned error + logger := logger.NewLogger(defaultZLC, debugLevel) - logger.Debug(host) + defer func() { _ = logger.Sync() }() // ignore the returned error - addr, err := net.ResolveUDPAddr("udp", listenAddr) + addr, err := net.ResolveUDPAddr("udp", localhost+":"+apPort) if err != nil { log.Fatalf("ResolveUDPAddr: %v", err) } @@ -81,12 +79,12 @@ func start() { } defer conn.Close() - var masterPeers []*peer.Peer - master, err := parseMaster(masterPeer) + masterPeers := []*peer.Peer{} + master, err := parseEntryNodes() if err != nil { - log.Printf("Ignoring master: %v\n", err) + log.Printf("Ignoring entry nodes: %v\n", err) } else if master != nil { - masterPeers = []*peer.Peer{master} + masterPeers = master } // use the UDP connection for transport @@ -127,27 +125,28 @@ func start() { defer Selection.Close() id := base64.StdEncoding.EncodeToString(local.PublicKey()) - fmt.Println("Discovery protocol started: ID=" + id + ", address=" + srv.LocalAddr()) + a, b, _ := net.SplitHostPort(srv.LocalAddr()) + logger.Info("Discovery protocol started: ID="+id+", address="+srv.LocalAddr(), a, b) <-close } -func parseMaster(s string) (*peer.Peer, error) { - if len(s) == 0 { - return nil, nil - } - - parts := strings.Split(s, "@") - if len(parts) != 2 { - return nil, errors.New("parseMaster") - } - pubKey, err := base64.StdEncoding.DecodeString(parts[0]) - if err != nil { - return nil, errors.Wrap(err, "parseMaster") - } - - return peer.NewPeer(pubKey, parts[1]), nil -} +// func parseMaster(s string) (*peer.Peer, error) { +// if len(s) == 0 { +// return nil, nil +// } + +// parts := strings.Split(s, "@") +// if len(parts) != 2 { +// return nil, errors.New("parseMaster") +// } +// pubKey, err := base64.StdEncoding.DecodeString(parts[0]) +// if err != nil { +// return nil, errors.Wrap(err, "parseMaster") +// } + +// return peer.NewPeer(pubKey, parts[1]), nil +// } func getMyIP() string { url := "https://api.ipify.org?format=text" diff --git a/plugins/autopeering/entrynodes.go b/plugins/autopeering/entrynodes.go new file mode 100644 index 0000000000..6aa5eb2cd7 --- /dev/null +++ b/plugins/autopeering/entrynodes.go @@ -0,0 +1,31 @@ +package autopeering + +import ( + "encoding/base64" + "strings" + + "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/goshimmer/packages/errors" + "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" +) + +func parseEntryNodes() (result []*peer.Peer, err error) { + for _, entryNodeDefinition := range strings.Fields(*parameters.ENTRY_NODES.Value) { + if entryNodeDefinition == "" { + continue + } + + parts := strings.Split(entryNodeDefinition, "@") + if len(parts) != 2 { + return nil, errors.New("parseMaster") + } + pubKey, err := base64.StdEncoding.DecodeString(parts[0]) + if err != nil { + return nil, errors.Wrap(err, "parseMaster") + } + + result = append(result, peer.NewPeer(pubKey, parts[1])) + } + + return result, nil +} diff --git a/plugins/autopeering/parameters/parameters.go b/plugins/autopeering/parameters/parameters.go index 15867abf66..50aa5c386a 100644 --- a/plugins/autopeering/parameters/parameters.go +++ b/plugins/autopeering/parameters/parameters.go @@ -4,8 +4,8 @@ import "github.com/iotaledger/goshimmer/packages/parameter" var ( ADDRESS = parameter.AddString("AUTOPEERING/ADDRESS", "0.0.0.0", "address to bind for incoming peering requests") - ENTRY_NODES = parameter.AddString("AUTOPEERING/ENTRY_NODES", "7f7a876a4236091257e650da8dcf195fbe3cb625@159.69.158.51:14626", "list of trusted entry nodes for auto peering") + ENTRY_NODES = parameter.AddString("AUTOPEERING/ENTRY_NODES", "qLsSGVTFm3WLJmFgTntHJM/NoFcvN6LpZl2/bFMv2To=@116.202.49.178:14626", "list of trusted entry nodes for auto peering") PORT = parameter.AddInt("AUTOPEERING/PORT", 14626, "tcp port for incoming peering requests") ACCEPT_REQUESTS = parameter.AddBool("AUTOPEERING/ACCEPT_REQUESTS", true, "accept incoming autopeering requests") SEND_REQUESTS = parameter.AddBool("AUTOPEERING/SEND_REQUESTS", true, "send autopeering requests") -) \ No newline at end of file +) diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index b5e9e5ffad..25c3ea9e79 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -35,15 +35,13 @@ func configureLogging(plugin *node.Plugin) { selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { plugin.LogDebug("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - address, _, _ := net.SplitHostPort(ev.Peer.Address()) - port := ev.Services["gossip"].Address + address, port, _ := net.SplitHostPort(ev.Services["gossip"].Address) gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port)) })) selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { plugin.LogDebug("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - address, _, _ := net.SplitHostPort(ev.Peer.Address()) - port := ev.Services["gossip"].Address + address, port, _ := net.SplitHostPort(ev.Services["gossip"].Address) gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port)) })) From aa210a5439c2aa56912948bca9526533cab6628c Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Sat, 16 Nov 2019 19:58:30 +0100 Subject: [PATCH 004/184] replaces logger, node and daemon package with the ones from hive.go --- go.mod | 2 +- go.sum | 10 ++ main.go | 2 +- packages/daemon/daemon.go | 123 ------------- packages/daemon/events.go | 13 -- packages/daemon/types.go | 3 - packages/node/constants.go | 9 - packages/node/events.go | 14 -- packages/node/logger.go | 59 ------- packages/node/node.go | 166 ------------------ packages/node/parameters.go | 17 -- packages/node/plugin.go | 75 -------- packages/node/types.go | 3 - packages/timeutil/sleep.go | 2 +- packages/timeutil/ticker.go | 2 +- .../transactionspammer/transactionspammer.go | 2 +- plugins/analysis/client/plugin.go | 9 +- plugins/analysis/plugin.go | 10 +- plugins/analysis/server/plugin.go | 18 +- .../webinterface/httpserver/plugin.go | 4 +- plugins/analysis/webinterface/plugin.go | 2 +- .../recordedevents/recorded_events.go | 2 +- .../instances/acceptedneighbors/plugin.go | 2 +- .../instances/chosenneighbors/plugin.go | 2 +- .../instances/entrynodes/instance.go | 2 +- .../instances/knownpeers/instance.go | 2 +- .../instances/neighborhood/instance.go | 4 +- .../instances/outgoingrequest/instance.go | 2 +- .../autopeering/instances/ownpeer/instance.go | 2 +- plugins/autopeering/instances/plugin.go | 2 +- .../autopeering/peerstorage/peerstorage.go | 10 +- plugins/autopeering/plugin.go | 22 ++- .../protocol/accepted_neighbor_dropper.go | 4 +- .../protocol/chosen_neighbor_dropper.go | 4 +- plugins/autopeering/protocol/error_handler.go | 4 +- .../protocol/incoming_drop_processor.go | 4 +- .../protocol/incoming_ping_processor.go | 4 +- .../protocol/incoming_request_processor.go | 12 +- .../protocol/incoming_response_processor.go | 4 +- .../protocol/outgoing_ping_processor.go | 16 +- .../protocol/outgoing_request_processor.go | 16 +- plugins/autopeering/protocol/plugin.go | 7 +- .../autopeering/saltmanager/saltmanager.go | 4 +- plugins/autopeering/server/server.go | 2 +- plugins/autopeering/server/tcp/server.go | 24 +-- plugins/autopeering/server/udp/server.go | 26 +-- .../bundleprocessor/bundleprocessor_test.go | 2 +- plugins/bundleprocessor/plugin.go | 28 ++- plugins/cli/cli.go | 2 +- plugins/cli/plugin.go | 7 +- plugins/dashboard/plugin.go | 8 +- plugins/gossip-on-solidification/plugin.go | 2 +- plugins/gossip/neighbors.go | 16 +- plugins/gossip/plugin.go | 4 +- plugins/gossip/send_queue.go | 12 +- plugins/gossip/server.go | 18 +- plugins/gracefulshutdown/plugin.go | 15 +- plugins/metrics/plugin.go | 6 +- plugins/statusscreen-tps/plugin.go | 4 +- plugins/statusscreen/logger.go | 31 +--- plugins/statusscreen/status_message.go | 3 +- plugins/statusscreen/statusscreen.go | 20 ++- plugins/statusscreen/ui_log_entry.go | 20 ++- plugins/tangle/approvers.go | 2 +- plugins/tangle/bundle.go | 2 +- plugins/tangle/plugin.go | 4 +- plugins/tangle/solidifier.go | 26 ++- plugins/tangle/solidifier_test.go | 2 +- plugins/tangle/transaction.go | 2 +- plugins/tangle/transaction_metadata.go | 2 +- plugins/tipselection/plugin.go | 2 +- plugins/ui/logger.go | 41 ++--- plugins/ui/ui.go | 12 +- plugins/validator/plugin.go | 12 +- plugins/webapi-gtta/plugin.go | 2 +- plugins/webapi-spammer/plugin.go | 2 +- plugins/webapi/plugin.go | 16 +- plugins/webauth/webauth.go | 4 +- plugins/zeromq/plugin.go | 23 +-- 79 files changed, 306 insertions(+), 774 deletions(-) delete mode 100644 packages/daemon/daemon.go delete mode 100644 packages/daemon/events.go delete mode 100644 packages/daemon/types.go delete mode 100644 packages/node/constants.go delete mode 100644 packages/node/events.go delete mode 100644 packages/node/logger.go delete mode 100644 packages/node/node.go delete mode 100644 packages/node/parameters.go delete mode 100644 packages/node/plugin.go delete mode 100644 packages/node/types.go diff --git a/go.mod b/go.mod index c2ee7f4c27..4778b1a364 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/golang/protobuf v1.3.2 // indirect github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/hive.go v0.0.0-20191113184748-b545de9170d9 + github.com/iotaledger/hive.go v0.0.0-20191116130349-b8be71b827be github.com/iotaledger/iota.go v1.0.0-beta.9 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect diff --git a/go.sum b/go.sum index f9244b0a7b..25c48c4cbb 100644 --- a/go.sum +++ b/go.sum @@ -80,6 +80,16 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/iotaledger/hive.go v0.0.0-20191113184748-b545de9170d9 h1:zlolyGALm324vLK6zJuw9cNp/XoNqsxqqx4jzHgoaFU= github.com/iotaledger/hive.go v0.0.0-20191113184748-b545de9170d9/go.mod h1:Ks2y/bEyfvb7nUA7l69a+8Epsv16UlGev0BvxggHius= +github.com/iotaledger/hive.go v0.0.0-20191115085829-f860e155ac2a h1:TNEDXmA66NE+0DdAtErNuOu/aep6YlYTqbDACiM4aQc= +github.com/iotaledger/hive.go v0.0.0-20191115085829-f860e155ac2a/go.mod h1:Ks2y/bEyfvb7nUA7l69a+8Epsv16UlGev0BvxggHius= +github.com/iotaledger/hive.go v0.0.0-20191115132232-9512db691c82 h1:J954SXMQS7Z6gnd/z/AFckKEZ+yLscsvMIbwsm9fnjQ= +github.com/iotaledger/hive.go v0.0.0-20191115132232-9512db691c82/go.mod h1:Ks2y/bEyfvb7nUA7l69a+8Epsv16UlGev0BvxggHius= +github.com/iotaledger/hive.go v0.0.0-20191115132634-8a8861c2801f h1:QPkMzHt4TBzZH7piaVz+eEFyV7CBXL/oSBc5lC0ijAE= +github.com/iotaledger/hive.go v0.0.0-20191115132634-8a8861c2801f/go.mod h1:Ks2y/bEyfvb7nUA7l69a+8Epsv16UlGev0BvxggHius= +github.com/iotaledger/hive.go v0.0.0-20191115134440-92f05839b6e0 h1:rHv9I8UNWO3u5QHY+IpxGLIoGKTChZAMSR/GwL3vWKo= +github.com/iotaledger/hive.go v0.0.0-20191115134440-92f05839b6e0/go.mod h1:Ks2y/bEyfvb7nUA7l69a+8Epsv16UlGev0BvxggHius= +github.com/iotaledger/hive.go v0.0.0-20191116130349-b8be71b827be h1:8aE2Pv9Z2db42CscDf78Yt/uHzHnkAOLmaXvzFqlX7o= +github.com/iotaledger/hive.go v0.0.0-20191116130349-b8be71b827be/go.mod h1:Ks2y/bEyfvb7nUA7l69a+8Epsv16UlGev0BvxggHius= github.com/iotaledger/iota.go v1.0.0-beta.9 h1:c654s9pkdhMBkABUvWg+6k91MEBbdtmZXP1xDfQpajg= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= diff --git a/main.go b/main.go index 8f742526f7..b43e2240c7 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/analysis" "github.com/iotaledger/goshimmer/plugins/autopeering" "github.com/iotaledger/goshimmer/plugins/bundleprocessor" @@ -21,6 +20,7 @@ import ( webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi-spammer" "github.com/iotaledger/goshimmer/plugins/webauth" "github.com/iotaledger/goshimmer/plugins/zeromq" + "github.com/iotaledger/hive.go/node" ) func main() { diff --git a/packages/daemon/daemon.go b/packages/daemon/daemon.go deleted file mode 100644 index 2e6aaaddb1..0000000000 --- a/packages/daemon/daemon.go +++ /dev/null @@ -1,123 +0,0 @@ -package daemon - -import ( - "sync" -) - -var ( - running bool - wg sync.WaitGroup - ShutdownSignal = make(chan int, 1) - backgroundWorkers = make([]func(), 0) - backgroundWorkerNames = make([]string, 0) - runningBackgroundWorkers = make(map[string]bool) - lock = sync.Mutex{} -) - -func GetRunningBackgroundWorkers() []string { - lock.Lock() - - result := make([]string, 0) - for runningBackgroundWorker := range runningBackgroundWorkers { - result = append(result, runningBackgroundWorker) - } - - lock.Unlock() - - return result -} - -func runBackgroundWorker(name string, backgroundWorker func()) { - wg.Add(1) - - go func() { - lock.Lock() - runningBackgroundWorkers[name] = true - lock.Unlock() - - backgroundWorker() - - lock.Lock() - delete(runningBackgroundWorkers, name) - lock.Unlock() - - wg.Done() - }() -} - -func BackgroundWorker(name string, handler func()) { - lock.Lock() - - if IsRunning() { - runBackgroundWorker(name, handler) - } else { - backgroundWorkerNames = append(backgroundWorkerNames, name) - backgroundWorkers = append(backgroundWorkers, handler) - } - - lock.Unlock() -} - -func Start() { - if !running { - lock.Lock() - - if !running { - ShutdownSignal = make(chan int, 1) - - running = true - - Events.Run.Trigger() - - for i, backgroundWorker := range backgroundWorkers { - runBackgroundWorker(backgroundWorkerNames[i], backgroundWorker) - } - } - - lock.Unlock() - } -} - -func Run() { - Start() - - wg.Wait() -} - -func Shutdown() { - if running { - lock.Lock() - - if running { - close(ShutdownSignal) - - running = false - - Events.Shutdown.Trigger() - } - - lock.Unlock() - } -} - -func ShutdownAndWait() { - if running { - lock.Lock() - - if running { - close(ShutdownSignal) - - running = false - - Events.Shutdown.Trigger() - } - - lock.Unlock() - } - - wg.Wait() -} - -func IsRunning() bool { - return running -} diff --git a/packages/daemon/events.go b/packages/daemon/events.go deleted file mode 100644 index 256d4c43f4..0000000000 --- a/packages/daemon/events.go +++ /dev/null @@ -1,13 +0,0 @@ -package daemon - -import ( - "github.com/iotaledger/hive.go/events" -) - -var Events = struct { - Run *events.Event - Shutdown *events.Event -}{ - Run: events.NewEvent(events.CallbackCaller), - Shutdown: events.NewEvent(events.CallbackCaller), -} diff --git a/packages/daemon/types.go b/packages/daemon/types.go deleted file mode 100644 index e87a1a750e..0000000000 --- a/packages/daemon/types.go +++ /dev/null @@ -1,3 +0,0 @@ -package daemon - -type Callback = func() diff --git a/packages/node/constants.go b/packages/node/constants.go deleted file mode 100644 index 4e90679ec1..0000000000 --- a/packages/node/constants.go +++ /dev/null @@ -1,9 +0,0 @@ -package node - -const ( - LOG_LEVEL_FAILURE = 0 - LOG_LEVEL_WARNING = 1 - LOG_LEVEL_SUCCESS = 2 - LOG_LEVEL_INFO = 3 - LOG_LEVEL_DEBUG = 4 -) diff --git a/packages/node/events.go b/packages/node/events.go deleted file mode 100644 index 820be882c8..0000000000 --- a/packages/node/events.go +++ /dev/null @@ -1,14 +0,0 @@ -package node - -import ( - "github.com/iotaledger/hive.go/events" -) - -type pluginEvents struct { - Configure *events.Event - Run *events.Event -} - -func pluginCaller(handler interface{}, params ...interface{}) { - handler.(func(*Plugin))(params[0].(*Plugin)) -} diff --git a/packages/node/logger.go b/packages/node/logger.go deleted file mode 100644 index ded291082f..0000000000 --- a/packages/node/logger.go +++ /dev/null @@ -1,59 +0,0 @@ -package node - -import ( - "fmt" - "sync" -) - -type Logger struct { - enabled bool - enabledMutex sync.RWMutex - LogInfo func(pluginName string, message string) - LogSuccess func(pluginName string, message string) - LogWarning func(pluginName string, message string) - LogFailure func(pluginName string, message string) - LogDebug func(pluginName string, message string) -} - -func (logger *Logger) SetEnabled(value bool) { - logger.enabledMutex.Lock() - logger.enabled = value - logger.enabledMutex.Unlock() -} - -func (logger *Logger) GetEnabled() (result bool) { - logger.enabledMutex.RLock() - result = logger.enabled - logger.enabledMutex.RUnlock() - return -} - -func pluginPrefix(pluginName string) string { - var pluginPrefix string - if pluginName == "Node" { - pluginPrefix = "" - } else { - pluginPrefix = pluginName + ": " - } - - return pluginPrefix -} - -var DEFAULT_LOGGER = &Logger{ - enabled: true, - LogSuccess: func(pluginName string, message string) { - fmt.Println("[ OK ] " + pluginPrefix(pluginName) + message) - }, - LogInfo: func(pluginName string, message string) { - fmt.Println("[ INFO ] " + pluginPrefix(pluginName) + message) - }, - LogWarning: func(pluginName string, message string) { - fmt.Println("[ WARN ] " + pluginPrefix(pluginName) + message) - }, - LogFailure: func(pluginName string, message string) { - fmt.Println("[ FAIL ] " + pluginPrefix(pluginName) + message) - }, - LogDebug: func(pluginName string, message string) { - fmt.Println("[ NOTE ] " + pluginPrefix(pluginName) + message) - }, -} diff --git a/packages/node/node.go b/packages/node/node.go deleted file mode 100644 index af82862d94..0000000000 --- a/packages/node/node.go +++ /dev/null @@ -1,166 +0,0 @@ -package node - -import ( - "sync" - - "github.com/iotaledger/hive.go/parameter" - - "github.com/iotaledger/goshimmer/packages/daemon" -) - -type Node struct { - wg *sync.WaitGroup - loggers []*Logger - loadedPlugins []*Plugin -} - -var DisabledPlugins = make(map[string]bool) -var EnabledPlugins = make(map[string]bool) - -func New(plugins ...*Plugin) *Node { - node := &Node{ - loggers: make([]*Logger, 0), - wg: &sync.WaitGroup{}, - loadedPlugins: make([]*Plugin, 0), - } - - node.AddLogger(DEFAULT_LOGGER) - - // configure the enabled plugins - node.configure(plugins...) - - return node -} - -func Start(plugins ...*Plugin) *Node { - node := New(plugins...) - node.Start() - - return node -} - -func Run(plugins ...*Plugin) *Node { - node := New(plugins...) - node.Run() - - return node -} - -func Shutdown() { - daemon.ShutdownAndWait() -} - -func (node *Node) AddLogger(logger *Logger) { - node.loggers = append(node.loggers, logger) -} - -func (node *Node) LogSuccess(pluginName string, message string) { - if parameter.NodeConfig.GetInt(CFG_LOG_LEVEL) >= LOG_LEVEL_SUCCESS { - for _, logger := range node.loggers { - if logger.GetEnabled() { - logger.LogSuccess(pluginName, message) - } - } - } -} - -func (node *Node) LogInfo(pluginName string, message string) { - if parameter.NodeConfig.GetInt(CFG_LOG_LEVEL) >= LOG_LEVEL_INFO { - for _, logger := range node.loggers { - if logger.GetEnabled() { - logger.LogInfo(pluginName, message) - } - } - } -} - -func (node *Node) LogDebug(pluginName string, message string) { - if parameter.NodeConfig.GetInt(CFG_LOG_LEVEL) >= LOG_LEVEL_DEBUG { - for _, logger := range node.loggers { - if logger.GetEnabled() { - logger.LogDebug(pluginName, message) - } - } - } -} - -func (node *Node) LogWarning(pluginName string, message string) { - if parameter.NodeConfig.GetInt(CFG_LOG_LEVEL) >= LOG_LEVEL_WARNING { - for _, logger := range node.loggers { - if logger.GetEnabled() { - logger.LogWarning(pluginName, message) - } - } - } -} - -func (node *Node) LogFailure(pluginName string, message string) { - if parameter.NodeConfig.GetInt(CFG_LOG_LEVEL) >= LOG_LEVEL_FAILURE { - for _, logger := range node.loggers { - if logger.GetEnabled() { - logger.LogFailure(pluginName, message) - } - } - } -} - -func isDisabled(plugin *Plugin) bool { - _, exists := DisabledPlugins[GetPluginIdentifier(plugin.Name)] - - return exists -} - -func isEnabled(plugin *Plugin) bool { - _, exists := EnabledPlugins[GetPluginIdentifier(plugin.Name)] - - return exists -} - -func (node *Node) configure(plugins ...*Plugin) { - for _, plugin := range plugins { - status := plugin.Status - if (status == Enabled && !isDisabled(plugin)) || - (status == Disabled && isEnabled(plugin)) { - - plugin.wg = node.wg - plugin.Node = node - - plugin.Events.Configure.Trigger(plugin) - node.loadedPlugins = append(node.loadedPlugins, plugin) - - node.LogInfo("Node", "Loading Plugin: "+plugin.Name+" ... done") - } else { - node.LogInfo("Node", "Skipping Plugin: "+plugin.Name) - } - } -} - -func (node *Node) Start() { - node.LogInfo("Node", "Executing plugins ...") - - for _, plugin := range node.loadedPlugins { - plugin.Events.Run.Trigger(plugin) - - node.LogSuccess("Node", "Starting Plugin: "+plugin.Name+" ... done") - } - - node.LogSuccess("Node", "Starting background workers ...") - - daemon.Start() -} - -func (node *Node) Run() { - node.LogInfo("Node", "Executing plugins ...") - - for _, plugin := range node.loadedPlugins { - plugin.Events.Run.Trigger(plugin) - - node.LogSuccess("Node", "Starting Plugin: "+plugin.Name+" ... done") - } - - node.LogSuccess("Node", "Starting background workers ...") - - daemon.Run() - - node.LogSuccess("Node", "Shutdown complete!") -} diff --git a/packages/node/parameters.go b/packages/node/parameters.go deleted file mode 100644 index 78862fea3b..0000000000 --- a/packages/node/parameters.go +++ /dev/null @@ -1,17 +0,0 @@ -package node - -import ( - flag "github.com/spf13/pflag" -) - -const ( - CFG_LOG_LEVEL = "node.logLevel" - CFG_DISABLE_PLUGINS = "node.disablePlugins" - CFG_ENABLE_PLGUINS = "node.enablePlugins" -) - -func init() { - flag.Int(CFG_LOG_LEVEL, LOG_LEVEL_INFO, "controls the log types that are shown") - flag.String(CFG_DISABLE_PLUGINS, "", "a list of plugins that shall be disabled") - flag.String(CFG_ENABLE_PLGUINS, "", "a list of plugins that shall be enabled") -} diff --git a/packages/node/plugin.go b/packages/node/plugin.go deleted file mode 100644 index 7a937e9945..0000000000 --- a/packages/node/plugin.go +++ /dev/null @@ -1,75 +0,0 @@ -package node - -import ( - "strings" - "sync" - - "github.com/iotaledger/hive.go/events" - "github.com/iotaledger/hive.go/parameter" -) - -const ( - Disabled = iota - Enabled -) - -type Plugin struct { - Node *Node - Name string - Status int - Events pluginEvents - wg *sync.WaitGroup -} - -// Creates a new plugin with the given name, default status and callbacks. -// The last specified callback is the mandatory run callback, while all other callbacks are configure callbacks. -func NewPlugin(name string, status int, callback Callback, callbacks ...Callback) *Plugin { - plugin := &Plugin{ - Name: name, - Status: status, - Events: pluginEvents{ - Configure: events.NewEvent(pluginCaller), - Run: events.NewEvent(pluginCaller), - }, - } - - // make the plugin known to the parameters - parameter.AddPlugin(name, status) - - if len(callbacks) >= 1 { - plugin.Events.Configure.Attach(events.NewClosure(callback)) - for _, callback = range callbacks[:len(callbacks)-1] { - plugin.Events.Configure.Attach(events.NewClosure(callback)) - } - - plugin.Events.Run.Attach(events.NewClosure(callbacks[len(callbacks)-1])) - } else { - plugin.Events.Run.Attach(events.NewClosure(callback)) - } - - return plugin -} - -func GetPluginIdentifier(name string) string { - return strings.ToLower(strings.Replace(name, " ", "", -1)) -} - -func (plugin *Plugin) LogSuccess(message string) { - plugin.Node.LogSuccess(plugin.Name, message) -} - -func (plugin *Plugin) LogInfo(message string) { - plugin.Node.LogInfo(plugin.Name, message) -} - -func (plugin *Plugin) LogWarning(message string) { - plugin.Node.LogWarning(plugin.Name, message) -} - -func (plugin *Plugin) LogFailure(message string) { - plugin.Node.LogFailure(plugin.Name, message) -} - -func (plugin *Plugin) LogDebug(message string) { - plugin.Node.LogDebug(plugin.Name, message) -} diff --git a/packages/node/types.go b/packages/node/types.go deleted file mode 100644 index fff6b60357..0000000000 --- a/packages/node/types.go +++ /dev/null @@ -1,3 +0,0 @@ -package node - -type Callback = func(plugin *Plugin) diff --git a/packages/timeutil/sleep.go b/packages/timeutil/sleep.go index 0f2577f22f..448c54d0fb 100644 --- a/packages/timeutil/sleep.go +++ b/packages/timeutil/sleep.go @@ -3,7 +3,7 @@ package timeutil import ( "time" - "github.com/iotaledger/goshimmer/packages/daemon" + "github.com/iotaledger/hive.go/daemon" ) func Sleep(interval time.Duration) bool { diff --git a/packages/timeutil/ticker.go b/packages/timeutil/ticker.go index eb076521b6..7530cd0999 100644 --- a/packages/timeutil/ticker.go +++ b/packages/timeutil/ticker.go @@ -3,7 +3,7 @@ package timeutil import ( "time" - "github.com/iotaledger/goshimmer/packages/daemon" + "github.com/iotaledger/hive.go/daemon" ) func Ticker(handler func(), interval time.Duration) { diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index 936519f968..ac1834f6c4 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -6,9 +6,9 @@ import ( "github.com/iotaledger/goshimmer/plugins/gossip" - "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/plugins/tipselection" + "github.com/iotaledger/hive.go/daemon" ) var spamming = false diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index fc882b0544..0fe9170915 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -1,14 +1,13 @@ package client import ( + "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/parameter" "net" "time" "github.com/iotaledger/goshimmer/packages/accountability" - "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/network" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/timeutil" "github.com/iotaledger/goshimmer/plugins/analysis/types/addnode" "github.com/iotaledger/goshimmer/plugins/analysis/types/connectnodes" @@ -18,9 +17,13 @@ import ( "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) +var log = logger.NewLogger("Analysis-Client") + func Run(plugin *node.Plugin) { daemon.BackgroundWorker("Analysis Client", func() { shuttingDown := false @@ -32,7 +35,7 @@ func Run(plugin *node.Plugin) { default: if conn, err := net.Dial("tcp", parameter.NodeConfig.GetString(CFG_SERVER_ADDRESS)); err != nil { - plugin.LogDebug("Could not connect to reporting server: " + err.Error()) + log.Debugf("Could not connect to reporting server: %s", err.Error()) timeutil.Sleep(1 * time.Second) } else { diff --git a/plugins/analysis/plugin.go b/plugins/analysis/plugin.go index 4756341b99..7721f971f8 100644 --- a/plugins/analysis/plugin.go +++ b/plugins/analysis/plugin.go @@ -1,16 +1,18 @@ package analysis import ( - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/analysis/client" "github.com/iotaledger/goshimmer/plugins/analysis/server" "github.com/iotaledger/goshimmer/plugins/analysis/webinterface" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/parameter" ) var PLUGIN = node.NewPlugin("Analysis", node.Enabled, configure, run) +var log = logger.NewLogger("Analysis") func configure(plugin *node.Plugin) { if parameter.NodeConfig.GetInt(server.CFG_SERVER_PORT) != 0 { @@ -28,12 +30,12 @@ func run(plugin *node.Plugin) { webinterface.Run(plugin) server.Run(plugin) } else { - plugin.Node.LogSuccess("Node", "Starting Plugin: Analysis ... server is disabled (server-port is 0)") + log.Info("Starting Plugin: Analysis ... server is disabled (server-port is 0)") } if parameter.NodeConfig.GetString(client.CFG_SERVER_ADDRESS) != "" { client.Run(plugin) } else { - plugin.Node.LogSuccess("Node", "Starting Plugin: Analysis ... client is disabled (server-address is empty)") + log.Info("Starting Plugin: Analysis ... client is disabled (server-address is empty)") } } diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index 35917d4ef0..517a3df193 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -2,16 +2,17 @@ package server import ( "encoding/hex" - "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/network/tcp" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/analysis/types/addnode" "github.com/iotaledger/goshimmer/plugins/analysis/types/connectnodes" "github.com/iotaledger/goshimmer/plugins/analysis/types/disconnectnodes" "github.com/iotaledger/goshimmer/plugins/analysis/types/ping" "github.com/iotaledger/goshimmer/plugins/analysis/types/removenode" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/parameter" "github.com/pkg/errors" "math" @@ -19,31 +20,32 @@ import ( var server *tcp.Server +var log = logger.NewLogger("Analysis-Server") + func Configure(plugin *node.Plugin) { server = tcp.NewServer() server.Events.Connect.Attach(events.NewClosure(HandleConnection)) server.Events.Error.Attach(events.NewClosure(func(err error) { - plugin.LogFailure("error in server: " + err.Error()) + log.Error("error in server: %s", err.Error()) })) server.Events.Start.Attach(events.NewClosure(func() { - plugin.LogSuccess("Starting Server (port " + string(parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) + ") ... done") + log.Infof("Starting Server (port %d) ... done", parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) })) server.Events.Shutdown.Attach(events.NewClosure(func() { - plugin.LogSuccess("Stopping Server ... done") + log.Info("Stopping Server ... done") })) } func Run(plugin *node.Plugin) { daemon.BackgroundWorker("Analysis Server", func() { - plugin.LogInfo("Starting Server (port " + string(parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) + ") ...") - + log.Infof("Starting Server (port %d) ... done", parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) server.Listen(parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) }) } func Shutdown(plugin *node.Plugin) { - plugin.LogInfo("Stopping Server ...") + log.Info("Stopping Server ...") server.Shutdown() } diff --git a/plugins/analysis/webinterface/httpserver/plugin.go b/plugins/analysis/webinterface/httpserver/plugin.go index a86fb7dffe..d02d449ed0 100644 --- a/plugins/analysis/webinterface/httpserver/plugin.go +++ b/plugins/analysis/webinterface/httpserver/plugin.go @@ -4,9 +4,9 @@ import ( "net/http" "time" - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" "golang.org/x/net/context" "golang.org/x/net/websocket" ) diff --git a/plugins/analysis/webinterface/plugin.go b/plugins/analysis/webinterface/plugin.go index 9719472c2a..f217dde659 100644 --- a/plugins/analysis/webinterface/plugin.go +++ b/plugins/analysis/webinterface/plugin.go @@ -1,9 +1,9 @@ package webinterface import ( - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/analysis/webinterface/httpserver" "github.com/iotaledger/goshimmer/plugins/analysis/webinterface/recordedevents" + "github.com/iotaledger/hive.go/node" ) func Configure(plugin *node.Plugin) { diff --git a/plugins/analysis/webinterface/recordedevents/recorded_events.go b/plugins/analysis/webinterface/recordedevents/recorded_events.go index 2a85fbc530..c31574b8cf 100644 --- a/plugins/analysis/webinterface/recordedevents/recorded_events.go +++ b/plugins/analysis/webinterface/recordedevents/recorded_events.go @@ -3,10 +3,10 @@ package recordedevents import ( "sync" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/analysis/server" "github.com/iotaledger/goshimmer/plugins/analysis/webinterface/types" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) var nodes = make(map[string]bool) diff --git a/plugins/autopeering/instances/acceptedneighbors/plugin.go b/plugins/autopeering/instances/acceptedneighbors/plugin.go index 9870c182bb..46f3eb31f0 100644 --- a/plugins/autopeering/instances/acceptedneighbors/plugin.go +++ b/plugins/autopeering/instances/acceptedneighbors/plugin.go @@ -1,6 +1,6 @@ package acceptedneighbors -import "github.com/iotaledger/goshimmer/packages/node" +import "github.com/iotaledger/hive.go/node" func Configure(plugin *node.Plugin) { configureOwnDistance() diff --git a/plugins/autopeering/instances/chosenneighbors/plugin.go b/plugins/autopeering/instances/chosenneighbors/plugin.go index 0e1224fc75..7a33d35f20 100644 --- a/plugins/autopeering/instances/chosenneighbors/plugin.go +++ b/plugins/autopeering/instances/chosenneighbors/plugin.go @@ -1,7 +1,7 @@ package chosenneighbors import ( - "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/node" ) func Configure(plugin *node.Plugin) { diff --git a/plugins/autopeering/instances/entrynodes/instance.go b/plugins/autopeering/instances/entrynodes/instance.go index aae083c61e..ee6c2ad316 100644 --- a/plugins/autopeering/instances/entrynodes/instance.go +++ b/plugins/autopeering/instances/entrynodes/instance.go @@ -9,9 +9,9 @@ import ( "strings" "github.com/iotaledger/goshimmer/packages/identity" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" "github.com/iotaledger/goshimmer/plugins/autopeering/types/peerlist" + "github.com/iotaledger/hive.go/node" ) var INSTANCE *peerlist.PeerList diff --git a/plugins/autopeering/instances/knownpeers/instance.go b/plugins/autopeering/instances/knownpeers/instance.go index 1cf3c56db7..91c12c96d6 100644 --- a/plugins/autopeering/instances/knownpeers/instance.go +++ b/plugins/autopeering/instances/knownpeers/instance.go @@ -1,9 +1,9 @@ package knownpeers import ( - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/entrynodes" "github.com/iotaledger/goshimmer/plugins/autopeering/types/peerregister" + "github.com/iotaledger/hive.go/node" ) var INSTANCE *peerregister.PeerRegister diff --git a/plugins/autopeering/instances/neighborhood/instance.go b/plugins/autopeering/instances/neighborhood/instance.go index 8c693d0ffa..7568b529b2 100644 --- a/plugins/autopeering/instances/neighborhood/instance.go +++ b/plugins/autopeering/instances/neighborhood/instance.go @@ -3,14 +3,14 @@ package neighborhood import ( "time" - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/timeutil" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/outgoingrequest" "github.com/iotaledger/goshimmer/plugins/autopeering/types/peerlist" "github.com/iotaledger/goshimmer/plugins/autopeering/types/peerregister" "github.com/iotaledger/goshimmer/plugins/autopeering/types/request" + "github.com/iotaledger/hive.go/daemon" + "github.com/iotaledger/hive.go/node" ) var INSTANCE *peerregister.PeerRegister diff --git a/plugins/autopeering/instances/outgoingrequest/instance.go b/plugins/autopeering/instances/outgoingrequest/instance.go index 455e558edb..238a608618 100644 --- a/plugins/autopeering/instances/outgoingrequest/instance.go +++ b/plugins/autopeering/instances/outgoingrequest/instance.go @@ -1,12 +1,12 @@ package outgoingrequest import ( - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/ownpeer" "github.com/iotaledger/goshimmer/plugins/autopeering/saltmanager" "github.com/iotaledger/goshimmer/plugins/autopeering/types/request" "github.com/iotaledger/goshimmer/plugins/autopeering/types/salt" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) var INSTANCE *request.Request diff --git a/plugins/autopeering/instances/ownpeer/instance.go b/plugins/autopeering/instances/ownpeer/instance.go index 157a5f2da3..fcd60e7e88 100644 --- a/plugins/autopeering/instances/ownpeer/instance.go +++ b/plugins/autopeering/instances/ownpeer/instance.go @@ -5,11 +5,11 @@ import ( "net" "github.com/iotaledger/goshimmer/packages/accountability" - "github.com/iotaledger/goshimmer/packages/node" autopeering_params "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" "github.com/iotaledger/goshimmer/plugins/autopeering/saltmanager" "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" "github.com/iotaledger/goshimmer/plugins/gossip" + "github.com/iotaledger/hive.go/node" ) var INSTANCE *peer.Peer diff --git a/plugins/autopeering/instances/plugin.go b/plugins/autopeering/instances/plugin.go index ed02fdf6ab..c1f02da20c 100644 --- a/plugins/autopeering/instances/plugin.go +++ b/plugins/autopeering/instances/plugin.go @@ -1,7 +1,6 @@ package instances import ( - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/entrynodes" @@ -9,6 +8,7 @@ import ( "github.com/iotaledger/goshimmer/plugins/autopeering/instances/neighborhood" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/outgoingrequest" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/ownpeer" + "github.com/iotaledger/hive.go/node" ) func Configure(plugin *node.Plugin) { diff --git a/plugins/autopeering/peerstorage/peerstorage.go b/plugins/autopeering/peerstorage/peerstorage.go index b65f21ffb9..f886d07622 100644 --- a/plugins/autopeering/peerstorage/peerstorage.go +++ b/plugins/autopeering/peerstorage/peerstorage.go @@ -2,18 +2,20 @@ package peerstorage import ( "bytes" - "strconv" + "github.com/iotaledger/hive.go/logger" "sync" "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) const peerDbName string = "peers" +var log = logger.NewLogger("Autopeering-Peerstorage") + var peerDb database.Database var once sync.Once @@ -61,13 +63,13 @@ func loadPeers(plugin *node.Plugin) { knownpeers.INSTANCE.AddOrUpdate(peer) count++ - plugin.LogDebug("Added stored peer: " + peer.GetAddress().String() + " / " + peer.GetIdentity().StringIdentifier) + log.Debugf("Added stored peer: %s / %s", peer.GetAddress().String(), peer.GetIdentity().StringIdentifier) }) if err != nil { panic(err) } - plugin.LogSuccess("Restored " + strconv.Itoa(count) + " peers from database") + log.Infof("Restored %d peers from database", count) } func Configure(plugin *node.Plugin) { diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 04c6a41470..86b8a749da 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -1,8 +1,6 @@ package autopeering import ( - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/instances" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" @@ -13,10 +11,14 @@ import ( "github.com/iotaledger/goshimmer/plugins/autopeering/server" "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" "github.com/iotaledger/goshimmer/plugins/gossip" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" ) var PLUGIN = node.NewPlugin("Auto Peering", node.Enabled, configure, run) +var log = logger.NewLogger("Autopeering") func configure(plugin *node.Plugin) { saltmanager.Configure(plugin) @@ -45,36 +47,32 @@ func configureLogging(plugin *node.Plugin) { })) acceptedneighbors.INSTANCE.Events.Add.Attach(events.NewClosure(func(p *peer.Peer) { - plugin.LogDebug("accepted neighbor added: " + p.GetAddress().String() + " / " + p.GetIdentity().StringIdentifier) - + log.Debugf("accepted neighbor added: %s / %s", p.GetAddress().String(), p.GetIdentity().StringIdentifier) gossip.AddNeighbor(gossip.NewNeighbor(p.GetIdentity(), p.GetAddress(), p.GetGossipPort())) })) acceptedneighbors.INSTANCE.Events.Remove.Attach(events.NewClosure(func(p *peer.Peer) { - plugin.LogDebug("accepted neighbor removed: " + p.GetAddress().String() + " / " + p.GetIdentity().StringIdentifier) - + log.Debugf("accepted neighbor removed: %s / %s", p.GetAddress().String(), p.GetIdentity().StringIdentifier) gossip.RemoveNeighbor(p.GetIdentity().StringIdentifier) })) chosenneighbors.INSTANCE.Events.Add.Attach(events.NewClosure(func(p *peer.Peer) { - plugin.LogDebug("chosen neighbor added: " + p.GetAddress().String() + " / " + p.GetIdentity().StringIdentifier) - + log.Debugf("chosen neighbor added: %s / %s", p.GetAddress().String(), p.GetIdentity().StringIdentifier) gossip.AddNeighbor(gossip.NewNeighbor(p.GetIdentity(), p.GetAddress(), p.GetGossipPort())) })) chosenneighbors.INSTANCE.Events.Remove.Attach(events.NewClosure(func(p *peer.Peer) { - plugin.LogDebug("chosen neighbor removed: " + p.GetAddress().String() + " / " + p.GetIdentity().StringIdentifier) - + log.Debugf("chosen neighbor removed: %s / %s", p.GetAddress().String(), p.GetIdentity().StringIdentifier) gossip.RemoveNeighbor(p.GetIdentity().StringIdentifier) })) knownpeers.INSTANCE.Events.Add.Attach(events.NewClosure(func(p *peer.Peer) { - plugin.LogInfo("new peer discovered: " + p.GetAddress().String() + " / " + p.GetIdentity().StringIdentifier) + log.Infof("new peer discovered: %s / %s", p.GetAddress().String(), p.GetIdentity().StringIdentifier) if _, exists := gossip.GetNeighbor(p.GetIdentity().StringIdentifier); exists { gossip.AddNeighbor(gossip.NewNeighbor(p.GetIdentity(), p.GetAddress(), p.GetGossipPort())) } })) knownpeers.INSTANCE.Events.Update.Attach(events.NewClosure(func(p *peer.Peer) { - plugin.LogDebug("peer updated: " + p.GetAddress().String() + " / " + p.GetIdentity().StringIdentifier) + log.Infof("peer updated: %s / %s", p.GetAddress().String(), p.GetIdentity().StringIdentifier) if _, exists := gossip.GetNeighbor(p.GetIdentity().StringIdentifier); exists { gossip.AddNeighbor(gossip.NewNeighbor(p.GetIdentity(), p.GetAddress(), p.GetGossipPort())) diff --git a/plugins/autopeering/protocol/accepted_neighbor_dropper.go b/plugins/autopeering/protocol/accepted_neighbor_dropper.go index f11c9169cd..056023f2d0 100644 --- a/plugins/autopeering/protocol/accepted_neighbor_dropper.go +++ b/plugins/autopeering/protocol/accepted_neighbor_dropper.go @@ -3,13 +3,13 @@ package protocol import ( "time" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/timeutil" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/ownpeer" "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants" "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/types" "github.com/iotaledger/goshimmer/plugins/autopeering/types/drop" + "github.com/iotaledger/hive.go/node" ) func createAcceptedNeighborDropper(plugin *node.Plugin) func() { @@ -29,7 +29,7 @@ func createAcceptedNeighborDropper(plugin *node.Plugin) func() { acceptedneighbors.INSTANCE.Remove(furthestNeighbor.GetIdentity().StringIdentifier) go func() { if _, err := furthestNeighbor.Send(dropMessage.Marshal(), types.PROTOCOL_TYPE_UDP, false); err != nil { - plugin.LogDebug("error when sending drop message to" + acceptedneighbors.FURTHEST_NEIGHBOR.String()) + log.Debugf("error when sending drop message to %s", acceptedneighbors.FURTHEST_NEIGHBOR.String()) } }() } diff --git a/plugins/autopeering/protocol/chosen_neighbor_dropper.go b/plugins/autopeering/protocol/chosen_neighbor_dropper.go index 23d2353302..4071d04efb 100644 --- a/plugins/autopeering/protocol/chosen_neighbor_dropper.go +++ b/plugins/autopeering/protocol/chosen_neighbor_dropper.go @@ -3,13 +3,13 @@ package protocol import ( "time" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/timeutil" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/ownpeer" "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants" "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/types" "github.com/iotaledger/goshimmer/plugins/autopeering/types/drop" + "github.com/iotaledger/hive.go/node" ) func createChosenNeighborDropper(plugin *node.Plugin) func() { @@ -29,7 +29,7 @@ func createChosenNeighborDropper(plugin *node.Plugin) func() { chosenneighbors.INSTANCE.Remove(furthestNeighbor.GetIdentity().StringIdentifier) go func() { if _, err := furthestNeighbor.Send(dropMessage.Marshal(), types.PROTOCOL_TYPE_UDP, false); err != nil { - plugin.LogDebug("error when sending drop message to" + chosenneighbors.FURTHEST_NEIGHBOR.String()) + log.Debugf("error when sending drop message to %s", chosenneighbors.FURTHEST_NEIGHBOR.String()) } }() } diff --git a/plugins/autopeering/protocol/error_handler.go b/plugins/autopeering/protocol/error_handler.go index d64eddc3ed..71f22fcf88 100644 --- a/plugins/autopeering/protocol/error_handler.go +++ b/plugins/autopeering/protocol/error_handler.go @@ -3,12 +3,12 @@ package protocol import ( "net" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) func createErrorHandler(plugin *node.Plugin) *events.Closure { return events.NewClosure(func(ip net.IP, err error) { - plugin.LogDebug("error when communicating with " + ip.String() + ": " + err.Error()) + log.Debugf("error when communicating with %s: %s", ip.String(), err.Error()) }) } diff --git a/plugins/autopeering/protocol/incoming_drop_processor.go b/plugins/autopeering/protocol/incoming_drop_processor.go index 808b5c2eb1..3ab80f3bb7 100644 --- a/plugins/autopeering/protocol/incoming_drop_processor.go +++ b/plugins/autopeering/protocol/incoming_drop_processor.go @@ -1,16 +1,16 @@ package protocol import ( - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" "github.com/iotaledger/goshimmer/plugins/autopeering/types/drop" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) func createIncomingDropProcessor(plugin *node.Plugin) *events.Closure { return events.NewClosure(func(drop *drop.Drop) { - plugin.LogDebug("received drop message from " + drop.Issuer.String()) + log.Debugf("received drop message from %s", drop.Issuer.String()) chosenneighbors.INSTANCE.Remove(drop.Issuer.GetIdentity().StringIdentifier) acceptedneighbors.INSTANCE.Remove(drop.Issuer.GetIdentity().StringIdentifier) diff --git a/plugins/autopeering/protocol/incoming_ping_processor.go b/plugins/autopeering/protocol/incoming_ping_processor.go index 035abaab51..ee52bf539e 100644 --- a/plugins/autopeering/protocol/incoming_ping_processor.go +++ b/plugins/autopeering/protocol/incoming_ping_processor.go @@ -1,15 +1,15 @@ package protocol import ( - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" "github.com/iotaledger/goshimmer/plugins/autopeering/types/ping" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) func createIncomingPingProcessor(plugin *node.Plugin) *events.Closure { return events.NewClosure(func(ping *ping.Ping) { - plugin.LogDebug("received ping from " + ping.Issuer.String()) + log.Debugf("received ping from %s", ping.Issuer.String()) knownpeers.INSTANCE.AddOrUpdate(ping.Issuer) for _, neighbor := range ping.Neighbors.GetPeers() { diff --git a/plugins/autopeering/protocol/incoming_request_processor.go b/plugins/autopeering/protocol/incoming_request_processor.go index 66493c080f..2dbc6f6592 100644 --- a/plugins/autopeering/protocol/incoming_request_processor.go +++ b/plugins/autopeering/protocol/incoming_request_processor.go @@ -6,7 +6,6 @@ import ( "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/neighborhood" @@ -15,6 +14,7 @@ import ( "github.com/iotaledger/goshimmer/plugins/autopeering/types/peerlist" "github.com/iotaledger/goshimmer/plugins/autopeering/types/request" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) func createIncomingRequestProcessor(plugin *node.Plugin) *events.Closure { @@ -24,7 +24,7 @@ func createIncomingRequestProcessor(plugin *node.Plugin) *events.Closure { } func processIncomingRequest(plugin *node.Plugin, req *request.Request) { - plugin.LogDebug("received peering request from " + req.Issuer.String()) + log.Debugf("received peering request from %s", req.Issuer.String()) knownpeers.INSTANCE.AddOrUpdate(req.Issuer) @@ -51,20 +51,20 @@ func requestShouldBeAccepted(req *request.Request) bool { func acceptRequest(plugin *node.Plugin, req *request.Request) { if err := req.Accept(generateProposedPeeringCandidates(req).GetPeers()); err != nil { - plugin.LogDebug("error when sending response to" + req.Issuer.String()) + log.Debugf("error when sending response to %s", req.Issuer.String()) } - plugin.LogDebug("sent positive peering response to " + req.Issuer.String()) + log.Debugf("sent positive peering response to %s", req.Issuer.String()) acceptedneighbors.INSTANCE.AddOrUpdate(req.Issuer) } func rejectRequest(plugin *node.Plugin, req *request.Request) { if err := req.Reject(generateProposedPeeringCandidates(req).GetPeers()); err != nil { - plugin.LogDebug("error when sending response to" + req.Issuer.String()) + log.Debugf("error when sending response to %s", req.Issuer.String()) } - plugin.LogDebug("sent negative peering response to " + req.Issuer.String()) + log.Debugf("sent negative peering response to %s", req.Issuer.String()) } func generateProposedPeeringCandidates(req *request.Request) *peerlist.PeerList { diff --git a/plugins/autopeering/protocol/incoming_response_processor.go b/plugins/autopeering/protocol/incoming_response_processor.go index e2f45f9657..60b222c09f 100644 --- a/plugins/autopeering/protocol/incoming_response_processor.go +++ b/plugins/autopeering/protocol/incoming_response_processor.go @@ -1,11 +1,11 @@ package protocol import ( - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/knownpeers" "github.com/iotaledger/goshimmer/plugins/autopeering/types/response" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) func createIncomingResponseProcessor(plugin *node.Plugin) *events.Closure { @@ -15,7 +15,7 @@ func createIncomingResponseProcessor(plugin *node.Plugin) *events.Closure { } func processIncomingResponse(plugin *node.Plugin, peeringResponse *response.Response) { - plugin.LogDebug("received peering response from " + peeringResponse.Issuer.String()) + log.Debugf("received peering response from %s", peeringResponse.Issuer.String()) if conn := peeringResponse.Issuer.GetConn(); conn != nil { _ = conn.Close() diff --git a/plugins/autopeering/protocol/outgoing_ping_processor.go b/plugins/autopeering/protocol/outgoing_ping_processor.go index aacc3eddd4..1aa0dafcd6 100644 --- a/plugins/autopeering/protocol/outgoing_ping_processor.go +++ b/plugins/autopeering/protocol/outgoing_ping_processor.go @@ -5,8 +5,6 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/accountability" - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/neighborhood" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/ownpeer" "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants" @@ -15,15 +13,17 @@ import ( "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" "github.com/iotaledger/goshimmer/plugins/autopeering/types/ping" "github.com/iotaledger/goshimmer/plugins/autopeering/types/salt" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) var lastPing time.Time func createOutgoingPingProcessor(plugin *node.Plugin) func() { return func() { - plugin.LogInfo("Starting Ping Processor ...") - plugin.LogSuccess("Starting Ping Processor ... done") + log.Info("Starting Ping Processor ...") + log.Info("Starting Ping Processor ... done") lastPing = time.Now().Add(-constants.PING_CYCLE_LENGTH) @@ -43,7 +43,7 @@ func createOutgoingPingProcessor(plugin *node.Plugin) func() { for { select { case <-daemon.ShutdownSignal: - plugin.LogInfo("Stopping Ping Processor ...") + log.Info("Stopping Ping Processor ...") break ticker case <-ticker.C: @@ -51,7 +51,7 @@ func createOutgoingPingProcessor(plugin *node.Plugin) func() { } } - plugin.LogSuccess("Stopping Ping Processor ... done") + log.Info("Stopping Ping Processor ... done") } } @@ -73,9 +73,9 @@ func pingPeers(plugin *node.Plugin, outgoingPing *ping.Ping) { for _, chosenPeer := range chosenPeers { go func(chosenPeer *peer.Peer) { if _, err := chosenPeer.Send(outgoingPing.Marshal(), types.PROTOCOL_TYPE_UDP, false); err != nil { - plugin.LogDebug("error when sending ping to " + chosenPeer.String() + ": " + err.Error()) + log.Debugf("error when sending ping to %s: %s", chosenPeer.String(), err.Error()) } else { - plugin.LogDebug("sent ping to " + chosenPeer.String()) + log.Debugf("sent ping to %s", chosenPeer.String()) } }(chosenPeer) } diff --git a/plugins/autopeering/protocol/outgoing_request_processor.go b/plugins/autopeering/protocol/outgoing_request_processor.go index f36c08af7c..8f6c3d7e15 100644 --- a/plugins/autopeering/protocol/outgoing_request_processor.go +++ b/plugins/autopeering/protocol/outgoing_request_processor.go @@ -10,18 +10,18 @@ import ( "github.com/iotaledger/goshimmer/packages/timeutil" "github.com/iotaledger/goshimmer/packages/accountability" - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/acceptedneighbors" "github.com/iotaledger/goshimmer/plugins/autopeering/instances/chosenneighbors" "github.com/iotaledger/goshimmer/plugins/autopeering/protocol/constants" "github.com/iotaledger/goshimmer/plugins/autopeering/types/peer" + "github.com/iotaledger/hive.go/daemon" + "github.com/iotaledger/hive.go/node" ) func createOutgoingRequestProcessor(plugin *node.Plugin) func() { return func() { - plugin.LogInfo("Starting Chosen Neighbor Processor ...") - plugin.LogSuccess("Starting Chosen Neighbor Processor ... done") + log.Info("Starting Chosen Neighbor Processor ...") + log.Info("Starting Chosen Neighbor Processor ... done") sendOutgoingRequests(plugin) @@ -30,7 +30,7 @@ func createOutgoingRequestProcessor(plugin *node.Plugin) func() { for { select { case <-daemon.ShutdownSignal: - plugin.LogInfo("Stopping Chosen Neighbor Processor ...") + log.Info("Stopping Chosen Neighbor Processor ...") break ticker case <-ticker.C: @@ -38,7 +38,7 @@ func createOutgoingRequestProcessor(plugin *node.Plugin) func() { } } - plugin.LogSuccess("Stopping Chosen Neighbor Processor ... done") + log.Info("Stopping Chosen Neighbor Processor ... done") } } @@ -51,9 +51,9 @@ func sendOutgoingRequests(plugin *node.Plugin) { go func(doneChan chan int) { if dialed, err := chosenNeighborCandidate.Send(outgoingrequest.INSTANCE.Marshal(), types.PROTOCOL_TYPE_TCP, true); err != nil { - plugin.LogDebug(err.Error()) + log.Debug(err.Error()) } else { - plugin.LogDebug("sent peering request to " + chosenNeighborCandidate.String()) + log.Debugf("sent peering request to %s", chosenNeighborCandidate.String()) if dialed { tcp.HandleConnection(chosenNeighborCandidate.GetConn()) diff --git a/plugins/autopeering/protocol/plugin.go b/plugins/autopeering/protocol/plugin.go index 569871e4c6..c026f2aa4a 100644 --- a/plugins/autopeering/protocol/plugin.go +++ b/plugins/autopeering/protocol/plugin.go @@ -1,14 +1,17 @@ package protocol import ( - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" "github.com/iotaledger/goshimmer/plugins/autopeering/server/tcp" "github.com/iotaledger/goshimmer/plugins/autopeering/server/udp" + "github.com/iotaledger/hive.go/daemon" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/parameter" ) +var log = logger.NewLogger("Autopeering-Protocol") + func Configure(plugin *node.Plugin) { errorHandler := createErrorHandler(plugin) diff --git a/plugins/autopeering/saltmanager/saltmanager.go b/plugins/autopeering/saltmanager/saltmanager.go index 6cb06a9a13..a8e47b7848 100644 --- a/plugins/autopeering/saltmanager/saltmanager.go +++ b/plugins/autopeering/saltmanager/saltmanager.go @@ -3,11 +3,11 @@ package saltmanager import ( "time" - "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/settings" "github.com/iotaledger/goshimmer/plugins/autopeering/types/salt" + "github.com/iotaledger/hive.go/daemon" + "github.com/iotaledger/hive.go/node" ) var ( diff --git a/plugins/autopeering/server/server.go b/plugins/autopeering/server/server.go index cf51cd303e..d04941f25b 100644 --- a/plugins/autopeering/server/server.go +++ b/plugins/autopeering/server/server.go @@ -1,9 +1,9 @@ package server import ( - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/server/tcp" "github.com/iotaledger/goshimmer/plugins/autopeering/server/udp" + "github.com/iotaledger/hive.go/node" ) func Configure(plugin *node.Plugin) { diff --git a/plugins/autopeering/server/tcp/server.go b/plugins/autopeering/server/tcp/server.go index a5b839512a..9ac9454e6a 100644 --- a/plugins/autopeering/server/tcp/server.go +++ b/plugins/autopeering/server/tcp/server.go @@ -4,51 +4,53 @@ import ( "math" "net" - "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/network/tcp" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" "github.com/iotaledger/goshimmer/plugins/autopeering/types/ping" "github.com/iotaledger/goshimmer/plugins/autopeering/types/request" "github.com/iotaledger/goshimmer/plugins/autopeering/types/response" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/parameter" "github.com/pkg/errors" ) var server = tcp.NewServer() +var log = logger.NewLogger("Autopeering-TCPServer") func ConfigureServer(plugin *node.Plugin) { serverAddress := parameter.NodeConfig.GetString(parameters.CFG_ADDRESS) - serverPortStr := parameter.NodeConfig.GetString(parameters.CFG_PORT) + serverPort := parameter.NodeConfig.GetInt(parameters.CFG_PORT) server.Events.Connect.Attach(events.NewClosure(HandleConnection)) server.Events.Error.Attach(events.NewClosure(func(err error) { - plugin.LogFailure("error in tcp server: " + err.Error()) + log.Errorf("error in tcp server: %s", err.Error()) })) server.Events.Start.Attach(events.NewClosure(func() { if serverAddress == "0.0.0.0" { - plugin.LogSuccess("Starting TCP Server (port " + serverPortStr + ") ... done") + log.Infof("Starting TCP Server (port %d) ... done", serverPort) } else { - plugin.LogSuccess("Starting TCP Server (" + serverAddress + ":" + serverPortStr + ") ... done") + log.Infof("Starting TCP Server (%s:%d) ... done", serverAddress, serverPort) } })) server.Events.Shutdown.Attach(events.NewClosure(func() { - plugin.LogSuccess("Stopping TCP Server ... done") + log.Info("Stopping TCP Server ... done") })) } func RunServer(plugin *node.Plugin) { serverAddress := parameter.NodeConfig.GetString(parameters.CFG_ADDRESS) - serverPortStr := parameter.NodeConfig.GetString(parameters.CFG_PORT) + serverPort := parameter.NodeConfig.GetInt(parameters.CFG_PORT) daemon.BackgroundWorker("Autopeering TCP Server", func() { if serverAddress == "0.0.0.0" { - plugin.LogInfo("Starting TCP Server (port " + serverPortStr + ") ...") + log.Infof("Starting TCP Server (port %d) ...", serverPort) } else { - plugin.LogInfo("Starting TCP Server (" + serverAddress + ":" + serverPortStr + ") ...") + log.Infof("Starting TCP Server (%s:%d) ...", serverAddress, serverPort) } server.Listen(parameter.NodeConfig.GetInt(parameters.CFG_PORT)) @@ -56,7 +58,7 @@ func RunServer(plugin *node.Plugin) { } func ShutdownServer(plugin *node.Plugin) { - plugin.LogInfo("Stopping TCP Server ...") + log.Info("Stopping TCP Server ...") server.Shutdown() } diff --git a/plugins/autopeering/server/udp/server.go b/plugins/autopeering/server/udp/server.go index 4af9f31269..5c6019bc5c 100644 --- a/plugins/autopeering/server/udp/server.go +++ b/plugins/autopeering/server/udp/server.go @@ -1,15 +1,16 @@ package udp import ( - "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/network/udp" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" "github.com/iotaledger/goshimmer/plugins/autopeering/types/drop" "github.com/iotaledger/goshimmer/plugins/autopeering/types/ping" "github.com/iotaledger/goshimmer/plugins/autopeering/types/request" "github.com/iotaledger/goshimmer/plugins/autopeering/types/response" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/parameter" "github.com/pkg/errors" "math" @@ -17,40 +18,41 @@ import ( ) var udpServer = udp.NewServer(int(math.Max(float64(request.MARSHALED_TOTAL_SIZE), float64(response.MARSHALED_TOTAL_SIZE)))) +var log = logger.NewLogger("Autopeering-UDPServer") func ConfigureServer(plugin *node.Plugin) { serverAddress := parameter.NodeConfig.GetString(parameters.CFG_ADDRESS) - serverPortStr := parameter.NodeConfig.GetString(parameters.CFG_PORT) + serverPort := parameter.NodeConfig.GetInt(parameters.CFG_PORT) Events.Error.Attach(events.NewClosure(func(ip net.IP, err error) { - plugin.LogFailure(err.Error()) + log.Error(err.Error()) })) udpServer.Events.ReceiveData.Attach(events.NewClosure(processReceivedData)) udpServer.Events.Error.Attach(events.NewClosure(func(err error) { - plugin.LogFailure("error in udp server: " + err.Error()) + log.Errorf("error in udp server: %s", err.Error()) })) udpServer.Events.Start.Attach(events.NewClosure(func() { if serverAddress == "0.0.0.0" { - plugin.LogSuccess("Starting UDP Server (port " + serverPortStr + ") ... done") + log.Infof("Starting UDP Server (port %d) ... done", serverPort) } else { - plugin.LogSuccess("Starting UDP Server (" + serverAddress + ":" + serverPortStr + ") ... done") + log.Infof("Starting UDP Server (%s:%d) ... done", serverAddress, serverPort) } })) udpServer.Events.Shutdown.Attach(events.NewClosure(func() { - plugin.LogSuccess("Stopping UDP Server ... done") + log.Info("Stopping UDP Server ... done") })) } func RunServer(plugin *node.Plugin) { serverAddress := parameter.NodeConfig.GetString(parameters.CFG_ADDRESS) - serverPortStr := parameter.NodeConfig.GetString(parameters.CFG_PORT) + serverPort := parameter.NodeConfig.GetInt(parameters.CFG_PORT) daemon.BackgroundWorker("Autopeering UDP Server", func() { if serverAddress == "0.0.0.0" { - plugin.LogInfo("Starting UDP Server (port " + serverPortStr + ") ...") + log.Infof("Starting UDP Server (port %d) ...", serverPort) } else { - plugin.LogInfo("Starting UDP Server (" + serverAddress + ":" + serverPortStr + ") ...") + log.Infof("Starting UDP Server (%s:%d) ...", serverAddress, serverPort) } udpServer.Listen(serverAddress, parameter.NodeConfig.GetInt(parameters.CFG_PORT)) @@ -58,7 +60,7 @@ func RunServer(plugin *node.Plugin) { } func ShutdownUDPServer(plugin *node.Plugin) { - plugin.LogInfo("Stopping UDP Server ...") + log.Info("Stopping UDP Server ...") udpServer.Shutdown() } diff --git a/plugins/bundleprocessor/bundleprocessor_test.go b/plugins/bundleprocessor/bundleprocessor_test.go index 99a47471a4..6fda90857c 100644 --- a/plugins/bundleprocessor/bundleprocessor_test.go +++ b/plugins/bundleprocessor/bundleprocessor_test.go @@ -14,7 +14,7 @@ import ( "github.com/iotaledger/goshimmer/packages/client" - "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/iota.go/consts" diff --git a/plugins/bundleprocessor/plugin.go b/plugins/bundleprocessor/plugin.go index f9b0143351..2344caa6c4 100644 --- a/plugins/bundleprocessor/plugin.go +++ b/plugins/bundleprocessor/plugin.go @@ -1,15 +1,17 @@ package bundleprocessor import ( - "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/tangle" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" ) var PLUGIN = node.NewPlugin("Bundle Processor", node.Enabled, configure, run) +var log = logger.NewLogger("Bundle Processor") func configure(plugin *node.Plugin) { tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { @@ -19,38 +21,34 @@ func configure(plugin *node.Plugin) { })) Events.Error.Attach(events.NewClosure(func(err errors.IdentifiableError) { - plugin.LogFailure(err.Error()) + log.Error(err.Error()) })) daemon.Events.Shutdown.Attach(events.NewClosure(func() { - plugin.LogInfo("Stopping Bundle Processor ...") + log.Info("Stopping Bundle Processor ...") workerPool.Stop() - plugin.LogInfo("Stopping Value Bundle Processor ...") + log.Info("Stopping Value Bundle Processor ...") valueBundleProcessorWorkerPool.Stop() })) } func run(plugin *node.Plugin) { - plugin.LogInfo("Starting Bundle Processor ...") + log.Info("Starting Bundle Processor ...") daemon.BackgroundWorker("Bundle Processor", func() { - plugin.LogSuccess("Starting Bundle Processor ... done") - + log.Info("Starting Bundle Processor ... done") workerPool.Run() - - plugin.LogSuccess("Stopping Bundle Processor ... done") + log.Info("Stopping Bundle Processor ... done") }) - plugin.LogInfo("Starting Value Bundle Processor ...") + log.Info("Starting Value Bundle Processor ...") daemon.BackgroundWorker("Value Bundle Processor", func() { - plugin.LogSuccess("Starting Value Bundle Processor ... done") - + log.Info("Starting Value Bundle Processor ... done") valueBundleProcessorWorkerPool.Run() - - plugin.LogSuccess("Stopping Value Bundle Processor ... done") + log.Info("Stopping Value Bundle Processor ... done") }) } diff --git a/plugins/cli/cli.go b/plugins/cli/cli.go index 55106e01a3..9275838b1e 100644 --- a/plugins/cli/cli.go +++ b/plugins/cli/cli.go @@ -9,7 +9,7 @@ import ( flag "github.com/spf13/pflag" - "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/node" ) var enabledPlugins []string diff --git a/plugins/cli/plugin.go b/plugins/cli/plugin.go index c7ac5908de..4439bb9117 100644 --- a/plugins/cli/plugin.go +++ b/plugins/cli/plugin.go @@ -7,7 +7,8 @@ import ( "github.com/iotaledger/hive.go/events" flag "github.com/spf13/pflag" - "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/parameter" ) @@ -39,7 +40,7 @@ func parseParameters() { for _, pluginName := range parameter.NodeConfig.GetStringSlice(node.CFG_DISABLE_PLUGINS) { node.DisabledPlugins[strings.ToLower(pluginName)] = true } - for _, pluginName := range parameter.NodeConfig.GetStringSlice(node.CFG_ENABLE_PLGUINS) { + for _, pluginName := range parameter.NodeConfig.GetStringSlice(node.CFG_ENABLE_PLUGINS) { node.EnabledPlugins[strings.ToLower(pluginName)] = true } } @@ -57,7 +58,7 @@ func configure(ctx *node.Plugin) { parameter.FetchConfig() parseParameters() - ctx.Node.LogInfo("Node", "Loading plugins ...") + ctx.Node.Logger.Info("Loading plugins ...") } func run(ctx *node.Plugin) { diff --git a/plugins/dashboard/plugin.go b/plugins/dashboard/plugin.go index 5b38ebed57..a5815826a3 100644 --- a/plugins/dashboard/plugin.go +++ b/plugins/dashboard/plugin.go @@ -1,15 +1,16 @@ package dashboard import ( + "github.com/iotaledger/hive.go/logger" "net/http" "time" "golang.org/x/net/context" - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/metrics" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) var server *http.Server @@ -17,6 +18,7 @@ var server *http.Server var router *http.ServeMux var PLUGIN = node.NewPlugin("Dashboard", node.Disabled, configure, run) +var log = logger.NewLogger("Dashboard") func configure(plugin *node.Plugin) { router = http.NewServeMux() @@ -45,7 +47,7 @@ func run(plugin *node.Plugin) { daemon.BackgroundWorker("Dashboard Updater", func() { go func() { if err := server.ListenAndServe(); err != nil { - plugin.LogFailure(err.Error()) + log.Error(err.Error()) } }() }) diff --git a/plugins/gossip-on-solidification/plugin.go b/plugins/gossip-on-solidification/plugin.go index 22c0f1067b..42b09256ba 100644 --- a/plugins/gossip-on-solidification/plugin.go +++ b/plugins/gossip-on-solidification/plugin.go @@ -2,10 +2,10 @@ package gossip_on_solidification import ( "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) var PLUGIN = node.NewPlugin("Gossip On Solidification", node.Enabled, func(plugin *node.Plugin) { diff --git a/plugins/gossip/neighbors.go b/plugins/gossip/neighbors.go index 2310767916..ef3431c14c 100644 --- a/plugins/gossip/neighbors.go +++ b/plugins/gossip/neighbors.go @@ -8,30 +8,30 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/accountability" - "github.com/iotaledger/goshimmer/packages/daemon" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/identity" "github.com/iotaledger/goshimmer/packages/network" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) func configureNeighbors(plugin *node.Plugin) { Events.AddNeighbor.Attach(events.NewClosure(func(neighbor *Neighbor) { - plugin.LogSuccess("new neighbor added " + neighbor.GetIdentity().StringIdentifier + "@" + neighbor.GetAddress().String() + ":" + strconv.Itoa(int(neighbor.GetPort()))) + log.Infof("new neighbor added %s@%s:%d", neighbor.GetIdentity().StringIdentifier, neighbor.GetAddress().String(), neighbor.GetPort()) })) Events.UpdateNeighbor.Attach(events.NewClosure(func(neighbor *Neighbor) { - plugin.LogSuccess("existing neighbor updated " + neighbor.GetIdentity().StringIdentifier + "@" + neighbor.GetAddress().String() + ":" + strconv.Itoa(int(neighbor.GetPort()))) + log.Infof("existing neighbor updated %s@%s:%d", neighbor.GetIdentity().StringIdentifier, neighbor.GetAddress().String(), neighbor.GetPort()) })) Events.RemoveNeighbor.Attach(events.NewClosure(func(neighbor *Neighbor) { - plugin.LogSuccess("existing neighbor removed " + neighbor.GetIdentity().StringIdentifier + "@" + neighbor.GetAddress().String() + ":" + strconv.Itoa(int(neighbor.GetPort()))) + log.Infof("existing neighbor removed %s@%s:%d", neighbor.GetIdentity().StringIdentifier, neighbor.GetAddress().String(), neighbor.GetPort()) })) } func runNeighbors(plugin *node.Plugin) { - plugin.LogInfo("Starting Neighbor Connection Manager ...") + log.Info("Starting Neighbor Connection Manager ...") neighborLock.RLock() for _, neighbor := range neighbors.GetMap() { @@ -43,7 +43,7 @@ func runNeighbors(plugin *node.Plugin) { manageConnection(plugin, neighbor) })) - plugin.LogSuccess("Starting Neighbor Connection Manager ... done") + log.Info("Starting Neighbor Connection Manager ... done") } func manageConnection(plugin *node.Plugin, neighbor *Neighbor) { @@ -55,7 +55,7 @@ func manageConnection(plugin *node.Plugin, neighbor *Neighbor) { if err != nil { failedConnectionAttempts++ - plugin.LogFailure("connection attempt [" + strconv.Itoa(int(failedConnectionAttempts)) + "/" + strconv.Itoa(CONNECTION_MAX_ATTEMPTS) + "] " + err.Error()) + log.Errorf("connection attempt [%d / %d] %s", failedConnectionAttempts, CONNECTION_MAX_ATTEMPTS, err.Error()) if failedConnectionAttempts <= CONNECTION_MAX_ATTEMPTS { select { diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 872e3caca3..c3d7ffef9f 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -1,10 +1,12 @@ package gossip import ( - "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" ) var PLUGIN = node.NewPlugin("Gossip", node.Enabled, configure, run) +var log = logger.NewLogger("Gossip") func configure(plugin *node.Plugin) { configureNeighbors(plugin) diff --git a/plugins/gossip/send_queue.go b/plugins/gossip/send_queue.go index 7b92be4ab0..b3b78bb0d7 100644 --- a/plugins/gossip/send_queue.go +++ b/plugins/gossip/send_queue.go @@ -3,10 +3,10 @@ package gossip import ( "sync" - "github.com/iotaledger/goshimmer/packages/daemon" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) // region plugin module setup ////////////////////////////////////////////////////////////////////////////////////////// @@ -19,20 +19,20 @@ func configureSendQueue(plugin *node.Plugin) { Events.AddNeighbor.Attach(events.NewClosure(setupEventHandlers)) daemon.Events.Shutdown.Attach(events.NewClosure(func() { - plugin.LogInfo("Stopping Send Queue Dispatcher ...") + log.Info("Stopping Send Queue Dispatcher ...") })) } func runSendQueue(plugin *node.Plugin) { - plugin.LogInfo("Starting Send Queue Dispatcher ...") + log.Info("Starting Send Queue Dispatcher ...") daemon.BackgroundWorker("Gossip Send Queue Dispatcher", func() { - plugin.LogSuccess("Starting Send Queue Dispatcher ... done") + log.Info("Starting Send Queue Dispatcher ... done") for { select { case <-daemon.ShutdownSignal: - plugin.LogSuccess("Stopping Send Queue Dispatcher ... done") + log.Info("Stopping Send Queue Dispatcher ... done") return diff --git a/plugins/gossip/server.go b/plugins/gossip/server.go index 5577d446d4..99520078df 100644 --- a/plugins/gossip/server.go +++ b/plugins/gossip/server.go @@ -2,13 +2,13 @@ package gossip import ( "github.com/iotaledger/goshimmer/packages/accountability" - "github.com/iotaledger/goshimmer/packages/daemon" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/identity" "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/network/tcp" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/parameter" ) @@ -20,7 +20,7 @@ func configureServer(plugin *node.Plugin) { // print protocol errors protocol.Events.Error.Attach(events.NewClosure(func(err errors.IdentifiableError) { - plugin.LogFailure(err.Error()) + log.Error(err.Error()) })) // store protocol in neighbor if its a neighbor calling @@ -57,21 +57,21 @@ func configureServer(plugin *node.Plugin) { })) daemon.Events.Shutdown.Attach(events.NewClosure(func() { - plugin.LogInfo("Stopping TCP Server ...") + log.Info("Stopping TCP Server ...") TCPServer.Shutdown() })) } func runServer(plugin *node.Plugin) { - gossipPort := parameter.NodeConfig.GetString(GOSSIP_PORT) - plugin.LogInfo("Starting TCP Server (port " + gossipPort + ") ...") + gossipPort := parameter.NodeConfig.GetInt(GOSSIP_PORT) + log.Infof("Starting TCP Server (port %d) ...", gossipPort) daemon.BackgroundWorker("Gossip TCP Server", func() { - plugin.LogSuccess("Starting TCP Server (port " + gossipPort + ") ... done") + log.Infof("Starting TCP Server (port %d) ... done", gossipPort) - TCPServer.Listen(parameter.NodeConfig.GetInt(GOSSIP_PORT)) + TCPServer.Listen(gossipPort) - plugin.LogSuccess("Stopping TCP Server ... done") + log.Info("Stopping TCP Server ... done") }) } diff --git a/plugins/gracefulshutdown/plugin.go b/plugins/gracefulshutdown/plugin.go index 41da78c249..d24c61b26b 100644 --- a/plugins/gracefulshutdown/plugin.go +++ b/plugins/gracefulshutdown/plugin.go @@ -1,20 +1,21 @@ package gracefulshutdown import ( + "github.com/iotaledger/hive.go/logger" "os" "os/signal" - "strconv" "strings" "syscall" "time" - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/daemon" + "github.com/iotaledger/hive.go/node" ) // maximum amount of time to wait for background processes to terminate. After that the process is killed. const WAIT_TO_KILL_TIME_IN_SECONDS = 10 +var log = logger.NewLogger("Graceful Shutdown") var PLUGIN = node.NewPlugin("Graceful Shutdown", node.Enabled, func(plugin *node.Plugin) { gracefulStop := make(chan os.Signal) @@ -24,7 +25,7 @@ var PLUGIN = node.NewPlugin("Graceful Shutdown", node.Enabled, func(plugin *node go func() { <-gracefulStop - plugin.LogWarning("Received shutdown request - waiting (max " + strconv.Itoa(WAIT_TO_KILL_TIME_IN_SECONDS) + " seconds) to finish processing ...") + log.Warningf("Received shutdown request - waiting (max %d) to finish processing ...", WAIT_TO_KILL_TIME_IN_SECONDS) go func() { start := time.Now() @@ -37,11 +38,9 @@ var PLUGIN = node.NewPlugin("Graceful Shutdown", node.Enabled, func(plugin *node if len(runningBackgroundWorkers) >= 1 { processList = "(" + strings.Join(runningBackgroundWorkers, ", ") + ") " } - - plugin.LogWarning("Received shutdown request - waiting (max " + strconv.Itoa(WAIT_TO_KILL_TIME_IN_SECONDS-int(secondsSinceStart)) + " seconds) to finish processing " + processList + "...") + log.Warningf("Received shutdown request - waiting (max %d seconds) to finish processing ...", WAIT_TO_KILL_TIME_IN_SECONDS-int(secondsSinceStart), processList) } else { - plugin.LogFailure("Background processes did not terminate in time! Forcing shutdown ...") - + log.Error("Background processes did not terminate in time! Forcing shutdown ...") os.Exit(1) } } diff --git a/plugins/metrics/plugin.go b/plugins/metrics/plugin.go index 6d8aa2fdf4..c483a42a9a 100644 --- a/plugins/metrics/plugin.go +++ b/plugins/metrics/plugin.go @@ -1,14 +1,14 @@ package metrics -import( +import ( "time" - "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/timeutil" "github.com/iotaledger/goshimmer/plugins/gossip" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) var PLUGIN = node.NewPlugin("Metrics", node.Enabled, configure, run) diff --git a/plugins/statusscreen-tps/plugin.go b/plugins/statusscreen-tps/plugin.go index 1b81a29ec4..15f4d1babc 100644 --- a/plugins/statusscreen-tps/plugin.go +++ b/plugins/statusscreen-tps/plugin.go @@ -5,14 +5,14 @@ import ( "sync/atomic" "time" - "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/goshimmer/plugins/statusscreen" "github.com/iotaledger/goshimmer/plugins/tangle" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) var receivedTpsCounter uint64 diff --git a/plugins/statusscreen/logger.go b/plugins/statusscreen/logger.go index f4734e3f87..a32db7fdc7 100644 --- a/plugins/statusscreen/logger.go +++ b/plugins/statusscreen/logger.go @@ -1,24 +1,23 @@ package statusscreen import ( + "github.com/iotaledger/hive.go/logger" "time" - - "github.com/iotaledger/goshimmer/packages/node" ) -func storeStatusMessage(pluginName string, message string, logLevel int) { +func storeStatusMessage(logLevel logger.LogLevel, prefix string, message string, ) { mutex.Lock() defer mutex.Unlock() messageLog = append(messageLog, &StatusMessage{ - Source: pluginName, + Source: prefix, LogLevel: logLevel, Message: message, Time: time.Now(), }) - if statusMessage, exists := statusMessages[pluginName]; !exists { - statusMessages[pluginName] = &StatusMessage{ - Source: pluginName, + if statusMessage, exists := statusMessages[prefix]; !exists { + statusMessages[prefix] = &StatusMessage{ + Source: prefix, LogLevel: logLevel, Message: message, Time: time.Now(), @@ -29,21 +28,3 @@ func storeStatusMessage(pluginName string, message string, logLevel int) { statusMessage.Time = time.Now() } } - -var DEFAULT_LOGGER = &node.Logger{ - LogInfo: func(pluginName string, message string) { - storeStatusMessage(pluginName, message, node.LOG_LEVEL_INFO) - }, - LogSuccess: func(pluginName string, message string) { - storeStatusMessage(pluginName, message, node.LOG_LEVEL_SUCCESS) - }, - LogWarning: func(pluginName string, message string) { - storeStatusMessage(pluginName, message, node.LOG_LEVEL_WARNING) - }, - LogFailure: func(pluginName string, message string) { - storeStatusMessage(pluginName, message, node.LOG_LEVEL_FAILURE) - }, - LogDebug: func(pluginName string, message string) { - storeStatusMessage(pluginName, message, node.LOG_LEVEL_DEBUG) - }, -} diff --git a/plugins/statusscreen/status_message.go b/plugins/statusscreen/status_message.go index a3b55becd2..6ac60673c2 100644 --- a/plugins/statusscreen/status_message.go +++ b/plugins/statusscreen/status_message.go @@ -1,12 +1,13 @@ package statusscreen import ( + "github.com/iotaledger/hive.go/logger" "time" ) type StatusMessage struct { Source string - LogLevel int + LogLevel logger.LogLevel Message string Time time.Time } diff --git a/plugins/statusscreen/statusscreen.go b/plugins/statusscreen/statusscreen.go index f76e097e13..93db9a1909 100644 --- a/plugins/statusscreen/statusscreen.go +++ b/plugins/statusscreen/statusscreen.go @@ -1,14 +1,16 @@ package statusscreen import ( + "github.com/iotaledger/hive.go/logger" + "io/ioutil" "os" "sync" "time" "github.com/gdamore/tcell" - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" "github.com/rivo/tview" "golang.org/x/crypto/ssh/terminal" ) @@ -24,13 +26,19 @@ func configure(plugin *node.Plugin) { return } - node.DEFAULT_LOGGER.SetEnabled(false) + // don't write anything to stdout anymore + // as log messages are now stored and displayed via this plugin + logger.InjectWriters(ioutil.Discard) - DEFAULT_LOGGER.SetEnabled(true) - plugin.Node.AddLogger(DEFAULT_LOGGER) + // store any log message for display + anyLogMsgClosure := events.NewClosure(func(logLevel logger.LogLevel, prefix string, msg string) { + storeStatusMessage(logLevel, prefix, msg) + }) + logger.Events.AnyMsg.Attach(anyLogMsgClosure) daemon.Events.Shutdown.Attach(events.NewClosure(func() { - node.DEFAULT_LOGGER.SetEnabled(true) + logger.InjectWriters(os.Stdout) + logger.Events.AnyMsg.Detach(anyLogMsgClosure) if app != nil { app.Stop() diff --git a/plugins/statusscreen/ui_log_entry.go b/plugins/statusscreen/ui_log_entry.go index df9a608d2e..168d6d1f21 100644 --- a/plugins/statusscreen/ui_log_entry.go +++ b/plugins/statusscreen/ui_log_entry.go @@ -2,9 +2,9 @@ package statusscreen import ( "fmt" + "github.com/iotaledger/hive.go/logger" "github.com/gdamore/tcell" - "github.com/iotaledger/goshimmer/packages/node" "github.com/rivo/tview" ) @@ -37,19 +37,25 @@ func NewUILogEntry(message StatusMessage) *UILogEntry { textColor := "black::d" switch message.LogLevel { - case node.LOG_LEVEL_INFO: + case logger.LevelInfo: fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [blue::d]INFO [black::d]]") - case node.LOG_LEVEL_SUCCESS: - fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [green::d]OK [black::d]]") - case node.LOG_LEVEL_WARNING: + case logger.LevelNotice: + fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [blue::d]NOTICE [black::d]]") + case logger.LevelWarning: fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [yellow::d]WARN [black::d]]") textColor = "yellow::d" - case node.LOG_LEVEL_FAILURE: + case logger.LevelError: + fallthrough + case logger.LevelCritical: + fallthrough + case logger.LevelPanic: + fallthrough + case logger.LevelFatal: fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [red::d]FAIL [black::d]]") textColor = "red::d" - case node.LOG_LEVEL_DEBUG: + case logger.LevelDebug: fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [black::b]NOTE [black::d]]") textColor = "black::b" diff --git a/plugins/tangle/approvers.go b/plugins/tangle/approvers.go index f0fbd88308..e150339650 100644 --- a/plugins/tangle/approvers.go +++ b/plugins/tangle/approvers.go @@ -5,8 +5,8 @@ import ( "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/approvers" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/typeutils" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/trinary" ) diff --git a/plugins/tangle/bundle.go b/plugins/tangle/bundle.go index c0d9ecb83f..ac5b1cd3eb 100644 --- a/plugins/tangle/bundle.go +++ b/plugins/tangle/bundle.go @@ -5,8 +5,8 @@ import ( "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/bundle" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/typeutils" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/trinary" ) diff --git a/plugins/tangle/plugin.go b/plugins/tangle/plugin.go index f1efc83ac5..62006c6be9 100644 --- a/plugins/tangle/plugin.go +++ b/plugins/tangle/plugin.go @@ -1,12 +1,14 @@ package tangle import ( - "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" ) // region plugin module setup ////////////////////////////////////////////////////////////////////////////////////////// var PLUGIN = node.NewPlugin("Tangle", node.Enabled, configure, run) +var log = logger.NewLogger("Tangle") func configure(plugin *node.Plugin) { configureTransactionDatabase(plugin) diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index 2a0dca5839..53a0fe61a4 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -3,16 +3,16 @@ package tangle import ( "runtime" - "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/approvers" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/workerpool" "github.com/iotaledger/goshimmer/plugins/gossip" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/trinary" ) @@ -32,21 +32,18 @@ func configureSolidifier(plugin *node.Plugin) { })) daemon.Events.Shutdown.Attach(events.NewClosure(func() { - plugin.LogInfo("Stopping Solidifier ...") - + log.Info("Stopping Solidifier ...") workerPool.Stop() })) } func runSolidifier(plugin *node.Plugin) { - plugin.LogInfo("Starting Solidifier ...") + log.Info("Starting Solidifier ...") daemon.BackgroundWorker("Tangle Solidifier", func() { - plugin.LogSuccess("Starting Solidifier ... done") - + log.Info("Starting Solidifier ... done") workerPool.Run() - - plugin.LogSuccess("Stopping Solidifier ... done") + log.Info("Stopping Solidifier ... done") }) } @@ -153,7 +150,7 @@ func processMetaTransaction(plugin *node.Plugin, metaTransaction *meta_transacti return value_transaction.FromMetaTransaction(metaTransaction) }); err != nil { - plugin.LogFailure(err.Error()) + log.Errorf("Unable to load transaction %s: %s", metaTransaction.GetHash(), err.Error()) } else if newTransaction { processTransaction(plugin, tx) } @@ -166,8 +163,7 @@ func processTransaction(plugin *node.Plugin, transaction *value_transaction.Valu // register tx as approver for trunk if trunkApprovers, err := GetApprovers(transaction.GetTrunkTransactionHash(), approvers.New); err != nil { - plugin.LogFailure(err.Error()) - + log.Errorf("Unable to get approvers of transaction %s: %s", transaction.GetTrunkTransactionHash(), err.Error()) return } else { trunkApprovers.Add(transactionHash) @@ -175,8 +171,7 @@ func processTransaction(plugin *node.Plugin, transaction *value_transaction.Valu // register tx as approver for branch if branchApprovers, err := GetApprovers(transaction.GetBranchTransactionHash(), approvers.New); err != nil { - plugin.LogFailure(err.Error()) - + log.Errorf("Unable to get approvers of transaction %s: %s", transaction.GetBranchTransactionHash(), err.Error()) return } else { branchApprovers.Add(transactionHash) @@ -184,8 +179,7 @@ func processTransaction(plugin *node.Plugin, transaction *value_transaction.Valu // update the solidity flags of this transaction and its approvers if _, err := IsSolid(transaction); err != nil { - plugin.LogFailure(err.Error()) - + log.Errorf("Unable to check solidity: %s", err.Error()) return } } diff --git a/plugins/tangle/solidifier_test.go b/plugins/tangle/solidifier_test.go index b6a1b8bf03..f13daf1bf4 100644 --- a/plugins/tangle/solidifier_test.go +++ b/plugins/tangle/solidifier_test.go @@ -7,9 +7,9 @@ import ( "testing" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/trinary" ) diff --git a/plugins/tangle/transaction.go b/plugins/tangle/transaction.go index 187e5df6d5..611a73dfa0 100644 --- a/plugins/tangle/transaction.go +++ b/plugins/tangle/transaction.go @@ -5,8 +5,8 @@ import ( "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/typeutils" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/trinary" ) diff --git a/plugins/tangle/transaction_metadata.go b/plugins/tangle/transaction_metadata.go index 16674b2167..75c1086fc0 100644 --- a/plugins/tangle/transaction_metadata.go +++ b/plugins/tangle/transaction_metadata.go @@ -5,8 +5,8 @@ import ( "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/typeutils" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/trinary" ) diff --git a/plugins/tipselection/plugin.go b/plugins/tipselection/plugin.go index a2c7ba175a..2f919f5857 100644 --- a/plugins/tipselection/plugin.go +++ b/plugins/tipselection/plugin.go @@ -2,9 +2,9 @@ package tipselection import ( "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) var PLUGIN = node.NewPlugin("Tipselection", node.Enabled, configure, run) diff --git a/plugins/ui/logger.go b/plugins/ui/logger.go index 9b159c6a89..b34519cef7 100644 --- a/plugins/ui/logger.go +++ b/plugins/ui/logger.go @@ -1,50 +1,33 @@ package ui import ( + "github.com/iotaledger/hive.go/logger" + "sync" "time" - - "github.com/iotaledger/goshimmer/packages/node" ) +var logMutex = sync.Mutex{} var logHistory = make([]*statusMessage, 0) type statusMessage struct { - Source string `json:"source"` - Level int `json:"level"` - Message string `json:"message"` - Time time.Time `json:"time"` + Source string `json:"source"` + Level logger.LogLevel `json:"level"` + Message string `json:"message"` + Time time.Time `json:"time"` } type resp map[string]interface{} -func storeAndSendStatusMessage(pluginName string, message string, level int) { +func storeAndSendStatusMessage(logLevel logger.LogLevel, pluginName string, message string) { msg := &statusMessage{ Source: pluginName, - Level: level, + Level: logLevel, Message: message, Time: time.Now(), } + logMutex.Lock() logHistory = append(logHistory, msg) - ws.send(resp{ - "logs": []*statusMessage{msg}, - }) -} - -var uiLogger = &node.Logger{ - LogInfo: func(pluginName string, message string) { - storeAndSendStatusMessage(pluginName, message, node.LOG_LEVEL_INFO) - }, - LogSuccess: func(pluginName string, message string) { - storeAndSendStatusMessage(pluginName, message, node.LOG_LEVEL_SUCCESS) - }, - LogWarning: func(pluginName string, message string) { - storeAndSendStatusMessage(pluginName, message, node.LOG_LEVEL_WARNING) - }, - LogFailure: func(pluginName string, message string) { - storeAndSendStatusMessage(pluginName, message, node.LOG_LEVEL_FAILURE) - }, - LogDebug: func(pluginName string, message string) { - storeAndSendStatusMessage(pluginName, message, node.LOG_LEVEL_DEBUG) - }, + logMutex.Unlock() + ws.send(resp{"logs": []*statusMessage{msg}}) } diff --git a/plugins/ui/ui.go b/plugins/ui/ui.go index 6ca34f3d3c..f4e5afad68 100644 --- a/plugins/ui/ui.go +++ b/plugins/ui/ui.go @@ -1,19 +1,20 @@ package ui import ( + "github.com/iotaledger/hive.go/logger" "net/http" "strings" "sync/atomic" "time" - "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/goshimmer/plugins/webapi" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" "github.com/labstack/echo" ) @@ -46,8 +47,11 @@ func configure(plugin *node.Plugin) { }() })) - uiLogger.SetEnabled(true) - plugin.Node.AddLogger(uiLogger) + // store log messages to send them down via the websocket + anyMsgClosure := events.NewClosure(func(logLvl logger.LogLevel, prefix string, msg string) { + storeAndSendStatusMessage(logLvl, prefix, msg) + }) + logger.Events.AnyMsg.Attach(anyMsgClosure) } func staticFileServer(c echo.Context) error { diff --git a/plugins/validator/plugin.go b/plugins/validator/plugin.go index 70f5241bf4..11217efc46 100644 --- a/plugins/validator/plugin.go +++ b/plugins/validator/plugin.go @@ -3,15 +3,17 @@ package validator import ( "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/bundleprocessor" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/kerl" "github.com/iotaledger/iota.go/signing" . "github.com/iotaledger/iota.go/trinary" ) var PLUGIN = node.NewPlugin("Validator", node.Enabled, configure, run) +var log = logger.NewLogger("Validator") func validateSignatures(bundleHash Hash, txs []*value_transaction.ValueTransaction) (bool, error) { for i, tx := range txs { @@ -52,9 +54,13 @@ func configure(plugin *node.Plugin) { bundleprocessor.Events.BundleSolid.Attach(events.NewClosure(func(b *bundle.Bundle, txs []*value_transaction.ValueTransaction) { // signature are verified against the bundle hash - valid, _ := validateSignatures(b.GetBundleEssenceHash(), txs) + valid, err := validateSignatures(b.GetBundleEssenceHash(), txs) if !valid { - plugin.LogFailure("Invalid signature") + if err != nil { + log.Errorf("Invalid signature: %s", err.Error()) + } else { + log.Error("Invalid signature") + } } })) } diff --git a/plugins/webapi-gtta/plugin.go b/plugins/webapi-gtta/plugin.go index 73ee6f22f2..c873f7a402 100644 --- a/plugins/webapi-gtta/plugin.go +++ b/plugins/webapi-gtta/plugin.go @@ -4,9 +4,9 @@ import ( "net/http" "time" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/tipselection" "github.com/iotaledger/goshimmer/plugins/webapi" + "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/trinary" "github.com/labstack/echo" ) diff --git a/plugins/webapi-spammer/plugin.go b/plugins/webapi-spammer/plugin.go index e40b962d6b..fb169eb86b 100644 --- a/plugins/webapi-spammer/plugin.go +++ b/plugins/webapi-spammer/plugin.go @@ -4,9 +4,9 @@ import ( "net/http" "time" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/packages/transactionspammer" "github.com/iotaledger/goshimmer/plugins/webapi" + "github.com/iotaledger/hive.go/node" "github.com/labstack/echo" ) diff --git a/plugins/webapi/plugin.go b/plugins/webapi/plugin.go index 9bce5f6eef..e73d1a09e2 100644 --- a/plugins/webapi/plugin.go +++ b/plugins/webapi/plugin.go @@ -2,15 +2,17 @@ package webapi import ( "context" + "github.com/iotaledger/hive.go/logger" "time" - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" "github.com/labstack/echo" ) var PLUGIN = node.NewPlugin("WebAPI", node.Enabled, configure, run) +var log = logger.NewLogger("WebAPI") var Server = echo.New() @@ -20,25 +22,25 @@ func configure(plugin *node.Plugin) { Server.GET("/", IndexRequest) daemon.Events.Shutdown.Attach(events.NewClosure(func() { - plugin.LogInfo("Stopping Web Server ...") + log.Info("Stopping Web Server ...") ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) defer cancel() if err := Server.Shutdown(ctx); err != nil { - plugin.LogFailure(err.Error()) + log.Errorf("Couldn't stop server cleanly: %s", err.Error()) } })) } func run(plugin *node.Plugin) { - plugin.LogInfo("Starting Web Server ...") + log.Info("Starting Web Server ...") daemon.BackgroundWorker("WebAPI Server", func() { - plugin.LogSuccess("Starting Web Server ... done") + log.Info("Starting Web Server ... done") if err := Server.Start(":8080"); err != nil { - plugin.LogSuccess("Stopping Web Server ... done") + log.Info("Stopping Web Server ... done") } }) } diff --git a/plugins/webauth/webauth.go b/plugins/webauth/webauth.go index 805590dcf2..b8e118147f 100644 --- a/plugins/webauth/webauth.go +++ b/plugins/webauth/webauth.go @@ -6,9 +6,9 @@ import ( "strings" "time" - "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/webapi" + "github.com/iotaledger/hive.go/daemon" + "github.com/iotaledger/hive.go/node" "github.com/labstack/echo" "github.com/labstack/echo/middleware" diff --git a/plugins/zeromq/plugin.go b/plugins/zeromq/plugin.go index ce8ad4c0b8..b3355ea079 100644 --- a/plugins/zeromq/plugin.go +++ b/plugins/zeromq/plugin.go @@ -1,21 +1,22 @@ package zeromq import ( + "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/parameter" "strconv" "strings" "time" - "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/tangle" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/node" ) // zeromq logging is disabled by default var PLUGIN = node.NewPlugin("ZeroMQ", node.Disabled, configure, run) - +var log = logger.NewLogger("ZeroMQ") var publisher *Publisher var emptyTag = strings.Repeat("9", 27) @@ -23,12 +24,12 @@ var emptyTag = strings.Repeat("9", 27) func configure(plugin *node.Plugin) { daemon.Events.Shutdown.Attach(events.NewClosure(func() { - plugin.LogInfo("Stopping ZeroMQ Publisher ...") + log.Info("Stopping ZeroMQ Publisher ...") if err := publisher.Shutdown(); err != nil { - plugin.LogFailure("Stopping ZeroMQ Publisher: " + err.Error()) + log.Errorf("Stopping ZeroMQ Publisher: %s", err.Error()) } else { - plugin.LogSuccess("Stopping ZeroMQ Publisher ... done") + log.Info("Stopping ZeroMQ Publisher ... done") } })) @@ -36,7 +37,7 @@ func configure(plugin *node.Plugin) { // create goroutine for every event go func() { if err := publishTx(tx); err != nil { - plugin.LogFailure(err.Error()) + log.Errorf("error publishing tx: %s", err.Error()) } }() })) @@ -44,14 +45,14 @@ func configure(plugin *node.Plugin) { // Start the zeromq plugin func run(plugin *node.Plugin) { - zeromqPort := parameter.NodeConfig.GetString(ZEROMQ_PORT) - plugin.LogInfo("Starting ZeroMQ Publisher (port " + zeromqPort + ") ...") + zeromqPort := parameter.NodeConfig.GetInt(ZEROMQ_PORT) + log.Infof("Starting ZeroMQ Publisher (port %d) ...", zeromqPort) daemon.BackgroundWorker("ZeroMQ Publisher", func() { if err := startPublisher(plugin); err != nil { - plugin.LogFailure("Stopping ZeroMQ Publisher: " + err.Error()) + log.Errorf("Stopping ZeroMQ Publisher: %s", err.Error()) } else { - plugin.LogSuccess("Starting ZeroMQ Publisher (port " + zeromqPort + ") ... done") + log.Infof("Starting ZeroMQ Publisher (port %d) ... done", zeromqPort) } }) } From 495fae2ced2f1d2a66d86c85a039f524b8bf338b Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Sat, 16 Nov 2019 20:24:22 +0100 Subject: [PATCH 005/184] fixes args in formatted prints --- plugins/analysis/server/plugin.go | 2 +- plugins/gracefulshutdown/plugin.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index 517a3df193..7c5863d656 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -27,7 +27,7 @@ func Configure(plugin *node.Plugin) { server.Events.Connect.Attach(events.NewClosure(HandleConnection)) server.Events.Error.Attach(events.NewClosure(func(err error) { - log.Error("error in server: %s", err.Error()) + log.Errorf("error in server: %s", err.Error()) })) server.Events.Start.Attach(events.NewClosure(func() { log.Infof("Starting Server (port %d) ... done", parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) diff --git a/plugins/gracefulshutdown/plugin.go b/plugins/gracefulshutdown/plugin.go index d24c61b26b..15d5cbe646 100644 --- a/plugins/gracefulshutdown/plugin.go +++ b/plugins/gracefulshutdown/plugin.go @@ -1,7 +1,6 @@ package gracefulshutdown import ( - "github.com/iotaledger/hive.go/logger" "os" "os/signal" "strings" @@ -9,6 +8,7 @@ import ( "time" "github.com/iotaledger/hive.go/daemon" + "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" ) @@ -38,7 +38,7 @@ var PLUGIN = node.NewPlugin("Graceful Shutdown", node.Enabled, func(plugin *node if len(runningBackgroundWorkers) >= 1 { processList = "(" + strings.Join(runningBackgroundWorkers, ", ") + ") " } - log.Warningf("Received shutdown request - waiting (max %d seconds) to finish processing ...", WAIT_TO_KILL_TIME_IN_SECONDS-int(secondsSinceStart), processList) + log.Warningf("Received shutdown request - waiting (max %d seconds) to finish processing %s...", WAIT_TO_KILL_TIME_IN_SECONDS-int(secondsSinceStart), processList) } else { log.Error("Background processes did not terminate in time! Forcing shutdown ...") os.Exit(1) From 1ddd1aaf39e3b583ac663404e3cc70d5549c386e Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Mon, 25 Nov 2019 11:50:25 +0100 Subject: [PATCH 006/184] fixes typos in CLI cfg options --- plugins/cli/cli.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/cli/cli.go b/plugins/cli/cli.go index 9275838b1e..104d1d44b9 100644 --- a/plugins/cli/cli.go +++ b/plugins/cli/cli.go @@ -43,6 +43,6 @@ func printUsage() { flag.PrintDefaults() fmt.Fprintf(os.Stderr, "\nThe following plugins are enabled by default and can be disabled with -%s:\n %s\n", node.CFG_DISABLE_PLUGINS, getList(enabledPlugins)) - fmt.Fprintf(os.Stderr, "The following plugins are disabled by default and can be enabled with -%s:\n %s\n", node.CFG_ENABLE_PLGUINS, getList(disabledPlugins)) - fmt.Fprintf(os.Stderr, "The enabled/disabled plugins can be overriden by altering %s/%s inside config.json\n\n", node.CFG_ENABLE_PLGUINS, node.CFG_DISABLE_PLUGINS) + fmt.Fprintf(os.Stderr, "The following plugins are disabled by default and can be enabled with -%s:\n %s\n", node.CFG_ENABLE_PLUGINS, getList(disabledPlugins)) + fmt.Fprintf(os.Stderr, "The enabled/disabled plugins can be overriden by altering %s/%s inside config.json\n\n", node.CFG_ENABLE_PLUGINS, node.CFG_DISABLE_PLUGINS) } From c7080aca3ce0eb2c69294a50cd4d230d836b849e Mon Sep 17 00:00:00 2001 From: capossele Date: Mon, 25 Nov 2019 11:30:57 +0000 Subject: [PATCH 007/184] :construction: WIP --- .gitignore | 1 + go.mod | 8 ++- go.sum | 24 +++++++ packages/accountability/accountability.go | 59 ---------------- plugins/analysis/client/plugin.go | 68 ++++++++++++++----- plugins/analysis/client/types.go | 1 + plugins/analysis/server/plugin.go | 36 +++++++++- plugins/analysis/types/addnode/constants.go | 4 +- .../analysis/types/connectnodes/constants.go | 6 +- .../types/disconnectnodes/constants.go | 6 +- .../analysis/types/removenode/constants.go | 4 +- .../webinterface/httpserver/data_stream.go | 2 +- .../analysis/webinterface/httpserver/index.go | 24 ++++++- .../webinterface/httpserver/plugin.go | 2 +- .../recordedevents/recorded_events.go | 9 ++- plugins/autopeering/autopeering.go | 57 +++++++++------- plugins/autopeering/local/local.go | 5 ++ plugins/dashboard/tps.go | 4 +- plugins/gossip/neighbors.go | 5 +- plugins/gossip/protocol.go | 2 +- plugins/gossip/protocol_v1.go | 6 +- plugins/gossip/send_queue.go | 2 +- plugins/gossip/server.go | 6 +- plugins/statusscreen/ui_header_bar.go | 8 ++- plugins/ui/files.go | 17 +++-- plugins/ui/nodeInfo.go | 4 +- runNetwork.sh | 32 +++++++++ 27 files changed, 257 insertions(+), 145 deletions(-) delete mode 100644 packages/accountability/accountability.go create mode 100644 plugins/autopeering/local/local.go create mode 100755 runNetwork.sh diff --git a/.gitignore b/.gitignore index a18828787a..217c41d974 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ # Logs logs/* +testNodes/* # Project files .idea diff --git a/go.mod b/go.mod index d7079bdf9d..e73cf08c67 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/go-zeromq/zmq4 v0.6.2 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/autopeering-sim v0.0.0-20191121125328-c607091f6bc8 + github.com/iotaledger/autopeering-sim v0.0.0-20191125082010-418faee91e5a github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible @@ -19,10 +19,12 @@ require ( github.com/mattn/go-isatty v0.0.10 // indirect github.com/mattn/go-runewidth v0.0.6 // indirect github.com/pkg/errors v0.8.1 - github.com/rivo/tview v0.0.0-20191018125527-685bf6da76c2 + github.com/rivo/tview v0.0.0-20191121195645-2d957c4be01d github.com/valyala/fasttemplate v1.1.0 // indirect + go.uber.org/zap v1.13.0 golang.org/x/crypto v0.0.0-20191119213627-4f8c1d86b1ba - golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 + golang.org/x/net v0.0.0-20191124235446-72fef5d5e266 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect + golang.org/x/tools v0.0.0-20191125011157-cc15fab314e3 // indirect golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect ) diff --git a/go.sum b/go.sum index bbfbf8db73..be5fc55b1d 100644 --- a/go.sum +++ b/go.sum @@ -94,6 +94,18 @@ github.com/iotaledger/autopeering-sim v0.0.0-20191121112351-05d62de2edf2 h1:CGGJ github.com/iotaledger/autopeering-sim v0.0.0-20191121112351-05d62de2edf2/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/autopeering-sim v0.0.0-20191121125328-c607091f6bc8 h1:4G8MSFJhykckV4n5nQ48lx/qg3sf4MqHP6X4yoii2sc= github.com/iotaledger/autopeering-sim v0.0.0-20191121125328-c607091f6bc8/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191121203423-98315403e684 h1:+zVGrC8o9/UrCZvmwgi5sUIgN7UeBWufowRX/ATGS3Q= +github.com/iotaledger/autopeering-sim v0.0.0-20191121203423-98315403e684/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191122094050-3251b06f764a h1:GayngK7kqD+Xw1+jVTVn0MCkwsdeURcNvXTqPfA07Cg= +github.com/iotaledger/autopeering-sim v0.0.0-20191122094050-3251b06f764a/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191122165813-905dac7a7390 h1:mBRYX/C8/BR9dTw4Jkgw7HyvYUB50jLYW1LaAG7kXg0= +github.com/iotaledger/autopeering-sim v0.0.0-20191122165813-905dac7a7390/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191122182429-a6129bebaa09 h1:97V2yiOqnz5u8+8g2yPuoet5BFt1gOXnXWTRPb7I2Cg= +github.com/iotaledger/autopeering-sim v0.0.0-20191122182429-a6129bebaa09/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191122190327-b1fcfa1bf02b h1:ri8xe7feJk9GzT4c4HCy2SqBTb6fWoGzZ2aRMU3LjSk= +github.com/iotaledger/autopeering-sim v0.0.0-20191122190327-b1fcfa1bf02b/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191125082010-418faee91e5a h1:4/GYRv+ClV261Dq53B4toHbWq/mdzLEAPaZ9g9Ytio8= +github.com/iotaledger/autopeering-sim v0.0.0-20191125082010-418faee91e5a/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= @@ -159,6 +171,8 @@ github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40T github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341/go.mod h1:+rKjP5+h9HMwWRpAfhIkkQ9KE3m3Nz5rwn7YtUpwgqk= github.com/rivo/tview v0.0.0-20191018125527-685bf6da76c2 h1:GVXSfgXOMAeLvFH7IrpY3yYM8H3YekZEFcZ14q9gQXM= github.com/rivo/tview v0.0.0-20191018125527-685bf6da76c2/go.mod h1:/rBeY22VG2QprWnEqG57IBC8biVu3i0DOIjRLc9I8H0= +github.com/rivo/tview v0.0.0-20191121195645-2d957c4be01d h1:dPWYyMzc2VB5XX7eA/Pe5TXBGzhlVZZr54GhRJLTbts= +github.com/rivo/tview v0.0.0-20191121195645-2d957c4be01d/go.mod h1:/rBeY22VG2QprWnEqG57IBC8biVu3i0DOIjRLc9I8H0= github.com/rivo/uniseg v0.0.0-20190513083848-b9f5b9457d44/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -237,6 +251,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191124235446-72fef5d5e266 h1:QuOiA7GCO0OSDzlNlFyOWOywDsjuzW8M2yvBfCqw+cY= +golang.org/x/net v0.0.0-20191124235446-72fef5d5e266/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -277,6 +293,14 @@ golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191121040551-947d4aa89328 h1:t3X42h9e6xdbrCD/gPyWqAXr2BEpdJqRd1brThaaxII= golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191122080028-f774e2e2e5be h1:6d2MOtryvuMarrCTOqjhCZCVONST5uq4zNzBWKxzOls= +golang.org/x/tools v0.0.0-20191122080028-f774e2e2e5be/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191122161556-0ae87fff1b85 h1:T0S3IX2zGoozKqzqe8CQZRrJooHPr2aV/HmirRBwnRM= +golang.org/x/tools v0.0.0-20191122161556-0ae87fff1b85/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191122182703-035a8167be0b h1:CeeSPSpqT/6nJ9vHD7VQV5SkrnGMNnpYtwYajVX+29I= +golang.org/x/tools v0.0.0-20191122182703-035a8167be0b/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125011157-cc15fab314e3 h1:aHkNOJLg6a84bdLJN1yjqMSTadeAuaudhEPNSkLAWoA= +golang.org/x/tools v0.0.0-20191125011157-cc15fab314e3/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/packages/accountability/accountability.go b/packages/accountability/accountability.go deleted file mode 100644 index 6eff4ddd1e..0000000000 --- a/packages/accountability/accountability.go +++ /dev/null @@ -1,59 +0,0 @@ -package accountability - -import ( - "sync" - - "github.com/dgraph-io/badger" - "github.com/iotaledger/goshimmer/packages/identity" - "github.com/iotaledger/goshimmer/packages/settings" -) - -// Name of the key under which the node identity is stored. -const identityKey = "IDENTITY" - -var ownId *identity.Identity -var lazyInit sync.Once - -func OwnId() *identity.Identity { - lazyInit.Do(initOwnId) - - return ownId -} - -func initOwnId() { - ownId = getIdentity() -} - -func generateNewIdentity() *identity.Identity { - - newIdentity := identity.GeneratePrivateIdentity() - - key := []byte(identityKey) - value := newIdentity.Marshal() - - if err := settings.Set(key, value); err != nil { - panic(err) - } - - return newIdentity -} - -func getIdentity() *identity.Identity { - key := []byte(identityKey) - - value, err := settings.Get(key) - if err != nil { - if err == badger.ErrKeyNotFound { - return generateNewIdentity() - } else { - panic(err) - } - } - - result, err := identity.Unmarshal(value) - if err != nil { - panic(err) - } - - return result -} diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index fa7099e652..43e277e01a 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -1,12 +1,12 @@ package client import ( + "encoding/hex" "net" "time" "github.com/iotaledger/autopeering-sim/discover" "github.com/iotaledger/autopeering-sim/selection" - "github.com/iotaledger/goshimmer/packages/accountability" "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/node" @@ -15,10 +15,16 @@ import ( "github.com/iotaledger/goshimmer/plugins/analysis/types/connectnodes" "github.com/iotaledger/goshimmer/plugins/analysis/types/disconnectnodes" "github.com/iotaledger/goshimmer/plugins/analysis/types/ping" + "github.com/iotaledger/goshimmer/plugins/analysis/types/removenode" + "github.com/iotaledger/goshimmer/plugins/autopeering" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/hive.go/events" ) +var debug *node.Plugin + func Run(plugin *node.Plugin) { + debug = plugin daemon.BackgroundWorker("Analysis Client", func() { shuttingDown := false @@ -37,7 +43,7 @@ func Run(plugin *node.Plugin) { eventDispatchers := getEventDispatchers(managedConn) reportCurrentStatus(eventDispatchers) - setupHooks(managedConn, eventDispatchers) + setupHooks(plugin, managedConn, eventDispatchers) shuttingDown = keepConnectionAlive(managedConn) } @@ -49,46 +55,72 @@ func Run(plugin *node.Plugin) { func getEventDispatchers(conn *network.ManagedConnection) *EventDispatchers { return &EventDispatchers{ AddNode: func(nodeId []byte) { - conn.Write((&addnode.Packet{NodeId: nodeId}).Marshal()) + _, err := conn.Write((&addnode.Packet{NodeId: nodeId}).Marshal()) + if err != nil { + debug.LogFailure(err.Error()) + } + }, + RemoveNode: func(nodeId []byte) { + _, err := conn.Write((&removenode.Packet{NodeId: nodeId}).Marshal()) + if err != nil { + debug.LogFailure(err.Error()) + } }, ConnectNodes: func(sourceId []byte, targetId []byte) { - conn.Write((&connectnodes.Packet{SourceId: sourceId, TargetId: targetId}).Marshal()) + _, err := conn.Write((&connectnodes.Packet{SourceId: sourceId, TargetId: targetId}).Marshal()) + if err != nil { + debug.LogFailure(err.Error()) + } }, DisconnectNodes: func(sourceId []byte, targetId []byte) { - conn.Write((&disconnectnodes.Packet{SourceId: sourceId, TargetId: targetId}).Marshal()) + _, err := conn.Write((&disconnectnodes.Packet{SourceId: sourceId, TargetId: targetId}).Marshal()) + if err != nil { + debug.LogFailure(err.Error()) + } }, } } func reportCurrentStatus(eventDispatchers *EventDispatchers) { - eventDispatchers.AddNode(accountability.OwnId().Identifier.Bytes()) + if local.INSTANCE != nil { + eventDispatchers.AddNode(local.INSTANCE.ID().Bytes()) + } reportChosenNeighbors(eventDispatchers) } -func setupHooks(conn *network.ManagedConnection, eventDispatchers *EventDispatchers) { +func setupHooks(plugin *node.Plugin, conn *network.ManagedConnection, eventDispatchers *EventDispatchers) { // define hooks //////////////////////////////////////////////////////////////////////////////////////////////////// onDiscoverPeer := events.NewClosure(func(ev *discover.DiscoveredEvent) { - go eventDispatchers.AddNode(ev.Peer.ID().Bytes()) + plugin.LogInfo("onDiscoverPeer: " + hex.EncodeToString(ev.Peer.ID().Bytes())) + eventDispatchers.AddNode(ev.Peer.ID().Bytes()) + }) + + onDeletePeer := events.NewClosure(func(ev *discover.DeletedEvent) { + plugin.LogInfo("onDeletePeer: " + hex.EncodeToString(ev.Peer.ID().Bytes())) + eventDispatchers.RemoveNode(ev.Peer.ID().Bytes()) }) onAddAcceptedNeighbor := events.NewClosure(func(ev *selection.PeeringEvent) { - eventDispatchers.ConnectNodes(ev.Peer.ID().Bytes(), accountability.OwnId().Identifier.Bytes()) + plugin.LogInfo("onAddAcceptedNeighbor: " + hex.EncodeToString(ev.Peer.ID().Bytes()) + " - " + hex.EncodeToString(local.INSTANCE.ID().Bytes())) + eventDispatchers.ConnectNodes(ev.Peer.ID().Bytes(), local.INSTANCE.ID().Bytes()) }) onRemoveNeighbor := events.NewClosure(func(ev *selection.DroppedEvent) { - eventDispatchers.DisconnectNodes(ev.DroppedID.Bytes(), accountability.OwnId().Identifier.Bytes()) - eventDispatchers.DisconnectNodes(accountability.OwnId().Identifier.Bytes(), ev.DroppedID.Bytes()) + plugin.LogInfo("onRemoveNeighbor: " + hex.EncodeToString(ev.DroppedID.Bytes()) + " - " + hex.EncodeToString(local.INSTANCE.ID().Bytes())) + eventDispatchers.DisconnectNodes(ev.DroppedID.Bytes(), local.INSTANCE.ID().Bytes()) }) onAddChosenNeighbor := events.NewClosure(func(ev *selection.PeeringEvent) { - eventDispatchers.ConnectNodes(accountability.OwnId().Identifier.Bytes(), ev.Peer.ID().Bytes()) + plugin.LogInfo("onAddChosenNeighbor: " + hex.EncodeToString(local.INSTANCE.ID().Bytes()) + " - " + hex.EncodeToString(ev.Peer.ID().Bytes())) + eventDispatchers.ConnectNodes(local.INSTANCE.ID().Bytes(), ev.Peer.ID().Bytes()) }) // setup hooks ///////////////////////////////////////////////////////////////////////////////////////////////////// discover.Events.PeerDiscovered.Attach(onDiscoverPeer) + discover.Events.PeerDeleted.Attach(onDeletePeer) selection.Events.IncomingPeering.Attach(onAddAcceptedNeighbor) selection.Events.OutgoingPeering.Attach(onAddChosenNeighbor) selection.Events.Dropped.Attach(onRemoveNeighbor) @@ -108,12 +140,12 @@ func setupHooks(conn *network.ManagedConnection, eventDispatchers *EventDispatch } func reportChosenNeighbors(dispatchers *EventDispatchers) { - // for _, chosenNeighbor := range chosenneighbors.INSTANCE.Peers.GetMap() { - // dispatchers.AddNode(chosenNeighbor.GetIdentity().Identifier) - // } - // for _, chosenNeighbor := range chosenneighbors.INSTANCE.Peers.GetMap() { - // dispatchers.ConnectNodes(accountability.OwnId().Identifier, chosenNeighbor.GetIdentity().Identifier) - // } + if autopeering.Selection != nil { + for _, chosenNeighbor := range autopeering.Selection.GetOutgoingNeighbors() { + dispatchers.AddNode(chosenNeighbor.ID().Bytes()) + dispatchers.ConnectNodes(local.INSTANCE.ID().Bytes(), chosenNeighbor.ID().Bytes()) + } + } } func keepConnectionAlive(conn *network.ManagedConnection) bool { diff --git a/plugins/analysis/client/types.go b/plugins/analysis/client/types.go index 1af7c8f102..dabbb16001 100644 --- a/plugins/analysis/client/types.go +++ b/plugins/analysis/client/types.go @@ -2,6 +2,7 @@ package client type EventDispatchers struct { AddNode func(nodeId []byte) + RemoveNode func(nodeId []byte) ConnectNodes func(sourceId []byte, targetId []byte) DisconnectNodes func(sourceId []byte, targetId []byte) } diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index 36b8670843..b34f5a29bc 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -6,7 +6,6 @@ import ( "strconv" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/network/tcp" "github.com/iotaledger/goshimmer/packages/node" @@ -15,12 +14,16 @@ import ( "github.com/iotaledger/goshimmer/plugins/analysis/types/disconnectnodes" "github.com/iotaledger/goshimmer/plugins/analysis/types/ping" "github.com/iotaledger/goshimmer/plugins/analysis/types/removenode" + "github.com/iotaledger/hive.go/events" "github.com/pkg/errors" ) var server *tcp.Server +var debug *node.Plugin + func Configure(plugin *node.Plugin) { + debug = plugin server = tcp.NewServer() server.Events.Connect.Attach(events.NewClosure(HandleConnection)) @@ -153,7 +156,7 @@ func processIncomingPacket(connectionState *byte, receiveBuffer *[]byte, conn *n processIncomingDisconnectNodesPacket(connectionState, receiveBuffer, conn, data, offset, connectedNodeId) case STATE_REMOVE_NODE: - processIncomingAddNodePacket(connectionState, receiveBuffer, conn, data, offset, connectedNodeId) + processIncomingRemoveNodePacket(connectionState, receiveBuffer, conn, data, offset, connectedNodeId) } } @@ -309,3 +312,32 @@ func processIncomingDisconnectNodesPacket(connectionState *byte, receiveBuffer * } } } + +func processIncomingRemoveNodePacket(connectionState *byte, receiveBuffer *[]byte, conn *network.ManagedConnection, data []byte, offset *int, connectedNodeId *string) { + remainingCapacity := int(math.Min(float64(removenode.MARSHALED_TOTAL_SIZE-*offset), float64(len(data)))) + + copy((*receiveBuffer)[*offset:], data[:remainingCapacity]) + + if *offset+len(data) < removenode.MARSHALED_TOTAL_SIZE { + *offset += len(data) + } else { + if removeNodePacket, err := removenode.Unmarshal(*receiveBuffer); err != nil { + Events.Error.Trigger(err) + + conn.Close() + + return + } else { + nodeId := hex.EncodeToString(removeNodePacket.NodeId) + + Events.RemoveNode.Trigger(nodeId) + + } + + *connectionState = STATE_CONSECUTIVE + + if *offset+len(data) > addnode.MARSHALED_TOTAL_SIZE { + processIncomingPacket(connectionState, receiveBuffer, conn, data[remainingCapacity:], offset, connectedNodeId) + } + } +} diff --git a/plugins/analysis/types/addnode/constants.go b/plugins/analysis/types/addnode/constants.go index 6534ce8da6..a112e89aa7 100644 --- a/plugins/analysis/types/addnode/constants.go +++ b/plugins/analysis/types/addnode/constants.go @@ -1,5 +1,7 @@ package addnode +import "crypto/sha256" + const ( MARSHALED_PACKET_HEADER = 0x01 @@ -8,7 +10,7 @@ const ( MARSHALED_PACKET_HEADER_END = MARSHALED_PACKET_HEADER_START + MARSHALED_PACKET_HEADER_SIZE MARSHALED_ID_START = MARSHALED_PACKET_HEADER_END - MARSHALED_ID_SIZE = 20 + MARSHALED_ID_SIZE = sha256.Size MARSHALED_ID_END = MARSHALED_ID_START + MARSHALED_ID_SIZE MARSHALED_TOTAL_SIZE = MARSHALED_ID_END diff --git a/plugins/analysis/types/connectnodes/constants.go b/plugins/analysis/types/connectnodes/constants.go index d40065208b..09889329a4 100644 --- a/plugins/analysis/types/connectnodes/constants.go +++ b/plugins/analysis/types/connectnodes/constants.go @@ -1,5 +1,7 @@ package connectnodes +import "crypto/sha256" + const ( MARSHALED_PACKET_HEADER = 0x03 @@ -8,11 +10,11 @@ const ( MARSHALED_PACKET_HEADER_END = MARSHALED_PACKET_HEADER_START + MARSHALED_PACKET_HEADER_SIZE MARSHALED_SOURCE_ID_START = MARSHALED_PACKET_HEADER_END - MARSHALED_SOURCE_ID_SIZE = 20 + MARSHALED_SOURCE_ID_SIZE = sha256.Size MARSHALED_SOURCE_ID_END = MARSHALED_SOURCE_ID_START + MARSHALED_SOURCE_ID_SIZE MARSHALED_TARGET_ID_START = MARSHALED_SOURCE_ID_END - MARSHALED_TARGET_ID_SIZE = 20 + MARSHALED_TARGET_ID_SIZE = sha256.Size MARSHALED_TARGET_ID_END = MARSHALED_TARGET_ID_START + MARSHALED_TARGET_ID_SIZE MARSHALED_TOTAL_SIZE = MARSHALED_TARGET_ID_END diff --git a/plugins/analysis/types/disconnectnodes/constants.go b/plugins/analysis/types/disconnectnodes/constants.go index 928a723f9e..adf347455b 100644 --- a/plugins/analysis/types/disconnectnodes/constants.go +++ b/plugins/analysis/types/disconnectnodes/constants.go @@ -1,5 +1,7 @@ package disconnectnodes +import "crypto/sha256" + const ( MARSHALED_PACKET_HEADER = 0x04 @@ -8,11 +10,11 @@ const ( MARSHALED_PACKET_HEADER_END = MARSHALED_PACKET_HEADER_START + MARSHALED_PACKET_HEADER_SIZE MARSHALED_SOURCE_ID_START = MARSHALED_PACKET_HEADER_END - MARSHALED_SOURCE_ID_SIZE = 20 + MARSHALED_SOURCE_ID_SIZE = sha256.Size MARSHALED_SOURCE_ID_END = MARSHALED_SOURCE_ID_START + MARSHALED_SOURCE_ID_SIZE MARSHALED_TARGET_ID_START = MARSHALED_SOURCE_ID_END - MARSHALED_TARGET_ID_SIZE = 20 + MARSHALED_TARGET_ID_SIZE = sha256.Size MARSHALED_TARGET_ID_END = MARSHALED_TARGET_ID_START + MARSHALED_TARGET_ID_SIZE MARSHALED_TOTAL_SIZE = MARSHALED_TARGET_ID_END diff --git a/plugins/analysis/types/removenode/constants.go b/plugins/analysis/types/removenode/constants.go index 52d9bcc5c0..b8edb5d179 100644 --- a/plugins/analysis/types/removenode/constants.go +++ b/plugins/analysis/types/removenode/constants.go @@ -1,5 +1,7 @@ package removenode +import "crypto/sha256" + const ( MARSHALED_PACKET_HEADER = 0x02 @@ -8,7 +10,7 @@ const ( MARSHALED_PACKET_HEADER_END = MARSHALED_PACKET_HEADER_START + MARSHALED_PACKET_HEADER_SIZE MARSHALED_ID_START = MARSHALED_PACKET_HEADER_END - MARSHALED_ID_SIZE = 20 + MARSHALED_ID_SIZE = sha256.Size MARSHALED_ID_END = MARSHALED_ID_START + MARSHALED_ID_SIZE MARSHALED_TOTAL_SIZE = MARSHALED_ID_END diff --git a/plugins/analysis/webinterface/httpserver/data_stream.go b/plugins/analysis/webinterface/httpserver/data_stream.go index 2548064908..a2d54db771 100644 --- a/plugins/analysis/webinterface/httpserver/data_stream.go +++ b/plugins/analysis/webinterface/httpserver/data_stream.go @@ -3,10 +3,10 @@ package httpserver import ( "fmt" - "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/plugins/analysis/server" "github.com/iotaledger/goshimmer/plugins/analysis/webinterface/recordedevents" "github.com/iotaledger/goshimmer/plugins/analysis/webinterface/types" + "github.com/iotaledger/hive.go/events" "golang.org/x/net/websocket" ) diff --git a/plugins/analysis/webinterface/httpserver/index.go b/plugins/analysis/webinterface/httpserver/index.go index b0d791ebd5..9fce6f7698 100644 --- a/plugins/analysis/webinterface/httpserver/index.go +++ b/plugins/analysis/webinterface/httpserver/index.go @@ -26,6 +26,7 @@ func index(w http.ResponseWriter, r *http.Request) { }; socket.onmessage = function (e) { + console.log("Len: ", data.nodes.length); switch (e.data[0]) { case "_": // do nothing - its just a ping @@ -33,26 +34,32 @@ func index(w http.ResponseWriter, r *http.Request) { case "A": addNode(e.data.substr(1)); + console.log("Add node:",e.data.substr(1)); break; case "a": removeNode(e.data.substr(1)); + console.log("Remove node:", e.data.substr(1)); break; case "C": - connectNodes(e.data.substr(1, 40), e.data.substr(41, 40)); + connectNodes(e.data.substr(1, 64), e.data.substr(65, 128)); + console.log("Connect nodes:",e.data.substr(1, 64), " - ", e.data.substr(65, 128)); break; case "c": - disconnectNodes(e.data.substr(1, 40), e.data.substr(41, 40)); + disconnectNodes(e.data.substr(1, 64), e.data.substr(65, 128)); + console.log("Disconnect nodes:",e.data.substr(1, 64), " - ", e.data.substr(65, 128)); break; case "O": setNodeOnline(e.data.substr(1)); + console.log("setNodeOnline:",e.data.substr(1)); break; case "o": setNodeOffline(e.data.substr(1)); + console.log("setNodeOffline:",e.data.substr(1)); break; } }; @@ -96,6 +103,7 @@ func index(w http.ResponseWriter, r *http.Request) { data.nodes = [...data.nodes, node]; nodesById[node.id] = node; + nodesById[nodeId].online = true; updateGraph(); } @@ -128,6 +136,14 @@ func index(w http.ResponseWriter, r *http.Request) { function connectNodes(sourceNodeId, targetNodeId) { if(existingLinks[sourceNodeId + targetNodeId] == undefined && existingLinks[targetNodeId + sourceNodeId] == undefined) { + if (!(sourceNodeId in nodesById)) { + addNode(sourceNodeId); + } + if (!(targetNodeId in nodesById)) { + addNode(targetNodeId); + } + nodesById[sourceNodeId].online = true; + nodesById[targetNodeId].online = true; data.links = [...data.links, { source: sourceNodeId, target: targetNodeId }]; updateGraph(); @@ -136,7 +152,6 @@ func index(w http.ResponseWriter, r *http.Request) { function disconnectNodes(sourceNodeId, targetNodeId) { data.links = data.links.filter(l => !(l.source.id == sourceNodeId && l.target.id == targetNodeId) && !(l.source.id == targetNodeId && l.target.id == sourceNodeId)); - delete existingLinks[sourceNodeId + targetNodeId]; delete existingLinks[targetNodeId + sourceNodeId]; @@ -144,6 +159,9 @@ func index(w http.ResponseWriter, r *http.Request) { } function removeNodeX(node) { + if (!(node.id in nodesById)) { + addNode(sourceNodeId); + } removeNode(node.id) } diff --git a/plugins/analysis/webinterface/httpserver/plugin.go b/plugins/analysis/webinterface/httpserver/plugin.go index a7c8daf9ff..a86fb7dffe 100644 --- a/plugins/analysis/webinterface/httpserver/plugin.go +++ b/plugins/analysis/webinterface/httpserver/plugin.go @@ -5,8 +5,8 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/events" "golang.org/x/net/context" "golang.org/x/net/websocket" ) diff --git a/plugins/analysis/webinterface/recordedevents/recorded_events.go b/plugins/analysis/webinterface/recordedevents/recorded_events.go index 882696997b..95934ad11f 100644 --- a/plugins/analysis/webinterface/recordedevents/recorded_events.go +++ b/plugins/analysis/webinterface/recordedevents/recorded_events.go @@ -1,12 +1,13 @@ package recordedevents import ( + "strconv" "sync" - "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/analysis/server" "github.com/iotaledger/goshimmer/plugins/analysis/webinterface/types" + "github.com/iotaledger/hive.go/events" ) var nodes = make(map[string]bool) @@ -16,6 +17,7 @@ var lock sync.Mutex func Configure(plugin *node.Plugin) { server.Events.AddNode.Attach(events.NewClosure(func(nodeId string) { + plugin.LogInfo("AddNode: " + nodeId + " sizeof " + strconv.Itoa(len(nodeId))) if _, exists := nodes[nodeId]; !exists { lock.Lock() defer lock.Unlock() @@ -27,6 +29,7 @@ func Configure(plugin *node.Plugin) { })) server.Events.RemoveNode.Attach(events.NewClosure(func(nodeId string) { + plugin.LogInfo("RemoveNode: " + nodeId) lock.Lock() defer lock.Unlock() @@ -34,6 +37,7 @@ func Configure(plugin *node.Plugin) { })) server.Events.NodeOnline.Attach(events.NewClosure(func(nodeId string) { + plugin.LogInfo("NodeOnline: " + nodeId) lock.Lock() defer lock.Unlock() @@ -41,6 +45,7 @@ func Configure(plugin *node.Plugin) { })) server.Events.NodeOffline.Attach(events.NewClosure(func(nodeId string) { + plugin.LogInfo("NodeOffline: " + nodeId) lock.Lock() defer lock.Unlock() @@ -48,6 +53,7 @@ func Configure(plugin *node.Plugin) { })) server.Events.ConnectNodes.Attach(events.NewClosure(func(sourceId string, targetId string) { + plugin.LogInfo("ConnectNodes: " + sourceId + " - " + targetId) lock.Lock() defer lock.Unlock() @@ -61,6 +67,7 @@ func Configure(plugin *node.Plugin) { })) server.Events.DisconnectNodes.Attach(events.NewClosure(func(sourceId string, targetId string) { + plugin.LogInfo("DisconnectNodes: " + sourceId + " - " + targetId) lock.Lock() defer lock.Unlock() diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 2c98a22c93..8f1e599c21 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -8,6 +8,7 @@ import ( "net" "net/http" "strconv" + "time" "github.com/iotaledger/autopeering-sim/discover" "github.com/iotaledger/autopeering-sim/logger" @@ -16,13 +17,15 @@ import ( "github.com/iotaledger/autopeering-sim/server" "github.com/iotaledger/autopeering-sim/transport" "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" "github.com/iotaledger/goshimmer/plugins/gossip" + "go.uber.org/zap" ) var ( PLUGIN = node.NewPlugin("Auto Peering", node.Enabled, configure, run) - debugLevel = "debug" + debugLevel = "info" close = make(chan struct{}, 1) srv *server.Server Discovery *discover.Protocol @@ -32,7 +35,7 @@ var ( const defaultZLC = `{ "level": "info", "development": false, - "outputPaths": ["./logs/autopeering.log"], + "outputPaths": ["stdout"], "errorOutputPaths": ["stderr"], "encoding": "console", "encoderConfig": { @@ -94,26 +97,26 @@ func start() { // create a new local node db := peer.NewPersistentDB(logger.Named("db")) defer db.Close() - local, err := peer.NewLocal(db) + local.INSTANCE, err = peer.NewLocal(db) if err != nil { log.Fatalf("ListenUDP: %v", err) } // add a service for the peering - local.Services()["peering"] = peer.NetworkAddress{Network: "udp", Address: listenAddr} + local.INSTANCE.Services()["peering"] = peer.NetworkAddress{Network: "udp", Address: listenAddr} // add a service for the gossip - local.Services()["gossip"] = peer.NetworkAddress{Network: "tcp", Address: gossipAddr} + local.INSTANCE.Services()["gossip"] = peer.NetworkAddress{Network: "tcp", Address: gossipAddr} - Discovery = discover.New(local, discover.Config{ + Discovery = discover.New(local.INSTANCE, discover.Config{ Log: logger.Named("disc"), MasterPeers: masterPeers, }) - Selection = selection.New(local, Discovery, selection.Config{ + Selection = selection.New(local.INSTANCE, Discovery, selection.Config{ Log: logger.Named("sel"), SaltLifetime: selection.DefaultSaltLifetime, }) // start a server doing discovery and peering - srv = server.Listen(local, trans, logger.Named("srv"), Discovery, Selection) + srv = server.Listen(local.INSTANCE, trans, logger.Named("srv"), Discovery, Selection) defer srv.Close() // start the discovery on that connection @@ -124,30 +127,20 @@ func start() { Selection.Start(srv) defer Selection.Close() - id := base64.StdEncoding.EncodeToString(local.PublicKey()) + id := base64.StdEncoding.EncodeToString(local.INSTANCE.PublicKey()) a, b, _ := net.SplitHostPort(srv.LocalAddr()) logger.Info("Discovery protocol started: ID="+id+", address="+srv.LocalAddr(), a, b) + go func() { + for t := range time.NewTicker(2 * time.Second).C { + _ = t + printReport(logger) + } + }() + <-close } -// func parseMaster(s string) (*peer.Peer, error) { -// if len(s) == 0 { -// return nil, nil -// } - -// parts := strings.Split(s, "@") -// if len(parts) != 2 { -// return nil, errors.New("parseMaster") -// } -// pubKey, err := base64.StdEncoding.DecodeString(parts[0]) -// if err != nil { -// return nil, errors.Wrap(err, "parseMaster") -// } - -// return peer.NewPeer(pubKey, parts[1]), nil -// } - func getMyIP() string { url := "https://api.ipify.org?format=text" resp, err := http.Get(url) @@ -161,3 +154,15 @@ func getMyIP() string { } return fmt.Sprintf("%s", ip) } + +func printReport(log *zap.SugaredLogger) { + if Discovery == nil || Selection == nil { + return + } + knownPeers := Discovery.GetVerifiedPeers() + incoming := Selection.GetIncomingNeighbors() + outgoing := Selection.GetOutgoingNeighbors() + log.Info("Known peers:", len(knownPeers)) + log.Info("Chosen:", len(outgoing), outgoing) + log.Info("Accepted:", len(incoming), incoming) +} diff --git a/plugins/autopeering/local/local.go b/plugins/autopeering/local/local.go new file mode 100644 index 0000000000..d384c80735 --- /dev/null +++ b/plugins/autopeering/local/local.go @@ -0,0 +1,5 @@ +package local + +import "github.com/iotaledger/autopeering-sim/peer" + +var INSTANCE *peer.Local diff --git a/plugins/dashboard/tps.go b/plugins/dashboard/tps.go index ac1f5ceb24..3a20bbb388 100644 --- a/plugins/dashboard/tps.go +++ b/plugins/dashboard/tps.go @@ -11,8 +11,8 @@ import ( "time" "github.com/gorilla/websocket" - "github.com/iotaledger/goshimmer/packages/accountability" "github.com/iotaledger/goshimmer/plugins/autopeering" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/metrics" "github.com/iotaledger/hive.go/events" ) @@ -70,7 +70,7 @@ func GetStatus() *Status { uptime += fmt.Sprintf("%02ds ", int(duration.Seconds())%60) return &Status{ - Id: accountability.OwnId().StringIdentifier, + Id: local.INSTANCE.ID().String(), Neighbor: "Neighbors: " + strconv.Itoa(len(autopeering.Selection.GetOutgoingNeighbors())) + " chosen / " + strconv.Itoa(len(autopeering.Selection.GetIncomingNeighbors())) + " accepted / " + strconv.Itoa(len(autopeering.Selection.GetNeighbors())) + " total", KnownPeer: "Known Peers: " + strconv.Itoa(len(autopeering.Discovery.GetVerifiedPeers())) + " total", Uptime: uptime, diff --git a/plugins/gossip/neighbors.go b/plugins/gossip/neighbors.go index f4374c517b..6d1671dddc 100644 --- a/plugins/gossip/neighbors.go +++ b/plugins/gossip/neighbors.go @@ -8,18 +8,19 @@ import ( "time" "github.com/iotaledger/autopeering-sim/peer" - "github.com/iotaledger/goshimmer/packages/accountability" "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/identity" "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/hive.go/events" ) func configureNeighbors(plugin *node.Plugin) { Events.AddNeighbor.Attach(events.NewClosure(func(neighbor *Neighbor) { plugin.LogSuccess("new neighbor added " + neighbor.GetIdentity().StringIdentifier + "@" + neighbor.GetAddress().String() + ":" + neighbor.GetPort()) + //plugin.LogSuccess("new neighbor added " + hex.EncodeToString(neighbor.Peer.ID().Bytes()) + "@" + neighbor.GetAddress().String() + ":" + neighbor.GetPort()) })) Events.UpdateNeighbor.Attach(events.NewClosure(func(neighbor *Neighbor) { @@ -221,7 +222,7 @@ func (neighbor *Neighbor) Connect() (*protocol, bool, errors.IdentifiableError) // drop the "secondary" connection upon successful handshake neighbor.GetInitiatedProtocol().Events.HandshakeCompleted.Attach(events.NewClosure(func() { - if accountability.OwnId().StringIdentifier <= neighbor.GetIdentity().StringIdentifier { + if local.INSTANCE.ID().String() <= neighbor.Peer.ID().String() { var acceptedProtocolConn *network.ManagedConnection if neighbor.GetAcceptedProtocol() != nil { acceptedProtocolConn = neighbor.GetAcceptedProtocol().Conn diff --git a/plugins/gossip/protocol.go b/plugins/gossip/protocol.go index 5cda6f9988..54c891714b 100644 --- a/plugins/gossip/protocol.go +++ b/plugins/gossip/protocol.go @@ -5,8 +5,8 @@ import ( "sync" "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/network" + "github.com/iotaledger/hive.go/events" ) // region constants and variables ////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/gossip/protocol_v1.go b/plugins/gossip/protocol_v1.go index ee6681dc86..268ec8dc24 100644 --- a/plugins/gossip/protocol_v1.go +++ b/plugins/gossip/protocol_v1.go @@ -3,19 +3,19 @@ package gossip import ( "strconv" - "github.com/iotaledger/goshimmer/packages/accountability" "github.com/iotaledger/goshimmer/packages/byteutils" "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/identity" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/iota.go/consts" ) // region protocolV1 /////////////////////////////////////////////////////////////////////////////////////////////////// func protocolV1(protocol *protocol) errors.IdentifiableError { - if err := protocol.Send(accountability.OwnId()); err != nil { + if err := protocol.Send(local.INSTANCE.ID().Bytes()); err != nil { return err } diff --git a/plugins/gossip/send_queue.go b/plugins/gossip/send_queue.go index 02ba941564..7b92be4ab0 100644 --- a/plugins/gossip/send_queue.go +++ b/plugins/gossip/send_queue.go @@ -4,9 +4,9 @@ import ( "sync" "github.com/iotaledger/goshimmer/packages/daemon" - "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/events" ) // region plugin module setup ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/gossip/server.go b/plugins/gossip/server.go index cee62e7d5e..32c80b7569 100644 --- a/plugins/gossip/server.go +++ b/plugins/gossip/server.go @@ -3,14 +3,14 @@ package gossip import ( "strconv" - "github.com/iotaledger/goshimmer/packages/accountability" "github.com/iotaledger/goshimmer/packages/daemon" "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/hive.go/events" "github.com/iotaledger/goshimmer/packages/identity" "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/network/tcp" "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/hive.go/events" ) var TCPServer = tcp.NewServer() @@ -40,7 +40,7 @@ func configureServer(plugin *node.Plugin) { // drop the "secondary" connection upon successful handshake protocol.Events.HandshakeCompleted.Attach(events.NewClosure(func() { - if protocol.Neighbor.GetIdentity().StringIdentifier <= accountability.OwnId().StringIdentifier { + if protocol.Neighbor.Peer.ID().String() <= local.INSTANCE.ID().String() { var initiatedProtocolConn *network.ManagedConnection if protocol.Neighbor.GetInitiatedProtocol() != nil { initiatedProtocolConn = protocol.Neighbor.GetInitiatedProtocol().Conn diff --git a/plugins/statusscreen/ui_header_bar.go b/plugins/statusscreen/ui_header_bar.go index e1a1d17b88..4cff25dd17 100644 --- a/plugins/statusscreen/ui_header_bar.go +++ b/plugins/statusscreen/ui_header_bar.go @@ -9,8 +9,8 @@ import ( "time" "github.com/gdamore/tcell" - "github.com/iotaledger/goshimmer/packages/accountability" "github.com/iotaledger/goshimmer/plugins/autopeering" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/rivo/tview" ) @@ -81,6 +81,7 @@ func (headerBar *UIHeaderBar) Update() { incoming := "0" neighbors := "0" total := "0" + myID := "-" if autopeering.Selection != nil { outgoing = strconv.Itoa(len(autopeering.Selection.GetOutgoingNeighbors())) incoming = strconv.Itoa(len(autopeering.Selection.GetIncomingNeighbors())) @@ -89,8 +90,11 @@ func (headerBar *UIHeaderBar) Update() { if autopeering.Discovery != nil { total = strconv.Itoa(len(autopeering.Discovery.GetVerifiedPeers())) } + if local.INSTANCE != nil { + myID = local.INSTANCE.ID().String() + } - fmt.Fprintf(headerBar.InfoContainer, "[::b]Node ID: [::d]%40v ", accountability.OwnId().StringIdentifier) + fmt.Fprintf(headerBar.InfoContainer, "[::b]Node ID: [::d]%40v ", myID) fmt.Fprintln(headerBar.InfoContainer) fmt.Fprintf(headerBar.InfoContainer, "[::b]Neighbors: [::d]%40v ", outgoing+" chosen / "+incoming+" accepted / "+neighbors+" total") fmt.Fprintln(headerBar.InfoContainer) diff --git a/plugins/ui/files.go b/plugins/ui/files.go index 3d36119445..a336e08738 100644 --- a/plugins/ui/files.go +++ b/plugins/ui/files.go @@ -1,7 +1,7 @@ package ui var files = map[string]string{ - "css/styles.css":`/* mobile */ + "css/styles.css": `/* mobile */ html { font-size:12px; } @@ -206,7 +206,7 @@ body.fade { font-size: 0.8rem; } `, - "index.html":` + "index.html": ` @@ -365,7 +365,7 @@ body.fade { `, - "js/forcegraph.js":` + "js/forcegraph.js": ` Vue.component('force-graph', { props:['neighbors', 'me'], data: function() { @@ -423,7 +423,7 @@ Vue.component('force-graph', { ''+ '' })`, - "js/icons.js":` + "js/icons.js": ` Vue.component('iota-icon', { props:['size'], template: '' @@ -443,7 +443,7 @@ Vue.component('stop-icon', { Vue.component('empty-icon', { template: '' })`, - "js/initials.js":`var initialData = { + "js/initials.js": `var initialData = { loggedIn: false, connected: false, tabs: ['Logs', 'Spammer', 'Transactions', 'Neighbors'], @@ -458,7 +458,7 @@ Vue.component('empty-icon', { loginError:'', } `, - "js/main.js":`new Vue({ + "js/main.js": `new Vue({ el: '#app', created() { this.init() @@ -618,7 +618,7 @@ Vue.component('empty-icon', { } }, })`, - "js/tpschart.js":`Vue.component('tps-chart', { + "js/tpschart.js": `Vue.component('tps-chart', { props: ['tps'], watch:{ tps: function (val, oldVal) { @@ -900,7 +900,7 @@ var highchartsTheme = { contrastTextColor: '#F0F0F3', maskColor: 'rgba(255,255,255,0.3)' }`, - "js/utils.js":`function uptimeConverter(seconds) { + "js/utils.js": `function uptimeConverter(seconds) { var s = '' var hrs = Math.floor(seconds / 3600); if (hrs) s += hrs+'h ' @@ -992,5 +992,4 @@ function debounce(func, delay) { function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); }`, - } diff --git a/plugins/ui/nodeInfo.go b/plugins/ui/nodeInfo.go index a97ab5a19b..70f2531791 100644 --- a/plugins/ui/nodeInfo.go +++ b/plugins/ui/nodeInfo.go @@ -4,8 +4,8 @@ import ( "sync/atomic" "time" - "github.com/iotaledger/goshimmer/packages/accountability" "github.com/iotaledger/goshimmer/plugins/autopeering" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" ) var start = time.Now() @@ -49,7 +49,7 @@ func gatherInfo() nodeInfo { receivedTps, solidTps := updateTpsCounters() duration := time.Since(start) / time.Second info := nodeInfo{ - ID: accountability.OwnId().StringIdentifier, + ID: local.INSTANCE.ID().String(), ChosenNeighbors: chosenNeighbors, AcceptedNeighbors: acceptedNeighbors, KnownPeersSize: len(autopeering.Discovery.GetVerifiedPeers()), //knownpeers.INSTANCE.Peers.Len(), diff --git a/runNetwork.sh b/runNetwork.sh new file mode 100755 index 0000000000..30dd6a3399 --- /dev/null +++ b/runNetwork.sh @@ -0,0 +1,32 @@ + +#!/bin/bash + +if [ -z "$1" ]; then + echo "Usage: `basename $0` number_of_nodes" + exit 0 +fi + +re='^[0-9]+$' +if ! [[ $1 =~ $re ]] ; then + echo "Error: Number of nodes given is not a number" >&2; exit 1 +fi + +PEERING_PORT=14630 +GOSSIP_PORT=15670 + +if [ -d testNodes ]; then + rm -r testNodes +fi +mkdir testNodes +cd testNodes + +for i in `seq 1 $1`; do + PEERING_PORT=$((PEERING_PORT+1)) + GOSSIP_PORT=$((GOSSIP_PORT+1)) + mkdir node_$i + mkdir node_$i/logs + cp ../shimmer node_$i/ + cd node_$i + ./shimmer -autopeering-port $PEERING_PORT -gossip-port $GOSSIP_PORT -autopeering-address 127.0.0.1 -autopeering-entry-nodes 6rtO4nW2nzbSqZ8nrf0VFOn+fuyluf6ltJTkKpUc3LM=@127.0.0.1:14626 -node-log-level 4 -node-disable-plugins statusscreen -analysis-server-address 127.0.0.1:188 & + cd .. +done \ No newline at end of file From 08b64a265b5ee6e7535308f596290cc766bad1e0 Mon Sep 17 00:00:00 2001 From: capossele Date: Mon, 25 Nov 2019 12:28:46 +0000 Subject: [PATCH 008/184] :arrow_up: integrates new paramters --- go.mod | 19 +++++++++--- go.sum | 31 +++++++++++++++++++ plugins/autopeering/autopeering.go | 8 ++--- plugins/autopeering/entrynodes.go | 4 +-- .../{parameters => }/parameters.go | 2 +- plugins/cli/plugin.go | 7 ++--- runNetwork.sh | 2 +- 7 files changed, 57 insertions(+), 16 deletions(-) rename plugins/autopeering/{parameters => }/parameters.go (97%) diff --git a/go.mod b/go.mod index c18235bba7..85594ece84 100644 --- a/go.mod +++ b/go.mod @@ -10,15 +10,26 @@ require ( github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 github.com/iotaledger/autopeering-sim v0.0.0-20191125082010-418faee91e5a - github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb + github.com/iotaledger/hive.go v0.0.0-20191125115115-f88d4ecab6dd github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible github.com/lucasb-eyer/go-colorful v1.0.3 // indirect github.com/magiconair/properties v1.8.1 + github.com/mattn/go-colorable v0.1.4 // indirect + github.com/mattn/go-isatty v0.0.10 // indirect + github.com/mattn/go-runewidth v0.0.6 // indirect + github.com/pelletier/go-toml v1.6.0 // indirect github.com/pkg/errors v0.8.1 - github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341 + github.com/rivo/tview v0.0.0-20191121195645-2d957c4be01d + github.com/spf13/afero v1.2.2 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 + github.com/valyala/fasttemplate v1.1.0 // indirect go.uber.org/zap v1.13.0 - golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 - golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 + golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c + golang.org/x/net v0.0.0-20191125084936-ffdde1057850 + golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect + golang.org/x/tools v0.0.0-20191125011157-cc15fab314e3 // indirect + golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect + gopkg.in/yaml.v2 v2.2.7 // indirect ) diff --git a/go.sum b/go.sum index 420de47885..5e3a3eec6a 100644 --- a/go.sum +++ b/go.sum @@ -56,6 +56,7 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-zeromq/goczmq/v4 v4.2.2 h1:HAJN+i+3NW55ijMJJhk7oWxHKXgAuSBkoFfvr8bYj4U= github.com/go-zeromq/goczmq/v4 v4.2.2/go.mod h1:Sm/lxrfxP/Oxqs0tnHD6WAhwkWrx+S+1MRrKzcxoaYE= github.com/go-zeromq/zmq4 v0.5.0 h1:DijriKlrr2b48mymvAsZApiPzrbxQodYKG1aDH1rz8c= github.com/go-zeromq/zmq4 v0.5.0/go.mod h1:6p7pjNlkfrQQVipmEuZDk7fakLZCqPPVK+Iq3jfbDg8= @@ -97,6 +98,10 @@ github.com/iotaledger/hive.go v0.0.0-20191113184748-b545de9170d9 h1:zlolyGALm324 github.com/iotaledger/hive.go v0.0.0-20191113184748-b545de9170d9/go.mod h1:Ks2y/bEyfvb7nUA7l69a+8Epsv16UlGev0BvxggHius= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= +github.com/iotaledger/hive.go v0.0.0-20191125112048-8b1784dd1bce h1:QchbydsqgH7bXWXk8zLa1PvZ0fcWRddfIXCoXuWgzt4= +github.com/iotaledger/hive.go v0.0.0-20191125112048-8b1784dd1bce/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= +github.com/iotaledger/hive.go v0.0.0-20191125115115-f88d4ecab6dd h1:3tfMtDaByXXwx6jyPG1Qz8PtlN3YXc+3zLO2QRC7C9E= +github.com/iotaledger/hive.go v0.0.0-20191125115115-f88d4ecab6dd/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= github.com/iotaledger/iota.go v1.0.0-beta.7/go.mod h1:dMps6iMVU1pf5NDYNKIw4tRsPeC8W3ZWjOvYHOO1PMg= github.com/iotaledger/iota.go v1.0.0-beta.9 h1:c654s9pkdhMBkABUvWg+6k91MEBbdtmZXP1xDfQpajg= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= @@ -131,8 +136,12 @@ github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= +github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.6 h1:V2iyH+aX9C5fsYCpK60U8BYIvmhqxuOL3JZcqc1NB7k= +github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= @@ -146,6 +155,8 @@ github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.6.0 h1:aetoXYr0Tv7xRU/V4B4IZJ2QcbtMUFoNb3ORp7TzIK4= +github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -182,11 +193,15 @@ github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4k github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= +github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= @@ -225,6 +240,7 @@ go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/ go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.4.0 h1:f3WCSC2KzAcBXGATIxAB1E2XuCpNU255wNKZ505qi3E= go.uber.org/multierr v1.4.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0 h1:nR6NoDBgAf67s68NhaXbsojM+2gxp3S1hWkHDl27pVU= @@ -236,8 +252,11 @@ golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaE golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 h1:Gv7RPwsi3eZ2Fgewe3CBsuOebPwO27PoXzRpJPsvSSM= golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c h1:/nJuwDLoL/zrqY6gf57vxC+Pi+pZ8bfhpPkicO5H7W4= +golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -252,6 +271,8 @@ golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191125084936-ffdde1057850 h1:Vq85/r8R9IdcUHmZ0/nQlUg1v15rzvQ2sHdnZAj/x7s= +golang.org/x/net v0.0.0-20191125084936-ffdde1057850/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -259,6 +280,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -290,9 +313,14 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191121040551-947d4aa89328 h1:t3X42h9e6xdbrCD/gPyWqAXr2BEpdJqRd1brThaaxII= golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125011157-cc15fab314e3 h1:aHkNOJLg6a84bdLJN1yjqMSTadeAuaudhEPNSkLAWoA= +golang.org/x/tools v0.0.0-20191125011157-cc15fab314e3/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -311,7 +339,10 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= +gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/zeromq/goczmq.v4 v4.1.0 h1:CE+FE81mGVs2aSlnbfLuS1oAwdcVywyMM2AC1g33imI= gopkg.in/zeromq/goczmq.v4 v4.1.0/go.mod h1:h4IlfePEYMpFdywGr5gAwKhBBj+hiBl/nF4VoSE4k+0= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 8f1e599c21..aacc842efe 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -18,8 +18,8 @@ import ( "github.com/iotaledger/autopeering-sim/transport" "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/local" - "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" "github.com/iotaledger/goshimmer/plugins/gossip" + "github.com/iotaledger/hive.go/parameter" "go.uber.org/zap" ) @@ -58,10 +58,10 @@ func start() { err error ) - host := *parameters.ADDRESS.Value + host := parameter.NodeConfig.GetString(CFG_ADDRESS) localhost := host - apPort := strconv.Itoa(*parameters.PORT.Value) - gossipPort := strconv.Itoa(*gossip.PORT.Value) + apPort := strconv.Itoa(parameter.NodeConfig.GetInt(CFG_PORT)) + gossipPort := strconv.Itoa(parameter.NodeConfig.GetInt(gossip.GOSSIP_PORT)) if host == "0.0.0.0" { host = getMyIP() } diff --git a/plugins/autopeering/entrynodes.go b/plugins/autopeering/entrynodes.go index 6aa5eb2cd7..836903f282 100644 --- a/plugins/autopeering/entrynodes.go +++ b/plugins/autopeering/entrynodes.go @@ -6,11 +6,11 @@ import ( "github.com/iotaledger/autopeering-sim/peer" "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/plugins/autopeering/parameters" + "github.com/iotaledger/hive.go/parameter" ) func parseEntryNodes() (result []*peer.Peer, err error) { - for _, entryNodeDefinition := range strings.Fields(*parameters.ENTRY_NODES.Value) { + for _, entryNodeDefinition := range strings.Fields(parameter.NodeConfig.GetString(CFG_ENTRY_NODES)) { if entryNodeDefinition == "" { continue } diff --git a/plugins/autopeering/parameters/parameters.go b/plugins/autopeering/parameters.go similarity index 97% rename from plugins/autopeering/parameters/parameters.go rename to plugins/autopeering/parameters.go index 9903d1db5d..b7b02df1c7 100644 --- a/plugins/autopeering/parameters/parameters.go +++ b/plugins/autopeering/parameters.go @@ -1,4 +1,4 @@ -package parameters +package autopeering import ( flag "github.com/spf13/pflag" diff --git a/plugins/cli/plugin.go b/plugins/cli/plugin.go index c7ac5908de..566d021a7d 100644 --- a/plugins/cli/plugin.go +++ b/plugins/cli/plugin.go @@ -4,11 +4,10 @@ import ( "fmt" "strings" - "github.com/iotaledger/hive.go/events" - flag "github.com/spf13/pflag" - "github.com/iotaledger/goshimmer/packages/node" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/parameter" + flag "github.com/spf13/pflag" ) const ( @@ -54,7 +53,7 @@ func configure(ctx *node.Plugin) { fmt.Printf(" \\____/\\_| |_/\\___/\\_| |_/\\_| |_/\\____/\\_| \\_| fullnode %s", AppVersion) fmt.Println() - parameter.FetchConfig() + parameter.FetchConfig(false) parseParameters() ctx.Node.LogInfo("Node", "Loading plugins ...") diff --git a/runNetwork.sh b/runNetwork.sh index 30dd6a3399..0e2b315f6b 100755 --- a/runNetwork.sh +++ b/runNetwork.sh @@ -27,6 +27,6 @@ for i in `seq 1 $1`; do mkdir node_$i/logs cp ../shimmer node_$i/ cd node_$i - ./shimmer -autopeering-port $PEERING_PORT -gossip-port $GOSSIP_PORT -autopeering-address 127.0.0.1 -autopeering-entry-nodes 6rtO4nW2nzbSqZ8nrf0VFOn+fuyluf6ltJTkKpUc3LM=@127.0.0.1:14626 -node-log-level 4 -node-disable-plugins statusscreen -analysis-server-address 127.0.0.1:188 & + ./shimmer --autopeering.port $PEERING_PORT --gossip.port $GOSSIP_PORT --autopeering.address 127.0.0.1 --autopeering.entryNodes 6rtO4nW2nzbSqZ8nrf0VFOn+fuyluf6ltJTkKpUc3LM=@127.0.0.1:14626 --node.logLevel 4 --node.disablePlugins statusscreen --analysis.serverAddress 127.0.0.1:188 & cd .. done \ No newline at end of file From fa696c32200580e8e6bc647361f2c08c7da82950 Mon Sep 17 00:00:00 2001 From: capossele Date: Mon, 25 Nov 2019 12:36:43 +0000 Subject: [PATCH 009/184] :heavy_minus_sign: removes unnecessary dependencies --- go.sum | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/go.sum b/go.sum index 5e3a3eec6a..7e518b44a0 100644 --- a/go.sum +++ b/go.sum @@ -27,6 +27,7 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgraph-io/badger v1.5.4/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ= github.com/dgraph-io/badger v1.6.0 h1:DshxFxZWXUcO0xX476VJC07Xsr6ZCBVRHKZ93Oh7Evo= @@ -89,17 +90,14 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/iotaledger/autopeering-sim v0.0.0-20191125082010-418faee91e5a h1:4/GYRv+ClV261Dq53B4toHbWq/mdzLEAPaZ9g9Ytio8= github.com/iotaledger/autopeering-sim v0.0.0-20191125082010-418faee91e5a/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= -github.com/iotaledger/hive.go v0.0.0-20191113184748-b545de9170d9 h1:zlolyGALm324vLK6zJuw9cNp/XoNqsxqqx4jzHgoaFU= -github.com/iotaledger/hive.go v0.0.0-20191113184748-b545de9170d9/go.mod h1:Ks2y/bEyfvb7nUA7l69a+8Epsv16UlGev0BvxggHius= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= -github.com/iotaledger/hive.go v0.0.0-20191125112048-8b1784dd1bce h1:QchbydsqgH7bXWXk8zLa1PvZ0fcWRddfIXCoXuWgzt4= -github.com/iotaledger/hive.go v0.0.0-20191125112048-8b1784dd1bce/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= github.com/iotaledger/hive.go v0.0.0-20191125115115-f88d4ecab6dd h1:3tfMtDaByXXwx6jyPG1Qz8PtlN3YXc+3zLO2QRC7C9E= github.com/iotaledger/hive.go v0.0.0-20191125115115-f88d4ecab6dd/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= github.com/iotaledger/iota.go v1.0.0-beta.7/go.mod h1:dMps6iMVU1pf5NDYNKIw4tRsPeC8W3ZWjOvYHOO1PMg= @@ -117,6 +115,7 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= @@ -151,7 +150,9 @@ github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uY github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= @@ -175,8 +176,6 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341 h1:d2Z5U4d3fenPRFFweaMCogbXiRywM5kgYtu20/hol3M= github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341/go.mod h1:+rKjP5+h9HMwWRpAfhIkkQ9KE3m3Nz5rwn7YtUpwgqk= -github.com/rivo/tview v0.0.0-20191018125527-685bf6da76c2 h1:GVXSfgXOMAeLvFH7IrpY3yYM8H3YekZEFcZ14q9gQXM= -github.com/rivo/tview v0.0.0-20191018125527-685bf6da76c2/go.mod h1:/rBeY22VG2QprWnEqG57IBC8biVu3i0DOIjRLc9I8H0= github.com/rivo/tview v0.0.0-20191121195645-2d957c4be01d h1:dPWYyMzc2VB5XX7eA/Pe5TXBGzhlVZZr54GhRJLTbts= github.com/rivo/tview v0.0.0-20191121195645-2d957c4be01d/go.mod h1:/rBeY22VG2QprWnEqG57IBC8biVu3i0DOIjRLc9I8H0= github.com/rivo/uniseg v0.0.0-20190513083848-b9f5b9457d44/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -209,6 +208,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.5.0 h1:GpsTwfsQ27oS/Aha/6d1oD7tpKIqWnOA6tgOX9HHkt4= github.com/spf13/viper v1.5.0/go.mod h1:AkYRkVJF8TkSG/xet6PzXX+l39KhhXa2pdqVSxnTcn4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -327,8 +327,10 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/h2non/gock.v1 v1.0.14/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= From 6798c3be178850c2dcb68e811ded24af18b997cf Mon Sep 17 00:00:00 2001 From: capossele Date: Mon, 25 Nov 2019 15:20:05 +0000 Subject: [PATCH 010/184] :construction: WIP --- .../webinterface/recordedevents/recorded_events.go | 7 ------- plugins/autopeering/autopeering.go | 5 +---- runNetwork.sh | 2 +- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/plugins/analysis/webinterface/recordedevents/recorded_events.go b/plugins/analysis/webinterface/recordedevents/recorded_events.go index 4496ecac21..c31574b8cf 100644 --- a/plugins/analysis/webinterface/recordedevents/recorded_events.go +++ b/plugins/analysis/webinterface/recordedevents/recorded_events.go @@ -1,7 +1,6 @@ package recordedevents import ( - "strconv" "sync" "github.com/iotaledger/goshimmer/plugins/analysis/server" @@ -17,7 +16,6 @@ var lock sync.Mutex func Configure(plugin *node.Plugin) { server.Events.AddNode.Attach(events.NewClosure(func(nodeId string) { - plugin.LogInfo("AddNode: " + nodeId + " sizeof " + strconv.Itoa(len(nodeId))) if _, exists := nodes[nodeId]; !exists { lock.Lock() defer lock.Unlock() @@ -29,7 +27,6 @@ func Configure(plugin *node.Plugin) { })) server.Events.RemoveNode.Attach(events.NewClosure(func(nodeId string) { - plugin.LogInfo("RemoveNode: " + nodeId) lock.Lock() defer lock.Unlock() @@ -37,7 +34,6 @@ func Configure(plugin *node.Plugin) { })) server.Events.NodeOnline.Attach(events.NewClosure(func(nodeId string) { - plugin.LogInfo("NodeOnline: " + nodeId) lock.Lock() defer lock.Unlock() @@ -45,7 +41,6 @@ func Configure(plugin *node.Plugin) { })) server.Events.NodeOffline.Attach(events.NewClosure(func(nodeId string) { - plugin.LogInfo("NodeOffline: " + nodeId) lock.Lock() defer lock.Unlock() @@ -53,7 +48,6 @@ func Configure(plugin *node.Plugin) { })) server.Events.ConnectNodes.Attach(events.NewClosure(func(sourceId string, targetId string) { - plugin.LogInfo("ConnectNodes: " + sourceId + " - " + targetId) lock.Lock() defer lock.Unlock() @@ -67,7 +61,6 @@ func Configure(plugin *node.Plugin) { })) server.Events.DisconnectNodes.Attach(events.NewClosure(func(sourceId string, targetId string) { - plugin.LogInfo("DisconnectNodes: " + sourceId + " - " + targetId) lock.Lock() defer lock.Unlock() diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index aacc842efe..e24d67dea1 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -4,7 +4,6 @@ import ( "encoding/base64" "fmt" "io/ioutil" - "log" "net" "net/http" "strconv" @@ -16,7 +15,6 @@ import ( "github.com/iotaledger/autopeering-sim/selection" "github.com/iotaledger/autopeering-sim/server" "github.com/iotaledger/autopeering-sim/transport" - "github.com/iotaledger/goshimmer/packages/node" "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/hive.go/parameter" @@ -24,7 +22,6 @@ import ( ) var ( - PLUGIN = node.NewPlugin("Auto Peering", node.Enabled, configure, run) debugLevel = "info" close = make(chan struct{}, 1) srv *server.Server @@ -85,7 +82,7 @@ func start() { masterPeers := []*peer.Peer{} master, err := parseEntryNodes() if err != nil { - log.Printf("Ignoring entry nodes: %v\n", err) + log.Fatalf("Ignoring entry nodes: %v\n", err) } else if master != nil { masterPeers = master } diff --git a/runNetwork.sh b/runNetwork.sh index 0e2b315f6b..a9e84ee51b 100755 --- a/runNetwork.sh +++ b/runNetwork.sh @@ -27,6 +27,6 @@ for i in `seq 1 $1`; do mkdir node_$i/logs cp ../shimmer node_$i/ cd node_$i - ./shimmer --autopeering.port $PEERING_PORT --gossip.port $GOSSIP_PORT --autopeering.address 127.0.0.1 --autopeering.entryNodes 6rtO4nW2nzbSqZ8nrf0VFOn+fuyluf6ltJTkKpUc3LM=@127.0.0.1:14626 --node.logLevel 4 --node.disablePlugins statusscreen --analysis.serverAddress 127.0.0.1:188 & + ./shimmer --autopeering.port $PEERING_PORT --gossip.port $GOSSIP_PORT --autopeering.address 127.0.0.1 --autopeering.entryNodes 6rtO4nW2nzbSqZ8nrf0VFOn+fuyluf6ltJTkKpUc3LM=@127.0.0.1:14626 --node.LogLevel 4 --node.disablePlugins statusscreen --analysis.serverAddress 127.0.0.1:188 & cd .. done \ No newline at end of file From a0f2996873c459852e74f3e5aeb63011f6a3f8ea Mon Sep 17 00:00:00 2001 From: capossele Date: Mon, 25 Nov 2019 15:23:17 +0000 Subject: [PATCH 011/184] :pencil: adds comments --- plugins/autopeering/autopeering.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index e24d67dea1..8289f23d89 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -152,6 +152,7 @@ func getMyIP() string { return fmt.Sprintf("%s", ip) } +// used only for debugging puropose func printReport(log *zap.SugaredLogger) { if Discovery == nil || Selection == nil { return From bb6139e4785ba1f55e663740554e768dc36087b7 Mon Sep 17 00:00:00 2001 From: capossele Date: Wed, 27 Nov 2019 15:44:56 +0000 Subject: [PATCH 012/184] :sparkles: adds parameters of the autopeering --- go.mod | 8 +++++--- go.sum | 29 +++++++++++++++++++++++++++++ plugins/autopeering/autopeering.go | 19 +++++++++++++++---- plugins/autopeering/parameters.go | 2 +- plugins/gossip/send_queue.go | 2 +- 5 files changed, 51 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 85594ece84..67b5c1f9ec 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/go-zeromq/zmq4 v0.6.2 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/autopeering-sim v0.0.0-20191125082010-418faee91e5a + github.com/iotaledger/autopeering-sim v0.0.0-20191127100001-7ff75c77f051 github.com/iotaledger/hive.go v0.0.0-20191125115115-f88d4ecab6dd github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible @@ -27,9 +27,11 @@ require ( github.com/valyala/fasttemplate v1.1.0 // indirect go.uber.org/zap v1.13.0 golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c - golang.org/x/net v0.0.0-20191125084936-ffdde1057850 + golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect + golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect - golang.org/x/tools v0.0.0-20191125011157-cc15fab314e3 // indirect + golang.org/x/sys v0.0.0-20191127021746-63cb32ae39b2 // indirect + golang.org/x/tools v0.0.0-20191127064951-724660f1afeb // indirect golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect gopkg.in/yaml.v2 v2.2.7 // indirect ) diff --git a/go.sum b/go.sum index 7e518b44a0..cb24f7c52c 100644 --- a/go.sum +++ b/go.sum @@ -95,6 +95,20 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/iotaledger/autopeering-sim v0.0.0-20191125082010-418faee91e5a h1:4/GYRv+ClV261Dq53B4toHbWq/mdzLEAPaZ9g9Ytio8= github.com/iotaledger/autopeering-sim v0.0.0-20191125082010-418faee91e5a/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191125182425-ba5a8313e083 h1:CZ0fRxEPIgzR3oUC0tNw0aNr2x0CPXSexZN0wCMRaDs= +github.com/iotaledger/autopeering-sim v0.0.0-20191125182425-ba5a8313e083/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191125185303-6b5ef6b0dc7c h1:uHWtkHBSnkyuC7WzZaXTgwGs3pT3rM7nzKHCsmVS7pw= +github.com/iotaledger/autopeering-sim v0.0.0-20191125185303-6b5ef6b0dc7c/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191125190556-b29181ff31e4 h1:4Uuow46qBpOd3JAivhNT26yifcKZYcOuD+AWGJzzu18= +github.com/iotaledger/autopeering-sim v0.0.0-20191125190556-b29181ff31e4/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191126105507-9db87680fea0 h1:H/tSIRwKBpyEZwBCWJmashK0IlmoBSw7J3Kuk9bmiXw= +github.com/iotaledger/autopeering-sim v0.0.0-20191126105507-9db87680fea0/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191126113046-8576d83d22f3 h1:85JvTkyY4n66Um+ZdjeMdMREup2tZo6uG1W5Qx9j8VQ= +github.com/iotaledger/autopeering-sim v0.0.0-20191126113046-8576d83d22f3/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191126125252-956917114dee h1:LslhNxj2Jll9eVhbwIqM2ecfUmp1bNR106KlaxLUeFg= +github.com/iotaledger/autopeering-sim v0.0.0-20191126125252-956917114dee/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191127100001-7ff75c77f051 h1:6JWvB/U6C2b92A5Bupnjj6J9KiO0i0AQHQ8RVmMagQo= +github.com/iotaledger/autopeering-sim v0.0.0-20191127100001-7ff75c77f051/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= @@ -258,6 +272,8 @@ golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTk golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f h1:J5lckAjkw6qYlOZNj90mLYNTEKDvWeuc1yieZ8qUzUE= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -273,6 +289,8 @@ golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191125084936-ffdde1057850 h1:Vq85/r8R9IdcUHmZ0/nQlUg1v15rzvQ2sHdnZAj/x7s= golang.org/x/net v0.0.0-20191125084936-ffdde1057850/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 h1:e6HwijUxhDe+hPNjZQQn9bA5PW3vNmnN64U2ZW759Lk= +golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -302,6 +320,8 @@ golang.org/x/sys v0.0.0-20191018095205-727590c5006e h1:ZtoklVMHQy6BFRHkbG6JzK+S6 golang.org/x/sys v0.0.0-20191018095205-727590c5006e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191127021746-63cb32ae39b2 h1:/J2nHFg1MTqaRLFO7M+J78ASNsJoz3r0cvHBPQ77fsE= +golang.org/x/sys v0.0.0-20191127021746-63cb32ae39b2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -317,6 +337,15 @@ golang.org/x/tools v0.0.0-20191121040551-947d4aa89328 h1:t3X42h9e6xdbrCD/gPyWqAX golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125011157-cc15fab314e3 h1:aHkNOJLg6a84bdLJN1yjqMSTadeAuaudhEPNSkLAWoA= golang.org/x/tools v0.0.0-20191125011157-cc15fab314e3/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125180314-a99e43fcffb7 h1:+R9+VCIcEYiZ7t1BAjuRV+y0mBc7kH/pLO8D3NdKXJY= +golang.org/x/tools v0.0.0-20191125180314-a99e43fcffb7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125182823-acc15743c3f6 h1:Gf5uAD3vrwHdZZsPCuRG2v1g2pX8ClixhrwqxTJ9QQ0= +golang.org/x/tools v0.0.0-20191125182823-acc15743c3f6/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191126055441-b0650ceb63d9 h1:m9xhlkk2j+sO9WjAgNfTtl505MN7ZkuW69nOcBlp9qY= +golang.org/x/tools v0.0.0-20191126055441-b0650ceb63d9/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191127064951-724660f1afeb h1:K4JMHRJSgd1q/yXZNrKKyneQJcLm1rn7JsokEs/xE9I= +golang.org/x/tools v0.0.0-20191127064951-724660f1afeb/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 8289f23d89..46b38a70f7 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -22,7 +22,7 @@ import ( ) var ( - debugLevel = "info" + debugLevel = "debug" close = make(chan struct{}, 1) srv *server.Server Discovery *discover.Protocol @@ -59,12 +59,19 @@ func start() { localhost := host apPort := strconv.Itoa(parameter.NodeConfig.GetInt(CFG_PORT)) gossipPort := strconv.Itoa(parameter.NodeConfig.GetInt(gossip.GOSSIP_PORT)) + + var externalAddr *string if host == "0.0.0.0" { host = getMyIP() + hostPort := host + ":" + apPort + externalAddr = &hostPort } listenAddr := host + ":" + apPort gossipAddr := host + ":" + gossipPort + outboundSelectionDisabled := !parameter.NodeConfig.GetBool(CFG_SEND_REQUESTS) + inboundSelectionDisabled := !parameter.NodeConfig.GetBool(CFG_ACCEPT_REQUESTS) + logger := logger.NewLogger(defaultZLC, debugLevel) defer func() { _ = logger.Sync() }() // ignore the returned error @@ -108,12 +115,16 @@ func start() { MasterPeers: masterPeers, }) Selection = selection.New(local.INSTANCE, Discovery, selection.Config{ - Log: logger.Named("sel"), - SaltLifetime: selection.DefaultSaltLifetime, + Log: logger.Named("sel"), + Param: &selection.Parameters{ + OutboundSelectionDisabled: outboundSelectionDisabled, + InboundSelectionDisabled: inboundSelectionDisabled, + RequiredService: []string{"gossip"}, + }, }) // start a server doing discovery and peering - srv = server.Listen(local.INSTANCE, trans, logger.Named("srv"), Discovery, Selection) + srv = server.Listen(local.INSTANCE, trans, externalAddr, logger.Named("srv"), Discovery, Selection) defer srv.Close() // start the discovery on that connection diff --git a/plugins/autopeering/parameters.go b/plugins/autopeering/parameters.go index b7b02df1c7..63da5d3e9a 100644 --- a/plugins/autopeering/parameters.go +++ b/plugins/autopeering/parameters.go @@ -15,7 +15,7 @@ const ( func init() { flag.String(CFG_ADDRESS, "0.0.0.0", "address to bind for incoming peering requests") flag.String(CFG_ENTRY_NODES, "7f7a876a4236091257e650da8dcf195fbe3cb625@159.69.158.51:14626", "list of trusted entry nodes for auto peering") - flag.Int(CFG_PORT, 14626, "tcp port for incoming peering requests") + flag.Int(CFG_PORT, 14626, "udp port for incoming peering requests") flag.Bool(CFG_ACCEPT_REQUESTS, true, "accept incoming autopeering requests") flag.Bool(CFG_SEND_REQUESTS, true, "send autopeering requests") } diff --git a/plugins/gossip/send_queue.go b/plugins/gossip/send_queue.go index b3b78bb0d7..c855028951 100644 --- a/plugins/gossip/send_queue.go +++ b/plugins/gossip/send_queue.go @@ -3,8 +3,8 @@ package gossip import ( "sync" - "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" ) From 2b5921e60e9747104968bbbf38f9525388d9eaa7 Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 28 Nov 2019 07:28:29 +0000 Subject: [PATCH 013/184] :tada: initial commit --- packages/gossip/neighbors.go | 1 + packages/gossip/proto/message.proto | 0 2 files changed, 1 insertion(+) create mode 100644 packages/gossip/neighbors.go create mode 100644 packages/gossip/proto/message.proto diff --git a/packages/gossip/neighbors.go b/packages/gossip/neighbors.go new file mode 100644 index 0000000000..1022ea1071 --- /dev/null +++ b/packages/gossip/neighbors.go @@ -0,0 +1 @@ +package gossip diff --git a/packages/gossip/proto/message.proto b/packages/gossip/proto/message.proto new file mode 100644 index 0000000000..e69de29bb2 From 1ff8046da66be568404c732e82004fab9994f51a Mon Sep 17 00:00:00 2001 From: capossele Date: Mon, 2 Dec 2019 13:47:04 +0000 Subject: [PATCH 014/184] :construction: WIP --- Makefile | 17 +++ go.mod | 5 +- go.sum | 4 + packages/gossip/buffstreams | 1 + packages/gossip/errors.go | 11 ++ packages/gossip/manager.go | 4 + packages/gossip/neighbors.go | 8 ++ packages/gossip/neighbors_test.go | 126 +++++++++++++++++++ packages/gossip/proto/message.pb.go | 165 +++++++++++++++++++++++++ packages/gossip/proto/message.proto | 26 ++++ packages/gossip/protocol.go | 61 +++++++++ packages/gossip/protocol_test.go | 50 ++++++++ packages/gossip/transport/transport.go | 25 ++++ 13 files changed, 502 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 160000 packages/gossip/buffstreams create mode 100644 packages/gossip/errors.go create mode 100644 packages/gossip/manager.go create mode 100644 packages/gossip/neighbors_test.go create mode 100644 packages/gossip/proto/message.pb.go create mode 100644 packages/gossip/protocol.go create mode 100644 packages/gossip/protocol_test.go create mode 100644 packages/gossip/transport/transport.go diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..60211a35d7 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +SHELL := /bin/bash +REPO := $(shell pwd) +PROTOC_GEN_GO := $(GOPATH)/bin/protoc-gen-go +# Protobuf generated go files +PROTO_FILES = $(shell find . -path ./vendor -prune -o -type f -name '*.proto' -print) +PROTO_GO_FILES = $(patsubst %.proto, %.pb.go, $(PROTO_FILES)) + +# If $GOPATH/bin/protoc-gen-go does not exist, we'll run this command to install it. +$(PROTOC_GEN_GO): + (GO111MODULE=off go get -v github.com/golang/protobuf/protoc-gen-go) + +# Implicit compile rule for GRPC/proto files +%.pb.go: %.proto | $(PROTOC_GEN_GO) + protoc $< --go_out=plugins=grpc,paths=source_relative:. + +.PHONY: compile +compile: $(PROTO_GO_FILES) diff --git a/go.mod b/go.mod index 67b5c1f9ec..41d778526d 100644 --- a/go.mod +++ b/go.mod @@ -3,13 +3,15 @@ module github.com/iotaledger/goshimmer go 1.13 require ( + github.com/StabbyCutyou/buffstreams v2.0.0+incompatible github.com/dgraph-io/badger v1.6.0 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/gdamore/tcell v1.3.0 github.com/go-zeromq/zmq4 v0.6.2 + github.com/golang/protobuf v1.3.2 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/autopeering-sim v0.0.0-20191127100001-7ff75c77f051 + github.com/iotaledger/autopeering-sim v0.0.0-20191201144404-58a6f3b1a56d github.com/iotaledger/hive.go v0.0.0-20191125115115-f88d4ecab6dd github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible @@ -24,6 +26,7 @@ require ( github.com/spf13/afero v1.2.2 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 + github.com/stretchr/testify v1.4.0 github.com/valyala/fasttemplate v1.1.0 // indirect go.uber.org/zap v1.13.0 golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c diff --git a/go.sum b/go.sum index cb24f7c52c..756f72664e 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0= github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/StabbyCutyou/buffstreams v2.0.0+incompatible h1:7bDqOlL2Ipve3YjZVVrWz/TOVOa+IEHj6XagpAtLn2I= +github.com/StabbyCutyou/buffstreams v2.0.0+incompatible/go.mod h1:gP6wgxHoC0NrobhUBwx+Y6hx2QyKFOT+ho8619aJCDk= github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -109,6 +111,8 @@ github.com/iotaledger/autopeering-sim v0.0.0-20191126125252-956917114dee h1:Lslh github.com/iotaledger/autopeering-sim v0.0.0-20191126125252-956917114dee/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/autopeering-sim v0.0.0-20191127100001-7ff75c77f051 h1:6JWvB/U6C2b92A5Bupnjj6J9KiO0i0AQHQ8RVmMagQo= github.com/iotaledger/autopeering-sim v0.0.0-20191127100001-7ff75c77f051/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191201144404-58a6f3b1a56d h1:wZoNQRwLj4PqhKfruVQ1Yeci6kaSXnE9nSNCFtJWZ9s= +github.com/iotaledger/autopeering-sim v0.0.0-20191201144404-58a6f3b1a56d/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= diff --git a/packages/gossip/buffstreams b/packages/gossip/buffstreams new file mode 160000 index 0000000000..20679e9ca3 --- /dev/null +++ b/packages/gossip/buffstreams @@ -0,0 +1 @@ +Subproject commit 20679e9ca31ad9ff33e5a1c3c4b90ec65e9a0b03 diff --git a/packages/gossip/errors.go b/packages/gossip/errors.go new file mode 100644 index 0000000000..9ab42437d2 --- /dev/null +++ b/packages/gossip/errors.go @@ -0,0 +1,11 @@ +package gossip + +import "errors" + +var ( + errClosed = errors.New("socket closed") + errSender = errors.New("could not match sender") + errRecipient = errors.New("could not match recipient") + errSignature = errors.New("could not verify signature") + errVersion = errors.New("protocol version not supported") +) diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go new file mode 100644 index 0000000000..156156678c --- /dev/null +++ b/packages/gossip/manager.go @@ -0,0 +1,4 @@ +package gossip + +type Manager struct { +} diff --git a/packages/gossip/neighbors.go b/packages/gossip/neighbors.go index 1022ea1071..5e137f5aab 100644 --- a/packages/gossip/neighbors.go +++ b/packages/gossip/neighbors.go @@ -1 +1,9 @@ package gossip + +import ( + "github.com/iotaledger/autopeering-sim/peer" +) + +type Neighbor struct { + peer *peer.Peer +} diff --git a/packages/gossip/neighbors_test.go b/packages/gossip/neighbors_test.go new file mode 100644 index 0000000000..d85bf1c11d --- /dev/null +++ b/packages/gossip/neighbors_test.go @@ -0,0 +1,126 @@ +package gossip + +import ( + "fmt" + "log" + "strconv" + "testing" + "time" + + "github.com/golang/protobuf/proto" + "github.com/iotaledger/goshimmer/packages/gossip/buffstreams" + pb "github.com/iotaledger/goshimmer/packages/gossip/proto" +) + +// TestCallback is a simple server for test purposes. It has a single callback, +// which is to unmarshall some data and log it. +func (t *testController) TestCallback(bts []byte) error { + msg := &pb.ConnectionRequest{ + // Version: 1, + // From: "client", + // To: "server", + // Timestamp: 1, + } + err := proto.Unmarshal(bts, msg) + if t.enableLogging { + fmt.Println(msg.GetFrom(), msg.GetTo()) + } + return err +} + +type testController struct { + enableLogging bool +} + +func server() { + tc := &testController{ + enableLogging: true, + } + cfg := buffstreams.TCPListenerConfig{ + MaxMessageSize: 2048, + EnableLogging: tc.enableLogging, + Address: buffstreams.FormatAddress("127.0.0.1", strconv.Itoa(5031)), + Callback: tc.TestCallback, + } + bm := buffstreams.NewManager() + err := bm.StartListening(cfg) + if err != nil { + log.Print(err) + } else { + // Need to block until ctrl+c, but having trouble getting signal trapping to work on OSX... + time.Sleep(time.Second * 2) + fmt.Println(bm.GetConnectionIDs()) + } +} + +func client() { + cfg := &buffstreams.TCPConnConfig{ + MaxMessageSize: 2048, + Address: buffstreams.FormatAddress("127.0.0.1", strconv.Itoa(5031)), + } + msg := &pb.ConnectionRequest{ + Version: 1, + From: "client", + To: "server", + Timestamp: 1, + } + msgBytes, err := proto.Marshal(msg) + if err != nil { + log.Print(err) + } + //count := 0 + cbm := buffstreams.NewManager() + err = cbm.Dial(cfg) + if err != nil { + log.Fatal(err) + } + btw, err := cbm.Write(cfg.Address, msgBytes) + //btw, err := buffstreams.DialTCP(cfg) + if err != nil { + log.Fatal(btw, err) + } + // currentTime := time.Now() + // lastTime := currentTime + // for { + // _, err := btw.Write(msgBytes) + // if err != nil { + // fmt.Println("There was an error") + // fmt.Println(err) + // } + // count = count + 1 + // if lastTime.Second() != currentTime.Second() { + // lastTime = currentTime + // fmt.Printf(", %d\n", count) + // count = 0 + // } + // currentTime = time.Now() + // } +} +func TestDummy(t *testing.T) { + // connections = make(map[string]net.Conn) + // makeListener() + + // conn, err := net.Dial("tcp", "localhost:8080") + // if err != nil { + // // handle error + // } + // testMessage := new(pb.ConnectionRequest) + // testMessage.Version = 1 + // testMessage.From = conn.LocalAddr().String() + // testMessage.To = conn.RemoteAddr().String() + // testMessage.Timestamp = 1 + // pkt, err := proto.Marshal(testMessage) + // if err != nil { + // fmt.Println(err) + // } + // n, err := conn.Write(pkt) + // if err != nil { + // fmt.Println(n, err) + // } + // //status, err := bufio.NewReader(conn).ReadString('\n') + // time.Sleep(4 * time.Second) + + go server() + go client() + time.Sleep(4 * time.Second) +} diff --git a/packages/gossip/proto/message.pb.go b/packages/gossip/proto/message.pb.go new file mode 100644 index 0000000000..04e2409f0b --- /dev/null +++ b/packages/gossip/proto/message.pb.go @@ -0,0 +1,165 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: packages/gossip/proto/message.proto + +package proto + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// 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 + +type ConnectionRequest struct { + // protocol version number + Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + // string form of the return address (e.g. "192.0.2.1:25", "[2001:db8::1]:80") + From string `protobuf:"bytes,2,opt,name=from,proto3" json:"from,omitempty"` + // string form of the recipient address + To string `protobuf:"bytes,3,opt,name=to,proto3" json:"to,omitempty"` + // unix time + Timestamp int64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ConnectionRequest) Reset() { *m = ConnectionRequest{} } +func (m *ConnectionRequest) String() string { return proto.CompactTextString(m) } +func (*ConnectionRequest) ProtoMessage() {} +func (*ConnectionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fcce9e84825f2fa5, []int{0} +} + +func (m *ConnectionRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ConnectionRequest.Unmarshal(m, b) +} +func (m *ConnectionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ConnectionRequest.Marshal(b, m, deterministic) +} +func (m *ConnectionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConnectionRequest.Merge(m, src) +} +func (m *ConnectionRequest) XXX_Size() int { + return xxx_messageInfo_ConnectionRequest.Size(m) +} +func (m *ConnectionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ConnectionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ConnectionRequest proto.InternalMessageInfo + +func (m *ConnectionRequest) GetVersion() uint32 { + if m != nil { + return m.Version + } + return 0 +} + +func (m *ConnectionRequest) GetFrom() string { + if m != nil { + return m.From + } + return "" +} + +func (m *ConnectionRequest) GetTo() string { + if m != nil { + return m.To + } + return "" +} + +func (m *ConnectionRequest) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +type SignedConnectionRequest struct { + // data of the request + Request *ConnectionRequest `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` + // signature of the request + Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *SignedConnectionRequest) Reset() { *m = SignedConnectionRequest{} } +func (m *SignedConnectionRequest) String() string { return proto.CompactTextString(m) } +func (*SignedConnectionRequest) ProtoMessage() {} +func (*SignedConnectionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fcce9e84825f2fa5, []int{1} +} + +func (m *SignedConnectionRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_SignedConnectionRequest.Unmarshal(m, b) +} +func (m *SignedConnectionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_SignedConnectionRequest.Marshal(b, m, deterministic) +} +func (m *SignedConnectionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_SignedConnectionRequest.Merge(m, src) +} +func (m *SignedConnectionRequest) XXX_Size() int { + return xxx_messageInfo_SignedConnectionRequest.Size(m) +} +func (m *SignedConnectionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_SignedConnectionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_SignedConnectionRequest proto.InternalMessageInfo + +func (m *SignedConnectionRequest) GetRequest() *ConnectionRequest { + if m != nil { + return m.Request + } + return nil +} + +func (m *SignedConnectionRequest) GetSignature() []byte { + if m != nil { + return m.Signature + } + return nil +} + +func init() { + proto.RegisterType((*ConnectionRequest)(nil), "proto.ConnectionRequest") + proto.RegisterType((*SignedConnectionRequest)(nil), "proto.SignedConnectionRequest") +} + +func init() { + proto.RegisterFile("packages/gossip/proto/message.proto", fileDescriptor_fcce9e84825f2fa5) +} + +var fileDescriptor_fcce9e84825f2fa5 = []byte{ + // 228 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x50, 0x3d, 0x4f, 0xc3, 0x30, + 0x10, 0x55, 0xd2, 0x42, 0x55, 0xf3, 0x21, 0xe1, 0x05, 0x0f, 0x0c, 0x51, 0x59, 0x32, 0xc5, 0x52, + 0x11, 0x62, 0x87, 0x7f, 0x60, 0x36, 0x36, 0x37, 0x3d, 0xdc, 0x53, 0xb1, 0x2f, 0xf8, 0x2e, 0xfc, + 0x7e, 0x54, 0x57, 0x55, 0x87, 0x74, 0x7a, 0x1f, 0x7a, 0xd2, 0x7b, 0x7a, 0xea, 0x79, 0xf0, 0xfd, + 0xde, 0x07, 0x60, 0x1b, 0x88, 0x19, 0x07, 0x3b, 0x64, 0x12, 0xb2, 0x11, 0x98, 0x7d, 0x80, 0xae, + 0x28, 0x7d, 0x55, 0x60, 0x45, 0xea, 0xe1, 0x83, 0x52, 0x82, 0x5e, 0x90, 0x92, 0x83, 0xdf, 0x11, + 0x58, 0xb4, 0x51, 0x8b, 0x3f, 0xc8, 0x8c, 0x94, 0x4c, 0xd5, 0x54, 0xed, 0x9d, 0x3b, 0x49, 0xad, + 0xd5, 0xfc, 0x3b, 0x53, 0x34, 0x75, 0x53, 0xb5, 0x4b, 0x57, 0xb8, 0xbe, 0x57, 0xb5, 0x90, 0x99, + 0x15, 0xa7, 0x16, 0xd2, 0x4f, 0x6a, 0x29, 0x18, 0x81, 0xc5, 0xc7, 0xc1, 0xcc, 0x9b, 0xaa, 0x9d, + 0xb9, 0xb3, 0xb1, 0xda, 0xab, 0xc7, 0x4f, 0x0c, 0x09, 0xb6, 0xd3, 0xda, 0xb5, 0x5a, 0xe4, 0x23, + 0x2d, 0xb5, 0x37, 0x6b, 0x73, 0xdc, 0xda, 0x4d, 0xa2, 0xee, 0x14, 0x3c, 0x94, 0x31, 0x86, 0xe4, + 0x65, 0xcc, 0x50, 0x56, 0xdd, 0xba, 0xb3, 0xf1, 0xfe, 0xf6, 0xf5, 0x1a, 0x50, 0x76, 0xe3, 0xa6, + 0xeb, 0x29, 0x5a, 0x24, 0xf1, 0x3f, 0xb0, 0x0d, 0x90, 0x0f, 0xc7, 0xec, 0x30, 0x46, 0xc8, 0xf6, + 0xe2, 0x57, 0x9b, 0xeb, 0x02, 0x2f, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd9, 0x68, 0x9e, 0x33, + 0x4b, 0x01, 0x00, 0x00, +} diff --git a/packages/gossip/proto/message.proto b/packages/gossip/proto/message.proto index e69de29bb2..7c0ac77a86 100644 --- a/packages/gossip/proto/message.proto +++ b/packages/gossip/proto/message.proto @@ -0,0 +1,26 @@ +syntax = "proto3"; + +option go_package = "github.com/iotaledger/goshimmer/packages/gossip/proto"; + +package proto; + +//import "peer/proto/peer.proto"; +//import "peer/service/proto/service.proto"; + +message ConnectionRequest { + // protocol version number + uint32 version = 1; + // string form of the return address (e.g. "192.0.2.1:25", "[2001:db8::1]:80") + string from = 2; + // string form of the recipient address + string to = 3; + // unix time + int64 timestamp = 4; +} + +message SignedConnectionRequest { + // data of the request + ConnectionRequest request = 1; + // signature of the request + bytes signature = 2; +} \ No newline at end of file diff --git a/packages/gossip/protocol.go b/packages/gossip/protocol.go new file mode 100644 index 0000000000..7bb6a5f1ae --- /dev/null +++ b/packages/gossip/protocol.go @@ -0,0 +1,61 @@ +package gossip + +import ( + "crypto/ed25519" + + "github.com/golang/protobuf/proto" + "github.com/iotaledger/autopeering-sim/peer" + pb "github.com/iotaledger/goshimmer/packages/gossip/proto" +) + +type Local struct { + id peer.ID + key peer.PrivateKey +} + +type Protocol struct { + version uint32 + local *Local + mgr *Manager + neighbors map[string]*peer.Peer +} + +func sendRequest(p *Protocol, to *peer.Peer) error { + msg := &pb.ConnectionRequest{ + Version: p.version, + From: p.local.id.String(), + To: to.ID().String(), + Timestamp: 1, + } + + return nil +} + +func verifyRequest(p *Protocol, msg *pb.ConnectionRequest, signature []byte) error { + requester, ok := p.neighbors[msg.GetFrom()] + if !ok { + return errSender + } + if msg.GetVersion() != p.version { + return errVersion + } + if msg.GetTo() != p.local.id.String() { + return errRecipient + } + msgBytes, err := proto.Marshal(msg) + if err != nil { + return err + } + if !ed25519.Verify(ed25519.PublicKey(requester.PublicKey()), msgBytes, signature) { + return errSignature + } + return nil +} + +func signRequest(key peer.PrivateKey, msg *pb.ConnectionRequest) (signature []byte, err error) { + msgByte, err := proto.Marshal(msg) + if err != nil { + return signature, err + } + return ed25519.Sign(ed25519.PrivateKey(key), msgByte), nil +} diff --git a/packages/gossip/protocol_test.go b/packages/gossip/protocol_test.go new file mode 100644 index 0000000000..2ee0d77ee3 --- /dev/null +++ b/packages/gossip/protocol_test.go @@ -0,0 +1,50 @@ +package gossip + +import ( + "crypto/ed25519" + "fmt" + "testing" + + "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/autopeering-sim/peer/service" + pb "github.com/iotaledger/goshimmer/packages/gossip/proto" +) + +const ( + testNetwork = "tcp" + testAddress = "127.0.0.1:8000" +) + +func newTestServiceRecord() *service.Record { + services := service.New() + services.Update(service.PeeringKey, testNetwork, testAddress) + return services +} + +func TestVerifyRequest(t *testing.T) { + pubA, privA, _ := ed25519.GenerateKey(nil) + pubB, privB, _ := ed25519.GenerateKey(nil) + peerA := &Local{ + id: peer.PublicKey(pubA).ID(), + key: peer.PrivateKey(privA), + } + peerB := peer.NewPeer(peer.PublicKey(pubB), newTestServiceRecord()) + p := &Protocol{ + version: 1, + local: peerA, + neighbors: map[string]*peer.Peer{ + peerB.ID().String(): peerB, + }, + } + msg := &pb.ConnectionRequest{ + Version: 1, + From: peerB.ID().String(), + To: peerA.id.String(), + Timestamp: 1, + } + signature, _ := signRequest(peer.PrivateKey(privB), msg) + err := verifyRequest(p, msg, signature) + if err != nil { + fmt.Println("Error:", err) + } +} diff --git a/packages/gossip/transport/transport.go b/packages/gossip/transport/transport.go new file mode 100644 index 0000000000..af9cd84f08 --- /dev/null +++ b/packages/gossip/transport/transport.go @@ -0,0 +1,25 @@ +package transport + +const ( + // MaxPacketSize specifies the maximum allowed size of packets. + // Packets larger than this will be cut and thus treated as invalid. + MaxPacketSize = 1280 +) + +// Transport is generic network connection to transfer protobuf packages. +// Multiple goroutines may invoke methods on a Conn simultaneously. +type Transport interface { + // ReadFrom reads a packet from the connection. It returns the package and + // the return address for that package in string form. + ReadFrom() (pkt []byte, address string, err error) + + // WriteTo writes a packet to the string encoded target address. + WriteTo(pkt []byte, address string) error + + // Close closes the transport layer. + // Any blocked ReadFrom or WriteTo operations will return errors. + Close() + + // LocalAddr returns the local network address in string form. + LocalAddr() string +} From 289f3bd3c3a1a38438688e2e9e203113f617e944 Mon Sep 17 00:00:00 2001 From: capossele Date: Mon, 2 Dec 2019 18:20:15 +0000 Subject: [PATCH 015/184] :construction: WIP --- go.mod | 8 ++-- go.sum | 40 ++++--------------- plugins/analysis/client/plugin.go | 7 ++-- plugins/autopeering/autopeering.go | 64 +++++++++++++++++++----------- plugins/autopeering/entrynodes.go | 6 ++- plugins/autopeering/parameters.go | 14 +++---- plugins/autopeering/plugin.go | 27 +++++++++---- plugins/cli/cli.go | 5 +-- plugins/dashboard/plugin.go | 2 +- plugins/dashboard/tps.go | 17 +++++++- plugins/ui/logger.go | 3 +- plugins/ui/nodeInfo.go | 20 +++++++--- plugins/ui/ui.go | 2 +- 13 files changed, 120 insertions(+), 95 deletions(-) diff --git a/go.mod b/go.mod index 67b5c1f9ec..a27fc5a958 100644 --- a/go.mod +++ b/go.mod @@ -9,8 +9,8 @@ require ( github.com/go-zeromq/zmq4 v0.6.2 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/autopeering-sim v0.0.0-20191127100001-7ff75c77f051 - github.com/iotaledger/hive.go v0.0.0-20191125115115-f88d4ecab6dd + github.com/iotaledger/autopeering-sim v0.0.0-20191202124431-1705dc628175 + github.com/iotaledger/hive.go v0.0.0-20191202111738-357cee7a1c37 github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible github.com/lucasb-eyer/go-colorful v1.0.3 // indirect @@ -30,8 +30,8 @@ require ( golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect - golang.org/x/sys v0.0.0-20191127021746-63cb32ae39b2 // indirect - golang.org/x/tools v0.0.0-20191127064951-724660f1afeb // indirect + golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 // indirect + golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d // indirect golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect gopkg.in/yaml.v2 v2.2.7 // indirect ) diff --git a/go.sum b/go.sum index cb24f7c52c..dce6a55c34 100644 --- a/go.sum +++ b/go.sum @@ -93,27 +93,13 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/autopeering-sim v0.0.0-20191125082010-418faee91e5a h1:4/GYRv+ClV261Dq53B4toHbWq/mdzLEAPaZ9g9Ytio8= -github.com/iotaledger/autopeering-sim v0.0.0-20191125082010-418faee91e5a/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= -github.com/iotaledger/autopeering-sim v0.0.0-20191125182425-ba5a8313e083 h1:CZ0fRxEPIgzR3oUC0tNw0aNr2x0CPXSexZN0wCMRaDs= -github.com/iotaledger/autopeering-sim v0.0.0-20191125182425-ba5a8313e083/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= -github.com/iotaledger/autopeering-sim v0.0.0-20191125185303-6b5ef6b0dc7c h1:uHWtkHBSnkyuC7WzZaXTgwGs3pT3rM7nzKHCsmVS7pw= -github.com/iotaledger/autopeering-sim v0.0.0-20191125185303-6b5ef6b0dc7c/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= -github.com/iotaledger/autopeering-sim v0.0.0-20191125190556-b29181ff31e4 h1:4Uuow46qBpOd3JAivhNT26yifcKZYcOuD+AWGJzzu18= -github.com/iotaledger/autopeering-sim v0.0.0-20191125190556-b29181ff31e4/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= -github.com/iotaledger/autopeering-sim v0.0.0-20191126105507-9db87680fea0 h1:H/tSIRwKBpyEZwBCWJmashK0IlmoBSw7J3Kuk9bmiXw= -github.com/iotaledger/autopeering-sim v0.0.0-20191126105507-9db87680fea0/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= -github.com/iotaledger/autopeering-sim v0.0.0-20191126113046-8576d83d22f3 h1:85JvTkyY4n66Um+ZdjeMdMREup2tZo6uG1W5Qx9j8VQ= -github.com/iotaledger/autopeering-sim v0.0.0-20191126113046-8576d83d22f3/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= -github.com/iotaledger/autopeering-sim v0.0.0-20191126125252-956917114dee h1:LslhNxj2Jll9eVhbwIqM2ecfUmp1bNR106KlaxLUeFg= -github.com/iotaledger/autopeering-sim v0.0.0-20191126125252-956917114dee/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= -github.com/iotaledger/autopeering-sim v0.0.0-20191127100001-7ff75c77f051 h1:6JWvB/U6C2b92A5Bupnjj6J9KiO0i0AQHQ8RVmMagQo= -github.com/iotaledger/autopeering-sim v0.0.0-20191127100001-7ff75c77f051/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191202124431-1705dc628175 h1:/RAxj+VEPTykp9cWRKTtydkfuBDaFemI7/bdNYCD7Nw= +github.com/iotaledger/autopeering-sim v0.0.0-20191202124431-1705dc628175/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= -github.com/iotaledger/hive.go v0.0.0-20191125115115-f88d4ecab6dd h1:3tfMtDaByXXwx6jyPG1Qz8PtlN3YXc+3zLO2QRC7C9E= -github.com/iotaledger/hive.go v0.0.0-20191125115115-f88d4ecab6dd/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= +github.com/iotaledger/hive.go v0.0.0-20191202111738-357cee7a1c37 h1:Vex6W5Oae7xXvVmnCrl7J4o+PCx0FW3paMzXxQDr8H4= +github.com/iotaledger/hive.go v0.0.0-20191202111738-357cee7a1c37/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= github.com/iotaledger/iota.go v1.0.0-beta.7/go.mod h1:dMps6iMVU1pf5NDYNKIw4tRsPeC8W3ZWjOvYHOO1PMg= github.com/iotaledger/iota.go v1.0.0-beta.9 h1:c654s9pkdhMBkABUvWg+6k91MEBbdtmZXP1xDfQpajg= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= @@ -287,8 +273,6 @@ golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191125084936-ffdde1057850 h1:Vq85/r8R9IdcUHmZ0/nQlUg1v15rzvQ2sHdnZAj/x7s= -golang.org/x/net v0.0.0-20191125084936-ffdde1057850/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 h1:e6HwijUxhDe+hPNjZQQn9bA5PW3vNmnN64U2ZW759Lk= golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -320,8 +304,8 @@ golang.org/x/sys v0.0.0-20191018095205-727590c5006e h1:ZtoklVMHQy6BFRHkbG6JzK+S6 golang.org/x/sys v0.0.0-20191018095205-727590c5006e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191127021746-63cb32ae39b2 h1:/J2nHFg1MTqaRLFO7M+J78ASNsJoz3r0cvHBPQ77fsE= -golang.org/x/sys v0.0.0-20191127021746-63cb32ae39b2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 h1:ZBzSG/7F4eNKz2L3GE9o300RX0Az1Bw5HF7PDraD+qU= +golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -335,17 +319,9 @@ golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191121040551-947d4aa89328 h1:t3X42h9e6xdbrCD/gPyWqAXr2BEpdJqRd1brThaaxII= golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125011157-cc15fab314e3 h1:aHkNOJLg6a84bdLJN1yjqMSTadeAuaudhEPNSkLAWoA= -golang.org/x/tools v0.0.0-20191125011157-cc15fab314e3/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125180314-a99e43fcffb7 h1:+R9+VCIcEYiZ7t1BAjuRV+y0mBc7kH/pLO8D3NdKXJY= -golang.org/x/tools v0.0.0-20191125180314-a99e43fcffb7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125182823-acc15743c3f6 h1:Gf5uAD3vrwHdZZsPCuRG2v1g2pX8ClixhrwqxTJ9QQ0= -golang.org/x/tools v0.0.0-20191125182823-acc15743c3f6/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191126055441-b0650ceb63d9 h1:m9xhlkk2j+sO9WjAgNfTtl505MN7ZkuW69nOcBlp9qY= -golang.org/x/tools v0.0.0-20191126055441-b0650ceb63d9/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191127064951-724660f1afeb h1:K4JMHRJSgd1q/yXZNrKKyneQJcLm1rn7JsokEs/xE9I= -golang.org/x/tools v0.0.0-20191127064951-724660f1afeb/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d h1:/iIZNFGxc/a7C3yWjGcnboV+Tkc7mxr+p6fDztwoxuM= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index 3d0008463d..32bc5cea95 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -5,10 +5,6 @@ import ( "net" "time" - "github.com/iotaledger/hive.go/daemon" - "github.com/iotaledger/hive.go/logger" - "github.com/iotaledger/hive.go/parameter" - "github.com/iotaledger/autopeering-sim/discover" "github.com/iotaledger/autopeering-sim/selection" "github.com/iotaledger/goshimmer/packages/network" @@ -20,8 +16,11 @@ import ( "github.com/iotaledger/goshimmer/plugins/analysis/types/removenode" "github.com/iotaledger/goshimmer/plugins/autopeering" "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/parameter" ) var log = logger.NewLogger("Analysis-Client") diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 46b38a70f7..526b92955c 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -12,6 +12,7 @@ import ( "github.com/iotaledger/autopeering-sim/discover" "github.com/iotaledger/autopeering-sim/logger" "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/autopeering-sim/peer/service" "github.com/iotaledger/autopeering-sim/selection" "github.com/iotaledger/autopeering-sim/server" "github.com/iotaledger/autopeering-sim/transport" @@ -56,27 +57,22 @@ func start() { ) host := parameter.NodeConfig.GetString(CFG_ADDRESS) - localhost := host + //localhost := host apPort := strconv.Itoa(parameter.NodeConfig.GetInt(CFG_PORT)) gossipPort := strconv.Itoa(parameter.NodeConfig.GetInt(gossip.GOSSIP_PORT)) - var externalAddr *string if host == "0.0.0.0" { host = getMyIP() - hostPort := host + ":" + apPort - externalAddr = &hostPort } + listenAddr := host + ":" + apPort gossipAddr := host + ":" + gossipPort - outboundSelectionDisabled := !parameter.NodeConfig.GetBool(CFG_SEND_REQUESTS) - inboundSelectionDisabled := !parameter.NodeConfig.GetBool(CFG_ACCEPT_REQUESTS) - logger := logger.NewLogger(defaultZLC, debugLevel) defer func() { _ = logger.Sync() }() // ignore the returned error - addr, err := net.ResolveUDPAddr("udp", localhost+":"+apPort) + addr, err := net.ResolveUDPAddr("udp", host+":"+apPort) if err != nil { log.Fatalf("ResolveUDPAddr: %v", err) } @@ -101,30 +97,30 @@ func start() { // create a new local node db := peer.NewPersistentDB(logger.Named("db")) defer db.Close() - local.INSTANCE, err = peer.NewLocal(db) + local.INSTANCE, err = peer.NewLocal("udp", listenAddr, db) if err != nil { log.Fatalf("ListenUDP: %v", err) } - // add a service for the peering - local.INSTANCE.Services()["peering"] = peer.NetworkAddress{Network: "udp", Address: listenAddr} + // add a service for the gossip - local.INSTANCE.Services()["gossip"] = peer.NetworkAddress{Network: "tcp", Address: gossipAddr} + local.INSTANCE.UpdateService(service.GossipKey, &networkAddress{"tcp", gossipAddr}) + log.Debug("Local Services:", local.INSTANCE.Services().CreateRecord().String()) Discovery = discover.New(local.INSTANCE, discover.Config{ Log: logger.Named("disc"), MasterPeers: masterPeers, }) + //if parameter.NodeConfig.GetBool(CFG_SELECTION) { Selection = selection.New(local.INSTANCE, Discovery, selection.Config{ Log: logger.Named("sel"), Param: &selection.Parameters{ - OutboundSelectionDisabled: outboundSelectionDisabled, - InboundSelectionDisabled: inboundSelectionDisabled, - RequiredService: []string{"gossip"}, + SaltLifetime: selection.DefaultSaltLifetime, + // RequiredService: []string{"gossip"}, }, }) // start a server doing discovery and peering - srv = server.Listen(local.INSTANCE, trans, externalAddr, logger.Named("srv"), Discovery, Selection) + srv = server.Listen(local.INSTANCE, trans, logger.Named("srv"), Discovery, Selection) defer srv.Close() // start the discovery on that connection @@ -132,12 +128,13 @@ func start() { defer Discovery.Close() // start the peering on that connection - Selection.Start(srv) - defer Selection.Close() + if parameter.NodeConfig.GetBool(CFG_SELECTION) { + Selection.Start(srv) + defer Selection.Close() + } id := base64.StdEncoding.EncodeToString(local.INSTANCE.PublicKey()) - a, b, _ := net.SplitHostPort(srv.LocalAddr()) - logger.Info("Discovery protocol started: ID="+id+", address="+srv.LocalAddr(), a, b) + logger.Info("Discovery protocol started: ID=" + id + ", address=" + srv.LocalAddr()) go func() { for t := range time.NewTicker(2 * time.Second).C { @@ -169,9 +166,28 @@ func printReport(log *zap.SugaredLogger) { return } knownPeers := Discovery.GetVerifiedPeers() - incoming := Selection.GetIncomingNeighbors() - outgoing := Selection.GetOutgoingNeighbors() + incoming := []*peer.Peer{} + outgoing := []*peer.Peer{} + if Selection != nil { + incoming = Selection.GetIncomingNeighbors() + outgoing = Selection.GetOutgoingNeighbors() + } log.Info("Known peers:", len(knownPeers)) - log.Info("Chosen:", len(outgoing), outgoing) - log.Info("Accepted:", len(incoming), incoming) + log.Info("Chosen:", len(outgoing)) + log.Info("Accepted:", len(incoming)) +} + +type networkAddress struct { + network string + address string +} + +// Network returns the service's network name. +func (a *networkAddress) Network() string { + return a.network +} + +// String returns the service's address in string form. +func (a *networkAddress) String() string { + return a.address } diff --git a/plugins/autopeering/entrynodes.go b/plugins/autopeering/entrynodes.go index 836903f282..0dc4862739 100644 --- a/plugins/autopeering/entrynodes.go +++ b/plugins/autopeering/entrynodes.go @@ -5,6 +5,7 @@ import ( "strings" "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/autopeering-sim/peer/service" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/hive.go/parameter" ) @@ -24,7 +25,10 @@ func parseEntryNodes() (result []*peer.Peer, err error) { return nil, errors.Wrap(err, "parseMaster") } - result = append(result, peer.NewPeer(pubKey, parts[1])) + services := service.New() + services.Update(service.PeeringKey, "udp", parts[1]) + + result = append(result, peer.NewPeer(pubKey, services)) } return result, nil diff --git a/plugins/autopeering/parameters.go b/plugins/autopeering/parameters.go index 63da5d3e9a..fdbe32a049 100644 --- a/plugins/autopeering/parameters.go +++ b/plugins/autopeering/parameters.go @@ -5,17 +5,15 @@ import ( ) const ( - CFG_ADDRESS = "autopeering.address" - CFG_ENTRY_NODES = "autopeering.entryNodes" - CFG_PORT = "autopeering.port" - CFG_ACCEPT_REQUESTS = "autopeering.acceptRequests" - CFG_SEND_REQUESTS = "autopeering.sendRequests" + CFG_ADDRESS = "autopeering.address" + CFG_ENTRY_NODES = "autopeering.entryNodes" + CFG_PORT = "autopeering.port" + CFG_SELECTION = "autopeering.selection" ) func init() { flag.String(CFG_ADDRESS, "0.0.0.0", "address to bind for incoming peering requests") - flag.String(CFG_ENTRY_NODES, "7f7a876a4236091257e650da8dcf195fbe3cb625@159.69.158.51:14626", "list of trusted entry nodes for auto peering") + flag.String(CFG_ENTRY_NODES, "pub_Key@127.0.0.1:14626", "list of trusted entry nodes for auto peering") flag.Int(CFG_PORT, 14626, "udp port for incoming peering requests") - flag.Bool(CFG_ACCEPT_REQUESTS, true, "accept incoming autopeering requests") - flag.Bool(CFG_SEND_REQUESTS, true, "send autopeering requests") + flag.Bool(CFG_SELECTION, true, "enable peer selection") } diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 3ebd4a0004..04f54e7f6b 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -4,6 +4,7 @@ import ( "net" "github.com/iotaledger/autopeering-sim/discover" + "github.com/iotaledger/autopeering-sim/peer/service" "github.com/iotaledger/autopeering-sim/selection" "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/hive.go/daemon" @@ -29,24 +30,34 @@ func run(plugin *node.Plugin) { func configureLogging(plugin *node.Plugin) { gossip.Events.RemoveNeighbor.Attach(events.NewClosure(func(peer *gossip.Neighbor) { - Selection.DropPeer(peer.Peer) + if Selection != nil { + Selection.DropPeer(peer.Peer) + } })) selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) { - log.Debug("neighbor removed: " + ev.DroppedID.String()) + log.Info("neighbor removed: " + ev.DroppedID.String()) gossip.RemoveNeighbor(ev.DroppedID.String()) })) selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { - log.Debug("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - address, port, _ := net.SplitHostPort(ev.Services["gossip"].Address) - gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port)) + log.Info("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) + log.Info("services: " + ev.Peer.Services().CreateRecord().String()) + gossipService := ev.Peer.Services().Get(service.GossipKey) + if gossipService != nil { + address, port, _ := net.SplitHostPort(ev.Peer.Services().Get(service.GossipKey).String()) + gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port)) + } })) selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { - log.Debug("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - address, port, _ := net.SplitHostPort(ev.Services["gossip"].Address) - gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port)) + log.Info("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) + log.Info("services: " + ev.Peer.Services().CreateRecord().String()) + gossipService := ev.Peer.Services().Get(service.GossipKey) + if gossipService != nil { + address, port, _ := net.SplitHostPort(ev.Peer.Services().Get(service.GossipKey).String()) + gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port)) + } })) discover.Events.PeerDiscovered.Attach(events.NewClosure(func(ev *discover.DiscoveredEvent) { diff --git a/plugins/cli/cli.go b/plugins/cli/cli.go index 104d1d44b9..39ea901ff1 100644 --- a/plugins/cli/cli.go +++ b/plugins/cli/cli.go @@ -7,9 +7,8 @@ import ( "sort" "strings" - flag "github.com/spf13/pflag" - "github.com/iotaledger/hive.go/node" + flag "github.com/spf13/pflag" ) var enabledPlugins []string @@ -44,5 +43,5 @@ func printUsage() { fmt.Fprintf(os.Stderr, "\nThe following plugins are enabled by default and can be disabled with -%s:\n %s\n", node.CFG_DISABLE_PLUGINS, getList(enabledPlugins)) fmt.Fprintf(os.Stderr, "The following plugins are disabled by default and can be enabled with -%s:\n %s\n", node.CFG_ENABLE_PLUGINS, getList(disabledPlugins)) - fmt.Fprintf(os.Stderr, "The enabled/disabled plugins can be overriden by altering %s/%s inside config.json\n\n", node.CFG_ENABLE_PLUGINS, node.CFG_DISABLE_PLUGINS) + fmt.Fprintf(os.Stderr, "The enabled/disabled plugins can be overridden by altering %s/%s inside config.json\n\n", node.CFG_ENABLE_PLUGINS, node.CFG_DISABLE_PLUGINS) } diff --git a/plugins/dashboard/plugin.go b/plugins/dashboard/plugin.go index a5815826a3..64f6e69c6f 100644 --- a/plugins/dashboard/plugin.go +++ b/plugins/dashboard/plugin.go @@ -1,7 +1,6 @@ package dashboard import ( - "github.com/iotaledger/hive.go/logger" "net/http" "time" @@ -10,6 +9,7 @@ import ( "github.com/iotaledger/goshimmer/plugins/metrics" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" ) diff --git a/plugins/dashboard/tps.go b/plugins/dashboard/tps.go index 3a20bbb388..6f6710bdc1 100644 --- a/plugins/dashboard/tps.go +++ b/plugins/dashboard/tps.go @@ -69,10 +69,23 @@ func GetStatus() *Status { } uptime += fmt.Sprintf("%02ds ", int(duration.Seconds())%60) + outgoing := "0" + incoming := "0" + neighbors := "0" + if autopeering.Selection != nil { + outgoing = strconv.Itoa(len(autopeering.Selection.GetOutgoingNeighbors())) + incoming = strconv.Itoa(len(autopeering.Selection.GetIncomingNeighbors())) + neighbors = strconv.Itoa(len(autopeering.Selection.GetNeighbors())) + } + knownPeers := "0" + if autopeering.Discovery != nil { + knownPeers = strconv.Itoa(len(autopeering.Discovery.GetVerifiedPeers())) + } + return &Status{ Id: local.INSTANCE.ID().String(), - Neighbor: "Neighbors: " + strconv.Itoa(len(autopeering.Selection.GetOutgoingNeighbors())) + " chosen / " + strconv.Itoa(len(autopeering.Selection.GetIncomingNeighbors())) + " accepted / " + strconv.Itoa(len(autopeering.Selection.GetNeighbors())) + " total", - KnownPeer: "Known Peers: " + strconv.Itoa(len(autopeering.Discovery.GetVerifiedPeers())) + " total", + Neighbor: "Neighbors: " + outgoing + " chosen / " + incoming + " accepted / " + neighbors + " total", + KnownPeer: "Known Peers: " + knownPeers + " total", Uptime: uptime, } } diff --git a/plugins/ui/logger.go b/plugins/ui/logger.go index b34519cef7..a4653aac52 100644 --- a/plugins/ui/logger.go +++ b/plugins/ui/logger.go @@ -1,9 +1,10 @@ package ui import ( - "github.com/iotaledger/hive.go/logger" "sync" "time" + + "github.com/iotaledger/hive.go/logger" ) var logMutex = sync.Mutex{} diff --git a/plugins/ui/nodeInfo.go b/plugins/ui/nodeInfo.go index 70f2531791..c23b25444e 100644 --- a/plugins/ui/nodeInfo.go +++ b/plugins/ui/nodeInfo.go @@ -39,11 +39,19 @@ func gatherInfo() nodeInfo { // update neighbors chosenNeighbors := []string{} acceptedNeighbors := []string{} - for _, peer := range autopeering.Selection.GetOutgoingNeighbors() { - chosenNeighbors = append(chosenNeighbors, peer.String()) + neighbors := 0 + knownPeers := 0 + if autopeering.Selection != nil { + for _, peer := range autopeering.Selection.GetOutgoingNeighbors() { + chosenNeighbors = append(chosenNeighbors, peer.String()) + } + for _, peer := range autopeering.Selection.GetIncomingNeighbors() { + acceptedNeighbors = append(acceptedNeighbors, peer.String()) + } + neighbors = len(chosenNeighbors) + len(acceptedNeighbors) } - for _, peer := range autopeering.Selection.GetIncomingNeighbors() { - acceptedNeighbors = append(acceptedNeighbors, peer.String()) + if autopeering.Discovery != nil { + knownPeers = len(autopeering.Discovery.GetVerifiedPeers()) } receivedTps, solidTps := updateTpsCounters() @@ -52,8 +60,8 @@ func gatherInfo() nodeInfo { ID: local.INSTANCE.ID().String(), ChosenNeighbors: chosenNeighbors, AcceptedNeighbors: acceptedNeighbors, - KnownPeersSize: len(autopeering.Discovery.GetVerifiedPeers()), //knownpeers.INSTANCE.Peers.Len(), - NeighborhoodSize: len(autopeering.Selection.GetNeighbors()), //neighborhood.INSTANCE.Peers.Len(), + KnownPeersSize: knownPeers, + NeighborhoodSize: neighbors, Uptime: uint64(duration), ReceivedTps: receivedTps, SolidTps: solidTps, diff --git a/plugins/ui/ui.go b/plugins/ui/ui.go index f4e5afad68..2bc5d3654f 100644 --- a/plugins/ui/ui.go +++ b/plugins/ui/ui.go @@ -1,7 +1,6 @@ package ui import ( - "github.com/iotaledger/hive.go/logger" "net/http" "strings" "sync/atomic" @@ -14,6 +13,7 @@ import ( "github.com/iotaledger/goshimmer/plugins/webapi" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" "github.com/labstack/echo" From f8b7c93ac803385707a3bf52e2a7428e851f11dd Mon Sep 17 00:00:00 2001 From: capossele Date: Mon, 2 Dec 2019 21:29:24 +0000 Subject: [PATCH 016/184] :construction: WIP --- go.mod | 4 +-- go.sum | 4 +++ plugins/autopeering/autopeering.go | 42 ++++++++++++------------------ 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/go.mod b/go.mod index a27fc5a958..7822f61265 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/go-zeromq/zmq4 v0.6.2 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/autopeering-sim v0.0.0-20191202124431-1705dc628175 + github.com/iotaledger/autopeering-sim v0.0.0-20191202212322-a6353b992662 github.com/iotaledger/hive.go v0.0.0-20191202111738-357cee7a1c37 github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible @@ -31,7 +31,7 @@ require ( golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 // indirect - golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d // indirect + golang.org/x/tools v0.0.0-20191202203127-2b6af5f9ace7 // indirect golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect gopkg.in/yaml.v2 v2.2.7 // indirect ) diff --git a/go.sum b/go.sum index dce6a55c34..ec6b36f293 100644 --- a/go.sum +++ b/go.sum @@ -95,6 +95,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/iotaledger/autopeering-sim v0.0.0-20191202124431-1705dc628175 h1:/RAxj+VEPTykp9cWRKTtydkfuBDaFemI7/bdNYCD7Nw= github.com/iotaledger/autopeering-sim v0.0.0-20191202124431-1705dc628175/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191202212322-a6353b992662 h1:al3bYvSaJnFyupe7bqgXYeBZ7W0fTNWrFd9WLLNlC6I= +github.com/iotaledger/autopeering-sim v0.0.0-20191202212322-a6353b992662/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= @@ -322,6 +324,8 @@ golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d h1:/iIZNFGxc/a7C3yWjGcnboV+Tkc7mxr+p6fDztwoxuM= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191202203127-2b6af5f9ace7 h1:I7bfRTrfnb7yQSesz6OhwGVh2imeNUcbbS8YtFYC8Ck= +golang.org/x/tools v0.0.0-20191202203127-2b6af5f9ace7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 526b92955c..f664c78aa6 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -103,24 +103,29 @@ func start() { } // add a service for the gossip - local.INSTANCE.UpdateService(service.GossipKey, &networkAddress{"tcp", gossipAddr}) - log.Debug("Local Services:", local.INSTANCE.Services().CreateRecord().String()) + if parameter.NodeConfig.GetBool(CFG_SELECTION) { + local.INSTANCE.UpdateService(service.GossipKey, "tcp", gossipAddr) + } Discovery = discover.New(local.INSTANCE, discover.Config{ Log: logger.Named("disc"), MasterPeers: masterPeers, }) - //if parameter.NodeConfig.GetBool(CFG_SELECTION) { - Selection = selection.New(local.INSTANCE, Discovery, selection.Config{ - Log: logger.Named("sel"), - Param: &selection.Parameters{ - SaltLifetime: selection.DefaultSaltLifetime, - // RequiredService: []string{"gossip"}, - }, - }) + handlers := append([]server.Handler{}, Discovery) + + if parameter.NodeConfig.GetBool(CFG_SELECTION) { + Selection = selection.New(local.INSTANCE, Discovery, selection.Config{ + Log: logger.Named("sel"), + Param: &selection.Parameters{ + SaltLifetime: selection.DefaultSaltLifetime, + // RequiredService: []string{"gossip"}, + }, + }) + handlers = append(handlers, Selection) + } // start a server doing discovery and peering - srv = server.Listen(local.INSTANCE, trans, logger.Named("srv"), Discovery, Selection) + srv = server.Listen(local.INSTANCE, trans, logger.Named("srv"), handlers...) defer srv.Close() // start the discovery on that connection @@ -176,18 +181,3 @@ func printReport(log *zap.SugaredLogger) { log.Info("Chosen:", len(outgoing)) log.Info("Accepted:", len(incoming)) } - -type networkAddress struct { - network string - address string -} - -// Network returns the service's network name. -func (a *networkAddress) Network() string { - return a.network -} - -// String returns the service's address in string form. -func (a *networkAddress) String() string { - return a.address -} From 6f726d74cf6d9b67f9c334ba4695faff6909933a Mon Sep 17 00:00:00 2001 From: capossele Date: Mon, 2 Dec 2019 21:58:09 +0000 Subject: [PATCH 017/184] :construction: WIP --- plugins/autopeering/autopeering.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index f664c78aa6..af5b20f894 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -57,7 +57,7 @@ func start() { ) host := parameter.NodeConfig.GetString(CFG_ADDRESS) - //localhost := host + localhost := host apPort := strconv.Itoa(parameter.NodeConfig.GetInt(CFG_PORT)) gossipPort := strconv.Itoa(parameter.NodeConfig.GetInt(gossip.GOSSIP_PORT)) @@ -72,7 +72,7 @@ func start() { defer func() { _ = logger.Sync() }() // ignore the returned error - addr, err := net.ResolveUDPAddr("udp", host+":"+apPort) + addr, err := net.ResolveUDPAddr("udp", localhost+":"+apPort) if err != nil { log.Fatalf("ResolveUDPAddr: %v", err) } @@ -117,8 +117,8 @@ func start() { Selection = selection.New(local.INSTANCE, Discovery, selection.Config{ Log: logger.Named("sel"), Param: &selection.Parameters{ - SaltLifetime: selection.DefaultSaltLifetime, - // RequiredService: []string{"gossip"}, + SaltLifetime: selection.DefaultSaltLifetime, + RequiredService: []service.Key{service.GossipKey}, }, }) handlers = append(handlers, Selection) From 5a065fa28930af8acfbfc03716df07028df64f02 Mon Sep 17 00:00:00 2001 From: capossele Date: Tue, 3 Dec 2019 17:09:56 +0000 Subject: [PATCH 018/184] :arrow_up: updates to master branch of ap --- go.mod | 4 ++-- go.sum | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 7822f61265..ecf09eb7bb 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/go-zeromq/zmq4 v0.6.2 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/autopeering-sim v0.0.0-20191202212322-a6353b992662 + github.com/iotaledger/autopeering-sim v0.0.0-20191203092805-a1dd5954f3f6 github.com/iotaledger/hive.go v0.0.0-20191202111738-357cee7a1c37 github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible @@ -31,7 +31,7 @@ require ( golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 // indirect - golang.org/x/tools v0.0.0-20191202203127-2b6af5f9ace7 // indirect + golang.org/x/tools v0.0.0-20191203134012-c197fd4bf371 // indirect golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect gopkg.in/yaml.v2 v2.2.7 // indirect ) diff --git a/go.sum b/go.sum index ec6b36f293..9e07ecd69b 100644 --- a/go.sum +++ b/go.sum @@ -97,6 +97,8 @@ github.com/iotaledger/autopeering-sim v0.0.0-20191202124431-1705dc628175 h1:/RAx github.com/iotaledger/autopeering-sim v0.0.0-20191202124431-1705dc628175/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/autopeering-sim v0.0.0-20191202212322-a6353b992662 h1:al3bYvSaJnFyupe7bqgXYeBZ7W0fTNWrFd9WLLNlC6I= github.com/iotaledger/autopeering-sim v0.0.0-20191202212322-a6353b992662/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191203092805-a1dd5954f3f6 h1:lcM/irmEr++tz/XQCHCTBsteqiBVZ3uTurLnnviCxLg= +github.com/iotaledger/autopeering-sim v0.0.0-20191203092805-a1dd5954f3f6/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= @@ -326,6 +328,8 @@ golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d h1:/iIZNFGxc/a7C3yWjGcnboV golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191202203127-2b6af5f9ace7 h1:I7bfRTrfnb7yQSesz6OhwGVh2imeNUcbbS8YtFYC8Ck= golang.org/x/tools v0.0.0-20191202203127-2b6af5f9ace7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191203134012-c197fd4bf371 h1:Cjq6sG3gnKDchzWy7ouGQklhxMtWvh4AhSNJ0qGIeo4= +golang.org/x/tools v0.0.0-20191203134012-c197fd4bf371/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= From b04d665a7749925fcb4627570fa02b1539483482 Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 5 Dec 2019 08:31:10 +0000 Subject: [PATCH 019/184] :heavy_minus_sign: removes old gossip --- packages/gossip/buffstreams | 1 - packages/gossip/errors.go | 11 -- packages/gossip/manager.go | 4 - packages/gossip/neighbors.go | 9 -- packages/gossip/neighbors_test.go | 126 ------------------- packages/gossip/proto/message.pb.go | 165 ------------------------- packages/gossip/proto/message.proto | 26 ---- packages/gossip/protocol.go | 61 --------- packages/gossip/protocol_test.go | 50 -------- packages/gossip/transport/transport.go | 25 ---- 10 files changed, 478 deletions(-) delete mode 160000 packages/gossip/buffstreams delete mode 100644 packages/gossip/errors.go delete mode 100644 packages/gossip/manager.go delete mode 100644 packages/gossip/neighbors.go delete mode 100644 packages/gossip/neighbors_test.go delete mode 100644 packages/gossip/proto/message.pb.go delete mode 100644 packages/gossip/proto/message.proto delete mode 100644 packages/gossip/protocol.go delete mode 100644 packages/gossip/protocol_test.go delete mode 100644 packages/gossip/transport/transport.go diff --git a/packages/gossip/buffstreams b/packages/gossip/buffstreams deleted file mode 160000 index 20679e9ca3..0000000000 --- a/packages/gossip/buffstreams +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 20679e9ca31ad9ff33e5a1c3c4b90ec65e9a0b03 diff --git a/packages/gossip/errors.go b/packages/gossip/errors.go deleted file mode 100644 index 9ab42437d2..0000000000 --- a/packages/gossip/errors.go +++ /dev/null @@ -1,11 +0,0 @@ -package gossip - -import "errors" - -var ( - errClosed = errors.New("socket closed") - errSender = errors.New("could not match sender") - errRecipient = errors.New("could not match recipient") - errSignature = errors.New("could not verify signature") - errVersion = errors.New("protocol version not supported") -) diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go deleted file mode 100644 index 156156678c..0000000000 --- a/packages/gossip/manager.go +++ /dev/null @@ -1,4 +0,0 @@ -package gossip - -type Manager struct { -} diff --git a/packages/gossip/neighbors.go b/packages/gossip/neighbors.go deleted file mode 100644 index 5e137f5aab..0000000000 --- a/packages/gossip/neighbors.go +++ /dev/null @@ -1,9 +0,0 @@ -package gossip - -import ( - "github.com/iotaledger/autopeering-sim/peer" -) - -type Neighbor struct { - peer *peer.Peer -} diff --git a/packages/gossip/neighbors_test.go b/packages/gossip/neighbors_test.go deleted file mode 100644 index d85bf1c11d..0000000000 --- a/packages/gossip/neighbors_test.go +++ /dev/null @@ -1,126 +0,0 @@ -package gossip - -import ( - "fmt" - "log" - "strconv" - "testing" - "time" - - "github.com/golang/protobuf/proto" - "github.com/iotaledger/goshimmer/packages/gossip/buffstreams" - pb "github.com/iotaledger/goshimmer/packages/gossip/proto" -) - -// TestCallback is a simple server for test purposes. It has a single callback, -// which is to unmarshall some data and log it. -func (t *testController) TestCallback(bts []byte) error { - msg := &pb.ConnectionRequest{ - // Version: 1, - // From: "client", - // To: "server", - // Timestamp: 1, - } - err := proto.Unmarshal(bts, msg) - if t.enableLogging { - fmt.Println(msg.GetFrom(), msg.GetTo()) - } - return err -} - -type testController struct { - enableLogging bool -} - -func server() { - tc := &testController{ - enableLogging: true, - } - cfg := buffstreams.TCPListenerConfig{ - MaxMessageSize: 2048, - EnableLogging: tc.enableLogging, - Address: buffstreams.FormatAddress("127.0.0.1", strconv.Itoa(5031)), - Callback: tc.TestCallback, - } - bm := buffstreams.NewManager() - err := bm.StartListening(cfg) - if err != nil { - log.Print(err) - } else { - // Need to block until ctrl+c, but having trouble getting signal trapping to work on OSX... - time.Sleep(time.Second * 2) - fmt.Println(bm.GetConnectionIDs()) - } -} - -func client() { - cfg := &buffstreams.TCPConnConfig{ - MaxMessageSize: 2048, - Address: buffstreams.FormatAddress("127.0.0.1", strconv.Itoa(5031)), - } - msg := &pb.ConnectionRequest{ - Version: 1, - From: "client", - To: "server", - Timestamp: 1, - } - msgBytes, err := proto.Marshal(msg) - if err != nil { - log.Print(err) - } - //count := 0 - cbm := buffstreams.NewManager() - err = cbm.Dial(cfg) - if err != nil { - log.Fatal(err) - } - btw, err := cbm.Write(cfg.Address, msgBytes) - //btw, err := buffstreams.DialTCP(cfg) - if err != nil { - log.Fatal(btw, err) - } - // currentTime := time.Now() - // lastTime := currentTime - // for { - // _, err := btw.Write(msgBytes) - // if err != nil { - // fmt.Println("There was an error") - // fmt.Println(err) - // } - // count = count + 1 - // if lastTime.Second() != currentTime.Second() { - // lastTime = currentTime - // fmt.Printf(", %d\n", count) - // count = 0 - // } - // currentTime = time.Now() - // } -} -func TestDummy(t *testing.T) { - // connections = make(map[string]net.Conn) - // makeListener() - - // conn, err := net.Dial("tcp", "localhost:8080") - // if err != nil { - // // handle error - // } - // testMessage := new(pb.ConnectionRequest) - // testMessage.Version = 1 - // testMessage.From = conn.LocalAddr().String() - // testMessage.To = conn.RemoteAddr().String() - // testMessage.Timestamp = 1 - // pkt, err := proto.Marshal(testMessage) - // if err != nil { - // fmt.Println(err) - // } - // n, err := conn.Write(pkt) - // if err != nil { - // fmt.Println(n, err) - // } - // //status, err := bufio.NewReader(conn).ReadString('\n') - // time.Sleep(4 * time.Second) - - go server() - go client() - time.Sleep(4 * time.Second) -} diff --git a/packages/gossip/proto/message.pb.go b/packages/gossip/proto/message.pb.go deleted file mode 100644 index 04e2409f0b..0000000000 --- a/packages/gossip/proto/message.pb.go +++ /dev/null @@ -1,165 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: packages/gossip/proto/message.proto - -package proto - -import ( - fmt "fmt" - proto "github.com/golang/protobuf/proto" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// 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 - -type ConnectionRequest struct { - // protocol version number - Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` - // string form of the return address (e.g. "192.0.2.1:25", "[2001:db8::1]:80") - From string `protobuf:"bytes,2,opt,name=from,proto3" json:"from,omitempty"` - // string form of the recipient address - To string `protobuf:"bytes,3,opt,name=to,proto3" json:"to,omitempty"` - // unix time - Timestamp int64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ConnectionRequest) Reset() { *m = ConnectionRequest{} } -func (m *ConnectionRequest) String() string { return proto.CompactTextString(m) } -func (*ConnectionRequest) ProtoMessage() {} -func (*ConnectionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_fcce9e84825f2fa5, []int{0} -} - -func (m *ConnectionRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ConnectionRequest.Unmarshal(m, b) -} -func (m *ConnectionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ConnectionRequest.Marshal(b, m, deterministic) -} -func (m *ConnectionRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ConnectionRequest.Merge(m, src) -} -func (m *ConnectionRequest) XXX_Size() int { - return xxx_messageInfo_ConnectionRequest.Size(m) -} -func (m *ConnectionRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ConnectionRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ConnectionRequest proto.InternalMessageInfo - -func (m *ConnectionRequest) GetVersion() uint32 { - if m != nil { - return m.Version - } - return 0 -} - -func (m *ConnectionRequest) GetFrom() string { - if m != nil { - return m.From - } - return "" -} - -func (m *ConnectionRequest) GetTo() string { - if m != nil { - return m.To - } - return "" -} - -func (m *ConnectionRequest) GetTimestamp() int64 { - if m != nil { - return m.Timestamp - } - return 0 -} - -type SignedConnectionRequest struct { - // data of the request - Request *ConnectionRequest `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` - // signature of the request - Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *SignedConnectionRequest) Reset() { *m = SignedConnectionRequest{} } -func (m *SignedConnectionRequest) String() string { return proto.CompactTextString(m) } -func (*SignedConnectionRequest) ProtoMessage() {} -func (*SignedConnectionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_fcce9e84825f2fa5, []int{1} -} - -func (m *SignedConnectionRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_SignedConnectionRequest.Unmarshal(m, b) -} -func (m *SignedConnectionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_SignedConnectionRequest.Marshal(b, m, deterministic) -} -func (m *SignedConnectionRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_SignedConnectionRequest.Merge(m, src) -} -func (m *SignedConnectionRequest) XXX_Size() int { - return xxx_messageInfo_SignedConnectionRequest.Size(m) -} -func (m *SignedConnectionRequest) XXX_DiscardUnknown() { - xxx_messageInfo_SignedConnectionRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_SignedConnectionRequest proto.InternalMessageInfo - -func (m *SignedConnectionRequest) GetRequest() *ConnectionRequest { - if m != nil { - return m.Request - } - return nil -} - -func (m *SignedConnectionRequest) GetSignature() []byte { - if m != nil { - return m.Signature - } - return nil -} - -func init() { - proto.RegisterType((*ConnectionRequest)(nil), "proto.ConnectionRequest") - proto.RegisterType((*SignedConnectionRequest)(nil), "proto.SignedConnectionRequest") -} - -func init() { - proto.RegisterFile("packages/gossip/proto/message.proto", fileDescriptor_fcce9e84825f2fa5) -} - -var fileDescriptor_fcce9e84825f2fa5 = []byte{ - // 228 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x50, 0x3d, 0x4f, 0xc3, 0x30, - 0x10, 0x55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0f, 0xc7, 0xec, 0x30, 0x46, 0xc8, 0xf6, - 0xe2, 0x57, 0x9b, 0xeb, 0x02, 0x2f, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd9, 0x68, 0x9e, 0x33, - 0x4b, 0x01, 0x00, 0x00, -} diff --git a/packages/gossip/proto/message.proto b/packages/gossip/proto/message.proto deleted file mode 100644 index 7c0ac77a86..0000000000 --- a/packages/gossip/proto/message.proto +++ /dev/null @@ -1,26 +0,0 @@ -syntax = "proto3"; - -option go_package = "github.com/iotaledger/goshimmer/packages/gossip/proto"; - -package proto; - -//import "peer/proto/peer.proto"; -//import "peer/service/proto/service.proto"; - -message ConnectionRequest { - // protocol version number - uint32 version = 1; - // string form of the return address (e.g. "192.0.2.1:25", "[2001:db8::1]:80") - string from = 2; - // string form of the recipient address - string to = 3; - // unix time - int64 timestamp = 4; -} - -message SignedConnectionRequest { - // data of the request - ConnectionRequest request = 1; - // signature of the request - bytes signature = 2; -} \ No newline at end of file diff --git a/packages/gossip/protocol.go b/packages/gossip/protocol.go deleted file mode 100644 index 7bb6a5f1ae..0000000000 --- a/packages/gossip/protocol.go +++ /dev/null @@ -1,61 +0,0 @@ -package gossip - -import ( - "crypto/ed25519" - - "github.com/golang/protobuf/proto" - "github.com/iotaledger/autopeering-sim/peer" - pb "github.com/iotaledger/goshimmer/packages/gossip/proto" -) - -type Local struct { - id peer.ID - key peer.PrivateKey -} - -type Protocol struct { - version uint32 - local *Local - mgr *Manager - neighbors map[string]*peer.Peer -} - -func sendRequest(p *Protocol, to *peer.Peer) error { - msg := &pb.ConnectionRequest{ - Version: p.version, - From: p.local.id.String(), - To: to.ID().String(), - Timestamp: 1, - } - - return nil -} - -func verifyRequest(p *Protocol, msg *pb.ConnectionRequest, signature []byte) error { - requester, ok := p.neighbors[msg.GetFrom()] - if !ok { - return errSender - } - if msg.GetVersion() != p.version { - return errVersion - } - if msg.GetTo() != p.local.id.String() { - return errRecipient - } - msgBytes, err := proto.Marshal(msg) - if err != nil { - return err - } - if !ed25519.Verify(ed25519.PublicKey(requester.PublicKey()), msgBytes, signature) { - return errSignature - } - return nil -} - -func signRequest(key peer.PrivateKey, msg *pb.ConnectionRequest) (signature []byte, err error) { - msgByte, err := proto.Marshal(msg) - if err != nil { - return signature, err - } - return ed25519.Sign(ed25519.PrivateKey(key), msgByte), nil -} diff --git a/packages/gossip/protocol_test.go b/packages/gossip/protocol_test.go deleted file mode 100644 index 2ee0d77ee3..0000000000 --- a/packages/gossip/protocol_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package gossip - -import ( - "crypto/ed25519" - "fmt" - "testing" - - "github.com/iotaledger/autopeering-sim/peer" - "github.com/iotaledger/autopeering-sim/peer/service" - pb "github.com/iotaledger/goshimmer/packages/gossip/proto" -) - -const ( - testNetwork = "tcp" - testAddress = "127.0.0.1:8000" -) - -func newTestServiceRecord() *service.Record { - services := service.New() - services.Update(service.PeeringKey, testNetwork, testAddress) - return services -} - -func TestVerifyRequest(t *testing.T) { - pubA, privA, _ := ed25519.GenerateKey(nil) - pubB, privB, _ := ed25519.GenerateKey(nil) - peerA := &Local{ - id: peer.PublicKey(pubA).ID(), - key: peer.PrivateKey(privA), - } - peerB := peer.NewPeer(peer.PublicKey(pubB), newTestServiceRecord()) - p := &Protocol{ - version: 1, - local: peerA, - neighbors: map[string]*peer.Peer{ - peerB.ID().String(): peerB, - }, - } - msg := &pb.ConnectionRequest{ - Version: 1, - From: peerB.ID().String(), - To: peerA.id.String(), - Timestamp: 1, - } - signature, _ := signRequest(peer.PrivateKey(privB), msg) - err := verifyRequest(p, msg, signature) - if err != nil { - fmt.Println("Error:", err) - } -} diff --git a/packages/gossip/transport/transport.go b/packages/gossip/transport/transport.go deleted file mode 100644 index af9cd84f08..0000000000 --- a/packages/gossip/transport/transport.go +++ /dev/null @@ -1,25 +0,0 @@ -package transport - -const ( - // MaxPacketSize specifies the maximum allowed size of packets. - // Packets larger than this will be cut and thus treated as invalid. - MaxPacketSize = 1280 -) - -// Transport is generic network connection to transfer protobuf packages. -// Multiple goroutines may invoke methods on a Conn simultaneously. -type Transport interface { - // ReadFrom reads a packet from the connection. It returns the package and - // the return address for that package in string form. - ReadFrom() (pkt []byte, address string, err error) - - // WriteTo writes a packet to the string encoded target address. - WriteTo(pkt []byte, address string) error - - // Close closes the transport layer. - // Any blocked ReadFrom or WriteTo operations will return errors. - Close() - - // LocalAddr returns the local network address in string form. - LocalAddr() string -} From 3af58727f1cbb9488cc6e635d7c331004121c0bc Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 5 Dec 2019 12:36:45 +0000 Subject: [PATCH 020/184] :construction: WIP --- go.mod | 3 +- go.sum | 6 + main.go | 3 +- packages/gossip/events.go | 28 ++ packages/gossip/manager.go | 204 +++++++++ packages/gossip/manager_test.go | 246 +++++++++++ .../gossip/neighbor/neighbor.go | 45 +- packages/gossip/proto/message.go | 30 ++ packages/gossip/proto/message.pb.go | 121 ++++++ packages/gossip/proto/message.proto | 15 + packages/gossip/transport/connection.go | 44 ++ packages/gossip/transport/handshake.go | 90 ++++ .../gossip/transport/proto/handshake.pb.go | 152 +++++++ .../gossip/transport/proto/handshake.proto | 21 + packages/gossip/transport/transport.go | 386 ++++++++++++++++++ packages/gossip/transport/transport_test.go | 197 +++++++++ plugins/autopeering/plugin.go | 38 +- plugins/gossip-on-solidification/plugin.go | 15 - plugins/gossip/errors.go | 12 - plugins/gossip/events.go | 97 ----- plugins/gossip/gossip.go | 86 ++++ plugins/gossip/neighbors.go | 286 ------------- plugins/gossip/plugin.go | 18 +- plugins/gossip/protocol.go | 199 --------- plugins/gossip/protocol_v1.go | 383 ----------------- plugins/gossip/protocol_v1.png | Bin 24951 -> 0 bytes plugins/gossip/send_queue.go | 156 ------- plugins/gossip/server.go | 77 ---- plugins/gossip/transaction_processor.go | 26 -- plugins/gossip/transaction_processor_test.go | 49 --- plugins/tangle/events.go | 4 +- 31 files changed, 1693 insertions(+), 1344 deletions(-) create mode 100644 packages/gossip/events.go create mode 100644 packages/gossip/manager.go create mode 100644 packages/gossip/manager_test.go rename plugins/gossip/neighborMap.go => packages/gossip/neighbor/neighbor.go (56%) create mode 100644 packages/gossip/proto/message.go create mode 100644 packages/gossip/proto/message.pb.go create mode 100644 packages/gossip/proto/message.proto create mode 100644 packages/gossip/transport/connection.go create mode 100644 packages/gossip/transport/handshake.go create mode 100644 packages/gossip/transport/proto/handshake.pb.go create mode 100644 packages/gossip/transport/proto/handshake.proto create mode 100644 packages/gossip/transport/transport.go create mode 100644 packages/gossip/transport/transport_test.go delete mode 100644 plugins/gossip-on-solidification/plugin.go delete mode 100644 plugins/gossip/errors.go delete mode 100644 plugins/gossip/events.go create mode 100644 plugins/gossip/gossip.go delete mode 100644 plugins/gossip/neighbors.go delete mode 100644 plugins/gossip/protocol.go delete mode 100644 plugins/gossip/protocol_v1.go delete mode 100644 plugins/gossip/protocol_v1.png delete mode 100644 plugins/gossip/send_queue.go delete mode 100644 plugins/gossip/server.go delete mode 100644 plugins/gossip/transaction_processor.go delete mode 100644 plugins/gossip/transaction_processor_test.go diff --git a/go.mod b/go.mod index 41d778526d..1a51bdbc97 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.13 require ( github.com/StabbyCutyou/buffstreams v2.0.0+incompatible + github.com/capossele/gossip v0.0.0-20191205112840-0e578079b414 github.com/dgraph-io/badger v1.6.0 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/gdamore/tcell v1.3.0 @@ -11,7 +12,7 @@ require ( github.com/golang/protobuf v1.3.2 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/autopeering-sim v0.0.0-20191201144404-58a6f3b1a56d + github.com/iotaledger/autopeering-sim v0.0.0-20191202192349-f8e7a238c2bb github.com/iotaledger/hive.go v0.0.0-20191125115115-f88d4ecab6dd github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible diff --git a/go.sum b/go.sum index 756f72664e..55861d7641 100644 --- a/go.sum +++ b/go.sum @@ -18,6 +18,10 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5 github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/capossele/gossip v0.0.0-20191204191545-36eddf08c1aa h1:46C1Ce+93zGZ+JJ4JUw3EuXHQXqKYzIX7+CRG0fweNk= +github.com/capossele/gossip v0.0.0-20191204191545-36eddf08c1aa/go.mod h1:P8rJEmorO5QpCL236F8vNhUFwFFjezt2d/+/LeRlELA= +github.com/capossele/gossip v0.0.0-20191205112840-0e578079b414 h1:C9Q279xU15Qt5WVZNH6t/1L7exbTVYp1uMRS9NSmL/U= +github.com/capossele/gossip v0.0.0-20191205112840-0e578079b414/go.mod h1:DnYLNZclq7cY6s2oA6wwhQ4tDB0j38enJHPrhpzOpJc= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= @@ -113,6 +117,8 @@ github.com/iotaledger/autopeering-sim v0.0.0-20191127100001-7ff75c77f051 h1:6JWv github.com/iotaledger/autopeering-sim v0.0.0-20191127100001-7ff75c77f051/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/autopeering-sim v0.0.0-20191201144404-58a6f3b1a56d h1:wZoNQRwLj4PqhKfruVQ1Yeci6kaSXnE9nSNCFtJWZ9s= github.com/iotaledger/autopeering-sim v0.0.0-20191201144404-58a6f3b1a56d/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191202192349-f8e7a238c2bb h1:nfe6HpDhLjvnliVwaz8sO2E/fpD4BEnI/FwfrU+iDRU= +github.com/iotaledger/autopeering-sim v0.0.0-20191202192349-f8e7a238c2bb/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= diff --git a/main.go b/main.go index b43e2240c7..2d313d6846 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,6 @@ import ( "github.com/iotaledger/goshimmer/plugins/cli" "github.com/iotaledger/goshimmer/plugins/dashboard" "github.com/iotaledger/goshimmer/plugins/gossip" - gossip_on_solidification "github.com/iotaledger/goshimmer/plugins/gossip-on-solidification" "github.com/iotaledger/goshimmer/plugins/gracefulshutdown" "github.com/iotaledger/goshimmer/plugins/metrics" "github.com/iotaledger/goshimmer/plugins/statusscreen" @@ -28,7 +27,7 @@ func main() { cli.PLUGIN, autopeering.PLUGIN, gossip.PLUGIN, - gossip_on_solidification.PLUGIN, + //gossip_on_solidification.PLUGIN, tangle.PLUGIN, bundleprocessor.PLUGIN, analysis.PLUGIN, diff --git a/packages/gossip/events.go b/packages/gossip/events.go new file mode 100644 index 0000000000..4c4e34a067 --- /dev/null +++ b/packages/gossip/events.go @@ -0,0 +1,28 @@ +package gossip + +import ( + "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/hive.go/events" +) + +// Events contains all the events that are triggered during the gossip protocol. +type Events struct { + NewTransaction *events.Event + DropNeighbor *events.Event +} + +type NewTransactionEvent struct { + Body []byte + Peer *peer.Peer +} +type DropNeighborEvent struct { + Peer *peer.Peer +} + +func newTransaction(handler interface{}, params ...interface{}) { + handler.(func(*NewTransactionEvent))(params[0].(*NewTransactionEvent)) +} + +func dropNeighbor(handler interface{}, params ...interface{}) { + handler.(func(*DropNeighborEvent))(params[0].(*DropNeighborEvent)) +} diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go new file mode 100644 index 0000000000..6c889e36fd --- /dev/null +++ b/packages/gossip/manager.go @@ -0,0 +1,204 @@ +package gossip + +import ( + "net" + + "github.com/capossele/gossip/neighbor" + pb "github.com/capossele/gossip/proto" + "github.com/capossele/gossip/transport" + "github.com/golang/protobuf/proto" + "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/hive.go/events" + "github.com/pkg/errors" + "go.uber.org/zap" +) + +const ( + maxAttempts = 3 +) + +var ( + Event Events +) + +type GetTransaction func(txHash []byte) ([]byte, error) + +type Manager struct { + neighborhood *neighbor.NeighborMap + trans *transport.TransportTCP + log *zap.SugaredLogger + getTransaction GetTransaction + Events Events +} + +func NewManager(t *transport.TransportTCP, log *zap.SugaredLogger, f GetTransaction) *Manager { + mgr := &Manager{ + neighborhood: neighbor.NewMap(), + trans: t, + log: log, + getTransaction: f, + Events: Events{ + NewTransaction: events.NewEvent(newTransaction), + DropNeighbor: events.NewEvent(dropNeighbor)}, + } + Event = mgr.Events + return mgr +} + +func (m *Manager) AddOutbound(p *peer.Peer) error { + return m.addNeighbor(p, m.trans.DialPeer) +} + +func (m *Manager) AddInbound(p *peer.Peer) error { + return m.addNeighbor(p, m.trans.AcceptPeer) +} + +func (m *Manager) DropNeighbor(id peer.ID) { + m.deleteNeighbor(id) +} + +func (m *Manager) RequestTransaction(data []byte, to ...*neighbor.Neighbor) { + req := &pb.TransactionRequest{} + err := proto.Unmarshal(data, req) + if err != nil { + m.log.Warnw("Data to send is not a Transaction Request", "err", err) + } + msg := marshal(req) + + m.send(msg, to...) +} + +func (m *Manager) Send(data []byte, to ...*neighbor.Neighbor) { + tx := &pb.Transaction{} + err := proto.Unmarshal(data, tx) + if err != nil { + m.log.Warnw("Data to send is not a Transaction", "err", err) + } + msg := marshal(tx) + + m.send(msg, to...) +} + +func (m *Manager) send(msg []byte, to ...*neighbor.Neighbor) { + neighbors := m.neighborhood.GetSlice() + if to != nil { + neighbors = to + } + + for _, neighbor := range neighbors { + m.log.Debugw("Sending", "to", neighbor.Peer.ID().String(), "msg", msg) + err := neighbor.Conn.Write(msg) + if err != nil { + m.log.Debugw("send error", "err", err) + } + } +} + +func (m *Manager) addNeighbor(peer *peer.Peer, handshake func(*peer.Peer) (*transport.Connection, error)) error { + if _, ok := m.neighborhood.Load(peer.ID().String()); ok { + return errors.New("Neighbor already added") + } + + var err error + var conn *transport.Connection + i := 0 + for i = 0; i < maxAttempts; i++ { + conn, err = handshake(peer) + if err != nil { + m.log.Warnw("Connection attempt failed", "attempt", i+1) + } else { + break + } + } + if i == maxAttempts { + m.log.Warnw("Connection failed to", "peer", peer.ID().String()) + m.Events.DropNeighbor.Trigger(&DropNeighborEvent{Peer: peer}) + return err + } + + // add the new neighbor + neighbor := neighbor.New(peer, conn) + m.neighborhood.Store(peer.ID().String(), neighbor) + + // start listener for the new neighbor + go m.readLoop(neighbor) + + return nil +} + +func (m *Manager) deleteNeighbor(id peer.ID) { + m.log.Debugw("Deleting neighbor", "neighbor", id.String()) + + p, ok := m.neighborhood.Delete(id.String()) + if ok { + m.Events.DropNeighbor.Trigger(&DropNeighborEvent{Peer: p.Peer}) + } +} + +func (m *Manager) readLoop(neighbor *neighbor.Neighbor) { + for { + data, err := neighbor.Conn.Read() + if nerr, ok := err.(net.Error); ok && nerr.Temporary() { + // ignore temporary read errors. + //m.log.Debugw("temporary read error", "err", err) + continue + } else if err != nil { + // return from the loop on all other errors + m.log.Debugw("reading stopped") + m.deleteNeighbor(neighbor.Peer.ID()) + + return + } + if err := m.handlePacket(data, neighbor); err != nil { + m.log.Warnw("failed to handle packet", "from", neighbor.Peer.ID().String(), "err", err) + } + } +} + +func (m *Manager) handlePacket(data []byte, neighbor *neighbor.Neighbor) error { + switch pb.MType(data[0]) { + + // Incoming Transaction + case pb.MTransaction: + msg := new(pb.Transaction) + if err := proto.Unmarshal(data[1:], msg); err != nil { + return errors.Wrap(err, "invalid message") + } + m.log.Debugw("Received Transaction", "data", msg.GetBody()) + m.Events.NewTransaction.Trigger(&NewTransactionEvent{Body: msg.GetBody(), Peer: neighbor.Peer}) + + // Incoming Transaction request + case pb.MTransactionRequest: + msg := new(pb.TransactionRequest) + if err := proto.Unmarshal(data[1:], msg); err != nil { + return errors.Wrap(err, "invalid message") + } + m.log.Debugw("Received Tx Req", "data", msg.GetHash()) + // do something + tx, err := m.getTransaction(msg.GetHash()) + if err != nil { + m.log.Debugw("Tx not available", "tx", msg.GetHash()) + } else { + m.log.Debugw("Tx found", "tx", tx) + m.Send(tx, neighbor) + } + + default: + return nil + } + + return nil +} + +func marshal(msg pb.Message) []byte { + mType := msg.Type() + if mType > 0xFF { + panic("invalid message") + } + + data, err := proto.Marshal(msg) + if err != nil { + panic("invalid message") + } + return append([]byte{byte(mType)}, data...) +} diff --git a/packages/gossip/manager_test.go b/packages/gossip/manager_test.go new file mode 100644 index 0000000000..e037c22d9f --- /dev/null +++ b/packages/gossip/manager_test.go @@ -0,0 +1,246 @@ +package gossip + +import ( + "log" + "sync" + "testing" + "time" + + pb "github.com/capossele/gossip/proto" + "github.com/capossele/gossip/transport" + "github.com/golang/protobuf/proto" + "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/autopeering-sim/peer/service" + "github.com/iotaledger/hive.go/events" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.uber.org/zap" +) + +const graceTime = 5 * time.Millisecond + +var logger *zap.SugaredLogger + +func init() { + l, err := zap.NewDevelopment() + if err != nil { + log.Fatalf("cannot initialize logger: %v", err) + } + logger = l.Sugar() +} +func testGetTransaction([]byte) ([]byte, error) { + tx := &pb.TransactionRequest{ + Hash: []byte("testTx"), + } + b, _ := proto.Marshal(tx) + return b, nil +} + +func newTest(t require.TestingT, name string) (*Manager, func(), *peer.Peer) { + log := logger.Named(name) + db := peer.NewMemoryDB(log.Named("db")) + local, err := peer.NewLocal("peering", name, db) + require.NoError(t, err) + require.NoError(t, local.UpdateService(service.GossipKey, "tcp", "localhost:0")) + + trans, err := transport.Listen(local, log) + require.NoError(t, err) + + mgr := NewManager(trans, log, testGetTransaction) + + // update the service with the actual address + require.NoError(t, local.UpdateService(service.GossipKey, trans.LocalAddr().Network(), trans.LocalAddr().String())) + + teardown := func() { + trans.Close() + db.Close() + } + return mgr, teardown, &local.Peer +} + +func TestClose(t *testing.T) { + _, teardown, _ := newTest(t, "A") + teardown() +} + +func TestUnicast(t *testing.T) { + mgrA, closeA, peerA := newTest(t, "A") + defer closeA() + mgrB, closeB, peerB := newTest(t, "B") + defer closeB() + + var wg sync.WaitGroup + wg.Add(2) + + go func() { + defer wg.Done() + err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) + assert.NoError(t, err) + }() + time.Sleep(graceTime) + go func() { + defer wg.Done() + err := mgrB.addNeighbor(peerA, mgrB.trans.DialPeer) + assert.NoError(t, err) + }() + + // wait for the connections to establish + wg.Wait() + + tx := &pb.Transaction{Body: []byte("Hello!")} + + triggered := make(chan struct{}, 1) + mgrB.Events.NewTransaction.Attach(events.NewClosure(func(ev *NewTransactionEvent) { + require.Empty(t, triggered) // only once + assert.Equal(t, tx.GetBody(), ev.Body) + assert.Equal(t, peerA, ev.Peer) + triggered <- struct{}{} + })) + + b, err := proto.Marshal(tx) + require.NoError(t, err) + mgrA.Send(b) + + // eventually the event should be triggered + assert.Eventually(t, func() bool { return len(triggered) >= 1 }, time.Second, 10*time.Millisecond) +} + +func TestBroadcast(t *testing.T) { + mgrA, closeA, peerA := newTest(t, "A") + defer closeA() + mgrB, closeB, peerB := newTest(t, "B") + defer closeB() + mgrC, closeC, peerC := newTest(t, "C") + defer closeC() + + var wg sync.WaitGroup + wg.Add(4) + + go func() { + defer wg.Done() + err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) + assert.NoError(t, err) + }() + go func() { + defer wg.Done() + err := mgrA.addNeighbor(peerC, mgrA.trans.AcceptPeer) + assert.NoError(t, err) + }() + time.Sleep(graceTime) + go func() { + defer wg.Done() + err := mgrB.addNeighbor(peerA, mgrB.trans.DialPeer) + assert.NoError(t, err) + }() + go func() { + defer wg.Done() + err := mgrC.addNeighbor(peerA, mgrC.trans.DialPeer) + assert.NoError(t, err) + }() + + // wait for the connections to establish + wg.Wait() + + tx := &pb.Transaction{Body: []byte("Hello!")} + + triggeredB := make(chan struct{}, 1) + mgrB.Events.NewTransaction.Attach(events.NewClosure(func(ev *NewTransactionEvent) { + require.Empty(t, triggeredB) // only once + assert.Equal(t, tx.GetBody(), ev.Body) + assert.Equal(t, peerA, ev.Peer) + triggeredB <- struct{}{} + })) + + triggeredC := make(chan struct{}, 1) + mgrC.Events.NewTransaction.Attach(events.NewClosure(func(ev *NewTransactionEvent) { + require.Empty(t, triggeredC) // only once + assert.Equal(t, tx.GetBody(), ev.Body) + assert.Equal(t, peerA, ev.Peer) + triggeredC <- struct{}{} + })) + + b, err := proto.Marshal(tx) + assert.NoError(t, err) + mgrA.Send(b) + + // eventually the events should be triggered + success := func() bool { + return len(triggeredB) >= 1 && len(triggeredC) >= 1 + } + assert.Eventually(t, success, time.Second, 10*time.Millisecond) +} + +func TestDropUnsuccessfulAccept(t *testing.T) { + mgrA, closeA, _ := newTest(t, "A") + defer closeA() + _, closeB, peerB := newTest(t, "B") + defer closeB() + + triggered := make(chan struct{}, 1) + mgrA.Events.DropNeighbor.Attach(events.NewClosure(func(ev *DropNeighborEvent) { + require.Empty(t, triggered) // only once + assert.Equal(t, peerB, ev.Peer) + triggered <- struct{}{} + })) + + err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) + assert.Error(t, err) + + // eventually the event should be triggered + assert.Eventually(t, func() bool { return len(triggered) >= 1 }, time.Second, 10*time.Millisecond) +} + +func TestTxRequest(t *testing.T) { + mgrA, closeA, peerA := newTest(t, "A") + defer closeA() + mgrB, closeB, peerB := newTest(t, "B") + defer closeB() + + var wg sync.WaitGroup + wg.Add(2) + + go func() { + defer wg.Done() + err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) + assert.NoError(t, err) + logger.Debugw("Len", "len", mgrA.neighborhood.Len()) + }() + go func() { + defer wg.Done() + err := mgrB.addNeighbor(peerA, mgrB.trans.DialPeer) + assert.NoError(t, err) + logger.Debugw("Len", "len", mgrB.neighborhood.Len()) + }() + + wg.Wait() + + tx := &pb.TransactionRequest{ + Hash: []byte("Hello!"), + } + b, err := proto.Marshal(tx) + assert.NoError(t, err) + + sendChan := make(chan struct{}) + sendSuccess := false + + mgrA.Events.NewTransaction.Attach(events.NewClosure(func(ev *NewTransactionEvent) { + logger.Debugw("New TX Event triggered", "data", ev.Body, "from", ev.Peer.ID().String()) + assert.Equal(t, []byte("testTx"), ev.Body) + assert.Equal(t, peerB, ev.Peer) + sendChan <- struct{}{} + })) + + mgrA.RequestTransaction(b) + + timer := time.NewTimer(5 * time.Second) + defer timer.Stop() + + select { + case <-sendChan: + sendSuccess = true + case <-timer.C: + sendSuccess = false + } + + assert.True(t, sendSuccess) +} diff --git a/plugins/gossip/neighborMap.go b/packages/gossip/neighbor/neighbor.go similarity index 56% rename from plugins/gossip/neighborMap.go rename to packages/gossip/neighbor/neighbor.go index 9823c35501..41d2d25fbc 100644 --- a/plugins/gossip/neighborMap.go +++ b/packages/gossip/neighbor/neighbor.go @@ -1,24 +1,40 @@ -package gossip +package neighbor import ( "sync" + + "github.com/capossele/gossip/transport" + "github.com/iotaledger/autopeering-sim/peer" ) -// NeighborMap is the mapping of neighbor identifier and their neighbor struct -// It uses a mutex to handle concurrent access to its internal map +// Neighbor defines a neighbor +type Neighbor struct { + Peer *peer.Peer + Conn *transport.Connection +} + +// NeighborMap implements a map of neighbors thread safe type NeighborMap struct { sync.RWMutex internal map[string]*Neighbor } -// NewPeerMap returns a new PeerMap -func NewNeighborMap() *NeighborMap { +// NewMap returns a new NeighborMap +func NewMap() *NeighborMap { return &NeighborMap{ internal: make(map[string]*Neighbor), } } -// Len returns the number of peers stored in a PeerMap +// New returns a new Neighbor +func New(peer *peer.Peer, conn *transport.Connection) *Neighbor { + return &Neighbor{ + Peer: peer, + Conn: conn, + } +} + +// Len returns the number of neighbors stored in a NeighborMap func (nm *NeighborMap) Len() int { nm.RLock() defer nm.RUnlock() @@ -36,7 +52,7 @@ func (nm *NeighborMap) GetMap() map[string]*Neighbor { return newMap } -// GetMap returns the content of the entire internal map +// GetSlice returns a slice of the content of the entire internal map func (nm *NeighborMap) GetSlice() []*Neighbor { newSlice := make([]*Neighbor, nm.Len()) nm.RLock() @@ -49,9 +65,9 @@ func (nm *NeighborMap) GetSlice() []*Neighbor { return newSlice } -// Load returns the peer for a given key. +// Load returns the neighbor for a given key. // It also return a bool to communicate the presence of the given -// peer into the internal map +// neighbor into the internal map func (nm *NeighborMap) Load(key string) (value *Neighbor, ok bool) { nm.RLock() defer nm.RUnlock() @@ -60,18 +76,21 @@ func (nm *NeighborMap) Load(key string) (value *Neighbor, ok bool) { } // Delete removes the entire entry for a given key and return true if successful -func (nm *NeighborMap) Delete(key string) (deletedPeer *Neighbor, ok bool) { - deletedPeer, ok = nm.Load(key) +func (nm *NeighborMap) Delete(key string) (deletedNeighbor *Neighbor, ok bool) { + deletedNeighbor, ok = nm.Load(key) if !ok { return nil, false } nm.Lock() defer nm.Unlock() + if deletedNeighbor.Conn != nil { + deletedNeighbor.Conn.Close() + } delete(nm.internal, key) - return deletedPeer, true + return deletedNeighbor, true } -// Store adds a new peer to the PeerMap +// Store adds a new neighbor to the NeighborMap func (nm *NeighborMap) Store(key string, value *Neighbor) { nm.Lock() defer nm.Unlock() diff --git a/packages/gossip/proto/message.go b/packages/gossip/proto/message.go new file mode 100644 index 0000000000..f9404c1ebb --- /dev/null +++ b/packages/gossip/proto/message.go @@ -0,0 +1,30 @@ +package proto + +import ( + "github.com/golang/protobuf/proto" +) + +// MType is the type of message type enum. +type MType uint + +// An enum for the different message types. +const ( + MTransaction MType = 20 + iota + MTransactionRequest +) + +// Message extends the proto.Message interface with additional util functions. +type Message interface { + proto.Message + + // Name returns the name of the corresponding message type for debugging. + Name() string + // Type returns the type of the corresponding message as an enum. + Type() MType +} + +func (m *Transaction) Name() string { return "TRANSACTION" } +func (m *Transaction) Type() MType { return MTransaction } + +func (m *TransactionRequest) Name() string { return "TRANSACTION_REQUEST" } +func (m *TransactionRequest) Type() MType { return MTransactionRequest } diff --git a/packages/gossip/proto/message.pb.go b/packages/gossip/proto/message.pb.go new file mode 100644 index 0000000000..1e67ece10c --- /dev/null +++ b/packages/gossip/proto/message.pb.go @@ -0,0 +1,121 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: proto/message.proto + +package proto + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// 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 + +type Transaction struct { + // body of the tx + Body []byte `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Transaction) Reset() { *m = Transaction{} } +func (m *Transaction) String() string { return proto.CompactTextString(m) } +func (*Transaction) ProtoMessage() {} +func (*Transaction) Descriptor() ([]byte, []int) { + return fileDescriptor_33f3a5e1293a7bcd, []int{0} +} + +func (m *Transaction) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Transaction.Unmarshal(m, b) +} +func (m *Transaction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Transaction.Marshal(b, m, deterministic) +} +func (m *Transaction) XXX_Merge(src proto.Message) { + xxx_messageInfo_Transaction.Merge(m, src) +} +func (m *Transaction) XXX_Size() int { + return xxx_messageInfo_Transaction.Size(m) +} +func (m *Transaction) XXX_DiscardUnknown() { + xxx_messageInfo_Transaction.DiscardUnknown(m) +} + +var xxx_messageInfo_Transaction proto.InternalMessageInfo + +func (m *Transaction) GetBody() []byte { + if m != nil { + return m.Body + } + return nil +} + +type TransactionRequest struct { + // transaction hash + Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *TransactionRequest) Reset() { *m = TransactionRequest{} } +func (m *TransactionRequest) String() string { return proto.CompactTextString(m) } +func (*TransactionRequest) ProtoMessage() {} +func (*TransactionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_33f3a5e1293a7bcd, []int{1} +} + +func (m *TransactionRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_TransactionRequest.Unmarshal(m, b) +} +func (m *TransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_TransactionRequest.Marshal(b, m, deterministic) +} +func (m *TransactionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_TransactionRequest.Merge(m, src) +} +func (m *TransactionRequest) XXX_Size() int { + return xxx_messageInfo_TransactionRequest.Size(m) +} +func (m *TransactionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_TransactionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_TransactionRequest proto.InternalMessageInfo + +func (m *TransactionRequest) GetHash() []byte { + if m != nil { + return m.Hash + } + return nil +} + +func init() { + proto.RegisterType((*Transaction)(nil), "proto.Transaction") + proto.RegisterType((*TransactionRequest)(nil), "proto.TransactionRequest") +} + +func init() { proto.RegisterFile("proto/message.proto", fileDescriptor_33f3a5e1293a7bcd) } + +var fileDescriptor_33f3a5e1293a7bcd = []byte{ + // 139 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2e, 0x28, 0xca, 0x2f, + 0xc9, 0xd7, 0xcf, 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0xd5, 0x03, 0xf3, 0x84, 0x58, 0xc1, 0x94, + 0x92, 0x22, 0x17, 0x77, 0x48, 0x51, 0x62, 0x5e, 0x71, 0x62, 0x72, 0x49, 0x66, 0x7e, 0x9e, 0x90, + 0x10, 0x17, 0x4b, 0x52, 0x7e, 0x4a, 0xa5, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x4f, 0x10, 0x98, 0xad, + 0xa4, 0xc1, 0x25, 0x84, 0xa4, 0x24, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x04, 0xa4, 0x32, 0x23, + 0xb1, 0x38, 0x03, 0xa6, 0x12, 0xc4, 0x76, 0x52, 0x8e, 0x52, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, + 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0x4e, 0x2c, 0xc8, 0x2f, 0x2e, 0x4e, 0xcd, 0x49, 0xd5, 0x4f, + 0xcf, 0x2f, 0x2e, 0xce, 0x2c, 0xd0, 0x07, 0xdb, 0x98, 0xc4, 0x06, 0xa6, 0x8c, 0x01, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x34, 0x46, 0xa5, 0x0f, 0x96, 0x00, 0x00, 0x00, +} diff --git a/packages/gossip/proto/message.proto b/packages/gossip/proto/message.proto new file mode 100644 index 0000000000..b01b93680c --- /dev/null +++ b/packages/gossip/proto/message.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +option go_package = "github.com/capossele/gossip/proto"; + +package proto; + +message Transaction { + // body of the tx + bytes body = 1; +} + +message TransactionRequest { + // transaction hash + bytes hash = 1; +} \ No newline at end of file diff --git a/packages/gossip/transport/connection.go b/packages/gossip/transport/connection.go new file mode 100644 index 0000000000..f688612973 --- /dev/null +++ b/packages/gossip/transport/connection.go @@ -0,0 +1,44 @@ +package transport + +import ( + "net" + + "github.com/iotaledger/autopeering-sim/peer" +) + +const ( + // MaxPacketSize specifies the maximum allowed size of packets. + // Packets larger than this will be cut and thus treated as invalid. + MaxPacketSize = 1280 +) + +type Connection struct { + peer *peer.Peer + conn net.Conn +} + +func newConnection(p *peer.Peer, c net.Conn) *Connection { + return &Connection{ + peer: p, + conn: c, + } +} + +func (c *Connection) Close() { + c.conn.Close() +} + +func (c *Connection) Read() ([]byte, error) { + b := make([]byte, MaxPacketSize) + n, err := c.conn.Read(b) + if err != nil { + return nil, err + } + + return b[:n], nil +} + +func (c *Connection) Write(b []byte) error { + _, err := c.conn.Write(b) + return err +} diff --git a/packages/gossip/transport/handshake.go b/packages/gossip/transport/handshake.go new file mode 100644 index 0000000000..c6e253ffda --- /dev/null +++ b/packages/gossip/transport/handshake.go @@ -0,0 +1,90 @@ +package transport + +import ( + "bytes" + "time" + + pb "github.com/capossele/gossip/transport/proto" + "github.com/golang/protobuf/proto" + "github.com/iotaledger/autopeering-sim/server" +) + +const ( + HandshakeExpiration = 20 * time.Second + VersionNum = 0 +) + +// isExpired checks whether the given UNIX time stamp is too far in the past. +func isExpired(ts int64) bool { + return time.Since(time.Unix(ts, 0)) >= HandshakeExpiration +} + +func newHandshakeRequest(fromAddr string, toAddr string) ([]byte, error) { + m := &pb.HandshakeRequest{ + Version: VersionNum, + From: fromAddr, + To: toAddr, + Timestamp: time.Now().Unix(), + } + return proto.Marshal(m) +} + +func newHandshakeResponse(reqData []byte) ([]byte, error) { + m := &pb.HandshakeResponse{ + ReqHash: server.PacketHash(reqData), + } + return proto.Marshal(m) +} + +func (t *TransportTCP) validateHandshakeRequest(reqData []byte, fromAddr string) bool { + m := new(pb.HandshakeRequest) + if err := proto.Unmarshal(reqData, m); err != nil { + t.log.Debugw("invalid handshake", + "err", err, + ) + return false + } + if m.GetVersion() != VersionNum { + t.log.Debugw("invalid handshake", + "version", m.GetVersion(), + ) + return false + } + if m.GetFrom() != fromAddr { + t.log.Debugw("invalid handshake", + "from", m.GetFrom(), + ) + return false + } + if m.GetTo() != t.LocalAddr().String() { + t.log.Debugw("invalid handshake", + "to", m.GetTo(), + ) + return false + } + if isExpired(m.GetTimestamp()) { + t.log.Debugw("invalid handshake", + "timestamp", time.Unix(m.GetTimestamp(), 0), + ) + } + + return true +} + +func (t *TransportTCP) validateHandshakeResponse(resData []byte, reqData []byte) bool { + m := new(pb.HandshakeResponse) + if err := proto.Unmarshal(resData, m); err != nil { + t.log.Debugw("invalid handshake", + "err", err, + ) + return false + } + if !bytes.Equal(m.GetReqHash(), server.PacketHash(reqData)) { + t.log.Debugw("invalid handshake", + "hash", m.GetReqHash(), + ) + return false + } + + return true +} diff --git a/packages/gossip/transport/proto/handshake.pb.go b/packages/gossip/transport/proto/handshake.pb.go new file mode 100644 index 0000000000..c7f3688734 --- /dev/null +++ b/packages/gossip/transport/proto/handshake.pb.go @@ -0,0 +1,152 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: transport/proto/handshake.proto + +package proto + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// 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 + +type HandshakeRequest struct { + // protocol version number + Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + // string form of the sender address (e.g. "192.0.2.1:25", "[2001:db8::1]:80") + From string `protobuf:"bytes,2,opt,name=from,proto3" json:"from,omitempty"` + // string form of the recipient address + To string `protobuf:"bytes,3,opt,name=to,proto3" json:"to,omitempty"` + // unix time + Timestamp int64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HandshakeRequest) Reset() { *m = HandshakeRequest{} } +func (m *HandshakeRequest) String() string { return proto.CompactTextString(m) } +func (*HandshakeRequest) ProtoMessage() {} +func (*HandshakeRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d7101ffe19b05443, []int{0} +} + +func (m *HandshakeRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HandshakeRequest.Unmarshal(m, b) +} +func (m *HandshakeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HandshakeRequest.Marshal(b, m, deterministic) +} +func (m *HandshakeRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_HandshakeRequest.Merge(m, src) +} +func (m *HandshakeRequest) XXX_Size() int { + return xxx_messageInfo_HandshakeRequest.Size(m) +} +func (m *HandshakeRequest) XXX_DiscardUnknown() { + xxx_messageInfo_HandshakeRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_HandshakeRequest proto.InternalMessageInfo + +func (m *HandshakeRequest) GetVersion() uint32 { + if m != nil { + return m.Version + } + return 0 +} + +func (m *HandshakeRequest) GetFrom() string { + if m != nil { + return m.From + } + return "" +} + +func (m *HandshakeRequest) GetTo() string { + if m != nil { + return m.To + } + return "" +} + +func (m *HandshakeRequest) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +type HandshakeResponse struct { + // hash of the ping packet + ReqHash []byte `protobuf:"bytes,1,opt,name=req_hash,json=reqHash,proto3" json:"req_hash,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *HandshakeResponse) Reset() { *m = HandshakeResponse{} } +func (m *HandshakeResponse) String() string { return proto.CompactTextString(m) } +func (*HandshakeResponse) ProtoMessage() {} +func (*HandshakeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_d7101ffe19b05443, []int{1} +} + +func (m *HandshakeResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_HandshakeResponse.Unmarshal(m, b) +} +func (m *HandshakeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_HandshakeResponse.Marshal(b, m, deterministic) +} +func (m *HandshakeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_HandshakeResponse.Merge(m, src) +} +func (m *HandshakeResponse) XXX_Size() int { + return xxx_messageInfo_HandshakeResponse.Size(m) +} +func (m *HandshakeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_HandshakeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_HandshakeResponse proto.InternalMessageInfo + +func (m *HandshakeResponse) GetReqHash() []byte { + if m != nil { + return m.ReqHash + } + return nil +} + +func init() { + proto.RegisterType((*HandshakeRequest)(nil), "proto.HandshakeRequest") + proto.RegisterType((*HandshakeResponse)(nil), "proto.HandshakeResponse") +} + +func init() { proto.RegisterFile("transport/proto/handshake.proto", fileDescriptor_d7101ffe19b05443) } + +var fileDescriptor_d7101ffe19b05443 = []byte{ + // 203 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x5c, 0x8f, 0x3f, 0x4b, 0x04, 0x31, + 0x10, 0xc5, 0xb9, 0x3f, 0x7a, 0xde, 0xa0, 0xa2, 0xa9, 0x22, 0x08, 0xca, 0x55, 0x82, 0xb8, 0x29, + 0xfc, 0x06, 0x56, 0x57, 0xa7, 0xb4, 0x91, 0xec, 0x3a, 0x6e, 0x82, 0x26, 0x93, 0xcd, 0x64, 0xfd, + 0xfc, 0x0e, 0x81, 0x45, 0xb1, 0x7a, 0xef, 0xf7, 0x0b, 0xe4, 0x25, 0x70, 0x57, 0x8b, 0x4b, 0x9c, + 0xa9, 0x54, 0x93, 0x0b, 0x55, 0x32, 0xde, 0xa5, 0x77, 0xf6, 0xee, 0x13, 0xbb, 0xc6, 0xea, 0xa4, + 0xc5, 0x21, 0xc1, 0xd5, 0x71, 0x39, 0xb1, 0x38, 0xcd, 0xc8, 0x55, 0x69, 0xd8, 0x7d, 0x63, 0xe1, + 0x40, 0x49, 0xaf, 0xee, 0x57, 0x0f, 0x17, 0x76, 0x41, 0xa5, 0x60, 0xfb, 0x51, 0x28, 0xea, 0xb5, + 0xe8, 0xbd, 0x6d, 0x5d, 0x5d, 0xc2, 0xba, 0x92, 0xde, 0x34, 0x23, 0x4d, 0xdd, 0xc2, 0xbe, 0x86, + 0x28, 0xf7, 0xb8, 0x98, 0xf5, 0x56, 0xf4, 0xc6, 0xfe, 0x8a, 0x43, 0x07, 0xd7, 0x7f, 0xf6, 0xe4, + 0x81, 0x89, 0x51, 0xdd, 0xc0, 0x59, 0xc1, 0xe9, 0xcd, 0x3b, 0xf6, 0x6d, 0xf1, 0xdc, 0xee, 0x84, + 0x8f, 0x82, 0x2f, 0x4f, 0xaf, 0x8f, 0x63, 0xa8, 0x7e, 0xee, 0xbb, 0x81, 0xa2, 0x19, 0x5c, 0x26, + 0x66, 0xfc, 0x42, 0x33, 0x4a, 0x86, 0x6c, 0xfe, 0xfd, 0xb2, 0x3f, 0x6d, 0xf1, 0xfc, 0x13, 0x00, + 0x00, 0xff, 0xff, 0x51, 0xe0, 0x08, 0xd0, 0xff, 0x00, 0x00, 0x00, +} diff --git a/packages/gossip/transport/proto/handshake.proto b/packages/gossip/transport/proto/handshake.proto new file mode 100644 index 0000000000..2f9c628169 --- /dev/null +++ b/packages/gossip/transport/proto/handshake.proto @@ -0,0 +1,21 @@ +syntax = "proto3"; + +option go_package = "github.com/capossele/gossip/transport/proto"; + +package proto; + +message HandshakeRequest { + // protocol version number + uint32 version = 1; + // string form of the sender address (e.g. "192.0.2.1:25", "[2001:db8::1]:80") + string from = 2; + // string form of the recipient address + string to = 3; + // unix time + int64 timestamp = 4; +} + +message HandshakeResponse { + // hash of the ping packet + bytes req_hash = 1; +} \ No newline at end of file diff --git a/packages/gossip/transport/transport.go b/packages/gossip/transport/transport.go new file mode 100644 index 0000000000..f9ae8101db --- /dev/null +++ b/packages/gossip/transport/transport.go @@ -0,0 +1,386 @@ +package transport + +import ( + "bytes" + "container/list" + "errors" + "net" + "sync" + "time" + + "github.com/golang/protobuf/proto" + "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/autopeering-sim/peer/service" + pb "github.com/iotaledger/autopeering-sim/server/proto" + "go.uber.org/zap" +) + +var ( + ErrTimeout = errors.New("accept timeout") + ErrClosed = errors.New("listener closed") + ErrInvalidHandshake = errors.New("invalid handshake") + ErrNoGossip = errors.New("peer does not have a gossip service") +) + +// connection timeouts +const ( + acceptTimeout = 500 * time.Millisecond + handshakeTimeout = 100 * time.Millisecond + connectionTimeout = acceptTimeout + handshakeTimeout +) + +type TransportTCP struct { + local *peer.Local + listener *net.TCPListener + log *zap.SugaredLogger + + addAcceptMatcher chan *acceptMatcher + acceptReceived chan accept + + closeOnce sync.Once + wg sync.WaitGroup + closing chan struct{} // if this channel gets closed all pending waits should terminate +} + +// connect contains the result of an incoming connection. +type connect struct { + c *Connection + err error +} + +type acceptMatcher struct { + peer *peer.Peer // connecting peer + deadline time.Time // deadline for the incoming call + connected chan connect // result of the connection is signaled here +} + +type accept struct { + fromID peer.ID // ID of the connecting peer + req []byte // raw data of the handshake request + conn net.Conn // the actual network connection +} + +func Listen(local *peer.Local, log *zap.SugaredLogger) (*TransportTCP, error) { + t := &TransportTCP{ + local: local, + log: log, + addAcceptMatcher: make(chan *acceptMatcher), + acceptReceived: make(chan accept), + closing: make(chan struct{}), + } + + gossipAddr := local.Services().Get(service.GossipKey) + if gossipAddr == nil { + return nil, ErrNoGossip + } + tcpAddr, err := net.ResolveTCPAddr(gossipAddr.Network(), gossipAddr.String()) + if err != nil { + return nil, err + } + listener, err := net.ListenTCP(gossipAddr.Network(), tcpAddr) + if err != nil { + return nil, err + } + t.listener = listener + + t.wg.Add(2) + go t.run() + go t.listenLoop() + + return t, nil +} + +// Close stops listening on the gossip address. +func (t *TransportTCP) Close() { + t.closeOnce.Do(func() { + close(t.closing) + if err := t.listener.Close(); err != nil { + t.log.Warnw("close error", "err", err) + } + t.wg.Wait() + }) +} + +// LocalAddr returns the listener's network address, +func (t *TransportTCP) LocalAddr() net.Addr { + return t.listener.Addr() +} + +// DialPeer establishes a gossip connection to the given peer. +// If the peer does not accept the connection or the handshake fails, an error is returned. +func (t *TransportTCP) DialPeer(p *peer.Peer) (*Connection, error) { + gossipAddr := p.Services().Get(service.GossipKey) + if gossipAddr == nil { + return nil, ErrNoGossip + } + + conn, err := net.DialTimeout(gossipAddr.Network(), gossipAddr.String(), acceptTimeout) + if err != nil { + return nil, err + } + + err = t.doHandshake(p.PublicKey(), gossipAddr.String(), conn) + if err != nil { + return nil, err + } + + t.log.Debugw("connected", "id", p.ID(), "addr", conn.RemoteAddr(), "direction", "out") + return newConnection(p, conn), nil +} + +// AcceptPeer awaits an incoming connection from the given peer. +// If the peer does not establish the connection or the handshake fails, an error is returned. +func (t *TransportTCP) AcceptPeer(p *peer.Peer) (*Connection, error) { + if p.Services().Get(service.GossipKey) == nil { + return nil, ErrNoGossip + } + // wait for the connection + connected := <-t.acceptPeer(p) + if connected.err != nil { + return nil, connected.err + } + t.log.Debugw("connected", "id", p.ID(), "addr", connected.c.conn.RemoteAddr(), "direction", "in") + return connected.c, nil +} + +func (t *TransportTCP) acceptPeer(p *peer.Peer) <-chan connect { + connected := make(chan connect, 1) + // add the matcher + select { + case t.addAcceptMatcher <- &acceptMatcher{peer: p, connected: connected}: + case <-t.closing: + connected <- connect{nil, ErrClosed} + } + return connected +} + +func (t *TransportTCP) closeConnection(c net.Conn) { + if err := c.Close(); err != nil { + t.log.Warnw("close error", "err", err) + } +} + +func (t *TransportTCP) run() { + defer t.wg.Done() + + var ( + mlist = list.New() + timeout = time.NewTimer(0) + ) + defer timeout.Stop() + + <-timeout.C // ignore first timeout + + for { + + // Set the timer so that it fires when the next accept expires + if el := mlist.Front(); el != nil { + // the first element always has the closest deadline + m := el.Value.(*acceptMatcher) + timeout.Reset(time.Until(m.deadline)) + } else { + timeout.Stop() + } + + select { + + // add a new matcher to the list + case m := <-t.addAcceptMatcher: + m.deadline = time.Now().Add(connectionTimeout) + mlist.PushBack(m) + + // on accept received, check all matchers for a fit + case a := <-t.acceptReceived: + matched := false + for el := mlist.Front(); el != nil; el = el.Next() { + m := el.Value.(*acceptMatcher) + if m.peer.ID() == a.fromID { + matched = true + mlist.Remove(el) + // finish the handshake + go t.matchAccept(m, a.req, a.conn) + } + } + // close the connection if not matched + if !matched { + t.log.Debugw("unexpected connection", "id", a.fromID, "addr", a.conn.RemoteAddr()) + t.closeConnection(a.conn) + } + + // on timeout, check for expired matchers + case <-timeout.C: + now := time.Now() + + // notify and remove any expired matchers + for el := mlist.Front(); el != nil; el = el.Next() { + m := el.Value.(*acceptMatcher) + if now.After(m.deadline) || now.Equal(m.deadline) { + m.connected <- connect{nil, ErrTimeout} + mlist.Remove(el) + } + } + + // on close, notify all the matchers + case <-t.closing: + for el := mlist.Front(); el != nil; el = el.Next() { + el.Value.(*acceptMatcher).connected <- connect{nil, ErrClosed} + } + return + + } + } +} + +func (t *TransportTCP) matchAccept(m *acceptMatcher, req []byte, conn net.Conn) { + t.wg.Add(1) + defer t.wg.Done() + + if err := t.writeHandshakeResponse(req, conn); err != nil { + t.log.Warnw("failed handshake", "addr", conn.RemoteAddr(), "err", err) + m.connected <- connect{nil, err} + t.closeConnection(conn) + return + } + m.connected <- connect{newConnection(m.peer, conn), nil} +} + +func (t *TransportTCP) listenLoop() { + defer t.wg.Done() + + for { + conn, err := t.listener.AcceptTCP() + if err, ok := err.(net.Error); ok && err.Temporary() { + t.log.Debugw("temporary read error", "err", err) + continue + } else if err != nil { + // return from the loop on all other errors + t.log.Warnw("read error", "err", err) + return + } + + key, req, err := t.readHandshakeRequest(conn) + if err != nil { + t.log.Warnw("failed handshake", "addr", conn.RemoteAddr(), "err", err) + t.closeConnection(conn) + continue + } + + select { + case t.acceptReceived <- accept{ + fromID: key.ID(), + req: req, + conn: conn, + }: + case <-t.closing: + t.closeConnection(conn) + return + } + } +} + +func (t *TransportTCP) doHandshake(key peer.PublicKey, remoteAddr string, conn net.Conn) error { + reqData, err := newHandshakeRequest(conn.LocalAddr().String(), remoteAddr) + if err != nil { + return err + } + + pkt := &pb.Packet{ + PublicKey: t.local.PublicKey(), + Signature: t.local.Sign(reqData), + Data: reqData, + } + b, err := proto.Marshal(pkt) + if err != nil { + return err + } + + if err := conn.SetWriteDeadline(time.Now().Add(handshakeTimeout)); err != nil { + return err + } + _, err = conn.Write(b) + if err != nil { + return err + } + + if err := conn.SetReadDeadline(time.Now().Add(handshakeTimeout)); err != nil { + return err + } + b = make([]byte, MaxPacketSize) + n, err := conn.Read(b) + if err != nil { + return err + } + + pkt = new(pb.Packet) + if err := proto.Unmarshal(b[:n], pkt); err != nil { + return err + } + + signer, err := peer.RecoverKeyFromSignedData(pkt) + if err != nil { + return err + } + if !bytes.Equal(key, signer) { + return errors.New("invalid key") + } + + if !t.validateHandshakeResponse(pkt.GetData(), reqData) { + return ErrInvalidHandshake + } + + return nil +} + +func (t *TransportTCP) readHandshakeRequest(conn net.Conn) (peer.PublicKey, []byte, error) { + if err := conn.SetReadDeadline(time.Now().Add(handshakeTimeout)); err != nil { + return nil, nil, err + } + b := make([]byte, MaxPacketSize) + n, err := conn.Read(b) + if err != nil { + return nil, nil, err + } + + pkt := new(pb.Packet) + if err := proto.Unmarshal(b[:n], pkt); err != nil { + return nil, nil, err + } + + key, err := peer.RecoverKeyFromSignedData(pkt) + if err != nil { + return nil, nil, err + } + + if !t.validateHandshakeRequest(pkt.GetData(), conn.RemoteAddr().String()) { + return nil, nil, ErrInvalidHandshake + } + + return key, pkt.GetData(), nil +} + +func (t *TransportTCP) writeHandshakeResponse(reqData []byte, conn net.Conn) error { + data, err := newHandshakeResponse(reqData) + if err != nil { + return err + } + + pkt := &pb.Packet{ + PublicKey: t.local.PublicKey(), + Signature: t.local.Sign(data), + Data: data, + } + b, err := proto.Marshal(pkt) + if err != nil { + return err + } + + if err := conn.SetWriteDeadline(time.Now().Add(handshakeTimeout)); err != nil { + return err + } + _, err = conn.Write(b) + if err != nil { + return err + } + + return nil +} diff --git a/packages/gossip/transport/transport_test.go b/packages/gossip/transport/transport_test.go new file mode 100644 index 0000000000..c0b670476d --- /dev/null +++ b/packages/gossip/transport/transport_test.go @@ -0,0 +1,197 @@ +package transport + +import ( + "log" + "net" + "sync" + "testing" + "time" + + "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/autopeering-sim/peer/service" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.uber.org/zap" +) + +const graceTime = 5 * time.Millisecond + +var logger *zap.SugaredLogger + +func init() { + l, err := zap.NewDevelopment() + if err != nil { + log.Fatalf("cannot initialize logger: %v", err) + } + logger = l.Sugar() +} + +func newTest(t require.TestingT, name string) (*TransportTCP, func()) { + l := logger.Named(name) + db := peer.NewMemoryDB(l.Named("db")) + local, err := peer.NewLocal("peering", name, db) + require.NoError(t, err) + + // enable TCP gossipping + require.NoError(t, local.UpdateService(service.GossipKey, "tcp", ":0")) + + trans, err := Listen(local, l) + require.NoError(t, err) + + // update the service with the actual address + require.NoError(t, local.UpdateService(service.GossipKey, trans.LocalAddr().Network(), trans.LocalAddr().String())) + + teardown := func() { + trans.Close() + db.Close() + } + return trans, teardown +} + +func getPeer(t *TransportTCP) *peer.Peer { + return &t.local.Peer +} + +func TestClose(t *testing.T) { + _, teardown := newTest(t, "A") + teardown() +} + +func TestUnansweredAccept(t *testing.T) { + transA, closeA := newTest(t, "A") + defer closeA() + + _, err := transA.AcceptPeer(getPeer(transA)) + assert.Error(t, err) +} + +func TestCloseWhileAccepting(t *testing.T) { + transA, closeA := newTest(t, "A") + + var wg sync.WaitGroup + wg.Add(1) + go func() { + defer wg.Done() + _, err := transA.AcceptPeer(getPeer(transA)) + assert.Error(t, err) + }() + time.Sleep(graceTime) + + closeA() + wg.Wait() +} + +func TestUnansweredDial(t *testing.T) { + transA, closeA := newTest(t, "A") + defer closeA() + + // create peer with invalid gossip address + services := getPeer(transA).Services().CreateRecord() + services.Update(service.GossipKey, "tcp", ":0") + unreachablePeer := peer.NewPeer(getPeer(transA).PublicKey(), services) + + _, err := transA.DialPeer(unreachablePeer) + assert.Error(t, err) +} + +func TestNoHandshakeResponse(t *testing.T) { + transA, closeA := newTest(t, "A") + defer closeA() + + // accept and read incoming connections + lis, err := net.Listen("tcp", ":0") + require.NoError(t, err) + go func() { + conn, err := lis.Accept() + require.NoError(t, err) + n, _ := conn.Read(make([]byte, MaxPacketSize)) + assert.NotZero(t, n) + _ = conn.Close() + _ = lis.Close() + }() + + // create peer for the listener + services := getPeer(transA).Services().CreateRecord() + services.Update(service.GossipKey, lis.Addr().Network(), lis.Addr().String()) + p := peer.NewPeer(getPeer(transA).PublicKey(), services) + + _, err = transA.DialPeer(p) + assert.Error(t, err) +} + +func TestNoHandshakeRequest(t *testing.T) { + transA, closeA := newTest(t, "A") + defer closeA() + + var wg sync.WaitGroup + wg.Add(1) + go func() { + defer wg.Done() + _, err := transA.AcceptPeer(getPeer(transA)) + assert.Error(t, err) + }() + time.Sleep(graceTime) + + conn, err := net.Dial(transA.LocalAddr().Network(), transA.LocalAddr().String()) + require.NoError(t, err) + time.Sleep(handshakeTimeout) + _ = conn.Close() + + wg.Wait() +} + +func TestConnect(t *testing.T) { + transA, closeA := newTest(t, "A") + defer closeA() + transB, closeB := newTest(t, "B") + defer closeB() + + var wg sync.WaitGroup + wg.Add(2) + + go func() { + defer wg.Done() + c, err := transA.AcceptPeer(getPeer(transB)) + assert.NoError(t, err) + if assert.NotNil(t, c) { + c.Close() + } + }() + time.Sleep(graceTime) + go func() { + defer wg.Done() + c, err := transB.DialPeer(getPeer(transA)) + assert.NoError(t, err) + if assert.NotNil(t, c) { + c.Close() + } + }() + + wg.Wait() +} + +func TestWrongConnect(t *testing.T) { + transA, closeA := newTest(t, "A") + defer closeA() + transB, closeB := newTest(t, "B") + defer closeB() + transC, closeC := newTest(t, "C") + defer closeC() + + var wg sync.WaitGroup + wg.Add(2) + + // a expects connection from B, but C is connecting + go func() { + defer wg.Done() + _, err := transA.AcceptPeer(getPeer(transB)) + assert.Error(t, err) + }() + go func() { + defer wg.Done() + _, err := transC.DialPeer(getPeer(transA)) + assert.Error(t, err) + }() + + wg.Wait() +} diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 3ebd4a0004..f406622fed 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -1,10 +1,8 @@ package autopeering import ( - "net" - "github.com/iotaledger/autopeering-sim/discover" - "github.com/iotaledger/autopeering-sim/selection" + "github.com/iotaledger/goshimmer/packages/gossip/neighbor" "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" @@ -28,26 +26,26 @@ func run(plugin *node.Plugin) { } func configureLogging(plugin *node.Plugin) { - gossip.Events.RemoveNeighbor.Attach(events.NewClosure(func(peer *gossip.Neighbor) { + gossip.Events.DropNeighbor.Attach(events.NewClosure(func(peer *neighbor.Neighbor) { Selection.DropPeer(peer.Peer) })) - selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) { - log.Debug("neighbor removed: " + ev.DroppedID.String()) - gossip.RemoveNeighbor(ev.DroppedID.String()) - })) - - selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { - log.Debug("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - address, port, _ := net.SplitHostPort(ev.Services["gossip"].Address) - gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port)) - })) - - selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { - log.Debug("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - address, port, _ := net.SplitHostPort(ev.Services["gossip"].Address) - gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port)) - })) + // selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) { + // log.Debug("neighbor removed: " + ev.DroppedID.String()) + // gossip.RemoveNeighbor(ev.DroppedID.String()) + // })) + + // selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { + // log.Debug("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) + // address, port, _ := net.SplitHostPort(ev.Services["gossip"].Address) + // gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port)) + // })) + + // selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { + // log.Debug("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) + // address, port, _ := net.SplitHostPort(ev.Services["gossip"].Address) + // gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port)) + // })) discover.Events.PeerDiscovered.Attach(events.NewClosure(func(ev *discover.DiscoveredEvent) { log.Info("new peer discovered: " + ev.Peer.Address() + " / " + ev.Peer.ID().String()) diff --git a/plugins/gossip-on-solidification/plugin.go b/plugins/gossip-on-solidification/plugin.go deleted file mode 100644 index 42b09256ba..0000000000 --- a/plugins/gossip-on-solidification/plugin.go +++ /dev/null @@ -1,15 +0,0 @@ -package gossip_on_solidification - -import ( - "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/plugins/gossip" - "github.com/iotaledger/goshimmer/plugins/tangle" - "github.com/iotaledger/hive.go/events" - "github.com/iotaledger/hive.go/node" -) - -var PLUGIN = node.NewPlugin("Gossip On Solidification", node.Enabled, func(plugin *node.Plugin) { - tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { - gossip.SendTransaction(tx.MetaTransaction) - })) -}) diff --git a/plugins/gossip/errors.go b/plugins/gossip/errors.go deleted file mode 100644 index 8da04cfa7c..0000000000 --- a/plugins/gossip/errors.go +++ /dev/null @@ -1,12 +0,0 @@ -package gossip - -import "github.com/iotaledger/goshimmer/packages/errors" - -var ( - ErrConnectionFailed = errors.Wrap(errors.New("connection error"), "could not connect to neighbor") - ErrInvalidAuthenticationMessage = errors.Wrap(errors.New("protocol error"), "invalid authentication message") - ErrInvalidIdentity = errors.Wrap(errors.New("protocol error"), "invalid identity message") - ErrInvalidStateTransition = errors.New("protocol error: invalid state transition message") - ErrSendFailed = errors.Wrap(errors.New("protocol error"), "failed to send message") - ErrInvalidSendParam = errors.New("invalid parameter passed to send") -) diff --git a/plugins/gossip/events.go b/plugins/gossip/events.go deleted file mode 100644 index 4bcb484a1b..0000000000 --- a/plugins/gossip/events.go +++ /dev/null @@ -1,97 +0,0 @@ -package gossip - -import ( - "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/identity" - "github.com/iotaledger/goshimmer/packages/model/meta_transaction" - "github.com/iotaledger/goshimmer/packages/network" - "github.com/iotaledger/hive.go/events" -) - -var Events = pluginEvents{ - // neighbor events - AddNeighbor: events.NewEvent(neighborCaller), - UpdateNeighbor: events.NewEvent(neighborCaller), - RemoveNeighbor: events.NewEvent(neighborCaller), - - // low level network events - IncomingConnection: events.NewEvent(connectionCaller), - - // high level protocol events - DropNeighbor: events.NewEvent(neighborCaller), - SendTransaction: events.NewEvent(transactionCaller), - SendTransactionRequest: events.NewEvent(transactionCaller), // TODO - ReceiveTransaction: events.NewEvent(transactionCaller), - ReceiveTransactionRequest: events.NewEvent(transactionCaller), // TODO - ProtocolError: events.NewEvent(transactionCaller), // TODO - - // generic events - Error: events.NewEvent(errorCaller), -} - -type pluginEvents struct { - // neighbor events - AddNeighbor *events.Event - UpdateNeighbor *events.Event - RemoveNeighbor *events.Event - - // low level network events - IncomingConnection *events.Event - - // high level protocol events - DropNeighbor *events.Event - SendTransaction *events.Event - SendTransactionRequest *events.Event - ReceiveTransaction *events.Event - ReceiveTransactionRequest *events.Event - ProtocolError *events.Event - - // generic events - Error *events.Event -} - -type protocolEvents struct { - ReceiveVersion *events.Event - ReceiveIdentification *events.Event - ReceiveConnectionAccepted *events.Event - ReceiveConnectionRejected *events.Event - ReceiveDropConnection *events.Event - ReceiveTransactionData *events.Event - ReceiveRequestData *events.Event - HandshakeCompleted *events.Event - Error *events.Event -} - -type neighborEvents struct { - ProtocolConnectionEstablished *events.Event -} - -func intCaller(handler interface{}, params ...interface{}) { handler.(func(int))(params[0].(int)) } - -func identityCaller(handler interface{}, params ...interface{}) { - handler.(func(*identity.Identity))(params[0].(*identity.Identity)) -} - -func connectionCaller(handler interface{}, params ...interface{}) { - handler.(func(*network.ManagedConnection))(params[0].(*network.ManagedConnection)) -} - -func protocolCaller(handler interface{}, params ...interface{}) { - handler.(func(*protocol))(params[0].(*protocol)) -} - -func neighborCaller(handler interface{}, params ...interface{}) { - handler.(func(*Neighbor))(params[0].(*Neighbor)) -} - -func errorCaller(handler interface{}, params ...interface{}) { - handler.(func(errors.IdentifiableError))(params[0].(errors.IdentifiableError)) -} - -func dataCaller(handler interface{}, params ...interface{}) { - handler.(func([]byte))(params[0].([]byte)) -} - -func transactionCaller(handler interface{}, params ...interface{}) { - handler.(func(*meta_transaction.MetaTransaction))(params[0].(*meta_transaction.MetaTransaction)) -} diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go new file mode 100644 index 0000000000..0ca491a836 --- /dev/null +++ b/plugins/gossip/gossip.go @@ -0,0 +1,86 @@ +package gossip + +import ( + "github.com/iotaledger/goshimmer/packages/gossip/transport" + "github.com/iotaledger/goshimmer/packages/model/meta_transaction" + gp "github.com/iotaledger/goshimmer/packages/gossip" + pb "github.com/iotaledger/goshimmer/packages/gossip/proto" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/autopeering-sim/selection" + "github.com/iotaledger/goshimmer/plugins/tangle" + "go.uber.org/zap" + "github.com/golang/protobuf/proto" + "github.com/iotaledger/hive.go/events" +) + +var ( + zLogger *zap.SugaredLogger + mgr *gp.Manager + SendTransaction = mgr.Send + RequestTransaction = mgr.RequestTransaction + AddInbound = mgr.AddInbound + AddOutbound = mgr.AddOutbound + DropNeighbor = mgr.DropNeighbor +) + +func init() { + l, err := zap.NewDevelopment() + if err != nil { + log.Fatalf("cannot initialize logger: %v", err) + } + zLogger = l.Sugar() +} + +func getTransaction(h []byte) ([]byte, error) { + tx := &pb.TransactionRequest{ + Hash: []byte("testTx"), + } + b, _ := proto.Marshal(tx) + return b, nil +} + +func configureGossip() { + defer func() { _ = zLogger.Sync() }() // ignore the returned error + + trans, err := transport.Listen(local.INSTANCE, zLogger) + if err != nil { + // TODO: handle error + } + + mgr = gp.NewManager(trans, zLogger, getTransaction) +} + +func configureEvents() { + + selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) { + log.Debug("neighbor removed: " + ev.DroppedID.String()) + DropNeighbor(ev.DroppedID) + })) + + selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { + log.Debug("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) + AddInbound(ev.Peer) + })) + + selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { + log.Debug("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) + AddOutbound(ev.Peer) + })) + + // mgr.Events.NewTransaction.Attach(events.NewClosure(func(ev *gp.NewTransactionEvent) { + // tx := ev.Body + // metaTx := meta_transaction.FromBytes(tx) + // Events.NewTransaction.Trigger(metaTx) + // })) + + tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *meta_transaction.MetaTransaction) { + t := &pb.Transaction{ + Body: tx.GetBytes(), + } + b, err := proto.Marshal(t) + if err != nil { + return + } + SendTransaction(b) + })) +} diff --git a/plugins/gossip/neighbors.go b/plugins/gossip/neighbors.go deleted file mode 100644 index 2acecf294e..0000000000 --- a/plugins/gossip/neighbors.go +++ /dev/null @@ -1,286 +0,0 @@ -package gossip - -import ( - "math" - "net" - "sync" - "time" - - "github.com/iotaledger/autopeering-sim/peer" - "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/identity" - "github.com/iotaledger/goshimmer/packages/network" - "github.com/iotaledger/goshimmer/plugins/autopeering/local" - "github.com/iotaledger/hive.go/daemon" - "github.com/iotaledger/hive.go/events" - "github.com/iotaledger/hive.go/node" -) - -func configureNeighbors(plugin *node.Plugin) { - Events.AddNeighbor.Attach(events.NewClosure(func(neighbor *Neighbor) { - log.Info("new neighbor added " + neighbor.GetIdentity().StringIdentifier + "@" + neighbor.GetAddress().String() + ":" + neighbor.GetPort()) - //plugin.LogSuccess("new neighbor added " + hex.EncodeToString(neighbor.Peer.ID().Bytes()) + "@" + neighbor.GetAddress().String() + ":" + neighbor.GetPort()) - })) - - Events.UpdateNeighbor.Attach(events.NewClosure(func(neighbor *Neighbor) { - log.Info("existing neighbor updated " + neighbor.GetIdentity().StringIdentifier + "@" + neighbor.GetAddress().String() + ":" + neighbor.GetPort()) - })) - - Events.RemoveNeighbor.Attach(events.NewClosure(func(neighbor *Neighbor) { - log.Info("existing neighbor removed " + neighbor.GetIdentity().StringIdentifier + "@" + neighbor.GetAddress().String() + ":" + neighbor.GetPort()) - })) -} - -func runNeighbors(plugin *node.Plugin) { - log.Info("Starting Neighbor Connection Manager ...") - - neighborLock.RLock() - for _, neighbor := range neighbors.GetMap() { - manageConnection(plugin, neighbor) - } - neighborLock.RUnlock() - - Events.AddNeighbor.Attach(events.NewClosure(func(neighbor *Neighbor) { - manageConnection(plugin, neighbor) - })) - - log.Info("Starting Neighbor Connection Manager ... done") -} - -func manageConnection(plugin *node.Plugin, neighbor *Neighbor) { - daemon.BackgroundWorker("Connection Manager ("+neighbor.GetIdentity().StringIdentifier+")", func() { - failedConnectionAttempts := 0 - - for _, exists := neighbors.Load(neighbor.GetIdentity().StringIdentifier); exists && failedConnectionAttempts < CONNECTION_MAX_ATTEMPTS; { - protocol, dialed, err := neighbor.Connect() - if err != nil { - failedConnectionAttempts++ - - log.Errorf("connection attempt [%d / %d] %s", failedConnectionAttempts, CONNECTION_MAX_ATTEMPTS, err.Error()) - - if failedConnectionAttempts <= CONNECTION_MAX_ATTEMPTS { - select { - case <-daemon.ShutdownSignal: - return - - case <-time.After(time.Duration(int(math.Pow(2, float64(failedConnectionAttempts-1)))) * CONNECTION_BASE_TIMEOUT): - continue - } - } - } - - failedConnectionAttempts = 0 - - disconnectSignal := make(chan int, 1) - protocol.Conn.Events.Close.Attach(events.NewClosure(func() { - close(disconnectSignal) - })) - - if dialed { - go protocol.Init() - } - - // wait for shutdown or - select { - case <-daemon.ShutdownSignal: - return - - case <-disconnectSignal: - continue - } - } - - RemoveNeighbor(neighbor.GetIdentity().StringIdentifier) - }) -} - -type Neighbor struct { - identity *identity.Identity - identityMutex sync.RWMutex - address net.IP - addressMutex sync.RWMutex - port string - portMutex sync.RWMutex - initiatedProtocol *protocol - initiatedProtocolMutex sync.RWMutex - acceptedProtocol *protocol - Events neighborEvents - acceptedProtocolMutex sync.RWMutex - Peer *peer.Peer -} - -func NewNeighbor(peer *peer.Peer, address, port string) *Neighbor { - return &Neighbor{ - identity: identity.NewPublicIdentity(peer.ToProto().GetPublicKey()), - address: net.ParseIP(address), - port: port, - Peer: peer, - Events: neighborEvents{ - ProtocolConnectionEstablished: events.NewEvent(protocolCaller), - }, - } -} - -func (neighbor *Neighbor) GetIdentity() (result *identity.Identity) { - neighbor.identityMutex.RLock() - result = neighbor.identity - neighbor.identityMutex.RUnlock() - - return result -} - -func (neighbor *Neighbor) SetIdentity(identity *identity.Identity) { - neighbor.identityMutex.Lock() - neighbor.identity = identity - neighbor.identityMutex.Unlock() -} - -func (neighbor *Neighbor) GetAddress() (result net.IP) { - neighbor.addressMutex.RLock() - result = neighbor.address - neighbor.addressMutex.RUnlock() - - return result -} - -func (neighbor *Neighbor) SetAddress(address net.IP) { - neighbor.addressMutex.Lock() - neighbor.address = address - neighbor.addressMutex.Unlock() -} - -func (neighbor *Neighbor) GetPort() (result string) { - neighbor.portMutex.RLock() - result = neighbor.port - neighbor.portMutex.RUnlock() - - return result -} - -func (neighbor *Neighbor) SetPort(port string) { - neighbor.portMutex.Lock() - neighbor.port = port - neighbor.portMutex.Unlock() -} - -func (neighbor *Neighbor) GetInitiatedProtocol() (result *protocol) { - neighbor.initiatedProtocolMutex.RLock() - result = neighbor.initiatedProtocol - neighbor.initiatedProtocolMutex.RUnlock() - - return result -} - -func (neighbor *Neighbor) SetInitiatedProtocol(p *protocol) { - neighbor.initiatedProtocolMutex.Lock() - neighbor.initiatedProtocol = p - neighbor.initiatedProtocolMutex.Unlock() -} - -func (neighbor *Neighbor) GetAcceptedProtocol() (result *protocol) { - neighbor.acceptedProtocolMutex.RLock() - result = neighbor.acceptedProtocol - neighbor.acceptedProtocolMutex.RUnlock() - - return result -} - -func (neighbor *Neighbor) SetAcceptedProtocol(p *protocol) { - neighbor.acceptedProtocolMutex.Lock() - neighbor.acceptedProtocol = p - neighbor.acceptedProtocolMutex.Unlock() -} - -func UnmarshalPeer(data []byte) (*Neighbor, error) { - return &Neighbor{}, nil -} - -func (neighbor *Neighbor) Connect() (*protocol, bool, errors.IdentifiableError) { - // return existing connections first - if neighbor.GetInitiatedProtocol() != nil { - return neighbor.GetInitiatedProtocol(), false, nil - } - - // if we already have an accepted connection -> use it instead - if neighbor.GetAcceptedProtocol() != nil { - return neighbor.GetAcceptedProtocol(), false, nil - } - - // otherwise try to dial - conn, err := net.Dial("tcp", neighbor.GetAddress().String()+":"+neighbor.GetPort()) - if err != nil { - return nil, false, ErrConnectionFailed.Derive(err, "error when connecting to neighbor "+ - neighbor.GetIdentity().StringIdentifier+"@"+neighbor.GetAddress().String()+":"+neighbor.GetPort()) - } - - neighbor.SetInitiatedProtocol(newProtocol(network.NewManagedConnection(conn))) - - neighbor.GetInitiatedProtocol().Conn.Events.Close.Attach(events.NewClosure(func() { - neighbor.SetInitiatedProtocol(nil) - })) - - // drop the "secondary" connection upon successful handshake - neighbor.GetInitiatedProtocol().Events.HandshakeCompleted.Attach(events.NewClosure(func() { - if local.INSTANCE.ID().String() <= neighbor.Peer.ID().String() { - var acceptedProtocolConn *network.ManagedConnection - if neighbor.GetAcceptedProtocol() != nil { - acceptedProtocolConn = neighbor.GetAcceptedProtocol().Conn - } - - if acceptedProtocolConn != nil { - _ = acceptedProtocolConn.Close() - } - } - - neighbor.Events.ProtocolConnectionEstablished.Trigger(neighbor.GetInitiatedProtocol()) - })) - - return neighbor.GetInitiatedProtocol(), true, nil -} - -func (neighbor *Neighbor) Marshal() []byte { - return nil -} - -func (neighbor *Neighbor) Equals(other *Neighbor) bool { - return neighbor.GetIdentity().StringIdentifier == other.GetIdentity().StringIdentifier && - neighbor.GetPort() == other.GetPort() && neighbor.GetAddress().String() == other.GetAddress().String() -} - -func AddNeighbor(newNeighbor *Neighbor) { - if neighbor, exists := neighbors.Load(newNeighbor.GetIdentity().StringIdentifier); !exists { - neighbors.Store(newNeighbor.GetIdentity().StringIdentifier, newNeighbor) - Events.AddNeighbor.Trigger(newNeighbor) - } else { - if !neighbor.Equals(newNeighbor) { - neighbor.SetIdentity(newNeighbor.GetIdentity()) - neighbor.SetPort(newNeighbor.GetPort()) - neighbor.SetAddress(newNeighbor.GetAddress()) - - Events.UpdateNeighbor.Trigger(neighbor) - } - } -} - -func RemoveNeighbor(identifier string) { - if neighbor, exists := neighbors.Delete(identifier); exists { - Events.RemoveNeighbor.Trigger(neighbor) - } -} - -func GetNeighbor(identifier string) (*Neighbor, bool) { - return neighbors.Load(identifier) -} - -func GetNeighbors() map[string]*Neighbor { - return neighbors.GetMap() -} - -const ( - CONNECTION_MAX_ATTEMPTS = 5 - CONNECTION_BASE_TIMEOUT = 10 * time.Second -) - -var neighbors = NewNeighborMap() - -var neighborLock sync.RWMutex diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index c3d7ffef9f..2e6a902f91 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -3,19 +3,25 @@ package gossip import ( "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/daemon" + "github.com/iotaledger/hive.go/events" ) var PLUGIN = node.NewPlugin("Gossip", node.Enabled, configure, run) var log = logger.NewLogger("Gossip") +var ( + debugLevel = "debug" + close = make(chan struct{}, 1) +) + func configure(plugin *node.Plugin) { - configureNeighbors(plugin) - configureServer(plugin) - configureSendQueue(plugin) + daemon.Events.Shutdown.Attach(events.NewClosure(func() { + close <- struct{}{} + })) + configureGossip() + configureEvents() } func run(plugin *node.Plugin) { - runNeighbors(plugin) - runServer(plugin) - runSendQueue(plugin) } diff --git a/plugins/gossip/protocol.go b/plugins/gossip/protocol.go deleted file mode 100644 index 54c891714b..0000000000 --- a/plugins/gossip/protocol.go +++ /dev/null @@ -1,199 +0,0 @@ -package gossip - -import ( - "strconv" - "sync" - - "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/network" - "github.com/iotaledger/hive.go/events" -) - -// region constants and variables ////////////////////////////////////////////////////////////////////////////////////// - -var DEFAULT_PROTOCOL = protocolDefinition{ - version: VERSION_1, - initializer: protocolV1, -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// region protocol ///////////////////////////////////////////////////////////////////////////////////////////////////// - -type protocol struct { - Conn *network.ManagedConnection - Neighbor *Neighbor - Version byte - sendHandshakeCompleted bool - receiveHandshakeCompleted bool - SendState protocolState - ReceivingState protocolState - Events protocolEvents - sendMutex sync.Mutex - handshakeMutex sync.Mutex -} - -func newProtocol(conn *network.ManagedConnection) *protocol { - protocol := &protocol{ - Conn: conn, - Events: protocolEvents{ - ReceiveVersion: events.NewEvent(intCaller), - ReceiveIdentification: events.NewEvent(identityCaller), - ReceiveConnectionAccepted: events.NewEvent(events.CallbackCaller), - ReceiveConnectionRejected: events.NewEvent(events.CallbackCaller), - ReceiveTransactionData: events.NewEvent(dataCaller), - HandshakeCompleted: events.NewEvent(events.CallbackCaller), - Error: events.NewEvent(errorCaller), - }, - sendHandshakeCompleted: false, - receiveHandshakeCompleted: false, - } - - protocol.SendState = &versionState{protocol: protocol} - protocol.ReceivingState = &versionState{protocol: protocol} - - return protocol -} - -func (protocol *protocol) Init() { - // setup event handlers - onReceiveData := events.NewClosure(protocol.Receive) - onConnectionAccepted := events.NewClosure(func() { - protocol.handshakeMutex.Lock() - defer protocol.handshakeMutex.Unlock() - - protocol.receiveHandshakeCompleted = true - if protocol.sendHandshakeCompleted { - protocol.Events.HandshakeCompleted.Trigger() - } - }) - var onClose *events.Closure - onClose = events.NewClosure(func() { - protocol.Conn.Events.ReceiveData.Detach(onReceiveData) - protocol.Conn.Events.Close.Detach(onClose) - protocol.Events.ReceiveConnectionAccepted.Detach(onConnectionAccepted) - }) - - // region register event handlers - protocol.Conn.Events.ReceiveData.Attach(onReceiveData) - protocol.Conn.Events.Close.Attach(onClose) - protocol.Events.ReceiveConnectionAccepted.Attach(onConnectionAccepted) - - // send protocol version - if err := protocol.Send(DEFAULT_PROTOCOL.version); err != nil { - return - } - - // initialize default protocol - if err := DEFAULT_PROTOCOL.initializer(protocol); err != nil { - protocol.SendState = nil - - _ = protocol.Conn.Close() - - protocol.Events.Error.Trigger(err) - - return - } - - // start reading from the connection - _, _ = protocol.Conn.Read(make([]byte, 1000)) -} - -func (protocol *protocol) Receive(data []byte) { - offset := 0 - length := len(data) - for offset < length && protocol.ReceivingState != nil { - if readBytes, err := protocol.ReceivingState.Receive(data, offset, length); err != nil { - Events.Error.Trigger(err) - - _ = protocol.Conn.Close() - - return - } else { - offset += readBytes - } - } -} - -func (protocol *protocol) Send(data interface{}) errors.IdentifiableError { - protocol.sendMutex.Lock() - defer protocol.sendMutex.Unlock() - - return protocol.send(data) -} - -func (protocol *protocol) send(data interface{}) errors.IdentifiableError { - if protocol.SendState != nil { - if err := protocol.SendState.Send(data); err != nil { - protocol.SendState = nil - - _ = protocol.Conn.Close() - - protocol.Events.Error.Trigger(err) - - return err - } - } - - return nil -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// region versionState ///////////////////////////////////////////////////////////////////////////////////////////////// - -type versionState struct { - protocol *protocol -} - -func (state *versionState) Receive(data []byte, offset int, length int) (int, errors.IdentifiableError) { - switch data[offset] { - case 1: - protocol := state.protocol - - protocol.Version = 1 - protocol.Events.ReceiveVersion.Trigger(1) - - protocol.ReceivingState = newIndentificationStateV1(protocol) - - return 1, nil - - default: - return 1, ErrInvalidStateTransition.Derive("invalid version state transition (" + strconv.Itoa(int(data[offset])) + ")") - } -} - -func (state *versionState) Send(param interface{}) errors.IdentifiableError { - if version, ok := param.(byte); ok { - switch version { - case VERSION_1: - protocol := state.protocol - - if _, err := protocol.Conn.Write([]byte{version}); err != nil { - return ErrSendFailed.Derive(err, "failed to send version byte") - } - - protocol.SendState = newIndentificationStateV1(protocol) - - return nil - } - } - - return ErrInvalidSendParam.Derive("passed in parameter is not a valid version byte") -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// region types and interfaces ///////////////////////////////////////////////////////////////////////////////////////// - -type protocolState interface { - Send(param interface{}) errors.IdentifiableError - Receive(data []byte, offset int, length int) (int, errors.IdentifiableError) -} - -type protocolDefinition struct { - version byte - initializer func(*protocol) errors.IdentifiableError -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/gossip/protocol_v1.go b/plugins/gossip/protocol_v1.go deleted file mode 100644 index 268ec8dc24..0000000000 --- a/plugins/gossip/protocol_v1.go +++ /dev/null @@ -1,383 +0,0 @@ -package gossip - -import ( - "strconv" - - "github.com/iotaledger/goshimmer/packages/byteutils" - "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/identity" - "github.com/iotaledger/goshimmer/packages/model/meta_transaction" - "github.com/iotaledger/goshimmer/plugins/autopeering/local" - "github.com/iotaledger/hive.go/events" - "github.com/iotaledger/iota.go/consts" -) - -// region protocolV1 /////////////////////////////////////////////////////////////////////////////////////////////////// - -func protocolV1(protocol *protocol) errors.IdentifiableError { - if err := protocol.Send(local.INSTANCE.ID().Bytes()); err != nil { - return err - } - - onReceiveIdentification := events.NewClosure(func(identity *identity.Identity) { - if protocol.Neighbor == nil { - if err := protocol.Send(CONNECTION_REJECT); err != nil { - return - } - } else { - if err := protocol.Send(CONNECTION_ACCEPT); err != nil { - return - } - - protocol.handshakeMutex.Lock() - defer protocol.handshakeMutex.Unlock() - - protocol.sendHandshakeCompleted = true - if protocol.receiveHandshakeCompleted { - protocol.Events.HandshakeCompleted.Trigger() - } - } - }) - - protocol.Events.ReceiveIdentification.Attach(onReceiveIdentification) - - return nil -} - -func sendTransactionV1(protocol *protocol, tx *meta_transaction.MetaTransaction) { - if _, ok := protocol.SendState.(*dispatchStateV1); ok { - protocol.sendMutex.Lock() - defer protocol.sendMutex.Unlock() - - if err := protocol.send(DISPATCH_TRANSACTION); err != nil { - return - } - if err := protocol.send(tx); err != nil { - return - } - } -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// region indentificationStateV1 /////////////////////////////////////////////////////////////////////////////////////// - -type indentificationStateV1 struct { - protocol *protocol - buffer []byte - offset int -} - -func newIndentificationStateV1(protocol *protocol) *indentificationStateV1 { - return &indentificationStateV1{ - protocol: protocol, - buffer: make([]byte, MARSHALED_IDENTITY_TOTAL_SIZE), - offset: 0, - } -} - -func (state *indentificationStateV1) Receive(data []byte, offset int, length int) (int, errors.IdentifiableError) { - bytesRead := byteutils.ReadAvailableBytesToBuffer(state.buffer, state.offset, data, offset, length) - - state.offset += bytesRead - if state.offset == MARSHALED_IDENTITY_TOTAL_SIZE { - receivedIdentity, err := identity.FromSignedData(state.buffer) - if err != nil { - return bytesRead, ErrInvalidAuthenticationMessage.Derive(err, "invalid authentication message") - } - protocol := state.protocol - - if neighbor, exists := GetNeighbor(receivedIdentity.StringIdentifier); exists { - protocol.Neighbor = neighbor - } else { - protocol.Neighbor = nil - } - - protocol.Events.ReceiveIdentification.Trigger(receivedIdentity) - - // switch to new state - protocol.ReceivingState = newacceptanceStateV1(protocol) - state.offset = 0 - } - - return bytesRead, nil -} - -func (state *indentificationStateV1) Send(param interface{}) errors.IdentifiableError { - id, ok := param.(*identity.Identity) - if !ok { - return ErrInvalidSendParam.Derive("parameter is not a valid identity") - } - - msg := id.Identifier.Bytes() - data := id.AddSignature(msg) - - protocol := state.protocol - if _, err := protocol.Conn.Write(data); err != nil { - return ErrSendFailed.Derive(err, "failed to send identification") - } - - // switch to new state - protocol.SendState = newacceptanceStateV1(protocol) - - return nil -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// region acceptanceStateV1 //////////////////////////////////////////////////////////////////////////////////////////// - -type acceptanceStateV1 struct { - protocol *protocol -} - -func newacceptanceStateV1(protocol *protocol) *acceptanceStateV1 { - return &acceptanceStateV1{protocol: protocol} -} - -func (state *acceptanceStateV1) Receive(data []byte, offset int, length int) (int, errors.IdentifiableError) { - protocol := state.protocol - - switch data[offset] { - case 0: - protocol.Events.ReceiveConnectionRejected.Trigger() - - _ = protocol.Conn.Close() - - protocol.ReceivingState = nil - - case 1: - protocol.Events.ReceiveConnectionAccepted.Trigger() - - protocol.ReceivingState = newDispatchStateV1(protocol) - - default: - return 1, ErrInvalidStateTransition.Derive("invalid acceptance state transition (" + strconv.Itoa(int(data[offset])) + ")") - } - - return 1, nil -} - -func (state *acceptanceStateV1) Send(param interface{}) errors.IdentifiableError { - if responseType, ok := param.(byte); ok { - switch responseType { - case CONNECTION_REJECT: - protocol := state.protocol - - if _, err := protocol.Conn.Write([]byte{CONNECTION_REJECT}); err != nil { - return ErrSendFailed.Derive(err, "failed to send reject message") - } - - _ = protocol.Conn.Close() - - protocol.SendState = nil - - return nil - - case CONNECTION_ACCEPT: - protocol := state.protocol - - if _, err := protocol.Conn.Write([]byte{CONNECTION_ACCEPT}); err != nil { - return ErrSendFailed.Derive(err, "failed to send accept message") - } - - protocol.SendState = newDispatchStateV1(protocol) - - return nil - } - } - - return ErrInvalidSendParam.Derive("passed in parameter is not a valid acceptance byte") -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// region dispatchStateV1 ////////////////////////////////////////////////////////////////////////////////////////////// - -type dispatchStateV1 struct { - protocol *protocol -} - -func newDispatchStateV1(protocol *protocol) *dispatchStateV1 { - return &dispatchStateV1{ - protocol: protocol, - } -} - -func (state *dispatchStateV1) Receive(data []byte, offset int, length int) (int, errors.IdentifiableError) { - switch data[0] { - case DISPATCH_DROP: - protocol := state.protocol - - protocol.Events.ReceiveConnectionRejected.Trigger() - - _ = protocol.Conn.Close() - - protocol.ReceivingState = nil - - case DISPATCH_TRANSACTION: - protocol := state.protocol - - protocol.ReceivingState = newTransactionStateV1(protocol) - - case DISPATCH_REQUEST: - protocol := state.protocol - - protocol.ReceivingState = newRequestStateV1(protocol) - - default: - return 1, ErrInvalidStateTransition.Derive("invalid dispatch state transition (" + strconv.Itoa(int(data[offset])) + ")") - } - - return 1, nil -} - -func (state *dispatchStateV1) Send(param interface{}) errors.IdentifiableError { - if dispatchByte, ok := param.(byte); ok { - switch dispatchByte { - case DISPATCH_DROP: - protocol := state.protocol - - if _, err := protocol.Conn.Write([]byte{DISPATCH_DROP}); err != nil { - return ErrSendFailed.Derive(err, "failed to send drop message") - } - - _ = protocol.Conn.Close() - - protocol.SendState = nil - - return nil - - case DISPATCH_TRANSACTION: - protocol := state.protocol - - if _, err := protocol.Conn.Write([]byte{DISPATCH_TRANSACTION}); err != nil { - return ErrSendFailed.Derive(err, "failed to send transaction dispatch byte") - } - - protocol.SendState = newTransactionStateV1(protocol) - - return nil - - case DISPATCH_REQUEST: - protocol := state.protocol - - if _, err := protocol.Conn.Write([]byte{DISPATCH_REQUEST}); err != nil { - return ErrSendFailed.Derive(err, "failed to send request dispatch byte") - } - - protocol.SendState = newTransactionStateV1(protocol) - - return nil - } - } - - return ErrInvalidSendParam.Derive("passed in parameter is not a valid dispatch byte") -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// region transactionStateV1 /////////////////////////////////////////////////////////////////////////////////////////// - -type transactionStateV1 struct { - protocol *protocol - buffer []byte - offset int -} - -func newTransactionStateV1(protocol *protocol) *transactionStateV1 { - return &transactionStateV1{ - protocol: protocol, - buffer: make([]byte, meta_transaction.MARSHALED_TOTAL_SIZE/consts.NumberOfTritsInAByte), - offset: 0, - } -} - -func (state *transactionStateV1) Receive(data []byte, offset int, length int) (int, errors.IdentifiableError) { - bytesRead := byteutils.ReadAvailableBytesToBuffer(state.buffer, state.offset, data, offset, length) - - state.offset += bytesRead - if state.offset == meta_transaction.MARSHALED_TOTAL_SIZE/consts.NumberOfTritsInAByte { - protocol := state.protocol - - transactionData := make([]byte, meta_transaction.MARSHALED_TOTAL_SIZE/consts.NumberOfTritsInAByte) - copy(transactionData, state.buffer) - - protocol.Events.ReceiveTransactionData.Trigger(transactionData) - - go ProcessReceivedTransactionData(transactionData) - - protocol.ReceivingState = newDispatchStateV1(protocol) - state.offset = 0 - } - - return bytesRead, nil -} - -func (state *transactionStateV1) Send(param interface{}) errors.IdentifiableError { - if tx, ok := param.(*meta_transaction.MetaTransaction); ok { - protocol := state.protocol - - if _, err := protocol.Conn.Write(tx.GetBytes()); err != nil { - return ErrSendFailed.Derive(err, "failed to send transaction") - } - - protocol.SendState = newDispatchStateV1(protocol) - - return nil - } - - return ErrInvalidSendParam.Derive("passed in parameter is not a valid transaction") -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// region requestStateV1 /////////////////////////////////////////////////////////////////////////////////////////////// - -type requestStateV1 struct { - buffer []byte - offset int -} - -func newRequestStateV1(protocol *protocol) *requestStateV1 { - return &requestStateV1{ - buffer: make([]byte, 1), - offset: 0, - } -} - -func (state *requestStateV1) Receive(data []byte, offset int, length int) (int, errors.IdentifiableError) { - return 0, nil -} - -func (state *requestStateV1) Send(param interface{}) errors.IdentifiableError { - return nil -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// region constants and variables ////////////////////////////////////////////////////////////////////////////////////// - -const ( - VERSION_1 = byte(1) - - CONNECTION_REJECT = byte(0) - CONNECTION_ACCEPT = byte(1) - - DISPATCH_DROP = byte(0) - DISPATCH_TRANSACTION = byte(1) - DISPATCH_REQUEST = byte(2) - - MARSHALED_IDENTITY_IDENTIFIER_START = 0 - MARSHALED_IDENTITY_SIGNATURE_START = MARSHALED_IDENTITY_IDENTIFIER_END - - MARSHALED_IDENTITY_IDENTIFIER_SIZE = identity.IDENTIFIER_BYTE_LENGTH - MARSHALED_IDENTITY_SIGNATURE_SIZE = identity.SIGNATURE_BYTE_LENGTH - - MARSHALED_IDENTITY_IDENTIFIER_END = MARSHALED_IDENTITY_IDENTIFIER_START + MARSHALED_IDENTITY_IDENTIFIER_SIZE - MARSHALED_IDENTITY_SIGNATURE_END = MARSHALED_IDENTITY_SIGNATURE_START + MARSHALED_IDENTITY_SIGNATURE_SIZE - - MARSHALED_IDENTITY_TOTAL_SIZE = MARSHALED_IDENTITY_SIGNATURE_END -) - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/gossip/protocol_v1.png b/plugins/gossip/protocol_v1.png deleted file mode 100644 index ce667756467d35bf33185cf5c3727894ea7c4e57..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 24951 zcmdqJcT`i~);3BvfIvc5YJ!4DSDJv75Q-vAP*5p~NUzcn2%P`|B1M{1r6X05jub)Z zMd<_(q(}!L^lt^vd5^#MJ7e7Y-yP#R@&_Yk@4ePsvp(~gJ5)u$92n%tTG&i6K0K3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A-yxvniHVACzhG17WNi<^bQ|)<&c<{d zacfi(CNa}q=eZ}VN1?hioM|et=Z9KQbFB+rS7CM4Cath~M=(>&g>XmQy}kQ0ku8UV zM6lM7$zd>lT$$jdXO$mwkeFGVnA{sg5pz5+MhJz@nXq$Y5T(#WKia$*BrXy9Mxa{$ zl5XC__!$O?7Zz#w6NB<$p);Wl(XK-qrG);W6}FQVwx2($M-9&MwZ7tCQN*)IFHw!F z3DVX-_H*eFFLeF!C+f?{v%~&2wsGi_HySUv|CIxc>XJEh7k}X@-M@_uz#TGeWK?j~ zREG3t^zMSQPiBB2LY@xKn$}5W_`rb0#AgId4YeOdhe;U2&yf=^kPwn-U3Mg%na334 uWCvlk2=o_uW-Va+iPE$FS0;QyC)=z`-`)J%JA9zRtWEl6%zQnEu>Sy73~~Gb diff --git a/plugins/gossip/send_queue.go b/plugins/gossip/send_queue.go deleted file mode 100644 index c855028951..0000000000 --- a/plugins/gossip/send_queue.go +++ /dev/null @@ -1,156 +0,0 @@ -package gossip - -import ( - "sync" - - "github.com/iotaledger/goshimmer/packages/model/meta_transaction" - "github.com/iotaledger/hive.go/daemon" - "github.com/iotaledger/hive.go/events" - "github.com/iotaledger/hive.go/node" -) - -// region plugin module setup ////////////////////////////////////////////////////////////////////////////////////////// - -func configureSendQueue(plugin *node.Plugin) { - for _, neighbor := range neighbors.GetMap() { - setupEventHandlers(neighbor) - } - - Events.AddNeighbor.Attach(events.NewClosure(setupEventHandlers)) - - daemon.Events.Shutdown.Attach(events.NewClosure(func() { - log.Info("Stopping Send Queue Dispatcher ...") - })) -} - -func runSendQueue(plugin *node.Plugin) { - log.Info("Starting Send Queue Dispatcher ...") - - daemon.BackgroundWorker("Gossip Send Queue Dispatcher", func() { - log.Info("Starting Send Queue Dispatcher ... done") - - for { - select { - case <-daemon.ShutdownSignal: - log.Info("Stopping Send Queue Dispatcher ... done") - - return - - case tx := <-sendQueue: - connectedNeighborsMutex.RLock() - for _, neighborQueue := range neighborQueues { - select { - case neighborQueue.queue <- tx: - // log sth - - default: - // log sth - } - } - connectedNeighborsMutex.RUnlock() - } - } - }) - - connectedNeighborsMutex.Lock() - for _, neighborQueue := range neighborQueues { - startNeighborSendQueue(neighborQueue.protocol.Neighbor, neighborQueue) - } - connectedNeighborsMutex.Unlock() -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// region public api /////////////////////////////////////////////////////////////////////////////////////////////////// - -func SendTransaction(transaction *meta_transaction.MetaTransaction) { - sendQueue <- transaction -} - -func (neighbor *Neighbor) SendTransaction(transaction *meta_transaction.MetaTransaction) { - if queue, exists := neighborQueues[neighbor.GetIdentity().StringIdentifier]; exists { - select { - case queue.queue <- transaction: - return - - default: - return - } - } -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// region utility methods ////////////////////////////////////////////////////////////////////////////////////////////// - -func setupEventHandlers(neighbor *Neighbor) { - neighbor.Events.ProtocolConnectionEstablished.Attach(events.NewClosure(func(protocol *protocol) { - queue := &neighborQueue{ - protocol: protocol, - queue: make(chan *meta_transaction.MetaTransaction, SEND_QUEUE_SIZE), - disconnectChan: make(chan int, 1), - } - - connectedNeighborsMutex.Lock() - neighborQueues[neighbor.GetIdentity().StringIdentifier] = queue - connectedNeighborsMutex.Unlock() - - protocol.Conn.Events.Close.Attach(events.NewClosure(func() { - close(queue.disconnectChan) - - connectedNeighborsMutex.Lock() - delete(neighborQueues, neighbor.GetIdentity().StringIdentifier) - connectedNeighborsMutex.Unlock() - })) - - if daemon.IsRunning() { - startNeighborSendQueue(neighbor, queue) - } - })) -} - -func startNeighborSendQueue(neighbor *Neighbor, neighborQueue *neighborQueue) { - daemon.BackgroundWorker("Gossip Send Queue ("+neighbor.GetIdentity().StringIdentifier+")", func() { - for { - select { - case <-daemon.ShutdownSignal: - return - - case <-neighborQueue.disconnectChan: - return - - case tx := <-neighborQueue.queue: - switch neighborQueue.protocol.Version { - case VERSION_1: - sendTransactionV1(neighborQueue.protocol, tx) - } - } - } - }) -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// region types and interfaces ///////////////////////////////////////////////////////////////////////////////////////// - -type neighborQueue struct { - protocol *protocol - queue chan *meta_transaction.MetaTransaction - disconnectChan chan int -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// region constants and variables ////////////////////////////////////////////////////////////////////////////////////// - -var neighborQueues = make(map[string]*neighborQueue) - -var connectedNeighborsMutex sync.RWMutex - -var sendQueue = make(chan *meta_transaction.MetaTransaction, SEND_QUEUE_SIZE) - -const ( - SEND_QUEUE_SIZE = 500 -) - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/gossip/server.go b/plugins/gossip/server.go deleted file mode 100644 index 3a34424026..0000000000 --- a/plugins/gossip/server.go +++ /dev/null @@ -1,77 +0,0 @@ -package gossip - -import ( - "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/identity" - "github.com/iotaledger/goshimmer/packages/network" - "github.com/iotaledger/goshimmer/packages/network/tcp" - "github.com/iotaledger/goshimmer/plugins/autopeering/local" - "github.com/iotaledger/hive.go/daemon" - "github.com/iotaledger/hive.go/events" - "github.com/iotaledger/hive.go/node" - "github.com/iotaledger/hive.go/parameter" -) - -var TCPServer = tcp.NewServer() - -func configureServer(plugin *node.Plugin) { - TCPServer.Events.Connect.Attach(events.NewClosure(func(conn *network.ManagedConnection) { - protocol := newProtocol(conn) - - // print protocol errors - protocol.Events.Error.Attach(events.NewClosure(func(err errors.IdentifiableError) { - log.Error(err.Error()) - })) - - // store protocol in neighbor if its a neighbor calling - protocol.Events.ReceiveIdentification.Attach(events.NewClosure(func(identity *identity.Identity) { - if protocol.Neighbor != nil { - - if protocol.Neighbor.GetAcceptedProtocol() == nil { - protocol.Neighbor.SetAcceptedProtocol(protocol) - - protocol.Conn.Events.Close.Attach(events.NewClosure(func() { - protocol.Neighbor.SetAcceptedProtocol(nil) - })) - } - } - })) - - // drop the "secondary" connection upon successful handshake - protocol.Events.HandshakeCompleted.Attach(events.NewClosure(func() { - if protocol.Neighbor.Peer.ID().String() <= local.INSTANCE.ID().String() { - var initiatedProtocolConn *network.ManagedConnection - if protocol.Neighbor.GetInitiatedProtocol() != nil { - initiatedProtocolConn = protocol.Neighbor.GetInitiatedProtocol().Conn - } - - if initiatedProtocolConn != nil { - _ = initiatedProtocolConn.Close() - } - } - - protocol.Neighbor.Events.ProtocolConnectionEstablished.Trigger(protocol) - })) - - go protocol.Init() - })) - - daemon.Events.Shutdown.Attach(events.NewClosure(func() { - log.Info("Stopping TCP Server ...") - - TCPServer.Shutdown() - })) -} - -func runServer(plugin *node.Plugin) { - gossipPort := parameter.NodeConfig.GetInt(GOSSIP_PORT) - log.Infof("Starting TCP Server (port %d) ...", gossipPort) - - daemon.BackgroundWorker("Gossip TCP Server", func() { - log.Infof("Starting TCP Server (port %d) ... done", gossipPort) - - TCPServer.Listen(gossipPort) - - log.Info("Stopping TCP Server ... done") - }) -} diff --git a/plugins/gossip/transaction_processor.go b/plugins/gossip/transaction_processor.go deleted file mode 100644 index 742ac36929..0000000000 --- a/plugins/gossip/transaction_processor.go +++ /dev/null @@ -1,26 +0,0 @@ -package gossip - -import ( - "github.com/iotaledger/goshimmer/packages/filter" - "github.com/iotaledger/goshimmer/packages/model/meta_transaction" -) - -// region public api /////////////////////////////////////////////////////////////////////////////////////////////////// - -func ProcessReceivedTransactionData(transactionData []byte) { - if transactionFilter.Add(transactionData) { - Events.ReceiveTransaction.Trigger(meta_transaction.FromBytes(transactionData)) - } -} - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// - -// region constants and variables ////////////////////////////////////////////////////////////////////////////////////// - -var transactionFilter = filter.NewByteArrayFilter(TRANSACTION_FILTER_SIZE) - -const ( - TRANSACTION_FILTER_SIZE = 500 -) - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/gossip/transaction_processor_test.go b/plugins/gossip/transaction_processor_test.go deleted file mode 100644 index 082eba9d38..0000000000 --- a/plugins/gossip/transaction_processor_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package gossip - -import ( - "sync" - "testing" - - "github.com/iotaledger/goshimmer/packages/model/meta_transaction" - "github.com/iotaledger/iota.go/consts" -) - -func BenchmarkProcessSimilarTransactionsFiltered(b *testing.B) { - byteArray := setupTransaction(meta_transaction.MARSHALED_TOTAL_SIZE / consts.NumberOfTritsInAByte) - - b.ResetTimer() - - for i := 0; i < b.N; i++ { - ProcessReceivedTransactionData(byteArray) - } -} - -func BenchmarkProcessSimilarTransactionsUnfiltered(b *testing.B) { - byteArray := setupTransaction(meta_transaction.MARSHALED_TOTAL_SIZE / consts.NumberOfTritsInAByte) - - b.ResetTimer() - - var wg sync.WaitGroup - - for i := 0; i < b.N; i++ { - wg.Add(1) - - go func() { - Events.ReceiveTransaction.Trigger(meta_transaction.FromBytes(byteArray)) - - wg.Done() - }() - } - - wg.Wait() -} - -func setupTransaction(byteArraySize int) []byte { - byteArray := make([]byte, byteArraySize) - - for i := 0; i < len(byteArray); i++ { - byteArray[i] = byte(i % 128) - } - - return byteArray -} diff --git a/plugins/tangle/events.go b/plugins/tangle/events.go index 3cc90ba431..b9c0acf5a9 100644 --- a/plugins/tangle/events.go +++ b/plugins/tangle/events.go @@ -1,7 +1,7 @@ package tangle import ( - "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/hive.go/events" ) @@ -16,5 +16,5 @@ type pluginEvents struct { } func transactionCaller(handler interface{}, params ...interface{}) { - handler.(func(*value_transaction.ValueTransaction))(params[0].(*value_transaction.ValueTransaction)) + handler.(func(*meta_transaction.MetaTransaction))(params[0].(*meta_transaction.MetaTransaction)) } From 821e9fb6358111821bba3196048f02a65da5901b Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 5 Dec 2019 13:09:09 +0000 Subject: [PATCH 021/184] :construction: WIP --- packages/gossip/manager.go | 6 ++-- packages/gossip/manager_test.go | 4 +-- packages/gossip/neighbor/neighbor.go | 2 +- packages/gossip/proto/message.proto | 2 +- packages/gossip/transport/handshake.go | 2 +- .../gossip/transport/proto/handshake.proto | 2 +- .../transactionspammer/transactionspammer.go | 9 ++++-- plugins/autopeering/plugin.go | 32 ++----------------- plugins/gossip/gossip.go | 18 ++++++++--- plugins/metrics/plugin.go | 5 ++- plugins/statusscreen-tps/plugin.go | 5 ++- plugins/tangle/solidifier.go | 8 +++-- plugins/tangle/solidifier_test.go | 28 ++++++++++++---- plugins/ui/ui.go | 5 ++- 14 files changed, 63 insertions(+), 65 deletions(-) diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go index 6c889e36fd..681f6b07c8 100644 --- a/packages/gossip/manager.go +++ b/packages/gossip/manager.go @@ -3,11 +3,11 @@ package gossip import ( "net" - "github.com/capossele/gossip/neighbor" - pb "github.com/capossele/gossip/proto" - "github.com/capossele/gossip/transport" "github.com/golang/protobuf/proto" "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/goshimmer/packages/gossip/neighbor" + pb "github.com/iotaledger/goshimmer/packages/gossip/proto" + "github.com/iotaledger/goshimmer/packages/gossip/transport" "github.com/iotaledger/hive.go/events" "github.com/pkg/errors" "go.uber.org/zap" diff --git a/packages/gossip/manager_test.go b/packages/gossip/manager_test.go index e037c22d9f..51df26e9eb 100644 --- a/packages/gossip/manager_test.go +++ b/packages/gossip/manager_test.go @@ -6,11 +6,11 @@ import ( "testing" "time" - pb "github.com/capossele/gossip/proto" - "github.com/capossele/gossip/transport" "github.com/golang/protobuf/proto" "github.com/iotaledger/autopeering-sim/peer" "github.com/iotaledger/autopeering-sim/peer/service" + pb "github.com/iotaledger/goshimmer/packages/gossip/proto" + "github.com/iotaledger/goshimmer/packages/gossip/transport" "github.com/iotaledger/hive.go/events" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/packages/gossip/neighbor/neighbor.go b/packages/gossip/neighbor/neighbor.go index 41d2d25fbc..e3ec6bda87 100644 --- a/packages/gossip/neighbor/neighbor.go +++ b/packages/gossip/neighbor/neighbor.go @@ -3,8 +3,8 @@ package neighbor import ( "sync" - "github.com/capossele/gossip/transport" "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/goshimmer/packages/gossip/transport" ) // Neighbor defines a neighbor diff --git a/packages/gossip/proto/message.proto b/packages/gossip/proto/message.proto index b01b93680c..6be94fdf51 100644 --- a/packages/gossip/proto/message.proto +++ b/packages/gossip/proto/message.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -option go_package = "github.com/capossele/gossip/proto"; +option go_package = "github.com/iotaledger/goshimmer/packages/gossip/proto"; package proto; diff --git a/packages/gossip/transport/handshake.go b/packages/gossip/transport/handshake.go index c6e253ffda..ef3e8608e5 100644 --- a/packages/gossip/transport/handshake.go +++ b/packages/gossip/transport/handshake.go @@ -4,9 +4,9 @@ import ( "bytes" "time" - pb "github.com/capossele/gossip/transport/proto" "github.com/golang/protobuf/proto" "github.com/iotaledger/autopeering-sim/server" + pb "github.com/iotaledger/goshimmer/packages/gossip/transport/proto" ) const ( diff --git a/packages/gossip/transport/proto/handshake.proto b/packages/gossip/transport/proto/handshake.proto index 2f9c628169..68537177d9 100644 --- a/packages/gossip/transport/proto/handshake.proto +++ b/packages/gossip/transport/proto/handshake.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -option go_package = "github.com/capossele/gossip/transport/proto"; +option go_package = "github.com/iotaledger/goshimmer/packages/gossip/transport/proto"; package proto; diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index ac1834f6c4..f37a2fc3bf 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -4,8 +4,9 @@ import ( "sync" "time" - "github.com/iotaledger/goshimmer/plugins/gossip" - + "github.com/golang/protobuf/proto" + "github.com/iotaledger/goshimmer/packages/gossip" + pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/plugins/tipselection" "github.com/iotaledger/hive.go/daemon" @@ -50,7 +51,9 @@ func Start(tps uint) { tx.SetBranchTransactionHash(tipselection.GetRandomTip()) tx.SetTrunkTransactionHash(tipselection.GetRandomTip()) - gossip.Events.ReceiveTransaction.Trigger(tx.MetaTransaction) + mtx := &pb.Transaction{Body: tx.MetaTransaction.GetBytes()} + b, _ := proto.Marshal(mtx) + gossip.Event.NewTransaction.Trigger(b) if sentCounter >= tps { duration := time.Since(start) diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 47fe0934df..eefa8de3de 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -1,12 +1,9 @@ package autopeering import ( - "net" - "github.com/iotaledger/autopeering-sim/discover" - "github.com/iotaledger/autopeering-sim/peer/service" - "github.com/iotaledger/autopeering-sim/selection" "github.com/iotaledger/goshimmer/packages/gossip" + "github.com/iotaledger/goshimmer/packages/gossip/neighbor" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" @@ -29,37 +26,12 @@ func run(plugin *node.Plugin) { } func configureLogging(plugin *node.Plugin) { - gossip.Event.DropNeighbor.Attach(events.NewClosure(func(peer *gossip.Neighbor) { + gossip.Event.DropNeighbor.Attach(events.NewClosure(func(peer *neighbor.Neighbor) { if Selection != nil { Selection.DropPeer(peer.Peer) } })) - selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) { - log.Info("neighbor removed: " + ev.DroppedID.String()) - gossip.RemoveNeighbor(ev.DroppedID.String()) - })) - - selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { - log.Info("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - log.Info("services: " + ev.Peer.Services().CreateRecord().String()) - gossipService := ev.Peer.Services().Get(service.GossipKey) - if gossipService != nil { - address, port, _ := net.SplitHostPort(ev.Peer.Services().Get(service.GossipKey).String()) - gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port)) - } - })) - - selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { - log.Info("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - log.Info("services: " + ev.Peer.Services().CreateRecord().String()) - gossipService := ev.Peer.Services().Get(service.GossipKey) - if gossipService != nil { - address, port, _ := net.SplitHostPort(ev.Peer.Services().Get(service.GossipKey).String()) - gossip.AddNeighbor(gossip.NewNeighbor(ev.Peer, address, port)) - } - })) - discover.Events.PeerDiscovered.Attach(events.NewClosure(func(ev *discover.DiscoveredEvent) { log.Info("new peer discovered: " + ev.Peer.Address() + " / " + ev.Peer.ID().String()) })) diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 0ca491a836..89683109d7 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -1,11 +1,13 @@ package gossip import ( + "github.com/iotaledger/goshimmer/packages/gossip/transport" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" gp "github.com/iotaledger/goshimmer/packages/gossip" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/autopeering-sim/peer/service" "github.com/iotaledger/autopeering-sim/selection" "github.com/iotaledger/goshimmer/plugins/tangle" "go.uber.org/zap" @@ -58,13 +60,21 @@ func configureEvents() { })) selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { - log.Debug("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - AddInbound(ev.Peer) + gossipService := ev.Peer.Services().Get(service.GossipKey) + if gossipService != nil { + log.Debug("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) + //address, port, _ := net.SplitHostPort(ev.Peer.Services().Get(service.GossipKey).String()) + AddInbound(ev.Peer) + } })) selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { - log.Debug("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - AddOutbound(ev.Peer) + gossipService := ev.Peer.Services().Get(service.GossipKey) + if gossipService != nil { + log.Debug("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) + //address, port, _ := net.SplitHostPort(ev.Peer.Services().Get(service.GossipKey).String()) + AddOutbound(ev.Peer) + } })) // mgr.Events.NewTransaction.Attach(events.NewClosure(func(ev *gp.NewTransactionEvent) { diff --git a/plugins/metrics/plugin.go b/plugins/metrics/plugin.go index c483a42a9a..b379f012f3 100644 --- a/plugins/metrics/plugin.go +++ b/plugins/metrics/plugin.go @@ -3,9 +3,8 @@ package metrics import ( "time" - "github.com/iotaledger/goshimmer/packages/model/meta_transaction" + "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/timeutil" - "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" @@ -15,7 +14,7 @@ var PLUGIN = node.NewPlugin("Metrics", node.Enabled, configure, run) func configure(plugin *node.Plugin) { // increase received TPS counter whenever we receive a new transaction - gossip.Events.ReceiveTransaction.Attach(events.NewClosure(func(_ *meta_transaction.MetaTransaction) { increaseReceivedTPSCounter() })) + gossip.Event.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) { increaseReceivedTPSCounter() })) } func run(plugin *node.Plugin) { diff --git a/plugins/statusscreen-tps/plugin.go b/plugins/statusscreen-tps/plugin.go index 15f4d1babc..c05fedb2ba 100644 --- a/plugins/statusscreen-tps/plugin.go +++ b/plugins/statusscreen-tps/plugin.go @@ -5,9 +5,8 @@ import ( "sync/atomic" "time" - "github.com/iotaledger/goshimmer/packages/model/meta_transaction" + "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/goshimmer/plugins/statusscreen" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" @@ -24,7 +23,7 @@ var receivedTps uint64 var solidTps uint64 var PLUGIN = node.NewPlugin("Statusscreen TPS", node.Enabled, func(plugin *node.Plugin) { - gossip.Events.ReceiveTransaction.Attach(events.NewClosure(func(_ *meta_transaction.MetaTransaction) { + gossip.Event.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) { atomic.AddUint64(&receivedTpsCounter, 1) })) diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index 53a0fe61a4..899764fcfa 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -4,12 +4,12 @@ import ( "runtime" "github.com/iotaledger/goshimmer/packages/errors" + "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/approvers" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/workerpool" - "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" @@ -27,8 +27,10 @@ func configureSolidifier(plugin *node.Plugin) { task.Return(nil) }, workerpool.WorkerCount(WORKER_COUNT), workerpool.QueueSize(10000)) - gossip.Events.ReceiveTransaction.Attach(events.NewClosure(func(rawTransaction *meta_transaction.MetaTransaction) { - workerPool.Submit(rawTransaction) + gossip.Event.NewTransaction.Attach(events.NewClosure(func(ev *gossip.NewTransactionEvent) { + tx := ev.Body + metaTx := meta_transaction.FromBytes(tx) + workerPool.Submit(metaTx) })) daemon.Events.Shutdown.Attach(events.NewClosure(func() { diff --git a/plugins/tangle/solidifier_test.go b/plugins/tangle/solidifier_test.go index f13daf1bf4..9062eda476 100644 --- a/plugins/tangle/solidifier_test.go +++ b/plugins/tangle/solidifier_test.go @@ -1,20 +1,23 @@ package tangle import ( - "github.com/iotaledger/hive.go/parameter" "os" "sync" "testing" + "github.com/golang/protobuf/proto" + "github.com/iotaledger/hive.go/parameter" + + "github.com/iotaledger/goshimmer/packages/gossip" + pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/trinary" ) func TestMain(m *testing.M) { - parameter.FetchConfig() + parameter.FetchConfig(false) os.Exit(m.Run()) } @@ -43,10 +46,21 @@ func TestSolidifier(t *testing.T) { // issue transactions wg.Add(4) - gossip.Events.ReceiveTransaction.Trigger(transaction1.MetaTransaction) - gossip.Events.ReceiveTransaction.Trigger(transaction2.MetaTransaction) - gossip.Events.ReceiveTransaction.Trigger(transaction3.MetaTransaction) - gossip.Events.ReceiveTransaction.Trigger(transaction4.MetaTransaction) + tx := &pb.Transaction{Body: transaction1.MetaTransaction.GetBytes()} + b, _ := proto.Marshal(tx) + gossip.Event.NewTransaction.Trigger(b) + + tx = &pb.Transaction{Body: transaction2.MetaTransaction.GetBytes()} + b, _ = proto.Marshal(tx) + gossip.Event.NewTransaction.Trigger(b) + + tx = &pb.Transaction{Body: transaction3.MetaTransaction.GetBytes()} + b, _ = proto.Marshal(tx) + gossip.Event.NewTransaction.Trigger(b) + + tx = &pb.Transaction{Body: transaction4.MetaTransaction.GetBytes()} + b, _ = proto.Marshal(tx) + gossip.Event.NewTransaction.Trigger(b) // wait until all are solid wg.Wait() diff --git a/plugins/ui/ui.go b/plugins/ui/ui.go index 2bc5d3654f..66ef309941 100644 --- a/plugins/ui/ui.go +++ b/plugins/ui/ui.go @@ -6,9 +6,8 @@ import ( "sync/atomic" "time" - "github.com/iotaledger/goshimmer/packages/model/meta_transaction" + "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/goshimmer/plugins/webapi" "github.com/iotaledger/hive.go/daemon" @@ -35,7 +34,7 @@ func configure(plugin *node.Plugin) { return c.JSON(http.StatusOK, tpsQueue) }) - gossip.Events.ReceiveTransaction.Attach(events.NewClosure(func(_ *meta_transaction.MetaTransaction) { + gossip.Event.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) { atomic.AddUint64(&receivedTpsCounter, 1) })) tangle.Events.TransactionSolid.Attach(events.NewClosure(func(_ *value_transaction.ValueTransaction) { From a8c0a04501823ba74a8cec30ba80cb5b171f7f14 Mon Sep 17 00:00:00 2001 From: capossele Date: Fri, 6 Dec 2019 12:24:18 +0000 Subject: [PATCH 022/184] :sparkles: adds new gossip --- go.mod | 12 +- go.sum | 30 +-- main.go | 9 + packages/gossip/errors.go | 8 + packages/gossip/events.go | 6 +- packages/gossip/manager.go | 223 ++++++++++------ packages/gossip/manager_test.go | 251 +++++++++++------- packages/gossip/neighbor/neighbor.go | 98 ------- packages/gossip/proto/message.pb.go | 35 +-- packages/gossip/transport/connection.go | 37 +-- packages/gossip/transport/handshake.go | 14 +- .../gossip/transport/proto/handshake.pb.go | 43 +-- packages/gossip/transport/transport.go | 111 ++++---- packages/gossip/transport/transport_test.go | 12 +- .../transactionspammer/transactionspammer.go | 2 +- plugins/autopeering/autopeering.go | 52 ++-- plugins/autopeering/plugin.go | 7 +- plugins/gossip/gossip.go | 50 ++-- plugins/gossip/plugin.go | 4 +- plugins/metrics/plugin.go | 2 +- plugins/statusscreen-tps/plugin.go | 2 +- plugins/tangle/solidifier.go | 2 +- plugins/ui/ui.go | 2 +- 23 files changed, 539 insertions(+), 473 deletions(-) create mode 100644 packages/gossip/errors.go delete mode 100644 packages/gossip/neighbor/neighbor.go diff --git a/go.mod b/go.mod index 83b07b2bc4..bc1fe018a2 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,6 @@ module github.com/iotaledger/goshimmer go 1.13 require ( - github.com/StabbyCutyou/buffstreams v2.0.0+incompatible - github.com/capossele/gossip v0.0.0-20191205112840-0e578079b414 github.com/dgraph-io/badger v1.6.0 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/gdamore/tcell v1.3.0 @@ -12,8 +10,8 @@ require ( github.com/golang/protobuf v1.3.2 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/autopeering-sim v0.0.0-20191203092805-a1dd5954f3f6 - github.com/iotaledger/hive.go v0.0.0-20191202111738-357cee7a1c37 + github.com/iotaledger/autopeering-sim v0.0.0-20191206120939-725ee12834dd + github.com/iotaledger/hive.go v0.0.0-20191206003239-3231c4584e5c github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible github.com/lucasb-eyer/go-colorful v1.0.3 // indirect @@ -32,10 +30,10 @@ require ( go.uber.org/zap v1.13.0 golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect - golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 + golang.org/x/net v0.0.0-20191206103017-1ddd1de85cb0 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect - golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 // indirect - golang.org/x/tools v0.0.0-20191203134012-c197fd4bf371 // indirect + golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e // indirect + golang.org/x/tools v0.0.0-20191205225056-3393d29bb9fe // indirect golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect gopkg.in/yaml.v2 v2.2.7 // indirect ) diff --git a/go.sum b/go.sum index ee5fc31608..3db57d9a34 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,4 @@ +cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M= @@ -8,8 +9,6 @@ github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0= github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/StabbyCutyou/buffstreams v2.0.0+incompatible h1:7bDqOlL2Ipve3YjZVVrWz/TOVOa+IEHj6XagpAtLn2I= -github.com/StabbyCutyou/buffstreams v2.0.0+incompatible/go.mod h1:gP6wgxHoC0NrobhUBwx+Y6hx2QyKFOT+ho8619aJCDk= github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -18,10 +17,6 @@ github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5 github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/capossele/gossip v0.0.0-20191204191545-36eddf08c1aa h1:46C1Ce+93zGZ+JJ4JUw3EuXHQXqKYzIX7+CRG0fweNk= -github.com/capossele/gossip v0.0.0-20191204191545-36eddf08c1aa/go.mod h1:P8rJEmorO5QpCL236F8vNhUFwFFjezt2d/+/LeRlELA= -github.com/capossele/gossip v0.0.0-20191205112840-0e578079b414 h1:C9Q279xU15Qt5WVZNH6t/1L7exbTVYp1uMRS9NSmL/U= -github.com/capossele/gossip v0.0.0-20191205112840-0e578079b414/go.mod h1:DnYLNZclq7cY6s2oA6wwhQ4tDB0j38enJHPrhpzOpJc= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= @@ -99,18 +94,17 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/autopeering-sim v0.0.0-20191202124431-1705dc628175 h1:/RAxj+VEPTykp9cWRKTtydkfuBDaFemI7/bdNYCD7Nw= -github.com/iotaledger/autopeering-sim v0.0.0-20191202124431-1705dc628175/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= -github.com/iotaledger/autopeering-sim v0.0.0-20191202192349-f8e7a238c2bb/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= -github.com/iotaledger/autopeering-sim v0.0.0-20191202212322-a6353b992662 h1:al3bYvSaJnFyupe7bqgXYeBZ7W0fTNWrFd9WLLNlC6I= -github.com/iotaledger/autopeering-sim v0.0.0-20191202212322-a6353b992662/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/autopeering-sim v0.0.0-20191203092805-a1dd5954f3f6 h1:lcM/irmEr++tz/XQCHCTBsteqiBVZ3uTurLnnviCxLg= github.com/iotaledger/autopeering-sim v0.0.0-20191203092805-a1dd5954f3f6/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191206120939-725ee12834dd h1:CTHnqb0UdC+EwHBn20TeGvYj5F44zoZTfPOX/vEmSzQ= +github.com/iotaledger/autopeering-sim v0.0.0-20191206120939-725ee12834dd/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= github.com/iotaledger/hive.go v0.0.0-20191202111738-357cee7a1c37 h1:Vex6W5Oae7xXvVmnCrl7J4o+PCx0FW3paMzXxQDr8H4= github.com/iotaledger/hive.go v0.0.0-20191202111738-357cee7a1c37/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= +github.com/iotaledger/hive.go v0.0.0-20191206003239-3231c4584e5c h1:kmx6rRpMkeO+5gqj8ngv1+0Z7MGxulV3SCP2SZn/mU4= +github.com/iotaledger/hive.go v0.0.0-20191206003239-3231c4584e5c/go.mod h1:7iqun29a1x0lymTrn0UJ3Z/yy0sUzUpoOZ1OYMrYN20= github.com/iotaledger/iota.go v1.0.0-beta.7/go.mod h1:dMps6iMVU1pf5NDYNKIw4tRsPeC8W3ZWjOvYHOO1PMg= github.com/iotaledger/iota.go v1.0.0-beta.9 h1:c654s9pkdhMBkABUvWg+6k91MEBbdtmZXP1xDfQpajg= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= @@ -286,6 +280,8 @@ golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 h1:e6HwijUxhDe+hPNjZQQn9bA5PW3vNmnN64U2ZW759Lk= golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191206103017-1ddd1de85cb0 h1:LxY/gQN/MrcW24/46nLyiip1GhN/Yi14QPbeNskTvQA= +golang.org/x/net v0.0.0-20191206103017-1ddd1de85cb0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -315,8 +311,8 @@ golang.org/x/sys v0.0.0-20191018095205-727590c5006e h1:ZtoklVMHQy6BFRHkbG6JzK+S6 golang.org/x/sys v0.0.0-20191018095205-727590c5006e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 h1:ZBzSG/7F4eNKz2L3GE9o300RX0Az1Bw5HF7PDraD+qU= -golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e h1:9vRrk9YW2BTzLP0VCB9ZDjU4cPqkg+IDWL7XgxA1yxQ= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -331,19 +327,19 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191121040551-947d4aa89328 h1:t3X42h9e6xdbrCD/gPyWqAXr2BEpdJqRd1brThaaxII= golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d h1:/iIZNFGxc/a7C3yWjGcnboV+Tkc7mxr+p6fDztwoxuM= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191202203127-2b6af5f9ace7 h1:I7bfRTrfnb7yQSesz6OhwGVh2imeNUcbbS8YtFYC8Ck= -golang.org/x/tools v0.0.0-20191202203127-2b6af5f9ace7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191203134012-c197fd4bf371 h1:Cjq6sG3gnKDchzWy7ouGQklhxMtWvh4AhSNJ0qGIeo4= golang.org/x/tools v0.0.0-20191203134012-c197fd4bf371/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191205225056-3393d29bb9fe h1:BEVcKURC7E0EF+vD1l52Jb3LOM5Iwu7OI5FpdPuU50o= +golang.org/x/tools v0.0.0-20191205225056-3393d29bb9fe/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.21.0 h1:G+97AoqBnmZIT91cLG/EkCoK9NSelj64P8bOHHNmGn0= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/main.go b/main.go index 2d313d6846..1f8fa01c4e 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,15 @@ import ( ) func main() { + // go func() { + // if err := profiler.Start(profiler.Config{ + // Service: "race-service", + // ServiceVersion: "1.0", + // ProjectID: "premium-canyon-232915", // optional on GCP + // }); err != nil { + // log.Fatalf("Cannot start the profiler: %v", err) + // } + // }() node.Run( cli.PLUGIN, autopeering.PLUGIN, diff --git a/packages/gossip/errors.go b/packages/gossip/errors.go new file mode 100644 index 0000000000..66a2a23e41 --- /dev/null +++ b/packages/gossip/errors.go @@ -0,0 +1,8 @@ +package gossip + +import "github.com/pkg/errors" + +var ( + ErrClosed = errors.New("manager closed") + ErrDuplicateNeighbor = errors.New("peer already connected") +) diff --git a/packages/gossip/events.go b/packages/gossip/events.go index 4c4e34a067..e8f6642b96 100644 --- a/packages/gossip/events.go +++ b/packages/gossip/events.go @@ -6,9 +6,13 @@ import ( ) // Events contains all the events that are triggered during the gossip protocol. -type Events struct { +var Events = struct { + // A NewTransaction event is triggered when a new transaction is received by the gossip protocol. NewTransaction *events.Event DropNeighbor *events.Event +}{ + NewTransaction: events.NewEvent(newTransaction), + DropNeighbor: events.NewEvent(dropNeighbor), } type NewTransactionEvent struct { diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go index 681f6b07c8..52efd9ae17 100644 --- a/packages/gossip/manager.go +++ b/packages/gossip/manager.go @@ -1,48 +1,52 @@ package gossip import ( + "io" "net" + "strings" + "sync" "github.com/golang/protobuf/proto" "github.com/iotaledger/autopeering-sim/peer" - "github.com/iotaledger/goshimmer/packages/gossip/neighbor" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/gossip/transport" - "github.com/iotaledger/hive.go/events" "github.com/pkg/errors" "go.uber.org/zap" ) const ( - maxAttempts = 3 -) - -var ( - Event Events + maxConnectionAttempts = 3 + maxPacketSize = 2048 ) type GetTransaction func(txHash []byte) ([]byte, error) type Manager struct { - neighborhood *neighbor.NeighborMap - trans *transport.TransportTCP + trans *transport.TCP log *zap.SugaredLogger getTransaction GetTransaction - Events Events + + wg sync.WaitGroup + + mu sync.RWMutex + neighbors map[peer.ID]*neighbor + running bool +} + +type neighbor struct { + peer *peer.Peer + conn *transport.Connection } -func NewManager(t *transport.TransportTCP, log *zap.SugaredLogger, f GetTransaction) *Manager { - mgr := &Manager{ - neighborhood: neighbor.NewMap(), +func NewManager(t *transport.TCP, log *zap.SugaredLogger, f GetTransaction) *Manager { + m := &Manager{ trans: t, log: log, getTransaction: f, - Events: Events{ - NewTransaction: events.NewEvent(newTransaction), - DropNeighbor: events.NewEvent(dropNeighbor)}, + neighbors: make(map[peer.ID]*neighbor), } - Event = mgr.Events - return mgr + m.running = true + return m } func (m *Manager) AddOutbound(p *peer.Peer) error { @@ -53,41 +57,78 @@ func (m *Manager) AddInbound(p *peer.Peer) error { return m.addNeighbor(p, m.trans.AcceptPeer) } -func (m *Manager) DropNeighbor(id peer.ID) { - m.deleteNeighbor(id) +func (m *Manager) DropNeighbor(p peer.ID) { + m.deleteNeighbor(p) } -func (m *Manager) RequestTransaction(data []byte, to ...*neighbor.Neighbor) { - req := &pb.TransactionRequest{} - err := proto.Unmarshal(data, req) - if err != nil { - m.log.Warnw("Data to send is not a Transaction Request", "err", err) +func (m *Manager) Close() { + m.mu.Lock() + m.running = false + // close all connections + for _, n := range m.neighbors { + _ = n.conn.Close() } - msg := marshal(req) + m.mu.Unlock() - m.send(msg, to...) + m.wg.Wait() } -func (m *Manager) Send(data []byte, to ...*neighbor.Neighbor) { - tx := &pb.Transaction{} - err := proto.Unmarshal(data, tx) - if err != nil { - m.log.Warnw("Data to send is not a Transaction", "err", err) +func (m *Manager) getNeighbors(ids ...peer.ID) []*neighbor { + if len(ids) > 0 { + return m.getNeighborsById(ids) + } + return m.getAllNeighbors() +} + +func (m *Manager) getAllNeighbors() []*neighbor { + m.mu.Lock() + result := make([]*neighbor, 0, len(m.neighbors)) + for _, n := range m.neighbors { + result = append(result, n) + } + m.mu.Unlock() + + return result +} + +func (m *Manager) getNeighborsById(ids []peer.ID) []*neighbor { + result := make([]*neighbor, 0, len(ids)) + + m.mu.RLock() + for _, id := range ids { + if n, ok := m.neighbors[id]; ok { + result = append(result, n) + } + } + m.mu.RUnlock() + + return result +} + +func (m *Manager) RequestTransaction(txHash []byte, to ...peer.ID) { + req := &pb.TransactionRequest{ + Hash: txHash, } - msg := marshal(tx) + m.send(marshal(req), to...) +} - m.send(msg, to...) +// SendTransaction sends the transaction data to the given neighbors. +func (m *Manager) SendTransaction(txData []byte, to ...peer.ID) { + tx := &pb.Transaction{ + Body: txData, + } + m.send(marshal(tx), to...) } -func (m *Manager) send(msg []byte, to ...*neighbor.Neighbor) { - neighbors := m.neighborhood.GetSlice() - if to != nil { - neighbors = to +func (m *Manager) send(msg []byte, to ...peer.ID) { + if l := len(msg); l > maxPacketSize { + m.log.Errorw("message too large", "len", l, "max", maxPacketSize) } + neighbors := m.getNeighbors(to...) - for _, neighbor := range neighbors { - m.log.Debugw("Sending", "to", neighbor.Peer.ID().String(), "msg", msg) - err := neighbor.Conn.Write(msg) + for _, nbr := range neighbors { + m.log.Debugw("Sending", "to", nbr.peer.ID(), "msg", msg) + _, err := nbr.conn.Write(msg) if err != nil { m.log.Debugw("send error", "err", err) } @@ -95,67 +136,89 @@ func (m *Manager) send(msg []byte, to ...*neighbor.Neighbor) { } func (m *Manager) addNeighbor(peer *peer.Peer, handshake func(*peer.Peer) (*transport.Connection, error)) error { - if _, ok := m.neighborhood.Load(peer.ID().String()); ok { - return errors.New("Neighbor already added") - } - - var err error - var conn *transport.Connection - i := 0 - for i = 0; i < maxAttempts; i++ { + var ( + err error + conn *transport.Connection + ) + for i := 0; i < maxConnectionAttempts; i++ { conn, err = handshake(peer) - if err != nil { - m.log.Warnw("Connection attempt failed", "attempt", i+1) - } else { + if err == nil { break } } - if i == maxAttempts { - m.log.Warnw("Connection failed to", "peer", peer.ID().String()) - m.Events.DropNeighbor.Trigger(&DropNeighborEvent{Peer: peer}) + + // could not add neighbor + if err != nil { + m.log.Debugw("addNeighbor failed", "peer", peer.ID(), "err", err) + Events.DropNeighbor.Trigger(&DropNeighborEvent{Peer: peer}) return err } - // add the new neighbor - neighbor := neighbor.New(peer, conn) - m.neighborhood.Store(peer.ID().String(), neighbor) + m.mu.Lock() + defer m.mu.Unlock() + if !m.running { + disconnect(conn) + return ErrClosed + } + if _, ok := m.neighbors[peer.ID()]; ok { + disconnect(conn) + return ErrDuplicateNeighbor + } - // start listener for the new neighbor - go m.readLoop(neighbor) + // add the neighbor + n := &neighbor{ + peer: peer, + conn: conn, + } + m.neighbors[peer.ID()] = n + go m.readLoop(n) return nil } -func (m *Manager) deleteNeighbor(id peer.ID) { - m.log.Debugw("Deleting neighbor", "neighbor", id.String()) - - p, ok := m.neighborhood.Delete(id.String()) - if ok { - m.Events.DropNeighbor.Trigger(&DropNeighborEvent{Peer: p.Peer}) +func (m *Manager) deleteNeighbor(peer peer.ID) { + m.mu.Lock() + defer m.mu.Unlock() + if _, ok := m.neighbors[peer]; !ok { + return } + + n := m.neighbors[peer] + delete(m.neighbors, peer) + disconnect(n.conn) } -func (m *Manager) readLoop(neighbor *neighbor.Neighbor) { +func (m *Manager) readLoop(nbr *neighbor) { + m.wg.Add(1) + defer m.wg.Done() + + // create a buffer for the packages + b := make([]byte, maxPacketSize) + for { - data, err := neighbor.Conn.Read() + n, err := nbr.conn.Read(b) if nerr, ok := err.(net.Error); ok && nerr.Temporary() { // ignore temporary read errors. - //m.log.Debugw("temporary read error", "err", err) + m.log.Debugw("temporary read error", "err", err) continue } else if err != nil { // return from the loop on all other errors - m.log.Debugw("reading stopped") - m.deleteNeighbor(neighbor.Peer.ID()) - + if err != io.EOF && !strings.Contains(err.Error(), "use of closed network connection") { + m.log.Warnw("read error", "err", err) + } + _ = nbr.conn.Close() // just make sure that the connection is closed as fast as possible + m.deleteNeighbor(nbr.peer.ID()) + m.log.Debug("reading stopped") return } - if err := m.handlePacket(data, neighbor); err != nil { - m.log.Warnw("failed to handle packet", "from", neighbor.Peer.ID().String(), "err", err) + + if err := m.handlePacket(b[:n], nbr); err != nil { + m.log.Warnw("failed to handle packet", "id", nbr.peer.ID(), "err", err) } } } -func (m *Manager) handlePacket(data []byte, neighbor *neighbor.Neighbor) error { +func (m *Manager) handlePacket(data []byte, n *neighbor) error { switch pb.MType(data[0]) { // Incoming Transaction @@ -165,7 +228,7 @@ func (m *Manager) handlePacket(data []byte, neighbor *neighbor.Neighbor) error { return errors.Wrap(err, "invalid message") } m.log.Debugw("Received Transaction", "data", msg.GetBody()) - m.Events.NewTransaction.Trigger(&NewTransactionEvent{Body: msg.GetBody(), Peer: neighbor.Peer}) + Events.NewTransaction.Trigger(&NewTransactionEvent{Body: msg.GetBody(), Peer: n.peer}) // Incoming Transaction request case pb.MTransactionRequest: @@ -180,11 +243,10 @@ func (m *Manager) handlePacket(data []byte, neighbor *neighbor.Neighbor) error { m.log.Debugw("Tx not available", "tx", msg.GetHash()) } else { m.log.Debugw("Tx found", "tx", tx) - m.Send(tx, neighbor) + m.SendTransaction(tx, n.peer.ID()) } default: - return nil } return nil @@ -202,3 +264,8 @@ func marshal(msg pb.Message) []byte { } return append([]byte{byte(mType)}, data...) } + +func disconnect(conn *transport.Connection) { + _ = conn.Close() + Events.DropNeighbor.Trigger(&DropNeighborEvent{Peer: conn.Peer()}) +} diff --git a/packages/gossip/manager_test.go b/packages/gossip/manager_test.go index 51df26e9eb..5d4a1e6b8f 100644 --- a/packages/gossip/manager_test.go +++ b/packages/gossip/manager_test.go @@ -13,13 +13,32 @@ import ( "github.com/iotaledger/goshimmer/packages/gossip/transport" "github.com/iotaledger/hive.go/events" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" "go.uber.org/zap" ) -const graceTime = 5 * time.Millisecond +const graceTime = 10 * time.Millisecond -var logger *zap.SugaredLogger +var ( + logger *zap.SugaredLogger + eventMock mock.Mock + + testTxData = []byte("testTx") +) + +func newTransactionEvent(ev *NewTransactionEvent) { eventMock.Called(ev) } +func dropNeighborEvent(ev *DropNeighborEvent) { eventMock.Called(ev) } + +// assertEvents initializes the mock and asserts the expectations +func assertEvents(t *testing.T) func() { + eventMock = mock.Mock{} + return func() { + if !t.Failed() { + eventMock.AssertExpectations(t) + } + } +} func init() { l, err := zap.NewDevelopment() @@ -27,31 +46,33 @@ func init() { log.Fatalf("cannot initialize logger: %v", err) } logger = l.Sugar() + + // mock the events + Events.NewTransaction.Attach(events.NewClosure(newTransactionEvent)) + Events.DropNeighbor.Attach(events.NewClosure(dropNeighborEvent)) } -func testGetTransaction([]byte) ([]byte, error) { - tx := &pb.TransactionRequest{ - Hash: []byte("testTx"), - } - b, _ := proto.Marshal(tx) - return b, nil + +func getTestTransaction([]byte) ([]byte, error) { + return testTxData, nil } func newTest(t require.TestingT, name string) (*Manager, func(), *peer.Peer) { - log := logger.Named(name) - db := peer.NewMemoryDB(log.Named("db")) + l := logger.Named(name) + db := peer.NewMemoryDB(l.Named("db")) local, err := peer.NewLocal("peering", name, db) require.NoError(t, err) require.NoError(t, local.UpdateService(service.GossipKey, "tcp", "localhost:0")) - trans, err := transport.Listen(local, log) + trans, err := transport.Listen(local, l) require.NoError(t, err) - mgr := NewManager(trans, log, testGetTransaction) + mgr := NewManager(trans, l, getTestTransaction) // update the service with the actual address require.NoError(t, local.UpdateService(service.GossipKey, trans.LocalAddr().Network(), trans.LocalAddr().String())) teardown := func() { + mgr.Close() trans.Close() db.Close() } @@ -59,11 +80,15 @@ func newTest(t require.TestingT, name string) (*Manager, func(), *peer.Peer) { } func TestClose(t *testing.T) { + defer assertEvents(t)() + _, teardown, _ := newTest(t, "A") teardown() } -func TestUnicast(t *testing.T) { +func TestClosedConnection(t *testing.T) { + defer assertEvents(t)() + mgrA, closeA, peerA := newTest(t, "A") defer closeA() mgrB, closeB, peerB := newTest(t, "B") @@ -72,6 +97,8 @@ func TestUnicast(t *testing.T) { var wg sync.WaitGroup wg.Add(2) + // connect in the following way + // B -> A go func() { defer wg.Done() err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) @@ -87,25 +114,100 @@ func TestUnicast(t *testing.T) { // wait for the connections to establish wg.Wait() - tx := &pb.Transaction{Body: []byte("Hello!")} + eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerA}).Once() + eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerB}).Once() - triggered := make(chan struct{}, 1) - mgrB.Events.NewTransaction.Attach(events.NewClosure(func(ev *NewTransactionEvent) { - require.Empty(t, triggered) // only once - assert.Equal(t, tx.GetBody(), ev.Body) - assert.Equal(t, peerA, ev.Peer) - triggered <- struct{}{} - })) + // A drops B + mgrA.deleteNeighbor(peerB.ID()) + time.Sleep(graceTime) - b, err := proto.Marshal(tx) - require.NoError(t, err) - mgrA.Send(b) + // the events should be there even before we close + eventMock.AssertExpectations(t) +} + +func TestP2PSend(t *testing.T) { + defer assertEvents(t)() + + mgrA, closeA, peerA := newTest(t, "A") + defer closeA() + mgrB, closeB, peerB := newTest(t, "B") + defer closeB() + + var wg sync.WaitGroup + wg.Add(2) + + // connect in the following way + // B -> A + go func() { + defer wg.Done() + err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) + assert.NoError(t, err) + }() + time.Sleep(graceTime) + go func() { + defer wg.Done() + err := mgrB.addNeighbor(peerA, mgrB.trans.DialPeer) + assert.NoError(t, err) + }() + + // wait for the connections to establish + wg.Wait() + + eventMock.On("newTransactionEvent", &NewTransactionEvent{ + Body: testTxData, + Peer: peerA, + }).Once() + eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerA}).Once() + eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerB}).Once() + + mgrA.SendTransaction(testTxData) + time.Sleep(graceTime) +} + +func TestP2PSendTwice(t *testing.T) { + defer assertEvents(t)() - // eventually the event should be triggered - assert.Eventually(t, func() bool { return len(triggered) >= 1 }, time.Second, 10*time.Millisecond) + mgrA, closeA, peerA := newTest(t, "A") + defer closeA() + mgrB, closeB, peerB := newTest(t, "B") + defer closeB() + + var wg sync.WaitGroup + wg.Add(2) + + // connect in the following way + // B -> A + go func() { + defer wg.Done() + err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) + assert.NoError(t, err) + }() + time.Sleep(graceTime) + go func() { + defer wg.Done() + err := mgrB.addNeighbor(peerA, mgrB.trans.DialPeer) + assert.NoError(t, err) + }() + + // wait for the connections to establish + wg.Wait() + + eventMock.On("newTransactionEvent", &NewTransactionEvent{ + Body: testTxData, + Peer: peerA, + }).Twice() + eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerA}).Once() + eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerB}).Once() + + mgrA.SendTransaction(testTxData) + time.Sleep(1 * time.Second) // wait a bit between the sends, to test timeouts + mgrA.SendTransaction(testTxData) + time.Sleep(graceTime) } func TestBroadcast(t *testing.T) { + defer assertEvents(t)() + mgrA, closeA, peerA := newTest(t, "A") defer closeA() mgrB, closeB, peerB := newTest(t, "B") @@ -116,6 +218,8 @@ func TestBroadcast(t *testing.T) { var wg sync.WaitGroup wg.Add(4) + // connect in the following way + // B -> A <- C go func() { defer wg.Done() err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) @@ -141,56 +245,37 @@ func TestBroadcast(t *testing.T) { // wait for the connections to establish wg.Wait() - tx := &pb.Transaction{Body: []byte("Hello!")} - - triggeredB := make(chan struct{}, 1) - mgrB.Events.NewTransaction.Attach(events.NewClosure(func(ev *NewTransactionEvent) { - require.Empty(t, triggeredB) // only once - assert.Equal(t, tx.GetBody(), ev.Body) - assert.Equal(t, peerA, ev.Peer) - triggeredB <- struct{}{} - })) - - triggeredC := make(chan struct{}, 1) - mgrC.Events.NewTransaction.Attach(events.NewClosure(func(ev *NewTransactionEvent) { - require.Empty(t, triggeredC) // only once - assert.Equal(t, tx.GetBody(), ev.Body) - assert.Equal(t, peerA, ev.Peer) - triggeredC <- struct{}{} - })) - - b, err := proto.Marshal(tx) - assert.NoError(t, err) - mgrA.Send(b) - - // eventually the events should be triggered - success := func() bool { - return len(triggeredB) >= 1 && len(triggeredC) >= 1 - } - assert.Eventually(t, success, time.Second, 10*time.Millisecond) + eventMock.On("newTransactionEvent", &NewTransactionEvent{ + Body: testTxData, + Peer: peerA, + }).Twice() + eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerA}).Twice() + eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerB}).Once() + eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerC}).Once() + + mgrA.SendTransaction(testTxData) + time.Sleep(graceTime) } func TestDropUnsuccessfulAccept(t *testing.T) { + defer assertEvents(t)() + mgrA, closeA, _ := newTest(t, "A") defer closeA() _, closeB, peerB := newTest(t, "B") defer closeB() - triggered := make(chan struct{}, 1) - mgrA.Events.DropNeighbor.Attach(events.NewClosure(func(ev *DropNeighborEvent) { - require.Empty(t, triggered) // only once - assert.Equal(t, peerB, ev.Peer) - triggered <- struct{}{} - })) + eventMock.On("dropNeighborEvent", &DropNeighborEvent{ + Peer: peerB, + }).Once() err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) assert.Error(t, err) - - // eventually the event should be triggered - assert.Eventually(t, func() bool { return len(triggered) >= 1 }, time.Second, 10*time.Millisecond) } func TestTxRequest(t *testing.T) { + defer assertEvents(t)() + mgrA, closeA, peerA := newTest(t, "A") defer closeA() mgrB, closeB, peerB := newTest(t, "B") @@ -199,48 +284,32 @@ func TestTxRequest(t *testing.T) { var wg sync.WaitGroup wg.Add(2) + // connect in the following way + // B -> A go func() { defer wg.Done() err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) assert.NoError(t, err) - logger.Debugw("Len", "len", mgrA.neighborhood.Len()) }() + time.Sleep(graceTime) go func() { defer wg.Done() err := mgrB.addNeighbor(peerA, mgrB.trans.DialPeer) assert.NoError(t, err) - logger.Debugw("Len", "len", mgrB.neighborhood.Len()) }() + // wait for the connections to establish wg.Wait() - tx := &pb.TransactionRequest{ - Hash: []byte("Hello!"), - } - b, err := proto.Marshal(tx) - assert.NoError(t, err) - - sendChan := make(chan struct{}) - sendSuccess := false - - mgrA.Events.NewTransaction.Attach(events.NewClosure(func(ev *NewTransactionEvent) { - logger.Debugw("New TX Event triggered", "data", ev.Body, "from", ev.Peer.ID().String()) - assert.Equal(t, []byte("testTx"), ev.Body) - assert.Equal(t, peerB, ev.Peer) - sendChan <- struct{}{} - })) + eventMock.On("newTransactionEvent", &NewTransactionEvent{ + Body: testTxData, + Peer: peerB, + }).Once() + eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerA}).Once() + eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerB}).Once() + b, err := proto.Marshal(&pb.TransactionRequest{Hash: []byte("Hello!")}) + require.NoError(t, err) mgrA.RequestTransaction(b) - - timer := time.NewTimer(5 * time.Second) - defer timer.Stop() - - select { - case <-sendChan: - sendSuccess = true - case <-timer.C: - sendSuccess = false - } - - assert.True(t, sendSuccess) + time.Sleep(graceTime) } diff --git a/packages/gossip/neighbor/neighbor.go b/packages/gossip/neighbor/neighbor.go deleted file mode 100644 index e3ec6bda87..0000000000 --- a/packages/gossip/neighbor/neighbor.go +++ /dev/null @@ -1,98 +0,0 @@ -package neighbor - -import ( - "sync" - - "github.com/iotaledger/autopeering-sim/peer" - "github.com/iotaledger/goshimmer/packages/gossip/transport" -) - -// Neighbor defines a neighbor -type Neighbor struct { - Peer *peer.Peer - Conn *transport.Connection -} - -// NeighborMap implements a map of neighbors thread safe -type NeighborMap struct { - sync.RWMutex - internal map[string]*Neighbor -} - -// NewMap returns a new NeighborMap -func NewMap() *NeighborMap { - return &NeighborMap{ - internal: make(map[string]*Neighbor), - } -} - -// New returns a new Neighbor -func New(peer *peer.Peer, conn *transport.Connection) *Neighbor { - return &Neighbor{ - Peer: peer, - Conn: conn, - } -} - -// Len returns the number of neighbors stored in a NeighborMap -func (nm *NeighborMap) Len() int { - nm.RLock() - defer nm.RUnlock() - return len(nm.internal) -} - -// GetMap returns the content of the entire internal map -func (nm *NeighborMap) GetMap() map[string]*Neighbor { - newMap := make(map[string]*Neighbor) - nm.RLock() - defer nm.RUnlock() - for k, v := range nm.internal { - newMap[k] = v - } - return newMap -} - -// GetSlice returns a slice of the content of the entire internal map -func (nm *NeighborMap) GetSlice() []*Neighbor { - newSlice := make([]*Neighbor, nm.Len()) - nm.RLock() - defer nm.RUnlock() - i := 0 - for _, v := range nm.internal { - newSlice[i] = v - i++ - } - return newSlice -} - -// Load returns the neighbor for a given key. -// It also return a bool to communicate the presence of the given -// neighbor into the internal map -func (nm *NeighborMap) Load(key string) (value *Neighbor, ok bool) { - nm.RLock() - defer nm.RUnlock() - result, ok := nm.internal[key] - return result, ok -} - -// Delete removes the entire entry for a given key and return true if successful -func (nm *NeighborMap) Delete(key string) (deletedNeighbor *Neighbor, ok bool) { - deletedNeighbor, ok = nm.Load(key) - if !ok { - return nil, false - } - nm.Lock() - defer nm.Unlock() - if deletedNeighbor.Conn != nil { - deletedNeighbor.Conn.Close() - } - delete(nm.internal, key) - return deletedNeighbor, true -} - -// Store adds a new neighbor to the NeighborMap -func (nm *NeighborMap) Store(key string, value *Neighbor) { - nm.Lock() - defer nm.Unlock() - nm.internal[key] = value -} diff --git a/packages/gossip/proto/message.pb.go b/packages/gossip/proto/message.pb.go index 1e67ece10c..df48ced344 100644 --- a/packages/gossip/proto/message.pb.go +++ b/packages/gossip/proto/message.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: proto/message.proto +// source: packages/gossip/proto/message.proto package proto @@ -32,7 +32,7 @@ func (m *Transaction) Reset() { *m = Transaction{} } func (m *Transaction) String() string { return proto.CompactTextString(m) } func (*Transaction) ProtoMessage() {} func (*Transaction) Descriptor() ([]byte, []int) { - return fileDescriptor_33f3a5e1293a7bcd, []int{0} + return fileDescriptor_fcce9e84825f2fa5, []int{0} } func (m *Transaction) XXX_Unmarshal(b []byte) error { @@ -72,7 +72,7 @@ func (m *TransactionRequest) Reset() { *m = TransactionRequest{} } func (m *TransactionRequest) String() string { return proto.CompactTextString(m) } func (*TransactionRequest) ProtoMessage() {} func (*TransactionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_33f3a5e1293a7bcd, []int{1} + return fileDescriptor_fcce9e84825f2fa5, []int{1} } func (m *TransactionRequest) XXX_Unmarshal(b []byte) error { @@ -105,17 +105,20 @@ func init() { proto.RegisterType((*TransactionRequest)(nil), "proto.TransactionRequest") } -func init() { proto.RegisterFile("proto/message.proto", fileDescriptor_33f3a5e1293a7bcd) } - -var fileDescriptor_33f3a5e1293a7bcd = []byte{ - // 139 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2e, 0x28, 0xca, 0x2f, - 0xc9, 0xd7, 0xcf, 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0xd5, 0x03, 0xf3, 0x84, 0x58, 0xc1, 0x94, - 0x92, 0x22, 0x17, 0x77, 0x48, 0x51, 0x62, 0x5e, 0x71, 0x62, 0x72, 0x49, 0x66, 0x7e, 0x9e, 0x90, - 0x10, 0x17, 0x4b, 0x52, 0x7e, 0x4a, 0xa5, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x4f, 0x10, 0x98, 0xad, - 0xa4, 0xc1, 0x25, 0x84, 0xa4, 0x24, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x04, 0xa4, 0x32, 0x23, - 0xb1, 0x38, 0x03, 0xa6, 0x12, 0xc4, 0x76, 0x52, 0x8e, 0x52, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, - 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0x4e, 0x2c, 0xc8, 0x2f, 0x2e, 0x4e, 0xcd, 0x49, 0xd5, 0x4f, - 0xcf, 0x2f, 0x2e, 0xce, 0x2c, 0xd0, 0x07, 0xdb, 0x98, 0xc4, 0x06, 0xa6, 0x8c, 0x01, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x34, 0x46, 0xa5, 0x0f, 0x96, 0x00, 0x00, 0x00, +func init() { + proto.RegisterFile("packages/gossip/proto/message.proto", fileDescriptor_fcce9e84825f2fa5) +} + +var fileDescriptor_fcce9e84825f2fa5 = []byte{ + // 157 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x8e, 0x31, 0x0b, 0xc2, 0x30, + 0x10, 0x46, 0x29, 0xa8, 0x43, 0x74, 0xca, 0xe4, 0xa8, 0x75, 0xe9, 0xd4, 0x0c, 0x22, 0xee, 0xfe, + 0x84, 0xe2, 0xe4, 0x76, 0x49, 0x8f, 0x24, 0x68, 0x7a, 0x31, 0x97, 0x0e, 0xfe, 0x7b, 0x49, 0x40, + 0x70, 0xe8, 0xf4, 0xbd, 0x0f, 0xde, 0xf0, 0xc4, 0x29, 0x82, 0x79, 0x82, 0x45, 0x56, 0x96, 0x98, + 0x7d, 0x54, 0x31, 0x51, 0x26, 0x15, 0x90, 0x19, 0x2c, 0xf6, 0xf5, 0xc9, 0x75, 0x9d, 0xf6, 0x28, + 0xb6, 0xf7, 0x04, 0x13, 0x83, 0xc9, 0x9e, 0x26, 0x29, 0xc5, 0x4a, 0xd3, 0xf8, 0xd9, 0x37, 0x87, + 0xa6, 0xdb, 0x0d, 0x95, 0xdb, 0x4e, 0xc8, 0x3f, 0x65, 0xc0, 0xf7, 0x8c, 0x9c, 0x8b, 0xe9, 0x80, + 0xdd, 0xcf, 0x2c, 0x7c, 0xbb, 0x3e, 0x2e, 0xd6, 0x67, 0x37, 0xeb, 0xde, 0x50, 0x50, 0x9e, 0x32, + 0xbc, 0x70, 0xb4, 0x98, 0x4a, 0x87, 0xf3, 0x21, 0x60, 0x52, 0x8b, 0x69, 0x7a, 0x53, 0xe7, 0xfc, + 0x0d, 0x00, 0x00, 0xff, 0xff, 0xd7, 0x71, 0x33, 0x9a, 0xba, 0x00, 0x00, 0x00, } diff --git a/packages/gossip/transport/connection.go b/packages/gossip/transport/connection.go index f688612973..d677040f00 100644 --- a/packages/gossip/transport/connection.go +++ b/packages/gossip/transport/connection.go @@ -2,43 +2,28 @@ package transport import ( "net" + "time" "github.com/iotaledger/autopeering-sim/peer" ) -const ( - // MaxPacketSize specifies the maximum allowed size of packets. - // Packets larger than this will be cut and thus treated as invalid. - MaxPacketSize = 1280 -) - +// Connection represents a network connection to a neighbor peer. type Connection struct { + net.Conn peer *peer.Peer - conn net.Conn } -func newConnection(p *peer.Peer, c net.Conn) *Connection { +func newConnection(c net.Conn, p *peer.Peer) *Connection { + // make sure the connection has no timeouts + _ = c.SetDeadline(time.Time{}) + return &Connection{ + Conn: c, peer: p, - conn: c, } } -func (c *Connection) Close() { - c.conn.Close() -} - -func (c *Connection) Read() ([]byte, error) { - b := make([]byte, MaxPacketSize) - n, err := c.conn.Read(b) - if err != nil { - return nil, err - } - - return b[:n], nil -} - -func (c *Connection) Write(b []byte) error { - _, err := c.conn.Write(b) - return err +// Peer returns the peer associated with that connection. +func (c *Connection) Peer() *peer.Peer { + return c.peer } diff --git a/packages/gossip/transport/handshake.go b/packages/gossip/transport/handshake.go index ef3e8608e5..e5e928c4e2 100644 --- a/packages/gossip/transport/handshake.go +++ b/packages/gossip/transport/handshake.go @@ -10,18 +10,18 @@ import ( ) const ( - HandshakeExpiration = 20 * time.Second - VersionNum = 0 + versionNum = 0 + handshakeExpiration = 20 * time.Second ) // isExpired checks whether the given UNIX time stamp is too far in the past. func isExpired(ts int64) bool { - return time.Since(time.Unix(ts, 0)) >= HandshakeExpiration + return time.Since(time.Unix(ts, 0)) >= handshakeExpiration } func newHandshakeRequest(fromAddr string, toAddr string) ([]byte, error) { m := &pb.HandshakeRequest{ - Version: VersionNum, + Version: versionNum, From: fromAddr, To: toAddr, Timestamp: time.Now().Unix(), @@ -36,7 +36,7 @@ func newHandshakeResponse(reqData []byte) ([]byte, error) { return proto.Marshal(m) } -func (t *TransportTCP) validateHandshakeRequest(reqData []byte, fromAddr string) bool { +func (t *TCP) validateHandshakeRequest(reqData []byte, fromAddr string) bool { m := new(pb.HandshakeRequest) if err := proto.Unmarshal(reqData, m); err != nil { t.log.Debugw("invalid handshake", @@ -44,7 +44,7 @@ func (t *TransportTCP) validateHandshakeRequest(reqData []byte, fromAddr string) ) return false } - if m.GetVersion() != VersionNum { + if m.GetVersion() != versionNum { t.log.Debugw("invalid handshake", "version", m.GetVersion(), ) @@ -71,7 +71,7 @@ func (t *TransportTCP) validateHandshakeRequest(reqData []byte, fromAddr string) return true } -func (t *TransportTCP) validateHandshakeResponse(resData []byte, reqData []byte) bool { +func (t *TCP) validateHandshakeResponse(resData []byte, reqData []byte) bool { m := new(pb.HandshakeResponse) if err := proto.Unmarshal(resData, m); err != nil { t.log.Debugw("invalid handshake", diff --git a/packages/gossip/transport/proto/handshake.pb.go b/packages/gossip/transport/proto/handshake.pb.go index c7f3688734..610f02b3b9 100644 --- a/packages/gossip/transport/proto/handshake.pb.go +++ b/packages/gossip/transport/proto/handshake.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: transport/proto/handshake.proto +// source: packages/gossip/transport/proto/handshake.proto package proto @@ -38,7 +38,7 @@ func (m *HandshakeRequest) Reset() { *m = HandshakeRequest{} } func (m *HandshakeRequest) String() string { return proto.CompactTextString(m) } func (*HandshakeRequest) ProtoMessage() {} func (*HandshakeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d7101ffe19b05443, []int{0} + return fileDescriptor_f9e96b60881ea276, []int{0} } func (m *HandshakeRequest) XXX_Unmarshal(b []byte) error { @@ -99,7 +99,7 @@ func (m *HandshakeResponse) Reset() { *m = HandshakeResponse{} } func (m *HandshakeResponse) String() string { return proto.CompactTextString(m) } func (*HandshakeResponse) ProtoMessage() {} func (*HandshakeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_d7101ffe19b05443, []int{1} + return fileDescriptor_f9e96b60881ea276, []int{1} } func (m *HandshakeResponse) XXX_Unmarshal(b []byte) error { @@ -132,21 +132,24 @@ func init() { proto.RegisterType((*HandshakeResponse)(nil), "proto.HandshakeResponse") } -func init() { proto.RegisterFile("transport/proto/handshake.proto", fileDescriptor_d7101ffe19b05443) } - -var fileDescriptor_d7101ffe19b05443 = []byte{ - // 203 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x5c, 0x8f, 0x3f, 0x4b, 0x04, 0x31, - 0x10, 0xc5, 0xb9, 0x3f, 0x7a, 0xde, 0xa0, 0xa2, 0xa9, 0x22, 0x08, 0xca, 0x55, 0x82, 0xb8, 0x29, - 0xfc, 0x06, 0x56, 0x57, 0xa7, 0xb4, 0x91, 0xec, 0x3a, 0x6e, 0x82, 0x26, 0x93, 0xcd, 0x64, 0xfd, - 0xfc, 0x0e, 0x81, 0x45, 0xb1, 0x7a, 0xef, 0xf7, 0x0b, 0xe4, 0x25, 0x70, 0x57, 0x8b, 0x4b, 0x9c, - 0xa9, 0x54, 0x93, 0x0b, 0x55, 0x32, 0xde, 0xa5, 0x77, 0xf6, 0xee, 0x13, 0xbb, 0xc6, 0xea, 0xa4, - 0xc5, 0x21, 0xc1, 0xd5, 0x71, 0x39, 0xb1, 0x38, 0xcd, 0xc8, 0x55, 0x69, 0xd8, 0x7d, 0x63, 0xe1, - 0x40, 0x49, 0xaf, 0xee, 0x57, 0x0f, 0x17, 0x76, 0x41, 0xa5, 0x60, 0xfb, 0x51, 0x28, 0xea, 0xb5, - 0xe8, 0xbd, 0x6d, 0x5d, 0x5d, 0xc2, 0xba, 0x92, 0xde, 0x34, 0x23, 0x4d, 0xdd, 0xc2, 0xbe, 0x86, - 0x28, 0xf7, 0xb8, 0x98, 0xf5, 0x56, 0xf4, 0xc6, 0xfe, 0x8a, 0x43, 0x07, 0xd7, 0x7f, 0xf6, 0xe4, - 0x81, 0x89, 0x51, 0xdd, 0xc0, 0x59, 0xc1, 0xe9, 0xcd, 0x3b, 0xf6, 0x6d, 0xf1, 0xdc, 0xee, 0x84, - 0x8f, 0x82, 0x2f, 0x4f, 0xaf, 0x8f, 0x63, 0xa8, 0x7e, 0xee, 0xbb, 0x81, 0xa2, 0x19, 0x5c, 0x26, - 0x66, 0xfc, 0x42, 0x33, 0x4a, 0x86, 0x6c, 0xfe, 0xfd, 0xb2, 0x3f, 0x6d, 0xf1, 0xfc, 0x13, 0x00, - 0x00, 0xff, 0xff, 0x51, 0xe0, 0x08, 0xd0, 0xff, 0x00, 0x00, 0x00, +func init() { + proto.RegisterFile("packages/gossip/transport/proto/handshake.proto", fileDescriptor_f9e96b60881ea276) +} + +var fileDescriptor_f9e96b60881ea276 = []byte{ + // 219 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x8f, 0x31, 0x4f, 0xc3, 0x30, + 0x10, 0x85, 0x95, 0xb4, 0x50, 0x6a, 0x01, 0x02, 0x4f, 0x41, 0x62, 0x88, 0x3a, 0x65, 0x8a, 0x07, + 0x7e, 0x00, 0x82, 0xa9, 0xb3, 0x47, 0x16, 0x74, 0x6d, 0x8f, 0xd8, 0x2a, 0xf6, 0x39, 0x77, 0x57, + 0x7e, 0x3f, 0xc2, 0x52, 0x05, 0x1b, 0xd3, 0xbb, 0xf7, 0x6e, 0xf8, 0xf4, 0x19, 0x57, 0x60, 0x7f, + 0x84, 0x09, 0xc5, 0x4d, 0x24, 0x12, 0x8b, 0x53, 0x86, 0x2c, 0x85, 0x58, 0x5d, 0x61, 0x52, 0x72, + 0x01, 0xf2, 0x41, 0x02, 0x1c, 0x71, 0xac, 0xdd, 0x5e, 0xd4, 0xd8, 0x64, 0x73, 0xb7, 0x3d, 0x7f, + 0x3c, 0xce, 0x27, 0x14, 0xb5, 0x9d, 0x59, 0x7d, 0x21, 0x4b, 0xa4, 0xdc, 0x35, 0x7d, 0x33, 0xdc, + 0xf8, 0x73, 0xb5, 0xd6, 0x2c, 0x3f, 0x98, 0x52, 0xd7, 0xf6, 0xcd, 0xb0, 0xf6, 0xf5, 0xb6, 0xb7, + 0xa6, 0x55, 0xea, 0x16, 0x75, 0x69, 0x95, 0xec, 0xa3, 0x59, 0x6b, 0x4c, 0x28, 0x0a, 0xa9, 0x74, + 0xcb, 0xbe, 0x19, 0x16, 0xfe, 0x77, 0xd8, 0x8c, 0xe6, 0xfe, 0x0f, 0x4f, 0x0a, 0x65, 0x41, 0xfb, + 0x60, 0xae, 0x18, 0xe7, 0xf7, 0x00, 0x12, 0x2a, 0xf1, 0xda, 0xaf, 0x18, 0xe7, 0x2d, 0x48, 0x78, + 0x7d, 0x79, 0x7b, 0x9e, 0xa2, 0x86, 0xd3, 0x6e, 0xdc, 0x53, 0x72, 0x91, 0x14, 0x3e, 0xf1, 0x30, + 0x21, 0xff, 0x68, 0x86, 0x98, 0x12, 0xf2, 0x7f, 0xe6, 0xbb, 0xcb, 0x1a, 0x4f, 0xdf, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x2a, 0x53, 0xc3, 0xbb, 0x23, 0x01, 0x00, 0x00, } diff --git a/packages/gossip/transport/transport.go b/packages/gossip/transport/transport.go index f9ae8101db..791b8e310a 100644 --- a/packages/gossip/transport/transport.go +++ b/packages/gossip/transport/transport.go @@ -3,8 +3,10 @@ package transport import ( "bytes" "container/list" - "errors" + "fmt" + "io" "net" + "strings" "sync" "time" @@ -12,14 +14,19 @@ import ( "github.com/iotaledger/autopeering-sim/peer" "github.com/iotaledger/autopeering-sim/peer/service" pb "github.com/iotaledger/autopeering-sim/server/proto" + "github.com/pkg/errors" "go.uber.org/zap" ) var ( - ErrTimeout = errors.New("accept timeout") - ErrClosed = errors.New("listener closed") + // ErrTimeout is returned when an expected incoming connection was not received in time. + ErrTimeout = errors.New("accept timeout") + // ErrClosed means that the transport was shut down before a response could be received. + ErrClosed = errors.New("transport closed") + // ErrInvalidHandshake is returned when no correct handshake could be established. ErrInvalidHandshake = errors.New("invalid handshake") - ErrNoGossip = errors.New("peer does not have a gossip service") + // ErrNoGossip means that the given peer does not support the gossip service. + ErrNoGossip = errors.New("peer does not have a gossip service") ) // connection timeouts @@ -27,9 +34,12 @@ const ( acceptTimeout = 500 * time.Millisecond handshakeTimeout = 100 * time.Millisecond connectionTimeout = acceptTimeout + handshakeTimeout + + maxHandshakePacketSize = 256 ) -type TransportTCP struct { +// TCP establishes verified incoming and outgoing TCP connections to other peers. +type TCP struct { local *peer.Local listener *net.TCPListener log *zap.SugaredLogger @@ -60,8 +70,9 @@ type accept struct { conn net.Conn // the actual network connection } -func Listen(local *peer.Local, log *zap.SugaredLogger) (*TransportTCP, error) { - t := &TransportTCP{ +// Listen creates the object and starts listening for incoming connections. +func Listen(local *peer.Local, log *zap.SugaredLogger) (*TCP, error) { + t := &TCP{ local: local, log: log, addAcceptMatcher: make(chan *acceptMatcher), @@ -91,7 +102,7 @@ func Listen(local *peer.Local, log *zap.SugaredLogger) (*TransportTCP, error) { } // Close stops listening on the gossip address. -func (t *TransportTCP) Close() { +func (t *TCP) Close() { t.closeOnce.Do(func() { close(t.closing) if err := t.listener.Close(); err != nil { @@ -102,13 +113,13 @@ func (t *TransportTCP) Close() { } // LocalAddr returns the listener's network address, -func (t *TransportTCP) LocalAddr() net.Addr { +func (t *TCP) LocalAddr() net.Addr { return t.listener.Addr() } // DialPeer establishes a gossip connection to the given peer. // If the peer does not accept the connection or the handshake fails, an error is returned. -func (t *TransportTCP) DialPeer(p *peer.Peer) (*Connection, error) { +func (t *TCP) DialPeer(p *peer.Peer) (*Connection, error) { gossipAddr := p.Services().Get(service.GossipKey) if gossipAddr == nil { return nil, ErrNoGossip @@ -125,12 +136,12 @@ func (t *TransportTCP) DialPeer(p *peer.Peer) (*Connection, error) { } t.log.Debugw("connected", "id", p.ID(), "addr", conn.RemoteAddr(), "direction", "out") - return newConnection(p, conn), nil + return newConnection(conn, p), nil } // AcceptPeer awaits an incoming connection from the given peer. // If the peer does not establish the connection or the handshake fails, an error is returned. -func (t *TransportTCP) AcceptPeer(p *peer.Peer) (*Connection, error) { +func (t *TCP) AcceptPeer(p *peer.Peer) (*Connection, error) { if p.Services().Get(service.GossipKey) == nil { return nil, ErrNoGossip } @@ -139,11 +150,12 @@ func (t *TransportTCP) AcceptPeer(p *peer.Peer) (*Connection, error) { if connected.err != nil { return nil, connected.err } - t.log.Debugw("connected", "id", p.ID(), "addr", connected.c.conn.RemoteAddr(), "direction", "in") + + t.log.Debugw("connected", "id", p.ID(), "addr", connected.c.RemoteAddr(), "direction", "in") return connected.c, nil } -func (t *TransportTCP) acceptPeer(p *peer.Peer) <-chan connect { +func (t *TCP) acceptPeer(p *peer.Peer) <-chan connect { connected := make(chan connect, 1) // add the matcher select { @@ -154,18 +166,18 @@ func (t *TransportTCP) acceptPeer(p *peer.Peer) <-chan connect { return connected } -func (t *TransportTCP) closeConnection(c net.Conn) { +func (t *TCP) closeConnection(c net.Conn) { if err := c.Close(); err != nil { t.log.Warnw("close error", "err", err) } } -func (t *TransportTCP) run() { +func (t *TCP) run() { defer t.wg.Done() var ( - mlist = list.New() - timeout = time.NewTimer(0) + matcherList = list.New() + timeout = time.NewTimer(0) ) defer timeout.Stop() @@ -174,9 +186,9 @@ func (t *TransportTCP) run() { for { // Set the timer so that it fires when the next accept expires - if el := mlist.Front(); el != nil { + if e := matcherList.Front(); e != nil { // the first element always has the closest deadline - m := el.Value.(*acceptMatcher) + m := e.Value.(*acceptMatcher) timeout.Reset(time.Until(m.deadline)) } else { timeout.Stop() @@ -187,16 +199,16 @@ func (t *TransportTCP) run() { // add a new matcher to the list case m := <-t.addAcceptMatcher: m.deadline = time.Now().Add(connectionTimeout) - mlist.PushBack(m) + matcherList.PushBack(m) // on accept received, check all matchers for a fit case a := <-t.acceptReceived: matched := false - for el := mlist.Front(); el != nil; el = el.Next() { - m := el.Value.(*acceptMatcher) + for e := matcherList.Front(); e != nil; e = e.Next() { + m := e.Value.(*acceptMatcher) if m.peer.ID() == a.fromID { matched = true - mlist.Remove(el) + matcherList.Remove(e) // finish the handshake go t.matchAccept(m, a.req, a.conn) } @@ -212,18 +224,18 @@ func (t *TransportTCP) run() { now := time.Now() // notify and remove any expired matchers - for el := mlist.Front(); el != nil; el = el.Next() { - m := el.Value.(*acceptMatcher) + for e := matcherList.Front(); e != nil; e = e.Next() { + m := e.Value.(*acceptMatcher) if now.After(m.deadline) || now.Equal(m.deadline) { m.connected <- connect{nil, ErrTimeout} - mlist.Remove(el) + matcherList.Remove(e) } } // on close, notify all the matchers case <-t.closing: - for el := mlist.Front(); el != nil; el = el.Next() { - el.Value.(*acceptMatcher).connected <- connect{nil, ErrClosed} + for e := matcherList.Front(); e != nil; e = e.Next() { + e.Value.(*acceptMatcher).connected <- connect{nil, ErrClosed} } return @@ -231,7 +243,7 @@ func (t *TransportTCP) run() { } } -func (t *TransportTCP) matchAccept(m *acceptMatcher, req []byte, conn net.Conn) { +func (t *TCP) matchAccept(m *acceptMatcher, req []byte, conn net.Conn) { t.wg.Add(1) defer t.wg.Done() @@ -241,10 +253,10 @@ func (t *TransportTCP) matchAccept(m *acceptMatcher, req []byte, conn net.Conn) t.closeConnection(conn) return } - m.connected <- connect{newConnection(m.peer, conn), nil} + m.connected <- connect{newConnection(conn, m.peer), nil} } -func (t *TransportTCP) listenLoop() { +func (t *TCP) listenLoop() { defer t.wg.Done() for { @@ -254,7 +266,10 @@ func (t *TransportTCP) listenLoop() { continue } else if err != nil { // return from the loop on all other errors - t.log.Warnw("read error", "err", err) + if err != io.EOF && !strings.Contains(err.Error(), "use of closed network connection") { + t.log.Warnw("listen error", "err", err) + } + t.log.Debug("listening stopped") return } @@ -278,7 +293,7 @@ func (t *TransportTCP) listenLoop() { } } -func (t *TransportTCP) doHandshake(key peer.PublicKey, remoteAddr string, conn net.Conn) error { +func (t *TCP) doHandshake(key peer.PublicKey, remoteAddr string, conn net.Conn) error { reqData, err := newHandshakeRequest(conn.LocalAddr().String(), remoteAddr) if err != nil { return err @@ -291,7 +306,10 @@ func (t *TransportTCP) doHandshake(key peer.PublicKey, remoteAddr string, conn n } b, err := proto.Marshal(pkt) if err != nil { - return err + return errors.Wrap(err, ErrInvalidHandshake.Error()) + } + if l := len(b); l > maxHandshakePacketSize { + return fmt.Errorf("handshake size too large: %d, max %d", l, maxHandshakePacketSize) } if err := conn.SetWriteDeadline(time.Now().Add(handshakeTimeout)); err != nil { @@ -305,7 +323,7 @@ func (t *TransportTCP) doHandshake(key peer.PublicKey, remoteAddr string, conn n if err := conn.SetReadDeadline(time.Now().Add(handshakeTimeout)); err != nil { return err } - b = make([]byte, MaxPacketSize) + b = make([]byte, maxHandshakePacketSize) n, err := conn.Read(b) if err != nil { return err @@ -313,17 +331,13 @@ func (t *TransportTCP) doHandshake(key peer.PublicKey, remoteAddr string, conn n pkt = new(pb.Packet) if err := proto.Unmarshal(b[:n], pkt); err != nil { - return err + return errors.Wrap(err, ErrInvalidHandshake.Error()) } signer, err := peer.RecoverKeyFromSignedData(pkt) - if err != nil { - return err - } - if !bytes.Equal(key, signer) { - return errors.New("invalid key") + if err != nil || !bytes.Equal(key, signer) { + return ErrInvalidHandshake } - if !t.validateHandshakeResponse(pkt.GetData(), reqData) { return ErrInvalidHandshake } @@ -331,14 +345,14 @@ func (t *TransportTCP) doHandshake(key peer.PublicKey, remoteAddr string, conn n return nil } -func (t *TransportTCP) readHandshakeRequest(conn net.Conn) (peer.PublicKey, []byte, error) { +func (t *TCP) readHandshakeRequest(conn net.Conn) (peer.PublicKey, []byte, error) { if err := conn.SetReadDeadline(time.Now().Add(handshakeTimeout)); err != nil { return nil, nil, err } - b := make([]byte, MaxPacketSize) + b := make([]byte, maxHandshakePacketSize) n, err := conn.Read(b) if err != nil { - return nil, nil, err + return nil, nil, errors.Wrap(err, ErrInvalidHandshake.Error()) } pkt := new(pb.Packet) @@ -358,7 +372,7 @@ func (t *TransportTCP) readHandshakeRequest(conn net.Conn) (peer.PublicKey, []by return key, pkt.GetData(), nil } -func (t *TransportTCP) writeHandshakeResponse(reqData []byte, conn net.Conn) error { +func (t *TCP) writeHandshakeResponse(reqData []byte, conn net.Conn) error { data, err := newHandshakeResponse(reqData) if err != nil { return err @@ -373,6 +387,9 @@ func (t *TransportTCP) writeHandshakeResponse(reqData []byte, conn net.Conn) err if err != nil { return err } + if l := len(b); l > maxHandshakePacketSize { + return fmt.Errorf("handshake size too large: %d, max %d", l, maxHandshakePacketSize) + } if err := conn.SetWriteDeadline(time.Now().Add(handshakeTimeout)); err != nil { return err diff --git a/packages/gossip/transport/transport_test.go b/packages/gossip/transport/transport_test.go index c0b670476d..51b64b8143 100644 --- a/packages/gossip/transport/transport_test.go +++ b/packages/gossip/transport/transport_test.go @@ -26,14 +26,14 @@ func init() { logger = l.Sugar() } -func newTest(t require.TestingT, name string) (*TransportTCP, func()) { +func newTest(t require.TestingT, name string) (*TCP, func()) { l := logger.Named(name) db := peer.NewMemoryDB(l.Named("db")) local, err := peer.NewLocal("peering", name, db) require.NoError(t, err) // enable TCP gossipping - require.NoError(t, local.UpdateService(service.GossipKey, "tcp", ":0")) + require.NoError(t, local.UpdateService(service.GossipKey, "tcp", "localhost:0")) trans, err := Listen(local, l) require.NoError(t, err) @@ -48,7 +48,7 @@ func newTest(t require.TestingT, name string) (*TransportTCP, func()) { return trans, teardown } -func getPeer(t *TransportTCP) *peer.Peer { +func getPeer(t *TCP) *peer.Peer { return &t.local.Peer } @@ -87,7 +87,7 @@ func TestUnansweredDial(t *testing.T) { // create peer with invalid gossip address services := getPeer(transA).Services().CreateRecord() - services.Update(service.GossipKey, "tcp", ":0") + services.Update(service.GossipKey, "tcp", "localhost:0") unreachablePeer := peer.NewPeer(getPeer(transA).PublicKey(), services) _, err := transA.DialPeer(unreachablePeer) @@ -99,12 +99,12 @@ func TestNoHandshakeResponse(t *testing.T) { defer closeA() // accept and read incoming connections - lis, err := net.Listen("tcp", ":0") + lis, err := net.Listen("tcp", "localhost:0") require.NoError(t, err) go func() { conn, err := lis.Accept() require.NoError(t, err) - n, _ := conn.Read(make([]byte, MaxPacketSize)) + n, _ := conn.Read(make([]byte, maxHandshakePacketSize)) assert.NotZero(t, n) _ = conn.Close() _ = lis.Close() diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index f37a2fc3bf..e9fd616c3c 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -53,7 +53,7 @@ func Start(tps uint) { mtx := &pb.Transaction{Body: tx.MetaTransaction.GetBytes()} b, _ := proto.Marshal(mtx) - gossip.Event.NewTransaction.Trigger(b) + gossip.Events.NewTransaction.Trigger(b) if sentCounter >= tps { duration := time.Since(start) diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index af5b20f894..f980e91c83 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -51,11 +51,15 @@ const defaultZLC = `{ } }` -func start() { - var ( - err error - ) +var ( + db peer.DB + trans *transport.TransportConn + zLogger *zap.SugaredLogger + handlers []server.Handler + conn *net.UDPConn +) +func configureAP() { host := parameter.NodeConfig.GetString(CFG_ADDRESS) localhost := host apPort := strconv.Itoa(parameter.NodeConfig.GetInt(CFG_PORT)) @@ -68,19 +72,16 @@ func start() { listenAddr := host + ":" + apPort gossipAddr := host + ":" + gossipPort - logger := logger.NewLogger(defaultZLC, debugLevel) - - defer func() { _ = logger.Sync() }() // ignore the returned error + zLogger = logger.NewLogger(defaultZLC, debugLevel) addr, err := net.ResolveUDPAddr("udp", localhost+":"+apPort) if err != nil { log.Fatalf("ResolveUDPAddr: %v", err) } - conn, err := net.ListenUDP("udp", addr) + conn, err = net.ListenUDP("udp", addr) if err != nil { log.Fatalf("ListenUDP: %v", err) } - defer conn.Close() masterPeers := []*peer.Peer{} master, err := parseEntryNodes() @@ -91,12 +92,11 @@ func start() { } // use the UDP connection for transport - trans := transport.Conn(conn, func(network, address string) (net.Addr, error) { return net.ResolveUDPAddr(network, address) }) - defer trans.Close() + trans = transport.Conn(conn, func(network, address string) (net.Addr, error) { return net.ResolveUDPAddr(network, address) }) // create a new local node - db := peer.NewPersistentDB(logger.Named("db")) - defer db.Close() + db = peer.NewPersistentDB(zLogger.Named("db")) + local.INSTANCE, err = peer.NewLocal("udp", listenAddr, db) if err != nil { log.Fatalf("ListenUDP: %v", err) @@ -108,14 +108,14 @@ func start() { } Discovery = discover.New(local.INSTANCE, discover.Config{ - Log: logger.Named("disc"), + Log: zLogger.Named("disc"), MasterPeers: masterPeers, }) - handlers := append([]server.Handler{}, Discovery) + handlers = append([]server.Handler{}, Discovery) if parameter.NodeConfig.GetBool(CFG_SELECTION) { Selection = selection.New(local.INSTANCE, Discovery, selection.Config{ - Log: logger.Named("sel"), + Log: zLogger.Named("sel"), Param: &selection.Parameters{ SaltLifetime: selection.DefaultSaltLifetime, RequiredService: []service.Key{service.GossipKey}, @@ -123,14 +123,14 @@ func start() { }) handlers = append(handlers, Selection) } +} +func start() { // start a server doing discovery and peering - srv = server.Listen(local.INSTANCE, trans, logger.Named("srv"), handlers...) - defer srv.Close() + srv = server.Listen(local.INSTANCE, trans, zLogger.Named("srv"), handlers...) // start the discovery on that connection Discovery.Start(srv) - defer Discovery.Close() // start the peering on that connection if parameter.NodeConfig.GetBool(CFG_SELECTION) { @@ -139,12 +139,22 @@ func start() { } id := base64.StdEncoding.EncodeToString(local.INSTANCE.PublicKey()) - logger.Info("Discovery protocol started: ID=" + id + ", address=" + srv.LocalAddr()) + zLogger.Info("Discovery protocol started: ID=" + id + ", address=" + srv.LocalAddr()) + + defer func() { + _ = zLogger.Sync() // ignore the returned error + trans.Close() + db.Close() + conn.Close() + srv.Close() + Discovery.Close() + }() + // Only for debug go func() { for t := range time.NewTicker(2 * time.Second).C { _ = t - printReport(logger) + printReport(zLogger) } }() diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index eefa8de3de..6190e497f4 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -3,7 +3,6 @@ package autopeering import ( "github.com/iotaledger/autopeering-sim/discover" "github.com/iotaledger/goshimmer/packages/gossip" - "github.com/iotaledger/goshimmer/packages/gossip/neighbor" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" @@ -18,6 +17,7 @@ func configure(plugin *node.Plugin) { close <- struct{}{} })) + configureAP() configureLogging(plugin) } @@ -26,9 +26,10 @@ func run(plugin *node.Plugin) { } func configureLogging(plugin *node.Plugin) { - gossip.Event.DropNeighbor.Attach(events.NewClosure(func(peer *neighbor.Neighbor) { + gossip.Events.DropNeighbor.Attach(events.NewClosure(func(ev *gossip.DropNeighborEvent) { + log.Info("neighbor dropped: " + ev.Peer.Address() + " / " + ev.Peer.ID().String()) if Selection != nil { - Selection.DropPeer(peer.Peer) + Selection.DropPeer(ev.Peer) } })) diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 89683109d7..00598e5fc4 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -1,28 +1,27 @@ package gossip import ( - - "github.com/iotaledger/goshimmer/packages/gossip/transport" - "github.com/iotaledger/goshimmer/packages/model/meta_transaction" + "github.com/golang/protobuf/proto" + "github.com/iotaledger/autopeering-sim/peer/service" + "github.com/iotaledger/autopeering-sim/selection" gp "github.com/iotaledger/goshimmer/packages/gossip" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" + "github.com/iotaledger/goshimmer/packages/gossip/transport" + "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/plugins/autopeering/local" - "github.com/iotaledger/autopeering-sim/peer/service" - "github.com/iotaledger/autopeering-sim/selection" "github.com/iotaledger/goshimmer/plugins/tangle" - "go.uber.org/zap" - "github.com/golang/protobuf/proto" "github.com/iotaledger/hive.go/events" + "go.uber.org/zap" ) var ( - zLogger *zap.SugaredLogger - mgr *gp.Manager - SendTransaction = mgr.Send + zLogger *zap.SugaredLogger + mgr *gp.Manager + SendTransaction = mgr.SendTransaction RequestTransaction = mgr.RequestTransaction - AddInbound = mgr.AddInbound - AddOutbound = mgr.AddOutbound - DropNeighbor = mgr.DropNeighbor + AddInbound = mgr.AddInbound + AddOutbound = mgr.AddOutbound + DropNeighbor = mgr.DropNeighbor ) func init() { @@ -46,43 +45,38 @@ func configureGossip() { trans, err := transport.Listen(local.INSTANCE, zLogger) if err != nil { - // TODO: handle error + log.Fatal(err) } mgr = gp.NewManager(trans, zLogger, getTransaction) + log.Info("Gossip started @", trans.LocalAddr().String()) } func configureEvents() { - + selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) { - log.Debug("neighbor removed: " + ev.DroppedID.String()) - DropNeighbor(ev.DroppedID) + log.Info("neighbor removed: " + ev.DroppedID.String()) + mgr.DropNeighbor(ev.DroppedID) })) selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { gossipService := ev.Peer.Services().Get(service.GossipKey) if gossipService != nil { - log.Debug("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) + log.Info("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) //address, port, _ := net.SplitHostPort(ev.Peer.Services().Get(service.GossipKey).String()) - AddInbound(ev.Peer) + go mgr.AddInbound(ev.Peer) } })) selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { gossipService := ev.Peer.Services().Get(service.GossipKey) if gossipService != nil { - log.Debug("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) + log.Info("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) //address, port, _ := net.SplitHostPort(ev.Peer.Services().Get(service.GossipKey).String()) - AddOutbound(ev.Peer) + go mgr.AddOutbound(ev.Peer) } })) - // mgr.Events.NewTransaction.Attach(events.NewClosure(func(ev *gp.NewTransactionEvent) { - // tx := ev.Body - // metaTx := meta_transaction.FromBytes(tx) - // Events.NewTransaction.Trigger(metaTx) - // })) - tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *meta_transaction.MetaTransaction) { t := &pb.Transaction{ Body: tx.GetBytes(), @@ -91,6 +85,6 @@ func configureEvents() { if err != nil { return } - SendTransaction(b) + go SendTransaction(b) })) } diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 2e6a902f91..3cfadd2416 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -1,10 +1,10 @@ package gossip import ( - "github.com/iotaledger/hive.go/logger" - "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" ) var PLUGIN = node.NewPlugin("Gossip", node.Enabled, configure, run) diff --git a/plugins/metrics/plugin.go b/plugins/metrics/plugin.go index b379f012f3..f51ac06b89 100644 --- a/plugins/metrics/plugin.go +++ b/plugins/metrics/plugin.go @@ -14,7 +14,7 @@ var PLUGIN = node.NewPlugin("Metrics", node.Enabled, configure, run) func configure(plugin *node.Plugin) { // increase received TPS counter whenever we receive a new transaction - gossip.Event.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) { increaseReceivedTPSCounter() })) + gossip.Events.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) { increaseReceivedTPSCounter() })) } func run(plugin *node.Plugin) { diff --git a/plugins/statusscreen-tps/plugin.go b/plugins/statusscreen-tps/plugin.go index c05fedb2ba..aac5ceff6e 100644 --- a/plugins/statusscreen-tps/plugin.go +++ b/plugins/statusscreen-tps/plugin.go @@ -23,7 +23,7 @@ var receivedTps uint64 var solidTps uint64 var PLUGIN = node.NewPlugin("Statusscreen TPS", node.Enabled, func(plugin *node.Plugin) { - gossip.Event.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) { + gossip.Events.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) { atomic.AddUint64(&receivedTpsCounter, 1) })) diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index 899764fcfa..6e7b19912c 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -27,7 +27,7 @@ func configureSolidifier(plugin *node.Plugin) { task.Return(nil) }, workerpool.WorkerCount(WORKER_COUNT), workerpool.QueueSize(10000)) - gossip.Event.NewTransaction.Attach(events.NewClosure(func(ev *gossip.NewTransactionEvent) { + gossip.Events.NewTransaction.Attach(events.NewClosure(func(ev *gossip.NewTransactionEvent) { tx := ev.Body metaTx := meta_transaction.FromBytes(tx) workerPool.Submit(metaTx) diff --git a/plugins/ui/ui.go b/plugins/ui/ui.go index 66ef309941..555271ecb3 100644 --- a/plugins/ui/ui.go +++ b/plugins/ui/ui.go @@ -34,7 +34,7 @@ func configure(plugin *node.Plugin) { return c.JSON(http.StatusOK, tpsQueue) }) - gossip.Event.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) { + gossip.Events.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) { atomic.AddUint64(&receivedTpsCounter, 1) })) tangle.Events.TransactionSolid.Attach(events.NewClosure(func(_ *value_transaction.ValueTransaction) { From 7e81eac92872dae76b8acc1b0f296612b54b5ea8 Mon Sep 17 00:00:00 2001 From: capossele Date: Sun, 8 Dec 2019 11:21:06 +0000 Subject: [PATCH 023/184] :construction: WIP --- .../transactionspammer/transactionspammer.go | 3 +- .../bundleprocessor/bundleprocessor_test.go | 14 +++----- plugins/gossip/gossip.go | 36 +++++++++++++------ plugins/gossip/plugin.go | 3 +- plugins/tangle/events.go | 4 +-- plugins/tangle/solidifier.go | 8 +++-- plugins/tangle/solidifier_test.go | 11 +++--- 7 files changed, 47 insertions(+), 32 deletions(-) diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index e9fd616c3c..00866b8ab9 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -8,6 +8,7 @@ import ( "github.com/iotaledger/goshimmer/packages/gossip" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/tipselection" "github.com/iotaledger/hive.go/daemon" ) @@ -53,7 +54,7 @@ func Start(tps uint) { mtx := &pb.Transaction{Body: tx.MetaTransaction.GetBytes()} b, _ := proto.Marshal(mtx) - gossip.Events.NewTransaction.Trigger(b) + gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b, Peer: &local.INSTANCE.Peer}) if sentCounter >= tps { duration := time.Since(start) diff --git a/plugins/bundleprocessor/bundleprocessor_test.go b/plugins/bundleprocessor/bundleprocessor_test.go index 6fda90857c..93ea4dcdcf 100644 --- a/plugins/bundleprocessor/bundleprocessor_test.go +++ b/plugins/bundleprocessor/bundleprocessor_test.go @@ -1,22 +1,18 @@ package bundleprocessor import ( - "github.com/iotaledger/hive.go/parameter" "os" "sync" "testing" + "github.com/iotaledger/goshimmer/packages/client" "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/hive.go/events" - + "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/goshimmer/plugins/tipselection" - - "github.com/iotaledger/goshimmer/packages/client" - + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" - - "github.com/iotaledger/goshimmer/plugins/tangle" + "github.com/iotaledger/hive.go/parameter" "github.com/iotaledger/iota.go/consts" "github.com/magiconair/properties/assert" ) @@ -49,7 +45,7 @@ func BenchmarkValidateSignatures(b *testing.B) { } func TestMain(m *testing.M) { - parameter.FetchConfig() + parameter.FetchConfig(false) os.Exit(m.Run()) } diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 00598e5fc4..1f58e107f1 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -2,6 +2,7 @@ package gossip import ( "github.com/golang/protobuf/proto" + zL "github.com/iotaledger/autopeering-sim/logger" "github.com/iotaledger/autopeering-sim/peer/service" "github.com/iotaledger/autopeering-sim/selection" gp "github.com/iotaledger/goshimmer/packages/gossip" @@ -14,7 +15,29 @@ import ( "go.uber.org/zap" ) +const defaultZLC = `{ + "level": "info", + "development": false, + "outputPaths": ["stdout"], + "errorOutputPaths": ["stderr"], + "encoding": "console", + "encoderConfig": { + "timeKey": "ts", + "levelKey": "level", + "nameKey": "logger", + "callerKey": "caller", + "messageKey": "msg", + "stacktraceKey": "stacktrace", + "lineEnding": "", + "levelEncoder": "", + "timeEncoder": "iso8601", + "durationEncoder": "", + "callerEncoder": "" + } + }` + var ( + debugLevel = "debug" zLogger *zap.SugaredLogger mgr *gp.Manager SendTransaction = mgr.SendTransaction @@ -24,14 +47,6 @@ var ( DropNeighbor = mgr.DropNeighbor ) -func init() { - l, err := zap.NewDevelopment() - if err != nil { - log.Fatalf("cannot initialize logger: %v", err) - } - zLogger = l.Sugar() -} - func getTransaction(h []byte) ([]byte, error) { tx := &pb.TransactionRequest{ Hash: []byte("testTx"), @@ -41,7 +56,7 @@ func getTransaction(h []byte) ([]byte, error) { } func configureGossip() { - defer func() { _ = zLogger.Sync() }() // ignore the returned error + zLogger = zL.NewLogger(defaultZLC, debugLevel) trans, err := transport.Listen(local.INSTANCE, zLogger) if err != nil { @@ -56,7 +71,7 @@ func configureEvents() { selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) { log.Info("neighbor removed: " + ev.DroppedID.String()) - mgr.DropNeighbor(ev.DroppedID) + go mgr.DropNeighbor(ev.DroppedID) })) selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { @@ -78,6 +93,7 @@ func configureEvents() { })) tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *meta_transaction.MetaTransaction) { + log.Info("Tx solidified") t := &pb.Transaction{ Body: tx.GetBytes(), } diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 3cfadd2416..5bf6cfca6e 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -11,8 +11,7 @@ var PLUGIN = node.NewPlugin("Gossip", node.Enabled, configure, run) var log = logger.NewLogger("Gossip") var ( - debugLevel = "debug" - close = make(chan struct{}, 1) + close = make(chan struct{}, 1) ) func configure(plugin *node.Plugin) { diff --git a/plugins/tangle/events.go b/plugins/tangle/events.go index b9c0acf5a9..3cc90ba431 100644 --- a/plugins/tangle/events.go +++ b/plugins/tangle/events.go @@ -1,7 +1,7 @@ package tangle import ( - "github.com/iotaledger/goshimmer/packages/model/meta_transaction" + "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/hive.go/events" ) @@ -16,5 +16,5 @@ type pluginEvents struct { } func transactionCaller(handler interface{}, params ...interface{}) { - handler.(func(*meta_transaction.MetaTransaction))(params[0].(*meta_transaction.MetaTransaction)) + handler.(func(*value_transaction.ValueTransaction))(params[0].(*value_transaction.ValueTransaction)) } diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index 6e7b19912c..addd5ee113 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -3,8 +3,10 @@ package tangle import ( "runtime" + "github.com/golang/protobuf/proto" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/gossip" + pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/model/approvers" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" @@ -28,8 +30,10 @@ func configureSolidifier(plugin *node.Plugin) { }, workerpool.WorkerCount(WORKER_COUNT), workerpool.QueueSize(10000)) gossip.Events.NewTransaction.Attach(events.NewClosure(func(ev *gossip.NewTransactionEvent) { - tx := ev.Body - metaTx := meta_transaction.FromBytes(tx) + //log.Info("New Transaction", ev.Body) + pTx := &pb.Transaction{} + proto.Unmarshal(ev.Body, pTx) + metaTx := meta_transaction.FromBytes(pTx.GetBody()) workerPool.Submit(metaTx) })) diff --git a/plugins/tangle/solidifier_test.go b/plugins/tangle/solidifier_test.go index 9062eda476..692e5ccdcc 100644 --- a/plugins/tangle/solidifier_test.go +++ b/plugins/tangle/solidifier_test.go @@ -6,13 +6,12 @@ import ( "testing" "github.com/golang/protobuf/proto" - "github.com/iotaledger/hive.go/parameter" - "github.com/iotaledger/goshimmer/packages/gossip" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/parameter" "github.com/iotaledger/iota.go/trinary" ) @@ -48,19 +47,19 @@ func TestSolidifier(t *testing.T) { wg.Add(4) tx := &pb.Transaction{Body: transaction1.MetaTransaction.GetBytes()} b, _ := proto.Marshal(tx) - gossip.Event.NewTransaction.Trigger(b) + gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b}) tx = &pb.Transaction{Body: transaction2.MetaTransaction.GetBytes()} b, _ = proto.Marshal(tx) - gossip.Event.NewTransaction.Trigger(b) + gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b}) tx = &pb.Transaction{Body: transaction3.MetaTransaction.GetBytes()} b, _ = proto.Marshal(tx) - gossip.Event.NewTransaction.Trigger(b) + gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b}) tx = &pb.Transaction{Body: transaction4.MetaTransaction.GetBytes()} b, _ = proto.Marshal(tx) - gossip.Event.NewTransaction.Trigger(b) + gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b}) // wait until all are solid wg.Wait() From 6d13ad3a6d98bdc11e14e616a17713e584f6c908 Mon Sep 17 00:00:00 2001 From: capossele Date: Mon, 9 Dec 2019 09:40:57 +0000 Subject: [PATCH 024/184] :construction: WIP --- packages/gossip/manager.go | 4 ++-- plugins/gossip/gossip.go | 22 ++++++++-------------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go index 52efd9ae17..7121f60db0 100644 --- a/packages/gossip/manager.go +++ b/packages/gossip/manager.go @@ -81,12 +81,12 @@ func (m *Manager) getNeighbors(ids ...peer.ID) []*neighbor { } func (m *Manager) getAllNeighbors() []*neighbor { - m.mu.Lock() + m.mu.RLock() result := make([]*neighbor, 0, len(m.neighbors)) for _, n := range m.neighbors { result = append(result, n) } - m.mu.Unlock() + m.mu.RUnlock() return result } diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 1f58e107f1..48800c448a 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -8,7 +8,7 @@ import ( gp "github.com/iotaledger/goshimmer/packages/gossip" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/gossip/transport" - "github.com/iotaledger/goshimmer/packages/model/meta_transaction" + "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/events" @@ -37,14 +37,9 @@ const defaultZLC = `{ }` var ( - debugLevel = "debug" - zLogger *zap.SugaredLogger - mgr *gp.Manager - SendTransaction = mgr.SendTransaction - RequestTransaction = mgr.RequestTransaction - AddInbound = mgr.AddInbound - AddOutbound = mgr.AddOutbound - DropNeighbor = mgr.DropNeighbor + debugLevel = "debug" + zLogger *zap.SugaredLogger + mgr *gp.Manager ) func getTransaction(h []byte) ([]byte, error) { @@ -64,6 +59,7 @@ func configureGossip() { } mgr = gp.NewManager(trans, zLogger, getTransaction) + log.Info("Gossip started @", trans.LocalAddr().String()) } @@ -78,7 +74,6 @@ func configureEvents() { gossipService := ev.Peer.Services().Get(service.GossipKey) if gossipService != nil { log.Info("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - //address, port, _ := net.SplitHostPort(ev.Peer.Services().Get(service.GossipKey).String()) go mgr.AddInbound(ev.Peer) } })) @@ -87,20 +82,19 @@ func configureEvents() { gossipService := ev.Peer.Services().Get(service.GossipKey) if gossipService != nil { log.Info("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - //address, port, _ := net.SplitHostPort(ev.Peer.Services().Get(service.GossipKey).String()) go mgr.AddOutbound(ev.Peer) } })) - tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *meta_transaction.MetaTransaction) { + tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { log.Info("Tx solidified") t := &pb.Transaction{ - Body: tx.GetBytes(), + Body: tx.MetaTransaction.GetBytes(), } b, err := proto.Marshal(t) if err != nil { return } - go SendTransaction(b) + go mgr.SendTransaction(b) })) } From af2f691f35f7b777004db215eb7f2ae0b01c51b0 Mon Sep 17 00:00:00 2001 From: capossele Date: Mon, 9 Dec 2019 09:41:23 +0000 Subject: [PATCH 025/184] :zap: reduces size of the cache --- plugins/tangle/bundle.go | 2 +- plugins/tangle/transaction.go | 2 +- plugins/tangle/transaction_metadata.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/tangle/bundle.go b/plugins/tangle/bundle.go index ac5b1cd3eb..d8c33fc7ae 100644 --- a/plugins/tangle/bundle.go +++ b/plugins/tangle/bundle.go @@ -70,7 +70,7 @@ func onEvictBundle(_ interface{}, value interface{}) { } const ( - BUNDLE_CACHE_SIZE = 50000 + BUNDLE_CACHE_SIZE = 500 ) // endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/tangle/transaction.go b/plugins/tangle/transaction.go index 611a73dfa0..01bbe222b9 100644 --- a/plugins/tangle/transaction.go +++ b/plugins/tangle/transaction.go @@ -67,7 +67,7 @@ func onEvictTransaction(_ interface{}, value interface{}) { } const ( - TRANSACTION_CACHE_SIZE = 50000 + TRANSACTION_CACHE_SIZE = 500 ) // endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/tangle/transaction_metadata.go b/plugins/tangle/transaction_metadata.go index 75c1086fc0..07dc28f573 100644 --- a/plugins/tangle/transaction_metadata.go +++ b/plugins/tangle/transaction_metadata.go @@ -67,7 +67,7 @@ func onEvictTransactionMetadata(_ interface{}, value interface{}) { } const ( - TRANSACTION_METADATA_CACHE_SIZE = 50000 + TRANSACTION_METADATA_CACHE_SIZE = 500 ) // endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// From 5ef395cf78420e7a2343fa11153c55d21b898a19 Mon Sep 17 00:00:00 2001 From: capossele Date: Mon, 9 Dec 2019 10:10:52 +0000 Subject: [PATCH 026/184] :arrow_up: updates dependencies --- go.mod | 11 ++++++----- go.sum | 41 +++++++++++++++++++++++------------------ 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index bc1fe018a2..5c82b7a62d 100644 --- a/go.mod +++ b/go.mod @@ -10,8 +10,8 @@ require ( github.com/golang/protobuf v1.3.2 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/autopeering-sim v0.0.0-20191206120939-725ee12834dd - github.com/iotaledger/hive.go v0.0.0-20191206003239-3231c4584e5c + github.com/iotaledger/autopeering-sim v0.0.0-20191206234543-6bc473d306a9 + github.com/iotaledger/hive.go v0.0.0-20191208004610-567900b261bd github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible github.com/lucasb-eyer/go-colorful v1.0.3 // indirect @@ -25,15 +25,16 @@ require ( github.com/spf13/afero v1.2.2 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 + github.com/spf13/viper v1.6.1 // indirect github.com/stretchr/testify v1.4.0 github.com/valyala/fasttemplate v1.1.0 // indirect go.uber.org/zap v1.13.0 golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect - golang.org/x/net v0.0.0-20191206103017-1ddd1de85cb0 + golang.org/x/net v0.0.0-20191207000613-e7e4b65ae663 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect - golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e // indirect - golang.org/x/tools v0.0.0-20191205225056-3393d29bb9fe // indirect + golang.org/x/sys v0.0.0-20191206220618-eeba5f6aabab // indirect + golang.org/x/tools v0.0.0-20191206204035-259af5ff87bd // indirect golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect gopkg.in/yaml.v2 v2.2.7 // indirect ) diff --git a/go.sum b/go.sum index 3db57d9a34..41a838f9d3 100644 --- a/go.sum +++ b/go.sum @@ -81,6 +81,8 @@ github.com/google/open-location-code/go v0.0.0-20190723034300-2c7115db77a3/go.mo github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 h1:OdVal38kmXn0U3M3CYmPF4cpMLLvD4ioshwrooNfmxs= github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51/go.mod h1:eJfRN6aj+kR/rnua/rw9jAgYhqoMHldQkdTi+sePRKk= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= @@ -94,17 +96,13 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/autopeering-sim v0.0.0-20191203092805-a1dd5954f3f6 h1:lcM/irmEr++tz/XQCHCTBsteqiBVZ3uTurLnnviCxLg= -github.com/iotaledger/autopeering-sim v0.0.0-20191203092805-a1dd5954f3f6/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= -github.com/iotaledger/autopeering-sim v0.0.0-20191206120939-725ee12834dd h1:CTHnqb0UdC+EwHBn20TeGvYj5F44zoZTfPOX/vEmSzQ= -github.com/iotaledger/autopeering-sim v0.0.0-20191206120939-725ee12834dd/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191206234543-6bc473d306a9 h1:JHAeVTHd8HnXnFsG2mFq3rBaXS4dRJ2lM85DSag44qo= +github.com/iotaledger/autopeering-sim v0.0.0-20191206234543-6bc473d306a9/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= -github.com/iotaledger/hive.go v0.0.0-20191202111738-357cee7a1c37 h1:Vex6W5Oae7xXvVmnCrl7J4o+PCx0FW3paMzXxQDr8H4= -github.com/iotaledger/hive.go v0.0.0-20191202111738-357cee7a1c37/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= -github.com/iotaledger/hive.go v0.0.0-20191206003239-3231c4584e5c h1:kmx6rRpMkeO+5gqj8ngv1+0Z7MGxulV3SCP2SZn/mU4= -github.com/iotaledger/hive.go v0.0.0-20191206003239-3231c4584e5c/go.mod h1:7iqun29a1x0lymTrn0UJ3Z/yy0sUzUpoOZ1OYMrYN20= +github.com/iotaledger/hive.go v0.0.0-20191208004610-567900b261bd h1:hh8iusLOBylWNHeJNiZv6atCbO7vzjCLlg53pNAMkFk= +github.com/iotaledger/hive.go v0.0.0-20191208004610-567900b261bd/go.mod h1:7iqun29a1x0lymTrn0UJ3Z/yy0sUzUpoOZ1OYMrYN20= github.com/iotaledger/iota.go v1.0.0-beta.7/go.mod h1:dMps6iMVU1pf5NDYNKIw4tRsPeC8W3ZWjOvYHOO1PMg= github.com/iotaledger/iota.go v1.0.0-beta.9 h1:c654s9pkdhMBkABUvWg+6k91MEBbdtmZXP1xDfQpajg= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= @@ -112,6 +110,8 @@ github.com/iotaledger/iota.go v1.0.0-beta.10 h1:PBRWEcBSw0UO7zqEHJLrHOUbjJj1eldl github.com/iotaledger/iota.go v1.0.0-beta.10/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= @@ -193,6 +193,10 @@ github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73 github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= github.com/simia-tech/env v0.1.0/go.mod h1:eVRQ7W5NXXHifpPAcTJ3r5EmoGgMn++dXfSVbZv3Opo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= @@ -212,6 +216,8 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.5.0 h1:GpsTwfsQ27oS/Aha/6d1oD7tpKIqWnOA6tgOX9HHkt4= github.com/spf13/viper v1.5.0/go.mod h1:AkYRkVJF8TkSG/xet6PzXX+l39KhhXa2pdqVSxnTcn4= +github.com/spf13/viper v1.6.1 h1:VPZzIkznI1YhVMRi6vNFLHSwhnhReBfgTxIPccpfdZk= +github.com/spf13/viper v1.6.1/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -278,10 +284,8 @@ golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933 h1:e6HwijUxhDe+hPNjZQQn9bA5PW3vNmnN64U2ZW759Lk= -golang.org/x/net v0.0.0-20191126235420-ef20fe5d7933/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191206103017-1ddd1de85cb0 h1:LxY/gQN/MrcW24/46nLyiip1GhN/Yi14QPbeNskTvQA= -golang.org/x/net v0.0.0-20191206103017-1ddd1de85cb0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191207000613-e7e4b65ae663 h1:Dd5RoEW+yQi+9DMybroBctIdyiwuNT7sJFMC27/6KxI= +golang.org/x/net v0.0.0-20191207000613-e7e4b65ae663/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -311,8 +315,8 @@ golang.org/x/sys v0.0.0-20191018095205-727590c5006e h1:ZtoklVMHQy6BFRHkbG6JzK+S6 golang.org/x/sys v0.0.0-20191018095205-727590c5006e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e h1:9vRrk9YW2BTzLP0VCB9ZDjU4cPqkg+IDWL7XgxA1yxQ= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191206220618-eeba5f6aabab h1:FvshnhkKW+LO3HWHodML8kuVX8rnJTxKm9dFPuI68UM= +golang.org/x/sys v0.0.0-20191206220618-eeba5f6aabab/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -321,16 +325,15 @@ golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191121040551-947d4aa89328 h1:t3X42h9e6xdbrCD/gPyWqAXr2BEpdJqRd1brThaaxII= golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191203134012-c197fd4bf371 h1:Cjq6sG3gnKDchzWy7ouGQklhxMtWvh4AhSNJ0qGIeo4= -golang.org/x/tools v0.0.0-20191203134012-c197fd4bf371/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191205225056-3393d29bb9fe h1:BEVcKURC7E0EF+vD1l52Jb3LOM5Iwu7OI5FpdPuU50o= -golang.org/x/tools v0.0.0-20191205225056-3393d29bb9fe/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191206204035-259af5ff87bd h1:Zc7EU2PqpsNeIfOoVA7hvQX4cS3YDJEs5KlfatT3hLo= +golang.org/x/tools v0.0.0-20191206204035-259af5ff87bd/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= @@ -349,6 +352,8 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/h2non/gock.v1 v1.0.14/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE= +gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= +gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= From 1cd22b160c5a3859a2d7c5dd50d01b6cc9bc3bc2 Mon Sep 17 00:00:00 2001 From: capossele Date: Mon, 9 Dec 2019 10:35:40 +0000 Subject: [PATCH 027/184] :sparkles: integrates latest gossip package --- packages/gossip/errors.go | 1 + packages/gossip/events.go | 36 +++-- packages/gossip/manager.go | 86 ++++++------ packages/gossip/manager_test.go | 132 +++++++++++++----- packages/gossip/proto/message.pb.go | 35 +++-- packages/gossip/transport/handshake.go | 2 +- .../gossip/transport/proto/handshake.pb.go | 43 +++--- .../transactionspammer/transactionspammer.go | 2 +- plugins/autopeering/plugin.go | 2 +- plugins/metrics/plugin.go | 2 +- plugins/statusscreen-tps/plugin.go | 2 +- plugins/tangle/solidifier.go | 2 +- plugins/tangle/solidifier_test.go | 8 +- plugins/ui/ui.go | 2 +- 14 files changed, 211 insertions(+), 144 deletions(-) diff --git a/packages/gossip/errors.go b/packages/gossip/errors.go index 66a2a23e41..7be5d0fc55 100644 --- a/packages/gossip/errors.go +++ b/packages/gossip/errors.go @@ -4,5 +4,6 @@ import "github.com/pkg/errors" var ( ErrClosed = errors.New("manager closed") + ErrNotANeighbor = errors.New("peer is not a neighbor") ErrDuplicateNeighbor = errors.New("peer already connected") ) diff --git a/packages/gossip/events.go b/packages/gossip/events.go index e8f6642b96..7792214bcd 100644 --- a/packages/gossip/events.go +++ b/packages/gossip/events.go @@ -5,28 +5,40 @@ import ( "github.com/iotaledger/hive.go/events" ) -// Events contains all the events that are triggered during the gossip protocol. +// Events contains all the events related to the gossip protocol. var Events = struct { - // A NewTransaction event is triggered when a new transaction is received by the gossip protocol. - NewTransaction *events.Event - DropNeighbor *events.Event + // A TransactionReceived event is triggered when a new transaction is received by the gossip protocol. + TransactionReceived *events.Event + // A NeighborDropped event is triggered when a neighbor has been dropped. + NeighborDropped *events.Event + // A RequestTransaction should be triggered for a transaction to be requested through the gossip protocol. + RequestTransaction *events.Event }{ - NewTransaction: events.NewEvent(newTransaction), - DropNeighbor: events.NewEvent(dropNeighbor), + TransactionReceived: events.NewEvent(transactionReceived), + NeighborDropped: events.NewEvent(neighborDropped), + RequestTransaction: events.NewEvent(requestTransaction), } -type NewTransactionEvent struct { +type TransactionReceivedEvent struct { Body []byte Peer *peer.Peer } -type DropNeighborEvent struct { + +type RequestTransactionEvent struct { + Hash []byte // hash of the transaction to request +} +type NeighborDroppedEvent struct { Peer *peer.Peer } -func newTransaction(handler interface{}, params ...interface{}) { - handler.(func(*NewTransactionEvent))(params[0].(*NewTransactionEvent)) +func transactionReceived(handler interface{}, params ...interface{}) { + handler.(func(*TransactionReceivedEvent))(params[0].(*TransactionReceivedEvent)) +} + +func requestTransaction(handler interface{}, params ...interface{}) { + handler.(func(*RequestTransactionEvent))(params[0].(*RequestTransactionEvent)) } -func dropNeighbor(handler interface{}, params ...interface{}) { - handler.(func(*DropNeighborEvent))(params[0].(*DropNeighborEvent)) +func neighborDropped(handler interface{}, params ...interface{}) { + handler.(func(*NeighborDroppedEvent))(params[0].(*NeighborDroppedEvent)) } diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go index 7121f60db0..49c0e6b56d 100644 --- a/packages/gossip/manager.go +++ b/packages/gossip/manager.go @@ -49,28 +49,59 @@ func NewManager(t *transport.TCP, log *zap.SugaredLogger, f GetTransaction) *Man return m } +// Close stops the manager and closes all established connections. +func (m *Manager) Close() { + m.mu.Lock() + m.running = false + // close all connections + for _, n := range m.neighbors { + _ = n.conn.Close() + } + m.mu.Unlock() + + m.wg.Wait() +} + +// AddOutbound tries to add a neighbor by connecting to that peer. func (m *Manager) AddOutbound(p *peer.Peer) error { return m.addNeighbor(p, m.trans.DialPeer) } +// AddInbound tries to add a neighbor by accepting an incoming connection from that peer. func (m *Manager) AddInbound(p *peer.Peer) error { return m.addNeighbor(p, m.trans.AcceptPeer) } -func (m *Manager) DropNeighbor(p peer.ID) { - m.deleteNeighbor(p) +// NeighborDropped disconnects the neighbor with the given ID. +func (m *Manager) DropNeighbor(id peer.ID) error { + m.mu.Lock() + defer m.mu.Unlock() + if _, ok := m.neighbors[id]; !ok { + return ErrNotANeighbor + } + n := m.neighbors[id] + delete(m.neighbors, id) + disconnect(n.conn) + + return nil } -func (m *Manager) Close() { - m.mu.Lock() - m.running = false - // close all connections - for _, n := range m.neighbors { - _ = n.conn.Close() +// RequestTransaction requests the transaction with the given hash from the neighbors. +// If no peer is provided, all neighbors are queried. +func (m *Manager) RequestTransaction(txHash []byte, to ...peer.ID) { + req := &pb.TransactionRequest{ + Hash: txHash, } - m.mu.Unlock() + m.send(marshal(req), to...) +} - m.wg.Wait() +// SendTransaction sends the given transaction data to the neighbors. +// If no peer is provided, it is send to all neighbors. +func (m *Manager) SendTransaction(txData []byte, to ...peer.ID) { + tx := &pb.Transaction{ + Body: txData, + } + m.send(marshal(tx), to...) } func (m *Manager) getNeighbors(ids ...peer.ID) []*neighbor { @@ -105,21 +136,6 @@ func (m *Manager) getNeighborsById(ids []peer.ID) []*neighbor { return result } -func (m *Manager) RequestTransaction(txHash []byte, to ...peer.ID) { - req := &pb.TransactionRequest{ - Hash: txHash, - } - m.send(marshal(req), to...) -} - -// SendTransaction sends the transaction data to the given neighbors. -func (m *Manager) SendTransaction(txData []byte, to ...peer.ID) { - tx := &pb.Transaction{ - Body: txData, - } - m.send(marshal(tx), to...) -} - func (m *Manager) send(msg []byte, to ...peer.ID) { if l := len(msg); l > maxPacketSize { m.log.Errorw("message too large", "len", l, "max", maxPacketSize) @@ -150,7 +166,7 @@ func (m *Manager) addNeighbor(peer *peer.Peer, handshake func(*peer.Peer) (*tran // could not add neighbor if err != nil { m.log.Debugw("addNeighbor failed", "peer", peer.ID(), "err", err) - Events.DropNeighbor.Trigger(&DropNeighborEvent{Peer: peer}) + Events.NeighborDropped.Trigger(&NeighborDroppedEvent{Peer: peer}) return err } @@ -176,18 +192,6 @@ func (m *Manager) addNeighbor(peer *peer.Peer, handshake func(*peer.Peer) (*tran return nil } -func (m *Manager) deleteNeighbor(peer peer.ID) { - m.mu.Lock() - defer m.mu.Unlock() - if _, ok := m.neighbors[peer]; !ok { - return - } - - n := m.neighbors[peer] - delete(m.neighbors, peer) - disconnect(n.conn) -} - func (m *Manager) readLoop(nbr *neighbor) { m.wg.Add(1) defer m.wg.Done() @@ -207,7 +211,7 @@ func (m *Manager) readLoop(nbr *neighbor) { m.log.Warnw("read error", "err", err) } _ = nbr.conn.Close() // just make sure that the connection is closed as fast as possible - m.deleteNeighbor(nbr.peer.ID()) + _ = m.DropNeighbor(nbr.peer.ID()) m.log.Debug("reading stopped") return } @@ -228,7 +232,7 @@ func (m *Manager) handlePacket(data []byte, n *neighbor) error { return errors.Wrap(err, "invalid message") } m.log.Debugw("Received Transaction", "data", msg.GetBody()) - Events.NewTransaction.Trigger(&NewTransactionEvent{Body: msg.GetBody(), Peer: n.peer}) + Events.TransactionReceived.Trigger(&TransactionReceivedEvent{Body: msg.GetBody(), Peer: n.peer}) // Incoming Transaction request case pb.MTransactionRequest: @@ -267,5 +271,5 @@ func marshal(msg pb.Message) []byte { func disconnect(conn *transport.Connection) { _ = conn.Close() - Events.DropNeighbor.Trigger(&DropNeighborEvent{Peer: conn.Peer()}) + Events.NeighborDropped.Trigger(&NeighborDroppedEvent{Peer: conn.Peer()}) } diff --git a/packages/gossip/manager_test.go b/packages/gossip/manager_test.go index 5d4a1e6b8f..7674e2b281 100644 --- a/packages/gossip/manager_test.go +++ b/packages/gossip/manager_test.go @@ -6,11 +6,11 @@ import ( "testing" "time" + pb "github.com/iotaledger/goshimmer/packages/gossip/proto" + "github.com/iotaledger/goshimmer/packages/gossip/transport" "github.com/golang/protobuf/proto" "github.com/iotaledger/autopeering-sim/peer" "github.com/iotaledger/autopeering-sim/peer/service" - pb "github.com/iotaledger/goshimmer/packages/gossip/proto" - "github.com/iotaledger/goshimmer/packages/gossip/transport" "github.com/iotaledger/hive.go/events" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -27,8 +27,8 @@ var ( testTxData = []byte("testTx") ) -func newTransactionEvent(ev *NewTransactionEvent) { eventMock.Called(ev) } -func dropNeighborEvent(ev *DropNeighborEvent) { eventMock.Called(ev) } +func transactionReceivedEvent(ev *TransactionReceivedEvent) { eventMock.Called(ev) } +func neighborDroppedEvent(ev *NeighborDroppedEvent) { eventMock.Called(ev) } // assertEvents initializes the mock and asserts the expectations func assertEvents(t *testing.T) func() { @@ -47,9 +47,9 @@ func init() { } logger = l.Sugar() - // mock the events - Events.NewTransaction.Attach(events.NewClosure(newTransactionEvent)) - Events.DropNeighbor.Attach(events.NewClosure(dropNeighborEvent)) + // mock the events triggered by the gossip + Events.TransactionReceived.Attach(events.NewClosure(transactionReceivedEvent)) + Events.NeighborDropped.Attach(events.NewClosure(neighborDroppedEvent)) } func getTestTransaction([]byte) ([]byte, error) { @@ -101,24 +101,25 @@ func TestClosedConnection(t *testing.T) { // B -> A go func() { defer wg.Done() - err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) + err := mgrA.AddInbound(peerB) assert.NoError(t, err) }() time.Sleep(graceTime) go func() { defer wg.Done() - err := mgrB.addNeighbor(peerA, mgrB.trans.DialPeer) + err := mgrB.AddOutbound(peerA) assert.NoError(t, err) }() // wait for the connections to establish wg.Wait() - eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerA}).Once() - eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerB}).Once() + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Once() + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerB}).Once() // A drops B - mgrA.deleteNeighbor(peerB.ID()) + err := mgrA.NeighborDropped(peerB.ID()) + require.NoError(t, err) time.Sleep(graceTime) // the events should be there even before we close @@ -140,25 +141,25 @@ func TestP2PSend(t *testing.T) { // B -> A go func() { defer wg.Done() - err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) + err := mgrA.AddInbound(peerB) assert.NoError(t, err) }() time.Sleep(graceTime) go func() { defer wg.Done() - err := mgrB.addNeighbor(peerA, mgrB.trans.DialPeer) + err := mgrB.AddOutbound(peerA) assert.NoError(t, err) }() // wait for the connections to establish wg.Wait() - eventMock.On("newTransactionEvent", &NewTransactionEvent{ + eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ Body: testTxData, Peer: peerA, }).Once() - eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerA}).Once() - eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerB}).Once() + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Once() + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerB}).Once() mgrA.SendTransaction(testTxData) time.Sleep(graceTime) @@ -179,25 +180,25 @@ func TestP2PSendTwice(t *testing.T) { // B -> A go func() { defer wg.Done() - err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) + err := mgrA.AddInbound(peerB) assert.NoError(t, err) }() time.Sleep(graceTime) go func() { defer wg.Done() - err := mgrB.addNeighbor(peerA, mgrB.trans.DialPeer) + err := mgrB.AddOutbound(peerA) assert.NoError(t, err) }() // wait for the connections to establish wg.Wait() - eventMock.On("newTransactionEvent", &NewTransactionEvent{ + eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ Body: testTxData, Peer: peerA, }).Twice() - eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerA}).Once() - eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerB}).Once() + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Once() + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerB}).Once() mgrA.SendTransaction(testTxData) time.Sleep(1 * time.Second) // wait a bit between the sends, to test timeouts @@ -222,41 +223,94 @@ func TestBroadcast(t *testing.T) { // B -> A <- C go func() { defer wg.Done() - err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) + err := mgrA.AddInbound(peerB) assert.NoError(t, err) }() go func() { defer wg.Done() - err := mgrA.addNeighbor(peerC, mgrA.trans.AcceptPeer) + err := mgrA.AddInbound(peerC) assert.NoError(t, err) }() time.Sleep(graceTime) go func() { defer wg.Done() - err := mgrB.addNeighbor(peerA, mgrB.trans.DialPeer) + err := mgrB.AddOutbound(peerA) assert.NoError(t, err) }() go func() { defer wg.Done() - err := mgrC.addNeighbor(peerA, mgrC.trans.DialPeer) + err := mgrC.AddOutbound(peerA) assert.NoError(t, err) }() // wait for the connections to establish wg.Wait() - eventMock.On("newTransactionEvent", &NewTransactionEvent{ + eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ Body: testTxData, Peer: peerA, }).Twice() - eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerA}).Twice() - eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerB}).Once() - eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerC}).Once() + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Twice() + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerB}).Once() + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerC}).Once() mgrA.SendTransaction(testTxData) time.Sleep(graceTime) } +func TestSingleSend(t *testing.T) { + defer assertEvents(t)() + + mgrA, closeA, peerA := newTest(t, "A") + defer closeA() + mgrB, closeB, peerB := newTest(t, "B") + defer closeB() + mgrC, closeC, peerC := newTest(t, "C") + defer closeC() + + var wg sync.WaitGroup + wg.Add(4) + + // connect in the following way + // B -> A <- C + go func() { + defer wg.Done() + err := mgrA.AddInbound(peerB) + assert.NoError(t, err) + }() + go func() { + defer wg.Done() + err := mgrA.AddInbound(peerC) + assert.NoError(t, err) + }() + time.Sleep(graceTime) + go func() { + defer wg.Done() + err := mgrB.AddOutbound(peerA) + assert.NoError(t, err) + }() + go func() { + defer wg.Done() + err := mgrC.AddOutbound(peerA) + assert.NoError(t, err) + }() + + // wait for the connections to establish + wg.Wait() + + eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ + Body: testTxData, + Peer: peerA, + }).Once() + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Twice() + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerB}).Once() + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerC}).Once() + + // A sends the transaction only to B + mgrA.SendTransaction(testTxData, peerB.ID()) + time.Sleep(graceTime) +} + func TestDropUnsuccessfulAccept(t *testing.T) { defer assertEvents(t)() @@ -265,11 +319,11 @@ func TestDropUnsuccessfulAccept(t *testing.T) { _, closeB, peerB := newTest(t, "B") defer closeB() - eventMock.On("dropNeighborEvent", &DropNeighborEvent{ + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{ Peer: peerB, }).Once() - err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) + err := mgrA.AddInbound(peerB) assert.Error(t, err) } @@ -288,27 +342,29 @@ func TestTxRequest(t *testing.T) { // B -> A go func() { defer wg.Done() - err := mgrA.addNeighbor(peerB, mgrA.trans.AcceptPeer) + err := mgrA.AddInbound(peerB) assert.NoError(t, err) }() time.Sleep(graceTime) go func() { defer wg.Done() - err := mgrB.addNeighbor(peerA, mgrB.trans.DialPeer) + err := mgrB.AddOutbound(peerA) assert.NoError(t, err) }() // wait for the connections to establish wg.Wait() - eventMock.On("newTransactionEvent", &NewTransactionEvent{ + txHash := []byte("Hello!") + + eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ Body: testTxData, Peer: peerB, }).Once() - eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerA}).Once() - eventMock.On("dropNeighborEvent", &DropNeighborEvent{Peer: peerB}).Once() + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Once() + eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerB}).Once() - b, err := proto.Marshal(&pb.TransactionRequest{Hash: []byte("Hello!")}) + b, err := proto.Marshal(&pb.TransactionRequest{Hash: txHash}) require.NoError(t, err) mgrA.RequestTransaction(b) time.Sleep(graceTime) diff --git a/packages/gossip/proto/message.pb.go b/packages/gossip/proto/message.pb.go index df48ced344..b18bb7517d 100644 --- a/packages/gossip/proto/message.pb.go +++ b/packages/gossip/proto/message.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: packages/gossip/proto/message.proto +// source: proto/message.proto package proto @@ -32,7 +32,7 @@ func (m *Transaction) Reset() { *m = Transaction{} } func (m *Transaction) String() string { return proto.CompactTextString(m) } func (*Transaction) ProtoMessage() {} func (*Transaction) Descriptor() ([]byte, []int) { - return fileDescriptor_fcce9e84825f2fa5, []int{0} + return fileDescriptor_33f3a5e1293a7bcd, []int{0} } func (m *Transaction) XXX_Unmarshal(b []byte) error { @@ -72,7 +72,7 @@ func (m *TransactionRequest) Reset() { *m = TransactionRequest{} } func (m *TransactionRequest) String() string { return proto.CompactTextString(m) } func (*TransactionRequest) ProtoMessage() {} func (*TransactionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_fcce9e84825f2fa5, []int{1} + return fileDescriptor_33f3a5e1293a7bcd, []int{1} } func (m *TransactionRequest) XXX_Unmarshal(b []byte) error { @@ -105,20 +105,17 @@ func init() { proto.RegisterType((*TransactionRequest)(nil), "proto.TransactionRequest") } -func init() { - proto.RegisterFile("packages/gossip/proto/message.proto", fileDescriptor_fcce9e84825f2fa5) -} - -var fileDescriptor_fcce9e84825f2fa5 = []byte{ - // 157 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x8e, 0x31, 0x0b, 0xc2, 0x30, - 0x10, 0x46, 0x29, 0xa8, 0x43, 0x74, 0xca, 0xe4, 0xa8, 0x75, 0xe9, 0xd4, 0x0c, 0x22, 0xee, 0xfe, - 0x84, 0xe2, 0xe4, 0x76, 0x49, 0x8f, 0x24, 0x68, 0x7a, 0x31, 0x97, 0x0e, 0xfe, 0x7b, 0x49, 0x40, - 0x70, 0xe8, 0xf4, 0xbd, 0x0f, 0xde, 0xf0, 0xc4, 0x29, 0x82, 0x79, 0x82, 0x45, 0x56, 0x96, 0x98, - 0x7d, 0x54, 0x31, 0x51, 0x26, 0x15, 0x90, 0x19, 0x2c, 0xf6, 0xf5, 0xc9, 0x75, 0x9d, 0xf6, 0x28, - 0xb6, 0xf7, 0x04, 0x13, 0x83, 0xc9, 0x9e, 0x26, 0x29, 0xc5, 0x4a, 0xd3, 0xf8, 0xd9, 0x37, 0x87, - 0xa6, 0xdb, 0x0d, 0x95, 0xdb, 0x4e, 0xc8, 0x3f, 0x65, 0xc0, 0xf7, 0x8c, 0x9c, 0x8b, 0xe9, 0x80, - 0xdd, 0xcf, 0x2c, 0x7c, 0xbb, 0x3e, 0x2e, 0xd6, 0x67, 0x37, 0xeb, 0xde, 0x50, 0x50, 0x9e, 0x32, - 0xbc, 0x70, 0xb4, 0x98, 0x4a, 0x87, 0xf3, 0x21, 0x60, 0x52, 0x8b, 0x69, 0x7a, 0x53, 0xe7, 0xfc, - 0x0d, 0x00, 0x00, 0xff, 0xff, 0xd7, 0x71, 0x33, 0x9a, 0xba, 0x00, 0x00, 0x00, +func init() { proto.RegisterFile("proto/message.proto", fileDescriptor_33f3a5e1293a7bcd) } + +var fileDescriptor_33f3a5e1293a7bcd = []byte{ + // 137 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x12, 0x2e, 0x28, 0xca, 0x2f, + 0xc9, 0xd7, 0xcf, 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0xd5, 0x03, 0xf3, 0x84, 0x58, 0xc1, 0x94, + 0x92, 0x22, 0x17, 0x77, 0x48, 0x51, 0x62, 0x5e, 0x71, 0x62, 0x72, 0x49, 0x66, 0x7e, 0x9e, 0x90, + 0x10, 0x17, 0x4b, 0x52, 0x7e, 0x4a, 0xa5, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x4f, 0x10, 0x98, 0xad, + 0xa4, 0xc1, 0x25, 0x84, 0xa4, 0x24, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x04, 0xa4, 0x32, 0x23, + 0xb1, 0x38, 0x03, 0xa6, 0x12, 0xc4, 0x76, 0x52, 0x8e, 0x52, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, + 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0x4e, 0x2c, 0xc8, 0x2f, 0x2e, 0x4e, 0xcd, 0x49, 0xd5, 0x4f, + 0x07, 0xd2, 0x99, 0x05, 0xfa, 0x60, 0x1b, 0x93, 0xd8, 0xc0, 0x94, 0x31, 0x20, 0x00, 0x00, 0xff, + 0xff, 0x34, 0x46, 0xa5, 0x0f, 0x96, 0x00, 0x00, 0x00, } diff --git a/packages/gossip/transport/handshake.go b/packages/gossip/transport/handshake.go index e5e928c4e2..661443e8f6 100644 --- a/packages/gossip/transport/handshake.go +++ b/packages/gossip/transport/handshake.go @@ -4,9 +4,9 @@ import ( "bytes" "time" + pb "github.com/iotaledger/goshimmer/packages/gossip/transport/proto" "github.com/golang/protobuf/proto" "github.com/iotaledger/autopeering-sim/server" - pb "github.com/iotaledger/goshimmer/packages/gossip/transport/proto" ) const ( diff --git a/packages/gossip/transport/proto/handshake.pb.go b/packages/gossip/transport/proto/handshake.pb.go index 610f02b3b9..c7f3688734 100644 --- a/packages/gossip/transport/proto/handshake.pb.go +++ b/packages/gossip/transport/proto/handshake.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: packages/gossip/transport/proto/handshake.proto +// source: transport/proto/handshake.proto package proto @@ -38,7 +38,7 @@ func (m *HandshakeRequest) Reset() { *m = HandshakeRequest{} } func (m *HandshakeRequest) String() string { return proto.CompactTextString(m) } func (*HandshakeRequest) ProtoMessage() {} func (*HandshakeRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f9e96b60881ea276, []int{0} + return fileDescriptor_d7101ffe19b05443, []int{0} } func (m *HandshakeRequest) XXX_Unmarshal(b []byte) error { @@ -99,7 +99,7 @@ func (m *HandshakeResponse) Reset() { *m = HandshakeResponse{} } func (m *HandshakeResponse) String() string { return proto.CompactTextString(m) } func (*HandshakeResponse) ProtoMessage() {} func (*HandshakeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f9e96b60881ea276, []int{1} + return fileDescriptor_d7101ffe19b05443, []int{1} } func (m *HandshakeResponse) XXX_Unmarshal(b []byte) error { @@ -132,24 +132,21 @@ func init() { proto.RegisterType((*HandshakeResponse)(nil), "proto.HandshakeResponse") } -func init() { - proto.RegisterFile("packages/gossip/transport/proto/handshake.proto", fileDescriptor_f9e96b60881ea276) -} - -var fileDescriptor_f9e96b60881ea276 = []byte{ - // 219 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x8f, 0x31, 0x4f, 0xc3, 0x30, - 0x10, 0x85, 0x95, 0xb4, 0x50, 0x6a, 0x01, 0x02, 0x4f, 0x41, 0x62, 0x88, 0x3a, 0x65, 0x8a, 0x07, - 0x7e, 0x00, 0x82, 0xa9, 0xb3, 0x47, 0x16, 0x74, 0x6d, 0x8f, 0xd8, 0x2a, 0xf6, 0x39, 0x77, 0x57, - 0x7e, 0x3f, 0xc2, 0x52, 0x05, 0x1b, 0xd3, 0xbb, 0xf7, 0x6e, 0xf8, 0xf4, 0x19, 0x57, 0x60, 0x7f, - 0x84, 0x09, 0xc5, 0x4d, 0x24, 0x12, 0x8b, 0x53, 0x86, 0x2c, 0x85, 0x58, 0x5d, 0x61, 0x52, 0x72, - 0x01, 0xf2, 0x41, 0x02, 0x1c, 0x71, 0xac, 0xdd, 0x5e, 0xd4, 0xd8, 0x64, 0x73, 0xb7, 0x3d, 0x7f, - 0x3c, 0xce, 0x27, 0x14, 0xb5, 0x9d, 0x59, 0x7d, 0x21, 0x4b, 0xa4, 0xdc, 0x35, 0x7d, 0x33, 0xdc, - 0xf8, 0x73, 0xb5, 0xd6, 0x2c, 0x3f, 0x98, 0x52, 0xd7, 0xf6, 0xcd, 0xb0, 0xf6, 0xf5, 0xb6, 0xb7, - 0xa6, 0x55, 0xea, 0x16, 0x75, 0x69, 0x95, 0xec, 0xa3, 0x59, 0x6b, 0x4c, 0x28, 0x0a, 0xa9, 0x74, - 0xcb, 0xbe, 0x19, 0x16, 0xfe, 0x77, 0xd8, 0x8c, 0xe6, 0xfe, 0x0f, 0x4f, 0x0a, 0x65, 0x41, 0xfb, - 0x60, 0xae, 0x18, 0xe7, 0xf7, 0x00, 0x12, 0x2a, 0xf1, 0xda, 0xaf, 0x18, 0xe7, 0x2d, 0x48, 0x78, - 0x7d, 0x79, 0x7b, 0x9e, 0xa2, 0x86, 0xd3, 0x6e, 0xdc, 0x53, 0x72, 0x91, 0x14, 0x3e, 0xf1, 0x30, - 0x21, 0xff, 0x68, 0x86, 0x98, 0x12, 0xf2, 0x7f, 0xe6, 0xbb, 0xcb, 0x1a, 0x4f, 0xdf, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x2a, 0x53, 0xc3, 0xbb, 0x23, 0x01, 0x00, 0x00, +func init() { proto.RegisterFile("transport/proto/handshake.proto", fileDescriptor_d7101ffe19b05443) } + +var fileDescriptor_d7101ffe19b05443 = []byte{ + // 203 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x5c, 0x8f, 0x3f, 0x4b, 0x04, 0x31, + 0x10, 0xc5, 0xb9, 0x3f, 0x7a, 0xde, 0xa0, 0xa2, 0xa9, 0x22, 0x08, 0xca, 0x55, 0x82, 0xb8, 0x29, + 0xfc, 0x06, 0x56, 0x57, 0xa7, 0xb4, 0x91, 0xec, 0x3a, 0x6e, 0x82, 0x26, 0x93, 0xcd, 0x64, 0xfd, + 0xfc, 0x0e, 0x81, 0x45, 0xb1, 0x7a, 0xef, 0xf7, 0x0b, 0xe4, 0x25, 0x70, 0x57, 0x8b, 0x4b, 0x9c, + 0xa9, 0x54, 0x93, 0x0b, 0x55, 0x32, 0xde, 0xa5, 0x77, 0xf6, 0xee, 0x13, 0xbb, 0xc6, 0xea, 0xa4, + 0xc5, 0x21, 0xc1, 0xd5, 0x71, 0x39, 0xb1, 0x38, 0xcd, 0xc8, 0x55, 0x69, 0xd8, 0x7d, 0x63, 0xe1, + 0x40, 0x49, 0xaf, 0xee, 0x57, 0x0f, 0x17, 0x76, 0x41, 0xa5, 0x60, 0xfb, 0x51, 0x28, 0xea, 0xb5, + 0xe8, 0xbd, 0x6d, 0x5d, 0x5d, 0xc2, 0xba, 0x92, 0xde, 0x34, 0x23, 0x4d, 0xdd, 0xc2, 0xbe, 0x86, + 0x28, 0xf7, 0xb8, 0x98, 0xf5, 0x56, 0xf4, 0xc6, 0xfe, 0x8a, 0x43, 0x07, 0xd7, 0x7f, 0xf6, 0xe4, + 0x81, 0x89, 0x51, 0xdd, 0xc0, 0x59, 0xc1, 0xe9, 0xcd, 0x3b, 0xf6, 0x6d, 0xf1, 0xdc, 0xee, 0x84, + 0x8f, 0x82, 0x2f, 0x4f, 0xaf, 0x8f, 0x63, 0xa8, 0x7e, 0xee, 0xbb, 0x81, 0xa2, 0x19, 0x5c, 0x26, + 0x66, 0xfc, 0x42, 0x33, 0x4a, 0x86, 0x6c, 0xfe, 0xfd, 0xb2, 0x3f, 0x6d, 0xf1, 0xfc, 0x13, 0x00, + 0x00, 0xff, 0xff, 0x51, 0xe0, 0x08, 0xd0, 0xff, 0x00, 0x00, 0x00, } diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index 00866b8ab9..b8283e55dd 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -54,7 +54,7 @@ func Start(tps uint) { mtx := &pb.Transaction{Body: tx.MetaTransaction.GetBytes()} b, _ := proto.Marshal(mtx) - gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b, Peer: &local.INSTANCE.Peer}) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b, Peer: &local.INSTANCE.Peer}) if sentCounter >= tps { duration := time.Since(start) diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 6190e497f4..9168f07022 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -26,7 +26,7 @@ func run(plugin *node.Plugin) { } func configureLogging(plugin *node.Plugin) { - gossip.Events.DropNeighbor.Attach(events.NewClosure(func(ev *gossip.DropNeighborEvent) { + gossip.Events.NeighborDropped.Attach(events.NewClosure(func(ev *gossip.NeighborDroppedEvent) { log.Info("neighbor dropped: " + ev.Peer.Address() + " / " + ev.Peer.ID().String()) if Selection != nil { Selection.DropPeer(ev.Peer) diff --git a/plugins/metrics/plugin.go b/plugins/metrics/plugin.go index f51ac06b89..65a4418120 100644 --- a/plugins/metrics/plugin.go +++ b/plugins/metrics/plugin.go @@ -14,7 +14,7 @@ var PLUGIN = node.NewPlugin("Metrics", node.Enabled, configure, run) func configure(plugin *node.Plugin) { // increase received TPS counter whenever we receive a new transaction - gossip.Events.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) { increaseReceivedTPSCounter() })) + gossip.Events.TransactionReceived.Attach(events.NewClosure(func(_ *gossip.TransactionReceivedEvent) { increaseReceivedTPSCounter() })) } func run(plugin *node.Plugin) { diff --git a/plugins/statusscreen-tps/plugin.go b/plugins/statusscreen-tps/plugin.go index aac5ceff6e..7433b286a9 100644 --- a/plugins/statusscreen-tps/plugin.go +++ b/plugins/statusscreen-tps/plugin.go @@ -23,7 +23,7 @@ var receivedTps uint64 var solidTps uint64 var PLUGIN = node.NewPlugin("Statusscreen TPS", node.Enabled, func(plugin *node.Plugin) { - gossip.Events.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) { + gossip.Events.TransactionReceived.Attach(events.NewClosure(func(_ *gossip.TransactionReceivedEvent) { atomic.AddUint64(&receivedTpsCounter, 1) })) diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index addd5ee113..696a475052 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -29,7 +29,7 @@ func configureSolidifier(plugin *node.Plugin) { task.Return(nil) }, workerpool.WorkerCount(WORKER_COUNT), workerpool.QueueSize(10000)) - gossip.Events.NewTransaction.Attach(events.NewClosure(func(ev *gossip.NewTransactionEvent) { + gossip.Events.TransactionReceived.Attach(events.NewClosure(func(ev *gossip.TransactionReceivedEvent) { //log.Info("New Transaction", ev.Body) pTx := &pb.Transaction{} proto.Unmarshal(ev.Body, pTx) diff --git a/plugins/tangle/solidifier_test.go b/plugins/tangle/solidifier_test.go index 692e5ccdcc..5daf06e8a2 100644 --- a/plugins/tangle/solidifier_test.go +++ b/plugins/tangle/solidifier_test.go @@ -47,19 +47,19 @@ func TestSolidifier(t *testing.T) { wg.Add(4) tx := &pb.Transaction{Body: transaction1.MetaTransaction.GetBytes()} b, _ := proto.Marshal(tx) - gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b}) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b}) tx = &pb.Transaction{Body: transaction2.MetaTransaction.GetBytes()} b, _ = proto.Marshal(tx) - gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b}) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b}) tx = &pb.Transaction{Body: transaction3.MetaTransaction.GetBytes()} b, _ = proto.Marshal(tx) - gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b}) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b}) tx = &pb.Transaction{Body: transaction4.MetaTransaction.GetBytes()} b, _ = proto.Marshal(tx) - gossip.Events.NewTransaction.Trigger(&gossip.NewTransactionEvent{Body: b}) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b}) // wait until all are solid wg.Wait() diff --git a/plugins/ui/ui.go b/plugins/ui/ui.go index 555271ecb3..d75b958cde 100644 --- a/plugins/ui/ui.go +++ b/plugins/ui/ui.go @@ -34,7 +34,7 @@ func configure(plugin *node.Plugin) { return c.JSON(http.StatusOK, tpsQueue) }) - gossip.Events.NewTransaction.Attach(events.NewClosure(func(_ *gossip.NewTransactionEvent) { + gossip.Events.TransactionReceived.Attach(events.NewClosure(func(_ *gossip.TransactionReceivedEvent) { atomic.AddUint64(&receivedTpsCounter, 1) })) tangle.Events.TransactionSolid.Attach(events.NewClosure(func(_ *value_transaction.ValueTransaction) { From f04dda8941131534448ed8be86304e3dbce918dc Mon Sep 17 00:00:00 2001 From: capossele Date: Mon, 9 Dec 2019 10:56:21 +0000 Subject: [PATCH 028/184] :art: removes commented code --- main.go | 10 ---------- plugins/statusscreen/logger.go | 5 +++-- plugins/statusscreen/status_message.go | 3 ++- plugins/statusscreen/statusscreen.go | 2 +- plugins/statusscreen/ui_log_entry.go | 2 +- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/main.go b/main.go index 1f8fa01c4e..cb0803bb49 100644 --- a/main.go +++ b/main.go @@ -23,20 +23,10 @@ import ( ) func main() { - // go func() { - // if err := profiler.Start(profiler.Config{ - // Service: "race-service", - // ServiceVersion: "1.0", - // ProjectID: "premium-canyon-232915", // optional on GCP - // }); err != nil { - // log.Fatalf("Cannot start the profiler: %v", err) - // } - // }() node.Run( cli.PLUGIN, autopeering.PLUGIN, gossip.PLUGIN, - //gossip_on_solidification.PLUGIN, tangle.PLUGIN, bundleprocessor.PLUGIN, analysis.PLUGIN, diff --git a/plugins/statusscreen/logger.go b/plugins/statusscreen/logger.go index a32db7fdc7..871472bf48 100644 --- a/plugins/statusscreen/logger.go +++ b/plugins/statusscreen/logger.go @@ -1,11 +1,12 @@ package statusscreen import ( - "github.com/iotaledger/hive.go/logger" "time" + + "github.com/iotaledger/hive.go/logger" ) -func storeStatusMessage(logLevel logger.LogLevel, prefix string, message string, ) { +func storeStatusMessage(logLevel logger.LogLevel, prefix string, message string) { mutex.Lock() defer mutex.Unlock() messageLog = append(messageLog, &StatusMessage{ diff --git a/plugins/statusscreen/status_message.go b/plugins/statusscreen/status_message.go index 6ac60673c2..96ae34ee95 100644 --- a/plugins/statusscreen/status_message.go +++ b/plugins/statusscreen/status_message.go @@ -1,8 +1,9 @@ package statusscreen import ( - "github.com/iotaledger/hive.go/logger" "time" + + "github.com/iotaledger/hive.go/logger" ) type StatusMessage struct { diff --git a/plugins/statusscreen/statusscreen.go b/plugins/statusscreen/statusscreen.go index 93db9a1909..575a1b3bc9 100644 --- a/plugins/statusscreen/statusscreen.go +++ b/plugins/statusscreen/statusscreen.go @@ -1,7 +1,6 @@ package statusscreen import ( - "github.com/iotaledger/hive.go/logger" "io/ioutil" "os" "sync" @@ -10,6 +9,7 @@ import ( "github.com/gdamore/tcell" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" "github.com/rivo/tview" "golang.org/x/crypto/ssh/terminal" diff --git a/plugins/statusscreen/ui_log_entry.go b/plugins/statusscreen/ui_log_entry.go index 168d6d1f21..fc8db3a76d 100644 --- a/plugins/statusscreen/ui_log_entry.go +++ b/plugins/statusscreen/ui_log_entry.go @@ -2,9 +2,9 @@ package statusscreen import ( "fmt" - "github.com/iotaledger/hive.go/logger" "github.com/gdamore/tcell" + "github.com/iotaledger/hive.go/logger" "github.com/rivo/tview" ) From af4127ee646a412c1b3494a9f6a38cc79b39e258 Mon Sep 17 00:00:00 2001 From: capossele Date: Tue, 17 Dec 2019 12:00:10 +0000 Subject: [PATCH 029/184] :heavy_minus_sign: removes unused imports --- plugins/statusscreen/status_message.go | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/statusscreen/status_message.go b/plugins/statusscreen/status_message.go index 85e0aae030..96ae34ee95 100644 --- a/plugins/statusscreen/status_message.go +++ b/plugins/statusscreen/status_message.go @@ -1,7 +1,6 @@ package statusscreen import ( - "github.com/iotaledger/hive.go/logger" "time" "github.com/iotaledger/hive.go/logger" From e0bc9931281d41446a4974536febf0880f8afbb5 Mon Sep 17 00:00:00 2001 From: capossele Date: Tue, 17 Dec 2019 12:03:31 +0000 Subject: [PATCH 030/184] :arrow_up: updates dependencies --- go.mod | 9 ++++----- go.sum | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 5c82b7a62d..58f2604874 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 github.com/iotaledger/autopeering-sim v0.0.0-20191206234543-6bc473d306a9 - github.com/iotaledger/hive.go v0.0.0-20191208004610-567900b261bd + github.com/iotaledger/hive.go v0.0.0-20191215153041-f324513d92ce github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible github.com/lucasb-eyer/go-colorful v1.0.3 // indirect @@ -31,10 +31,9 @@ require ( go.uber.org/zap v1.13.0 golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect - golang.org/x/net v0.0.0-20191207000613-e7e4b65ae663 + golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect - golang.org/x/sys v0.0.0-20191206220618-eeba5f6aabab // indirect - golang.org/x/tools v0.0.0-20191206204035-259af5ff87bd // indirect - golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect + golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 // indirect + golang.org/x/tools v0.0.0-20191217033636-bbbf87ae2631 // indirect gopkg.in/yaml.v2 v2.2.7 // indirect ) diff --git a/go.sum b/go.sum index 41a838f9d3..67fe4cf700 100644 --- a/go.sum +++ b/go.sum @@ -101,8 +101,8 @@ github.com/iotaledger/autopeering-sim v0.0.0-20191206234543-6bc473d306a9/go.mod github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= -github.com/iotaledger/hive.go v0.0.0-20191208004610-567900b261bd h1:hh8iusLOBylWNHeJNiZv6atCbO7vzjCLlg53pNAMkFk= -github.com/iotaledger/hive.go v0.0.0-20191208004610-567900b261bd/go.mod h1:7iqun29a1x0lymTrn0UJ3Z/yy0sUzUpoOZ1OYMrYN20= +github.com/iotaledger/hive.go v0.0.0-20191215153041-f324513d92ce h1:+Tdo2OSZ8DCW97GuWLpGP0O64ExMYVnejfqXJZoadV8= +github.com/iotaledger/hive.go v0.0.0-20191215153041-f324513d92ce/go.mod h1:7iqun29a1x0lymTrn0UJ3Z/yy0sUzUpoOZ1OYMrYN20= github.com/iotaledger/iota.go v1.0.0-beta.7/go.mod h1:dMps6iMVU1pf5NDYNKIw4tRsPeC8W3ZWjOvYHOO1PMg= github.com/iotaledger/iota.go v1.0.0-beta.9 h1:c654s9pkdhMBkABUvWg+6k91MEBbdtmZXP1xDfQpajg= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= @@ -263,6 +263,7 @@ golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaE golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 h1:Gv7RPwsi3eZ2Fgewe3CBsuOebPwO27PoXzRpJPsvSSM= golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c h1:/nJuwDLoL/zrqY6gf57vxC+Pi+pZ8bfhpPkicO5H7W4= golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -272,6 +273,7 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f h1:J5lckAjkw6qYlOZNj90mLYNTEKDvWeuc1yieZ8qUzUE= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -284,8 +286,8 @@ golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191207000613-e7e4b65ae663 h1:Dd5RoEW+yQi+9DMybroBctIdyiwuNT7sJFMC27/6KxI= -golang.org/x/net v0.0.0-20191207000613-e7e4b65ae663/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -315,8 +317,8 @@ golang.org/x/sys v0.0.0-20191018095205-727590c5006e h1:ZtoklVMHQy6BFRHkbG6JzK+S6 golang.org/x/sys v0.0.0-20191018095205-727590c5006e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191206220618-eeba5f6aabab h1:FvshnhkKW+LO3HWHodML8kuVX8rnJTxKm9dFPuI68UM= -golang.org/x/sys v0.0.0-20191206220618-eeba5f6aabab/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 h1:gSbV7h1NRL2G1xTg/owz62CST1oJBmxy4QpMMregXVQ= +golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -332,8 +334,8 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191121040551-947d4aa89328 h1:t3X42h9e6xdbrCD/gPyWqAXr2BEpdJqRd1brThaaxII= golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191206204035-259af5ff87bd h1:Zc7EU2PqpsNeIfOoVA7hvQX4cS3YDJEs5KlfatT3hLo= -golang.org/x/tools v0.0.0-20191206204035-259af5ff87bd/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191217033636-bbbf87ae2631 h1:6/HU2wqgxuc1kG3FdVH8K60WlieDAlIYaVc21Cit9Us= +golang.org/x/tools v0.0.0-20191217033636-bbbf87ae2631/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= From 6faf3d7e74c1afa07b075b539970e83574a7ff6a Mon Sep 17 00:00:00 2001 From: capossele Date: Tue, 17 Dec 2019 12:09:19 +0000 Subject: [PATCH 031/184] :arrow_up: updates gossip --- packages/gossip/manager_test.go | 6 +++--- packages/gossip/transport/handshake.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/gossip/manager_test.go b/packages/gossip/manager_test.go index 7674e2b281..ea9ca56b98 100644 --- a/packages/gossip/manager_test.go +++ b/packages/gossip/manager_test.go @@ -6,11 +6,11 @@ import ( "testing" "time" - pb "github.com/iotaledger/goshimmer/packages/gossip/proto" - "github.com/iotaledger/goshimmer/packages/gossip/transport" "github.com/golang/protobuf/proto" "github.com/iotaledger/autopeering-sim/peer" "github.com/iotaledger/autopeering-sim/peer/service" + pb "github.com/iotaledger/goshimmer/packages/gossip/proto" + "github.com/iotaledger/goshimmer/packages/gossip/transport" "github.com/iotaledger/hive.go/events" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -118,7 +118,7 @@ func TestClosedConnection(t *testing.T) { eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerB}).Once() // A drops B - err := mgrA.NeighborDropped(peerB.ID()) + err := mgrA.DropNeighbor(peerB.ID()) require.NoError(t, err) time.Sleep(graceTime) diff --git a/packages/gossip/transport/handshake.go b/packages/gossip/transport/handshake.go index 661443e8f6..e5e928c4e2 100644 --- a/packages/gossip/transport/handshake.go +++ b/packages/gossip/transport/handshake.go @@ -4,9 +4,9 @@ import ( "bytes" "time" - pb "github.com/iotaledger/goshimmer/packages/gossip/transport/proto" "github.com/golang/protobuf/proto" "github.com/iotaledger/autopeering-sim/server" + pb "github.com/iotaledger/goshimmer/packages/gossip/transport/proto" ) const ( From 97172be5c2a8bbea14fc739119bc2d73e65f5868 Mon Sep 17 00:00:00 2001 From: capossele Date: Tue, 17 Dec 2019 12:28:07 +0000 Subject: [PATCH 032/184] :rotating_light: changes debug level --- .gitignore | 1 + plugins/autopeering/autopeering.go | 47 +++++++++++++++--------------- plugins/gossip/gossip.go | 4 +-- runNetwork.sh | 2 +- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 217c41d974..52422ce9cd 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ # Logs logs/* testNodes/* +*.log # Project files .idea diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index f980e91c83..7dc06d78d6 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -7,7 +7,6 @@ import ( "net" "net/http" "strconv" - "time" "github.com/iotaledger/autopeering-sim/discover" "github.com/iotaledger/autopeering-sim/logger" @@ -23,7 +22,7 @@ import ( ) var ( - debugLevel = "debug" + debugLevel = "info" close = make(chan struct{}, 1) srv *server.Server Discovery *discover.Protocol @@ -33,7 +32,7 @@ var ( const defaultZLC = `{ "level": "info", "development": false, - "outputPaths": ["stdout"], + "outputPaths": ["./autopeering.log"], "errorOutputPaths": ["stderr"], "encoding": "console", "encoderConfig": { @@ -151,12 +150,12 @@ func start() { }() // Only for debug - go func() { - for t := range time.NewTicker(2 * time.Second).C { - _ = t - printReport(zLogger) - } - }() + // go func() { + // for t := range time.NewTicker(2 * time.Second).C { + // _ = t + // printReport(zLogger) + // } + // }() <-close } @@ -176,18 +175,18 @@ func getMyIP() string { } // used only for debugging puropose -func printReport(log *zap.SugaredLogger) { - if Discovery == nil || Selection == nil { - return - } - knownPeers := Discovery.GetVerifiedPeers() - incoming := []*peer.Peer{} - outgoing := []*peer.Peer{} - if Selection != nil { - incoming = Selection.GetIncomingNeighbors() - outgoing = Selection.GetOutgoingNeighbors() - } - log.Info("Known peers:", len(knownPeers)) - log.Info("Chosen:", len(outgoing)) - log.Info("Accepted:", len(incoming)) -} +// func printReport(log *zap.SugaredLogger) { +// if Discovery == nil || Selection == nil { +// return +// } +// knownPeers := Discovery.GetVerifiedPeers() +// incoming := []*peer.Peer{} +// outgoing := []*peer.Peer{} +// if Selection != nil { +// incoming = Selection.GetIncomingNeighbors() +// outgoing = Selection.GetOutgoingNeighbors() +// } +// log.Info("Known peers:", len(knownPeers)) +// log.Info("Chosen:", len(outgoing)) +// log.Info("Accepted:", len(incoming)) +// } diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 48800c448a..64e5b77890 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -18,7 +18,7 @@ import ( const defaultZLC = `{ "level": "info", "development": false, - "outputPaths": ["stdout"], + "outputPaths": ["./gossip.log"], "errorOutputPaths": ["stderr"], "encoding": "console", "encoderConfig": { @@ -37,7 +37,7 @@ const defaultZLC = `{ }` var ( - debugLevel = "debug" + debugLevel = "info" zLogger *zap.SugaredLogger mgr *gp.Manager ) diff --git a/runNetwork.sh b/runNetwork.sh index a9e84ee51b..daa942e47e 100755 --- a/runNetwork.sh +++ b/runNetwork.sh @@ -27,6 +27,6 @@ for i in `seq 1 $1`; do mkdir node_$i/logs cp ../shimmer node_$i/ cd node_$i - ./shimmer --autopeering.port $PEERING_PORT --gossip.port $GOSSIP_PORT --autopeering.address 127.0.0.1 --autopeering.entryNodes 6rtO4nW2nzbSqZ8nrf0VFOn+fuyluf6ltJTkKpUc3LM=@127.0.0.1:14626 --node.LogLevel 4 --node.disablePlugins statusscreen --analysis.serverAddress 127.0.0.1:188 & + ./shimmer --autopeering.port $PEERING_PORT --gossip.port $GOSSIP_PORT --autopeering.address 127.0.0.1 --autopeering.entryNodes 2TwlC5mtYVrCHNKG8zkFWmEUlL0pJPS1DOOC2U4yjwo=@127.0.0.1:14626 --node.LogLevel 4 --node.disablePlugins statusscreen --analysis.serverAddress 127.0.0.1:188 & cd .. done \ No newline at end of file From 16c7e44dad9bd1b91c4c40df6526424164a763f0 Mon Sep 17 00:00:00 2001 From: capossele Date: Tue, 17 Dec 2019 14:03:11 +0000 Subject: [PATCH 033/184] :bug: listens on 0.0.0.0 if not on loopback --- packages/gossip/transport/transport.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/gossip/transport/transport.go b/packages/gossip/transport/transport.go index 791b8e310a..a948dd2316 100644 --- a/packages/gossip/transport/transport.go +++ b/packages/gossip/transport/transport.go @@ -84,7 +84,13 @@ func Listen(local *peer.Local, log *zap.SugaredLogger) (*TCP, error) { if gossipAddr == nil { return nil, ErrNoGossip } - tcpAddr, err := net.ResolveTCPAddr(gossipAddr.Network(), gossipAddr.String()) + + host, port, _ := net.SplitHostPort(gossipAddr.String()) + if host != "127.0.0.1" { + host = "0.0.0.0" + } + + tcpAddr, err := net.ResolveTCPAddr(gossipAddr.Network(), host+":"+port) if err != nil { return nil, err } From 6acec35f355646eeb98303038304715209505b47 Mon Sep 17 00:00:00 2001 From: capossele Date: Tue, 17 Dec 2019 20:28:24 +0000 Subject: [PATCH 034/184] :art: adds pubIP to the transport --- packages/gossip/transport/handshake.go | 2 +- packages/gossip/transport/transport.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/gossip/transport/handshake.go b/packages/gossip/transport/handshake.go index e5e928c4e2..2be73aaba0 100644 --- a/packages/gossip/transport/handshake.go +++ b/packages/gossip/transport/handshake.go @@ -56,7 +56,7 @@ func (t *TCP) validateHandshakeRequest(reqData []byte, fromAddr string) bool { ) return false } - if m.GetTo() != t.LocalAddr().String() { + if m.GetTo() != t.pubIP { t.log.Debugw("invalid handshake", "to", m.GetTo(), ) diff --git a/packages/gossip/transport/transport.go b/packages/gossip/transport/transport.go index a948dd2316..83fd6eddc2 100644 --- a/packages/gossip/transport/transport.go +++ b/packages/gossip/transport/transport.go @@ -41,6 +41,7 @@ const ( // TCP establishes verified incoming and outgoing TCP connections to other peers. type TCP struct { local *peer.Local + pubIP string listener *net.TCPListener log *zap.SugaredLogger @@ -85,6 +86,8 @@ func Listen(local *peer.Local, log *zap.SugaredLogger) (*TCP, error) { return nil, ErrNoGossip } + t.pubIP = gossipAddr.String() + host, port, _ := net.SplitHostPort(gossipAddr.String()) if host != "127.0.0.1" { host = "0.0.0.0" @@ -300,7 +303,10 @@ func (t *TCP) listenLoop() { } func (t *TCP) doHandshake(key peer.PublicKey, remoteAddr string, conn net.Conn) error { - reqData, err := newHandshakeRequest(conn.LocalAddr().String(), remoteAddr) + _, connPort, _ := net.SplitHostPort(conn.LocalAddr().String()) + from, _, _ := net.SplitHostPort(t.pubIP) + + reqData, err := newHandshakeRequest(from+":"+connPort, remoteAddr) if err != nil { return err } From cf8842a3276bf90e3fcb31d365b94d7b01b0909d Mon Sep 17 00:00:00 2001 From: capossele Date: Tue, 17 Dec 2019 20:30:39 +0000 Subject: [PATCH 035/184] :art: changes default entry node --- plugins/autopeering/parameters.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/autopeering/parameters.go b/plugins/autopeering/parameters.go index fdbe32a049..e5b2c7f291 100644 --- a/plugins/autopeering/parameters.go +++ b/plugins/autopeering/parameters.go @@ -13,7 +13,7 @@ const ( func init() { flag.String(CFG_ADDRESS, "0.0.0.0", "address to bind for incoming peering requests") - flag.String(CFG_ENTRY_NODES, "pub_Key@127.0.0.1:14626", "list of trusted entry nodes for auto peering") + flag.String(CFG_ENTRY_NODES, "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626", "list of trusted entry nodes for auto peering") flag.Int(CFG_PORT, 14626, "udp port for incoming peering requests") flag.Bool(CFG_SELECTION, true, "enable peer selection") } From a760ddc11c9955c90b123224f56e5fbd844049d8 Mon Sep 17 00:00:00 2001 From: capossele Date: Tue, 17 Dec 2019 20:31:45 +0000 Subject: [PATCH 036/184] :art: changes default analysis server --- plugins/analysis/client/parameters.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/analysis/client/parameters.go b/plugins/analysis/client/parameters.go index d66f647492..a60d143282 100644 --- a/plugins/analysis/client/parameters.go +++ b/plugins/analysis/client/parameters.go @@ -9,5 +9,5 @@ const ( ) func init() { - flag.String(CFG_SERVER_ADDRESS, "159.69.158.51:188", "tcp server for collecting analysis information") + flag.String(CFG_SERVER_ADDRESS, "ressims.iota.cafe:188", "tcp server for collecting analysis information") } From 3b59fd0fe0badbf82ca7af84159aa39c16cab3ce Mon Sep 17 00:00:00 2001 From: capossele Date: Wed, 18 Dec 2019 08:38:54 +0000 Subject: [PATCH 037/184] :art: adds pubAddr to the transport --- packages/gossip/transport/handshake.go | 2 +- packages/gossip/transport/transport.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/gossip/transport/handshake.go b/packages/gossip/transport/handshake.go index 2be73aaba0..a33b332966 100644 --- a/packages/gossip/transport/handshake.go +++ b/packages/gossip/transport/handshake.go @@ -56,7 +56,7 @@ func (t *TCP) validateHandshakeRequest(reqData []byte, fromAddr string) bool { ) return false } - if m.GetTo() != t.pubIP { + if m.GetTo() != t.pubAddr { t.log.Debugw("invalid handshake", "to", m.GetTo(), ) diff --git a/packages/gossip/transport/transport.go b/packages/gossip/transport/transport.go index 83fd6eddc2..61690e0fb0 100644 --- a/packages/gossip/transport/transport.go +++ b/packages/gossip/transport/transport.go @@ -41,7 +41,7 @@ const ( // TCP establishes verified incoming and outgoing TCP connections to other peers. type TCP struct { local *peer.Local - pubIP string + pubAddr string listener *net.TCPListener log *zap.SugaredLogger @@ -86,7 +86,7 @@ func Listen(local *peer.Local, log *zap.SugaredLogger) (*TCP, error) { return nil, ErrNoGossip } - t.pubIP = gossipAddr.String() + t.pubAddr = gossipAddr.String() host, port, _ := net.SplitHostPort(gossipAddr.String()) if host != "127.0.0.1" { @@ -304,7 +304,7 @@ func (t *TCP) listenLoop() { func (t *TCP) doHandshake(key peer.PublicKey, remoteAddr string, conn net.Conn) error { _, connPort, _ := net.SplitHostPort(conn.LocalAddr().String()) - from, _, _ := net.SplitHostPort(t.pubIP) + from, _, _ := net.SplitHostPort(t.pubAddr) reqData, err := newHandshakeRequest(from+":"+connPort, remoteAddr) if err != nil { From f18261cd3d75671888ac916e370e2856a4919f13 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 18 Dec 2019 12:34:18 +0100 Subject: [PATCH 038/184] Fix wrong fromAddr --- packages/gossip/manager_test.go | 17 ++++++- packages/gossip/transport/handshake.go | 15 +++---- .../gossip/transport/proto/handshake.pb.go | 41 +++++++---------- .../gossip/transport/proto/handshake.proto | 6 +-- packages/gossip/transport/transport.go | 44 ++++++++++--------- packages/gossip/transport/transport_test.go | 17 +++++-- 6 files changed, 75 insertions(+), 65 deletions(-) diff --git a/packages/gossip/manager_test.go b/packages/gossip/manager_test.go index ea9ca56b98..df9e83337b 100644 --- a/packages/gossip/manager_test.go +++ b/packages/gossip/manager_test.go @@ -2,6 +2,7 @@ package gossip import ( "log" + "net" "sync" "testing" "time" @@ -56,12 +57,26 @@ func getTestTransaction([]byte) ([]byte, error) { return testTxData, nil } +func getTCPAddress(t require.TestingT) string { + laddr, err := net.ResolveTCPAddr("tcp", "localhost:0") + require.NoError(t, err) + lis, err := net.ListenTCP("tcp", laddr) + require.NoError(t, err) + + addr := lis.Addr().String() + require.NoError(t, lis.Close()) + + return addr +} + func newTest(t require.TestingT, name string) (*Manager, func(), *peer.Peer) { l := logger.Named(name) db := peer.NewMemoryDB(l.Named("db")) local, err := peer.NewLocal("peering", name, db) require.NoError(t, err) - require.NoError(t, local.UpdateService(service.GossipKey, "tcp", "localhost:0")) + + // enable TCP gossipping + require.NoError(t, local.UpdateService(service.GossipKey, "tcp", getTCPAddress(t))) trans, err := transport.Listen(local, l) require.NoError(t, err) diff --git a/packages/gossip/transport/handshake.go b/packages/gossip/transport/handshake.go index a33b332966..3489a9d66a 100644 --- a/packages/gossip/transport/handshake.go +++ b/packages/gossip/transport/handshake.go @@ -19,10 +19,9 @@ func isExpired(ts int64) bool { return time.Since(time.Unix(ts, 0)) >= handshakeExpiration } -func newHandshakeRequest(fromAddr string, toAddr string) ([]byte, error) { +func newHandshakeRequest(toAddr string) ([]byte, error) { m := &pb.HandshakeRequest{ Version: versionNum, - From: fromAddr, To: toAddr, Timestamp: time.Now().Unix(), } @@ -36,7 +35,7 @@ func newHandshakeResponse(reqData []byte) ([]byte, error) { return proto.Marshal(m) } -func (t *TCP) validateHandshakeRequest(reqData []byte, fromAddr string) bool { +func (t *TCP) validateHandshakeRequest(reqData []byte) bool { m := new(pb.HandshakeRequest) if err := proto.Unmarshal(reqData, m); err != nil { t.log.Debugw("invalid handshake", @@ -47,18 +46,14 @@ func (t *TCP) validateHandshakeRequest(reqData []byte, fromAddr string) bool { if m.GetVersion() != versionNum { t.log.Debugw("invalid handshake", "version", m.GetVersion(), + "want", versionNum, ) return false } - if m.GetFrom() != fromAddr { - t.log.Debugw("invalid handshake", - "from", m.GetFrom(), - ) - return false - } - if m.GetTo() != t.pubAddr { + if m.GetTo() != t.publicAddr.String() { t.log.Debugw("invalid handshake", "to", m.GetTo(), + "want", t.publicAddr.String(), ) return false } diff --git a/packages/gossip/transport/proto/handshake.pb.go b/packages/gossip/transport/proto/handshake.pb.go index c7f3688734..da559c8190 100644 --- a/packages/gossip/transport/proto/handshake.pb.go +++ b/packages/gossip/transport/proto/handshake.pb.go @@ -23,12 +23,10 @@ const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type HandshakeRequest struct { // protocol version number Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` - // string form of the sender address (e.g. "192.0.2.1:25", "[2001:db8::1]:80") - From string `protobuf:"bytes,2,opt,name=from,proto3" json:"from,omitempty"` // string form of the recipient address - To string `protobuf:"bytes,3,opt,name=to,proto3" json:"to,omitempty"` + To string `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"` // unix time - Timestamp int64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Timestamp int64 `protobuf:"varint,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -66,13 +64,6 @@ func (m *HandshakeRequest) GetVersion() uint32 { return 0 } -func (m *HandshakeRequest) GetFrom() string { - if m != nil { - return m.From - } - return "" -} - func (m *HandshakeRequest) GetTo() string { if m != nil { return m.To @@ -135,18 +126,18 @@ func init() { func init() { proto.RegisterFile("transport/proto/handshake.proto", fileDescriptor_d7101ffe19b05443) } var fileDescriptor_d7101ffe19b05443 = []byte{ - // 203 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x5c, 0x8f, 0x3f, 0x4b, 0x04, 0x31, - 0x10, 0xc5, 0xb9, 0x3f, 0x7a, 0xde, 0xa0, 0xa2, 0xa9, 0x22, 0x08, 0xca, 0x55, 0x82, 0xb8, 0x29, - 0xfc, 0x06, 0x56, 0x57, 0xa7, 0xb4, 0x91, 0xec, 0x3a, 0x6e, 0x82, 0x26, 0x93, 0xcd, 0x64, 0xfd, - 0xfc, 0x0e, 0x81, 0x45, 0xb1, 0x7a, 0xef, 0xf7, 0x0b, 0xe4, 0x25, 0x70, 0x57, 0x8b, 0x4b, 0x9c, - 0xa9, 0x54, 0x93, 0x0b, 0x55, 0x32, 0xde, 0xa5, 0x77, 0xf6, 0xee, 0x13, 0xbb, 0xc6, 0xea, 0xa4, - 0xc5, 0x21, 0xc1, 0xd5, 0x71, 0x39, 0xb1, 0x38, 0xcd, 0xc8, 0x55, 0x69, 0xd8, 0x7d, 0x63, 0xe1, - 0x40, 0x49, 0xaf, 0xee, 0x57, 0x0f, 0x17, 0x76, 0x41, 0xa5, 0x60, 0xfb, 0x51, 0x28, 0xea, 0xb5, - 0xe8, 0xbd, 0x6d, 0x5d, 0x5d, 0xc2, 0xba, 0x92, 0xde, 0x34, 0x23, 0x4d, 0xdd, 0xc2, 0xbe, 0x86, - 0x28, 0xf7, 0xb8, 0x98, 0xf5, 0x56, 0xf4, 0xc6, 0xfe, 0x8a, 0x43, 0x07, 0xd7, 0x7f, 0xf6, 0xe4, - 0x81, 0x89, 0x51, 0xdd, 0xc0, 0x59, 0xc1, 0xe9, 0xcd, 0x3b, 0xf6, 0x6d, 0xf1, 0xdc, 0xee, 0x84, - 0x8f, 0x82, 0x2f, 0x4f, 0xaf, 0x8f, 0x63, 0xa8, 0x7e, 0xee, 0xbb, 0x81, 0xa2, 0x19, 0x5c, 0x26, - 0x66, 0xfc, 0x42, 0x33, 0x4a, 0x86, 0x6c, 0xfe, 0xfd, 0xb2, 0x3f, 0x6d, 0xf1, 0xfc, 0x13, 0x00, - 0x00, 0xff, 0xff, 0x51, 0xe0, 0x08, 0xd0, 0xff, 0x00, 0x00, 0x00, + // 206 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x5c, 0x8f, 0x31, 0x4b, 0x83, 0x31, + 0x10, 0x86, 0x69, 0x8b, 0xd6, 0x06, 0x15, 0xcd, 0xf4, 0x09, 0x82, 0xd2, 0xc9, 0xe9, 0xcb, 0xe0, + 0x0f, 0x10, 0x9d, 0x3a, 0x67, 0xec, 0x22, 0xd7, 0xf6, 0x48, 0x42, 0x4d, 0x2e, 0xcd, 0x5d, 0xfd, + 0xfd, 0x9e, 0x81, 0xa2, 0x74, 0x7a, 0xdf, 0xe7, 0x09, 0x79, 0x49, 0xcc, 0x93, 0x34, 0x28, 0x5c, + 0xa9, 0x89, 0xab, 0x8d, 0x84, 0x5c, 0x84, 0xb2, 0xe3, 0x08, 0x7b, 0x1c, 0x3b, 0xdb, 0x8b, 0x1e, + 0xcb, 0xb5, 0xb9, 0x5b, 0x9d, 0x4e, 0x3c, 0x1e, 0x8e, 0xc8, 0x62, 0x07, 0x33, 0xff, 0xc6, 0xc6, + 0x89, 0xca, 0x30, 0x79, 0x9e, 0xbc, 0xdc, 0xf8, 0x13, 0xda, 0x5b, 0x33, 0x15, 0x1a, 0xa6, 0x2a, + 0x17, 0x5e, 0x9b, 0x7d, 0x34, 0x0b, 0x49, 0x59, 0xef, 0x40, 0xae, 0xc3, 0x4c, 0xf5, 0xcc, 0xff, + 0x89, 0xe5, 0x68, 0xee, 0xff, 0x6d, 0xeb, 0x63, 0x0a, 0xa3, 0x7d, 0x30, 0x57, 0x0d, 0x0f, 0x9f, + 0x11, 0x38, 0xf6, 0xf5, 0x6b, 0x3f, 0x57, 0x5e, 0x29, 0x7e, 0xbc, 0xaf, 0xdf, 0x42, 0x92, 0x78, + 0xdc, 0x8c, 0x5b, 0xca, 0x2e, 0x91, 0xc0, 0x17, 0xee, 0x02, 0x36, 0x17, 0x88, 0x63, 0xca, 0x59, + 0x5b, 0x85, 0xed, 0x1e, 0x02, 0xf2, 0xaf, 0xe2, 0x54, 0xdd, 0xd9, 0x2f, 0x37, 0x97, 0x3d, 0x5e, + 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x51, 0x6a, 0x20, 0xf4, 0xff, 0x00, 0x00, 0x00, } diff --git a/packages/gossip/transport/proto/handshake.proto b/packages/gossip/transport/proto/handshake.proto index 68537177d9..c2242c270f 100644 --- a/packages/gossip/transport/proto/handshake.proto +++ b/packages/gossip/transport/proto/handshake.proto @@ -7,12 +7,10 @@ package proto; message HandshakeRequest { // protocol version number uint32 version = 1; - // string form of the sender address (e.g. "192.0.2.1:25", "[2001:db8::1]:80") - string from = 2; // string form of the recipient address - string to = 3; + string to = 2; // unix time - int64 timestamp = 4; + int64 timestamp = 3; } message HandshakeResponse { diff --git a/packages/gossip/transport/transport.go b/packages/gossip/transport/transport.go index 61690e0fb0..e379f00138 100644 --- a/packages/gossip/transport/transport.go +++ b/packages/gossip/transport/transport.go @@ -40,10 +40,10 @@ const ( // TCP establishes verified incoming and outgoing TCP connections to other peers. type TCP struct { - local *peer.Local - pubAddr string - listener *net.TCPListener - log *zap.SugaredLogger + local *peer.Local + publicAddr net.Addr + listener *net.TCPListener + log *zap.SugaredLogger addAcceptMatcher chan *acceptMatcher acceptReceived chan accept @@ -81,27 +81,32 @@ func Listen(local *peer.Local, log *zap.SugaredLogger) (*TCP, error) { closing: make(chan struct{}), } - gossipAddr := local.Services().Get(service.GossipKey) - if gossipAddr == nil { + t.publicAddr = local.Services().Get(service.GossipKey) + if t.publicAddr == nil { return nil, ErrNoGossip } - - t.pubAddr = gossipAddr.String() - - host, port, _ := net.SplitHostPort(gossipAddr.String()) - if host != "127.0.0.1" { - host = "0.0.0.0" - } - - tcpAddr, err := net.ResolveTCPAddr(gossipAddr.Network(), host+":"+port) + tcpAddr, err := net.ResolveTCPAddr(t.publicAddr.Network(), t.publicAddr.String()) if err != nil { return nil, err } - listener, err := net.ListenTCP(gossipAddr.Network(), tcpAddr) + // if the ip is an external ip, set it to zero + if tcpAddr.IP.IsGlobalUnicast() { + if len(tcpAddr.IP) == net.IPv4len { + tcpAddr.IP = net.IPv4zero + } else if len(tcpAddr.IP) == net.IPv6len { + tcpAddr.IP = net.IPv6zero + } + } + + listener, err := net.ListenTCP(t.publicAddr.Network(), tcpAddr) if err != nil { return nil, err } t.listener = listener + t.log.Debugw("listening started", + "network", listener.Addr().Network(), + "address", listener.Addr().String(), + ) t.wg.Add(2) go t.run() @@ -303,10 +308,7 @@ func (t *TCP) listenLoop() { } func (t *TCP) doHandshake(key peer.PublicKey, remoteAddr string, conn net.Conn) error { - _, connPort, _ := net.SplitHostPort(conn.LocalAddr().String()) - from, _, _ := net.SplitHostPort(t.pubAddr) - - reqData, err := newHandshakeRequest(from+":"+connPort, remoteAddr) + reqData, err := newHandshakeRequest(remoteAddr) if err != nil { return err } @@ -377,7 +379,7 @@ func (t *TCP) readHandshakeRequest(conn net.Conn) (peer.PublicKey, []byte, error return nil, nil, err } - if !t.validateHandshakeRequest(pkt.GetData(), conn.RemoteAddr().String()) { + if !t.validateHandshakeRequest(pkt.GetData()) { return nil, nil, ErrInvalidHandshake } diff --git a/packages/gossip/transport/transport_test.go b/packages/gossip/transport/transport_test.go index 51b64b8143..7c1fecf632 100644 --- a/packages/gossip/transport/transport_test.go +++ b/packages/gossip/transport/transport_test.go @@ -26,6 +26,18 @@ func init() { logger = l.Sugar() } +func getTCPAddress(t require.TestingT) string { + laddr, err := net.ResolveTCPAddr("tcp", "localhost:0") + require.NoError(t, err) + lis, err := net.ListenTCP("tcp", laddr) + require.NoError(t, err) + + addr := lis.Addr().String() + require.NoError(t, lis.Close()) + + return addr +} + func newTest(t require.TestingT, name string) (*TCP, func()) { l := logger.Named(name) db := peer.NewMemoryDB(l.Named("db")) @@ -33,14 +45,11 @@ func newTest(t require.TestingT, name string) (*TCP, func()) { require.NoError(t, err) // enable TCP gossipping - require.NoError(t, local.UpdateService(service.GossipKey, "tcp", "localhost:0")) + require.NoError(t, local.UpdateService(service.GossipKey, "tcp", getTCPAddress(t))) trans, err := Listen(local, l) require.NoError(t, err) - // update the service with the actual address - require.NoError(t, local.UpdateService(service.GossipKey, trans.LocalAddr().Network(), trans.LocalAddr().String())) - teardown := func() { trans.Close() db.Close() From adf5f02a6b148a1a17a4f2b8ad1d3945e6d457fa Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 18 Dec 2019 12:57:26 +0100 Subject: [PATCH 039/184] Fix check for IPv4/IPv6 --- packages/gossip/transport/transport.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/gossip/transport/transport.go b/packages/gossip/transport/transport.go index e379f00138..54794a631f 100644 --- a/packages/gossip/transport/transport.go +++ b/packages/gossip/transport/transport.go @@ -91,9 +91,9 @@ func Listen(local *peer.Local, log *zap.SugaredLogger) (*TCP, error) { } // if the ip is an external ip, set it to zero if tcpAddr.IP.IsGlobalUnicast() { - if len(tcpAddr.IP) == net.IPv4len { + if tcpAddr.IP.To4() != nil { tcpAddr.IP = net.IPv4zero - } else if len(tcpAddr.IP) == net.IPv6len { + } else { tcpAddr.IP = net.IPv6zero } } From 39a918a8ace120d30e36e72385507737df631125 Mon Sep 17 00:00:00 2001 From: capossele Date: Wed, 18 Dec 2019 14:53:57 +0000 Subject: [PATCH 040/184] :sparkles: adds unsolid tx request --- plugins/gossip/gossip.go | 18 +++++++--- plugins/tangle/solidifier.go | 52 ++++++++++++++++++++++++---- plugins/tangle/solidifier_test.go | 17 ++++++++-- plugins/tangle/unsolidTxs.go | 56 +++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+), 13 deletions(-) create mode 100644 plugins/tangle/unsolidTxs.go diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 64e5b77890..2d549ce97b 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -5,6 +5,7 @@ import ( zL "github.com/iotaledger/autopeering-sim/logger" "github.com/iotaledger/autopeering-sim/peer/service" "github.com/iotaledger/autopeering-sim/selection" + "github.com/iotaledger/goshimmer/packages/gossip" gp "github.com/iotaledger/goshimmer/packages/gossip" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/gossip/transport" @@ -43,10 +44,14 @@ var ( ) func getTransaction(h []byte) ([]byte, error) { - tx := &pb.TransactionRequest{ - Hash: []byte("testTx"), + tx, err := tangle.GetTransaction(string(h)) + if err != nil { + return []byte{}, err + } + pTx := &pb.TransactionRequest{ + Hash: tx.GetBytes(), } - b, _ := proto.Marshal(tx) + b, _ := proto.Marshal(pTx) return b, nil } @@ -87,7 +92,7 @@ func configureEvents() { })) tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { - log.Info("Tx solidified") + log.Info("Tx solidified:", tx.MetaTransaction.GetBytes()) t := &pb.Transaction{ Body: tx.MetaTransaction.GetBytes(), } @@ -97,4 +102,9 @@ func configureEvents() { } go mgr.SendTransaction(b) })) + + gossip.Events.RequestTransaction.Attach(events.NewClosure(func(ev *gossip.RequestTransactionEvent) { + log.Info("Tx Requested:", ev.Hash) + go mgr.RequestTransaction(ev.Hash) + })) } diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index 696a475052..f799848033 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -2,6 +2,7 @@ package tangle import ( "runtime" + "time" "github.com/golang/protobuf/proto" "github.com/iotaledger/goshimmer/packages/errors" @@ -20,7 +21,12 @@ import ( // region plugin module setup ////////////////////////////////////////////////////////////////////////////////////////// -var workerPool *workerpool.WorkerPool +const UnsolidInterval = 30 + +var ( + workerPool *workerpool.WorkerPool + unsolidTxs *UnsolidTxs +) func configureSolidifier(plugin *node.Plugin) { workerPool = workerpool.New(func(task workerpool.Task) { @@ -29,6 +35,8 @@ func configureSolidifier(plugin *node.Plugin) { task.Return(nil) }, workerpool.WorkerCount(WORKER_COUNT), workerpool.QueueSize(10000)) + unsolidTxs = NewUnsolidTxs() + gossip.Events.TransactionReceived.Attach(events.NewClosure(func(ev *gossip.TransactionReceivedEvent) { //log.Info("New Transaction", ev.Body) pTx := &pb.Transaction{} @@ -77,10 +85,16 @@ func checkSolidity(transaction *value_transaction.ValueTransaction) (result bool return } else if branchTransaction == nil { + //log.Info("Missing Branch (nil)", transaction.GetValue(), "Missing ", transaction.GetBranchTransactionHash()) + + // add BranchTransactionHash to the unsolid txs and send a transaction request + unsolidTxs.Add(transaction.GetBranchTransactionHash()) + requestTransaction(transaction.GetBranchTransactionHash()) + return } else if branchTransactionMetadata, branchErr := GetTransactionMetadata(branchTransaction.GetHash(), transactionmetadata.New); branchErr != nil { err = branchErr - + //log.Info("Missing Branch", transaction.GetValue()) return } else if !branchTransactionMetadata.GetSolid() { return @@ -94,10 +108,16 @@ func checkSolidity(transaction *value_transaction.ValueTransaction) (result bool return } else if trunkTransaction == nil { + //log.Info("Missing Trunk (nil)", transaction.GetValue()) + + // add TrunkTransactionHash to the unsolid txs and send a transaction request + unsolidTxs.Add(transaction.GetTrunkTransactionHash()) + requestTransaction(transaction.GetTrunkTransactionHash()) + return } else if trunkTransactionMetadata, trunkErr := GetTransactionMetadata(trunkTransaction.GetHash(), transactionmetadata.New); trunkErr != nil { err = trunkErr - + //log.Info("Missing Trunk", transaction.GetValue()) return } else if !trunkTransactionMetadata.GetSolid() { return @@ -119,11 +139,13 @@ func IsSolid(transaction *value_transaction.ValueTransaction) (bool, errors.Iden if isSolid, err := checkSolidity(transaction); err != nil { return false, err } else if isSolid { + //log.Info("Solid ", transaction.GetValue()) if err := propagateSolidity(transaction.GetHash()); err != nil { - return false, err + return false, err //should we return true? } + return true, nil } - + //log.Info("Not solid ", transaction.GetValue()) return false, nil } @@ -158,6 +180,7 @@ func processMetaTransaction(plugin *node.Plugin, metaTransaction *meta_transacti }); err != nil { log.Errorf("Unable to load transaction %s: %s", metaTransaction.GetHash(), err.Error()) } else if newTransaction { + updateUnsolidTxs(tx) processTransaction(plugin, tx) } } @@ -184,10 +207,27 @@ func processTransaction(plugin *node.Plugin, transaction *value_transaction.Valu } // update the solidity flags of this transaction and its approvers - if _, err := IsSolid(transaction); err != nil { + _, err := IsSolid(transaction) + if err != nil { log.Errorf("Unable to check solidity: %s", err.Error()) return } } +func updateUnsolidTxs(tx *value_transaction.ValueTransaction) { + unsolidTxs.Remove(tx.GetHash()) + targetTime := time.Now().Add(time.Duration(-UnsolidInterval) * time.Second) + txs := unsolidTxs.Update(targetTime) + for _, tx := range txs { + requestTransaction(tx) + } +} + +func requestTransaction(tx string) { + log.Info("Requesting tx: ", tx) + req := &pb.TransactionRequest{Hash: []byte(tx)} + b, _ := proto.Marshal(req) + gossip.Events.RequestTransaction.Trigger(&gossip.RequestTransactionEvent{Hash: b}) +} + var WORKER_COUNT = runtime.NumCPU() diff --git a/plugins/tangle/solidifier_test.go b/plugins/tangle/solidifier_test.go index 5daf06e8a2..263294f59e 100644 --- a/plugins/tangle/solidifier_test.go +++ b/plugins/tangle/solidifier_test.go @@ -31,18 +31,28 @@ func TestSolidifier(t *testing.T) { transaction1 := value_transaction.New() transaction1.SetNonce(trinary.Trytes("99999999999999999999999999A")) transaction2 := value_transaction.New() + transaction2.SetValue(2) transaction2.SetBranchTransactionHash(transaction1.GetHash()) transaction3 := value_transaction.New() + transaction3.SetValue(3) transaction3.SetBranchTransactionHash(transaction2.GetHash()) transaction4 := value_transaction.New() + transaction4.SetValue(4) transaction4.SetBranchTransactionHash(transaction3.GetHash()) // setup event handlers var wg sync.WaitGroup Events.TransactionSolid.Attach(events.NewClosure(func(transaction *value_transaction.ValueTransaction) { + t.Log("Tx solidified", transaction.GetValue()) wg.Done() })) + gossip.Events.RequestTransaction.Attach(events.NewClosure(func(ev *gossip.RequestTransactionEvent) { + tx := &pb.Transaction{Body: transaction3.MetaTransaction.GetBytes()} + b, _ := proto.Marshal(tx) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b}) + })) + // issue transactions wg.Add(4) tx := &pb.Transaction{Body: transaction1.MetaTransaction.GetBytes()} @@ -53,9 +63,9 @@ func TestSolidifier(t *testing.T) { b, _ = proto.Marshal(tx) gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b}) - tx = &pb.Transaction{Body: transaction3.MetaTransaction.GetBytes()} - b, _ = proto.Marshal(tx) - gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b}) + // tx = &pb.Transaction{Body: transaction3.MetaTransaction.GetBytes()} + // b, _ = proto.Marshal(tx) + // gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b}) tx = &pb.Transaction{Body: transaction4.MetaTransaction.GetBytes()} b, _ = proto.Marshal(tx) @@ -66,4 +76,5 @@ func TestSolidifier(t *testing.T) { // shutdown test node node.Shutdown() + } diff --git a/plugins/tangle/unsolidTxs.go b/plugins/tangle/unsolidTxs.go new file mode 100644 index 0000000000..631da933af --- /dev/null +++ b/plugins/tangle/unsolidTxs.go @@ -0,0 +1,56 @@ +package tangle + +import ( + "sync" + "time" +) + +type UnsolidTxs struct { + internal map[string]Info + sync.RWMutex +} + +type Info struct { + lastRequest time.Time + counter int +} + +func NewUnsolidTxs() *UnsolidTxs { + return &UnsolidTxs{ + internal: make(map[string]Info), + } +} + +func (u *UnsolidTxs) Add(hash string) { + u.Lock() + info := Info{ + lastRequest: time.Now(), + counter: 1, + } + u.internal[hash] = info + u.Unlock() +} + +func (u *UnsolidTxs) Remove(hash string) { + u.Lock() + if _, exists := u.internal[hash]; !exists { + delete(u.internal, hash) + } + u.Unlock() +} + +func (u *UnsolidTxs) Update(targetTime time.Time) (result []string) { + u.Lock() + for k, v := range u.internal { + if v.lastRequest.Before(targetTime) { + result = append(result, k) + + v.lastRequest = time.Now() + v.counter++ + + u.internal[k] = v + } + } + u.Unlock() + return result +} From fcc949a5b20d1be2b3a6ebb7022ab9abb28335e7 Mon Sep 17 00:00:00 2001 From: capossele Date: Wed, 18 Dec 2019 15:40:17 +0000 Subject: [PATCH 041/184] :bug: fixes unmarshaling of tx hash --- plugins/gossip/gossip.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 2d549ce97b..4691f4e551 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -1,6 +1,8 @@ package gossip import ( + "errors" + "github.com/golang/protobuf/proto" zL "github.com/iotaledger/autopeering-sim/logger" "github.com/iotaledger/autopeering-sim/peer/service" @@ -44,9 +46,10 @@ var ( ) func getTransaction(h []byte) ([]byte, error) { + log.Info("Retrieving tx:", string(h)) tx, err := tangle.GetTransaction(string(h)) - if err != nil { - return []byte{}, err + if err != nil || tx == nil { + return []byte{}, errors.New("Not found") } pTx := &pb.TransactionRequest{ Hash: tx.GetBytes(), @@ -92,7 +95,7 @@ func configureEvents() { })) tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { - log.Info("Tx solidified:", tx.MetaTransaction.GetBytes()) + log.Info("Tx solidified:", tx.MetaTransaction.GetHash()) t := &pb.Transaction{ Body: tx.MetaTransaction.GetBytes(), } @@ -104,7 +107,9 @@ func configureEvents() { })) gossip.Events.RequestTransaction.Attach(events.NewClosure(func(ev *gossip.RequestTransactionEvent) { - log.Info("Tx Requested:", ev.Hash) - go mgr.RequestTransaction(ev.Hash) + pTx := &pb.TransactionRequest{} + proto.Unmarshal(ev.Hash, pTx) + log.Info("Tx Requested:", string(pTx.Hash)) + go mgr.RequestTransaction(pTx.Hash) })) } From 4114edaa267a72f2b3eba31b351ca69acc31514e Mon Sep 17 00:00:00 2001 From: capossele Date: Wed, 18 Dec 2019 16:33:44 +0000 Subject: [PATCH 042/184] :art: fixes getTransaction error handling --- plugins/gossip/gossip.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 4691f4e551..12045c6369 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -48,7 +48,10 @@ var ( func getTransaction(h []byte) ([]byte, error) { log.Info("Retrieving tx:", string(h)) tx, err := tangle.GetTransaction(string(h)) - if err != nil || tx == nil { + if err != nil { + return []byte{}, err + } + if tx == nil { return []byte{}, errors.New("Not found") } pTx := &pb.TransactionRequest{ From c534f236ba772438fb1fd4a059470e1343f813f5 Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 19 Dec 2019 09:20:02 +0000 Subject: [PATCH 043/184] :bug: fix data race on recorded events --- .../webinterface/recordedevents/recorded_events.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/analysis/webinterface/recordedevents/recorded_events.go b/plugins/analysis/webinterface/recordedevents/recorded_events.go index c31574b8cf..ae6a5597c0 100644 --- a/plugins/analysis/webinterface/recordedevents/recorded_events.go +++ b/plugins/analysis/webinterface/recordedevents/recorded_events.go @@ -16,13 +16,11 @@ var lock sync.Mutex func Configure(plugin *node.Plugin) { server.Events.AddNode.Attach(events.NewClosure(func(nodeId string) { - if _, exists := nodes[nodeId]; !exists { - lock.Lock() - defer lock.Unlock() + lock.Lock() + defer lock.Unlock() - if _, exists := nodes[nodeId]; !exists { - nodes[nodeId] = false - } + if _, exists := nodes[nodeId]; !exists { + nodes[nodeId] = false } })) From 963f23ec8581d2644b7d6c4e87c89aa84563105c Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 19 Dec 2019 09:22:37 +0000 Subject: [PATCH 044/184] :bug: fix data races on ui --- plugins/ui/logger.go | 2 +- plugins/ui/nodeInfo.go | 6 +++++- plugins/ui/txLog.go | 6 ++++++ plugins/ui/ui.go | 6 ++++++ plugins/ui/websocket.go | 4 ++++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/plugins/ui/logger.go b/plugins/ui/logger.go index a4653aac52..08658c4317 100644 --- a/plugins/ui/logger.go +++ b/plugins/ui/logger.go @@ -7,7 +7,7 @@ import ( "github.com/iotaledger/hive.go/logger" ) -var logMutex = sync.Mutex{} +var logMutex = sync.RWMutex{} var logHistory = make([]*statusMessage, 0) type statusMessage struct { diff --git a/plugins/ui/nodeInfo.go b/plugins/ui/nodeInfo.go index c23b25444e..3c3f09c02f 100644 --- a/plugins/ui/nodeInfo.go +++ b/plugins/ui/nodeInfo.go @@ -1,6 +1,7 @@ package ui import ( + "sync" "sync/atomic" "time" @@ -14,6 +15,7 @@ var receivedTpsCounter uint64 var solidTpsCounter uint64 var tpsQueue []uint32 +var tpsQueueMutex sync.RWMutex const maxQueueSize int = 3600 @@ -31,10 +33,12 @@ type nodeInfo struct { func gatherInfo() nodeInfo { // update tps queue - tpsQueue = append(tpsQueue, uint32(receivedTpsCounter)) + tpsQueueMutex.Lock() + tpsQueue = append(tpsQueue, uint32(atomic.LoadUint64(&receivedTpsCounter))) if len(tpsQueue) > maxQueueSize { tpsQueue = tpsQueue[1:] } + tpsQueueMutex.Unlock() // update neighbors chosenNeighbors := []string{} diff --git a/plugins/ui/txLog.go b/plugins/ui/txLog.go index 3f64ac6198..d8d57932d1 100644 --- a/plugins/ui/txLog.go +++ b/plugins/ui/txLog.go @@ -2,6 +2,7 @@ package ui import ( "strings" + "sync" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/iota.go/transaction" @@ -9,16 +10,21 @@ import ( // cleared every second var transactions []transaction.Transaction +var tMutex sync.Mutex var emptyTag = strings.Repeat("9", 27) func logTransactions() interface{} { + tMutex.Lock() + defer tMutex.Unlock() a := transactions transactions = make([]transaction.Transaction, 0) return a } func saveTx(tx *value_transaction.ValueTransaction) { + tMutex.Lock() + defer tMutex.Unlock() transactions = append(transactions, transaction.Transaction{ Hash: tx.MetaTransaction.GetHash(), Address: tx.GetAddress(), diff --git a/plugins/ui/ui.go b/plugins/ui/ui.go index 3061a900e7..86add4dfce 100644 --- a/plugins/ui/ui.go +++ b/plugins/ui/ui.go @@ -27,9 +27,13 @@ func configure(plugin *node.Plugin) { webapi.AddEndpoint("ws", upgrader) webapi.AddEndpoint("loghistory", func(c echo.Context) error { + logMutex.RLock() + defer logMutex.RUnlock() return c.JSON(http.StatusOK, logHistory) }) webapi.AddEndpoint("tpsqueue", func(c echo.Context) error { + tpsQueueMutex.RLock() + defer tpsQueueMutex.RUnlock() return c.JSON(http.StatusOK, tpsQueue) }) @@ -74,10 +78,12 @@ func run(plugin *node.Plugin) { case <-daemon.ShutdownSignal: return case <-time.After(1 * time.Second): + wsMutex.Lock() ws.send(resp{ "info": gatherInfo(), "txs": logTransactions(), }) + wsMutex.Unlock() } } }) diff --git a/plugins/ui/websocket.go b/plugins/ui/websocket.go index 84cacf5396..8507f59aea 100644 --- a/plugins/ui/websocket.go +++ b/plugins/ui/websocket.go @@ -3,6 +3,7 @@ package ui import ( "encoding/json" "fmt" + "sync" "github.com/labstack/echo" "golang.org/x/net/websocket" @@ -13,6 +14,7 @@ type socket struct { } var ws socket +var wsMutex sync.Mutex func (sock socket) send(msg interface{}) { payload, err := json.Marshal(msg) @@ -24,7 +26,9 @@ func (sock socket) send(msg interface{}) { func upgrader(c echo.Context) error { websocket.Handler(func(conn *websocket.Conn) { + wsMutex.Lock() ws.conn = conn + wsMutex.Unlock() defer conn.Close() for { msg := "" From 19f276af78392fd6acce545972b32f79b64632b4 Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 19 Dec 2019 10:35:00 +0000 Subject: [PATCH 045/184] :bug: fix data races on spammer --- .../transactionspammer/transactionspammer.go | 117 +++++++++--------- 1 file changed, 56 insertions(+), 61 deletions(-) diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index b8283e55dd..d189acde38 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -14,79 +14,74 @@ import ( ) var spamming = false +var spammingMutex sync.Mutex -var startMutex sync.Mutex - -var shutdownSignal chan int +var shutdownSignal chan struct{} +var done chan struct{} var sentCounter = uint(0) -func Start(tps uint) { - startMutex.Lock() - - if !spamming { - shutdownSignal = make(chan int, 1) - - func(shutdownSignal chan int) { - daemon.BackgroundWorker("Transaction Spammer", func() { - for { - start := time.Now() - totalSentCounter := int64(0) - - for { - select { - case <-daemon.ShutdownSignal: - return - - case <-shutdownSignal: - return - - default: - sentCounter++ - totalSentCounter++ - - tx := value_transaction.New() - tx.SetHead(true) - tx.SetTail(true) - tx.SetValue(totalSentCounter) - tx.SetBranchTransactionHash(tipselection.GetRandomTip()) - tx.SetTrunkTransactionHash(tipselection.GetRandomTip()) - - mtx := &pb.Transaction{Body: tx.MetaTransaction.GetBytes()} - b, _ := proto.Marshal(mtx) - gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b, Peer: &local.INSTANCE.Peer}) - - if sentCounter >= tps { - duration := time.Since(start) - - if duration < time.Second { - time.Sleep(time.Second - duration) - } - - start = time.Now() +func init() { + shutdownSignal = make(chan struct{}) + done = make(chan struct{}) +} - sentCounter = 0 - } - } +func Start(tps uint) { + spammingMutex.Lock() + spamming = true + spammingMutex.Unlock() + + daemon.BackgroundWorker("Transaction Spammer", func() { + start := time.Now() + totalSentCounter := int64(0) + + for { + select { + case <-daemon.ShutdownSignal: + return + + case <-shutdownSignal: + done <- struct{}{} + return + + default: + sentCounter++ + totalSentCounter++ + + tx := value_transaction.New() + tx.SetHead(true) + tx.SetTail(true) + tx.SetValue(totalSentCounter) + tx.SetBranchTransactionHash(tipselection.GetRandomTip()) + tx.SetTrunkTransactionHash(tipselection.GetRandomTip()) + + mtx := &pb.Transaction{Body: tx.MetaTransaction.GetBytes()} + b, _ := proto.Marshal(mtx) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b, Peer: &local.INSTANCE.Peer}) + + if sentCounter >= tps { + duration := time.Since(start) + + if duration < time.Second { + time.Sleep(time.Second - duration) } - } - }) - }(shutdownSignal) - spamming = true - } + start = time.Now() - startMutex.Unlock() + sentCounter = 0 + } + } + } + }) } func Stop() { - startMutex.Lock() - + spammingMutex.Lock() if spamming { - close(shutdownSignal) - + shutdownSignal <- struct{}{} + // wait for spammer to be done + <-done spamming = false } - - startMutex.Unlock() + spammingMutex.Unlock() } From 4d6a560a077f57e53aa88015e9899f0ae4fd6498 Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 19 Dec 2019 12:23:03 +0000 Subject: [PATCH 046/184] :zap: removes go routine in the TSA --- plugins/tipselection/plugin.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/tipselection/plugin.go b/plugins/tipselection/plugin.go index 2f919f5857..eb983d4869 100644 --- a/plugins/tipselection/plugin.go +++ b/plugins/tipselection/plugin.go @@ -11,11 +11,9 @@ var PLUGIN = node.NewPlugin("Tipselection", node.Enabled, configure, run) func configure(node *node.Plugin) { tangle.Events.TransactionSolid.Attach(events.NewClosure(func(transaction *value_transaction.ValueTransaction) { - go func() { - tips.Delete(transaction.GetBranchTransactionHash()) - tips.Delete(transaction.GetTrunkTransactionHash()) - tips.Set(transaction.GetHash(), transaction.GetHash()) - }() + tips.Delete(transaction.GetBranchTransactionHash()) + tips.Delete(transaction.GetTrunkTransactionHash()) + tips.Set(transaction.GetHash(), transaction.GetHash()) })) } From 5892424592b2ea4843e4ead53d2b63df035af4d0 Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 19 Dec 2019 19:05:16 +0000 Subject: [PATCH 047/184] :sparkles: adds sendData and txRequest API --- go.mod | 2 +- go.sum | 35 +----------- main.go | 4 ++ plugins/webapi-send-data/plugin.go | 89 +++++++++++++++++++++++++++++ plugins/webapi-tx-request/plugin.go | 65 +++++++++++++++++++++ 5 files changed, 161 insertions(+), 34 deletions(-) create mode 100644 plugins/webapi-send-data/plugin.go create mode 100644 plugins/webapi-tx-request/plugin.go diff --git a/go.mod b/go.mod index 58f2604874..786fb555f9 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 github.com/iotaledger/autopeering-sim v0.0.0-20191206234543-6bc473d306a9 - github.com/iotaledger/hive.go v0.0.0-20191215153041-f324513d92ce + github.com/iotaledger/hive.go v0.0.0-20191219085244-317ae9a463c7 github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible github.com/lucasb-eyer/go-colorful v1.0.3 // indirect diff --git a/go.sum b/go.sum index 67fe4cf700..feb45b405d 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,3 @@ -cloud.google.com/go v0.26.0 h1:e0WKqKTd5BnrG8aKH3J3h+QvEIQtSUcf2n5UZ5ZgLtQ= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M= @@ -36,7 +35,6 @@ github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6ps github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190323231341-8198c7b169ec/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b h1:SeiGBzKrEtuDddnBABHkp4kq9sBGE9nuYmk6FPTg0zg= github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= @@ -49,7 +47,6 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/tcell v1.1.2/go.mod h1:h3kq4HO9l2On+V9ed8w8ewqQEmGCSSHOgQ+2h8uzurE= -github.com/gdamore/tcell v1.2.0 h1:ikixzsxc8K8o3V2/CEmyoEW8mJZaNYQQ3NP3VIQdUe4= github.com/gdamore/tcell v1.2.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM= github.com/gdamore/tcell v1.3.0 h1:r35w0JBADPZCVQijYebl6YMWWtHRqVEGt7kL2eBADRM= github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM= @@ -60,7 +57,6 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-zeromq/goczmq/v4 v4.2.2 h1:HAJN+i+3NW55ijMJJhk7oWxHKXgAuSBkoFfvr8bYj4U= github.com/go-zeromq/goczmq/v4 v4.2.2/go.mod h1:Sm/lxrfxP/Oxqs0tnHD6WAhwkWrx+S+1MRrKzcxoaYE= -github.com/go-zeromq/zmq4 v0.5.0 h1:DijriKlrr2b48mymvAsZApiPzrbxQodYKG1aDH1rz8c= github.com/go-zeromq/zmq4 v0.5.0/go.mod h1:6p7pjNlkfrQQVipmEuZDk7fakLZCqPPVK+Iq3jfbDg8= github.com/go-zeromq/zmq4 v0.6.2 h1:MjiFSwpiQax3LbErEV+H4eNOETGQNwbngq9MlebocbI= github.com/go-zeromq/zmq4 v0.6.2/go.mod h1:fo1rWyfV/bsg7tq/F9LF1H0e2Cf3ovQFoge1G21AnWU= @@ -70,7 +66,6 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -99,12 +94,10 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/iotaledger/autopeering-sim v0.0.0-20191206234543-6bc473d306a9 h1:JHAeVTHd8HnXnFsG2mFq3rBaXS4dRJ2lM85DSag44qo= github.com/iotaledger/autopeering-sim v0.0.0-20191206234543-6bc473d306a9/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= -github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb h1:nuS/LETRJ8obUyBIZeyxeei0ZPlyOMj8YPziOgSM4Og= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= -github.com/iotaledger/hive.go v0.0.0-20191215153041-f324513d92ce h1:+Tdo2OSZ8DCW97GuWLpGP0O64ExMYVnejfqXJZoadV8= -github.com/iotaledger/hive.go v0.0.0-20191215153041-f324513d92ce/go.mod h1:7iqun29a1x0lymTrn0UJ3Z/yy0sUzUpoOZ1OYMrYN20= +github.com/iotaledger/hive.go v0.0.0-20191219085244-317ae9a463c7 h1:2NG/9r2K4c6o+yTuqCNg+HhGb8FJ79YFm5hqInlB0Hc= +github.com/iotaledger/hive.go v0.0.0-20191219085244-317ae9a463c7/go.mod h1:7iqun29a1x0lymTrn0UJ3Z/yy0sUzUpoOZ1OYMrYN20= github.com/iotaledger/iota.go v1.0.0-beta.7/go.mod h1:dMps6iMVU1pf5NDYNKIw4tRsPeC8W3ZWjOvYHOO1PMg= -github.com/iotaledger/iota.go v1.0.0-beta.9 h1:c654s9pkdhMBkABUvWg+6k91MEBbdtmZXP1xDfQpajg= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/iotaledger/iota.go v1.0.0-beta.10 h1:PBRWEcBSw0UO7zqEHJLrHOUbjJj1eldlERzOyka/GJo= github.com/iotaledger/iota.go v1.0.0-beta.10/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= @@ -126,23 +119,19 @@ github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8 github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= -github.com/lucasb-eyer/go-colorful v1.0.2 h1:mCMFu6PgSozg9tDNMMK3g18oJBX7oYGrC09mS6CXfO4= github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1fYclkSPilDOKW0s= github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.9 h1:d5US/mDsogSGW37IV293h//ZFaeajb69h+EHFsv2xGg= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.6 h1:V2iyH+aX9C5fsYCpK60U8BYIvmhqxuOL3JZcqc1NB7k= github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= @@ -159,7 +148,6 @@ github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.6.0 h1:aetoXYr0Tv7xRU/V4B4IZJ2QcbtMUFoNb3ORp7TzIK4= github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys= @@ -179,7 +167,6 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341 h1:d2Z5U4d3fenPRFFweaMCogbXiRywM5kgYtu20/hol3M= github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341/go.mod h1:+rKjP5+h9HMwWRpAfhIkkQ9KE3m3Nz5rwn7YtUpwgqk= github.com/rivo/tview v0.0.0-20191121195645-2d957c4be01d h1:dPWYyMzc2VB5XX7eA/Pe5TXBGzhlVZZr54GhRJLTbts= github.com/rivo/tview v0.0.0-20191121195645-2d957c4be01d/go.mod h1:/rBeY22VG2QprWnEqG57IBC8biVu3i0DOIjRLc9I8H0= @@ -199,14 +186,12 @@ github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIK github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= @@ -214,7 +199,6 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/spf13/viper v1.5.0 h1:GpsTwfsQ27oS/Aha/6d1oD7tpKIqWnOA6tgOX9HHkt4= github.com/spf13/viper v1.5.0/go.mod h1:AkYRkVJF8TkSG/xet6PzXX+l39KhhXa2pdqVSxnTcn4= github.com/spf13/viper v1.6.1 h1:VPZzIkznI1YhVMRi6vNFLHSwhnhReBfgTxIPccpfdZk= github.com/spf13/viper v1.6.1/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= @@ -233,7 +217,6 @@ github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGr github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= -github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.1.0 h1:RZqt0yGBsps8NGvLSGW804QQqCUYYLsaOjTVHy1Ocw4= github.com/valyala/fasttemplate v1.1.0/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= @@ -261,14 +244,12 @@ golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472 h1:Gv7RPwsi3eZ2Fgewe3CBsuOebPwO27PoXzRpJPsvSSM= golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c h1:/nJuwDLoL/zrqY6gf57vxC+Pi+pZ8bfhpPkicO5H7W4= golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f h1:J5lckAjkw6qYlOZNj90mLYNTEKDvWeuc1yieZ8qUzUE= golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= @@ -282,9 +263,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914 h1:MlY3mEfbnWGmUi4rtHOtNnnnN4UJRGSyLPx+DXA5Sq4= golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -293,7 +272,6 @@ golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -310,12 +288,9 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd h1:DBH9mDw0zluJT/R+nGuV3jWFWLFaHyYZWD4tOT+cjn0= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191018095205-727590c5006e h1:ZtoklVMHQy6BFRHkbG6JzK+S6rX82//Yeok1vMlizfQ= golang.org/x/sys v0.0.0-20191018095205-727590c5006e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e h1:N7DeIrjYszNmSW409R3frPPwglRwMkXSBzwVbkOjLLA= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 h1:gSbV7h1NRL2G1xTg/owz62CST1oJBmxy4QpMMregXVQ= golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -331,20 +306,16 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191121040551-947d4aa89328 h1:t3X42h9e6xdbrCD/gPyWqAXr2BEpdJqRd1brThaaxII= golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191217033636-bbbf87ae2631 h1:6/HU2wqgxuc1kG3FdVH8K60WlieDAlIYaVc21Cit9Us= golang.org/x/tools v0.0.0-20191217033636-bbbf87ae2631/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.21.0 h1:G+97AoqBnmZIT91cLG/EkCoK9NSelj64P8bOHHNmGn0= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -362,11 +333,9 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/zeromq/goczmq.v4 v4.1.0 h1:CE+FE81mGVs2aSlnbfLuS1oAwdcVywyMM2AC1g33imI= gopkg.in/zeromq/goczmq.v4 v4.1.0/go.mod h1:h4IlfePEYMpFdywGr5gAwKhBBj+hiBl/nF4VoSE4k+0= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= diff --git a/main.go b/main.go index cb0803bb49..1ac904adae 100644 --- a/main.go +++ b/main.go @@ -16,7 +16,9 @@ import ( "github.com/iotaledger/goshimmer/plugins/ui" "github.com/iotaledger/goshimmer/plugins/webapi" webapi_gtta "github.com/iotaledger/goshimmer/plugins/webapi-gtta" + webapi_send_data "github.com/iotaledger/goshimmer/plugins/webapi-send-data" webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi-spammer" + webapi_tx_request "github.com/iotaledger/goshimmer/plugins/webapi-tx-request" "github.com/iotaledger/goshimmer/plugins/webauth" "github.com/iotaledger/goshimmer/plugins/zeromq" "github.com/iotaledger/hive.go/node" @@ -42,6 +44,8 @@ func main() { webapi.PLUGIN, webapi_gtta.PLUGIN, webapi_spammer.PLUGIN, + webapi_send_data.PLUGIN, + webapi_tx_request.PLUGIN, ui.PLUGIN, webauth.PLUGIN, diff --git a/plugins/webapi-send-data/plugin.go b/plugins/webapi-send-data/plugin.go new file mode 100644 index 0000000000..98c01bb5eb --- /dev/null +++ b/plugins/webapi-send-data/plugin.go @@ -0,0 +1,89 @@ +package webapi_send_data + +import ( + "net/http" + "time" + + "github.com/golang/protobuf/proto" + "github.com/iotaledger/goshimmer/packages/gossip" + pb "github.com/iotaledger/goshimmer/packages/gossip/proto" + "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/goshimmer/plugins/tipselection" + "github.com/iotaledger/goshimmer/plugins/webapi" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/iota.go/trinary" + "github.com/labstack/echo" +) + +var PLUGIN = node.NewPlugin("WebAPI SendData Endpoint", node.Enabled, configure) +var log = logger.NewLogger("API-sendData") + +func configure(plugin *node.Plugin) { + webapi.AddEndpoint("sendData", SendDataHandler) +} + +func SendDataHandler(c echo.Context) error { + c.Set("requestStartTime", time.Now()) + + var request webRequest + if err := c.Bind(&request); err != nil { + log.Info(err.Error()) + return requestFailed(c, err.Error()) + } + log.Info("Received:", request.Data) + tx := value_transaction.New() + tx.SetHead(true) + tx.SetTail(true) + + buffer := make([]byte, 6561) + if len(request.Data) > 6561 { + return requestFailed(c, "data exceding 6561 byte limit") + } + + copy(buffer, []byte(request.Data)) + + trytes, err := trinary.BytesToTrytes(buffer) + if err != nil { + log.Info("Trytes conversion", err.Error()) + return requestFailed(c, err.Error()) + } + + tx.SetSignatureMessageFragment(trytes) + tx.SetBranchTransactionHash(tipselection.GetRandomTip()) + tx.SetTrunkTransactionHash(tipselection.GetRandomTip()) + + transactionHash := tx.GetHash() + + mtx := &pb.Transaction{Body: tx.MetaTransaction.GetBytes()} + b, _ := proto.Marshal(mtx) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b, Peer: &local.INSTANCE.Peer}) + + return requestSuccessful(c, transactionHash) +} + +func requestSuccessful(c echo.Context, txHash string) error { + return c.JSON(http.StatusCreated, webResponse{ + Duration: time.Since(c.Get("requestStartTime").(time.Time)).Nanoseconds() / 1e6, + TransactionHash: txHash, + Status: "OK", + }) +} + +func requestFailed(c echo.Context, message string) error { + return c.JSON(http.StatusNotModified, webResponse{ + Duration: time.Since(c.Get("requestStartTime").(time.Time)).Nanoseconds() / 1e6, + Status: message, + }) +} + +type webResponse struct { + Duration int64 `json:"duration"` + TransactionHash string `json:"transactionHash"` + Status string `json:"status"` +} + +type webRequest struct { + Data string `json:"data"` +} diff --git a/plugins/webapi-tx-request/plugin.go b/plugins/webapi-tx-request/plugin.go new file mode 100644 index 0000000000..a10ac0eada --- /dev/null +++ b/plugins/webapi-tx-request/plugin.go @@ -0,0 +1,65 @@ +package webapi_tx_request + +import ( + "net/http" + "time" + + "github.com/iotaledger/goshimmer/plugins/tangle" + "github.com/iotaledger/goshimmer/plugins/webapi" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" + "github.com/labstack/echo" +) + +var PLUGIN = node.NewPlugin("WebAPI Transaction Request Endpoint", node.Enabled, configure) +var log = logger.NewLogger("API-TxRequest") + +func configure(plugin *node.Plugin) { + webapi.AddEndpoint("txRequest", Handler) +} + +func Handler(c echo.Context) error { + c.Set("requestStartTime", time.Now()) + + var request webRequest + if err := c.Bind(&request); err != nil { + log.Info(err.Error()) + return requestFailed(c, err.Error()) + } + log.Info("Received:", request.TransactionHash) + + tx, err := tangle.GetTransaction(request.TransactionHash) + if err != nil { + return requestFailed(c, err.Error()) + } + if tx == nil { + return requestFailed(c, "Tx not found") + } + + return requestSuccessful(c, tx.GetBytes()) +} + +func requestSuccessful(c echo.Context, tx []byte) error { + return c.JSON(http.StatusOK, webResponse{ + Duration: time.Since(c.Get("requestStartTime").(time.Time)).Nanoseconds() / 1e6, + Transaction: tx, + Status: "OK", + }) +} + +func requestFailed(c echo.Context, message string) error { + return c.JSON(http.StatusNotFound, webResponse{ + Duration: time.Since(c.Get("requestStartTime").(time.Time)).Nanoseconds() / 1e6, + Status: message, + }) +} + +type webResponse struct { + Duration int64 `json:"duration"` + Transaction []byte `json:"transaction"` + Status string `json:"status"` +} + +type webRequest struct { + TransactionHash string `json:"transactionHash"` +} From a4af68b1b95a25cd053763a9df49d323ce09e7f4 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Sat, 21 Dec 2019 17:32:47 +0100 Subject: [PATCH 048/184] Add PoW support for MetaTransaction --- packages/model/meta_transaction/constants.go | 6 +- .../meta_transaction/meta_transaction.go | 90 +++++++++++++++++-- .../meta_transaction/meta_transaction_test.go | 69 ++++++++------ packages/model/value_transaction/constants.go | 5 +- .../value_transaction/value_transaction.go | 49 ---------- 5 files changed, 133 insertions(+), 86 deletions(-) diff --git a/packages/model/meta_transaction/constants.go b/packages/model/meta_transaction/constants.go index 1e5cbdcccf..814e958c82 100644 --- a/packages/model/meta_transaction/constants.go +++ b/packages/model/meta_transaction/constants.go @@ -1,6 +1,7 @@ package meta_transaction import ( + "github.com/iotaledger/iota.go/consts" "github.com/iotaledger/iota.go/trinary" ) @@ -12,6 +13,7 @@ const ( TAIL_OFFSET = HEAD_END TRANSACTION_TYPE_OFFSET = TAIL_END DATA_OFFSET = TRANSACTION_TYPE_END + NONCE_OFFSET = DATA_END SHARD_MARKER_SIZE = 11 TRUNK_TRANSACTION_HASH_SIZE = 243 @@ -20,6 +22,7 @@ const ( TAIL_SIZE = 1 TRANSACTION_TYPE_SIZE = 8 DATA_SIZE = 6993 + NONCE_SIZE = consts.NonceTrinarySize SHARD_MARKER_END = SHARD_MARKER_OFFSET + SHARD_MARKER_SIZE TRUNK_TRANSACTION_HASH_END = TRUNK_TRANSACTION_HASH_OFFSET + TRUNK_TRANSACTION_HASH_SIZE @@ -28,8 +31,9 @@ const ( TAIL_END = TAIL_OFFSET + TAIL_SIZE TRANSACTION_TYPE_END = TRANSACTION_TYPE_OFFSET + TRANSACTION_TYPE_SIZE DATA_END = DATA_OFFSET + DATA_SIZE + NONCE_END = NONCE_OFFSET + NONCE_SIZE - MARSHALED_TOTAL_SIZE = DATA_END + MARSHALED_TOTAL_SIZE = NONCE_END BRANCH_NULL_HASH = trinary.Trytes("999999999999999999999999999999999999999999999999999999999999999999999999999999999") ) diff --git a/packages/model/meta_transaction/meta_transaction.go b/packages/model/meta_transaction/meta_transaction.go index 575ea6b435..c20bab96a3 100644 --- a/packages/model/meta_transaction/meta_transaction.go +++ b/packages/model/meta_transaction/meta_transaction.go @@ -3,8 +3,11 @@ package meta_transaction import ( "sync" - "github.com/iotaledger/goshimmer/packages/curl" + "github.com/iotaledger/iota.go/consts" + "github.com/iotaledger/iota.go/curl" + "github.com/iotaledger/iota.go/pow" "github.com/iotaledger/iota.go/trinary" + "github.com/pkg/errors" ) type MetaTransaction struct { @@ -19,6 +22,7 @@ type MetaTransaction struct { transactionType *trinary.Trytes data trinary.Trits modified bool + nonce *trinary.Trytes hasherMutex sync.RWMutex hashMutex sync.RWMutex @@ -31,6 +35,7 @@ type MetaTransaction struct { dataMutex sync.RWMutex bytesMutex sync.RWMutex modifiedMutex sync.RWMutex + nonceMutex sync.RWMutex trits trinary.Trits bytes []byte @@ -85,7 +90,7 @@ func (this *MetaTransaction) GetHash() (result trinary.Trytes) { defer this.hashMutex.Unlock() if this.hash == nil { this.hasherMutex.Lock() - this.parseHashRelatedDetails() + this.computeHashDetails() this.hasherMutex.Unlock() } } else { @@ -106,7 +111,7 @@ func (this *MetaTransaction) GetWeightMagnitude() (result int) { defer this.hashMutex.Unlock() if this.hash == nil { this.hasherMutex.Lock() - this.parseHashRelatedDetails() + this.computeHashDetails() this.hasherMutex.Unlock() } } else { @@ -118,9 +123,26 @@ func (this *MetaTransaction) GetWeightMagnitude() (result int) { return } +// returns the trytes that are relevant for the transaction hash +func (this *MetaTransaction) getHashEssence() trinary.Trits { + txTrits := this.trits + + // very dirty hack, to get an iota.go compatible size + if len(txTrits) > consts.TransactionTrinarySize { + panic("transaction too large") + } + essenceTrits := make([]int8, consts.TransactionTrinarySize) + copy(essenceTrits[consts.TransactionTrinarySize-len(txTrits):], txTrits) + + return essenceTrits +} + // hashes the transaction using curl (without locking - internal usage) -func (this *MetaTransaction) parseHashRelatedDetails() { - hashTrits := curl.CURLP81.Hash(this.trits) +func (this *MetaTransaction) computeHashDetails() { + hashTrits, err := curl.HashTrits(this.getHashEssence()) + if err != nil { + panic(err) + } hashTrytes := trinary.MustTritsToTrytes(hashTrits) this.hash = &hashTrytes @@ -466,6 +488,49 @@ func (this *MetaTransaction) GetBytes() (result []byte) { return } +func (this *MetaTransaction) GetNonce() trinary.Trytes { + this.nonceMutex.RLock() + if this.nonce == nil { + this.nonceMutex.RUnlock() + this.nonceMutex.Lock() + defer this.nonceMutex.Unlock() + if this.nonce == nil { + nonce := trinary.MustTritsToTrytes(this.trits[NONCE_OFFSET:NONCE_END]) + + this.nonce = &nonce + } + } else { + defer this.nonceMutex.RUnlock() + } + + return *this.nonce +} + +func (this *MetaTransaction) SetNonce(nonce trinary.Trytes) bool { + this.nonceMutex.RLock() + if this.nonce == nil || *this.nonce != nonce { + this.nonceMutex.RUnlock() + this.nonceMutex.Lock() + defer this.nonceMutex.Unlock() + if this.nonce == nil || *this.nonce != nonce { + this.nonce = &nonce + + this.hasherMutex.RLock() + copy(this.trits[NONCE_OFFSET:NONCE_END], trinary.MustTrytesToTrits(nonce)[:NONCE_SIZE]) + this.hasherMutex.RUnlock() + + this.SetModified(true) + this.ReHash() + + return true + } + } else { + this.nonceMutex.RUnlock() + } + + return false +} + // returns true if the transaction contains unsaved changes (supports concurrency) func (this *MetaTransaction) GetModified() bool { this.modifiedMutex.RLock() @@ -481,3 +546,18 @@ func (this *MetaTransaction) SetModified(modified bool) { this.modified = modified } + +func (this *MetaTransaction) DoProofOfWork(mwm int) error { + this.hasherMutex.Lock() + powTrytes := trinary.MustTritsToTrytes(this.getHashEssence()) + _, pow := pow.GetFastestProofOfWorkImpl() + nonce, err := pow(powTrytes, mwm) + this.hasherMutex.Unlock() + + if err != nil { + return errors.Wrap(err, "PoW failed") + } + this.SetNonce(nonce) + + return nil +} diff --git a/packages/model/meta_transaction/meta_transaction_test.go b/packages/model/meta_transaction/meta_transaction_test.go index 2ba055b76a..fa6ec56525 100644 --- a/packages/model/meta_transaction/meta_transaction_test.go +++ b/packages/model/meta_transaction/meta_transaction_test.go @@ -1,40 +1,55 @@ package meta_transaction import ( - "fmt" "sync" "testing" "github.com/iotaledger/iota.go/trinary" - "github.com/magiconair/properties/assert" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) +const ( + shardMarker = trinary.Trytes("NPHTQORL9XKA") + trunkTransactionHash = trinary.Trytes("99999999999999999999999999999999999999999999999999999999999999999999999999999999A") + branchTransactionHash = trinary.Trytes("99999999999999999999999999999999999999999999999999999999999999999999999999999999B") + head = true + tail = true + transactionType = trinary.Trytes("9999999999999999999999") +) + +func newTestTransaction() *MetaTransaction { + tx := New() + tx.SetShardMarker(shardMarker) + tx.SetTrunkTransactionHash(trunkTransactionHash) + tx.SetBranchTransactionHash(branchTransactionHash) + tx.SetHead(head) + tx.SetTail(tail) + tx.SetTransactionType(transactionType) + + return tx +} + +func TestDoPow(t *testing.T) { + tx := newTestTransaction() + require.NoError(t, tx.DoProofOfWork(10)) + + assert.GreaterOrEqual(t, tx.GetWeightMagnitude(), 10) +} + func TestMetaTransaction_SettersGetters(t *testing.T) { - shardMarker := trinary.Trytes("NPHTQORL9XKA") - trunkTransactionHash := trinary.Trytes("99999999999999999999999999999999999999999999999999999999999999999999999999999999A") - branchTransactionHash := trinary.Trytes("99999999999999999999999999999999999999999999999999999999999999999999999999999999B") - head := true - tail := true - transactionType := trinary.Trytes("9999999999999999999999") - - transaction := New() - transaction.SetShardMarker(shardMarker) - transaction.SetTrunkTransactionHash(trunkTransactionHash) - transaction.SetBranchTransactionHash(branchTransactionHash) - transaction.SetHead(head) - transaction.SetTail(tail) - transaction.SetTransactionType(transactionType) - - assert.Equal(t, transaction.GetWeightMagnitude(), 0) - assert.Equal(t, transaction.GetShardMarker(), shardMarker) - assert.Equal(t, transaction.GetTrunkTransactionHash(), trunkTransactionHash) - assert.Equal(t, transaction.GetBranchTransactionHash(), branchTransactionHash) - assert.Equal(t, transaction.IsHead(), head) - assert.Equal(t, transaction.IsTail(), tail) - assert.Equal(t, transaction.GetTransactionType(), transactionType) - assert.Equal(t, transaction.GetHash(), FromBytes(transaction.GetBytes()).GetHash()) - - fmt.Println(transaction.GetHash()) + tx := newTestTransaction() + + assert.Equal(t, tx.GetWeightMagnitude(), 0) + assert.Equal(t, tx.GetShardMarker(), shardMarker) + assert.Equal(t, tx.GetTrunkTransactionHash(), trunkTransactionHash) + assert.Equal(t, tx.GetBranchTransactionHash(), branchTransactionHash) + assert.Equal(t, tx.IsHead(), head) + assert.Equal(t, tx.IsTail(), tail) + assert.Equal(t, tx.GetTransactionType(), transactionType) + assert.Equal(t, tx.GetHash(), FromBytes(tx.GetBytes()).GetHash()) + + assert.EqualValues(t, "KKDVHBENVLQUNO9WOWWEJPBBHUSYRSRKIMZWCFCDB9RYZKYWLAYWRIBRQETBFKE9TIVWQPCKFWAMCLCAV", tx.GetHash()) } func BenchmarkMetaTransaction_GetHash(b *testing.B) { diff --git a/packages/model/value_transaction/constants.go b/packages/model/value_transaction/constants.go index cc2175fd49..c602d1ea6d 100644 --- a/packages/model/value_transaction/constants.go +++ b/packages/model/value_transaction/constants.go @@ -10,20 +10,17 @@ const ( ADDRESS_OFFSET = 0 VALUE_OFFSET = ADDRESS_END TIMESTAMP_OFFSET = VALUE_END - NONCE_OFFSET = TIMESTAMP_END - SIGNATURE_MESSAGE_FRAGMENT_OFFSET = NONCE_END + SIGNATURE_MESSAGE_FRAGMENT_OFFSET = TIMESTAMP_SIZE ADDRESS_SIZE = 243 VALUE_SIZE = 81 TIMESTAMP_SIZE = 27 - NONCE_SIZE = 81 SIGNATURE_MESSAGE_FRAGMENT_SIZE = 6561 BUNDLE_ESSENCE_SIZE = ADDRESS_SIZE + VALUE_SIZE + SIGNATURE_MESSAGE_FRAGMENT_SIZE ADDRESS_END = ADDRESS_OFFSET + ADDRESS_SIZE VALUE_END = VALUE_OFFSET + VALUE_SIZE TIMESTAMP_END = TIMESTAMP_OFFSET + TIMESTAMP_SIZE - NONCE_END = NONCE_OFFSET + NONCE_SIZE SIGNATURE_MESSAGE_FRAGMENT_END = SIGNATURE_MESSAGE_FRAGMENT_OFFSET + SIGNATURE_MESSAGE_FRAGMENT_SIZE TOTAL_SIZE = SIGNATURE_MESSAGE_FRAGMENT_END diff --git a/packages/model/value_transaction/value_transaction.go b/packages/model/value_transaction/value_transaction.go index e4972d271a..b42a647348 100644 --- a/packages/model/value_transaction/value_transaction.go +++ b/packages/model/value_transaction/value_transaction.go @@ -16,8 +16,6 @@ type ValueTransaction struct { valueMutex sync.RWMutex timestamp *uint timestampMutex sync.RWMutex - nonce *trinary.Trytes - nonceMutex sync.RWMutex signatureMessageFragment *trinary.Trytes signatureMessageFragmentMutex sync.RWMutex @@ -215,53 +213,6 @@ func (this *ValueTransaction) GetBundleEssence(includeSignatureMessageFragment b return } -// getter for the nonce (supports concurrency) -func (this *ValueTransaction) GetNonce() (result trinary.Trytes) { - this.nonceMutex.RLock() - if this.nonce == nil { - this.nonceMutex.RUnlock() - this.nonceMutex.Lock() - defer this.nonceMutex.Unlock() - if this.nonce == nil { - nonce := trinary.MustTritsToTrytes(this.trits[NONCE_OFFSET:NONCE_END]) - - this.nonce = &nonce - } - } else { - defer this.nonceMutex.RUnlock() - } - - result = *this.nonce - - return -} - -// setter for the nonce (supports concurrency) -func (this *ValueTransaction) SetNonce(nonce trinary.Trytes) bool { - this.nonceMutex.RLock() - if this.nonce == nil || *this.nonce != nonce { - this.nonceMutex.RUnlock() - this.nonceMutex.Lock() - defer this.nonceMutex.Unlock() - if this.nonce == nil || *this.nonce != nonce { - this.nonce = &nonce - - this.BlockHasher() - copy(this.trits[NONCE_OFFSET:NONCE_END], trinary.MustTrytesToTrits(nonce)[:NONCE_SIZE]) - this.UnblockHasher() - - this.SetModified(true) - this.ReHash() - - return true - } - } else { - this.nonceMutex.RUnlock() - } - - return false -} - // getter for the signatureMessageFragmetn (supports concurrency) func (this *ValueTransaction) GetSignatureMessageFragment() (result trinary.Trytes) { this.signatureMessageFragmentMutex.RLock() From dceedf1736e62e78c575addc27477ebea0d02b08 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Sun, 22 Dec 2019 15:17:45 +0100 Subject: [PATCH 049/184] Remove bundle hash comparision in failing test --- plugins/bundleprocessor/bundleprocessor_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/bundleprocessor/bundleprocessor_test.go b/plugins/bundleprocessor/bundleprocessor_test.go index 93ea4dcdcf..f1b52a48f0 100644 --- a/plugins/bundleprocessor/bundleprocessor_test.go +++ b/plugins/bundleprocessor/bundleprocessor_test.go @@ -127,7 +127,6 @@ func TestProcessSolidBundleHead_Value(t *testing.T) { testResults := events.NewClosure(func(bundle *bundle.Bundle, transactions []*value_transaction.ValueTransaction) { assert.Equal(t, bundle.GetHash(), generatedBundle.GetTransactions()[0].GetHash(), "invalid bundle hash") - assert.Equal(t, bundle.GetBundleEssenceHash(), generatedBundle.GetEssenceHash(), "invalid bundle essence hash") assert.Equal(t, bundle.IsValueBundle(), true, "invalid value bundle status") wg.Done() From 61a25ecebecaeeffb157d64bf00dc6049e8c2b1c Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Sun, 22 Dec 2019 16:02:13 +0100 Subject: [PATCH 050/184] Require PoW for all meta transactions --- packages/model/meta_transaction/constants.go | 2 ++ packages/model/meta_transaction/meta_transaction.go | 11 +++++++++++ packages/transactionspammer/transactionspammer.go | 9 +++++++++ plugins/gossip/gossip.go | 2 +- plugins/tangle/solidifier.go | 12 ++++++++++-- plugins/tangle/solidifier_test.go | 12 ++++++++++-- plugins/webapi-send-data/plugin.go | 5 +++++ 7 files changed, 48 insertions(+), 5 deletions(-) diff --git a/packages/model/meta_transaction/constants.go b/packages/model/meta_transaction/constants.go index 814e958c82..399fd041fc 100644 --- a/packages/model/meta_transaction/constants.go +++ b/packages/model/meta_transaction/constants.go @@ -36,4 +36,6 @@ const ( MARSHALED_TOTAL_SIZE = NONCE_END BRANCH_NULL_HASH = trinary.Trytes("999999999999999999999999999999999999999999999999999999999999999999999999999999999") + + MIN_WEIGHT_MAGNITUDE = 12 ) diff --git a/packages/model/meta_transaction/meta_transaction.go b/packages/model/meta_transaction/meta_transaction.go index c20bab96a3..d85160a615 100644 --- a/packages/model/meta_transaction/meta_transaction.go +++ b/packages/model/meta_transaction/meta_transaction.go @@ -1,6 +1,7 @@ package meta_transaction import ( + "fmt" "sync" "github.com/iotaledger/iota.go/consts" @@ -561,3 +562,13 @@ func (this *MetaTransaction) DoProofOfWork(mwm int) error { return nil } + +func (this *MetaTransaction) Validate() error { + // check that the weight magnitude is valid + weightMagnitude := this.GetWeightMagnitude() + if weightMagnitude < MIN_WEIGHT_MAGNITUDE { + return fmt.Errorf("insufficient weight magnitude: got=%d, want=%d", weightMagnitude, MIN_WEIGHT_MAGNITUDE) + } + + return nil +} diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index d189acde38..75ccf787b4 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -7,12 +7,16 @@ import ( "github.com/golang/protobuf/proto" "github.com/iotaledger/goshimmer/packages/gossip" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" + "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/tipselection" "github.com/iotaledger/hive.go/daemon" + "github.com/iotaledger/hive.go/logger" ) +var log = logger.NewLogger("Transaction Spammer") + var spamming = false var spammingMutex sync.Mutex @@ -54,6 +58,11 @@ func Start(tps uint) { tx.SetValue(totalSentCounter) tx.SetBranchTransactionHash(tipselection.GetRandomTip()) tx.SetTrunkTransactionHash(tipselection.GetRandomTip()) + tx.SetTimestamp(uint(time.Now().Unix())) + if err := tx.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE); err != nil { + log.Warning("PoW failed", err) + continue + } mtx := &pb.Transaction{Body: tx.MetaTransaction.GetBytes()} b, _ := proto.Marshal(mtx) diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 12045c6369..efbb650e22 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -98,7 +98,7 @@ func configureEvents() { })) tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { - log.Info("Tx solidified:", tx.MetaTransaction.GetHash()) + log.Info("gossip solid tx", tx.MetaTransaction.GetHash()) t := &pb.Transaction{ Body: tx.MetaTransaction.GetBytes(), } diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index f799848033..130deda4fc 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -38,10 +38,18 @@ func configureSolidifier(plugin *node.Plugin) { unsolidTxs = NewUnsolidTxs() gossip.Events.TransactionReceived.Attach(events.NewClosure(func(ev *gossip.TransactionReceivedEvent) { - //log.Info("New Transaction", ev.Body) pTx := &pb.Transaction{} - proto.Unmarshal(ev.Body, pTx) + if err := proto.Unmarshal(ev.Body, pTx); err != nil { + log.Warningf("invalid transaction: %s", err) + return + } + metaTx := meta_transaction.FromBytes(pTx.GetBody()) + if err := metaTx.Validate(); err != nil { + log.Warningf("invalid transaction: %s", err) + return + } + workerPool.Submit(metaTx) })) diff --git a/plugins/tangle/solidifier_test.go b/plugins/tangle/solidifier_test.go index 263294f59e..be845077fa 100644 --- a/plugins/tangle/solidifier_test.go +++ b/plugins/tangle/solidifier_test.go @@ -8,11 +8,12 @@ import ( "github.com/golang/protobuf/proto" "github.com/iotaledger/goshimmer/packages/gossip" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" + "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/parameter" - "github.com/iotaledger/iota.go/trinary" + "github.com/stretchr/testify/require" ) func TestMain(m *testing.M) { @@ -29,16 +30,23 @@ func TestSolidifier(t *testing.T) { // create transactions and chain them together transaction1 := value_transaction.New() - transaction1.SetNonce(trinary.Trytes("99999999999999999999999999A")) + transaction1.SetValue(1) + require.NoError(t, transaction1.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE)) + transaction2 := value_transaction.New() transaction2.SetValue(2) transaction2.SetBranchTransactionHash(transaction1.GetHash()) + require.NoError(t, transaction2.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE)) + transaction3 := value_transaction.New() transaction3.SetValue(3) transaction3.SetBranchTransactionHash(transaction2.GetHash()) + require.NoError(t, transaction3.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE)) + transaction4 := value_transaction.New() transaction4.SetValue(4) transaction4.SetBranchTransactionHash(transaction3.GetHash()) + require.NoError(t, transaction4.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE)) // setup event handlers var wg sync.WaitGroup diff --git a/plugins/webapi-send-data/plugin.go b/plugins/webapi-send-data/plugin.go index 98c01bb5eb..8fdf374634 100644 --- a/plugins/webapi-send-data/plugin.go +++ b/plugins/webapi-send-data/plugin.go @@ -7,6 +7,7 @@ import ( "github.com/golang/protobuf/proto" "github.com/iotaledger/goshimmer/packages/gossip" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" + "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/tipselection" @@ -53,6 +54,10 @@ func SendDataHandler(c echo.Context) error { tx.SetSignatureMessageFragment(trytes) tx.SetBranchTransactionHash(tipselection.GetRandomTip()) tx.SetTrunkTransactionHash(tipselection.GetRandomTip()) + tx.SetTimestamp(uint(time.Now().Unix())) + if err := tx.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE); err != nil { + log.Warning("PoW failed", err) + } transactionHash := tx.GetHash() From eb72626d884231a511185fecbc1ce605b12d7cf4 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Mon, 30 Dec 2019 12:25:57 +0100 Subject: [PATCH 051/184] Update autopeering to latest version --- go.mod | 8 +++++--- go.sum | 16 ++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 235c5498ef..9c9001471b 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/golang/protobuf v1.3.2 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/autopeering-sim v0.0.0-20191206234543-6bc473d306a9 + github.com/iotaledger/autopeering-sim v0.0.0-20191230110650-35e88c0f9fe6 github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20 github.com/iotaledger/iota.go v1.0.0-beta.10 github.com/labstack/echo v3.3.10+incompatible @@ -23,6 +23,7 @@ require ( github.com/pkg/errors v0.8.1 github.com/rivo/tview v0.0.0-20191121195645-2d957c4be01d github.com/spf13/afero v1.2.2 // indirect + github.com/spf13/cast v1.3.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.6.1 // indirect @@ -33,7 +34,8 @@ require ( golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect - golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 // indirect - golang.org/x/tools v0.0.0-20191217033636-bbbf87ae2631 // indirect + golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 // indirect + golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4 // indirect + gopkg.in/ini.v1 v1.51.1 // indirect gopkg.in/yaml.v2 v2.2.7 // indirect ) diff --git a/go.sum b/go.sum index 65471d9b51..aef858272c 100644 --- a/go.sum +++ b/go.sum @@ -91,8 +91,8 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/autopeering-sim v0.0.0-20191206234543-6bc473d306a9 h1:JHAeVTHd8HnXnFsG2mFq3rBaXS4dRJ2lM85DSag44qo= -github.com/iotaledger/autopeering-sim v0.0.0-20191206234543-6bc473d306a9/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= +github.com/iotaledger/autopeering-sim v0.0.0-20191230110650-35e88c0f9fe6 h1:i4VRC/lg5dec9FAt8jDHbJzy0bxWf18S4yOcy/u7RZ8= +github.com/iotaledger/autopeering-sim v0.0.0-20191230110650-35e88c0f9fe6/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20 h1:ZIJAeQSEdmVbmZNIW2198IwD23+wBteb4WE4pyjxk+c= @@ -191,6 +191,8 @@ github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= +github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= @@ -292,8 +294,8 @@ golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191018095205-727590c5006e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191210023423-ac6580df4449 h1:gSbV7h1NRL2G1xTg/owz62CST1oJBmxy4QpMMregXVQ= -golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 h1:JA8d3MPx/IToSyXZG/RhwYEtfrKO1Fxrqe8KrkiLXKM= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -308,8 +310,8 @@ golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191217033636-bbbf87ae2631 h1:6/HU2wqgxuc1kG3FdVH8K60WlieDAlIYaVc21Cit9Us= -golang.org/x/tools v0.0.0-20191217033636-bbbf87ae2631/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4 h1:Toz2IK7k8rbltAXwNAxKcn9OzqyNfMUhUNjz3sL0NMk= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -327,6 +329,8 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/h2non/gock.v1 v1.0.14/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE= gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.51.1 h1:GyboHr4UqMiLUybYjd22ZjQIKEJEpgtLXtuGbR21Oho= +gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= From e24616358fb82ba35e49bd8ad028950866cbc6d3 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Mon, 30 Dec 2019 13:25:22 +0100 Subject: [PATCH 052/184] Switch to docker host network mode --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index b4af6fb9da..cc59aa4d05 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ version: "3" services: goshimmer: + network_mode: host image: iotaledger/goshimmer build: context: ./ From 9dfc23f0583224f9d3d2b404e44978f1a108a1a3 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Mon, 30 Dec 2019 16:46:45 +0100 Subject: [PATCH 053/184] Improve log and error messages --- packages/gossip/manager.go | 7 ++++--- packages/gossip/transport/transport.go | 24 +++++++++++++++--------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go index 49c0e6b56d..8a8c1587e1 100644 --- a/packages/gossip/manager.go +++ b/packages/gossip/manager.go @@ -151,13 +151,13 @@ func (m *Manager) send(msg []byte, to ...peer.ID) { } } -func (m *Manager) addNeighbor(peer *peer.Peer, handshake func(*peer.Peer) (*transport.Connection, error)) error { +func (m *Manager) addNeighbor(peer *peer.Peer, connectorFunc func(*peer.Peer) (*transport.Connection, error)) error { var ( err error conn *transport.Connection ) for i := 0; i < maxConnectionAttempts; i++ { - conn, err = handshake(peer) + conn, err = connectorFunc(peer) if err == nil { break } @@ -210,9 +210,10 @@ func (m *Manager) readLoop(nbr *neighbor) { if err != io.EOF && !strings.Contains(err.Error(), "use of closed network connection") { m.log.Warnw("read error", "err", err) } + + m.log.Debug("connection closed", "id", nbr.peer.ID(), "addr", nbr.conn.RemoteAddr().String()) _ = nbr.conn.Close() // just make sure that the connection is closed as fast as possible _ = m.DropNeighbor(nbr.peer.ID()) - m.log.Debug("reading stopped") return } diff --git a/packages/gossip/transport/transport.go b/packages/gossip/transport/transport.go index 54794a631f..ef651bb300 100644 --- a/packages/gossip/transport/transport.go +++ b/packages/gossip/transport/transport.go @@ -141,15 +141,18 @@ func (t *TCP) DialPeer(p *peer.Peer) (*Connection, error) { conn, err := net.DialTimeout(gossipAddr.Network(), gossipAddr.String(), acceptTimeout) if err != nil { - return nil, err + return nil, errors.Wrap(err, "dial peer failed") } err = t.doHandshake(p.PublicKey(), gossipAddr.String(), conn) if err != nil { - return nil, err + return nil, errors.Wrap(err, "outgoing handshake failed") } - t.log.Debugw("connected", "id", p.ID(), "addr", conn.RemoteAddr(), "direction", "out") + t.log.Debugw("outgoing connection established", + "id", p.ID(), + "addr", conn.RemoteAddr(), + ) return newConnection(conn, p), nil } @@ -159,13 +162,17 @@ func (t *TCP) AcceptPeer(p *peer.Peer) (*Connection, error) { if p.Services().Get(service.GossipKey) == nil { return nil, ErrNoGossip } + // wait for the connection connected := <-t.acceptPeer(p) if connected.err != nil { - return nil, connected.err + return nil, errors.Wrap(connected.err, "accept peer failed") } - t.log.Debugw("connected", "id", p.ID(), "addr", connected.c.RemoteAddr(), "direction", "in") + t.log.Debugw("incoming connection established", + "id", p.ID(), + "addr", connected.c.RemoteAddr(), + ) return connected.c, nil } @@ -262,8 +269,7 @@ func (t *TCP) matchAccept(m *acceptMatcher, req []byte, conn net.Conn) { defer t.wg.Done() if err := t.writeHandshakeResponse(req, conn); err != nil { - t.log.Warnw("failed handshake", "addr", conn.RemoteAddr(), "err", err) - m.connected <- connect{nil, err} + m.connected <- connect{nil, errors.Wrap(err, "incoming handshake failed")} t.closeConnection(conn) return } @@ -320,7 +326,7 @@ func (t *TCP) doHandshake(key peer.PublicKey, remoteAddr string, conn net.Conn) } b, err := proto.Marshal(pkt) if err != nil { - return errors.Wrap(err, ErrInvalidHandshake.Error()) + return err } if l := len(b); l > maxHandshakePacketSize { return fmt.Errorf("handshake size too large: %d, max %d", l, maxHandshakePacketSize) @@ -345,7 +351,7 @@ func (t *TCP) doHandshake(key peer.PublicKey, remoteAddr string, conn net.Conn) pkt = new(pb.Packet) if err := proto.Unmarshal(b[:n], pkt); err != nil { - return errors.Wrap(err, ErrInvalidHandshake.Error()) + return err } signer, err := peer.RecoverKeyFromSignedData(pkt) From 8d20b73910de74df1910feaa5cee5f251e1245a3 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Mon, 30 Dec 2019 16:49:22 +0100 Subject: [PATCH 054/184] Increase connection timeouts --- packages/gossip/transport/transport.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/gossip/transport/transport.go b/packages/gossip/transport/transport.go index ef651bb300..97f98f00e4 100644 --- a/packages/gossip/transport/transport.go +++ b/packages/gossip/transport/transport.go @@ -31,8 +31,8 @@ var ( // connection timeouts const ( - acceptTimeout = 500 * time.Millisecond - handshakeTimeout = 100 * time.Millisecond + acceptTimeout = 250 * time.Millisecond + handshakeTimeout = 500 * time.Millisecond connectionTimeout = acceptTimeout + handshakeTimeout maxHandshakePacketSize = 256 From 4d4a76b00f5b6d621bb182dabc65dde8e602b852 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Mon, 30 Dec 2019 17:20:37 +0100 Subject: [PATCH 055/184] Fix wrong formating --- packages/gossip/manager.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go index 8a8c1587e1..8c11efba42 100644 --- a/packages/gossip/manager.go +++ b/packages/gossip/manager.go @@ -211,7 +211,10 @@ func (m *Manager) readLoop(nbr *neighbor) { m.log.Warnw("read error", "err", err) } - m.log.Debug("connection closed", "id", nbr.peer.ID(), "addr", nbr.conn.RemoteAddr().String()) + m.log.Debugw("connection closed", + "id", nbr.peer.ID(), + "addr", nbr.conn.RemoteAddr().String(), + ) _ = nbr.conn.Close() // just make sure that the connection is closed as fast as possible _ = m.DropNeighbor(nbr.peer.ID()) return From 418f5d6d424b89305231e9f7de48199e475f45ec Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Mon, 30 Dec 2019 19:41:46 +0100 Subject: [PATCH 056/184] Make masterNodes a StringSlice parameter --- plugins/autopeering/autopeering.go | 8 ++++---- plugins/autopeering/entrynodes.go | 2 +- plugins/autopeering/parameters.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 7dc06d78d6..314459ed66 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -82,12 +82,12 @@ func configureAP() { log.Fatalf("ListenUDP: %v", err) } - masterPeers := []*peer.Peer{} - master, err := parseEntryNodes() + var masterPeers []*peer.Peer + peers, err := parseEntryNodes() if err != nil { log.Fatalf("Ignoring entry nodes: %v\n", err) - } else if master != nil { - masterPeers = master + } else if peers != nil { + masterPeers = peers } // use the UDP connection for transport diff --git a/plugins/autopeering/entrynodes.go b/plugins/autopeering/entrynodes.go index 0dc4862739..1b4384d37d 100644 --- a/plugins/autopeering/entrynodes.go +++ b/plugins/autopeering/entrynodes.go @@ -11,7 +11,7 @@ import ( ) func parseEntryNodes() (result []*peer.Peer, err error) { - for _, entryNodeDefinition := range strings.Fields(parameter.NodeConfig.GetString(CFG_ENTRY_NODES)) { + for _, entryNodeDefinition := range parameter.NodeConfig.GetStringSlice(CFG_ENTRY_NODES) { if entryNodeDefinition == "" { continue } diff --git a/plugins/autopeering/parameters.go b/plugins/autopeering/parameters.go index e5b2c7f291..27b117006e 100644 --- a/plugins/autopeering/parameters.go +++ b/plugins/autopeering/parameters.go @@ -13,7 +13,7 @@ const ( func init() { flag.String(CFG_ADDRESS, "0.0.0.0", "address to bind for incoming peering requests") - flag.String(CFG_ENTRY_NODES, "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626", "list of trusted entry nodes for auto peering") + flag.StringSlice(CFG_ENTRY_NODES, []string{"V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626"}, "list of trusted entry nodes for auto peering") flag.Int(CFG_PORT, 14626, "udp port for incoming peering requests") flag.Bool(CFG_SELECTION, true, "enable peer selection") } From 6d380e33f7a10e47be9d32268802c61921f12a76 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Mon, 30 Dec 2019 19:42:15 +0100 Subject: [PATCH 057/184] Update provided config file --- config.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/config.json b/config.json index 93dbdd992d..b86b494423 100644 --- a/config.json +++ b/config.json @@ -9,7 +9,7 @@ }, "analysis": { "serverPort": 0, - "serverAddress": "159.69.158.51:188" + "serverAddress": "ressims.iota.cafe:188" }, "gossip": { "port": 14666 @@ -21,9 +21,8 @@ "address": "0.0.0.0", "port": 14626, "entryNodes": [ - "7f7a876a4236091257e650da8dcf195fbe3cb625@159.69.158.51:14626" + "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626" ], - "acceptRequests": true, - "sendRequests": true + "selection": true } } \ No newline at end of file From 3b83a26840694eae13f7ab7bdf5e7e5e987e195b Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Mon, 30 Dec 2019 19:59:59 +0100 Subject: [PATCH 058/184] Upgrade dependencies --- go.mod | 16 +++++++++------- go.sum | 56 +++++++++++++++++++------------------------------------- 2 files changed, 28 insertions(+), 44 deletions(-) diff --git a/go.mod b/go.mod index 9c9001471b..60cc8d7c51 100644 --- a/go.mod +++ b/go.mod @@ -6,36 +6,38 @@ require ( github.com/dgraph-io/badger v1.6.0 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/gdamore/tcell v1.3.0 - github.com/go-zeromq/zmq4 v0.6.2 + github.com/go-zeromq/zmq4 v0.7.0 github.com/golang/protobuf v1.3.2 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 github.com/iotaledger/autopeering-sim v0.0.0-20191230110650-35e88c0f9fe6 github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20 - github.com/iotaledger/iota.go v1.0.0-beta.10 + github.com/iotaledger/iota.go v1.0.0-beta.12 github.com/labstack/echo v3.3.10+incompatible github.com/lucasb-eyer/go-colorful v1.0.3 // indirect github.com/magiconair/properties v1.8.1 github.com/mattn/go-colorable v0.1.4 // indirect - github.com/mattn/go-isatty v0.0.10 // indirect - github.com/mattn/go-runewidth v0.0.6 // indirect + github.com/mattn/go-isatty v0.0.11 // indirect + github.com/mattn/go-runewidth v0.0.7 // indirect github.com/pelletier/go-toml v1.6.0 // indirect github.com/pkg/errors v0.8.1 - github.com/rivo/tview v0.0.0-20191121195645-2d957c4be01d + github.com/rivo/tview v0.0.0-20191229165609-1ee8d9874dcf github.com/spf13/afero v1.2.2 // indirect github.com/spf13/cast v1.3.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.6.1 // indirect + github.com/stretchr/objx v0.2.0 // indirect github.com/stretchr/testify v1.4.0 github.com/valyala/fasttemplate v1.1.0 // indirect go.uber.org/zap v1.13.0 - golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c + golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 // indirect - golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4 // indirect + golang.org/x/tools v0.0.0-20191230181014-9fb4d21460e1 // indirect + golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect gopkg.in/ini.v1 v1.51.1 // indirect gopkg.in/yaml.v2 v2.2.7 // indirect ) diff --git a/go.sum b/go.sum index aef858272c..78860b4fa7 100644 --- a/go.sum +++ b/go.sum @@ -2,7 +2,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0= @@ -30,7 +29,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgraph-io/badger v1.5.4/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ= -github.com/dgraph-io/badger v1.6.0 h1:DshxFxZWXUcO0xX476VJC07Xsr6ZCBVRHKZ93Oh7Evo= github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= @@ -39,12 +37,9 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUn github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b h1:SeiGBzKrEtuDddnBABHkp4kq9sBGE9nuYmk6FPTg0zg= github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/ethereum/go-ethereum v1.9.3/go.mod h1:PwpWDrCLZrV+tfrhqqF6kPknbISMHaJv9Ln3kPCZLwY= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/tcell v1.1.2/go.mod h1:h3kq4HO9l2On+V9ed8w8ewqQEmGCSSHOgQ+2h8uzurE= github.com/gdamore/tcell v1.2.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM= @@ -58,8 +53,8 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me github.com/go-zeromq/goczmq/v4 v4.2.2 h1:HAJN+i+3NW55ijMJJhk7oWxHKXgAuSBkoFfvr8bYj4U= github.com/go-zeromq/goczmq/v4 v4.2.2/go.mod h1:Sm/lxrfxP/Oxqs0tnHD6WAhwkWrx+S+1MRrKzcxoaYE= github.com/go-zeromq/zmq4 v0.5.0/go.mod h1:6p7pjNlkfrQQVipmEuZDk7fakLZCqPPVK+Iq3jfbDg8= -github.com/go-zeromq/zmq4 v0.6.2 h1:MjiFSwpiQax3LbErEV+H4eNOETGQNwbngq9MlebocbI= -github.com/go-zeromq/zmq4 v0.6.2/go.mod h1:fo1rWyfV/bsg7tq/F9LF1H0e2Cf3ovQFoge1G21AnWU= +github.com/go-zeromq/zmq4 v0.7.0 h1:tmmTVfWB0HYo+8Ra0DK2MJIDl1lsvuU/J9559hpLU7s= +github.com/go-zeromq/zmq4 v0.7.0/go.mod h1:fo1rWyfV/bsg7tq/F9LF1H0e2Cf3ovQFoge1G21AnWU= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -67,7 +62,6 @@ github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4er github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -86,7 +80,6 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmg github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -99,8 +92,8 @@ github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20 h1:ZIJAeQSEdmVb github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20/go.mod h1:7iqun29a1x0lymTrn0UJ3Z/yy0sUzUpoOZ1OYMrYN20= github.com/iotaledger/iota.go v1.0.0-beta.7/go.mod h1:dMps6iMVU1pf5NDYNKIw4tRsPeC8W3ZWjOvYHOO1PMg= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= -github.com/iotaledger/iota.go v1.0.0-beta.10 h1:PBRWEcBSw0UO7zqEHJLrHOUbjJj1eldlERzOyka/GJo= -github.com/iotaledger/iota.go v1.0.0-beta.10/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= +github.com/iotaledger/iota.go v1.0.0-beta.12 h1:p6Pk3N8tmb6Kaj8F45O5XVJQfH5qQYqpvUnXiSMrtiE= +github.com/iotaledger/iota.go v1.0.0-beta.12/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= @@ -115,7 +108,6 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= @@ -123,21 +115,19 @@ github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1 github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= -github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM= +github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.6 h1:V2iyH+aX9C5fsYCpK60U8BYIvmhqxuOL3JZcqc1NB7k= -github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54= +github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= @@ -154,9 +144,7 @@ github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= @@ -168,10 +156,9 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341/go.mod h1:+rKjP5+h9HMwWRpAfhIkkQ9KE3m3Nz5rwn7YtUpwgqk= -github.com/rivo/tview v0.0.0-20191121195645-2d957c4be01d h1:dPWYyMzc2VB5XX7eA/Pe5TXBGzhlVZZr54GhRJLTbts= -github.com/rivo/tview v0.0.0-20191121195645-2d957c4be01d/go.mod h1:/rBeY22VG2QprWnEqG57IBC8biVu3i0DOIjRLc9I8H0= +github.com/rivo/tview v0.0.0-20191229165609-1ee8d9874dcf h1:rh73WIukDlFIRqk1lk76or+LExEjTci2789EDvDD67U= +github.com/rivo/tview v0.0.0-20191229165609-1ee8d9874dcf/go.mod h1:/rBeY22VG2QprWnEqG57IBC8biVu3i0DOIjRLc9I8H0= github.com/rivo/uniseg v0.0.0-20190513083848-b9f5b9457d44/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -187,15 +174,12 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9 github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= -github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -205,11 +189,11 @@ github.com/spf13/viper v1.5.0/go.mod h1:AkYRkVJF8TkSG/xet6PzXX+l39KhhXa2pdqVSxnT github.com/spf13/viper v1.6.1 h1:VPZzIkznI1YhVMRi6vNFLHSwhnhReBfgTxIPccpfdZk= github.com/spf13/viper v1.6.1/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= +github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= @@ -217,7 +201,6 @@ github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhV github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.1.0 h1:RZqt0yGBsps8NGvLSGW804QQqCUYYLsaOjTVHy1Ocw4= @@ -248,8 +231,8 @@ golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaE golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c h1:/nJuwDLoL/zrqY6gf57vxC+Pi+pZ8bfhpPkicO5H7W4= -golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 h1:sKJQZMuxjOAR/Uo2LBfU90onWEf1dF4C+0hPJCc9Mpc= +golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= @@ -291,13 +274,12 @@ golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191018095205-727590c5006e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 h1:JA8d3MPx/IToSyXZG/RhwYEtfrKO1Fxrqe8KrkiLXKM= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -310,11 +292,12 @@ golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4 h1:Toz2IK7k8rbltAXwNAxKcn9OzqyNfMUhUNjz3sL0NMk= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191230181014-9fb4d21460e1 h1:vNFL7Do+hbqZGmVjqkjTBUugGFXohWPyiHMLqLUbtP4= +golang.org/x/tools v0.0.0-20191230181014-9fb4d21460e1/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -327,7 +310,6 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/h2non/gock.v1 v1.0.14/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE= -gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.51.1 h1:GyboHr4UqMiLUybYjd22ZjQIKEJEpgtLXtuGbR21Oho= gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= From 60efb2aab0b05d5f2cd2a4efe4a2185efb989f5b Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Fri, 3 Jan 2020 19:00:38 +0100 Subject: [PATCH 059/184] fix: Run autopeering plugin as a daemon --- packages/gossip/transport/transport.go | 4 +- plugins/autopeering/autopeering.go | 203 ++++++++++++++----------- plugins/autopeering/entrynodes.go | 35 ----- plugins/autopeering/plugin.go | 21 +-- 4 files changed, 123 insertions(+), 140 deletions(-) delete mode 100644 plugins/autopeering/entrynodes.go diff --git a/packages/gossip/transport/transport.go b/packages/gossip/transport/transport.go index 97f98f00e4..39d6c32b28 100644 --- a/packages/gossip/transport/transport.go +++ b/packages/gossip/transport/transport.go @@ -89,12 +89,12 @@ func Listen(local *peer.Local, log *zap.SugaredLogger) (*TCP, error) { if err != nil { return nil, err } - // if the ip is an external ip, set it to zero + // if the ip is an external ip, set it to unspecified if tcpAddr.IP.IsGlobalUnicast() { if tcpAddr.IP.To4() != nil { tcpAddr.IP = net.IPv4zero } else { - tcpAddr.IP = net.IPv6zero + tcpAddr.IP = net.IPv6unspecified } } diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 314459ed66..ea761dbfb7 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -7,6 +7,7 @@ import ( "net" "net/http" "strconv" + "strings" "github.com/iotaledger/autopeering-sim/discover" "github.com/iotaledger/autopeering-sim/logger" @@ -17,16 +18,16 @@ import ( "github.com/iotaledger/autopeering-sim/transport" "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/gossip" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/parameter" - "go.uber.org/zap" + "github.com/pkg/errors" ) var ( - debugLevel = "info" - close = make(chan struct{}, 1) - srv *server.Server - Discovery *discover.Protocol - Selection *selection.Protocol + // Discovery is the peer discovery protocol. + Discovery *discover.Protocol + // Selection is the peer selection protocol. + Selection *selection.Protocol ) const defaultZLC = `{ @@ -50,67 +51,53 @@ const defaultZLC = `{ } }` -var ( - db peer.DB - trans *transport.TransportConn - zLogger *zap.SugaredLogger - handlers []server.Handler - conn *net.UDPConn -) +var zLogger = logger.NewLogger(defaultZLC, "info") -func configureAP() { - host := parameter.NodeConfig.GetString(CFG_ADDRESS) - localhost := host - apPort := strconv.Itoa(parameter.NodeConfig.GetInt(CFG_PORT)) - gossipPort := strconv.Itoa(parameter.NodeConfig.GetInt(gossip.GOSSIP_PORT)) - - if host == "0.0.0.0" { - host = getMyIP() - } - - listenAddr := host + ":" + apPort - gossipAddr := host + ":" + gossipPort - - zLogger = logger.NewLogger(defaultZLC, debugLevel) - - addr, err := net.ResolveUDPAddr("udp", localhost+":"+apPort) - if err != nil { - log.Fatalf("ResolveUDPAddr: %v", err) - } - conn, err = net.ListenUDP("udp", addr) - if err != nil { - log.Fatalf("ListenUDP: %v", err) +func configureLocal() { + ip := net.ParseIP(parameter.NodeConfig.GetString(CFG_ADDRESS)) + if ip == nil { + log.Fatalf("Invalid IP address: %s", parameter.NodeConfig.GetString(CFG_ADDRESS)) } - - var masterPeers []*peer.Peer - peers, err := parseEntryNodes() - if err != nil { - log.Fatalf("Ignoring entry nodes: %v\n", err) - } else if peers != nil { - masterPeers = peers + if ip.IsUnspecified() { + myIp, err := getMyIP() + if err != nil { + log.Fatalf("Could not query public IP: %v", err) + } + ip = myIp } - // use the UDP connection for transport - trans = transport.Conn(conn, func(network, address string) (net.Addr, error) { return net.ResolveUDPAddr(network, address) }) + apPort := strconv.Itoa(parameter.NodeConfig.GetInt(CFG_PORT)) + gossipPort := strconv.Itoa(parameter.NodeConfig.GetInt(gossip.GOSSIP_PORT)) // create a new local node - db = peer.NewPersistentDB(zLogger.Named("db")) + db := peer.NewPersistentDB(zLogger.Named("db")) - local.INSTANCE, err = peer.NewLocal("udp", listenAddr, db) + var err error + local.INSTANCE, err = peer.NewLocal(NETWORK, net.JoinHostPort(ip.String(), apPort), db) if err != nil { - log.Fatalf("ListenUDP: %v", err) + log.Fatalf("NewLocal: %v", err) } // add a service for the gossip if parameter.NodeConfig.GetBool(CFG_SELECTION) { - local.INSTANCE.UpdateService(service.GossipKey, "tcp", gossipAddr) + err = local.INSTANCE.UpdateService(service.GossipKey, "tcp", net.JoinHostPort(ip.String(), gossipPort)) + if err != nil { + log.Fatalf("UpdateService: %v", err) + } + } +} + +func configureAP() { + masterPeers, err := parseEntryNodes() + if err != nil { + log.Errorf("Invalid entry nodes; ignoring: %v", err) } + log.Debugf("Master peers: %v", masterPeers) Discovery = discover.New(local.INSTANCE, discover.Config{ Log: zLogger.Named("disc"), MasterPeers: masterPeers, }) - handlers = append([]server.Handler{}, Discovery) if parameter.NodeConfig.GetBool(CFG_SELECTION) { Selection = selection.New(local.INSTANCE, Discovery, selection.Config{ @@ -120,73 +107,103 @@ func configureAP() { RequiredService: []service.Key{service.GossipKey}, }, }) - handlers = append(handlers, Selection) } } func start() { + defer log.Info("Stopping Auto Peering server ... done") + + addr := local.INSTANCE.Services().Get(service.PeeringKey) + udpAddr, err := net.ResolveUDPAddr(addr.Network(), addr.String()) + if err != nil { + log.Fatalf("ResolveUDPAddr: %v", err) + } + + // if the ip is an external ip, set it to unspecified + if udpAddr.IP.IsGlobalUnicast() { + if udpAddr.IP.To4() != nil { + udpAddr.IP = net.IPv4zero + } else { + udpAddr.IP = net.IPv6unspecified + } + } + + conn, err := net.ListenUDP(addr.Network(), udpAddr) + if err != nil { + log.Fatalf("ListenUDP: %v", err) + } + + // use the UDP connection for transport + trans := transport.Conn(conn, func(network, address string) (net.Addr, error) { return net.ResolveUDPAddr(network, address) }) + defer trans.Close() + + handlers := []server.Handler{Discovery} + if Selection != nil { + handlers = append(handlers, Selection) + } + // start a server doing discovery and peering - srv = server.Listen(local.INSTANCE, trans, zLogger.Named("srv"), handlers...) + srv := server.Listen(local.INSTANCE, trans, zLogger.Named("srv"), handlers...) + defer srv.Close() // start the discovery on that connection Discovery.Start(srv) + defer Discovery.Close() - // start the peering on that connection - if parameter.NodeConfig.GetBool(CFG_SELECTION) { + if Selection != nil { + // start the peering on that connection Selection.Start(srv) defer Selection.Close() } - id := base64.StdEncoding.EncodeToString(local.INSTANCE.PublicKey()) - zLogger.Info("Discovery protocol started: ID=" + id + ", address=" + srv.LocalAddr()) + log.Infof("Auto Peering server started: ID=%x, address=%s", local.INSTANCE.ID(), srv.LocalAddr()) - defer func() { - _ = zLogger.Sync() // ignore the returned error - trans.Close() - db.Close() - conn.Close() - srv.Close() - Discovery.Close() - }() + <-daemon.ShutdownSignal + log.Info("Stopping Auto Peering server ...") +} - // Only for debug - // go func() { - // for t := range time.NewTicker(2 * time.Second).C { - // _ = t - // printReport(zLogger) - // } - // }() +func parseEntryNodes() (result []*peer.Peer, err error) { + for _, entryNodeDefinition := range parameter.NodeConfig.GetStringSlice(CFG_ENTRY_NODES) { + if entryNodeDefinition == "" { + continue + } + + parts := strings.Split(entryNodeDefinition, "@") + if len(parts) != 2 { + return nil, fmt.Errorf("parseMaster") + } + pubKey, err := base64.StdEncoding.DecodeString(parts[0]) + if err != nil { + return nil, errors.Wrap(err, "parseMaster") + } + + services := service.New() + services.Update(service.PeeringKey, "udp", parts[1]) + + result = append(result, peer.NewPeer(pubKey, services)) + } - <-close + return result, nil } -func getMyIP() string { +func getMyIP() (net.IP, error) { url := "https://api.ipify.org?format=text" resp, err := http.Get(url) if err != nil { - return "" + return nil, err } defer resp.Body.Close() - ip, err := ioutil.ReadAll(resp.Body) + + body, err := ioutil.ReadAll(resp.Body) if err != nil { - return "" + return nil, err } - return fmt.Sprintf("%s", ip) -} -// used only for debugging puropose -// func printReport(log *zap.SugaredLogger) { -// if Discovery == nil || Selection == nil { -// return -// } -// knownPeers := Discovery.GetVerifiedPeers() -// incoming := []*peer.Peer{} -// outgoing := []*peer.Peer{} -// if Selection != nil { -// incoming = Selection.GetIncomingNeighbors() -// outgoing = Selection.GetOutgoingNeighbors() -// } -// log.Info("Known peers:", len(knownPeers)) -// log.Info("Chosen:", len(outgoing)) -// log.Info("Accepted:", len(incoming)) -// } + // the body only consists of the ip address + ip := net.ParseIP(string(body)) + if ip == nil { + return nil, fmt.Errorf("not an IP: %s", body) + } + + return ip, nil +} diff --git a/plugins/autopeering/entrynodes.go b/plugins/autopeering/entrynodes.go deleted file mode 100644 index 1b4384d37d..0000000000 --- a/plugins/autopeering/entrynodes.go +++ /dev/null @@ -1,35 +0,0 @@ -package autopeering - -import ( - "encoding/base64" - "strings" - - "github.com/iotaledger/autopeering-sim/peer" - "github.com/iotaledger/autopeering-sim/peer/service" - "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/hive.go/parameter" -) - -func parseEntryNodes() (result []*peer.Peer, err error) { - for _, entryNodeDefinition := range parameter.NodeConfig.GetStringSlice(CFG_ENTRY_NODES) { - if entryNodeDefinition == "" { - continue - } - - parts := strings.Split(entryNodeDefinition, "@") - if len(parts) != 2 { - return nil, errors.New("parseMaster") - } - pubKey, err := base64.StdEncoding.DecodeString(parts[0]) - if err != nil { - return nil, errors.Wrap(err, "parseMaster") - } - - services := service.New() - services.Update(service.PeeringKey, "udp", parts[1]) - - result = append(result, peer.NewPeer(pubKey, services)) - } - - return result, nil -} diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 9168f07022..904a19ffb5 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -9,23 +9,24 @@ import ( "github.com/iotaledger/hive.go/node" ) -var PLUGIN = node.NewPlugin("Auto Peering", node.Enabled, configure, run) -var log = logger.NewLogger("Autopeering") +// NETWORK defines the network type used for the autopeering. +const NETWORK = "udp" -func configure(plugin *node.Plugin) { - daemon.Events.Shutdown.Attach(events.NewClosure(func() { - close <- struct{}{} - })) +var PLUGIN = node.NewPlugin("Autopeering", node.Enabled, configure, run) + +var log = logger.NewLogger("Autopeering") +func configure(*node.Plugin) { + configureEvents() + configureLocal() configureAP() - configureLogging(plugin) } -func run(plugin *node.Plugin) { - go start() +func run(*node.Plugin) { + daemon.BackgroundWorker("Autopeering", start) } -func configureLogging(plugin *node.Plugin) { +func configureEvents() { gossip.Events.NeighborDropped.Attach(events.NewClosure(func(ev *gossip.NeighborDroppedEvent) { log.Info("neighbor dropped: " + ev.Peer.Address() + " / " + ev.Peer.ID().String()) if Selection != nil { From b16c56308c0391006acc5ddeba7e8271237d264d Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Sat, 4 Jan 2020 13:15:41 +0100 Subject: [PATCH 060/184] fix: Run gossip plugin as a daemon --- packages/gossip/errors.go | 1 + packages/gossip/manager.go | 74 +++++++----- packages/gossip/manager_test.go | 15 ++- .../{transport => server}/connection.go | 2 +- .../gossip/{transport => server}/handshake.go | 4 +- .../proto/handshake.pb.go | 7 +- .../proto/handshake.proto | 0 .../transport.go => server/server.go} | 10 +- .../server_test.go} | 4 +- plugins/autopeering/autopeering.go | 2 +- plugins/autopeering/plugin.go | 15 ++- plugins/gossip/gossip.go | 110 ++++++------------ plugins/gossip/plugin.go | 69 +++++++++-- 13 files changed, 179 insertions(+), 134 deletions(-) rename packages/gossip/{transport => server}/connection.go (96%) rename packages/gossip/{transport => server}/handshake.go (95%) rename packages/gossip/{transport => server}/proto/handshake.pb.go (97%) rename packages/gossip/{transport => server}/proto/handshake.proto (100%) rename packages/gossip/{transport/transport.go => server/server.go} (97%) rename packages/gossip/{transport/transport_test.go => server/server_test.go} (98%) diff --git a/packages/gossip/errors.go b/packages/gossip/errors.go index 7be5d0fc55..160ed5513d 100644 --- a/packages/gossip/errors.go +++ b/packages/gossip/errors.go @@ -3,6 +3,7 @@ package gossip import "github.com/pkg/errors" var ( + ErrNotStarted = errors.New("manager not started") ErrClosed = errors.New("manager closed") ErrNotANeighbor = errors.New("peer is not a neighbor") ErrDuplicateNeighbor = errors.New("peer already connected") diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go index 8c11efba42..897f1c50c9 100644 --- a/packages/gossip/manager.go +++ b/packages/gossip/manager.go @@ -6,47 +6,57 @@ import ( "strings" "sync" + "github.com/iotaledger/autopeering-sim/peer/service" + "github.com/golang/protobuf/proto" "github.com/iotaledger/autopeering-sim/peer" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" - "github.com/iotaledger/goshimmer/packages/gossip/transport" + "github.com/iotaledger/goshimmer/packages/gossip/server" "github.com/pkg/errors" "go.uber.org/zap" ) const ( - maxConnectionAttempts = 3 - maxPacketSize = 2048 + maxPacketSize = 2048 ) type GetTransaction func(txHash []byte) ([]byte, error) type Manager struct { - trans *transport.TCP - log *zap.SugaredLogger + local *peer.Local getTransaction GetTransaction + log *zap.SugaredLogger wg sync.WaitGroup mu sync.RWMutex + srv *server.TCP neighbors map[peer.ID]*neighbor running bool } type neighbor struct { peer *peer.Peer - conn *transport.Connection + conn *server.Connection } -func NewManager(t *transport.TCP, log *zap.SugaredLogger, f GetTransaction) *Manager { - m := &Manager{ - trans: t, - log: log, +func NewManager(local *peer.Local, f GetTransaction, log *zap.SugaredLogger) *Manager { + return &Manager{ + local: local, getTransaction: f, + log: log, + srv: nil, neighbors: make(map[peer.ID]*neighbor), + running: false, } +} + +func (m *Manager) Start(srv *server.TCP) { + m.mu.Lock() + defer m.mu.Unlock() + + m.srv = srv m.running = true - return m } // Close stops the manager and closes all established connections. @@ -62,14 +72,35 @@ func (m *Manager) Close() { m.wg.Wait() } +// LocalAddr returns the public address of the gossip service. +func (m *Manager) LocalAddr() net.Addr { + return m.local.Services().Get(service.GossipKey) +} + // AddOutbound tries to add a neighbor by connecting to that peer. func (m *Manager) AddOutbound(p *peer.Peer) error { - return m.addNeighbor(p, m.trans.DialPeer) + var srv *server.TCP + m.mu.RLock() + if m.srv == nil { + return ErrNotStarted + } + srv = m.srv + m.mu.RUnlock() + + return m.addNeighbor(p, srv.DialPeer) } // AddInbound tries to add a neighbor by accepting an incoming connection from that peer. func (m *Manager) AddInbound(p *peer.Peer) error { - return m.addNeighbor(p, m.trans.AcceptPeer) + var srv *server.TCP + m.mu.RLock() + if m.srv == nil { + return ErrNotStarted + } + srv = m.srv + m.mu.RUnlock() + + return m.addNeighbor(p, srv.AcceptPeer) } // NeighborDropped disconnects the neighbor with the given ID. @@ -151,19 +182,8 @@ func (m *Manager) send(msg []byte, to ...peer.ID) { } } -func (m *Manager) addNeighbor(peer *peer.Peer, connectorFunc func(*peer.Peer) (*transport.Connection, error)) error { - var ( - err error - conn *transport.Connection - ) - for i := 0; i < maxConnectionAttempts; i++ { - conn, err = connectorFunc(peer) - if err == nil { - break - } - } - - // could not add neighbor +func (m *Manager) addNeighbor(peer *peer.Peer, connectorFunc func(*peer.Peer) (*server.Connection, error)) error { + conn, err := connectorFunc(peer) if err != nil { m.log.Debugw("addNeighbor failed", "peer", peer.ID(), "err", err) Events.NeighborDropped.Trigger(&NeighborDroppedEvent{Peer: peer}) @@ -273,7 +293,7 @@ func marshal(msg pb.Message) []byte { return append([]byte{byte(mType)}, data...) } -func disconnect(conn *transport.Connection) { +func disconnect(conn *server.Connection) { _ = conn.Close() Events.NeighborDropped.Trigger(&NeighborDroppedEvent{Peer: conn.Peer()}) } diff --git a/packages/gossip/manager_test.go b/packages/gossip/manager_test.go index df9e83337b..789b86992f 100644 --- a/packages/gossip/manager_test.go +++ b/packages/gossip/manager_test.go @@ -11,7 +11,7 @@ import ( "github.com/iotaledger/autopeering-sim/peer" "github.com/iotaledger/autopeering-sim/peer/service" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" - "github.com/iotaledger/goshimmer/packages/gossip/transport" + "github.com/iotaledger/goshimmer/packages/gossip/server" "github.com/iotaledger/hive.go/events" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -78,17 +78,20 @@ func newTest(t require.TestingT, name string) (*Manager, func(), *peer.Peer) { // enable TCP gossipping require.NoError(t, local.UpdateService(service.GossipKey, "tcp", getTCPAddress(t))) - trans, err := transport.Listen(local, l) - require.NoError(t, err) + mgr := NewManager(local, getTestTransaction, l) - mgr := NewManager(trans, l, getTestTransaction) + srv, err := server.ListenTCP(local, l) + require.NoError(t, err) // update the service with the actual address - require.NoError(t, local.UpdateService(service.GossipKey, trans.LocalAddr().Network(), trans.LocalAddr().String())) + require.NoError(t, local.UpdateService(service.GossipKey, srv.LocalAddr().Network(), srv.LocalAddr().String())) + + // start the actual gossipping + mgr.Start(srv) teardown := func() { mgr.Close() - trans.Close() + srv.Close() db.Close() } return mgr, teardown, &local.Peer diff --git a/packages/gossip/transport/connection.go b/packages/gossip/server/connection.go similarity index 96% rename from packages/gossip/transport/connection.go rename to packages/gossip/server/connection.go index d677040f00..076068f140 100644 --- a/packages/gossip/transport/connection.go +++ b/packages/gossip/server/connection.go @@ -1,4 +1,4 @@ -package transport +package server import ( "net" diff --git a/packages/gossip/transport/handshake.go b/packages/gossip/server/handshake.go similarity index 95% rename from packages/gossip/transport/handshake.go rename to packages/gossip/server/handshake.go index 3489a9d66a..ef5bb60ec7 100644 --- a/packages/gossip/transport/handshake.go +++ b/packages/gossip/server/handshake.go @@ -1,4 +1,4 @@ -package transport +package server import ( "bytes" @@ -6,7 +6,7 @@ import ( "github.com/golang/protobuf/proto" "github.com/iotaledger/autopeering-sim/server" - pb "github.com/iotaledger/goshimmer/packages/gossip/transport/proto" + pb "github.com/iotaledger/goshimmer/packages/gossip/server/proto" ) const ( diff --git a/packages/gossip/transport/proto/handshake.pb.go b/packages/gossip/server/proto/handshake.pb.go similarity index 97% rename from packages/gossip/transport/proto/handshake.pb.go rename to packages/gossip/server/proto/handshake.pb.go index da559c8190..c0e7307267 100644 --- a/packages/gossip/transport/proto/handshake.pb.go +++ b/packages/gossip/server/proto/handshake.pb.go @@ -1,12 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: transport/proto/handshake.proto +// source: server/proto/handshake.proto package proto import ( fmt "fmt" - proto "github.com/golang/protobuf/proto" math "math" + + proto "github.com/golang/protobuf/proto" ) // Reference imports to suppress errors if they are not otherwise used. @@ -123,7 +124,7 @@ func init() { proto.RegisterType((*HandshakeResponse)(nil), "proto.HandshakeResponse") } -func init() { proto.RegisterFile("transport/proto/handshake.proto", fileDescriptor_d7101ffe19b05443) } +func init() { proto.RegisterFile("server/proto/handshake.proto", fileDescriptor_d7101ffe19b05443) } var fileDescriptor_d7101ffe19b05443 = []byte{ // 206 bytes of a gzipped FileDescriptorProto diff --git a/packages/gossip/transport/proto/handshake.proto b/packages/gossip/server/proto/handshake.proto similarity index 100% rename from packages/gossip/transport/proto/handshake.proto rename to packages/gossip/server/proto/handshake.proto diff --git a/packages/gossip/transport/transport.go b/packages/gossip/server/server.go similarity index 97% rename from packages/gossip/transport/transport.go rename to packages/gossip/server/server.go index 39d6c32b28..658f6be6df 100644 --- a/packages/gossip/transport/transport.go +++ b/packages/gossip/server/server.go @@ -1,4 +1,4 @@ -package transport +package server import ( "bytes" @@ -21,8 +21,8 @@ import ( var ( // ErrTimeout is returned when an expected incoming connection was not received in time. ErrTimeout = errors.New("accept timeout") - // ErrClosed means that the transport was shut down before a response could be received. - ErrClosed = errors.New("transport closed") + // ErrClosed means that the server was shut down before a response could be received. + ErrClosed = errors.New("server closed") // ErrInvalidHandshake is returned when no correct handshake could be established. ErrInvalidHandshake = errors.New("invalid handshake") // ErrNoGossip means that the given peer does not support the gossip service. @@ -71,8 +71,8 @@ type accept struct { conn net.Conn // the actual network connection } -// Listen creates the object and starts listening for incoming connections. -func Listen(local *peer.Local, log *zap.SugaredLogger) (*TCP, error) { +// ListenTCP creates the object and starts listening for incoming connections. +func ListenTCP(local *peer.Local, log *zap.SugaredLogger) (*TCP, error) { t := &TCP{ local: local, log: log, diff --git a/packages/gossip/transport/transport_test.go b/packages/gossip/server/server_test.go similarity index 98% rename from packages/gossip/transport/transport_test.go rename to packages/gossip/server/server_test.go index 7c1fecf632..e4f0607032 100644 --- a/packages/gossip/transport/transport_test.go +++ b/packages/gossip/server/server_test.go @@ -1,4 +1,4 @@ -package transport +package server import ( "log" @@ -47,7 +47,7 @@ func newTest(t require.TestingT, name string) (*TCP, func()) { // enable TCP gossipping require.NoError(t, local.UpdateService(service.GossipKey, "tcp", getTCPAddress(t))) - trans, err := Listen(local, l) + trans, err := ListenTCP(local, l) require.NoError(t, err) teardown := func() { diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index ea761dbfb7..a7759994b5 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -51,7 +51,7 @@ const defaultZLC = `{ } }` -var zLogger = logger.NewLogger(defaultZLC, "info") +var zLogger = logger.NewLogger(defaultZLC, logLevel) func configureLocal() { ip := net.ParseIP(parameter.NodeConfig.GetString(CFG_ADDRESS)) diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 904a19ffb5..3a71eae9c0 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -9,12 +9,17 @@ import ( "github.com/iotaledger/hive.go/node" ) -// NETWORK defines the network type used for the autopeering. -const NETWORK = "udp" +const ( + // NETWORK defines the network type used for the autopeering. + NETWORK = "udp" -var PLUGIN = node.NewPlugin("Autopeering", node.Enabled, configure, run) + name = "Autopeering" // name of the plugin + logLevel = "info" +) + +var PLUGIN = node.NewPlugin(name, node.Enabled, configure, run) -var log = logger.NewLogger("Autopeering") +var log = logger.NewLogger(name) func configure(*node.Plugin) { configureEvents() @@ -23,7 +28,7 @@ func configure(*node.Plugin) { } func run(*node.Plugin) { - daemon.BackgroundWorker("Autopeering", start) + daemon.BackgroundWorker(name, start) } func configureEvents() { diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index efbb650e22..3ce2dc711f 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -1,21 +1,22 @@ package gossip import ( - "errors" + "fmt" "github.com/golang/protobuf/proto" - zL "github.com/iotaledger/autopeering-sim/logger" - "github.com/iotaledger/autopeering-sim/peer/service" - "github.com/iotaledger/autopeering-sim/selection" - "github.com/iotaledger/goshimmer/packages/gossip" + "github.com/iotaledger/autopeering-sim/logger" + "github.com/iotaledger/goshimmer/packages/errors" gp "github.com/iotaledger/goshimmer/packages/gossip" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" - "github.com/iotaledger/goshimmer/packages/gossip/transport" - "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/gossip/server" + "github.com/iotaledger/goshimmer/packages/typeutils" "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/tangle" - "github.com/iotaledger/hive.go/events" - "go.uber.org/zap" + "github.com/iotaledger/hive.go/daemon" +) + +var ( + mgr *gp.Manager ) const defaultZLC = `{ @@ -39,80 +40,45 @@ const defaultZLC = `{ } }` -var ( - debugLevel = "info" - zLogger *zap.SugaredLogger - mgr *gp.Manager -) +var zLogger = logger.NewLogger(defaultZLC, logLevel) -func getTransaction(h []byte) ([]byte, error) { - log.Info("Retrieving tx:", string(h)) - tx, err := tangle.GetTransaction(string(h)) - if err != nil { - return []byte{}, err - } - if tx == nil { - return []byte{}, errors.New("Not found") - } - pTx := &pb.TransactionRequest{ - Hash: tx.GetBytes(), - } - b, _ := proto.Marshal(pTx) - return b, nil +func configureGossip() { + mgr = gp.NewManager(local.INSTANCE, getTransaction, zLogger) } -func configureGossip() { - zLogger = zL.NewLogger(defaultZLC, debugLevel) +func start() { + defer log.Info("Stopping Gossip ... done") - trans, err := transport.Listen(local.INSTANCE, zLogger) + srv, err := server.ListenTCP(local.INSTANCE, zLogger) if err != nil { - log.Fatal(err) + log.Fatalf("ListenTCP: %v", err) } + defer srv.Close() - mgr = gp.NewManager(trans, zLogger, getTransaction) - - log.Info("Gossip started @", trans.LocalAddr().String()) -} + mgr.Start(srv) + defer mgr.Close() -func configureEvents() { + log.Infof("Gossip started: address=%v", mgr.LocalAddr()) - selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) { - log.Info("neighbor removed: " + ev.DroppedID.String()) - go mgr.DropNeighbor(ev.DroppedID) - })) + <-daemon.ShutdownSignal + log.Info("Stopping Gossip ...") +} - selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { - gossipService := ev.Peer.Services().Get(service.GossipKey) - if gossipService != nil { - log.Info("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - go mgr.AddInbound(ev.Peer) - } - })) +func getTransaction(hash []byte) ([]byte, error) { + log.Infof("Retrieving tx: hash=%s", hash) - selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { - gossipService := ev.Peer.Services().Get(service.GossipKey) - if gossipService != nil { - log.Info("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - go mgr.AddOutbound(ev.Peer) - } - })) + tx, err := tangle.GetTransaction(typeutils.BytesToString(hash)) + if err != nil { + return nil, errors.Wrap(err, "could not get transaction") + } + if tx == nil { + return nil, fmt.Errorf("transaction not found: hash=%s", hash) + } - tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { - log.Info("gossip solid tx", tx.MetaTransaction.GetHash()) - t := &pb.Transaction{ - Body: tx.MetaTransaction.GetBytes(), - } - b, err := proto.Marshal(t) - if err != nil { - return - } - go mgr.SendTransaction(b) - })) + pTx := &pb.TransactionRequest{ + Hash: tx.GetBytes(), + } + b, _ := proto.Marshal(pTx) - gossip.Events.RequestTransaction.Attach(events.NewClosure(func(ev *gossip.RequestTransactionEvent) { - pTx := &pb.TransactionRequest{} - proto.Unmarshal(ev.Hash, pTx) - log.Info("Tx Requested:", string(pTx.Hash)) - go mgr.RequestTransaction(pTx.Hash) - })) + return b, nil } diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 5bf6cfca6e..963a830e4d 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -1,26 +1,75 @@ package gossip import ( + "github.com/golang/protobuf/proto" + "github.com/iotaledger/autopeering-sim/peer/service" + "github.com/iotaledger/autopeering-sim/selection" + "github.com/iotaledger/goshimmer/packages/gossip" + pb "github.com/iotaledger/goshimmer/packages/gossip/proto" + "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" ) -var PLUGIN = node.NewPlugin("Gossip", node.Enabled, configure, run) -var log = logger.NewLogger("Gossip") - -var ( - close = make(chan struct{}, 1) +const ( + name = "Gossip" // name of the plugin + logLevel = "info" ) -func configure(plugin *node.Plugin) { - daemon.Events.Shutdown.Attach(events.NewClosure(func() { - close <- struct{}{} - })) +var PLUGIN = node.NewPlugin(name, node.Enabled, configure, run) + +var log = logger.NewLogger(name) + +func configure(*node.Plugin) { configureGossip() configureEvents() } -func run(plugin *node.Plugin) { +func run(*node.Plugin) { + daemon.BackgroundWorker(name, start) +} + +func configureEvents() { + selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) { + log.Info("neighbor removed: " + ev.DroppedID.String()) + go mgr.DropNeighbor(ev.DroppedID) + })) + + selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { + gossipService := ev.Peer.Services().Get(service.GossipKey) + if gossipService != nil { + log.Info("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) + go mgr.AddInbound(ev.Peer) + } + })) + + selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { + gossipService := ev.Peer.Services().Get(service.GossipKey) + if gossipService != nil { + log.Info("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) + go mgr.AddOutbound(ev.Peer) + } + })) + + tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { + log.Info("gossip solid tx", tx.MetaTransaction.GetHash()) + t := &pb.Transaction{ + Body: tx.MetaTransaction.GetBytes(), + } + b, err := proto.Marshal(t) + if err != nil { + return + } + go mgr.SendTransaction(b) + })) + + gossip.Events.RequestTransaction.Attach(events.NewClosure(func(ev *gossip.RequestTransactionEvent) { + pTx := &pb.TransactionRequest{} + proto.Unmarshal(ev.Hash, pTx) + log.Info("Tx Requested:", string(pTx.Hash)) + go mgr.RequestTransaction(pTx.Hash) + })) } From 12408bad076925f3816112404929e1e914c2d93f Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Sat, 4 Jan 2020 13:49:04 +0100 Subject: [PATCH 061/184] fix: remove useless proto calls in gossip --- packages/gossip/events.go | 26 +++++------ packages/gossip/manager.go | 7 +-- packages/gossip/manager_test.go | 10 ++--- packages/gossip/proto/message.pb.go | 43 ++++++++++--------- packages/gossip/proto/message.proto | 4 +- .../transactionspammer/transactionspammer.go | 6 +-- plugins/gossip/gossip.go | 10 +---- plugins/gossip/plugin.go | 20 +++------ plugins/tangle/solidifier.go | 18 ++------ plugins/tangle/solidifier_test.go | 26 +++-------- plugins/webapi-send-data/plugin.go | 11 +---- 11 files changed, 68 insertions(+), 113 deletions(-) diff --git a/packages/gossip/events.go b/packages/gossip/events.go index 7792214bcd..5483e3f146 100644 --- a/packages/gossip/events.go +++ b/packages/gossip/events.go @@ -3,32 +3,38 @@ package gossip import ( "github.com/iotaledger/autopeering-sim/peer" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/iota.go/trinary" ) // Events contains all the events related to the gossip protocol. var Events = struct { - // A TransactionReceived event is triggered when a new transaction is received by the gossip protocol. - TransactionReceived *events.Event // A NeighborDropped event is triggered when a neighbor has been dropped. NeighborDropped *events.Event + // A TransactionReceived event is triggered when a new transaction is received by the gossip protocol. + TransactionReceived *events.Event // A RequestTransaction should be triggered for a transaction to be requested through the gossip protocol. RequestTransaction *events.Event }{ - TransactionReceived: events.NewEvent(transactionReceived), NeighborDropped: events.NewEvent(neighborDropped), + TransactionReceived: events.NewEvent(transactionReceived), RequestTransaction: events.NewEvent(requestTransaction), } -type TransactionReceivedEvent struct { - Body []byte +type NeighborDroppedEvent struct { Peer *peer.Peer } +type TransactionReceivedEvent struct { + Data []byte // transaction data + Peer *peer.Peer // peer that send the transaction +} + type RequestTransactionEvent struct { - Hash []byte // hash of the transaction to request + Hash trinary.Trytes // hash of the transaction to request } -type NeighborDroppedEvent struct { - Peer *peer.Peer + +func neighborDropped(handler interface{}, params ...interface{}) { + handler.(func(*NeighborDroppedEvent))(params[0].(*NeighborDroppedEvent)) } func transactionReceived(handler interface{}, params ...interface{}) { @@ -38,7 +44,3 @@ func transactionReceived(handler interface{}, params ...interface{}) { func requestTransaction(handler interface{}, params ...interface{}) { handler.(func(*RequestTransactionEvent))(params[0].(*RequestTransactionEvent)) } - -func neighborDropped(handler interface{}, params ...interface{}) { - handler.(func(*NeighborDroppedEvent))(params[0].(*NeighborDroppedEvent)) -} diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go index 897f1c50c9..fb1073bf5d 100644 --- a/packages/gossip/manager.go +++ b/packages/gossip/manager.go @@ -20,6 +20,7 @@ const ( maxPacketSize = 2048 ) +// GetTransaction defines a function that returns the transaction data with the given hash. type GetTransaction func(txHash []byte) ([]byte, error) type Manager struct { @@ -130,7 +131,7 @@ func (m *Manager) RequestTransaction(txHash []byte, to ...peer.ID) { // If no peer is provided, it is send to all neighbors. func (m *Manager) SendTransaction(txData []byte, to ...peer.ID) { tx := &pb.Transaction{ - Body: txData, + Data: txData, } m.send(marshal(tx), to...) } @@ -255,8 +256,8 @@ func (m *Manager) handlePacket(data []byte, n *neighbor) error { if err := proto.Unmarshal(data[1:], msg); err != nil { return errors.Wrap(err, "invalid message") } - m.log.Debugw("Received Transaction", "data", msg.GetBody()) - Events.TransactionReceived.Trigger(&TransactionReceivedEvent{Body: msg.GetBody(), Peer: n.peer}) + m.log.Debugw("Received Transaction", "data", msg.GetData()) + Events.TransactionReceived.Trigger(&TransactionReceivedEvent{Data: msg.GetData(), Peer: n.peer}) // Incoming Transaction request case pb.MTransactionRequest: diff --git a/packages/gossip/manager_test.go b/packages/gossip/manager_test.go index 789b86992f..6d0fd452b1 100644 --- a/packages/gossip/manager_test.go +++ b/packages/gossip/manager_test.go @@ -173,7 +173,7 @@ func TestP2PSend(t *testing.T) { wg.Wait() eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ - Body: testTxData, + Data: testTxData, Peer: peerA, }).Once() eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Once() @@ -212,7 +212,7 @@ func TestP2PSendTwice(t *testing.T) { wg.Wait() eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ - Body: testTxData, + Data: testTxData, Peer: peerA, }).Twice() eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Once() @@ -265,7 +265,7 @@ func TestBroadcast(t *testing.T) { wg.Wait() eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ - Body: testTxData, + Data: testTxData, Peer: peerA, }).Twice() eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Twice() @@ -317,7 +317,7 @@ func TestSingleSend(t *testing.T) { wg.Wait() eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ - Body: testTxData, + Data: testTxData, Peer: peerA, }).Once() eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Twice() @@ -376,7 +376,7 @@ func TestTxRequest(t *testing.T) { txHash := []byte("Hello!") eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ - Body: testTxData, + Data: testTxData, Peer: peerB, }).Once() eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Once() diff --git a/packages/gossip/proto/message.pb.go b/packages/gossip/proto/message.pb.go index b18bb7517d..06ab295e24 100644 --- a/packages/gossip/proto/message.pb.go +++ b/packages/gossip/proto/message.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-go. DO NOT EDIT. -// source: proto/message.proto +// source: packages/gossip/proto/message.proto package proto @@ -21,8 +21,8 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type Transaction struct { - // body of the tx - Body []byte `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"` + // transaction data + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -32,7 +32,7 @@ func (m *Transaction) Reset() { *m = Transaction{} } func (m *Transaction) String() string { return proto.CompactTextString(m) } func (*Transaction) ProtoMessage() {} func (*Transaction) Descriptor() ([]byte, []int) { - return fileDescriptor_33f3a5e1293a7bcd, []int{0} + return fileDescriptor_fcce9e84825f2fa5, []int{0} } func (m *Transaction) XXX_Unmarshal(b []byte) error { @@ -53,9 +53,9 @@ func (m *Transaction) XXX_DiscardUnknown() { var xxx_messageInfo_Transaction proto.InternalMessageInfo -func (m *Transaction) GetBody() []byte { +func (m *Transaction) GetData() []byte { if m != nil { - return m.Body + return m.Data } return nil } @@ -72,7 +72,7 @@ func (m *TransactionRequest) Reset() { *m = TransactionRequest{} } func (m *TransactionRequest) String() string { return proto.CompactTextString(m) } func (*TransactionRequest) ProtoMessage() {} func (*TransactionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_33f3a5e1293a7bcd, []int{1} + return fileDescriptor_fcce9e84825f2fa5, []int{1} } func (m *TransactionRequest) XXX_Unmarshal(b []byte) error { @@ -105,17 +105,20 @@ func init() { proto.RegisterType((*TransactionRequest)(nil), "proto.TransactionRequest") } -func init() { proto.RegisterFile("proto/message.proto", fileDescriptor_33f3a5e1293a7bcd) } - -var fileDescriptor_33f3a5e1293a7bcd = []byte{ - // 137 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x12, 0x2e, 0x28, 0xca, 0x2f, - 0xc9, 0xd7, 0xcf, 0x4d, 0x2d, 0x2e, 0x4e, 0x4c, 0x4f, 0xd5, 0x03, 0xf3, 0x84, 0x58, 0xc1, 0x94, - 0x92, 0x22, 0x17, 0x77, 0x48, 0x51, 0x62, 0x5e, 0x71, 0x62, 0x72, 0x49, 0x66, 0x7e, 0x9e, 0x90, - 0x10, 0x17, 0x4b, 0x52, 0x7e, 0x4a, 0xa5, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x4f, 0x10, 0x98, 0xad, - 0xa4, 0xc1, 0x25, 0x84, 0xa4, 0x24, 0x28, 0xb5, 0xb0, 0x34, 0xb5, 0xb8, 0x04, 0xa4, 0x32, 0x23, - 0xb1, 0x38, 0x03, 0xa6, 0x12, 0xc4, 0x76, 0x52, 0x8e, 0x52, 0x4c, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, - 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0x4e, 0x2c, 0xc8, 0x2f, 0x2e, 0x4e, 0xcd, 0x49, 0xd5, 0x4f, - 0x07, 0xd2, 0x99, 0x05, 0xfa, 0x60, 0x1b, 0x93, 0xd8, 0xc0, 0x94, 0x31, 0x20, 0x00, 0x00, 0xff, - 0xff, 0x34, 0x46, 0xa5, 0x0f, 0x96, 0x00, 0x00, 0x00, +func init() { + proto.RegisterFile("packages/gossip/proto/message.proto", fileDescriptor_fcce9e84825f2fa5) +} + +var fileDescriptor_fcce9e84825f2fa5 = []byte{ + // 155 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x52, 0x2e, 0x48, 0x4c, 0xce, + 0x4e, 0x4c, 0x4f, 0x2d, 0xd6, 0x4f, 0xcf, 0x2f, 0x2e, 0xce, 0x2c, 0xd0, 0x2f, 0x28, 0xca, 0x2f, + 0xc9, 0xd7, 0xcf, 0x4d, 0x2d, 0x2e, 0x06, 0x8a, 0xea, 0x81, 0x79, 0x42, 0xac, 0x60, 0x4a, 0x49, + 0x91, 0x8b, 0x3b, 0xa4, 0x28, 0x31, 0xaf, 0x38, 0x31, 0xb9, 0x24, 0x33, 0x3f, 0x4f, 0x48, 0x88, + 0x8b, 0x25, 0x25, 0xb1, 0x24, 0x51, 0x82, 0x51, 0x81, 0x51, 0x83, 0x27, 0x08, 0xcc, 0x56, 0xd2, + 0xe0, 0x12, 0x42, 0x52, 0x12, 0x94, 0x5a, 0x58, 0x9a, 0x5a, 0x5c, 0x02, 0x52, 0x99, 0x91, 0x58, + 0x9c, 0x01, 0x53, 0x09, 0x62, 0x3b, 0x99, 0x47, 0x99, 0xa6, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, + 0x25, 0xe7, 0xe7, 0xea, 0x67, 0xe6, 0x97, 0x24, 0xe6, 0xa4, 0xa6, 0xa4, 0xa7, 0x16, 0x81, 0xdc, + 0x91, 0x91, 0x99, 0x9b, 0x0b, 0x64, 0x61, 0x75, 0x5a, 0x12, 0x1b, 0x98, 0x32, 0x06, 0x04, 0x00, + 0x00, 0xff, 0xff, 0x9f, 0x78, 0x4d, 0x0f, 0xba, 0x00, 0x00, 0x00, } diff --git a/packages/gossip/proto/message.proto b/packages/gossip/proto/message.proto index 6be94fdf51..8d6bc2851d 100644 --- a/packages/gossip/proto/message.proto +++ b/packages/gossip/proto/message.proto @@ -5,8 +5,8 @@ option go_package = "github.com/iotaledger/goshimmer/packages/gossip/proto"; package proto; message Transaction { - // body of the tx - bytes body = 1; + // transaction data + bytes data = 1; } message TransactionRequest { diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index 75ccf787b4..f95573c73e 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -4,9 +4,7 @@ import ( "sync" "time" - "github.com/golang/protobuf/proto" "github.com/iotaledger/goshimmer/packages/gossip" - pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/plugins/autopeering/local" @@ -64,9 +62,7 @@ func Start(tps uint) { continue } - mtx := &pb.Transaction{Body: tx.MetaTransaction.GetBytes()} - b, _ := proto.Marshal(mtx) - gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b, Peer: &local.INSTANCE.Peer}) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: tx.GetBytes(), Peer: &local.INSTANCE.Peer}) if sentCounter >= tps { duration := time.Since(start) diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 3ce2dc711f..834a4edfb0 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -3,11 +3,9 @@ package gossip import ( "fmt" - "github.com/golang/protobuf/proto" "github.com/iotaledger/autopeering-sim/logger" "github.com/iotaledger/goshimmer/packages/errors" gp "github.com/iotaledger/goshimmer/packages/gossip" - pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/gossip/server" "github.com/iotaledger/goshimmer/packages/typeutils" "github.com/iotaledger/goshimmer/plugins/autopeering/local" @@ -74,11 +72,5 @@ func getTransaction(hash []byte) ([]byte, error) { if tx == nil { return nil, fmt.Errorf("transaction not found: hash=%s", hash) } - - pTx := &pb.TransactionRequest{ - Hash: tx.GetBytes(), - } - b, _ := proto.Marshal(pTx) - - return b, nil + return tx.GetBytes(), nil } diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 963a830e4d..39fd6f1936 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -1,12 +1,11 @@ package gossip import ( - "github.com/golang/protobuf/proto" "github.com/iotaledger/autopeering-sim/peer/service" "github.com/iotaledger/autopeering-sim/selection" "github.com/iotaledger/goshimmer/packages/gossip" - pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/typeutils" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" @@ -55,21 +54,12 @@ func configureEvents() { })) tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { - log.Info("gossip solid tx", tx.MetaTransaction.GetHash()) - t := &pb.Transaction{ - Body: tx.MetaTransaction.GetBytes(), - } - b, err := proto.Marshal(t) - if err != nil { - return - } - go mgr.SendTransaction(b) + log.Debugf("gossip solid tx: hash=%s", tx.GetHash()) + go mgr.SendTransaction(tx.GetBytes()) })) gossip.Events.RequestTransaction.Attach(events.NewClosure(func(ev *gossip.RequestTransactionEvent) { - pTx := &pb.TransactionRequest{} - proto.Unmarshal(ev.Hash, pTx) - log.Info("Tx Requested:", string(pTx.Hash)) - go mgr.RequestTransaction(pTx.Hash) + log.Debugf("gossip tx request: hash=%s", ev.Hash) + go mgr.RequestTransaction(typeutils.StringToBytes(ev.Hash)) })) } diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index 130deda4fc..dddd71e960 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -4,10 +4,8 @@ import ( "runtime" "time" - "github.com/golang/protobuf/proto" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/gossip" - pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/model/approvers" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" @@ -38,13 +36,7 @@ func configureSolidifier(plugin *node.Plugin) { unsolidTxs = NewUnsolidTxs() gossip.Events.TransactionReceived.Attach(events.NewClosure(func(ev *gossip.TransactionReceivedEvent) { - pTx := &pb.Transaction{} - if err := proto.Unmarshal(ev.Body, pTx); err != nil { - log.Warningf("invalid transaction: %s", err) - return - } - - metaTx := meta_transaction.FromBytes(pTx.GetBody()) + metaTx := meta_transaction.FromBytes(ev.Data) if err := metaTx.Validate(); err != nil { log.Warningf("invalid transaction: %s", err) return @@ -231,11 +223,9 @@ func updateUnsolidTxs(tx *value_transaction.ValueTransaction) { } } -func requestTransaction(tx string) { - log.Info("Requesting tx: ", tx) - req := &pb.TransactionRequest{Hash: []byte(tx)} - b, _ := proto.Marshal(req) - gossip.Events.RequestTransaction.Trigger(&gossip.RequestTransactionEvent{Hash: b}) +func requestTransaction(hash trinary.Trytes) { + log.Infof("Requesting hash: hash=%s", hash) + gossip.Events.RequestTransaction.Trigger(&gossip.RequestTransactionEvent{Hash: hash}) } var WORKER_COUNT = runtime.NumCPU() diff --git a/plugins/tangle/solidifier_test.go b/plugins/tangle/solidifier_test.go index be845077fa..7b8aaf1dea 100644 --- a/plugins/tangle/solidifier_test.go +++ b/plugins/tangle/solidifier_test.go @@ -5,9 +5,7 @@ import ( "sync" "testing" - "github.com/golang/protobuf/proto" "github.com/iotaledger/goshimmer/packages/gossip" - pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/hive.go/events" @@ -56,28 +54,18 @@ func TestSolidifier(t *testing.T) { })) gossip.Events.RequestTransaction.Attach(events.NewClosure(func(ev *gossip.RequestTransactionEvent) { - tx := &pb.Transaction{Body: transaction3.MetaTransaction.GetBytes()} - b, _ := proto.Marshal(tx) - gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b}) + require.Equal(t, transaction3.GetHash(), ev.Hash) + // return the transaction data + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: transaction3.GetBytes()}) })) // issue transactions wg.Add(4) - tx := &pb.Transaction{Body: transaction1.MetaTransaction.GetBytes()} - b, _ := proto.Marshal(tx) - gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b}) - tx = &pb.Transaction{Body: transaction2.MetaTransaction.GetBytes()} - b, _ = proto.Marshal(tx) - gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b}) - - // tx = &pb.Transaction{Body: transaction3.MetaTransaction.GetBytes()} - // b, _ = proto.Marshal(tx) - // gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b}) - - tx = &pb.Transaction{Body: transaction4.MetaTransaction.GetBytes()} - b, _ = proto.Marshal(tx) - gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b}) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: transaction1.GetBytes()}) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: transaction2.GetBytes()}) + // gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: transaction3.GetBytes()}) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: transaction4.GetBytes()}) // wait until all are solid wg.Wait() diff --git a/plugins/webapi-send-data/plugin.go b/plugins/webapi-send-data/plugin.go index 8fdf374634..b36da53608 100644 --- a/plugins/webapi-send-data/plugin.go +++ b/plugins/webapi-send-data/plugin.go @@ -4,9 +4,7 @@ import ( "net/http" "time" - "github.com/golang/protobuf/proto" "github.com/iotaledger/goshimmer/packages/gossip" - pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/plugins/autopeering/local" @@ -59,13 +57,8 @@ func SendDataHandler(c echo.Context) error { log.Warning("PoW failed", err) } - transactionHash := tx.GetHash() - - mtx := &pb.Transaction{Body: tx.MetaTransaction.GetBytes()} - b, _ := proto.Marshal(mtx) - gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Body: b, Peer: &local.INSTANCE.Peer}) - - return requestSuccessful(c, transactionHash) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: tx.GetBytes(), Peer: &local.INSTANCE.Peer}) + return requestSuccessful(c, tx.GetHash()) } func requestSuccessful(c echo.Context, txHash string) error { From 142c0750c71db5ff6fc01d3a0a8843891e518937 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Sat, 4 Jan 2020 13:57:04 +0100 Subject: [PATCH 062/184] fix: correct linter warnings --- packages/gossip/server/server.go | 19 ++++++++++++------- packages/gossip/server/server_test.go | 3 +-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/gossip/server/server.go b/packages/gossip/server/server.go index 658f6be6df..fdb72cc096 100644 --- a/packages/gossip/server/server.go +++ b/packages/gossip/server/server.go @@ -332,7 +332,8 @@ func (t *TCP) doHandshake(key peer.PublicKey, remoteAddr string, conn net.Conn) return fmt.Errorf("handshake size too large: %d, max %d", l, maxHandshakePacketSize) } - if err := conn.SetWriteDeadline(time.Now().Add(handshakeTimeout)); err != nil { + err = conn.SetWriteDeadline(time.Now().Add(handshakeTimeout)) + if err != nil { return err } _, err = conn.Write(b) @@ -340,7 +341,8 @@ func (t *TCP) doHandshake(key peer.PublicKey, remoteAddr string, conn net.Conn) return err } - if err := conn.SetReadDeadline(time.Now().Add(handshakeTimeout)); err != nil { + err = conn.SetReadDeadline(time.Now().Add(handshakeTimeout)) + if err != nil { return err } b = make([]byte, maxHandshakePacketSize) @@ -349,8 +351,9 @@ func (t *TCP) doHandshake(key peer.PublicKey, remoteAddr string, conn net.Conn) return err } - pkt = new(pb.Packet) - if err := proto.Unmarshal(b[:n], pkt); err != nil { + pkt = &pb.Packet{} + err = proto.Unmarshal(b[:n], pkt) + if err != nil { return err } @@ -375,8 +378,9 @@ func (t *TCP) readHandshakeRequest(conn net.Conn) (peer.PublicKey, []byte, error return nil, nil, errors.Wrap(err, ErrInvalidHandshake.Error()) } - pkt := new(pb.Packet) - if err := proto.Unmarshal(b[:n], pkt); err != nil { + pkt := &pb.Packet{} + err = proto.Unmarshal(b[:n], pkt) + if err != nil { return nil, nil, err } @@ -411,7 +415,8 @@ func (t *TCP) writeHandshakeResponse(reqData []byte, conn net.Conn) error { return fmt.Errorf("handshake size too large: %d, max %d", l, maxHandshakePacketSize) } - if err := conn.SetWriteDeadline(time.Now().Add(handshakeTimeout)); err != nil { + err = conn.SetWriteDeadline(time.Now().Add(handshakeTimeout)) + if err != nil { return err } _, err = conn.Write(b) diff --git a/packages/gossip/server/server_test.go b/packages/gossip/server/server_test.go index e4f0607032..517f948b9f 100644 --- a/packages/gossip/server/server_test.go +++ b/packages/gossip/server/server_test.go @@ -111,8 +111,7 @@ func TestNoHandshakeResponse(t *testing.T) { lis, err := net.Listen("tcp", "localhost:0") require.NoError(t, err) go func() { - conn, err := lis.Accept() - require.NoError(t, err) + conn, _ := lis.Accept() n, _ := conn.Read(make([]byte, maxHandshakePacketSize)) assert.NotZero(t, n) _ = conn.Close() From f24af478cee4333b7952fa353baf56d60f2766c4 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Sat, 4 Jan 2020 14:50:28 +0100 Subject: [PATCH 063/184] refactor: make local a singleton --- .../transactionspammer/transactionspammer.go | 5 +- plugins/analysis/client/plugin.go | 21 ++--- plugins/autopeering/autopeering.go | 73 ++---------------- plugins/autopeering/local/local.go | 76 ++++++++++++++++++- plugins/autopeering/local/parameters.go | 15 ++++ plugins/autopeering/parameters.go | 4 - plugins/autopeering/plugin.go | 4 - plugins/dashboard/tps.go | 5 +- plugins/gossip/gossip.go | 21 ++++- plugins/statusscreen/ui_header_bar.go | 7 +- plugins/ui/nodeInfo.go | 5 +- plugins/webapi-send-data/plugin.go | 5 +- 12 files changed, 142 insertions(+), 99 deletions(-) create mode 100644 plugins/autopeering/local/parameters.go diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index f95573c73e..aaf868830f 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -4,10 +4,11 @@ import ( "sync" "time" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/tipselection" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/logger" @@ -62,7 +63,7 @@ func Start(tps uint) { continue } - gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: tx.GetBytes(), Peer: &local.INSTANCE.Peer}) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: tx.GetBytes(), Peer: &local.GetInstance().Peer}) if sentCounter >= tps { duration := time.Since(start) diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index 32bc5cea95..8d9d58baa3 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -5,6 +5,8 @@ import ( "net" "time" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/autopeering-sim/discover" "github.com/iotaledger/autopeering-sim/selection" "github.com/iotaledger/goshimmer/packages/network" @@ -15,7 +17,6 @@ import ( "github.com/iotaledger/goshimmer/plugins/analysis/types/ping" "github.com/iotaledger/goshimmer/plugins/analysis/types/removenode" "github.com/iotaledger/goshimmer/plugins/autopeering" - "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" @@ -71,8 +72,8 @@ func getEventDispatchers(conn *network.ManagedConnection) *EventDispatchers { } func reportCurrentStatus(eventDispatchers *EventDispatchers) { - if local.INSTANCE != nil { - eventDispatchers.AddNode(local.INSTANCE.ID().Bytes()) + if local.GetInstance() != nil { + eventDispatchers.AddNode(local.GetInstance().ID().Bytes()) } reportChosenNeighbors(eventDispatchers) @@ -92,18 +93,18 @@ func setupHooks(plugin *node.Plugin, conn *network.ManagedConnection, eventDispa }) onAddAcceptedNeighbor := events.NewClosure(func(ev *selection.PeeringEvent) { - log.Info("onAddAcceptedNeighbor: " + hex.EncodeToString(ev.Peer.ID().Bytes()) + " - " + hex.EncodeToString(local.INSTANCE.ID().Bytes())) - eventDispatchers.ConnectNodes(ev.Peer.ID().Bytes(), local.INSTANCE.ID().Bytes()) + log.Info("onAddAcceptedNeighbor: " + hex.EncodeToString(ev.Peer.ID().Bytes()) + " - " + hex.EncodeToString(local.GetInstance().ID().Bytes())) + eventDispatchers.ConnectNodes(ev.Peer.ID().Bytes(), local.GetInstance().ID().Bytes()) }) onRemoveNeighbor := events.NewClosure(func(ev *selection.DroppedEvent) { - log.Info("onRemoveNeighbor: " + hex.EncodeToString(ev.DroppedID.Bytes()) + " - " + hex.EncodeToString(local.INSTANCE.ID().Bytes())) - eventDispatchers.DisconnectNodes(ev.DroppedID.Bytes(), local.INSTANCE.ID().Bytes()) + log.Info("onRemoveNeighbor: " + hex.EncodeToString(ev.DroppedID.Bytes()) + " - " + hex.EncodeToString(local.GetInstance().ID().Bytes())) + eventDispatchers.DisconnectNodes(ev.DroppedID.Bytes(), local.GetInstance().ID().Bytes()) }) onAddChosenNeighbor := events.NewClosure(func(ev *selection.PeeringEvent) { - log.Info("onAddChosenNeighbor: " + hex.EncodeToString(local.INSTANCE.ID().Bytes()) + " - " + hex.EncodeToString(ev.Peer.ID().Bytes())) - eventDispatchers.ConnectNodes(local.INSTANCE.ID().Bytes(), ev.Peer.ID().Bytes()) + log.Info("onAddChosenNeighbor: " + hex.EncodeToString(local.GetInstance().ID().Bytes()) + " - " + hex.EncodeToString(ev.Peer.ID().Bytes())) + eventDispatchers.ConnectNodes(local.GetInstance().ID().Bytes(), ev.Peer.ID().Bytes()) }) // setup hooks ///////////////////////////////////////////////////////////////////////////////////////////////////// @@ -132,7 +133,7 @@ func reportChosenNeighbors(dispatchers *EventDispatchers) { if autopeering.Selection != nil { for _, chosenNeighbor := range autopeering.Selection.GetOutgoingNeighbors() { dispatchers.AddNode(chosenNeighbor.ID().Bytes()) - dispatchers.ConnectNodes(local.INSTANCE.ID().Bytes(), chosenNeighbor.ID().Bytes()) + dispatchers.ConnectNodes(local.GetInstance().ID().Bytes(), chosenNeighbor.ID().Bytes()) } } } diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index a7759994b5..6875acbec5 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -3,12 +3,11 @@ package autopeering import ( "encoding/base64" "fmt" - "io/ioutil" "net" - "net/http" - "strconv" "strings" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/autopeering-sim/discover" "github.com/iotaledger/autopeering-sim/logger" "github.com/iotaledger/autopeering-sim/peer" @@ -16,8 +15,6 @@ import ( "github.com/iotaledger/autopeering-sim/selection" "github.com/iotaledger/autopeering-sim/server" "github.com/iotaledger/autopeering-sim/transport" - "github.com/iotaledger/goshimmer/plugins/autopeering/local" - "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/parameter" "github.com/pkg/errors" @@ -53,40 +50,6 @@ const defaultZLC = `{ var zLogger = logger.NewLogger(defaultZLC, logLevel) -func configureLocal() { - ip := net.ParseIP(parameter.NodeConfig.GetString(CFG_ADDRESS)) - if ip == nil { - log.Fatalf("Invalid IP address: %s", parameter.NodeConfig.GetString(CFG_ADDRESS)) - } - if ip.IsUnspecified() { - myIp, err := getMyIP() - if err != nil { - log.Fatalf("Could not query public IP: %v", err) - } - ip = myIp - } - - apPort := strconv.Itoa(parameter.NodeConfig.GetInt(CFG_PORT)) - gossipPort := strconv.Itoa(parameter.NodeConfig.GetInt(gossip.GOSSIP_PORT)) - - // create a new local node - db := peer.NewPersistentDB(zLogger.Named("db")) - - var err error - local.INSTANCE, err = peer.NewLocal(NETWORK, net.JoinHostPort(ip.String(), apPort), db) - if err != nil { - log.Fatalf("NewLocal: %v", err) - } - - // add a service for the gossip - if parameter.NodeConfig.GetBool(CFG_SELECTION) { - err = local.INSTANCE.UpdateService(service.GossipKey, "tcp", net.JoinHostPort(ip.String(), gossipPort)) - if err != nil { - log.Fatalf("UpdateService: %v", err) - } - } -} - func configureAP() { masterPeers, err := parseEntryNodes() if err != nil { @@ -94,13 +57,13 @@ func configureAP() { } log.Debugf("Master peers: %v", masterPeers) - Discovery = discover.New(local.INSTANCE, discover.Config{ + Discovery = discover.New(local.GetInstance(), discover.Config{ Log: zLogger.Named("disc"), MasterPeers: masterPeers, }) if parameter.NodeConfig.GetBool(CFG_SELECTION) { - Selection = selection.New(local.INSTANCE, Discovery, selection.Config{ + Selection = selection.New(local.GetInstance(), Discovery, selection.Config{ Log: zLogger.Named("sel"), Param: &selection.Parameters{ SaltLifetime: selection.DefaultSaltLifetime, @@ -113,7 +76,7 @@ func configureAP() { func start() { defer log.Info("Stopping Auto Peering server ... done") - addr := local.INSTANCE.Services().Get(service.PeeringKey) + addr := local.GetInstance().Services().Get(service.PeeringKey) udpAddr, err := net.ResolveUDPAddr(addr.Network(), addr.String()) if err != nil { log.Fatalf("ResolveUDPAddr: %v", err) @@ -143,7 +106,7 @@ func start() { } // start a server doing discovery and peering - srv := server.Listen(local.INSTANCE, trans, zLogger.Named("srv"), handlers...) + srv := server.Listen(local.GetInstance(), trans, zLogger.Named("srv"), handlers...) defer srv.Close() // start the discovery on that connection @@ -156,7 +119,7 @@ func start() { defer Selection.Close() } - log.Infof("Auto Peering server started: ID=%x, address=%s", local.INSTANCE.ID(), srv.LocalAddr()) + log.Infof("Auto Peering server started: ID=%x, address=%s", local.GetInstance().ID(), srv.LocalAddr()) <-daemon.ShutdownSignal log.Info("Stopping Auto Peering server ...") @@ -185,25 +148,3 @@ func parseEntryNodes() (result []*peer.Peer, err error) { return result, nil } - -func getMyIP() (net.IP, error) { - url := "https://api.ipify.org?format=text" - resp, err := http.Get(url) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } - - // the body only consists of the ip address - ip := net.ParseIP(string(body)) - if ip == nil { - return nil, fmt.Errorf("not an IP: %s", body) - } - - return ip, nil -} diff --git a/plugins/autopeering/local/local.go b/plugins/autopeering/local/local.go index d384c80735..095648e570 100644 --- a/plugins/autopeering/local/local.go +++ b/plugins/autopeering/local/local.go @@ -1,5 +1,77 @@ package local -import "github.com/iotaledger/autopeering-sim/peer" +import ( + "fmt" + "io/ioutil" + "log" + "net" + "net/http" + "strconv" + "sync" -var INSTANCE *peer.Local + "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/hive.go/parameter" + "go.uber.org/zap" +) + +var ( + instance *peer.Local + once sync.Once +) + +func configureLocal() *peer.Local { + ip := net.ParseIP(parameter.NodeConfig.GetString(CFG_ADDRESS)) + if ip == nil { + log.Fatalf("Invalid IP address: %s", parameter.NodeConfig.GetString(CFG_ADDRESS)) + } + if ip.IsUnspecified() { + myIp, err := getMyIP() + if err != nil { + log.Fatalf("Could not query public IP: %v", err) + } + ip = myIp + } + + port := strconv.Itoa(parameter.NodeConfig.GetInt(CFG_PORT)) + + // create a new local node + logger, err := zap.NewProduction() + if err != nil { + log.Fatalf("Could not create logger: %v", err) + } + db := peer.NewPersistentDB(logger.Named("db").Sugar()) + + local, err := peer.NewLocal("udp", net.JoinHostPort(ip.String(), port), db) + if err != nil { + log.Fatalf("NewLocal: %v", err) + } + + return local +} + +func getMyIP() (net.IP, error) { + url := "https://api.ipify.org?format=text" + resp, err := http.Get(url) + if err != nil { + return nil, err + } + defer resp.Body.Close() + + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, err + } + + // the body only consists of the ip address + ip := net.ParseIP(string(body)) + if ip == nil { + return nil, fmt.Errorf("not an IP: %s", body) + } + + return ip, nil +} + +func GetInstance() *peer.Local { + once.Do(func() { instance = configureLocal() }) + return instance +} diff --git a/plugins/autopeering/local/parameters.go b/plugins/autopeering/local/parameters.go new file mode 100644 index 0000000000..1bb7847d5b --- /dev/null +++ b/plugins/autopeering/local/parameters.go @@ -0,0 +1,15 @@ +package local + +import ( + flag "github.com/spf13/pflag" +) + +const ( + CFG_ADDRESS = "autopeering.address" + CFG_PORT = "autopeering.port" +) + +func init() { + flag.String(CFG_ADDRESS, "0.0.0.0", "address to bind for incoming peering requests") + flag.Int(CFG_PORT, 14626, "udp port for incoming peering requests") +} diff --git a/plugins/autopeering/parameters.go b/plugins/autopeering/parameters.go index 27b117006e..0c2454272e 100644 --- a/plugins/autopeering/parameters.go +++ b/plugins/autopeering/parameters.go @@ -5,15 +5,11 @@ import ( ) const ( - CFG_ADDRESS = "autopeering.address" CFG_ENTRY_NODES = "autopeering.entryNodes" - CFG_PORT = "autopeering.port" CFG_SELECTION = "autopeering.selection" ) func init() { - flag.String(CFG_ADDRESS, "0.0.0.0", "address to bind for incoming peering requests") flag.StringSlice(CFG_ENTRY_NODES, []string{"V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626"}, "list of trusted entry nodes for auto peering") - flag.Int(CFG_PORT, 14626, "udp port for incoming peering requests") flag.Bool(CFG_SELECTION, true, "enable peer selection") } diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 3a71eae9c0..1deaa3684b 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -10,9 +10,6 @@ import ( ) const ( - // NETWORK defines the network type used for the autopeering. - NETWORK = "udp" - name = "Autopeering" // name of the plugin logLevel = "info" ) @@ -23,7 +20,6 @@ var log = logger.NewLogger(name) func configure(*node.Plugin) { configureEvents() - configureLocal() configureAP() } diff --git a/plugins/dashboard/tps.go b/plugins/dashboard/tps.go index 6f6710bdc1..656998c2bf 100644 --- a/plugins/dashboard/tps.go +++ b/plugins/dashboard/tps.go @@ -10,9 +10,10 @@ import ( "sync" "time" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/gorilla/websocket" "github.com/iotaledger/goshimmer/plugins/autopeering" - "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/metrics" "github.com/iotaledger/hive.go/events" ) @@ -83,7 +84,7 @@ func GetStatus() *Status { } return &Status{ - Id: local.INSTANCE.ID().String(), + Id: local.GetInstance().ID().String(), Neighbor: "Neighbors: " + outgoing + " chosen / " + incoming + " accepted / " + neighbors + " total", KnownPeer: "Known Peers: " + knownPeers + " total", Uptime: uptime, diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 834a4edfb0..dae769cf05 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -2,8 +2,11 @@ package gossip import ( "fmt" + "net" + "strconv" "github.com/iotaledger/autopeering-sim/logger" + "github.com/iotaledger/autopeering-sim/peer/service" "github.com/iotaledger/goshimmer/packages/errors" gp "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/gossip/server" @@ -11,6 +14,7 @@ import ( "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" + "github.com/iotaledger/hive.go/parameter" ) var ( @@ -41,13 +45,26 @@ const defaultZLC = `{ var zLogger = logger.NewLogger(defaultZLC, logLevel) func configureGossip() { - mgr = gp.NewManager(local.INSTANCE, getTransaction, zLogger) + lPeer := local.GetInstance() + + port := strconv.Itoa(parameter.NodeConfig.GetInt(GOSSIP_PORT)) + + host, _, err := net.SplitHostPort(lPeer.Address()) + if err != nil { + log.Fatalf("invalid peering address: %v", err) + } + err = lPeer.UpdateService(service.GossipKey, "tcp", net.JoinHostPort(host, port)) + if err != nil { + log.Fatalf("could not update services: %v", err) + } + + mgr = gp.NewManager(lPeer, getTransaction, zLogger) } func start() { defer log.Info("Stopping Gossip ... done") - srv, err := server.ListenTCP(local.INSTANCE, zLogger) + srv, err := server.ListenTCP(local.GetInstance(), zLogger) if err != nil { log.Fatalf("ListenTCP: %v", err) } diff --git a/plugins/statusscreen/ui_header_bar.go b/plugins/statusscreen/ui_header_bar.go index 4cff25dd17..607be9d4e6 100644 --- a/plugins/statusscreen/ui_header_bar.go +++ b/plugins/statusscreen/ui_header_bar.go @@ -5,12 +5,13 @@ import ( "math" "strconv" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" + //"strconv" "time" "github.com/gdamore/tcell" "github.com/iotaledger/goshimmer/plugins/autopeering" - "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/rivo/tview" ) @@ -90,8 +91,8 @@ func (headerBar *UIHeaderBar) Update() { if autopeering.Discovery != nil { total = strconv.Itoa(len(autopeering.Discovery.GetVerifiedPeers())) } - if local.INSTANCE != nil { - myID = local.INSTANCE.ID().String() + if local.GetInstance() != nil { + myID = local.GetInstance().ID().String() } fmt.Fprintf(headerBar.InfoContainer, "[::b]Node ID: [::d]%40v ", myID) diff --git a/plugins/ui/nodeInfo.go b/plugins/ui/nodeInfo.go index 3c3f09c02f..7f3226236c 100644 --- a/plugins/ui/nodeInfo.go +++ b/plugins/ui/nodeInfo.go @@ -5,8 +5,9 @@ import ( "sync/atomic" "time" - "github.com/iotaledger/goshimmer/plugins/autopeering" "github.com/iotaledger/goshimmer/plugins/autopeering/local" + + "github.com/iotaledger/goshimmer/plugins/autopeering" ) var start = time.Now() @@ -61,7 +62,7 @@ func gatherInfo() nodeInfo { receivedTps, solidTps := updateTpsCounters() duration := time.Since(start) / time.Second info := nodeInfo{ - ID: local.INSTANCE.ID().String(), + ID: local.GetInstance().ID().String(), ChosenNeighbors: chosenNeighbors, AcceptedNeighbors: acceptedNeighbors, KnownPeersSize: knownPeers, diff --git a/plugins/webapi-send-data/plugin.go b/plugins/webapi-send-data/plugin.go index b36da53608..778a41b27b 100644 --- a/plugins/webapi-send-data/plugin.go +++ b/plugins/webapi-send-data/plugin.go @@ -4,10 +4,11 @@ import ( "net/http" "time" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/tipselection" "github.com/iotaledger/goshimmer/plugins/webapi" "github.com/iotaledger/hive.go/logger" @@ -57,7 +58,7 @@ func SendDataHandler(c echo.Context) error { log.Warning("PoW failed", err) } - gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: tx.GetBytes(), Peer: &local.INSTANCE.Peer}) + gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: tx.GetBytes(), Peer: &local.GetInstance().Peer}) return requestSuccessful(c, tx.GetHash()) } From 8fde09bf5b40f82559c2cf7333b182acde468d02 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Sat, 4 Jan 2020 15:22:54 +0100 Subject: [PATCH 064/184] Move autopeering code from iotaledger/autopeering-sim to goshimmer (#91) * :sparkles: GetNextCandidate selection added * :bug: Recompile salt.proto * :recycle: Refactor peer IDs completely * :bug: Recompile proto sources * :construction: WIP * :ok_hand: renamed to sort * :construction: Return requested peers on request * :sparkles: Kepp track how ofter a managed peer was verified * :wrench: sort adapted to the new peer * :construction: Query verified peers for new peers * :construction: WIP * :white_check_mark: Add manager tests * :bento: Add peering messages to protobuf * :art: Make Salt methods consistent with Peer * :sparkles: Handle peering messages * :construction: WIP * :bug: Add To filed to PeersRequest * :white_check_mark: Add PeersRequest test * :zap: Adding PeersRequest benchmark * :art: Move mpeer and helper functions to own file * :bug: Bump peer only once on reverification * :construction: WIP * :bug: * :construction: WIP * :bug: Increase buffer to prevent deadlocks * :zap: Remove unnecessary lock * :white_check_mark: Add peering request test * :white_check_mark: Make tests deterministic by triggering reverify * :construction: WIP * :lock: fixing concurrency issues * :white_check_mark: testManager improved * :bug: Don't send PeeringResponse for invalid salt * :construction: WIP * :construction: WIP * :pencil: removed commented code * :construction: WIP * :construction: WIP * Neighbourhood manager (#11) * :sparkles: GetNextCandidate selection added * :lock: fixing concurrency issues * :white_check_mark: testManager improved * :pencil: removed commented code * :construction: WIP * :construction: WIP * :construction: WIP * :construction: WIP * :heavy_check_mark: Make TestAdd pass in neighborhood_test `Add` should do nothing if the neighborhood list is full. * :white_check_mark: Improve TestSrvVerifyBoot * :arrow_up: Upgrade to go 1.13 * :heavy_minus_sign: Use testify instead of magiconair/properties * :construction: * :construction: WIP * :construction: WIP * :construction: WIP * :construction: WIP * Simulation (#14) * :sparkles: clear rejection filter after refreshing the public salt * :sparkles: clean rejection filter * :white_check_mark: Add mpeer test * :art: gofmt test * :art: Remove ineffactual assignments * :hammer: Trigger panic when index is out of bound in deletePeer * :white_check_mark: Add selection test * :white_check_mark: Add TestGetFurtherest and TestGetPeerIndex * :sparkles: both salt updated at the same time and neighborhood dropped * :art: Add node peering history for simulation * :construction: WIP * :sparkles: added sim visualization * :fire: removed root handler * :pencil: added README * :pencil: updated README * :heavy_minus_sign: removed unused dependencies * :art: Tidy go.mod * :construction: Work in progress * :construction: WIP * :construction: WIP * :construction: WIP * :lipstick: improved start button * :construction: WIP * :sparkles: added keyboard support for start * :construction: WIP * :construction: WIP * :construction: WIP * :construction: WIP * :construction: WIP * :construction: WIP * :sparkles: added input parameters * :pencil: README updated * :lipstick: gif updated * :lipstick: figure updated * :pencil: updated * :lipstick: updated gif * removed simulation metrics * :pencil: updated * :pencil: updated * :recycle: Extract server from discovery and peering * :bug: Use golang/protobuf * Update README.md * :recycle: Rename PeersRequest to DiscoveryRequest * :pencil2: Fixing typos * :art: Move unused function to tests * :recycle: The selection protocol depends on the discovery * :white_check_mark: Make tests more robust when using -race * :loud_sound: Improve logging * :art: Remove unnecessary arguments * :bug: Fix data races * :bug: added timeout for simulated network * :art: added loop to animation * :recycle: rename neighborhood to selection * :sparkles: adds initial salt and fixes simulation end * :pencil: visualizer enabled by default * :sparkles: new parameter dropAll and improved python script * :pencil: updated README * :pencil: updated README * :bug: fix salt initialization * :pencil: added blogpost link * :pencil: Add badges to README * :construction_worker: Add Travis CI for tests * :rotating_light: Correct formating * :construction_worker: Running golangci on Travis * :rotating_light: Ignore return value of 'logger.Sync' * :rotating_light: Remove unused functions * :pencil: Add link to license * :art: Move simnetwork to transport * :art: Use the complete network protocol in simulations * :recycle: Do not export selection/manager * :fire: Remove gRPC transport layer * :white_check_mark: Add UDP connection transport test * :construction: Implement the peer DB using Goshimmer database * :heavy_plus_sign: Use the local GoShimmer version * :sparkles: Add support for a persistent database * :sparkles: Persist private key of local peer in database * :bug: Set TTL for bootstrap peers * :construction: Use GoShimmer events * :sparkles: Store the supported services in the local peer * :pushpin: Use most current GoShimmer git version as a dep * :heavy_plus_sign: Switch to hive.go event package * :art: Use correct module iotaledger/autopeering-sim * :bug: Provide dummy service in autopeering simulation * :sparkles: adds service support in the selection * :sparkles: adds peer discovered events * :sparkles: adds GetIncomingNeighbors and GetOutgoingNeighbors * :bug: fixes out of bound error in splitNodeKey * :sparkles: adds public IP support * :bug: fixes localhost * :bug: fixes localhost parsing * :wrench: changes selection loop to 1s * :loud_sound: switches from fmt.Println to log.Debug * :wrench: increases maxKnown to 1000 and always triggers discovered peer * :sparkles: adds PeerDeleted event * :construction: moves PeerDeleted event into deletePeer * :sparkles: adds config paramters for the peer discovery * :sparkles: adds config parameters to neighbor selection * :sparkles: enable/disable inbound/outbound selection * :bulb: Improve Godoc comments * :sparkles: modifies disabled outbound selection * :bug: fixes bug with disabling the selection * :heavy_minus_sign: removes getMyIP() from server * :mute: removes some debugging logs * :construction: Introduce services - Each peer now comes with a set of services - Local peer is a proper peer - Services are exchanged during Pong and are available for all verified peers * :bug: fixes GetVerifiedPeer * :sparkles: adds gossip key to the service * :mute: removes debugging logs * :white_check_mark: Add test for GetVerifiedPeer * :bug: Fix main * :art: Add localNetwork to Protocol * :bug: Add new but verified peers to the manager * :wrench: changes configurable parameters * :bug: fixes DiscoveryRequest field sequence * :bento: Regenerate proto files * :art: Cleanup parameters * :bug: Fix potential race condition * :mute: Reduce logging verbosity * :white_check_mark: Add test for selection+discover * :sparkles: Return net.Addr in Transport * :bug: Remove inbound/outbound switches completely * :loud_sound: Improve logging * :loud_sound: Fix peerdb logs * :bug: Fix peer updating * :white_check_mark: Make TestProtFull more robust * :art: Make queryInterval a parameter * :loud_sound: Improve loggind during querying * :bug: Trigger PeerDiscovered only for active peers * :art: Cleanup protocol tests * :white_check_mark: Add discovery test on protocol level * :art: Rename maxVerified to maxManaged * :wrench: Increase default query interval * :art: Improve discover benchmarks * :white_check_mark: Fix manager tests * :art: Do not use bugged assert.Eventually * :rotating_light: Fix linter warnings in server * :rotating_light: Remove unused parameters * :art: Make transport work on slices of bytes * :pencil2: Fix typo in comments * :rotating_light: Fix linter warnings * :art: UpdateService accepts two strings * :white_check_mark: Add test that services are received in discover * :sparkles: adds required services * :art: Handle closed connections consistently * :art: Code cleanup * :bug: fixes DropPeer * :art: improves debug messages * :loud_sound: Log errors during reverification * :loud_sound: Log packet size * refactor: remove unused files * refactor: use internal autopeering package Co-authored-by: Angelo Capossele Co-authored-by: jkrvivian --- go.mod | 8 +- go.sum | 28 -- packages/autopeering/discover/common.go | 55 ++ packages/autopeering/discover/events.go | 35 ++ packages/autopeering/discover/manager.go | 361 ++++++++++++++ packages/autopeering/discover/manager_test.go | 179 +++++++ packages/autopeering/discover/mpeer.go | 95 ++++ packages/autopeering/discover/mpeer_test.go | 196 ++++++++ .../autopeering/discover/proto/message.go | 39 ++ .../autopeering/discover/proto/message.pb.go | 280 +++++++++++ .../autopeering/discover/proto/message.proto | 42 ++ packages/autopeering/discover/protocol.go | 468 ++++++++++++++++++ .../autopeering/discover/protocol_test.go | 294 +++++++++++ packages/autopeering/discover/query_strat.go | 94 ++++ packages/autopeering/distance/consts.go | 5 + packages/autopeering/distance/distance.go | 33 ++ .../autopeering/distance/distance_test.go | 38 ++ packages/autopeering/logger/logger.go | 60 +++ packages/autopeering/peer/id.go | 40 ++ packages/autopeering/peer/local.go | 129 +++++ packages/autopeering/peer/local_test.go | 63 +++ packages/autopeering/peer/mapdb.go | 233 +++++++++ packages/autopeering/peer/mapdb_test.go | 78 +++ packages/autopeering/peer/peer.go | 136 +++++ packages/autopeering/peer/peer_test.go | 81 +++ packages/autopeering/peer/peerdb.go | 319 ++++++++++++ packages/autopeering/peer/proto/peer.pb.go | 94 ++++ packages/autopeering/peer/proto/peer.proto | 15 + .../peer/service/proto/service.pb.go | 137 +++++ .../peer/service/proto/service.proto | 17 + packages/autopeering/peer/service/record.go | 118 +++++ packages/autopeering/peer/service/service.go | 26 + packages/autopeering/peer/sort.go | 38 ++ packages/autopeering/peer/sort_test.go | 45 ++ packages/autopeering/salt/proto/salt.pb.go | 89 ++++ packages/autopeering/salt/proto/salt.proto | 12 + packages/autopeering/salt/salt.go | 86 ++++ packages/autopeering/salt/salt_test.go | 73 +++ packages/autopeering/selection/common.go | 41 ++ packages/autopeering/selection/events.go | 42 ++ packages/autopeering/selection/manager.go | 412 +++++++++++++++ .../autopeering/selection/manager_test.go | 135 +++++ .../autopeering/selection/neighborhood.go | 108 ++++ .../selection/neighborhood_test.go | 252 ++++++++++ .../autopeering/selection/proto/message.go | 35 ++ .../autopeering/selection/proto/message.pb.go | 207 ++++++++ .../autopeering/selection/proto/message.proto | 30 ++ packages/autopeering/selection/protocol.go | 338 +++++++++++++ .../autopeering/selection/protocol_test.go | 186 +++++++ packages/autopeering/selection/selection.go | 73 +++ .../autopeering/selection/selection_test.go | 182 +++++++ packages/autopeering/server/common.go | 41 ++ packages/autopeering/server/errors.go | 17 + .../autopeering/server/proto/packet.pb.go | 97 ++++ .../autopeering/server/proto/packet.proto | 11 + packages/autopeering/server/protocol.go | 42 ++ packages/autopeering/server/server.go | 313 ++++++++++++ packages/autopeering/server/server_test.go | 218 ++++++++ packages/autopeering/transport/chan.go | 116 +++++ packages/autopeering/transport/chan_test.go | 78 +++ packages/autopeering/transport/conn.go | 58 +++ packages/autopeering/transport/conn_test.go | 41 ++ packages/autopeering/transport/const.go | 5 + packages/autopeering/transport/errors.go | 8 + packages/autopeering/transport/p2p.go | 93 ++++ packages/autopeering/transport/p2p_test.go | 34 ++ packages/autopeering/transport/transport.go | 37 ++ packages/gossip/events.go | 2 +- packages/gossip/manager.go | 4 +- packages/gossip/manager_test.go | 4 +- packages/gossip/server/connection.go | 2 +- packages/gossip/server/handshake.go | 2 +- packages/gossip/server/server.go | 6 +- packages/gossip/server/server_test.go | 4 +- packages/identity/identity.go | 2 +- plugins/analysis/client/plugin.go | 4 +- plugins/autopeering/autopeering.go | 15 +- plugins/autopeering/local/local.go | 2 +- plugins/autopeering/plugin.go | 2 +- plugins/gossip/gossip.go | 4 +- plugins/gossip/plugin.go | 4 +- 81 files changed, 7388 insertions(+), 58 deletions(-) create mode 100644 packages/autopeering/discover/common.go create mode 100644 packages/autopeering/discover/events.go create mode 100644 packages/autopeering/discover/manager.go create mode 100644 packages/autopeering/discover/manager_test.go create mode 100644 packages/autopeering/discover/mpeer.go create mode 100644 packages/autopeering/discover/mpeer_test.go create mode 100644 packages/autopeering/discover/proto/message.go create mode 100644 packages/autopeering/discover/proto/message.pb.go create mode 100644 packages/autopeering/discover/proto/message.proto create mode 100644 packages/autopeering/discover/protocol.go create mode 100644 packages/autopeering/discover/protocol_test.go create mode 100644 packages/autopeering/discover/query_strat.go create mode 100644 packages/autopeering/distance/consts.go create mode 100644 packages/autopeering/distance/distance.go create mode 100644 packages/autopeering/distance/distance_test.go create mode 100644 packages/autopeering/logger/logger.go create mode 100644 packages/autopeering/peer/id.go create mode 100644 packages/autopeering/peer/local.go create mode 100644 packages/autopeering/peer/local_test.go create mode 100644 packages/autopeering/peer/mapdb.go create mode 100644 packages/autopeering/peer/mapdb_test.go create mode 100644 packages/autopeering/peer/peer.go create mode 100644 packages/autopeering/peer/peer_test.go create mode 100644 packages/autopeering/peer/peerdb.go create mode 100644 packages/autopeering/peer/proto/peer.pb.go create mode 100644 packages/autopeering/peer/proto/peer.proto create mode 100644 packages/autopeering/peer/service/proto/service.pb.go create mode 100644 packages/autopeering/peer/service/proto/service.proto create mode 100644 packages/autopeering/peer/service/record.go create mode 100644 packages/autopeering/peer/service/service.go create mode 100644 packages/autopeering/peer/sort.go create mode 100644 packages/autopeering/peer/sort_test.go create mode 100644 packages/autopeering/salt/proto/salt.pb.go create mode 100644 packages/autopeering/salt/proto/salt.proto create mode 100644 packages/autopeering/salt/salt.go create mode 100644 packages/autopeering/salt/salt_test.go create mode 100644 packages/autopeering/selection/common.go create mode 100644 packages/autopeering/selection/events.go create mode 100644 packages/autopeering/selection/manager.go create mode 100644 packages/autopeering/selection/manager_test.go create mode 100644 packages/autopeering/selection/neighborhood.go create mode 100644 packages/autopeering/selection/neighborhood_test.go create mode 100644 packages/autopeering/selection/proto/message.go create mode 100644 packages/autopeering/selection/proto/message.pb.go create mode 100644 packages/autopeering/selection/proto/message.proto create mode 100644 packages/autopeering/selection/protocol.go create mode 100644 packages/autopeering/selection/protocol_test.go create mode 100644 packages/autopeering/selection/selection.go create mode 100644 packages/autopeering/selection/selection_test.go create mode 100644 packages/autopeering/server/common.go create mode 100644 packages/autopeering/server/errors.go create mode 100644 packages/autopeering/server/proto/packet.pb.go create mode 100644 packages/autopeering/server/proto/packet.proto create mode 100644 packages/autopeering/server/protocol.go create mode 100644 packages/autopeering/server/server.go create mode 100644 packages/autopeering/server/server_test.go create mode 100644 packages/autopeering/transport/chan.go create mode 100644 packages/autopeering/transport/chan_test.go create mode 100644 packages/autopeering/transport/conn.go create mode 100644 packages/autopeering/transport/conn_test.go create mode 100644 packages/autopeering/transport/const.go create mode 100644 packages/autopeering/transport/errors.go create mode 100644 packages/autopeering/transport/p2p.go create mode 100644 packages/autopeering/transport/p2p_test.go create mode 100644 packages/autopeering/transport/transport.go diff --git a/go.mod b/go.mod index 60cc8d7c51..8524bdb29e 100644 --- a/go.mod +++ b/go.mod @@ -3,25 +3,29 @@ module github.com/iotaledger/goshimmer go 1.13 require ( + github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect github.com/dgraph-io/badger v1.6.0 github.com/dgrijalva/jwt-go v3.2.0+incompatible + github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b // indirect github.com/gdamore/tcell v1.3.0 github.com/go-zeromq/zmq4 v0.7.0 github.com/golang/protobuf v1.3.2 github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/autopeering-sim v0.0.0-20191230110650-35e88c0f9fe6 github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20 github.com/iotaledger/iota.go v1.0.0-beta.12 github.com/labstack/echo v3.3.10+incompatible + github.com/labstack/gommon v0.3.0 // indirect github.com/lucasb-eyer/go-colorful v1.0.3 // indirect github.com/magiconair/properties v1.8.1 github.com/mattn/go-colorable v0.1.4 // indirect github.com/mattn/go-isatty v0.0.11 // indirect github.com/mattn/go-runewidth v0.0.7 // indirect github.com/pelletier/go-toml v1.6.0 // indirect + github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect github.com/pkg/errors v0.8.1 github.com/rivo/tview v0.0.0-20191229165609-1ee8d9874dcf + github.com/sasha-s/go-deadlock v0.2.0 // indirect github.com/spf13/afero v1.2.2 // indirect github.com/spf13/cast v1.3.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect @@ -30,6 +34,8 @@ require ( github.com/stretchr/objx v0.2.0 // indirect github.com/stretchr/testify v1.4.0 github.com/valyala/fasttemplate v1.1.0 // indirect + go.uber.org/atomic v1.5.1 // indirect + go.uber.org/multierr v1.4.0 // indirect go.uber.org/zap v1.13.0 golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect diff --git a/go.sum b/go.sum index 78860b4fa7..5163fbe2ae 100644 --- a/go.sum +++ b/go.sum @@ -4,13 +4,9 @@ github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIo github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= -github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0= -github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/apsdehal/go-logger v0.0.0-20190506062552-f85330a4b532/go.mod h1:U3/8D6R9+bVpX0ORZjV+3mU9pQ86m7h1lESgJbXNvXA= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= @@ -24,7 +20,6 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= -github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -38,11 +33,8 @@ github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b h1:SeiGBzKrEtuDddn github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/ethereum/go-ethereum v1.9.3/go.mod h1:PwpWDrCLZrV+tfrhqqF6kPknbISMHaJv9Ln3kPCZLwY= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= -github.com/gdamore/tcell v1.1.2/go.mod h1:h3kq4HO9l2On+V9ed8w8ewqQEmGCSSHOgQ+2h8uzurE= -github.com/gdamore/tcell v1.2.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM= github.com/gdamore/tcell v1.3.0 h1:r35w0JBADPZCVQijYebl6YMWWtHRqVEGt7kL2eBADRM= github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -52,7 +44,6 @@ github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-zeromq/goczmq/v4 v4.2.2 h1:HAJN+i+3NW55ijMJJhk7oWxHKXgAuSBkoFfvr8bYj4U= github.com/go-zeromq/goczmq/v4 v4.2.2/go.mod h1:Sm/lxrfxP/Oxqs0tnHD6WAhwkWrx+S+1MRrKzcxoaYE= -github.com/go-zeromq/zmq4 v0.5.0/go.mod h1:6p7pjNlkfrQQVipmEuZDk7fakLZCqPPVK+Iq3jfbDg8= github.com/go-zeromq/zmq4 v0.7.0 h1:tmmTVfWB0HYo+8Ra0DK2MJIDl1lsvuU/J9559hpLU7s= github.com/go-zeromq/zmq4 v0.7.0/go.mod h1:fo1rWyfV/bsg7tq/F9LF1H0e2Cf3ovQFoge1G21AnWU= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -66,13 +57,11 @@ github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/open-location-code/go v0.0.0-20190723034300-2c7115db77a3/go.mod h1:eJfRN6aj+kR/rnua/rw9jAgYhqoMHldQkdTi+sePRKk= github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 h1:OdVal38kmXn0U3M3CYmPF4cpMLLvD4ioshwrooNfmxs= github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51/go.mod h1:eJfRN6aj+kR/rnua/rw9jAgYhqoMHldQkdTi+sePRKk= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= @@ -84,17 +73,11 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/autopeering-sim v0.0.0-20191230110650-35e88c0f9fe6 h1:i4VRC/lg5dec9FAt8jDHbJzy0bxWf18S4yOcy/u7RZ8= -github.com/iotaledger/autopeering-sim v0.0.0-20191230110650-35e88c0f9fe6/go.mod h1:JiaqaxLkQVnd8e/sya9y/LlRW56WlRKRl2TQXQCVssI= -github.com/iotaledger/goshimmer v0.0.0-20191113134331-c2d1b2f9d533/go.mod h1:7vYiofXphp9+PkgVAEM0pvw3aoi4ksrZ7lrEgX50XHs= -github.com/iotaledger/hive.go v0.0.0-20191118130432-89eebe8fe8eb/go.mod h1:1Thhlil4lHzuy53EVvmEbEvWBFY0Tasp4kCBfxBCPIk= github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20 h1:ZIJAeQSEdmVbmZNIW2198IwD23+wBteb4WE4pyjxk+c= github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20/go.mod h1:7iqun29a1x0lymTrn0UJ3Z/yy0sUzUpoOZ1OYMrYN20= -github.com/iotaledger/iota.go v1.0.0-beta.7/go.mod h1:dMps6iMVU1pf5NDYNKIw4tRsPeC8W3ZWjOvYHOO1PMg= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/iotaledger/iota.go v1.0.0-beta.12 h1:p6Pk3N8tmb6Kaj8F45O5XVJQfH5qQYqpvUnXiSMrtiE= github.com/iotaledger/iota.go v1.0.0-beta.12/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -131,7 +114,6 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= -github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= @@ -155,10 +137,8 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/rivo/tview v0.0.0-20190829161255-f8bc69b90341/go.mod h1:+rKjP5+h9HMwWRpAfhIkkQ9KE3m3Nz5rwn7YtUpwgqk= github.com/rivo/tview v0.0.0-20191229165609-1ee8d9874dcf h1:rh73WIukDlFIRqk1lk76or+LExEjTci2789EDvDD67U= github.com/rivo/tview v0.0.0-20191229165609-1ee8d9874dcf/go.mod h1:/rBeY22VG2QprWnEqG57IBC8biVu3i0DOIjRLc9I8H0= -github.com/rivo/uniseg v0.0.0-20190513083848-b9f5b9457d44/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -229,7 +209,6 @@ golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 h1:sKJQZMuxjOAR/Uo2LBfU90onWEf1dF4C+0hPJCc9Mpc= golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -248,15 +227,12 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191119073136-fc4aabc6c914/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -273,10 +249,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191018095205-727590c5006e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 h1:JA8d3MPx/IToSyXZG/RhwYEtfrKO1Fxrqe8KrkiLXKM= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -290,7 +264,6 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191121040551-947d4aa89328/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191230181014-9fb4d21460e1 h1:vNFL7Do+hbqZGmVjqkjTBUugGFXohWPyiHMLqLUbtP4= golang.org/x/tools v0.0.0-20191230181014-9fb4d21460e1/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -322,7 +295,6 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/zeromq/goczmq.v4 v4.1.0/go.mod h1:h4IlfePEYMpFdywGr5gAwKhBBj+hiBl/nF4VoSE4k+0= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/packages/autopeering/discover/common.go b/packages/autopeering/discover/common.go new file mode 100644 index 0000000000..7249d1beea --- /dev/null +++ b/packages/autopeering/discover/common.go @@ -0,0 +1,55 @@ +package discover + +import ( + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "go.uber.org/zap" +) + +const ( + // PingExpiration is the time until a peer verification expires. + PingExpiration = 12 * time.Hour + // MaxPeersInResponse is the maximum number of peers returned in DiscoveryResponse. + MaxPeersInResponse = 6 + // MaxServices is the maximum number of services a peer can support. + MaxServices = 5 + + // VersionNum specifies the expected version number for this Protocol. + VersionNum = 0 +) + +// Config holds discovery related settings. +type Config struct { + // These settings are required and configure the listener: + Log *zap.SugaredLogger + + // These settings are optional: + MasterPeers []*peer.Peer // list of master peers used for bootstrapping + Param *Parameters // parameters +} + +// default parameter values +const ( + // DefaultReverifyInterval is the default time interval after which a new peer is reverified. + DefaultReverifyInterval = 10 * time.Second + // DefaultReverifyTries is the default number of times a peer is pinged before it is removed. + DefaultReverifyTries = 2 + + // DefaultQueryInterval is the default time interval after which known peers are queried for new peers. + DefaultQueryInterval = 60 * time.Second + + // DefaultMaxManaged is the default maximum number of peers that can be managed. + DefaultMaxManaged = 1000 + // DefaultMaxReplacements is the default maximum number of peers kept in the replacement list. + DefaultMaxReplacements = 10 +) + +// Parameters holds the parameters that can be configured. +type Parameters struct { + ReverifyInterval time.Duration // time interval after which the next peer is reverified + ReverifyTries int // number of times a peer is pinged before it is removed + QueryInterval time.Duration // time interval after which peers are queried for new peers + MaxManaged int // maximum number of peers that can be managed + MaxReplacements int // maximum number of peers kept in the replacement list +} diff --git a/packages/autopeering/discover/events.go b/packages/autopeering/discover/events.go new file mode 100644 index 0000000000..177c6be84f --- /dev/null +++ b/packages/autopeering/discover/events.go @@ -0,0 +1,35 @@ +package discover + +import ( + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/hive.go/events" +) + +// Events contains all the events that are triggered during the peer discovery. +var Events = struct { + // A PeerDiscovered event is triggered, when a new peer has been discovered and verified. + PeerDiscovered *events.Event + // A PeerDeleted event is triggered, when a discovered and verified peer could not be reverified. + PeerDeleted *events.Event +}{ + PeerDiscovered: events.NewEvent(peerDiscovered), + PeerDeleted: events.NewEvent(peerDeleted), +} + +// DiscoveredEvent bundles the information of the discovered peer. +type DiscoveredEvent struct { + Peer *peer.Peer // discovered peer +} + +// DeletedEvent bundles the information of the deleted peer. +type DeletedEvent struct { + Peer *peer.Peer // deleted peer +} + +func peerDiscovered(handler interface{}, params ...interface{}) { + handler.(func(*DiscoveredEvent))(params[0].(*DiscoveredEvent)) +} + +func peerDeleted(handler interface{}, params ...interface{}) { + handler.(func(*DeletedEvent))(params[0].(*DeletedEvent)) +} diff --git a/packages/autopeering/discover/manager.go b/packages/autopeering/discover/manager.go new file mode 100644 index 0000000000..33e41c788d --- /dev/null +++ b/packages/autopeering/discover/manager.go @@ -0,0 +1,361 @@ +package discover + +import ( + "math/rand" + "sync" + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/server" + "go.uber.org/zap" +) + +var ( + reverifyInterval = DefaultReverifyInterval // time interval after which the next peer is reverified + reverifyTries = DefaultReverifyTries // number of times a peer is pinged before it is removed + queryInterval = DefaultQueryInterval // time interval after which peers are queried for new peers + maxManaged = DefaultMaxManaged // maximum number of peers that can be managed + maxReplacements = DefaultMaxReplacements // maximum number of peers kept in the replacement list +) + +type network interface { + local() *peer.Local + + ping(*peer.Peer) error + discoveryRequest(*peer.Peer) ([]*peer.Peer, error) +} + +type manager struct { + mutex sync.Mutex // protects active and replacement + active []*mpeer + replacements []*mpeer + + net network + log *zap.SugaredLogger + + wg sync.WaitGroup + closing chan struct{} +} + +func newManager(net network, masters []*peer.Peer, log *zap.SugaredLogger, param *Parameters) *manager { + if param != nil { + if param.ReverifyInterval > 0 { + reverifyInterval = param.ReverifyInterval + } + if param.ReverifyTries > 0 { + reverifyTries = param.ReverifyTries + } + if param.QueryInterval > 0 { + queryInterval = param.QueryInterval + } + if param.MaxManaged > 0 { + maxManaged = param.MaxManaged + } + if param.MaxReplacements > 0 { + maxReplacements = param.MaxReplacements + } + } + + m := &manager{ + active: make([]*mpeer, 0, maxManaged), + replacements: make([]*mpeer, 0, maxReplacements), + net: net, + log: log, + closing: make(chan struct{}), + } + m.loadInitialPeers(masters) + + return m +} + +func (m *manager) start() { + m.wg.Add(1) + go m.loop() +} + +func (m *manager) self() peer.ID { + return m.net.local().ID() +} + +func (m *manager) close() { + close(m.closing) + m.wg.Wait() +} + +func (m *manager) loop() { + defer m.wg.Done() + + var ( + reverify = time.NewTimer(0) // setting this to 0 will cause a trigger right away + reverifyDone chan struct{} + + query = time.NewTimer(server.ResponseTimeout) // trigger the first query after the reverify + queryNext chan time.Duration + ) + defer reverify.Stop() + defer query.Stop() + +Loop: + for { + select { + // start verification, if not yet running + case <-reverify.C: + // if there is no reverifyDone, this means doReverify is not running + if reverifyDone == nil { + reverifyDone = make(chan struct{}) + go m.doReverify(reverifyDone) + } + + // reset verification + case <-reverifyDone: + reverifyDone = nil + reverify.Reset(reverifyInterval) // reverify again after the given interval + + // start requesting new peers, if no yet running + case <-query.C: + if queryNext == nil { + queryNext = make(chan time.Duration) + go m.doQuery(queryNext) + } + + // on query done, reset time to given duration + case d := <-queryNext: + queryNext = nil + query.Reset(d) + + // on close, exit the loop + case <-m.closing: + break Loop + } + } + + // wait for spawned goroutines to finish + if reverifyDone != nil { + <-reverifyDone + } + if queryNext != nil { + <-queryNext + } +} + +// doReverify pings the oldest active peer. +func (m *manager) doReverify(done chan<- struct{}) { + defer close(done) + + p := m.peerToReverify() + if p == nil { + return // nothing can be reverified + } + m.log.Debugw("reverifying", + "id", p.ID(), + "addr", p.Address(), + ) + + var err error + for i := 0; i < reverifyTries; i++ { + err = m.net.ping(unwrapPeer(p)) + if err == nil { + break + } else { + m.log.Debugw("ping failed", + "id", p.ID(), + "addr", p.Address(), + "err", err, + ) + time.Sleep(1 * time.Second) + } + } + + // could not verify the peer + if err != nil { + m.mutex.Lock() + defer m.mutex.Unlock() + + m.active, _ = deletePeerByID(m.active, p.ID()) + m.log.Debugw("remove dead", + "peer", p, + ) + Events.PeerDeleted.Trigger(&DeletedEvent{Peer: unwrapPeer(p)}) + + // add a random replacement, if available + if len(m.replacements) > 0 { + var r *mpeer + m.replacements, r = deletePeer(m.replacements, rand.Intn(len(m.replacements))) + m.active = pushPeer(m.active, r, maxManaged) + } + return + } + + // no need to do anything here, as the peer is bumped when handling the pong +} + +// peerToReverify returns the oldest peer, or nil if empty. +func (m *manager) peerToReverify() *mpeer { + m.mutex.Lock() + defer m.mutex.Unlock() + + if len(m.active) == 0 { + return nil + } + // the last peer is the oldest + return m.active[len(m.active)-1] +} + +// updatePeer moves the peer with the given ID to the front of the list of managed peers. +// It returns true if a peer was bumped or false if there was no peer with that id +func (m *manager) updatePeer(update *peer.Peer) bool { + id := update.ID() + for i, p := range m.active { + if p.ID() == id { + if i > 0 { + // move i-th peer to the front + copy(m.active[1:], m.active[:i]) + } + // replace first mpeer with a wrap of the updated peer + m.active[0] = &mpeer{ + Peer: *update, + verifiedCount: p.verifiedCount + 1, + lastNewPeers: p.lastNewPeers, + } + + return true + } + } + return false +} + +func (m *manager) addReplacement(p *mpeer) bool { + if containsPeer(m.replacements, p.ID()) { + return false // already in the list + } + m.replacements = unshiftPeer(m.replacements, p, maxReplacements) + return true +} + +func (m *manager) loadInitialPeers(masters []*peer.Peer) { + var peers []*peer.Peer + + db := m.net.local().Database() + if db != nil { + peers = db.SeedPeers() + } + peers = append(peers, masters...) + for _, p := range peers { + m.addDiscoveredPeer(p) + } +} + +// addDiscoveredPeer adds a newly discovered peer that has never been verified or pinged yet. +// It returns true, if the given peer was new and added, false otherwise. +func (m *manager) addDiscoveredPeer(p *peer.Peer) bool { + // never add the local peer + if p.ID() == m.self() { + return false + } + + m.mutex.Lock() + defer m.mutex.Unlock() + + if containsPeer(m.active, p.ID()) { + return false + } + m.log.Debugw("discovered", + "peer", p, + ) + + mp := wrapPeer(p) + if len(m.active) >= maxManaged { + return m.addReplacement(mp) + } + + m.active = pushPeer(m.active, mp, maxManaged) + return true +} + +// addVerifiedPeer adds a new peer that has just been successfully pinged. +// It returns true, if the given peer was new and added, false otherwise. +func (m *manager) addVerifiedPeer(p *peer.Peer) bool { + // never add the local peer + if p.ID() == m.self() { + return false + } + + m.log.Debugw("verified", + "peer", p, + "services", p.Services(), + ) + + m.mutex.Lock() + defer m.mutex.Unlock() + + // if already in the list, move it to the front + if m.updatePeer(p) { + return false + } + + mp := wrapPeer(p) + mp.verifiedCount = 1 + + if len(m.active) >= maxManaged { + return m.addReplacement(mp) + } + // trigger the event only when the peer is added to active + Events.PeerDiscovered.Trigger(&DiscoveredEvent{Peer: p}) + + // new nodes are added to the front + m.active = unshiftPeer(m.active, mp, maxManaged) + return true +} + +// getRandomPeers returns a list of randomly selected peers. +func (m *manager) getRandomPeers(n int, minVerified uint) []*peer.Peer { + m.mutex.Lock() + defer m.mutex.Unlock() + + if n > len(m.active) { + n = len(m.active) + } + + peers := make([]*peer.Peer, 0, n) + for _, i := range rand.Perm(len(m.active)) { + if len(peers) == n { + break + } + + mp := m.active[i] + if mp.verifiedCount < minVerified { + continue + } + peers = append(peers, unwrapPeer(mp)) + } + + return peers +} + +// getVerifiedPeers returns all the currently managed peers that have been verified at least once. +func (m *manager) getVerifiedPeers() []*mpeer { + m.mutex.Lock() + defer m.mutex.Unlock() + + peers := make([]*mpeer, 0, len(m.active)) + for _, mp := range m.active { + if mp.verifiedCount == 0 { + continue + } + peers = append(peers, mp) + } + + return peers +} + +// isKnown returns true if the manager is keeping track of that peer. +func (m *manager) isKnown(id peer.ID) bool { + if id == m.self() { + return true + } + + m.mutex.Lock() + defer m.mutex.Unlock() + + return containsPeer(m.active, id) || containsPeer(m.replacements, id) +} diff --git a/packages/autopeering/discover/manager_test.go b/packages/autopeering/discover/manager_test.go new file mode 100644 index 0000000000..580b87e78d --- /dev/null +++ b/packages/autopeering/discover/manager_test.go @@ -0,0 +1,179 @@ +package discover + +import ( + "fmt" + "testing" + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/iotaledger/goshimmer/packages/autopeering/server" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" +) + +type NetworkMock struct { + mock.Mock + + loc *peer.Local +} + +func (m *NetworkMock) local() *peer.Local { + return m.loc +} + +func (m *NetworkMock) ping(p *peer.Peer) error { + args := m.Called(p) + return args.Error(0) +} + +func (m *NetworkMock) discoveryRequest(p *peer.Peer) ([]*peer.Peer, error) { + args := m.Called(p) + return args.Get(0).([]*peer.Peer), args.Error(1) +} + +func newNetworkMock() *NetworkMock { + local, _ := peer.NewLocal("mock", "0", peer.NewMemoryDB(logger)) + return &NetworkMock{ + // no database needed + loc: local, + } +} + +func newDummyPeer(name string) *peer.Peer { + services := service.New() + services.Update(service.PeeringKey, "dummy", name) + + return peer.NewPeer([]byte(name), services) +} + +func newTestManager() (*manager, *NetworkMock, func()) { + networkMock := newNetworkMock() + mgr := newManager(networkMock, nil, logger, nil) + teardown := func() { + mgr.close() + } + return mgr, networkMock, teardown +} + +func TestMgrClose(t *testing.T) { + _, _, teardown := newTestManager() + defer teardown() + + time.Sleep(graceTime) +} + +func TestMgrVerifyDiscoveredPeer(t *testing.T) { + mgr, m, teardown := newTestManager() + defer teardown() + + p := newDummyPeer("p") + + // expect ping of peer p + m.On("ping", p).Return(nil).Once() + // ignore discoveryRequest calls + m.On("discoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() + + // let the manager initialize + time.Sleep(graceTime) + + mgr.addDiscoveredPeer(p) + + mgr.doReverify(make(chan struct{})) // manually trigger a verify + m.AssertExpectations(t) +} + +func TestMgrReverifyPeer(t *testing.T) { + mgr, m, teardown := newTestManager() + defer teardown() + + p := newDummyPeer("p") + + // expect ping of peer p + m.On("ping", p).Return(nil).Once() + // ignore discoveryRequest calls + m.On("discoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() + + // let the manager initialize + time.Sleep(graceTime) + + mgr.addVerifiedPeer(p) + + mgr.doReverify(make(chan struct{})) // manually trigger a verify + m.AssertExpectations(t) +} + +func TestMgrRequestDiscoveredPeer(t *testing.T) { + mgr, m, teardown := newTestManager() + defer teardown() + + p1 := newDummyPeer("verified") + p2 := newDummyPeer("discovered") + + // expect discoveryRequest on the discovered peer + m.On("discoveryRequest", p1).Return([]*peer.Peer{p2}, nil).Once() + // ignore any ping + m.On("ping", mock.Anything).Return(nil).Maybe() + + mgr.addVerifiedPeer(p1) + mgr.addDiscoveredPeer(p2) + + mgr.doQuery(make(chan time.Duration, 1)) // manually trigger a query + m.AssertExpectations(t) +} + +func TestMgrAddManyVerifiedPeers(t *testing.T) { + mgr, m, teardown := newTestManager() + defer teardown() + + p := newDummyPeer("p") + + // expect ping of peer p + m.On("ping", p).Return(nil).Once() + // ignore discoveryRequest calls + m.On("discoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() + + // let the manager initialize + time.Sleep(graceTime) + + mgr.addVerifiedPeer(p) + for i := 0; i < maxManaged+maxReplacements; i++ { + mgr.addVerifiedPeer(newDummyPeer(fmt.Sprintf("p%d", i))) + } + + mgr.doReverify(make(chan struct{})) // manually trigger a verify + ps := unwrapPeers(mgr.getVerifiedPeers()) + + assert.Equal(t, maxManaged, len(ps)) + assert.Contains(t, ps, p) + + m.AssertExpectations(t) +} + +func TestMgrDeleteUnreachablePeer(t *testing.T) { + mgr, m, teardown := newTestManager() + defer teardown() + + p := newDummyPeer("p") + + // expect ping of peer p, but return error + m.On("ping", p).Return(server.ErrTimeout).Times(reverifyTries) + // ignore discoveryRequest calls + m.On("discoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() + + // let the manager initialize + time.Sleep(graceTime) + + mgr.addVerifiedPeer(p) + for i := 0; i < maxManaged; i++ { + mgr.addVerifiedPeer(newDummyPeer(fmt.Sprintf("p%d", i))) + } + + mgr.doReverify(make(chan struct{})) // manually trigger a verify + ps := unwrapPeers(mgr.getVerifiedPeers()) + + assert.Equal(t, maxManaged, len(ps)) + assert.NotContains(t, ps, p) + + m.AssertExpectations(t) +} diff --git a/packages/autopeering/discover/mpeer.go b/packages/autopeering/discover/mpeer.go new file mode 100644 index 0000000000..7116ad85b6 --- /dev/null +++ b/packages/autopeering/discover/mpeer.go @@ -0,0 +1,95 @@ +package discover + +import ( + "fmt" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" +) + +// mpeer represents a discovered peer with additional data. +// The fields of Peer may not be modified. +type mpeer struct { + peer.Peer + + verifiedCount uint // how often that peer has been reverified + lastNewPeers uint // number of returned new peers when queried the last time +} + +func wrapPeer(p *peer.Peer) *mpeer { + return &mpeer{Peer: *p} +} + +func unwrapPeer(p *mpeer) *peer.Peer { + return &p.Peer +} + +func unwrapPeers(ps []*mpeer) []*peer.Peer { + result := make([]*peer.Peer, len(ps)) + for i, n := range ps { + result[i] = unwrapPeer(n) + } + return result +} + +// containsPeer returns true if a peer with the given ID is in the list. +func containsPeer(list []*mpeer, id peer.ID) bool { + for _, p := range list { + if p.ID() == id { + return true + } + } + return false +} + +// unshiftPeer adds a new peer to the front of the list. +// If the list already contains max peers, the last is discarded. +func unshiftPeer(list []*mpeer, p *mpeer, max int) []*mpeer { + if len(list) > max { + panic(fmt.Sprintf("mpeer: invalid max value %d", max)) + } + if len(list) < max { + list = append(list, nil) + } + copy(list[1:], list) + list[0] = p + + return list +} + +// deletePeer is a helper that deletes the peer with the given index from the list. +func deletePeer(list []*mpeer, i int) ([]*mpeer, *mpeer) { + if i >= len(list) { + panic("mpeer: invalid index or empty mpeer list") + } + p := list[i] + + copy(list[i:], list[i+1:]) + list[len(list)-1] = nil + + return list[:len(list)-1], p +} + +// deletePeerByID deletes the peer with the given ID from the list. +func deletePeerByID(list []*mpeer, id peer.ID) ([]*mpeer, *mpeer) { + for i, p := range list { + if p.ID() == id { + return deletePeer(list, i) + } + } + panic("mpeer: id not contained in list") +} + +// pushPeer adds the given peer to the pack of the list. +// If the list already contains max peers, the first is discarded. +func pushPeer(list []*mpeer, p *mpeer, max int) []*mpeer { + if len(list) > max { + panic(fmt.Sprintf("mpeer: invalid max value %d", max)) + } + if len(list) == max { + copy(list, list[1:]) + list[len(list)-1] = p + return list + } + + return append(list, p) +} diff --git a/packages/autopeering/discover/mpeer_test.go b/packages/autopeering/discover/mpeer_test.go new file mode 100644 index 0000000000..97a8f22d26 --- /dev/null +++ b/packages/autopeering/discover/mpeer_test.go @@ -0,0 +1,196 @@ +package discover + +import ( + "fmt" + "testing" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/stretchr/testify/assert" +) + +func newTestPeer(name string) *peer.Peer { + services := service.New() + services.Update(service.PeeringKey, "test", name) + + return peer.NewPeer([]byte(name), services) +} + +func TestUnwrapPeers(t *testing.T) { + m := make([]*mpeer, 5) + p := make([]*peer.Peer, 5) + for i := range m { + p[i] = newTestPeer(fmt.Sprintf("%d", i)) + m[i] = &mpeer{Peer: *p[i]} + } + + unwrapP := unwrapPeers(m) + assert.Equal(t, p, unwrapP, "unwrapPeers") +} + +func TestContainsPeer(t *testing.T) { + m := make([]*mpeer, 5) + p := make([]*peer.Peer, 5) + k := newTestPeer("k") + for i := range m { + p[i] = newTestPeer(fmt.Sprintf("%d", i)) + m[i] = &mpeer{Peer: *p[i]} + } + + for i := range m { + assert.Equal(t, true, containsPeer(m, p[i].ID()), "Contains") + } + assert.Equal(t, false, containsPeer(m, k.ID()), "Contains") +} + +func TestUnshiftPeer(t *testing.T) { + m := make([]*mpeer, 5) + for i := range m { + m[i] = &mpeer{Peer: *newTestPeer(fmt.Sprintf("%d", i))} + } + + type testCase struct { + input []*mpeer + toAdd *mpeer + expected []*mpeer + } + + tests := []testCase{ + { + input: []*mpeer{}, + toAdd: m[0], + expected: []*mpeer{m[0]}, + }, + { + input: []*mpeer{m[0]}, + toAdd: m[1], + expected: []*mpeer{m[1], m[0]}, + }, + { + input: []*mpeer{m[0], m[1]}, + toAdd: m[2], + expected: []*mpeer{m[2], m[0], m[1]}, + }, + { + input: []*mpeer{m[0], m[1], m[2], m[3]}, + toAdd: m[4], + expected: []*mpeer{m[4], m[0], m[1], m[2]}, + }, + } + + for _, test := range tests { + test.input = unshiftPeer(test.input, test.toAdd, len(m)-1) + assert.Equal(t, test.expected, test.input, "unshiftPeer") + } +} + +func TestDeletePeer(t *testing.T) { + m := make([]*mpeer, 5) + for i := range m { + m[i] = &mpeer{Peer: *newTestPeer(fmt.Sprintf("%d", i))} + } + + type testCase struct { + input []*mpeer + toRemove int + expected []*mpeer + deleted *mpeer + } + + tests := []testCase{ + { + input: []*mpeer{m[0]}, + toRemove: 0, + expected: []*mpeer{}, + deleted: m[0], + }, + { + input: []*mpeer{m[0], m[1], m[2], m[3]}, + toRemove: 2, + expected: []*mpeer{m[0], m[1], m[3]}, + deleted: m[2], + }, + } + + for _, test := range tests { + var deleted *mpeer + test.input, deleted = deletePeer(test.input, test.toRemove) + assert.Equal(t, test.expected, test.input, "deletePeer_list") + assert.Equal(t, test.deleted, deleted, "deletePeer_peer") + } +} + +func TestDeletePeerByID(t *testing.T) { + m := make([]*mpeer, 5) + p := make([]*peer.Peer, 5) + for i := range m { + p[i] = newTestPeer(fmt.Sprintf("%d", i)) + m[i] = &mpeer{Peer: *p[i]} + } + + type testCase struct { + input []*mpeer + toRemove peer.ID + expected []*mpeer + deleted *mpeer + } + + tests := []testCase{ + { + input: []*mpeer{m[0]}, + toRemove: p[0].ID(), + expected: []*mpeer{}, + deleted: m[0], + }, + { + input: []*mpeer{m[0], m[1], m[2], m[3]}, + toRemove: p[2].ID(), + expected: []*mpeer{m[0], m[1], m[3]}, + deleted: m[2], + }, + } + + for _, test := range tests { + var deleted *mpeer + test.input, deleted = deletePeerByID(test.input, test.toRemove) + assert.Equal(t, test.expected, test.input, "deletePeerByID_list") + assert.Equal(t, test.deleted, deleted, "deletePeerByID_peer") + } +} + +func TestPushPeer(t *testing.T) { + m := make([]*mpeer, 5) + max := len(m) - 1 + for i := range m { + m[i] = &mpeer{Peer: *newTestPeer(fmt.Sprintf("%d", i))} + } + + type testCase struct { + input []*mpeer + toPush *mpeer + expected []*mpeer + } + + tests := []testCase{ + { + input: []*mpeer{}, + toPush: m[0], + expected: []*mpeer{m[0]}, + }, + { + input: []*mpeer{m[0], m[1]}, + toPush: m[2], + expected: []*mpeer{m[0], m[1], m[2]}, + }, + { + input: []*mpeer{m[0], m[1], m[2], m[3]}, + toPush: m[4], + expected: []*mpeer{m[1], m[2], m[3], m[4]}, + }, + } + + for _, test := range tests { + test.input = pushPeer(test.input, test.toPush, max) + assert.Equal(t, test.expected, test.input, "pushPeer") + } +} diff --git a/packages/autopeering/discover/proto/message.go b/packages/autopeering/discover/proto/message.go new file mode 100644 index 0000000000..d751686297 --- /dev/null +++ b/packages/autopeering/discover/proto/message.go @@ -0,0 +1,39 @@ +package proto + +import ( + "github.com/golang/protobuf/proto" + "github.com/iotaledger/goshimmer/packages/autopeering/server" +) + +// MType is the type of message type enum. +type MType = server.MType + +// An enum for the different message types. +const ( + MPing MType = 10 + iota + MPong + MDiscoveryRequest + MDiscoveryResponse +) + +// Message extends the proto.Message interface with additional util functions. +type Message interface { + proto.Message + + // Name returns the name of the corresponding message type for debugging. + Name() string + // Type returns the type of the corresponding message as an enum. + Type() MType +} + +func (m *Ping) Name() string { return "PING" } +func (m *Ping) Type() MType { return MPing } + +func (m *Pong) Name() string { return "PONG" } +func (m *Pong) Type() MType { return MPong } + +func (m *DiscoveryRequest) Name() string { return "DISCOVERY_REQUEST" } +func (m *DiscoveryRequest) Type() MType { return MDiscoveryRequest } + +func (m *DiscoveryResponse) Name() string { return "DISCOVERY_RESPONSE" } +func (m *DiscoveryResponse) Type() MType { return MDiscoveryResponse } diff --git a/packages/autopeering/discover/proto/message.pb.go b/packages/autopeering/discover/proto/message.pb.go new file mode 100644 index 0000000000..f130a59ec2 --- /dev/null +++ b/packages/autopeering/discover/proto/message.pb.go @@ -0,0 +1,280 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: discover/proto/message.proto + +package proto + +import ( + fmt "fmt" + math "math" + + proto "github.com/golang/protobuf/proto" + proto2 "github.com/iotaledger/goshimmer/packages/autopeering/peer/proto" + proto1 "github.com/iotaledger/goshimmer/packages/autopeering/peer/service/proto" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// 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 + +type Ping struct { + // protocol version number + Version uint32 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + // string form of the return address (e.g. "192.0.2.1:25", "[2001:db8::1]:80") + From string `protobuf:"bytes,2,opt,name=from,proto3" json:"from,omitempty"` + // string form of the recipient address + To string `protobuf:"bytes,3,opt,name=to,proto3" json:"to,omitempty"` + // unix time + Timestamp int64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Ping) Reset() { *m = Ping{} } +func (m *Ping) String() string { return proto.CompactTextString(m) } +func (*Ping) ProtoMessage() {} +func (*Ping) Descriptor() ([]byte, []int) { + return fileDescriptor_43f14146485f66eb, []int{0} +} + +func (m *Ping) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Ping.Unmarshal(m, b) +} +func (m *Ping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Ping.Marshal(b, m, deterministic) +} +func (m *Ping) XXX_Merge(src proto.Message) { + xxx_messageInfo_Ping.Merge(m, src) +} +func (m *Ping) XXX_Size() int { + return xxx_messageInfo_Ping.Size(m) +} +func (m *Ping) XXX_DiscardUnknown() { + xxx_messageInfo_Ping.DiscardUnknown(m) +} + +var xxx_messageInfo_Ping proto.InternalMessageInfo + +func (m *Ping) GetVersion() uint32 { + if m != nil { + return m.Version + } + return 0 +} + +func (m *Ping) GetFrom() string { + if m != nil { + return m.From + } + return "" +} + +func (m *Ping) GetTo() string { + if m != nil { + return m.To + } + return "" +} + +func (m *Ping) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +type Pong struct { + // hash of the ping packet + PingHash []byte `protobuf:"bytes,1,opt,name=ping_hash,json=pingHash,proto3" json:"ping_hash,omitempty"` + // string form of the recipient address + To string `protobuf:"bytes,2,opt,name=to,proto3" json:"to,omitempty"` + // services supported by the sender + Services *proto1.ServiceMap `protobuf:"bytes,3,opt,name=services,proto3" json:"services,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Pong) Reset() { *m = Pong{} } +func (m *Pong) String() string { return proto.CompactTextString(m) } +func (*Pong) ProtoMessage() {} +func (*Pong) Descriptor() ([]byte, []int) { + return fileDescriptor_43f14146485f66eb, []int{1} +} + +func (m *Pong) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Pong.Unmarshal(m, b) +} +func (m *Pong) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Pong.Marshal(b, m, deterministic) +} +func (m *Pong) XXX_Merge(src proto.Message) { + xxx_messageInfo_Pong.Merge(m, src) +} +func (m *Pong) XXX_Size() int { + return xxx_messageInfo_Pong.Size(m) +} +func (m *Pong) XXX_DiscardUnknown() { + xxx_messageInfo_Pong.DiscardUnknown(m) +} + +var xxx_messageInfo_Pong proto.InternalMessageInfo + +func (m *Pong) GetPingHash() []byte { + if m != nil { + return m.PingHash + } + return nil +} + +func (m *Pong) GetTo() string { + if m != nil { + return m.To + } + return "" +} + +func (m *Pong) GetServices() *proto1.ServiceMap { + if m != nil { + return m.Services + } + return nil +} + +type DiscoveryRequest struct { + // string form of the recipient address + To string `protobuf:"bytes,1,opt,name=to,proto3" json:"to,omitempty"` + // unix time + Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DiscoveryRequest) Reset() { *m = DiscoveryRequest{} } +func (m *DiscoveryRequest) String() string { return proto.CompactTextString(m) } +func (*DiscoveryRequest) ProtoMessage() {} +func (*DiscoveryRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_43f14146485f66eb, []int{2} +} + +func (m *DiscoveryRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DiscoveryRequest.Unmarshal(m, b) +} +func (m *DiscoveryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DiscoveryRequest.Marshal(b, m, deterministic) +} +func (m *DiscoveryRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_DiscoveryRequest.Merge(m, src) +} +func (m *DiscoveryRequest) XXX_Size() int { + return xxx_messageInfo_DiscoveryRequest.Size(m) +} +func (m *DiscoveryRequest) XXX_DiscardUnknown() { + xxx_messageInfo_DiscoveryRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_DiscoveryRequest proto.InternalMessageInfo + +func (m *DiscoveryRequest) GetTo() string { + if m != nil { + return m.To + } + return "" +} + +func (m *DiscoveryRequest) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +type DiscoveryResponse struct { + // hash of the corresponding request + ReqHash []byte `protobuf:"bytes,1,opt,name=req_hash,json=reqHash,proto3" json:"req_hash,omitempty"` + // list of peers + Peers []*proto2.Peer `protobuf:"bytes,2,rep,name=peers,proto3" json:"peers,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *DiscoveryResponse) Reset() { *m = DiscoveryResponse{} } +func (m *DiscoveryResponse) String() string { return proto.CompactTextString(m) } +func (*DiscoveryResponse) ProtoMessage() {} +func (*DiscoveryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_43f14146485f66eb, []int{3} +} + +func (m *DiscoveryResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_DiscoveryResponse.Unmarshal(m, b) +} +func (m *DiscoveryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_DiscoveryResponse.Marshal(b, m, deterministic) +} +func (m *DiscoveryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_DiscoveryResponse.Merge(m, src) +} +func (m *DiscoveryResponse) XXX_Size() int { + return xxx_messageInfo_DiscoveryResponse.Size(m) +} +func (m *DiscoveryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_DiscoveryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_DiscoveryResponse proto.InternalMessageInfo + +func (m *DiscoveryResponse) GetReqHash() []byte { + if m != nil { + return m.ReqHash + } + return nil +} + +func (m *DiscoveryResponse) GetPeers() []*proto2.Peer { + if m != nil { + return m.Peers + } + return nil +} + +func init() { + proto.RegisterType((*Ping)(nil), "proto.Ping") + proto.RegisterType((*Pong)(nil), "proto.Pong") + proto.RegisterType((*DiscoveryRequest)(nil), "proto.DiscoveryRequest") + proto.RegisterType((*DiscoveryResponse)(nil), "proto.DiscoveryResponse") +} + +func init() { proto.RegisterFile("discover/proto/message.proto", fileDescriptor_43f14146485f66eb) } + +var fileDescriptor_43f14146485f66eb = []byte{ + // 309 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x6c, 0x91, 0xc1, 0x4b, 0xc3, 0x30, + 0x14, 0xc6, 0x59, 0xd7, 0xb9, 0xf6, 0x4d, 0xc5, 0x05, 0x84, 0x3a, 0x77, 0x98, 0x3b, 0x79, 0x59, + 0x0b, 0x2a, 0x9e, 0x45, 0x3c, 0x78, 0x11, 0x66, 0xbc, 0x79, 0x91, 0xb4, 0x8b, 0x6d, 0xc0, 0x36, + 0x59, 0x93, 0x0e, 0xfc, 0xef, 0x7d, 0x4d, 0x63, 0x9d, 0xe2, 0x29, 0xef, 0x7d, 0xef, 0xf1, 0x7d, + 0xbf, 0x24, 0x30, 0xdf, 0x08, 0x9d, 0xc9, 0x1d, 0xaf, 0x13, 0x55, 0x4b, 0x23, 0x93, 0x92, 0x6b, + 0xcd, 0x72, 0x1e, 0xdb, 0x8e, 0x8c, 0xec, 0x31, 0x3b, 0x55, 0xbc, 0x5f, 0x68, 0xcb, 0x6e, 0x3a, + 0x5b, 0x58, 0x59, 0xf3, 0x7a, 0x27, 0x32, 0xee, 0xc6, 0xae, 0xeb, 0x36, 0x96, 0x29, 0xf8, 0x6b, + 0x51, 0xe5, 0x24, 0x82, 0x31, 0x46, 0x68, 0x21, 0xab, 0x68, 0xb0, 0x18, 0x5c, 0x1e, 0xd1, 0xef, + 0x96, 0x10, 0xf0, 0xdf, 0x6b, 0x59, 0x46, 0x1e, 0xca, 0x21, 0xb5, 0x35, 0x39, 0x06, 0xcf, 0xc8, + 0x68, 0x68, 0x15, 0xac, 0xc8, 0x1c, 0x42, 0x23, 0x10, 0xcc, 0xb0, 0x52, 0x45, 0x3e, 0xca, 0x43, + 0xfa, 0x23, 0xd8, 0x0c, 0x89, 0x19, 0xe7, 0x10, 0x2a, 0xcc, 0x7a, 0x2b, 0x98, 0x2e, 0x6c, 0xca, + 0x21, 0x0d, 0x5a, 0xe1, 0x11, 0x7b, 0x67, 0xe9, 0xf5, 0x96, 0x2b, 0x08, 0x1c, 0xa9, 0xb6, 0x41, + 0x93, 0xab, 0x69, 0x87, 0x1c, 0xbf, 0x74, 0xf2, 0x13, 0x53, 0xb4, 0x5f, 0x59, 0xde, 0xc1, 0xc9, + 0x83, 0x7b, 0xa7, 0x4f, 0xca, 0xb7, 0x0d, 0x46, 0x3b, 0xcb, 0xc1, 0xff, 0x94, 0xde, 0x5f, 0xca, + 0x67, 0x98, 0xee, 0x39, 0x68, 0x25, 0x2b, 0xcd, 0xc9, 0x19, 0x04, 0x35, 0xdf, 0xee, 0x13, 0x8f, + 0xb1, 0xb7, 0xc0, 0x17, 0x30, 0x6a, 0x5f, 0x57, 0xa3, 0xd3, 0x10, 0xe9, 0x26, 0x8e, 0x6e, 0x8d, + 0x1a, 0xed, 0x26, 0xf7, 0xb7, 0xaf, 0x37, 0xb9, 0x30, 0x45, 0x93, 0xc6, 0x99, 0x2c, 0x13, 0x21, + 0x0d, 0xfb, 0xe0, 0x9b, 0x1c, 0x7f, 0x84, 0x35, 0x46, 0xb6, 0x2b, 0x78, 0xf9, 0x95, 0x16, 0x65, + 0xf2, 0xfb, 0x8b, 0xd3, 0x03, 0x7b, 0x5c, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x4d, 0xa6, 0x1f, + 0xce, 0xfb, 0x01, 0x00, 0x00, +} diff --git a/packages/autopeering/discover/proto/message.proto b/packages/autopeering/discover/proto/message.proto new file mode 100644 index 0000000000..e76db4eab9 --- /dev/null +++ b/packages/autopeering/discover/proto/message.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; + +option go_package = "github.com/iotaledger/goshimmer/packages/autopeering/discover/proto"; + +package proto; + +import "peer/proto/peer.proto"; +import "peer/service/proto/service.proto"; + +message Ping { + // protocol version number + uint32 version = 1; + // string form of the return address (e.g. "192.0.2.1:25", "[2001:db8::1]:80") + string from = 2; + // string form of the recipient address + string to = 3; + // unix time + int64 timestamp = 4; +} + +message Pong { + // hash of the ping packet + bytes ping_hash = 1; + // string form of the recipient address + string to = 2; + // services supported by the sender + ServiceMap services = 3; +} + +message DiscoveryRequest { + // string form of the recipient address + string to = 1; + // unix time + int64 timestamp = 2; +} + +message DiscoveryResponse { + // hash of the corresponding request + bytes req_hash = 1; + // list of peers + repeated Peer peers = 2; +} diff --git a/packages/autopeering/discover/protocol.go b/packages/autopeering/discover/protocol.go new file mode 100644 index 0000000000..7202c66dbe --- /dev/null +++ b/packages/autopeering/discover/protocol.go @@ -0,0 +1,468 @@ +package discover + +import ( + "bytes" + "sync" + "time" + + "github.com/golang/protobuf/proto" + pb "github.com/iotaledger/goshimmer/packages/autopeering/discover/proto" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + peerpb "github.com/iotaledger/goshimmer/packages/autopeering/peer/proto" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/iotaledger/goshimmer/packages/autopeering/server" + "github.com/pkg/errors" + "go.uber.org/zap" +) + +// The Protocol handles the peer discovery. +// It responds to incoming messages and sends own requests when needed. +type Protocol struct { + server.Protocol + + loc *peer.Local // local peer that runs the protocol + log *zap.SugaredLogger // logging + + mgr *manager // the manager handles the actual peer discovery and re-verification + closeOnce sync.Once +} + +// New creates a new discovery protocol. +func New(local *peer.Local, cfg Config) *Protocol { + p := &Protocol{ + Protocol: server.Protocol{}, + loc: local, + log: cfg.Log, + } + p.mgr = newManager(p, cfg.MasterPeers, cfg.Log.Named("mgr"), cfg.Param) + + return p +} + +// local returns the associated local peer of the neighbor selection. +func (p *Protocol) local() *peer.Local { + return p.loc +} + +// Start starts the actual peer discovery over the provided Sender. +func (p *Protocol) Start(s server.Sender) { + p.Protocol.Sender = s + p.mgr.start() + + p.log.Debugw("discover started", + "addr", s.LocalAddr(), + ) +} + +// Close finalizes the protocol. +func (p *Protocol) Close() { + p.closeOnce.Do(func() { + p.mgr.close() + }) +} + +// IsVerified checks whether the given peer has recently been verified a recent enough endpoint proof. +func (p *Protocol) IsVerified(id peer.ID, addr string) bool { + return time.Since(p.loc.Database().LastPong(id, addr)) < PingExpiration +} + +// EnsureVerified checks if the given peer has recently sent a ping; +// if not, we send a ping to trigger a verification. +func (p *Protocol) EnsureVerified(peer *peer.Peer) { + if !p.hasVerified(peer.ID(), peer.Address()) { + <-p.sendPing(peer.Address(), peer.ID()) + // Wait for them to ping back and process our pong + time.Sleep(server.ResponseTimeout) + } +} + +// GetVerifiedPeer returns the verified peer with the given ID, or nil if no such peer exists. +func (p *Protocol) GetVerifiedPeer(id peer.ID, addr string) *peer.Peer { + if !p.IsVerified(id, addr) { + return nil + } + peer := p.loc.Database().Peer(id) + if peer == nil { + return nil + } + if peer.Address() != addr { + return nil + } + return peer +} + +// GetVerifiedPeers returns all the currently managed peers that have been verified at least once. +func (p *Protocol) GetVerifiedPeers() []*peer.Peer { + return unwrapPeers(p.mgr.getVerifiedPeers()) +} + +// HandleMessage responds to incoming peer discovery messages. +func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer.ID, fromKey peer.PublicKey, data []byte) (bool, error) { + switch pb.MType(data[0]) { + + // Ping + case pb.MPing: + m := new(pb.Ping) + if err := proto.Unmarshal(data[1:], m); err != nil { + return true, errors.Wrap(err, "invalid message") + } + if p.validatePing(s, fromAddr, m) { + p.handlePing(s, fromAddr, fromID, fromKey, data) + } + + // Pong + case pb.MPong: + m := new(pb.Pong) + if err := proto.Unmarshal(data[1:], m); err != nil { + return true, errors.Wrap(err, "invalid message") + } + if p.validatePong(s, fromAddr, fromID, m) { + p.handlePong(fromAddr, fromID, fromKey, m) + } + + // DiscoveryRequest + case pb.MDiscoveryRequest: + m := new(pb.DiscoveryRequest) + if err := proto.Unmarshal(data[1:], m); err != nil { + return true, errors.Wrap(err, "invalid message") + } + if p.validateDiscoveryRequest(s, fromAddr, fromID, m) { + p.handleDiscoveryRequest(s, fromAddr, data) + } + + // DiscoveryResponse + case pb.MDiscoveryResponse: + m := new(pb.DiscoveryResponse) + if err := proto.Unmarshal(data[1:], m); err != nil { + return true, errors.Wrap(err, "invalid message") + } + p.validateDiscoveryResponse(s, fromAddr, fromID, m) + // DiscoveryResponse messages are handled in the handleReply function of the validation + + default: + return false, nil + } + + return true, nil +} + +// ------ message senders ------ + +// ping sends a ping to the specified peer and blocks until a reply is received or timeout. +func (p *Protocol) ping(to *peer.Peer) error { + return <-p.sendPing(to.Address(), to.ID()) +} + +// sendPing sends a ping to the specified address and expects a matching reply. +// This method is non-blocking, but it returns a channel that can be used to query potential errors. +func (p *Protocol) sendPing(toAddr string, toID peer.ID) <-chan error { + ping := newPing(p.LocalAddr(), toAddr) + data := marshal(ping) + + // compute the message hash + hash := server.PacketHash(data) + hashEqual := func(m interface{}) bool { + return bytes.Equal(m.(*pb.Pong).GetPingHash(), hash) + } + + // expect a pong referencing the ping we are about to send + p.log.Debugw("send message", "type", ping.Name(), "addr", toAddr) + errc := p.Protocol.SendExpectingReply(toAddr, toID, data, pb.MPong, hashEqual) + + return errc +} + +// discoveryRequest request known peers from the given target. This method blocks +// until a response is received and the provided peers are returned. +func (p *Protocol) discoveryRequest(to *peer.Peer) ([]*peer.Peer, error) { + p.EnsureVerified(to) + + // create the request package + toAddr := to.Address() + req := newDiscoveryRequest(toAddr) + data := marshal(req) + + // compute the message hash + hash := server.PacketHash(data) + peers := make([]*peer.Peer, 0, MaxPeersInResponse) + + p.log.Debugw("send message", "type", req.Name(), "addr", toAddr) + errc := p.Protocol.SendExpectingReply(toAddr, to.ID(), data, pb.MDiscoveryResponse, func(m interface{}) bool { + res := m.(*pb.DiscoveryResponse) + if !bytes.Equal(res.GetReqHash(), hash) { + return false + } + + for _, rp := range res.GetPeers() { + peer, err := peer.FromProto(rp) + if err != nil { + p.log.Warnw("invalid peer received", "err", err) + continue + } + peers = append(peers, peer) + } + + return true + }) + + // wait for the response and then return peers + return peers, <-errc +} + +// ------ helper functions ------ + +// hasVerified returns whether the given peer has recently verified the local peer. +func (p *Protocol) hasVerified(id peer.ID, addr string) bool { + return time.Since(p.loc.Database().LastPing(id, addr)) < PingExpiration +} + +func marshal(msg pb.Message) []byte { + mType := msg.Type() + if mType > 0xFF { + panic("invalid message") + } + + data, err := proto.Marshal(msg) + if err != nil { + panic("invalid message") + } + return append([]byte{byte(mType)}, data...) +} + +// createDiscoverPeer creates a new peer that only has a peering service at the given address. +func createDiscoverPeer(key peer.PublicKey, network string, address string) *peer.Peer { + services := service.New() + services.Update(service.PeeringKey, network, address) + + return peer.NewPeer(key, services) +} + +// ------ Packet Constructors ------ + +func newPing(fromAddr string, toAddr string) *pb.Ping { + return &pb.Ping{ + Version: VersionNum, + From: fromAddr, + To: toAddr, + Timestamp: time.Now().Unix(), + } +} + +func newPong(toAddr string, reqData []byte, services *service.Record) *pb.Pong { + return &pb.Pong{ + PingHash: server.PacketHash(reqData), + To: toAddr, + Services: services.ToProto(), + } +} + +func newDiscoveryRequest(toAddr string) *pb.DiscoveryRequest { + return &pb.DiscoveryRequest{ + To: toAddr, + Timestamp: time.Now().Unix(), + } +} + +func newDiscoveryResponse(reqData []byte, list []*peer.Peer) *pb.DiscoveryResponse { + peers := make([]*peerpb.Peer, 0, len(list)) + for _, p := range list { + peers = append(peers, p.ToProto()) + } + return &pb.DiscoveryResponse{ + ReqHash: server.PacketHash(reqData), + Peers: peers, + } +} + +// ------ Packet Handlers ------ + +func (p *Protocol) validatePing(s *server.Server, fromAddr string, m *pb.Ping) bool { + // check version number + if m.GetVersion() != VersionNum { + p.log.Debugw("invalid message", + "type", m.Name(), + "version", m.GetVersion(), + "want", VersionNum, + ) + return false + } + // check that From matches the package sender address + if m.GetFrom() != fromAddr { + p.log.Debugw("invalid message", + "type", m.Name(), + "from", m.GetFrom(), + "want", fromAddr, + ) + return false + } + // check that To matches the local address + if m.GetTo() != s.LocalAddr() { + p.log.Debugw("invalid message", + "type", m.Name(), + "to", m.GetTo(), + "want", s.LocalAddr(), + ) + return false + } + // check Timestamp + if p.Protocol.IsExpired(m.GetTimestamp()) { + p.log.Debugw("invalid message", + "type", m.Name(), + "timestamp", time.Unix(m.GetTimestamp(), 0), + ) + return false + } + + p.log.Debugw("valid message", + "type", m.Name(), + "addr", fromAddr, + ) + return true +} + +func (p *Protocol) handlePing(s *server.Server, fromAddr string, fromID peer.ID, fromKey peer.PublicKey, rawData []byte) { + // create and send the pong response + pong := newPong(fromAddr, rawData, s.Local().Services().CreateRecord()) + + p.log.Debugw("send message", + "type", pong.Name(), + "addr", fromAddr, + ) + s.Send(fromAddr, marshal(pong)) + + // if the peer is new or expired, send a ping to verify + if !p.IsVerified(fromID, fromAddr) { + p.sendPing(fromAddr, fromID) + } else if !p.mgr.isKnown(fromID) { // add a discovered peer to the manager if it is new + peer := createDiscoverPeer(fromKey, p.LocalNetwork(), fromAddr) + p.mgr.addDiscoveredPeer(peer) + } + + _ = p.local().Database().UpdateLastPing(fromID, fromAddr, time.Now()) +} + +func (p *Protocol) validatePong(s *server.Server, fromAddr string, fromID peer.ID, m *pb.Pong) bool { + // check that To matches the local address + if m.GetTo() != s.LocalAddr() { + p.log.Debugw("invalid message", + "type", m.Name(), + "to", m.GetTo(), + "want", s.LocalAddr(), + ) + return false + } + // there must be a ping waiting for this pong as a reply + if !s.IsExpectedReply(fromAddr, fromID, m.Type(), m) { + p.log.Debugw("invalid message", + "type", m.Name(), + "unexpected", fromAddr, + ) + return false + } + // there must a valid number of services + numServices := len(m.GetServices().GetMap()) + if numServices <= 0 || numServices > MaxServices { + p.log.Debugw("invalid message", + "type", m.Name(), + "#peers", numServices, + ) + return false + } + + p.log.Debugw("valid message", + "type", m.Name(), + "addr", fromAddr, + ) + return true +} + +func (p *Protocol) handlePong(fromAddr string, fromID peer.ID, fromKey peer.PublicKey, m *pb.Pong) { + services, _ := service.FromProto(m.GetServices()) + peering := services.Get(service.PeeringKey) + if peering == nil || peering.String() != fromAddr { + p.log.Warn("invalid services") + return + } + + // create a proper key with these services + from := peer.NewPeer(fromKey, services) + + // a valid pong verifies the peer + p.mgr.addVerifiedPeer(from) + + // update peer database + db := p.local().Database() + _ = db.UpdateLastPong(fromID, fromAddr, time.Now()) + _ = db.UpdatePeer(from) +} + +func (p *Protocol) validateDiscoveryRequest(s *server.Server, fromAddr string, fromID peer.ID, m *pb.DiscoveryRequest) bool { + // check that To matches the local address + if m.GetTo() != s.LocalAddr() { + p.log.Debugw("invalid message", + "type", m.Name(), + "to", m.GetTo(), + "want", s.LocalAddr(), + ) + return false + } + // check Timestamp + if p.Protocol.IsExpired(m.GetTimestamp()) { + p.log.Debugw("invalid message", + "type", m.Name(), + "timestamp", time.Unix(m.GetTimestamp(), 0), + ) + return false + } + // check whether the sender is verified + if !p.IsVerified(fromID, fromAddr) { + p.log.Debugw("invalid message", + "type", m.Name(), + "unverified", fromAddr, + ) + return false + } + + p.log.Debugw("valid message", + "type", m.Name(), + "addr", fromAddr, + ) + return true +} + +func (p *Protocol) handleDiscoveryRequest(s *server.Server, fromAddr string, rawData []byte) { + // get a random list of verified peers + peers := p.mgr.getRandomPeers(MaxPeersInResponse, 1) + res := newDiscoveryResponse(rawData, peers) + + p.log.Debugw("send message", + "type", res.Name(), + "addr", fromAddr, + ) + s.Send(fromAddr, marshal(res)) +} + +func (p *Protocol) validateDiscoveryResponse(s *server.Server, fromAddr string, fromID peer.ID, m *pb.DiscoveryResponse) bool { + // there must not be too many peers + if len(m.GetPeers()) > MaxPeersInResponse { + p.log.Debugw("invalid message", + "type", m.Name(), + "#peers", len(m.GetPeers()), + ) + return false + } + // there must be a request waiting for this response + if !s.IsExpectedReply(fromAddr, fromID, m.Type(), m) { + p.log.Debugw("invalid message", + "type", m.Name(), + "unexpected", fromAddr, + ) + return false + } + + p.log.Debugw("valid message", + "type", m.Name(), + "addr", fromAddr, + ) + return true +} diff --git a/packages/autopeering/discover/protocol_test.go b/packages/autopeering/discover/protocol_test.go new file mode 100644 index 0000000000..5de6c010b5 --- /dev/null +++ b/packages/autopeering/discover/protocol_test.go @@ -0,0 +1,294 @@ +package discover + +import ( + "log" + "testing" + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/iotaledger/goshimmer/packages/autopeering/server" + "github.com/iotaledger/goshimmer/packages/autopeering/transport" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.uber.org/zap" +) + +const graceTime = 100 * time.Millisecond + +var logger *zap.SugaredLogger + +func init() { + l, err := zap.NewDevelopment() + if err != nil { + log.Fatalf("cannot initialize logger: %v", err) + } + logger = l.Sugar() + + // decrease parameters to simplify and speed up tests + reverifyInterval = 500 * time.Millisecond + queryInterval = 1000 * time.Millisecond + maxManaged = 10 + maxReplacements = 2 +} + +// newTest creates a new discovery server and also returns the teardown. +func newTest(t require.TestingT, trans transport.Transport, logger *zap.SugaredLogger, masters ...*peer.Peer) (*server.Server, *Protocol, func()) { + log := logger.Named(trans.LocalAddr().String()) + db := peer.NewMemoryDB(log.Named("db")) + local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) + require.NoError(t, err) + + cfg := Config{ + Log: log, + MasterPeers: masters, + } + prot := New(local, cfg) + srv := server.Listen(local, trans, log.Named("srv"), prot) + prot.Start(srv) + + teardown := func() { + srv.Close() + prot.Close() + db.Close() + } + return srv, prot, teardown +} + +func getPeer(s *server.Server) *peer.Peer { + return &s.Local().Peer +} + +func TestProtVerifyMaster(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() + + srvA, _, closeA := newTest(t, p2p.A, logger) + defer closeA() + peerA := getPeer(srvA) + + // use peerA as masters peer + _, protB, closeB := newTest(t, p2p.B, logger, peerA) + + time.Sleep(graceTime) // wait for the packages to ripple through the network + closeB() // close srvB to avoid race conditions, when asserting + + if assert.EqualValues(t, 1, len(protB.mgr.active)) { + assert.EqualValues(t, peerA, &protB.mgr.active[0].Peer) + assert.EqualValues(t, 1, protB.mgr.active[0].verifiedCount) + } +} + +func TestProtPingPong(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() + + srvA, protA, closeA := newTest(t, p2p.A, logger) + defer closeA() + srvB, protB, closeB := newTest(t, p2p.B, logger) + defer closeB() + + peerA := getPeer(srvA) + peerB := getPeer(srvB) + + // send a ping from node A to B + t.Run("A->B", func(t *testing.T) { assert.NoError(t, protA.ping(peerB)) }) + time.Sleep(graceTime) + + // send a ping from node B to A + t.Run("B->A", func(t *testing.T) { assert.NoError(t, protB.ping(peerA)) }) + time.Sleep(graceTime) +} + +func TestProtPingTimeout(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() + + _, protA, closeA := newTest(t, p2p.A, logger) + defer closeA() + srvB, _, closeB := newTest(t, p2p.B, logger) + closeB() // close the connection right away to prevent any replies + + peerB := getPeer(srvB) + + // send a ping from node A to B + err := protA.ping(peerB) + assert.EqualError(t, err, server.ErrTimeout.Error()) +} + +func TestProtVerifiedPeers(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() + + _, protA, closeA := newTest(t, p2p.A, logger) + defer closeA() + srvB, _, closeB := newTest(t, p2p.B, logger) + defer closeB() + + peerB := getPeer(srvB) + + // send a ping from node A to B + assert.NoError(t, protA.ping(peerB)) + time.Sleep(graceTime) + + // protA should have peerB as the single verified peer + assert.ElementsMatch(t, []*peer.Peer{peerB}, protA.GetVerifiedPeers()) + for _, p := range protA.GetVerifiedPeers() { + assert.Equal(t, p, protA.GetVerifiedPeer(p.ID(), p.Address())) + } +} + +func TestProtVerifiedPeer(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() + + srvA, protA, closeA := newTest(t, p2p.A, logger) + defer closeA() + srvB, _, closeB := newTest(t, p2p.B, logger) + defer closeB() + + peerA := getPeer(srvA) + peerB := getPeer(srvB) + + // send a ping from node A to B + assert.NoError(t, protA.ping(peerB)) + time.Sleep(graceTime) + + // we should have peerB as a verified peer + assert.Equal(t, peerB, protA.GetVerifiedPeer(peerB.ID(), peerB.Address())) + // we should not have ourself as a verified peer + assert.Nil(t, protA.GetVerifiedPeer(peerA.ID(), peerA.Address())) + // the address of peerB should match + assert.Nil(t, protA.GetVerifiedPeer(peerB.ID(), "")) +} + +func TestProtDiscoveryRequest(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() + + srvA, protA, closeA := newTest(t, p2p.A, logger) + defer closeA() + srvB, protB, closeB := newTest(t, p2p.B, logger) + defer closeB() + + peerA := getPeer(srvA) + peerB := getPeer(srvB) + + // request peers from node A + t.Run("A->B", func(t *testing.T) { + if ps, err := protA.discoveryRequest(peerB); assert.NoError(t, err) { + assert.ElementsMatch(t, []*peer.Peer{peerA}, ps) + } + }) + // request peers from node B + t.Run("B->A", func(t *testing.T) { + if ps, err := protB.discoveryRequest(peerA); assert.NoError(t, err) { + assert.ElementsMatch(t, []*peer.Peer{peerB}, ps) + } + }) +} + +func TestProtServices(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() + + srvA, _, closeA := newTest(t, p2p.A, logger) + defer closeA() + err := srvA.Local().UpdateService(service.FPCKey, "fpc", p2p.A.LocalAddr().String()) + require.NoError(t, err) + + // use peerA as masters peer + _, protB, closeB := newTest(t, p2p.B, logger, getPeer(srvA)) + defer closeB() + + time.Sleep(graceTime) // wait for the packages to ripple through the network + ps := protB.GetVerifiedPeers() + + if assert.ElementsMatch(t, []*peer.Peer{getPeer(srvA)}, ps) { + assert.Equal(t, srvA.Local().Services(), ps[0].Services()) + } +} + +func TestProtDiscovery(t *testing.T) { + net := transport.NewNetwork("M", "A", "B", "C") + defer net.Close() + + srvM, protM, closeM := newTest(t, net.GetTransport("M"), logger) + defer closeM() + time.Sleep(graceTime) // wait for the master to initialize + + srvA, protA, closeA := newTest(t, net.GetTransport("A"), logger, getPeer(srvM)) + defer closeA() + srvB, protB, closeB := newTest(t, net.GetTransport("B"), logger, getPeer(srvM)) + defer closeB() + srvC, protC, closeC := newTest(t, net.GetTransport("C"), logger, getPeer(srvM)) + defer closeC() + + time.Sleep(queryInterval + graceTime) // wait for the next discovery cycle + time.Sleep(reverifyInterval + graceTime) // wait for the next verification cycle + + // now the full network should be discovered + assert.ElementsMatch(t, []*peer.Peer{getPeer(srvA), getPeer(srvB), getPeer(srvC)}, protM.GetVerifiedPeers()) + assert.ElementsMatch(t, []*peer.Peer{getPeer(srvM), getPeer(srvB), getPeer(srvC)}, protA.GetVerifiedPeers()) + assert.ElementsMatch(t, []*peer.Peer{getPeer(srvM), getPeer(srvA), getPeer(srvC)}, protB.GetVerifiedPeers()) + assert.ElementsMatch(t, []*peer.Peer{getPeer(srvM), getPeer(srvA), getPeer(srvB)}, protC.GetVerifiedPeers()) +} + +func BenchmarkPingPong(b *testing.B) { + p2p := transport.P2P() + defer p2p.Close() + log := zap.NewNop().Sugar() // disable logging + + // disable query/reverify + reverifyInterval = time.Hour + queryInterval = time.Hour + + _, protA, closeA := newTest(b, p2p.A, log) + defer closeA() + srvB, _, closeB := newTest(b, p2p.B, log) + defer closeB() + + peerB := getPeer(srvB) + + // send initial ping to ensure that every peer is verified + err := protA.ping(peerB) + require.NoError(b, err) + time.Sleep(graceTime) + + b.ResetTimer() + for n := 0; n < b.N; n++ { + // send a ping from node A to B + _ = protA.ping(peerB) + } + + b.StopTimer() +} + +func BenchmarkDiscoveryRequest(b *testing.B) { + p2p := transport.P2P() + defer p2p.Close() + log := zap.NewNop().Sugar() // disable logging + + // disable query/reverify + reverifyInterval = time.Hour + queryInterval = time.Hour + + _, protA, closeA := newTest(b, p2p.A, log) + defer closeA() + srvB, _, closeB := newTest(b, p2p.B, log) + defer closeB() + + peerB := getPeer(srvB) + + // send initial request to ensure that every peer is verified + _, err := protA.discoveryRequest(peerB) + require.NoError(b, err) + time.Sleep(graceTime) + + b.ResetTimer() + for n := 0; n < b.N; n++ { + _, _ = protA.discoveryRequest(peerB) + } + + b.StopTimer() +} diff --git a/packages/autopeering/discover/query_strat.go b/packages/autopeering/discover/query_strat.go new file mode 100644 index 0000000000..8095473551 --- /dev/null +++ b/packages/autopeering/discover/query_strat.go @@ -0,0 +1,94 @@ +package discover + +import ( + "container/ring" + "math/rand" + "sync" + "time" +) + +// doQuery is the main method of the query strategy. +// It writes the next time this function should be called by the manager to next. +// The current strategy is to always select the latest verified peer and one of +// the peers that returned the most number of peers the last time it was queried. +func (m *manager) doQuery(next chan<- time.Duration) { + defer func() { next <- queryInterval }() + + ps := m.peersToQuery() + if len(ps) == 0 { + return + } + m.log.Debugw("querying", + "#peers", len(ps), + ) + + // request from peers in parallel + var wg sync.WaitGroup + wg.Add(len(ps)) + for _, p := range ps { + go m.requestWorker(p, &wg) + } + wg.Wait() +} + +func (m *manager) requestWorker(p *mpeer, wg *sync.WaitGroup) { + defer wg.Done() + + r, err := m.net.discoveryRequest(unwrapPeer(p)) + if err != nil || len(r) == 0 { + p.lastNewPeers = 0 + + m.log.Debugw("query failed", + "id", p.ID(), + "addr", p.Address(), + "err", err, + ) + return + } + + var added uint + for _, rp := range r { + if m.addDiscoveredPeer(rp) { + added++ + } + } + p.lastNewPeers = added + + m.log.Debugw("queried", + "id", p.ID(), + "addr", p.Address(), + "#added", added, + ) +} + +// peersToQuery selects the peers that should be queried. +func (m *manager) peersToQuery() []*mpeer { + ps := m.getVerifiedPeers() + if len(ps) == 0 { + return nil + } + + latest := ps[0] + if len(ps) == 1 { + return []*mpeer{latest} + } + + // find the 3 heaviest peers + r := ring.New(3) + for i, p := range ps { + if i == 0 { + continue // the latest peer is already included + } + if r.Value == nil { + r.Value = p + } else if p.lastNewPeers >= r.Value.(*mpeer).lastNewPeers { + r = r.Next() + r.Value = p + } + } + + // select a random peer from the heaviest ones + r.Move(rand.Intn(r.Len())) + + return []*mpeer{latest, r.Value.(*mpeer)} +} diff --git a/packages/autopeering/distance/consts.go b/packages/autopeering/distance/consts.go new file mode 100644 index 0000000000..b51f994b12 --- /dev/null +++ b/packages/autopeering/distance/consts.go @@ -0,0 +1,5 @@ +package distance + +const ( + Max = 4294967295 +) diff --git a/packages/autopeering/distance/distance.go b/packages/autopeering/distance/distance.go new file mode 100644 index 0000000000..6a943b1705 --- /dev/null +++ b/packages/autopeering/distance/distance.go @@ -0,0 +1,33 @@ +package distance + +import ( + "crypto/sha256" + "encoding/binary" +) + +// BySalt returns the distance (uint32) between x and y +// by xoring the hash of x and y + salt +// xor(hash(x), hash(y+salt))[:4] +func BySalt(x, y, salt []byte) uint32 { + return xorSHA32(x, joinBytes(y, salt)) +} + +func joinBytes(a, b []byte) (out []byte) { + out = make([]byte, len(a)+len(b)) + copy(out[0:], a) + copy(out[len(a):], b) + return out +} + +func xorSHA32(a, b []byte) uint32 { + return binary.LittleEndian.Uint32( + xorSHA(sha256.Sum256(a), sha256.Sum256(b))[:4]) +} + +func xorSHA(a, b [sha256.Size]byte) (out []byte) { + out = make([]byte, sha256.Size) + for i := 0; i < sha256.Size; i++ { + out[i] = a[i] ^ b[i] + } + return out +} diff --git a/packages/autopeering/distance/distance_test.go b/packages/autopeering/distance/distance_test.go new file mode 100644 index 0000000000..1f92274842 --- /dev/null +++ b/packages/autopeering/distance/distance_test.go @@ -0,0 +1,38 @@ +package distance + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestBySalt(t *testing.T) { + type testCase struct { + x []byte + y []byte + salt []byte + zeroDistance bool + } + + tests := []testCase{ + { + x: []byte("X"), + y: []byte("Y"), + salt: []byte("salt"), + zeroDistance: false, + }, + { + x: []byte("X"), + y: []byte("X"), + salt: []byte{}, + zeroDistance: true, + }, + } + + for _, test := range tests { + d := BySalt(test.x, test.y, test.salt) + got := d == 0 + assert.Equal(t, test.zeroDistance, got, "Zero Distance") + } + +} diff --git a/packages/autopeering/logger/logger.go b/packages/autopeering/logger/logger.go new file mode 100644 index 0000000000..9a14bb0586 --- /dev/null +++ b/packages/autopeering/logger/logger.go @@ -0,0 +1,60 @@ +package logger + +import ( + "encoding/json" + "fmt" + + "go.uber.org/zap" + "go.uber.org/zap/zapcore" +) + +// NewLogger creates a logger with the supplied configuration. +func NewLogger(configJSON string, levelOverride string, opts ...zap.Option) *zap.SugaredLogger { + var loggingCfg zap.Config + if err := json.Unmarshal([]byte(configJSON), &loggingCfg); err != nil { + return newFallbackLogger(err, levelOverride, opts...) + } + if len(levelOverride) > 0 { + if level, err := levelFromString(levelOverride); err == nil { + loggingCfg.Level = zap.NewAtomicLevelAt(*level) + } + } + + logger, err := loggingCfg.Build(opts...) + if err != nil { + return newFallbackLogger(err, levelOverride, opts...) + } + + logger.Info("Successfully created the logger.") + logger.Sugar().Infof("Logging level set to %v", loggingCfg.Level) + + return logger.Sugar() +} + +func levelFromString(level string) (*zapcore.Level, error) { + var zapLevel zapcore.Level + if err := zapLevel.UnmarshalText([]byte(level)); err != nil { + return nil, fmt.Errorf("invalid logging level: %v", level) + } + return &zapLevel, nil +} + +func newFallbackLogger(cause error, levelOverride string, opts ...zap.Option) *zap.SugaredLogger { + loggingCfg := zap.NewProductionConfig() + if len(levelOverride) > 0 { + if level, err := levelFromString(levelOverride); err == nil { + loggingCfg.Level = zap.NewAtomicLevelAt(*level) + } + } + + logger, err := loggingCfg.Build(opts...) + if err != nil { + panic(err) + } + logger = logger.Named("fallback-logger") + + logger.Warn("Failed to create logger, using fallback:", zap.Error(cause)) + logger.Sugar().Infof("Logging level set to %v", loggingCfg.Level) + + return logger.Sugar() +} diff --git a/packages/autopeering/peer/id.go b/packages/autopeering/peer/id.go new file mode 100644 index 0000000000..7365c4332f --- /dev/null +++ b/packages/autopeering/peer/id.go @@ -0,0 +1,40 @@ +package peer + +import ( + "crypto/sha256" + "encoding/hex" + "fmt" + "strings" +) + +// ID is a unique identifier for each peer. +type ID [sha256.Size]byte + +// Bytes returns the byte slice representation of the ID +func (id ID) Bytes() []byte { + return id[:] +} + +// String returns a shortened version of the ID as a hex encoded string. +func (id ID) String() string { + return hex.EncodeToString(id[:8]) +} + +// ParseID parses a hex encoded ID. +func ParseID(s string) (ID, error) { + var id ID + b, err := hex.DecodeString(strings.TrimPrefix(s, "0x")) + if err != nil { + return id, err + } + if len(b) != len(ID{}) { + return id, fmt.Errorf("invalid length: need %d hex chars", hex.EncodedLen(len(ID{}))) + } + copy(id[:], b) + return id, nil +} + +// ID computes the ID corresponding to the given public key. +func (k PublicKey) ID() ID { + return sha256.Sum256(k) +} diff --git a/packages/autopeering/peer/local.go b/packages/autopeering/peer/local.go new file mode 100644 index 0000000000..65638ae185 --- /dev/null +++ b/packages/autopeering/peer/local.go @@ -0,0 +1,129 @@ +package peer + +import ( + "crypto/ed25519" + "fmt" + "sync" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/iotaledger/goshimmer/packages/autopeering/salt" +) + +// Local defines the struct of a local peer +type Local struct { + Peer + key PrivateKey + db DB + + // everything below is protected by a lock + mu sync.RWMutex + serviceRecord *service.Record + publicSalt *salt.Salt + privateSalt *salt.Salt +} + +// PrivateKey is the type of Ed25519 private keys used for the local peer. +type PrivateKey ed25519.PrivateKey + +// Public returns the PublicKey corresponding to priv. +func (priv PrivateKey) Public() PublicKey { + publicKey := ed25519.PrivateKey(priv).Public() + return PublicKey(publicKey.(ed25519.PublicKey)) +} + +// newLocal creates a new local peer. +func newLocal(key PrivateKey, serviceRecord *service.Record, db DB) *Local { + return &Local{ + Peer: *NewPeer(key.Public(), serviceRecord), + key: key, + db: db, + serviceRecord: serviceRecord, + } +} + +// NewLocal creates a new local peer linked to the provided db. +func NewLocal(network string, address string, db DB) (*Local, error) { + key, err := db.LocalPrivateKey() + if err != nil { + return nil, err + } + if l := len(key); l != ed25519.PrivateKeySize { + return nil, fmt.Errorf("invalid key length: %d, need %d", l, ed25519.PublicKeySize) + } + services, err := db.LocalServices() + if err != nil { + return nil, err + } + serviceRecord := services.CreateRecord() + + // update the external address used for the peering and store back in DB + serviceRecord.Update(service.PeeringKey, network, address) + err = db.UpdateLocalServices(serviceRecord) + if err != nil { + return nil, err + } + + return newLocal(key, serviceRecord, db), nil +} + +// Database returns the node database associated with the local peer. +func (l *Local) Database() DB { + return l.db +} + +// Sign signs the message with the local peer's private key and returns a signature. +func (l *Local) Sign(message []byte) []byte { + return ed25519.Sign(ed25519.PrivateKey(l.key), message) +} + +// UpdateService updates the endpoint address of the given local service. +func (l *Local) UpdateService(key service.Key, network string, address string) error { + l.mu.Lock() + defer l.mu.Unlock() + + // update the service in the read protected map and store back in DB + l.serviceRecord.Update(key, network, address) + err := l.db.UpdateLocalServices(l.serviceRecord) + if err != nil { + return err + } + + // create a new peer with the corresponding services + l.Peer = *NewPeer(l.key.Public(), l.serviceRecord) + + return nil +} + +// GetPublicSalt returns the public salt +func (l *Local) GetPublicSalt() *salt.Salt { + l.mu.RLock() + defer l.mu.RUnlock() + return l.publicSalt +} + +// SetPublicSalt sets the public salt +func (l *Local) SetPublicSalt(salt *salt.Salt) { + l.mu.Lock() + defer l.mu.Unlock() + l.publicSalt = salt +} + +// GetPrivateSalt returns the private salt +func (l *Local) GetPrivateSalt() *salt.Salt { + l.mu.RLock() + defer l.mu.RUnlock() + return l.privateSalt +} + +// SetPrivateSalt sets the private salt +func (l *Local) SetPrivateSalt(salt *salt.Salt) { + l.mu.Lock() + defer l.mu.Unlock() + l.privateSalt = salt +} + +// generatePrivateKey generates a private key that can be used for Local. +func generatePrivateKey() (PrivateKey, error) { + _, priv, err := ed25519.GenerateKey(nil) + return PrivateKey(priv), err +} diff --git a/packages/autopeering/peer/local_test.go b/packages/autopeering/peer/local_test.go new file mode 100644 index 0000000000..aa50862c1a --- /dev/null +++ b/packages/autopeering/peer/local_test.go @@ -0,0 +1,63 @@ +package peer + +import ( + "crypto/ed25519" + "testing" + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/iotaledger/goshimmer/packages/autopeering/salt" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestID(t *testing.T) { + pub, priv, err := ed25519.GenerateKey(nil) + require.NoError(t, err) + + local := newLocal(PrivateKey(priv), newTestServiceRecord(), nil) + id := PublicKey(pub).ID() + assert.Equal(t, id, local.ID()) +} + +func TestPublicKey(t *testing.T) { + pub, priv, err := ed25519.GenerateKey(nil) + require.NoError(t, err) + + local := newLocal(PrivateKey(priv), newTestServiceRecord(), nil) + assert.EqualValues(t, pub, local.PublicKey()) +} + +func newTestLocal(t require.TestingT) *Local { + priv, err := generatePrivateKey() + require.NoError(t, err) + return newLocal(priv, newTestServiceRecord(), nil) +} + +func TestAddress(t *testing.T) { + local := newTestLocal(t) + + address := local.Services().Get(service.PeeringKey).String() + assert.EqualValues(t, address, local.Address()) +} + +func TestPrivateSalt(t *testing.T) { + p := newTestLocal(t) + + salt, _ := salt.NewSalt(time.Second * 10) + p.SetPrivateSalt(salt) + + got := p.GetPrivateSalt() + assert.Equal(t, salt, got, "Private salt") +} + +func TestPublicSalt(t *testing.T) { + p := newTestLocal(t) + + salt, _ := salt.NewSalt(time.Second * 10) + p.SetPublicSalt(salt) + + got := p.GetPublicSalt() + + assert.Equal(t, salt, got, "Public salt") +} diff --git a/packages/autopeering/peer/mapdb.go b/packages/autopeering/peer/mapdb.go new file mode 100644 index 0000000000..548830f3a9 --- /dev/null +++ b/packages/autopeering/peer/mapdb.go @@ -0,0 +1,233 @@ +package peer + +import ( + "sync" + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "go.uber.org/zap" +) + +// mapDB is a simple implementation of DB using a map. +type mapDB struct { + mutex sync.RWMutex + m map[string]peerEntry + key PrivateKey + services *service.Record + + log *zap.SugaredLogger + + wg sync.WaitGroup + closeOnce sync.Once + closing chan struct{} +} + +type peerEntry struct { + data []byte + properties map[string]peerPropEntry +} + +type peerPropEntry struct { + lastPing, lastPong int64 +} + +// NewMemoryDB creates a new DB that uses a GO map. +func NewMemoryDB(log *zap.SugaredLogger) DB { + db := &mapDB{ + m: make(map[string]peerEntry), + services: service.New(), + log: log, + closing: make(chan struct{}), + } + + // start the expirer routine + db.wg.Add(1) + go db.expirer() + + return db +} + +// Close closes the DB. +func (db *mapDB) Close() { + db.closeOnce.Do(func() { + db.log.Debugf("closing") + close(db.closing) + db.wg.Wait() + }) +} + +// LocalPrivateKey returns the private key stored in the database or creates a new one. +func (db *mapDB) LocalPrivateKey() (PrivateKey, error) { + db.mutex.Lock() + defer db.mutex.Unlock() + + if db.key == nil { + key, err := generatePrivateKey() + db.key = key + return key, err + } + + return db.key, nil +} + +// LocalServices returns the services stored in the database or creates an empty map. +func (db *mapDB) LocalServices() (service.Service, error) { + db.mutex.RLock() + defer db.mutex.RUnlock() + + return db.services, nil +} + +// UpdateLocalServices updates the services stored in the database. +func (db *mapDB) UpdateLocalServices(services service.Service) error { + db.mutex.Lock() + db.services = services.CreateRecord() + db.mutex.Unlock() + + return nil +} + +// LastPing returns that property for the given peer ID and address. +func (db *mapDB) LastPing(id ID, address string) time.Time { + db.mutex.RLock() + peerEntry := db.m[string(id.Bytes())] + db.mutex.RUnlock() + + return time.Unix(peerEntry.properties[address].lastPing, 0) +} + +// UpdateLastPing updates that property for the given peer ID and address. +func (db *mapDB) UpdateLastPing(id ID, address string, t time.Time) error { + key := string(id.Bytes()) + + db.mutex.Lock() + peerEntry := db.m[key] + if peerEntry.properties == nil { + peerEntry.properties = make(map[string]peerPropEntry) + } + entry := peerEntry.properties[address] + entry.lastPing = t.Unix() + peerEntry.properties[address] = entry + db.m[key] = peerEntry + db.mutex.Unlock() + + return nil +} + +// LastPong returns that property for the given peer ID and address. +func (db *mapDB) LastPong(id ID, address string) time.Time { + db.mutex.RLock() + peerEntry := db.m[string(id.Bytes())] + db.mutex.RUnlock() + + return time.Unix(peerEntry.properties[address].lastPong, 0) +} + +// UpdateLastPong updates that property for the given peer ID and address. +func (db *mapDB) UpdateLastPong(id ID, address string, t time.Time) error { + key := string(id.Bytes()) + + db.mutex.Lock() + peerEntry := db.m[key] + if peerEntry.properties == nil { + peerEntry.properties = make(map[string]peerPropEntry) + } + entry := peerEntry.properties[address] + entry.lastPong = t.Unix() + peerEntry.properties[address] = entry + db.m[key] = peerEntry + db.mutex.Unlock() + + return nil +} + +// UpdatePeer updates a peer in the database. +func (db *mapDB) UpdatePeer(p *Peer) error { + data, err := p.Marshal() + if err != nil { + return err + } + key := string(p.ID().Bytes()) + + db.mutex.Lock() + peerEntry := db.m[key] + peerEntry.data = data + db.m[key] = peerEntry + db.mutex.Unlock() + + return nil +} + +// Peer retrieves a peer from the database. +func (db *mapDB) Peer(id ID) *Peer { + db.mutex.RLock() + peerEntry := db.m[string(id.Bytes())] + db.mutex.RUnlock() + + if peerEntry.data == nil { + return nil + } + return parsePeer(peerEntry.data) +} + +// SeedPeers retrieves random nodes to be used as potential bootstrap peers. +func (db *mapDB) SeedPeers() []*Peer { + peers := make([]*Peer, 0) + now := time.Now() + + db.mutex.RLock() + for id, peerEntry := range db.m { + p := parsePeer(peerEntry.data) + if p == nil || id != string(p.ID().Bytes()) { + continue + } + if now.Sub(db.LastPong(p.ID(), p.Address())) > seedExpiration { + continue + } + + peers = append(peers, p) + } + db.mutex.RUnlock() + + return randomSubset(peers, seedCount) +} + +func (db *mapDB) expirer() { + defer db.wg.Done() + + // the expiring isn't triggert right away, to give the bootstrapping the chance to use older nodes + tick := time.NewTicker(cleanupInterval) + defer tick.Stop() + + for { + select { + case <-tick.C: + db.expirePeers() + case <-db.closing: + return + } + } +} + +func (db *mapDB) expirePeers() { + var ( + threshold = time.Now().Add(-peerExpiration).Unix() + count int + ) + + db.mutex.Lock() + for id, peerEntry := range db.m { + for address, peerPropEntry := range peerEntry.properties { + if peerPropEntry.lastPong <= threshold { + delete(peerEntry.properties, address) + } + } + if len(peerEntry.properties) == 0 { + delete(db.m, id) + count++ + } + } + db.mutex.Unlock() + + db.log.Debugw("expired peers", "count", count) +} diff --git a/packages/autopeering/peer/mapdb_test.go b/packages/autopeering/peer/mapdb_test.go new file mode 100644 index 0000000000..516d735165 --- /dev/null +++ b/packages/autopeering/peer/mapdb_test.go @@ -0,0 +1,78 @@ +package peer + +import ( + "crypto/ed25519" + "log" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.uber.org/zap" +) + +var logger *zap.SugaredLogger + +func init() { + l, err := zap.NewDevelopment() + if err != nil { + log.Fatalf("cannot initialize logger: %v", err) + } + logger = l.Sugar() +} + +func TestMapDBPing(t *testing.T) { + p := newTestPeer() + db := NewMemoryDB(logger) + + time := time.Now() + err := db.UpdateLastPing(p.ID(), p.Address(), time) + require.NoError(t, err) + + assert.Equal(t, time.Unix(), db.LastPing(p.ID(), p.Address()).Unix()) +} + +func TestMapDBPong(t *testing.T) { + p := newTestPeer() + db := NewMemoryDB(logger) + + time := time.Now() + err := db.UpdateLastPong(p.ID(), p.Address(), time) + require.NoError(t, err) + + assert.Equal(t, time.Unix(), db.LastPong(p.ID(), p.Address()).Unix()) +} + +func TestMapDBPeer(t *testing.T) { + p := newTestPeer() + db := NewMemoryDB(logger) + + err := db.UpdatePeer(p) + require.NoError(t, err) + + assert.Equal(t, p, db.Peer(p.ID())) +} + +func TestMapDBSeedPeers(t *testing.T) { + p := newTestPeer() + db := NewMemoryDB(logger) + + require.NoError(t, db.UpdatePeer(p)) + require.NoError(t, db.UpdateLastPong(p.ID(), p.Address(), time.Now())) + + peers := db.SeedPeers() + assert.ElementsMatch(t, []*Peer{p}, peers) +} + +func TestMapDBLocal(t *testing.T) { + db := NewMemoryDB(logger) + + l1, err := NewLocal(testNetwork, testAddress, db) + require.NoError(t, err) + assert.Equal(t, len(l1.PublicKey()), ed25519.PublicKeySize) + + l2, err := NewLocal(testNetwork, testAddress, db) + require.NoError(t, err) + + assert.Equal(t, l1, l2) +} diff --git a/packages/autopeering/peer/peer.go b/packages/autopeering/peer/peer.go new file mode 100644 index 0000000000..c7200dd1bb --- /dev/null +++ b/packages/autopeering/peer/peer.go @@ -0,0 +1,136 @@ +package peer + +import ( + "crypto/ed25519" + "errors" + "fmt" + "net/url" + + "github.com/golang/protobuf/proto" + pb "github.com/iotaledger/goshimmer/packages/autopeering/peer/proto" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" +) + +// PublicKey is the type of Ed25519 public keys used for peers. +type PublicKey ed25519.PublicKey + +// Peer defines the immutable data of a peer. +type Peer struct { + id ID // comparable node identifier + publicKey PublicKey // public key used to verify signatures + services *service.Record // unmodifiable services supported by the peer +} + +// ID returns the identifier of the peer. +func (p *Peer) ID() ID { + return p.id +} + +// PublicKey returns the public key of the peer. +func (p *Peer) PublicKey() PublicKey { + return p.publicKey +} + +// Network returns the autopeering network of the peer. +func (p *Peer) Network() string { + return p.services.Get(service.PeeringKey).Network() +} + +// Address returns the autopeering address of a peer. +func (p *Peer) Address() string { + return p.services.Get(service.PeeringKey).String() +} + +// Services returns the supported services of the peer. +func (p *Peer) Services() service.Service { + return p.services +} + +// String returns a string representation of the peer. +func (p *Peer) String() string { + u := url.URL{ + Scheme: "peer", + User: url.User(fmt.Sprintf("%x", p.publicKey)), + Host: p.Address(), + } + return u.String() +} + +// SignedData is an interface wrapper around data with key and signature. +type SignedData interface { + GetData() []byte + GetPublicKey() []byte + GetSignature() []byte +} + +// RecoverKeyFromSignedData validates and returns the key that was used to sign the data. +func RecoverKeyFromSignedData(m SignedData) (PublicKey, error) { + return recoverKey(m.GetPublicKey(), m.GetData(), m.GetSignature()) +} + +// NewPeer creates a new unmodifiable peer. +func NewPeer(publicKey PublicKey, services service.Service) *Peer { + if services.Get(service.PeeringKey) == nil { + panic("need peering service") + } + + return &Peer{ + id: publicKey.ID(), + publicKey: publicKey, + services: services.CreateRecord(), + } +} + +// ToProto encodes a given peer into a proto buffer Peer message +func (p *Peer) ToProto() *pb.Peer { + return &pb.Peer{ + PublicKey: p.publicKey, + Services: p.services.ToProto(), + } +} + +// FromProto decodes a given proto buffer Peer message (in) and returns the corresponding Peer. +func FromProto(in *pb.Peer) (*Peer, error) { + if l := len(in.GetPublicKey()); l != ed25519.PublicKeySize { + return nil, fmt.Errorf("invalid key length: %d, need %d", l, ed25519.PublicKeySize) + } + services, err := service.FromProto(in.GetServices()) + if err != nil { + return nil, err + } + if services.Get(service.PeeringKey) == nil { + return nil, errors.New("need peering service") + } + + return NewPeer(in.GetPublicKey(), services), nil +} + +// Marshal serializes a given Peer (p) into a slice of bytes. +func (p *Peer) Marshal() ([]byte, error) { + return proto.Marshal(p.ToProto()) +} + +// Unmarshal de-serializes a given slice of bytes (data) into a Peer. +func Unmarshal(data []byte) (*Peer, error) { + s := &pb.Peer{} + if err := proto.Unmarshal(data, s); err != nil { + return nil, err + } + return FromProto(s) +} + +func recoverKey(key, data, sig []byte) (PublicKey, error) { + if l := len(key); l != ed25519.PublicKeySize { + return nil, fmt.Errorf("invalid key length: %d, need %d", l, ed25519.PublicKeySize) + } + if l := len(sig); l != ed25519.SignatureSize { + return nil, fmt.Errorf("invalid signature length: %d, need %d", l, ed25519.SignatureSize) + } + if !ed25519.Verify(key, data, sig) { + return nil, errors.New("invalid signature") + } + + publicKey := make([]byte, ed25519.PublicKeySize) + copy(publicKey, key) + return publicKey, nil +} diff --git a/packages/autopeering/peer/peer_test.go b/packages/autopeering/peer/peer_test.go new file mode 100644 index 0000000000..77d59125bb --- /dev/null +++ b/packages/autopeering/peer/peer_test.go @@ -0,0 +1,81 @@ +package peer + +import ( + "crypto/ed25519" + "testing" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +const ( + testNetwork = "udp" + testAddress = "127.0.0.1:8000" + testMessage = "Hello World!" +) + +func newTestServiceRecord() *service.Record { + services := service.New() + services.Update(service.PeeringKey, testNetwork, testAddress) + + return services +} + +func newTestPeer() *Peer { + key := make([]byte, ed25519.PublicKeySize) + return NewPeer(key, newTestServiceRecord()) +} + +func TestNoServicePeer(t *testing.T) { + key := make([]byte, ed25519.PublicKeySize) + services := service.New() + + assert.Panics(t, func() { + _ = NewPeer(key, services) + }) +} + +func TestInvalidServicePeer(t *testing.T) { + key := make([]byte, ed25519.PublicKeySize) + services := service.New() + services.Update(service.FPCKey, "network", "address") + + assert.Panics(t, func() { + _ = NewPeer(key, services) + }) +} + +func TestMarshalUnmarshal(t *testing.T) { + p := newTestPeer() + data, err := p.Marshal() + require.NoError(t, err) + + got, err := Unmarshal(data) + require.NoError(t, err) + + assert.Equal(t, p, got) +} + +func TestRecoverKeyFromSignedData(t *testing.T) { + msg := []byte(testMessage) + + pub, priv, err := ed25519.GenerateKey(nil) + require.NoError(t, err) + + sig := ed25519.Sign(priv, msg) + + d := signedData{pub: pub, msg: msg, sig: sig} + key, err := RecoverKeyFromSignedData(d) + require.NoError(t, err) + + assert.Equal(t, PublicKey(pub).ID(), key.ID()) +} + +type signedData struct { + pub, msg, sig []byte +} + +func (d signedData) GetPublicKey() []byte { return d.pub } +func (d signedData) GetData() []byte { return d.msg } +func (d signedData) GetSignature() []byte { return d.sig } diff --git a/packages/autopeering/peer/peerdb.go b/packages/autopeering/peer/peerdb.go new file mode 100644 index 0000000000..3947f3afb1 --- /dev/null +++ b/packages/autopeering/peer/peerdb.go @@ -0,0 +1,319 @@ +package peer + +import ( + "bytes" + "encoding/binary" + "math/rand" + "sync" + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/iotaledger/goshimmer/packages/database" + "go.uber.org/zap" +) + +const ( + // remove peers from DB, when the last received ping was older than this + peerExpiration = 24 * time.Hour + // interval in which expired peers are checked + cleanupInterval = time.Hour + + // number of peers used for bootstrapping + seedCount = 10 + // time after which potential seed peers should expire + seedExpiration = 5 * 24 * time.Hour +) + +// DB is the peer database, storing previously seen peers and any collected +// properties of them. +type DB interface { + // LocalPrivateKey returns the private key stored in the database or creates a new one. + LocalPrivateKey() (PrivateKey, error) + // LocalServices returns the services stored in the database or creates an empty services. + LocalServices() (service.Service, error) + // UpdateLocalServices updates the services stored in the database. + UpdateLocalServices(services service.Service) error + + // Peer retrieves a peer from the database. + Peer(id ID) *Peer + // UpdatePeer updates a peer in the database. + UpdatePeer(p *Peer) error + // SeedPeers retrieves random nodes to be used as potential bootstrap peers. + SeedPeers() []*Peer + + // LastPing returns that property for the given peer ID and address. + LastPing(id ID, address string) time.Time + // UpdateLastPing updates that property for the given peer ID and address. + UpdateLastPing(id ID, address string, t time.Time) error + + // LastPong returns that property for the given peer ID and address. + LastPong(id ID, address string) time.Time + // UpdateLastPong updates that property for the given peer ID and address. + UpdateLastPong(id ID, address string, t time.Time) error + + // Close closes the DB. + Close() +} + +type persistentDB struct { + db database.Database + log *zap.SugaredLogger + + closeOnce sync.Once +} + +// Keys in the node database. +const ( + dbNodePrefix = "n:" // Identifier to prefix node entries with + dbLocalPrefix = "local:" // Identifier to prefix local entries + + // These fields are stored per ID and address. Use nodeFieldKey to create those keys. + dbNodePing = "lastping" + dbNodePong = "lastpong" + + // Local information is keyed by ID only. Use localFieldKey to create those keys. + dbLocalKey = "key" + dbLocalServices = "services" +) + +// NewPersistentDB creates a new persistent DB. +func NewPersistentDB(log *zap.SugaredLogger) DB { + db, err := database.Get("peer") + if err != nil { + panic(err) + } + + pDB := &persistentDB{ + db: db, + log: log, + } + pDB.start() + + return pDB +} + +// Close closes the DB. +func (db *persistentDB) Close() { + db.closeOnce.Do(func() { + db.persistSeeds() + }) +} + +func (db *persistentDB) start() { + // get all peers in the DB + peers := db.getPeers(0) + + for _, p := range peers { + // if they dont have an associated pong, give them a grace period + if db.LastPong(p.ID(), p.Address()).Unix() == 0 { + err := db.setPeerWithTTL(p, cleanupInterval) + if err != nil { + db.log.Warnw("database error", "err", err) + } + } + } +} + +// persistSeeds assures that potential bootstrap peers are not garbage collected. +func (db *persistentDB) persistSeeds() { + // randomly select potential bootstrap peers + peers := randomSubset(db.getPeers(peerExpiration), seedCount) + + for _, p := range peers { + err := db.setPeerWithTTL(p, seedExpiration) + if err != nil { + db.log.Warnw("database error", "err", err) + } + } + db.log.Infof("%d bootstrap peers remain in DB", len(peers)) +} + +// nodeKey returns the database key for a node record. +func nodeKey(id ID) []byte { + return append([]byte(dbNodePrefix), id.Bytes()...) +} + +func splitNodeKey(key []byte) (id ID, rest []byte) { + if !bytes.HasPrefix(key, []byte(dbNodePrefix)) { + return ID{}, nil + } + item := key[len(dbNodePrefix):] + copy(id[:], item[:len(id)]) + return id, item[len(id):] +} + +// nodeFieldKey returns the database key for a node metadata field. +func nodeFieldKey(id ID, address string, field string) []byte { + return bytes.Join([][]byte{nodeKey(id), []byte(address), []byte(field)}, []byte{':'}) +} + +func localFieldKey(field string) []byte { + return append([]byte(dbLocalPrefix), []byte(field)...) +} + +func parseInt64(blob []byte) int64 { + val, read := binary.Varint(blob) + if read <= 0 { + return 0 + } + return val +} + +// getInt64 retrieves an integer associated with a particular key. +func (db *persistentDB) getInt64(key []byte) int64 { + blob, err := db.db.Get(key) + if err != nil { + return 0 + } + return parseInt64(blob) +} + +// setInt64 stores an integer in the given key. +func (db *persistentDB) setInt64(key []byte, n int64) error { + blob := make([]byte, binary.MaxVarintLen64) + blob = blob[:binary.PutVarint(blob, n)] + return db.db.SetWithTTL(key, blob, peerExpiration) +} + +// LocalPrivateKey returns the private key stored in the database or creates a new one. +func (db *persistentDB) LocalPrivateKey() (PrivateKey, error) { + key, err := db.db.Get(localFieldKey(dbLocalKey)) + if err == database.ErrKeyNotFound { + key, err = generatePrivateKey() + if err == nil { + err = db.db.Set(localFieldKey(dbLocalKey), key) + } + return key, err + } + if err != nil { + return nil, err + } + + return key, nil +} + +// LocalServices returns the services stored in the database or creates an empty services. +func (db *persistentDB) LocalServices() (service.Service, error) { + key, err := db.db.Get(localFieldKey(dbLocalServices)) + if err == database.ErrKeyNotFound { + return service.New(), nil + } + if err != nil { + return nil, err + } + + services, err := service.Unmarshal(key) + if err != nil { + return nil, err + } + + return services, nil +} + +// UpdateLocalServices updates the services stored in the database. +func (db *persistentDB) UpdateLocalServices(services service.Service) error { + value, err := services.CreateRecord().CreateRecord().Marshal() + if err != nil { + return err + } + return db.db.Set(localFieldKey(dbLocalServices), value) +} + +// LastPing returns that property for the given peer ID and address. +func (db *persistentDB) LastPing(id ID, address string) time.Time { + return time.Unix(db.getInt64(nodeFieldKey(id, address, dbNodePing)), 0) +} + +// UpdateLastPing updates that property for the given peer ID and address. +func (db *persistentDB) UpdateLastPing(id ID, address string, t time.Time) error { + return db.setInt64(nodeFieldKey(id, address, dbNodePing), t.Unix()) +} + +// LastPing returns that property for the given peer ID and address. +func (db *persistentDB) LastPong(id ID, address string) time.Time { + return time.Unix(db.getInt64(nodeFieldKey(id, address, dbNodePong)), 0) +} + +// UpdateLastPing updates that property for the given peer ID and address. +func (db *persistentDB) UpdateLastPong(id ID, address string, t time.Time) error { + return db.setInt64(nodeFieldKey(id, address, dbNodePong), t.Unix()) +} + +func (db *persistentDB) setPeerWithTTL(p *Peer, ttl time.Duration) error { + data, err := p.Marshal() + if err != nil { + return err + } + return db.db.SetWithTTL(nodeKey(p.ID()), data, ttl) +} + +func (db *persistentDB) UpdatePeer(p *Peer) error { + return db.setPeerWithTTL(p, peerExpiration) +} + +func parsePeer(data []byte) *Peer { + p, err := Unmarshal(data) + if err != nil { + return nil + } + return p +} + +func (db *persistentDB) Peer(id ID) *Peer { + data, err := db.db.Get(nodeKey(id)) + if err != nil { + return nil + } + return parsePeer(data) +} + +func randomSubset(peers []*Peer, m int) []*Peer { + if len(peers) <= m { + return peers + } + + result := make([]*Peer, 0, m) + for i, p := range peers { + if rand.Intn(len(peers)-i) < m-len(result) { + result = append(result, p) + } + } + return result +} + +func (db *persistentDB) getPeers(maxAge time.Duration) []*Peer { + peers := make([]*Peer, 0) + now := time.Now() + + err := db.db.ForEachWithPrefix([]byte(dbNodePrefix), func(key []byte, value []byte) { + id, rest := splitNodeKey(key) + if len(rest) > 0 { + return + } + + p := parsePeer(value) + if p == nil || p.ID() != id { + return + } + if maxAge > 0 && now.Sub(db.LastPong(p.ID(), p.Address())) > maxAge { + return + } + + peers = append(peers, p) + }) + if err != nil { + return []*Peer{} + } + return peers +} + +// SeedPeers retrieves random nodes to be used as potential bootstrap peers. +func (db *persistentDB) SeedPeers() []*Peer { + // get all stored peers and select subset + peers := db.getPeers(0) + + seeds := randomSubset(peers, seedCount) + db.log.Infof("%d potential bootstrap peers restored form DB", len(seeds)) + + return seeds +} diff --git a/packages/autopeering/peer/proto/peer.pb.go b/packages/autopeering/peer/proto/peer.pb.go new file mode 100644 index 0000000000..471070ffc2 --- /dev/null +++ b/packages/autopeering/peer/proto/peer.pb.go @@ -0,0 +1,94 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: peer/proto/peer.proto + +package proto + +import ( + fmt "fmt" + math "math" + + proto "github.com/golang/protobuf/proto" + proto1 "github.com/iotaledger/goshimmer/packages/autopeering/peer/service/proto" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// 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 + +// Minimal encoding of a peer +type Peer struct { + // public key used for signing + PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + // services supported by the peer + Services *proto1.ServiceMap `protobuf:"bytes,2,opt,name=services,proto3" json:"services,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Peer) Reset() { *m = Peer{} } +func (m *Peer) String() string { return proto.CompactTextString(m) } +func (*Peer) ProtoMessage() {} +func (*Peer) Descriptor() ([]byte, []int) { + return fileDescriptor_155860cd2f47eba7, []int{0} +} + +func (m *Peer) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Peer.Unmarshal(m, b) +} +func (m *Peer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Peer.Marshal(b, m, deterministic) +} +func (m *Peer) XXX_Merge(src proto.Message) { + xxx_messageInfo_Peer.Merge(m, src) +} +func (m *Peer) XXX_Size() int { + return xxx_messageInfo_Peer.Size(m) +} +func (m *Peer) XXX_DiscardUnknown() { + xxx_messageInfo_Peer.DiscardUnknown(m) +} + +var xxx_messageInfo_Peer proto.InternalMessageInfo + +func (m *Peer) GetPublicKey() []byte { + if m != nil { + return m.PublicKey + } + return nil +} + +func (m *Peer) GetServices() *proto1.ServiceMap { + if m != nil { + return m.Services + } + return nil +} + +func init() { + proto.RegisterType((*Peer)(nil), "proto.Peer") +} + +func init() { proto.RegisterFile("peer/proto/peer.proto", fileDescriptor_155860cd2f47eba7) } + +var fileDescriptor_155860cd2f47eba7 = []byte{ + // 168 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x48, 0x4d, 0x2d, + 0xd2, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x07, 0x31, 0xf5, 0xc0, 0x4c, 0x21, 0x56, 0x30, 0x25, + 0xa5, 0x00, 0x96, 0x2d, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0x85, 0xaa, 0x82, 0xf2, 0x20, 0x0a, + 0x95, 0x42, 0xb8, 0x58, 0x02, 0x80, 0x6a, 0x84, 0x64, 0xb9, 0xb8, 0x0a, 0x4a, 0x93, 0x72, 0x32, + 0x93, 0xe3, 0xb3, 0x53, 0x2b, 0x25, 0x18, 0x15, 0x18, 0x35, 0x78, 0x82, 0x38, 0x21, 0x22, 0xde, + 0xa9, 0x95, 0x42, 0xba, 0x5c, 0x1c, 0x50, 0x7d, 0xc5, 0x12, 0x4c, 0x40, 0x49, 0x6e, 0x23, 0x41, + 0x88, 0x01, 0x7a, 0xc1, 0x10, 0x61, 0xdf, 0xc4, 0x82, 0x20, 0xb8, 0x12, 0x27, 0xa3, 0x28, 0x83, + 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xcc, 0xfc, 0x92, 0xc4, 0x9c, + 0xd4, 0x94, 0x74, 0xa0, 0x53, 0x12, 0x4b, 0x4b, 0xf2, 0x41, 0x6e, 0xca, 0xcc, 0x4b, 0xd7, 0x2d, + 0xce, 0xcc, 0xd5, 0x47, 0xb8, 0x3e, 0x89, 0x0d, 0x4c, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, + 0x8e, 0xb0, 0x04, 0x1f, 0xd2, 0x00, 0x00, 0x00, +} diff --git a/packages/autopeering/peer/proto/peer.proto b/packages/autopeering/peer/proto/peer.proto new file mode 100644 index 0000000000..16327b26cf --- /dev/null +++ b/packages/autopeering/peer/proto/peer.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; + +option go_package = "github.com/iotaledger/goshimmer/packages/autopeering/peer/proto"; + +package proto; + +import "peer/service/proto/service.proto"; + +// Minimal encoding of a peer +message Peer { + // public key used for signing + bytes public_key = 1; + // services supported by the peer + ServiceMap services = 2; +} diff --git a/packages/autopeering/peer/service/proto/service.pb.go b/packages/autopeering/peer/service/proto/service.pb.go new file mode 100644 index 0000000000..9da648b9f6 --- /dev/null +++ b/packages/autopeering/peer/service/proto/service.pb.go @@ -0,0 +1,137 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: peer/service/proto/service.proto + +package proto + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// 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 + +// Mapping between a service ID and its tuple network_address +// e.g., map[autopeering:&{tcp, 198.51.100.1:80}] +type ServiceMap struct { + Map map[string]*NetworkAddress `protobuf:"bytes,1,rep,name=map,proto3" json:"map,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *ServiceMap) Reset() { *m = ServiceMap{} } +func (m *ServiceMap) String() string { return proto.CompactTextString(m) } +func (*ServiceMap) ProtoMessage() {} +func (*ServiceMap) Descriptor() ([]byte, []int) { + return fileDescriptor_8dd4c5b37d65f758, []int{0} +} + +func (m *ServiceMap) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ServiceMap.Unmarshal(m, b) +} +func (m *ServiceMap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ServiceMap.Marshal(b, m, deterministic) +} +func (m *ServiceMap) XXX_Merge(src proto.Message) { + xxx_messageInfo_ServiceMap.Merge(m, src) +} +func (m *ServiceMap) XXX_Size() int { + return xxx_messageInfo_ServiceMap.Size(m) +} +func (m *ServiceMap) XXX_DiscardUnknown() { + xxx_messageInfo_ServiceMap.DiscardUnknown(m) +} + +var xxx_messageInfo_ServiceMap proto.InternalMessageInfo + +func (m *ServiceMap) GetMap() map[string]*NetworkAddress { + if m != nil { + return m.Map + } + return nil +} + +// The service type (e.g., tcp, upd) and the address (e.g., 198.51.100.1:80) +type NetworkAddress struct { + Network string `protobuf:"bytes,1,opt,name=network,proto3" json:"network,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *NetworkAddress) Reset() { *m = NetworkAddress{} } +func (m *NetworkAddress) String() string { return proto.CompactTextString(m) } +func (*NetworkAddress) ProtoMessage() {} +func (*NetworkAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_8dd4c5b37d65f758, []int{1} +} + +func (m *NetworkAddress) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_NetworkAddress.Unmarshal(m, b) +} +func (m *NetworkAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_NetworkAddress.Marshal(b, m, deterministic) +} +func (m *NetworkAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_NetworkAddress.Merge(m, src) +} +func (m *NetworkAddress) XXX_Size() int { + return xxx_messageInfo_NetworkAddress.Size(m) +} +func (m *NetworkAddress) XXX_DiscardUnknown() { + xxx_messageInfo_NetworkAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_NetworkAddress proto.InternalMessageInfo + +func (m *NetworkAddress) GetNetwork() string { + if m != nil { + return m.Network + } + return "" +} + +func (m *NetworkAddress) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func init() { + proto.RegisterType((*ServiceMap)(nil), "proto.ServiceMap") + proto.RegisterMapType((map[string]*NetworkAddress)(nil), "proto.ServiceMap.MapEntry") + proto.RegisterType((*NetworkAddress)(nil), "proto.NetworkAddress") +} + +func init() { proto.RegisterFile("peer/service/proto/service.proto", fileDescriptor_8dd4c5b37d65f758) } + +var fileDescriptor_8dd4c5b37d65f758 = []byte{ + // 227 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x52, 0x28, 0x48, 0x4d, 0x2d, + 0xd2, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x87, 0xf1, + 0xf4, 0xc0, 0x3c, 0x21, 0x56, 0x30, 0xa5, 0xd4, 0xc9, 0xc8, 0xc5, 0x15, 0x0c, 0x91, 0xf0, 0x4d, + 0x2c, 0x10, 0xd2, 0xe1, 0x62, 0xce, 0x4d, 0x2c, 0x90, 0x60, 0x54, 0x60, 0xd6, 0xe0, 0x36, 0x92, + 0x82, 0x28, 0xd5, 0x43, 0xc8, 0xeb, 0x01, 0xb1, 0x6b, 0x5e, 0x49, 0x51, 0x65, 0x10, 0x48, 0x99, + 0x94, 0x2f, 0x17, 0x07, 0x4c, 0x40, 0x48, 0x80, 0x8b, 0x39, 0x3b, 0xb5, 0x12, 0xa8, 0x93, 0x51, + 0x83, 0x33, 0x08, 0xc4, 0x14, 0xd2, 0xe6, 0x62, 0x2d, 0x4b, 0xcc, 0x29, 0x4d, 0x95, 0x60, 0x02, + 0x8a, 0x71, 0x1b, 0x89, 0x42, 0x4d, 0xf3, 0x4b, 0x2d, 0x29, 0xcf, 0x2f, 0xca, 0x76, 0x4c, 0x49, + 0x29, 0x4a, 0x2d, 0x2e, 0x0e, 0x82, 0xa8, 0xb1, 0x62, 0xb2, 0x60, 0x54, 0x72, 0xe1, 0xe2, 0x43, + 0x95, 0x14, 0x92, 0xe0, 0x62, 0xcf, 0x83, 0x88, 0x40, 0x0d, 0x86, 0x71, 0x41, 0x32, 0x89, 0x10, + 0x45, 0x60, 0xe3, 0x81, 0x32, 0x50, 0xae, 0x93, 0x55, 0x94, 0x45, 0x7a, 0x66, 0x49, 0x46, 0x69, + 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x66, 0x7e, 0x49, 0x62, 0x4e, 0x6a, 0x4a, 0x3a, 0x30, 0x34, + 0x12, 0x4b, 0x4b, 0xf2, 0x41, 0xc1, 0x92, 0x99, 0x97, 0xae, 0x5b, 0x9c, 0x99, 0xab, 0x8f, 0x19, + 0x44, 0x49, 0x6c, 0x60, 0xca, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x5f, 0xe9, 0x8e, 0x9d, 0x3f, + 0x01, 0x00, 0x00, +} diff --git a/packages/autopeering/peer/service/proto/service.proto b/packages/autopeering/peer/service/proto/service.proto new file mode 100644 index 0000000000..28f04088a1 --- /dev/null +++ b/packages/autopeering/peer/service/proto/service.proto @@ -0,0 +1,17 @@ +syntax = "proto3"; + +option go_package = "github.com/iotaledger/goshimmer/packages/autopeering/peer/service/proto"; + +package proto; + +// Mapping between a service ID and its tuple network_address +// e.g., map[autopeering:&{tcp, 198.51.100.1:80}] +message ServiceMap { + map map = 1; +} + +// The service type (e.g., tcp, upd) and the address (e.g., 198.51.100.1:80) +message NetworkAddress { + string network = 1; + string address = 2; +} \ No newline at end of file diff --git a/packages/autopeering/peer/service/record.go b/packages/autopeering/peer/service/record.go new file mode 100644 index 0000000000..7a6df07a63 --- /dev/null +++ b/packages/autopeering/peer/service/record.go @@ -0,0 +1,118 @@ +package service + +import ( + "fmt" + "net" + + "github.com/golang/protobuf/proto" + pb "github.com/iotaledger/goshimmer/packages/autopeering/peer/service/proto" +) + +// Record defines the mapping between a service ID and its tuple TypePort +// e.g., map[autopeering:&{TCP, 8000}] +type Record struct { + m map[string]*networkAddress +} + +// networkAddress implements net.Addr +type networkAddress struct { + network string + address string +} + +// Network returns the service's network name. +func (a *networkAddress) Network() string { + return a.network +} + +// String returns the service's address in string form. +func (a *networkAddress) String() string { + return a.address +} + +// New initializes and returns an empty new Record +func New() *Record { + return &Record{ + m: make(map[string]*networkAddress), + } +} + +// Get returns the network end point address of the service with the given name. +func (s *Record) Get(key Key) net.Addr { + val, ok := s.m[string(key)] + if !ok { + return nil + } + return val +} + +// CreateRecord creates a modifyable Record from the services. +func (s *Record) CreateRecord() *Record { + result := New() + for k, v := range s.m { + result.m[k] = v + } + return result +} + +// Update adds a new service to the map. +func (s *Record) Update(key Key, network string, address string) { + s.m[string(key)] = &networkAddress{ + network: network, address: address, + } +} + +// String returns a string representation of the service record. +func (s *Record) String() string { + return fmt.Sprintf("%v", s.m) +} + +// FromProto creates a Record from the provided protobuf struct. +func FromProto(in *pb.ServiceMap) (*Record, error) { + m := in.GetMap() + if m == nil { + return nil, nil + } + + services := New() + for service, addr := range m { + services.m[service] = &networkAddress{ + network: addr.GetNetwork(), + address: addr.GetAddress(), + } + } + return services, nil +} + +// ToProto returns the corresponding protobuf struct. +func (s *Record) ToProto() *pb.ServiceMap { + if len(s.m) == 0 { + return nil + } + + services := make(map[string]*pb.NetworkAddress, len(s.m)) + for service, addr := range s.m { + services[service] = &pb.NetworkAddress{ + Network: addr.network, + Address: addr.address, + } + } + + return &pb.ServiceMap{ + Map: services, + } +} + +// Marshal serializes a given Peer (p) into a slice of bytes. +func (s *Record) Marshal() ([]byte, error) { + return proto.Marshal(s.ToProto()) +} + +// Unmarshal de-serializes a given slice of bytes (data) into a Peer. +func Unmarshal(data []byte) (*Record, error) { + s := &pb.ServiceMap{} + if err := proto.Unmarshal(data, s); err != nil { + return nil, err + } + return FromProto(s) +} diff --git a/packages/autopeering/peer/service/service.go b/packages/autopeering/peer/service/service.go new file mode 100644 index 0000000000..a201bce01e --- /dev/null +++ b/packages/autopeering/peer/service/service.go @@ -0,0 +1,26 @@ +package service + +import ( + "net" +) + +// Service is a read-only interface to access services. +type Service interface { + // Get returns the network end point address of the given service or nil if not supported. + Get(Key) net.Addr + + // CreateRecord creates a modifyable Record from the services. + CreateRecord() *Record +} + +// Key is the type of keys used to look-up a service. +type Key string + +const ( + // PeeringKey is the key for the auto peering service. + PeeringKey Key = "peering" + // FPCKey is the key for the FPC service. + FPCKey Key = "fpc" + // GossipKey is the key for the gossip service. + GossipKey Key = "gossip" +) diff --git a/packages/autopeering/peer/sort.go b/packages/autopeering/peer/sort.go new file mode 100644 index 0000000000..a0dd3e9a77 --- /dev/null +++ b/packages/autopeering/peer/sort.go @@ -0,0 +1,38 @@ +package peer + +import ( + "sort" + + "github.com/iotaledger/goshimmer/packages/autopeering/distance" +) + +// PeerDistance defines the relative distance wrt a remote peer +type PeerDistance struct { + Remote *Peer + Distance uint32 +} + +// byDistance is a slice of PeerDistance used to sort +type byDistance []PeerDistance + +func (a byDistance) Len() int { return len(a) } +func (a byDistance) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a byDistance) Less(i, j int) bool { return a[i].Distance < a[j].Distance } + +// NewPeerDistance returns a new PeerDistance +func NewPeerDistance(anchorID, salt []byte, remote *Peer) PeerDistance { + return PeerDistance{ + Remote: remote, + Distance: distance.BySalt(anchorID, remote.ID().Bytes(), salt), + } +} + +// SortBySalt returns a slice of PeerDistance given a list of remote peers +func SortBySalt(anchor, salt []byte, remotePeers []*Peer) (result []PeerDistance) { + result = make(byDistance, len(remotePeers)) + for i, remote := range remotePeers { + result[i] = NewPeerDistance(anchor, salt, remote) + } + sort.Sort(byDistance(result)) + return result +} diff --git a/packages/autopeering/peer/sort_test.go b/packages/autopeering/peer/sort_test.go new file mode 100644 index 0000000000..9357bb7a78 --- /dev/null +++ b/packages/autopeering/peer/sort_test.go @@ -0,0 +1,45 @@ +package peer + +import ( + "crypto/ed25519" + "testing" + + "github.com/stretchr/testify/assert" +) + +func newTestPeerWithID(ID byte) *Peer { + key := make([]byte, ed25519.PublicKeySize) + key[0] = ID + return NewPeer(key, newTestServiceRecord()) +} + +func TestOrderedDistanceList(t *testing.T) { + type testCase struct { + anchor []byte + salt []byte + ordered bool + } + + tests := []testCase{ + { + anchor: []byte("X"), + salt: []byte("salt"), + ordered: true, + }, + } + + remotePeers := make([]*Peer, 10) + for i := range remotePeers { + remotePeers[i] = newTestPeerWithID(byte(i + 1)) + } + + for _, test := range tests { + d := SortBySalt(test.anchor, test.salt, remotePeers) + prev := d[0] + for _, next := range d[1:] { + got := prev.Distance < next.Distance + assert.Equal(t, test.ordered, got, "Ordered distance list") + prev = next + } + } +} diff --git a/packages/autopeering/salt/proto/salt.pb.go b/packages/autopeering/salt/proto/salt.pb.go new file mode 100644 index 0000000000..cb7f27bf30 --- /dev/null +++ b/packages/autopeering/salt/proto/salt.pb.go @@ -0,0 +1,89 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: salt/proto/salt.proto + +package proto + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// 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 + +type Salt struct { + // value of the salt + Bytes []byte `protobuf:"bytes,1,opt,name=bytes,proto3" json:"bytes,omitempty"` + // expiration time of the salt + ExpTime uint64 `protobuf:"fixed64,2,opt,name=exp_time,json=expTime,proto3" json:"exp_time,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Salt) Reset() { *m = Salt{} } +func (m *Salt) String() string { return proto.CompactTextString(m) } +func (*Salt) ProtoMessage() {} +func (*Salt) Descriptor() ([]byte, []int) { + return fileDescriptor_d46762658484b01f, []int{0} +} + +func (m *Salt) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Salt.Unmarshal(m, b) +} +func (m *Salt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Salt.Marshal(b, m, deterministic) +} +func (m *Salt) XXX_Merge(src proto.Message) { + xxx_messageInfo_Salt.Merge(m, src) +} +func (m *Salt) XXX_Size() int { + return xxx_messageInfo_Salt.Size(m) +} +func (m *Salt) XXX_DiscardUnknown() { + xxx_messageInfo_Salt.DiscardUnknown(m) +} + +var xxx_messageInfo_Salt proto.InternalMessageInfo + +func (m *Salt) GetBytes() []byte { + if m != nil { + return m.Bytes + } + return nil +} + +func (m *Salt) GetExpTime() uint64 { + if m != nil { + return m.ExpTime + } + return 0 +} + +func init() { + proto.RegisterType((*Salt)(nil), "proto.Salt") +} + +func init() { proto.RegisterFile("salt/proto/salt.proto", fileDescriptor_d46762658484b01f) } + +var fileDescriptor_d46762658484b01f = []byte{ + // 142 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x4e, 0xcc, 0x29, + 0xd1, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x07, 0x31, 0xf5, 0xc0, 0x4c, 0x21, 0x56, 0x30, 0xa5, + 0x64, 0xce, 0xc5, 0x12, 0x0c, 0x14, 0x14, 0x12, 0xe1, 0x62, 0x4d, 0xaa, 0x2c, 0x49, 0x2d, 0x96, + 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x09, 0x82, 0x70, 0x84, 0x24, 0xb9, 0x38, 0x52, 0x2b, 0x0a, 0xe2, + 0x4b, 0x32, 0x73, 0x53, 0x25, 0x98, 0x80, 0x12, 0x6c, 0x41, 0xec, 0x40, 0x7e, 0x08, 0x90, 0xeb, + 0x64, 0x14, 0x65, 0x90, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0xab, 0x9f, 0x99, + 0x5f, 0x92, 0x98, 0x93, 0x9a, 0x92, 0x9e, 0x5a, 0xa4, 0x9f, 0x58, 0x5a, 0x92, 0x5f, 0x90, 0x9a, + 0x5a, 0x94, 0x99, 0x97, 0xae, 0x5b, 0x9c, 0x99, 0xab, 0x8f, 0xb0, 0x3e, 0x89, 0x0d, 0x4c, 0x19, + 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x47, 0x07, 0x7d, 0x5f, 0x93, 0x00, 0x00, 0x00, +} diff --git a/packages/autopeering/salt/proto/salt.proto b/packages/autopeering/salt/proto/salt.proto new file mode 100644 index 0000000000..e1b61df55a --- /dev/null +++ b/packages/autopeering/salt/proto/salt.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +option go_package = "github.com/iotaledger/goshimmer/packages/autopeering/salt/proto"; + +package proto; + +message Salt { + // value of the salt + bytes bytes = 1; + // expiration time of the salt + fixed64 exp_time = 2; +} \ No newline at end of file diff --git a/packages/autopeering/salt/salt.go b/packages/autopeering/salt/salt.go new file mode 100644 index 0000000000..917f5a9127 --- /dev/null +++ b/packages/autopeering/salt/salt.go @@ -0,0 +1,86 @@ +package salt + +import ( + "crypto/rand" + "fmt" + "sync" + "time" + + "github.com/golang/protobuf/proto" + pb "github.com/iotaledger/goshimmer/packages/autopeering/salt/proto" +) + +// SaltByteSize specifies the number of bytes used for the salt. +const SaltByteSize = 20 + +// Salt encapsulates high level functions around salt management. +type Salt struct { + bytes []byte // value of the salt + expirationTime time.Time // expiration time of the salt + mutex sync.RWMutex +} + +// NewSalt generates a new salt given a lifetime duration +func NewSalt(lifetime time.Duration) (salt *Salt, err error) { + salt = &Salt{ + bytes: make([]byte, SaltByteSize), + expirationTime: time.Now().Add(lifetime), + } + + if _, err = rand.Read(salt.bytes); err != nil { + return nil, err + } + + return salt, err +} + +func (s *Salt) GetBytes() []byte { + s.mutex.RLock() + defer s.mutex.RUnlock() + return s.bytes +} + +func (s *Salt) GetExpiration() time.Time { + s.mutex.RLock() + defer s.mutex.RUnlock() + return s.expirationTime +} + +// Expired returns true if the given salt expired +func (s *Salt) Expired() bool { + return time.Now().After(s.GetExpiration()) +} + +// ToProto encodes the Salt into a proto buffer Salt message +func (s *Salt) ToProto() *pb.Salt { + return &pb.Salt{ + Bytes: s.bytes, + ExpTime: uint64(s.expirationTime.Unix()), + } +} + +// FromProto decodes a given proto buffer Salt message (in) and returns the corresponding Salt. +func FromProto(in *pb.Salt) (*Salt, error) { + if l := len(in.GetBytes()); l != SaltByteSize { + return nil, fmt.Errorf("invalid salt length: %d, need %d", l, SaltByteSize) + } + out := &Salt{ + bytes: in.GetBytes(), + expirationTime: time.Unix(int64(in.GetExpTime()), 0), + } + return out, nil +} + +// Marshal serializes a given salt (s) into a slice of bytes (data) +func (s *Salt) Marshal() ([]byte, error) { + return proto.Marshal(s.ToProto()) +} + +// Unmarshal de-serializes a given slice of bytes (data) into a Salt. +func Unmarshal(data []byte) (*Salt, error) { + s := &pb.Salt{} + if err := proto.Unmarshal(data, s); err != nil { + return nil, err + } + return FromProto(s) +} diff --git a/packages/autopeering/salt/salt_test.go b/packages/autopeering/salt/salt_test.go new file mode 100644 index 0000000000..3e5bbc3f69 --- /dev/null +++ b/packages/autopeering/salt/salt_test.go @@ -0,0 +1,73 @@ +package salt + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestNewSalt(t *testing.T) { + type testCase struct { + input time.Duration + want error + } + + tests := []testCase{ + {input: 0, want: nil}, + {input: 10, want: nil}, + {input: -1, want: nil}, + } + + for _, test := range tests { + _, err := NewSalt(test.input) + assert.Equal(t, test.want, err, test) + } +} + +func TestSaltExpired(t *testing.T) { + type testCase struct { + input time.Duration + want bool + } + + tests := []testCase{ + {input: 0, want: true}, + {input: time.Second * 10, want: false}, + {input: -1, want: true}, + } + + for _, test := range tests { + salt, _ := NewSalt(test.input) + got := salt.Expired() + assert.Equal(t, test.want, got, test) + } +} + +func TestMarshalUnmarshal(t *testing.T) { + type testCase struct { + input time.Duration + } + + tests := []testCase{ + {input: 0}, + {input: time.Second * 10}, + {input: -1}, + } + + for _, test := range tests { + salt, _ := NewSalt(test.input) + + data, err := salt.Marshal() + require.Equal(t, nil, err, "NoErrorCheck") + + got, err := Unmarshal(data) + require.Equal(t, nil, err, "NoErrorCheck") + + assert.Equal(t, salt.GetBytes(), got.GetBytes(), "Salt") + assert.Equal(t, salt.GetExpiration().Unix(), got.GetExpiration().Unix(), "SameSaltExpirationTime") + + } + +} diff --git a/packages/autopeering/selection/common.go b/packages/autopeering/selection/common.go new file mode 100644 index 0000000000..e31c84168e --- /dev/null +++ b/packages/autopeering/selection/common.go @@ -0,0 +1,41 @@ +package selection + +import ( + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "go.uber.org/zap" +) + +// Config holds settings for the peer selection. +type Config struct { + // Logger + Log *zap.SugaredLogger + + // These settings are optional: + Param *Parameters // parameters +} + +// default parameter values +const ( + // DefaultInboundNeighborSize is the default number of inbound neighbors. + DefaultInboundNeighborSize = 4 + // DefaultOutboundNeighborSize is the default number of outbound neighbors. + DefaultOutboundNeighborSize = 4 + + // DefaultSaltLifetime is the default lifetime of the private and public local salt. + DefaultSaltLifetime = 30 * time.Minute + + // DefaultUpdateOutboundInterval is the default time interval after which the outbound neighbors are checked. + DefaultUpdateOutboundInterval = 200 * time.Millisecond +) + +// Parameters holds the parameters that can be configured. +type Parameters struct { + InboundNeighborSize int // number of inbound neighbors + OutboundNeighborSize int // number of outbound neighbors + SaltLifetime time.Duration // lifetime of the private and public local salt + UpdateOutboundInterval time.Duration // time interval after which the outbound neighbors are checked + DropNeighborsOnUpdate bool // set true to drop all neighbors when the distance is updated + RequiredService []service.Key // services required in order to select/be selected during autopeering +} diff --git a/packages/autopeering/selection/events.go b/packages/autopeering/selection/events.go new file mode 100644 index 0000000000..9a312b2fee --- /dev/null +++ b/packages/autopeering/selection/events.go @@ -0,0 +1,42 @@ +package selection + +import ( + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/hive.go/events" +) + +// Events contains all the events that are triggered during the neighbor selection. +var Events = struct { + // An OutgoingPeering event is triggered, when a valid response of PeeringRequest has been received. + OutgoingPeering *events.Event + // An IncomingPeering event is triggered, when a valid PeerRequest has been received. + IncomingPeering *events.Event + + // A Dropped event is triggered, when a neigbhor is dropped or when a drop message is received. + Dropped *events.Event +}{ + OutgoingPeering: events.NewEvent(peeringCaller), + IncomingPeering: events.NewEvent(peeringCaller), + Dropped: events.NewEvent(droppedCaller), +} + +// PeeringEvent bundles the information sent in a peering event. +type PeeringEvent struct { + Self peer.ID // ID of the peer triggering the event. + Peer *peer.Peer // peering partner + Status bool // true, when the peering partner has accepted the request +} + +// DroppedEvent bundles the information sent in Dropped events. +type DroppedEvent struct { + Self peer.ID // ID of the peer triggering the event. + DroppedID peer.ID // ID of the peer that gets dropped. +} + +func peeringCaller(handler interface{}, params ...interface{}) { + handler.(func(*PeeringEvent))(params[0].(*PeeringEvent)) +} + +func droppedCaller(handler interface{}, params ...interface{}) { + handler.(func(*DroppedEvent))(params[0].(*DroppedEvent)) +} diff --git a/packages/autopeering/selection/manager.go b/packages/autopeering/selection/manager.go new file mode 100644 index 0000000000..c30ef6aef1 --- /dev/null +++ b/packages/autopeering/selection/manager.go @@ -0,0 +1,412 @@ +package selection + +import ( + "math/rand" + "sync" + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/iotaledger/goshimmer/packages/autopeering/salt" + "go.uber.org/zap" +) + +const ( + accept = true + reject = false + + // buffer size of the channels handling inbound requests and drops. + queueSize = 100 +) + +var ( + // number of neighbors + inboundNeighborSize = DefaultInboundNeighborSize + outboundNeighborSize = DefaultOutboundNeighborSize + + // lifetime of the private and public local salt + saltLifetime = DefaultSaltLifetime + // time interval after which the outbound neighbors are checked + updateOutboundInterval = DefaultUpdateOutboundInterval + + dropNeighborsOnUpdate bool // whether all neighbors are dropped on distance update +) + +// A network represents the communication layer for the manager. +type network interface { + local() *peer.Local + + RequestPeering(*peer.Peer, *salt.Salt) (bool, error) + DropPeer(*peer.Peer) +} + +type peeringRequest struct { + peer *peer.Peer + salt *salt.Salt +} + +type manager struct { + net network + peersFunc func() []*peer.Peer + + log *zap.SugaredLogger + dropNeighbors bool + + inbound *Neighborhood + outbound *Neighborhood + + inboundRequestChan chan peeringRequest + inboundReplyChan chan bool + inboundDropChan chan peer.ID + outboundDropChan chan peer.ID + + rejectionFilter *Filter + + wg sync.WaitGroup + inboundClosing chan struct{} + outboundClosing chan struct{} + + requiredService []service.Key +} + +func newManager(net network, peersFunc func() []*peer.Peer, log *zap.SugaredLogger, param *Parameters) *manager { + var requiredService []service.Key + + if param != nil { + if param.InboundNeighborSize > 0 { + inboundNeighborSize = param.InboundNeighborSize + } + if param.OutboundNeighborSize > 0 { + outboundNeighborSize = param.OutboundNeighborSize + } + if param.SaltLifetime > 0 { + saltLifetime = param.SaltLifetime + } + if param.UpdateOutboundInterval > 0 { + updateOutboundInterval = param.UpdateOutboundInterval + } + requiredService = param.RequiredService + dropNeighborsOnUpdate = param.DropNeighborsOnUpdate + } + + return &manager{ + net: net, + peersFunc: peersFunc, + log: log, + dropNeighbors: dropNeighborsOnUpdate, + inboundClosing: make(chan struct{}), + outboundClosing: make(chan struct{}), + rejectionFilter: NewFilter(), + inboundRequestChan: make(chan peeringRequest, queueSize), + inboundReplyChan: make(chan bool), + inboundDropChan: make(chan peer.ID, queueSize), + outboundDropChan: make(chan peer.ID, queueSize), + inbound: &Neighborhood{ + Neighbors: []peer.PeerDistance{}, + Size: inboundNeighborSize}, + outbound: &Neighborhood{ + Neighbors: []peer.PeerDistance{}, + Size: outboundNeighborSize}, + requiredService: requiredService, + } +} + +func (m *manager) start() { + // create valid salts + if m.net.local().GetPublicSalt() == nil || m.net.local().GetPrivateSalt() == nil { + m.updateSalt() + } + + m.wg.Add(2) + go m.loopOutbound() + go m.loopInbound() +} + +func (m *manager) close() { + close(m.inboundClosing) + close(m.outboundClosing) + m.wg.Wait() +} + +func (m *manager) self() peer.ID { + return m.net.local().ID() +} + +func (m *manager) loopOutbound() { + defer m.wg.Done() + + var ( + updateOutboundDone chan struct{} + updateOutbound = time.NewTimer(0) // setting this to 0 will cause a trigger right away + backoff = 10 + ) + defer updateOutbound.Stop() + +Loop: + for { + select { + case <-updateOutbound.C: + // if there is no updateOutbound, this means doUpdateOutbound is not running + if updateOutboundDone == nil { + // check salt and update if necessary (this will drop the whole neighborhood) + if m.net.local().GetPublicSalt().Expired() { + m.updateSalt() + } + + //remove potential duplicates + dup := m.getDuplicates() + for _, peerToDrop := range dup { + toDrop := m.inbound.GetPeerFromID(peerToDrop) + time.Sleep(time.Duration(rand.Intn(backoff)) * time.Millisecond) + m.outbound.RemovePeer(peerToDrop) + m.inbound.RemovePeer(peerToDrop) + if toDrop != nil { + m.dropPeer(toDrop) + } + } + + updateOutboundDone = make(chan struct{}) + go m.updateOutbound(updateOutboundDone) + } + + case <-updateOutboundDone: + updateOutboundDone = nil + updateOutbound.Reset(updateOutboundInterval) // updateOutbound again after the given interval + + case peerToDrop := <-m.outboundDropChan: + if containsPeer(m.outbound.GetPeers(), peerToDrop) { + m.outbound.RemovePeer(peerToDrop) + m.rejectionFilter.AddPeer(peerToDrop) + m.log.Debug("Outbound Dropped BY ", peerToDrop, " (", len(m.outbound.GetPeers()), ",", len(m.inbound.GetPeers()), ")") + } + + // on close, exit the loop + case <-m.outboundClosing: + break Loop + } + } + + // wait for the updateOutbound to finish + if updateOutboundDone != nil { + <-updateOutboundDone + } +} + +func (m *manager) loopInbound() { + defer m.wg.Done() + +Loop: + for { + select { + case req := <-m.inboundRequestChan: + m.updateInbound(req.peer, req.salt) + + case peerToDrop := <-m.inboundDropChan: + if containsPeer(m.inbound.GetPeers(), peerToDrop) { + m.inbound.RemovePeer(peerToDrop) + m.log.Debug("Inbound Dropped BY ", peerToDrop, " (", len(m.outbound.GetPeers()), ",", len(m.inbound.GetPeers()), ")") + } + + // on close, exit the loop + case <-m.inboundClosing: + break Loop + } + } +} + +// updateOutbound updates outbound neighbors. +func (m *manager) updateOutbound(done chan<- struct{}) { + defer func() { + done <- struct{}{} + }() // always signal, when the function returns + + // sort verified peers by distance + distList := peer.SortBySalt(m.self().Bytes(), m.net.local().GetPublicSalt().GetBytes(), m.peersFunc()) + + filter := NewFilter() + filter.AddPeer(m.self()) //set filter for ourself + filter.AddPeers(m.inbound.GetPeers()) // set filter for inbound neighbors + filter.AddPeers(m.outbound.GetPeers()) // set filter for outbound neighbors + + filteredList := filter.Apply(distList) // filter out current neighbors + filteredList = m.rejectionFilter.Apply(filteredList) // filter out previous rejection + + // select new candidate + candidate := m.outbound.Select(filteredList) + + if candidate.Remote != nil { + // reject if required services are missing + for _, reqService := range m.requiredService { + if candidate.Remote.Services().Get(reqService) == nil { + m.rejectionFilter.AddPeer(candidate.Remote.ID()) + return + } + } + + furthest, _ := m.outbound.getFurthest() + + // send peering request + mySalt := m.net.local().GetPublicSalt() + status, err := m.net.RequestPeering(candidate.Remote, mySalt) + if err != nil { + m.rejectionFilter.AddPeer(candidate.Remote.ID()) // TODO: add retries + return + } + + // add candidate to the outbound neighborhood + if status { + //m.acceptedFilter.AddPeer(candidate.Remote.ID()) + if furthest.Remote != nil { + m.outbound.RemovePeer(furthest.Remote.ID()) + m.dropPeer(furthest.Remote) + m.log.Debug("Outbound furthest removed ", furthest.Remote.ID()) + } + m.outbound.Add(candidate) + m.log.Debug("Peering request TO ", candidate.Remote.ID(), " status ACCEPTED (", len(m.outbound.GetPeers()), ",", len(m.inbound.GetPeers()), ")") + } else { + m.log.Debug("Peering request TO ", candidate.Remote.ID(), " status REJECTED (", len(m.outbound.GetPeers()), ",", len(m.inbound.GetPeers()), ")") + m.rejectionFilter.AddPeer(candidate.Remote.ID()) + //m.log.Debug("Rejection Filter ", candidate.Remote.ID()) + } + + // signal the result of the outgoing peering request + Events.OutgoingPeering.Trigger(&PeeringEvent{Self: m.self(), Peer: candidate.Remote, Status: status}) + } +} + +func (m *manager) updateInbound(requester *peer.Peer, salt *salt.Salt) { + // TODO: check request legitimacy + //m.log.Debug("Evaluating peering request FROM ", requester.ID()) + reqDistance := peer.NewPeerDistance(m.self().Bytes(), m.net.local().GetPrivateSalt().GetBytes(), requester) + + candidateList := []peer.PeerDistance{reqDistance} + + filter := NewFilter() + filter.AddPeers(m.outbound.GetPeers()) // set filter for outbound neighbors + filteredList := filter.Apply(candidateList) // filter out current neighbors + + // make decision + toAccept := m.inbound.Select(filteredList) + for _, reqService := range m.requiredService { + if requester.Services().Get(reqService) == nil { + toAccept.Remote = nil // reject if required services are missing + break + } + } + // reject request + if toAccept.Remote == nil { + m.log.Debug("Peering request FROM ", requester.ID(), " status REJECTED (", len(m.outbound.GetPeers()), ",", len(m.inbound.GetPeers()), ")") + m.inboundReplyChan <- reject + return + } + // accept request + m.inboundReplyChan <- accept + furthest, _ := m.inbound.getFurthest() + // drop furthest neighbor + if furthest.Remote != nil { + m.inbound.RemovePeer(furthest.Remote.ID()) + m.dropPeer(furthest.Remote) + m.log.Debug("Inbound furthest removed ", furthest.Remote.ID()) + } + // update inbound neighborhood + m.inbound.Add(toAccept) + m.log.Debug("Peering request FROM ", toAccept.Remote.ID(), " status ACCEPTED (", len(m.outbound.GetPeers()), ",", len(m.inbound.GetPeers()), ")") +} + +func (m *manager) updateSalt() (*salt.Salt, *salt.Salt) { + pubSalt, _ := salt.NewSalt(saltLifetime) + m.net.local().SetPublicSalt(pubSalt) + + privSalt, _ := salt.NewSalt(saltLifetime) + m.net.local().SetPrivateSalt(privSalt) + + m.rejectionFilter.Clean() + + if !dropNeighborsOnUpdate { // update distance without dropping neighbors + m.outbound.UpdateDistance(m.self().Bytes(), m.net.local().GetPublicSalt().GetBytes()) + m.inbound.UpdateDistance(m.self().Bytes(), m.net.local().GetPrivateSalt().GetBytes()) + } else { // drop all the neighbors + m.dropNeighborhood(m.inbound) + m.dropNeighborhood(m.outbound) + } + + return pubSalt, privSalt +} + +func (m *manager) dropNeighbor(peerToDrop peer.ID) { + m.inboundDropChan <- peerToDrop + m.outboundDropChan <- peerToDrop + + // signal the dropped peer + Events.Dropped.Trigger(&DroppedEvent{Self: m.self(), DroppedID: peerToDrop}) +} + +// containsPeer returns true if a peer with the given ID is in the list. +func containsPeer(list []*peer.Peer, id peer.ID) bool { + for _, p := range list { + if p.ID() == id { + return true + } + } + return false +} + +func (m *manager) acceptRequest(p *peer.Peer, s *salt.Salt) bool { + m.inboundRequestChan <- peeringRequest{p, s} + status := <-m.inboundReplyChan + + // signal the received request + Events.IncomingPeering.Trigger(&PeeringEvent{Self: m.self(), Peer: p, Status: status}) + + return status +} + +func (m *manager) getNeighbors() []*peer.Peer { + var neighbors []*peer.Peer + + neighbors = append(neighbors, m.inbound.GetPeers()...) + neighbors = append(neighbors, m.outbound.GetPeers()...) + + return neighbors +} + +func (m *manager) getIncomingNeighbors() []*peer.Peer { + var neighbors []*peer.Peer + + neighbors = append(neighbors, m.inbound.GetPeers()...) + + return neighbors +} + +func (m *manager) getOutgoingNeighbors() []*peer.Peer { + var neighbors []*peer.Peer + + neighbors = append(neighbors, m.outbound.GetPeers()...) + + return neighbors +} + +func (m *manager) getDuplicates() []peer.ID { + var d []peer.ID + + for _, p := range m.inbound.GetPeers() { + if containsPeer(m.outbound.GetPeers(), p.ID()) { + d = append(d, p.ID()) + } + } + return d +} + +func (m *manager) dropNeighborhood(nh *Neighborhood) { + for _, p := range nh.GetPeers() { + nh.RemovePeer(p.ID()) + m.dropPeer(p) + } +} + +func (m *manager) dropPeer(p *peer.Peer) { + // send the drop request over the network + m.net.DropPeer(p) + // signal the drop + Events.Dropped.Trigger(&DroppedEvent{Self: m.self(), DroppedID: p.ID()}) +} diff --git a/packages/autopeering/selection/manager_test.go b/packages/autopeering/selection/manager_test.go new file mode 100644 index 0000000000..8c3939d8fc --- /dev/null +++ b/packages/autopeering/selection/manager_test.go @@ -0,0 +1,135 @@ +package selection + +import ( + "fmt" + "log" + "math/rand" + "testing" + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/salt" + "github.com/stretchr/testify/assert" + "go.uber.org/zap" +) + +var ( + allPeers []*peer.Peer +) + +type testPeer struct { + local *peer.Local + peer *peer.Peer + db peer.DB + log *zap.SugaredLogger + rand *rand.Rand // random number generator +} + +func newPeer(name string) testPeer { + var l *zap.Logger + var err error + if name == "1" { + l, err = zap.NewDevelopment() + } else { + l, err = zap.NewDevelopment() //zap.NewProduction() + } + if err != nil { + log.Fatalf("cannot initialize logger: %v", err) + } + logger := l.Sugar() + log := logger.Named(name) + db := peer.NewMemoryDB(log.Named("db")) + local, _ := peer.NewLocal("", name, db) + s, _ := salt.NewSalt(100 * time.Second) + local.SetPrivateSalt(s) + s, _ = salt.NewSalt(100 * time.Second) + local.SetPublicSalt(s) + p := &local.Peer + return testPeer{local, p, db, log, rand.New(rand.NewSource(time.Now().UnixNano()))} +} + +func removeDuplicatePeers(peers []*peer.Peer) []*peer.Peer { + seen := make(map[peer.ID]bool, len(peers)) + result := make([]*peer.Peer, 0, len(peers)) + + for _, p := range peers { + if !seen[p.ID()] { + seen[p.ID()] = true + result = append(result, p) + } + } + + return result +} + +type testNet struct { + loc *peer.Local + self *peer.Peer + mgr map[peer.ID]*manager + rand *rand.Rand +} + +func (n testNet) local() *peer.Local { + return n.loc +} + +func (n testNet) DropPeer(p *peer.Peer) { + n.mgr[p.ID()].dropNeighbor(n.local().ID()) +} + +func (n testNet) RequestPeering(p *peer.Peer, s *salt.Salt) (bool, error) { + return n.mgr[p.ID()].acceptRequest(n.self, s), nil +} + +func (n testNet) GetKnownPeers() []*peer.Peer { + list := make([]*peer.Peer, len(allPeers)-1) + i := 0 + for _, peer := range allPeers { + if peer.ID() == n.self.ID() { + continue + } + + list[i] = peer + i++ + } + return list +} + +func TestSimManager(t *testing.T) { + N := 9 // number of peers to generate + + allPeers = make([]*peer.Peer, N) + + mgrMap := make(map[peer.ID]*manager) + for i := range allPeers { + peer := newPeer(fmt.Sprintf("%d", i)) + allPeers[i] = peer.peer + + net := testNet{ + mgr: mgrMap, + loc: peer.local, + self: peer.peer, + rand: peer.rand, + } + mgrMap[peer.local.ID()] = newManager(net, net.GetKnownPeers, peer.log, &Parameters{SaltLifetime: 100 * time.Second}) + } + + // start all the managers + for _, mgr := range mgrMap { + mgr.start() + } + + time.Sleep(6 * time.Second) + + for i, peer := range allPeers { + neighbors := mgrMap[peer.ID()].getNeighbors() + + assert.NotEmpty(t, neighbors, "Peer %d has no neighbors", i) + assert.Equal(t, removeDuplicatePeers(neighbors), neighbors, "Peer %d has non unique neighbors", i) + } + + // close all the managers + for _, mgr := range mgrMap { + mgr.close() + } +} diff --git a/packages/autopeering/selection/neighborhood.go b/packages/autopeering/selection/neighborhood.go new file mode 100644 index 0000000000..e3e138b22f --- /dev/null +++ b/packages/autopeering/selection/neighborhood.go @@ -0,0 +1,108 @@ +package selection + +import ( + "sync" + + "github.com/iotaledger/goshimmer/packages/autopeering/distance" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" +) + +type Neighborhood struct { + Neighbors []peer.PeerDistance + Size int + mutex sync.RWMutex +} + +func (nh *Neighborhood) getFurthest() (peer.PeerDistance, int) { + nh.mutex.RLock() + defer nh.mutex.RUnlock() + if len(nh.Neighbors) < nh.Size { + return peer.PeerDistance{ + Remote: nil, + Distance: distance.Max, + }, len(nh.Neighbors) + } + + index := 0 + furthest := nh.Neighbors[index] + for i, neighbor := range nh.Neighbors { + if neighbor.Distance > furthest.Distance { + furthest = neighbor + index = i + } + } + return furthest, index +} + +func (nh *Neighborhood) Select(candidates []peer.PeerDistance) peer.PeerDistance { + if len(candidates) > 0 { + target, _ := nh.getFurthest() + for _, candidate := range candidates { + if candidate.Distance < target.Distance { + return candidate + } + } + } + return peer.PeerDistance{} +} + +func (nh *Neighborhood) Add(toAdd peer.PeerDistance) { + nh.mutex.Lock() + defer nh.mutex.Unlock() + if len(nh.Neighbors) < nh.Size { + nh.Neighbors = append(nh.Neighbors, toAdd) + } +} + +func (nh *Neighborhood) RemovePeer(toRemove peer.ID) { + index := nh.getPeerIndex(toRemove) + nh.mutex.Lock() + defer nh.mutex.Unlock() + if index < 0 || len(nh.Neighbors) == 0 || len(nh.Neighbors) < index+1 { + return + } + nh.Neighbors[index] = peer.PeerDistance{} + copy(nh.Neighbors[index:], nh.Neighbors[index+1:]) + nh.Neighbors = nh.Neighbors[:len(nh.Neighbors)-1] +} + +func (nh *Neighborhood) getPeerIndex(target peer.ID) int { + nh.mutex.RLock() + defer nh.mutex.RUnlock() + for i, peer := range nh.Neighbors { + if peer.Remote.ID() == target { + return i + } + } + return -1 + +} + +func (nh *Neighborhood) UpdateDistance(anchor, salt []byte) { + nh.mutex.Lock() + defer nh.mutex.Unlock() + for i, peer := range nh.Neighbors { + nh.Neighbors[i].Distance = distance.BySalt(anchor, peer.Remote.ID().Bytes(), salt) + } +} + +func (nh *Neighborhood) GetPeers() []*peer.Peer { + nh.mutex.RLock() + defer nh.mutex.RUnlock() + list := make([]*peer.Peer, len(nh.Neighbors)) + for i, peer := range nh.Neighbors { + list[i] = peer.Remote + } + return list +} + +func (nh *Neighborhood) GetPeerFromID(id peer.ID) *peer.Peer { + nh.mutex.RLock() + defer nh.mutex.RUnlock() + for _, peer := range nh.Neighbors { + if peer.Remote.ID() == id { + return peer.Remote + } + } + return nil +} diff --git a/packages/autopeering/selection/neighborhood_test.go b/packages/autopeering/selection/neighborhood_test.go new file mode 100644 index 0000000000..40fcf5978f --- /dev/null +++ b/packages/autopeering/selection/neighborhood_test.go @@ -0,0 +1,252 @@ +package selection + +import ( + "testing" + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/distance" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/salt" + "github.com/stretchr/testify/assert" +) + +func TestGetFurthest(t *testing.T) { + d := make([]peer.PeerDistance, 5) + for i := range d { + d[i].Remote = newTestPeer() + d[i].Distance = uint32(i + 1) + } + + type testCase struct { + input *Neighborhood + expected peer.PeerDistance + index int + } + + tests := []testCase{ + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0]}, + Size: 4}, + expected: peer.PeerDistance{ + Remote: nil, + Distance: distance.Max}, + index: 1, + }, + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0], d[1], d[2], d[3]}, + Size: 4}, + expected: d[3], + index: 3, + }, + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, + Size: 4}, + expected: d[4], + index: 2, + }, + } + + for _, test := range tests { + p, l := test.input.getFurthest() + assert.Equal(t, test.expected, p, "Get furthest neighbor") + assert.Equal(t, test.index, l, "Get furthest neighbor") + } +} + +func TestGetPeerIndex(t *testing.T) { + d := make([]peer.PeerDistance, 5) + for i := range d { + d[i].Remote = newTestPeer() + d[i].Distance = uint32(i + 1) + } + + type testCase struct { + input *Neighborhood + target *peer.Peer + index int + } + + tests := []testCase{ + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0]}, + Size: 4}, + target: d[0].Remote, + index: 0, + }, + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0], d[1], d[2], d[3]}, + Size: 4}, + target: d[3].Remote, + index: 3, + }, + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, + Size: 4}, + target: d[3].Remote, + index: -1, + }, + } + + for _, test := range tests { + i := test.input.getPeerIndex(test.target.ID()) + assert.Equal(t, test.index, i, "Get Peer Index") + } +} + +func TestRemove(t *testing.T) { + d := make([]peer.PeerDistance, 10) + for i := range d { + d[i].Remote = newTestPeer() + d[i].Distance = uint32(i + 1) + } + + type testCase struct { + input *Neighborhood + toRemove *peer.Peer + expected []peer.PeerDistance + } + + tests := []testCase{ + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0]}, + Size: 4}, + toRemove: d[0].Remote, + expected: []peer.PeerDistance{}, + }, + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0], d[1], d[3]}, + Size: 4}, + toRemove: d[1].Remote, + expected: []peer.PeerDistance{d[0], d[3]}, + }, + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, + Size: 4}, + toRemove: d[2].Remote, + expected: []peer.PeerDistance{d[0], d[1], d[4]}, + }, + } + + for _, test := range tests { + test.input.RemovePeer(test.toRemove.ID()) + assert.Equal(t, test.expected, test.input.Neighbors, "Remove") + } +} + +func TestAdd(t *testing.T) { + d := make([]peer.PeerDistance, 10) + for i := range d { + d[i].Remote = newTestPeer() + d[i].Distance = uint32(i + 1) + } + + type testCase struct { + input *Neighborhood + toAdd peer.PeerDistance + expected []peer.PeerDistance + } + + tests := []testCase{ + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0]}, + Size: 4}, + toAdd: d[2], + expected: []peer.PeerDistance{d[0], d[2]}, + }, + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0], d[1], d[3]}, + Size: 4}, + toAdd: d[2], + expected: []peer.PeerDistance{d[0], d[1], d[3], d[2]}, + }, + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, + Size: 4}, + toAdd: d[3], + expected: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, + }, + } + + for _, test := range tests { + test.input.Add(test.toAdd) + assert.Equal(t, test.expected, test.input.Neighbors, "Add") + } +} + +func TestUpdateDistance(t *testing.T) { + d := make([]peer.PeerDistance, 5) + for i := range d { + d[i].Remote = newTestPeer() + d[i].Distance = uint32(i + 1) + } + + s, _ := salt.NewSalt(100 * time.Second) + + d2 := make([]peer.PeerDistance, 4) + for i := range d2 { + d2[i].Remote = d[i+1].Remote + d2[i].Distance = distance.BySalt(d[0].Remote.ID().Bytes(), d2[i].Remote.ID().Bytes(), s.GetBytes()) + } + + neighborhood := Neighborhood{ + Neighbors: d[1:], + Size: 4} + + neighborhood.UpdateDistance(d[0].Remote.ID().Bytes(), s.GetBytes()) + + assert.Equal(t, d2, neighborhood.Neighbors, "UpdateDistance") +} + +func TestGetPeers(t *testing.T) { + d := make([]peer.PeerDistance, 4) + peers := make([]*peer.Peer, 4) + + for i := range d { + d[i].Remote = newTestPeer() + d[i].Distance = uint32(i + 1) + peers[i] = d[i].Remote + } + + type testCase struct { + input *Neighborhood + expected []*peer.Peer + } + + tests := []testCase{ + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{}, + Size: 4}, + expected: []*peer.Peer{}, + }, + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0]}, + Size: 4}, + expected: []*peer.Peer{peers[0]}, + }, + { + input: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0], d[1], d[3], d[2]}, + Size: 4}, + expected: []*peer.Peer{peers[0], peers[1], peers[3], peers[2]}, + }, + } + + for _, test := range tests { + got := test.input.GetPeers() + assert.Equal(t, test.expected, got, "GetPeers") + } +} diff --git a/packages/autopeering/selection/proto/message.go b/packages/autopeering/selection/proto/message.go new file mode 100644 index 0000000000..3e1516a641 --- /dev/null +++ b/packages/autopeering/selection/proto/message.go @@ -0,0 +1,35 @@ +package proto + +import ( + "github.com/golang/protobuf/proto" + "github.com/iotaledger/goshimmer/packages/autopeering/server" +) + +// MType is the type of message type enum. +type MType = server.MType + +// An enum for the different message types. +const ( + MPeeringRequest MType = 20 + iota + MPeeringResponse + MPeeringDrop +) + +// Message extends the proto.Message interface with additional util functions. +type Message interface { + proto.Message + + // Name returns the name of the corresponding message type for debugging. + Name() string + // Type returns the type of the corresponding message as an enum. + Type() MType +} + +func (m *PeeringRequest) Name() string { return "PEERING_REQUEST" } +func (m *PeeringRequest) Type() MType { return MPeeringRequest } + +func (m *PeeringResponse) Name() string { return "PEERING_RESPONSE" } +func (m *PeeringResponse) Type() MType { return MPeeringResponse } + +func (m *PeeringDrop) Name() string { return "PEERING_DROP" } +func (m *PeeringDrop) Type() MType { return MPeeringDrop } diff --git a/packages/autopeering/selection/proto/message.pb.go b/packages/autopeering/selection/proto/message.pb.go new file mode 100644 index 0000000000..5ad6103977 --- /dev/null +++ b/packages/autopeering/selection/proto/message.pb.go @@ -0,0 +1,207 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: selection/proto/message.proto + +package proto + +import ( + fmt "fmt" + math "math" + + proto "github.com/golang/protobuf/proto" + proto1 "github.com/iotaledger/goshimmer/packages/autopeering/salt/proto" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// 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 + +type PeeringRequest struct { + // string form of the recipient address + To string `protobuf:"bytes,1,opt,name=to,proto3" json:"to,omitempty"` + // unix time + Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + // salt of the requester + Salt *proto1.Salt `protobuf:"bytes,3,opt,name=salt,proto3" json:"salt,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PeeringRequest) Reset() { *m = PeeringRequest{} } +func (m *PeeringRequest) String() string { return proto.CompactTextString(m) } +func (*PeeringRequest) ProtoMessage() {} +func (*PeeringRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_e39e4329bafd72d5, []int{0} +} + +func (m *PeeringRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_PeeringRequest.Unmarshal(m, b) +} +func (m *PeeringRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_PeeringRequest.Marshal(b, m, deterministic) +} +func (m *PeeringRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_PeeringRequest.Merge(m, src) +} +func (m *PeeringRequest) XXX_Size() int { + return xxx_messageInfo_PeeringRequest.Size(m) +} +func (m *PeeringRequest) XXX_DiscardUnknown() { + xxx_messageInfo_PeeringRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_PeeringRequest proto.InternalMessageInfo + +func (m *PeeringRequest) GetTo() string { + if m != nil { + return m.To + } + return "" +} + +func (m *PeeringRequest) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +func (m *PeeringRequest) GetSalt() *proto1.Salt { + if m != nil { + return m.Salt + } + return nil +} + +type PeeringResponse struct { + // hash of the corresponding request + ReqHash []byte `protobuf:"bytes,1,opt,name=req_hash,json=reqHash,proto3" json:"req_hash,omitempty"` + // response of a peering request + Status bool `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PeeringResponse) Reset() { *m = PeeringResponse{} } +func (m *PeeringResponse) String() string { return proto.CompactTextString(m) } +func (*PeeringResponse) ProtoMessage() {} +func (*PeeringResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_e39e4329bafd72d5, []int{1} +} + +func (m *PeeringResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_PeeringResponse.Unmarshal(m, b) +} +func (m *PeeringResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_PeeringResponse.Marshal(b, m, deterministic) +} +func (m *PeeringResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_PeeringResponse.Merge(m, src) +} +func (m *PeeringResponse) XXX_Size() int { + return xxx_messageInfo_PeeringResponse.Size(m) +} +func (m *PeeringResponse) XXX_DiscardUnknown() { + xxx_messageInfo_PeeringResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_PeeringResponse proto.InternalMessageInfo + +func (m *PeeringResponse) GetReqHash() []byte { + if m != nil { + return m.ReqHash + } + return nil +} + +func (m *PeeringResponse) GetStatus() bool { + if m != nil { + return m.Status + } + return false +} + +type PeeringDrop struct { + // string form of the recipient address + To string `protobuf:"bytes,1,opt,name=to,proto3" json:"to,omitempty"` + // unix time + Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *PeeringDrop) Reset() { *m = PeeringDrop{} } +func (m *PeeringDrop) String() string { return proto.CompactTextString(m) } +func (*PeeringDrop) ProtoMessage() {} +func (*PeeringDrop) Descriptor() ([]byte, []int) { + return fileDescriptor_e39e4329bafd72d5, []int{2} +} + +func (m *PeeringDrop) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_PeeringDrop.Unmarshal(m, b) +} +func (m *PeeringDrop) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_PeeringDrop.Marshal(b, m, deterministic) +} +func (m *PeeringDrop) XXX_Merge(src proto.Message) { + xxx_messageInfo_PeeringDrop.Merge(m, src) +} +func (m *PeeringDrop) XXX_Size() int { + return xxx_messageInfo_PeeringDrop.Size(m) +} +func (m *PeeringDrop) XXX_DiscardUnknown() { + xxx_messageInfo_PeeringDrop.DiscardUnknown(m) +} + +var xxx_messageInfo_PeeringDrop proto.InternalMessageInfo + +func (m *PeeringDrop) GetTo() string { + if m != nil { + return m.To + } + return "" +} + +func (m *PeeringDrop) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +func init() { + proto.RegisterType((*PeeringRequest)(nil), "proto.PeeringRequest") + proto.RegisterType((*PeeringResponse)(nil), "proto.PeeringResponse") + proto.RegisterType((*PeeringDrop)(nil), "proto.PeeringDrop") +} + +func init() { proto.RegisterFile("selection/proto/message.proto", fileDescriptor_e39e4329bafd72d5) } + +var fileDescriptor_e39e4329bafd72d5 = []byte{ + // 243 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x94, 0x90, 0xc1, 0x4b, 0xf3, 0x40, + 0x10, 0xc5, 0x69, 0xfb, 0x7d, 0xb5, 0x9d, 0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5, 0x8e, 0x5a, 0xed, + 0x48, 0x6c, 0x83, 0x9f, 0x15, 0x06, 0x6d, 0x7b, 0x21, 0x3f, 0x60, 0xef, 0xd8, 0xb5, 0xfa, 0xd7, + 0x21, 0xb7, 0xf3, 0x34, 0x1e, 0xbe, 0x02, 0x00, 0x00, 0xff, 0xff, 0x3e, 0x1b, 0x76, 0xbe, 0x62, + 0x01, 0x00, 0x00, +} diff --git a/packages/autopeering/selection/proto/message.proto b/packages/autopeering/selection/proto/message.proto new file mode 100644 index 0000000000..0e0709514e --- /dev/null +++ b/packages/autopeering/selection/proto/message.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; + +option go_package = "github.com/iotaledger/goshimmer/packages/autopeering/selection/proto"; + +package proto; + +import "salt/proto/salt.proto"; + +message PeeringRequest { + // string form of the recipient address + string to = 1; + // unix time + int64 timestamp = 2; + // salt of the requester + Salt salt = 3; +} + +message PeeringResponse { + // hash of the corresponding request + bytes req_hash = 1; + // response of a peering request + bool status = 2; +} + +message PeeringDrop { + // string form of the recipient address + string to = 1; + // unix time + int64 timestamp = 2; +} diff --git a/packages/autopeering/selection/protocol.go b/packages/autopeering/selection/protocol.go new file mode 100644 index 0000000000..3b4b36c1a5 --- /dev/null +++ b/packages/autopeering/selection/protocol.go @@ -0,0 +1,338 @@ +package selection + +import ( + "bytes" + "sync" + "time" + + "github.com/golang/protobuf/proto" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/salt" + pb "github.com/iotaledger/goshimmer/packages/autopeering/selection/proto" + "github.com/iotaledger/goshimmer/packages/autopeering/server" + "github.com/pkg/errors" + "go.uber.org/zap" +) + +// DiscoverProtocol specifies the methods from the peer discovery that are required. +type DiscoverProtocol interface { + IsVerified(id peer.ID, addr string) bool + EnsureVerified(*peer.Peer) + + GetVerifiedPeer(id peer.ID, addr string) *peer.Peer + GetVerifiedPeers() []*peer.Peer +} + +// The Protocol handles the neighbor selection. +// It responds to incoming messages and sends own requests when needed. +type Protocol struct { + server.Protocol + + disc DiscoverProtocol // reference to the peer discovery to query verified peers + loc *peer.Local // local peer that runs the protocol + log *zap.SugaredLogger // logging + + mgr *manager // the manager handles the actual neighbor selection + closeOnce sync.Once +} + +// New creates a new neighbor selection protocol. +func New(local *peer.Local, disc DiscoverProtocol, cfg Config) *Protocol { + p := &Protocol{ + Protocol: server.Protocol{}, + loc: local, + disc: disc, + log: cfg.Log, + } + p.mgr = newManager(p, disc.GetVerifiedPeers, cfg.Log.Named("mgr"), cfg.Param) + + return p +} + +// Local returns the associated local peer of the neighbor selection. +func (p *Protocol) local() *peer.Local { + return p.loc +} + +// Start starts the actual neighbor selection over the provided Sender. +func (p *Protocol) Start(s server.Sender) { + p.Protocol.Sender = s + p.mgr.start() + + p.log.Debugw("neighborhood started", + "addr", s.LocalAddr(), + ) +} + +// Close finalizes the protocol. +func (p *Protocol) Close() { + p.closeOnce.Do(func() { + p.mgr.close() + }) +} + +// GetNeighbors returns the current neighbors. +func (p *Protocol) GetNeighbors() []*peer.Peer { + return p.mgr.getNeighbors() +} + +// GetIncomingNeighbors returns the current incoming neighbors. +func (p *Protocol) GetIncomingNeighbors() []*peer.Peer { + return p.mgr.getIncomingNeighbors() +} + +// GetOutgoingNeighbors returns the current outgoing neighbors. +func (p *Protocol) GetOutgoingNeighbors() []*peer.Peer { + return p.mgr.getOutgoingNeighbors() +} + +// HandleMessage responds to incoming neighbor selection messages. +func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer.ID, fromKey peer.PublicKey, data []byte) (bool, error) { + switch pb.MType(data[0]) { + + // PeeringRequest + case pb.MPeeringRequest: + m := new(pb.PeeringRequest) + if err := proto.Unmarshal(data[1:], m); err != nil { + return true, errors.Wrap(err, "invalid message") + } + if p.validatePeeringRequest(s, fromAddr, fromID, m) { + p.handlePeeringRequest(s, fromAddr, fromID, data, m) + } + + // PeeringResponse + case pb.MPeeringResponse: + m := new(pb.PeeringResponse) + if err := proto.Unmarshal(data[1:], m); err != nil { + return true, errors.Wrap(err, "invalid message") + } + p.validatePeeringResponse(s, fromAddr, fromID, m) + // PeeringResponse messages are handled in the handleReply function of the validation + + // PeeringDrop + case pb.MPeeringDrop: + m := new(pb.PeeringDrop) + if err := proto.Unmarshal(data[1:], m); err != nil { + return true, errors.Wrap(err, "invalid message") + } + if p.validatePeeringDrop(s, fromAddr, m) { + p.handlePeeringDrop(fromID) + } + + default: + return false, nil + } + + return true, nil +} + +// ------ message senders ------ + +// RequestPeering sends a peering request to the given peer. This method blocks +// until a response is received and the status answer is returned. +func (p *Protocol) RequestPeering(to *peer.Peer, salt *salt.Salt) (bool, error) { + p.disc.EnsureVerified(to) + + // create the request package + toAddr := to.Address() + req := newPeeringRequest(toAddr, salt) + data := marshal(req) + + // compute the message hash + hash := server.PacketHash(data) + + var status bool + callback := func(m interface{}) bool { + res := m.(*pb.PeeringResponse) + if !bytes.Equal(res.GetReqHash(), hash) { + return false + } + status = res.GetStatus() + return true + } + + p.log.Debugw("send message", + "type", req.Name(), + "addr", toAddr, + ) + err := <-p.Protocol.SendExpectingReply(toAddr, to.ID(), data, pb.MPeeringResponse, callback) + + return status, err +} + +// DropPeer sends a PeeringDrop to the given peer. +func (p *Protocol) DropPeer(to *peer.Peer) { + p.mgr.dropNeighbor(to.ID()) + + toAddr := to.Address() + drop := newPeeringDrop(toAddr) + + p.log.Debugw("send message", + "type", drop.Name(), + "addr", toAddr, + ) + p.Protocol.Send(to, marshal(drop)) +} + +// ------ helper functions ------ + +func marshal(msg pb.Message) []byte { + mType := msg.Type() + if mType > 0xFF { + panic("invalid message") + } + + data, err := proto.Marshal(msg) + if err != nil { + panic("invalid message") + } + return append([]byte{byte(mType)}, data...) +} + +// ------ Packet Constructors ------ + +func newPeeringRequest(toAddr string, salt *salt.Salt) *pb.PeeringRequest { + return &pb.PeeringRequest{ + To: toAddr, + Timestamp: time.Now().Unix(), + Salt: salt.ToProto(), + } +} + +func newPeeringResponse(reqData []byte, status bool) *pb.PeeringResponse { + return &pb.PeeringResponse{ + ReqHash: server.PacketHash(reqData), + Status: status, + } +} + +func newPeeringDrop(toAddr string) *pb.PeeringDrop { + return &pb.PeeringDrop{ + To: toAddr, + Timestamp: time.Now().Unix(), + } +} + +// ------ Packet Handlers ------ + +func (p *Protocol) validatePeeringRequest(s *server.Server, fromAddr string, fromID peer.ID, m *pb.PeeringRequest) bool { + // check that To matches the local address + if m.GetTo() != s.LocalAddr() { + p.log.Debugw("invalid message", + "type", m.Name(), + "to", m.GetTo(), + ) + return false + } + // check Timestamp + if p.Protocol.IsExpired(m.GetTimestamp()) { + p.log.Debugw("invalid message", + "type", m.Name(), + "timestamp", time.Unix(m.GetTimestamp(), 0), + ) + return false + } + // check whether the sender is verified + if !p.disc.IsVerified(fromID, fromAddr) { + p.log.Debugw("invalid message", + "type", m.Name(), + "unverified", fromAddr, + ) + return false + } + // check Salt + salt, err := salt.FromProto(m.GetSalt()) + if err != nil { + p.log.Debugw("invalid message", + "type", m.Name(), + "salt", err, + ) + return false + } + // check salt expiration + if salt.Expired() { + p.log.Debugw("invalid message", + "type", m.Name(), + "salt.expiration", salt.GetExpiration(), + ) + return false + } + + p.log.Debugw("valid message", + "type", m.Name(), + "addr", fromAddr, + ) + return true +} + +func (p *Protocol) handlePeeringRequest(s *server.Server, fromAddr string, fromID peer.ID, rawData []byte, m *pb.PeeringRequest) { + salt, err := salt.FromProto(m.GetSalt()) + if err != nil { + // this should not happen as it is checked in validation + p.log.Warnw("invalid salt", "err", err) + return + } + + from := p.disc.GetVerifiedPeer(fromID, fromAddr) + if from == nil { + // this should not happen as it is checked in validation + p.log.Warnw("invalid stored peer", + "id", fromID, + ) + return + } + + res := newPeeringResponse(rawData, p.mgr.acceptRequest(from, salt)) + + p.log.Debugw("send message", + "type", res.Name(), + "addr", fromAddr, + ) + s.Send(fromAddr, marshal(res)) +} + +func (p *Protocol) validatePeeringResponse(s *server.Server, fromAddr string, fromID peer.ID, m *pb.PeeringResponse) bool { + // there must be a request waiting for this response + if !s.IsExpectedReply(fromAddr, fromID, m.Type(), m) { + p.log.Debugw("invalid message", + "type", m.Name(), + "unexpected", fromAddr, + ) + return false + } + + p.log.Debugw("valid message", + "type", m.Name(), + "addr", fromAddr, + ) + return true +} + +func (p *Protocol) validatePeeringDrop(s *server.Server, fromAddr string, m *pb.PeeringDrop) bool { + // check that To matches the local address + if m.GetTo() != s.LocalAddr() { + p.log.Debugw("invalid message", + "type", m.Name(), + "to", m.GetTo(), + ) + return false + } + // check Timestamp + if p.Protocol.IsExpired(m.GetTimestamp()) { + p.log.Debugw("invalid message", + "type", m.Name(), + "timestamp", time.Unix(m.GetTimestamp(), 0), + ) + return false + } + + p.log.Debugw("valid message", + "type", m.Name(), + "addr", fromAddr, + ) + return true +} + +func (p *Protocol) handlePeeringDrop(fromID peer.ID) { + p.mgr.dropNeighbor(fromID) +} diff --git a/packages/autopeering/selection/protocol_test.go b/packages/autopeering/selection/protocol_test.go new file mode 100644 index 0000000000..2d3a129582 --- /dev/null +++ b/packages/autopeering/selection/protocol_test.go @@ -0,0 +1,186 @@ +package selection + +import ( + "log" + "testing" + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/discover" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/salt" + "github.com/iotaledger/goshimmer/packages/autopeering/server" + "github.com/iotaledger/goshimmer/packages/autopeering/transport" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.uber.org/zap" +) + +const graceTime = 100 * time.Millisecond + +var logger *zap.SugaredLogger + +func init() { + l, err := zap.NewDevelopment() + if err != nil { + log.Fatalf("cannot initialize logger: %v", err) + } + logger = l.Sugar() +} + +var peerMap = make(map[peer.ID]*peer.Peer) + +// dummyDiscovery is a dummy implementation of DiscoveryProtocol never returning any verified peers. +type dummyDiscovery struct{} + +func (d dummyDiscovery) IsVerified(peer.ID, string) bool { return true } +func (d dummyDiscovery) EnsureVerified(*peer.Peer) {} +func (d dummyDiscovery) GetVerifiedPeer(id peer.ID, addr string) *peer.Peer { return peerMap[id] } +func (d dummyDiscovery) GetVerifiedPeers() []*peer.Peer { return []*peer.Peer{} } + +// newTest creates a new neighborhood server and also returns the teardown. +func newTest(t require.TestingT, trans transport.Transport, logger *zap.SugaredLogger) (*server.Server, *Protocol, func()) { + log := logger.Named(trans.LocalAddr().String()) + db := peer.NewMemoryDB(log.Named("db")) + local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) + require.NoError(t, err) + + // add the new peer to the global map for dummyDiscovery + peerMap[local.ID()] = &local.Peer + + cfg := Config{ + Log: log, + } + prot := New(local, dummyDiscovery{}, cfg) + srv := server.Listen(local, trans, log.Named("srv"), prot) + prot.Start(srv) + + teardown := func() { + srv.Close() + prot.Close() + db.Close() + } + return srv, prot, teardown +} + +func getPeer(s *server.Server) *peer.Peer { + return &s.Local().Peer +} + +func TestProtPeeringRequest(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() + + srvA, protA, closeA := newTest(t, p2p.A, logger) + defer closeA() + srvB, protB, closeB := newTest(t, p2p.B, logger) + defer closeB() + + peerA := getPeer(srvA) + saltA, _ := salt.NewSalt(100 * time.Second) + peerB := getPeer(srvB) + saltB, _ := salt.NewSalt(100 * time.Second) + + // request peering to peer B + t.Run("A->B", func(t *testing.T) { + if services, err := protA.RequestPeering(peerB, saltA); assert.NoError(t, err) { + assert.NotEmpty(t, services) + } + }) + // request peering to peer A + t.Run("B->A", func(t *testing.T) { + if services, err := protB.RequestPeering(peerA, saltB); assert.NoError(t, err) { + assert.NotEmpty(t, services) + } + }) +} + +func TestProtExpiredSalt(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() + + _, protA, closeA := newTest(t, p2p.A, logger) + defer closeA() + srvB, _, closeB := newTest(t, p2p.B, logger) + defer closeB() + + saltA, _ := salt.NewSalt(-1 * time.Second) + peerB := getPeer(srvB) + + // request peering to peer B + _, err := protA.RequestPeering(peerB, saltA) + assert.EqualError(t, err, server.ErrTimeout.Error()) +} + +func TestProtDropPeer(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() + + srvA, protA, closeA := newTest(t, p2p.A, logger) + defer closeA() + srvB, protB, closeB := newTest(t, p2p.B, logger) + defer closeB() + + peerA := getPeer(srvA) + saltA, _ := salt.NewSalt(100 * time.Second) + peerB := getPeer(srvB) + + // request peering to peer B + services, err := protA.RequestPeering(peerB, saltA) + require.NoError(t, err) + assert.NotEmpty(t, services) + + require.Contains(t, protB.GetNeighbors(), peerA) + + // drop peer A + protA.DropPeer(peerB) + time.Sleep(graceTime) + require.NotContains(t, protB.GetNeighbors(), peerA) +} + +// newTest creates a new server handling discover as well as neighborhood and also returns the teardown. +func newFullTest(t require.TestingT, trans transport.Transport, masterPeers ...*peer.Peer) (*server.Server, *Protocol, func()) { + log := logger.Named(trans.LocalAddr().String()) + db := peer.NewMemoryDB(log.Named("db")) + local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) + require.NoError(t, err) + + discovery := discover.New(local, discover.Config{ + Log: log.Named("disc"), + MasterPeers: masterPeers, + }) + selection := New(local, discovery, Config{ + Log: log.Named("sel"), + }) + + srv := server.Listen(local, trans, log.Named("srv"), discovery, selection) + + discovery.Start(srv) + selection.Start(srv) + + teardown := func() { + srv.Close() + selection.Close() + discovery.Close() + db.Close() + } + return srv, selection, teardown +} + +func TestProtFull(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() + + srvA, protA, closeA := newFullTest(t, p2p.A) + defer closeA() + + time.Sleep(graceTime) // wait for the master to initialize + + srvB, protB, closeB := newFullTest(t, p2p.B, getPeer(srvA)) + defer closeB() + + time.Sleep(updateOutboundInterval + graceTime) // wait for the next outbound cycle + + // the two peers should be peered + assert.ElementsMatch(t, []*peer.Peer{getPeer(srvB)}, protA.GetNeighbors()) + assert.ElementsMatch(t, []*peer.Peer{getPeer(srvA)}, protB.GetNeighbors()) +} diff --git a/packages/autopeering/selection/selection.go b/packages/autopeering/selection/selection.go new file mode 100644 index 0000000000..f97acbdbb3 --- /dev/null +++ b/packages/autopeering/selection/selection.go @@ -0,0 +1,73 @@ +package selection + +import ( + "sync" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" +) + +type Selector interface { + Select(candidates peer.PeerDistance) *peer.Peer +} + +type Filter struct { + internal map[peer.ID]bool + lock sync.RWMutex +} + +func NewFilter() *Filter { + return &Filter{ + internal: make(map[peer.ID]bool), + } +} + +func (f *Filter) Apply(list []peer.PeerDistance) (filteredList []peer.PeerDistance) { + f.lock.RLock() + defer f.lock.RUnlock() + for _, peer := range list { + if !f.internal[peer.Remote.ID()] { + filteredList = append(filteredList, peer) + } + } + return filteredList +} + +func (f *Filter) PushBack(list []peer.PeerDistance) (filteredList []peer.PeerDistance) { + var head, tail []peer.PeerDistance + f.lock.RLock() + defer f.lock.RUnlock() + for _, peer := range list { + if f.internal[peer.Remote.ID()] { + tail = append(tail, peer) + } else { + head = append(head, peer) + } + } + return append(head, tail...) +} + +func (f *Filter) AddPeers(n []*peer.Peer) { + f.lock.Lock() + for _, peer := range n { + f.internal[peer.ID()] = true + } + f.lock.Unlock() +} + +func (f *Filter) AddPeer(peer peer.ID) { + f.lock.Lock() + f.internal[peer] = true + f.lock.Unlock() +} + +func (f *Filter) RemovePeer(peer peer.ID) { + f.lock.Lock() + f.internal[peer] = false + f.lock.Unlock() +} + +func (f *Filter) Clean() { + f.lock.Lock() + f.internal = make(map[peer.ID]bool) + f.lock.Unlock() +} diff --git a/packages/autopeering/selection/selection_test.go b/packages/autopeering/selection/selection_test.go new file mode 100644 index 0000000000..cdd89874aa --- /dev/null +++ b/packages/autopeering/selection/selection_test.go @@ -0,0 +1,182 @@ +package selection + +import ( + "crypto/ed25519" + "testing" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/stretchr/testify/assert" +) + +const ( + testNetwork = "udp" + testAddress = "127.0.0.1:8000" +) + +func newTestServiceRecord() *service.Record { + services := service.New() + services.Update(service.PeeringKey, testNetwork, testAddress) + + return services +} + +func newTestPeer() *peer.Peer { + key, _, _ := ed25519.GenerateKey(nil) + return peer.NewPeer(peer.PublicKey(key), newTestServiceRecord()) +} + +func TestFilterAddPeers(t *testing.T) { + p := make([]*peer.Peer, 5) + for i := range p { + p[i] = newTestPeer() + } + + type testCase struct { + input []*peer.Peer + notExist []*peer.Peer + } + + tests := []testCase{ + { + input: []*peer.Peer{p[0]}, + notExist: []*peer.Peer{p[1]}, + }, + { + input: []*peer.Peer{p[0], p[1], p[2]}, + notExist: []*peer.Peer{p[3], p[4]}, + }, + } + + for _, test := range tests { + f := NewFilter() + f.AddPeers(test.input) + for _, e := range test.input { + assert.Equal(t, true, f.internal[e.ID()], "Filter add peers") + } + + for _, e := range test.notExist { + assert.Equal(t, false, f.internal[e.ID()], "Filter add peers") + } + } +} + +func TestFilterRemovePeers(t *testing.T) { + p := make([]*peer.Peer, 5) + for i := range p { + p[i] = newTestPeer() + } + + type testCase struct { + input []*peer.Peer + toRemove *peer.Peer + left []*peer.Peer + } + + tests := []testCase{ + { + input: []*peer.Peer{p[0]}, + toRemove: p[0], + left: []*peer.Peer{}, + }, + { + input: []*peer.Peer{p[0], p[1], p[2]}, + toRemove: p[1], + left: []*peer.Peer{p[0], p[2]}, + }, + } + + for _, test := range tests { + f := NewFilter() + f.AddPeers(test.input) + f.RemovePeer(test.toRemove.ID()) + for _, e := range test.left { + assert.Equal(t, true, f.internal[e.ID()], "Filter remove peers") + } + assert.Equal(t, false, f.internal[test.toRemove.ID()], "Filter remove peers") + } +} + +func TestFilterApply(t *testing.T) { + d := make([]peer.PeerDistance, 5) + for i := range d { + d[i].Remote = newTestPeer() + d[i].Distance = uint32(i + 1) + } + + type testCase struct { + input []*peer.Peer + apply []peer.PeerDistance + expected []peer.PeerDistance + } + + tests := []testCase{ + { + input: []*peer.Peer{d[0].Remote}, + apply: []peer.PeerDistance{d[0], d[1], d[2]}, + expected: []peer.PeerDistance{d[1], d[2]}, + }, + { + input: []*peer.Peer{d[0].Remote, d[1].Remote}, + apply: []peer.PeerDistance{d[2], d[3], d[4]}, + expected: []peer.PeerDistance{d[2], d[3], d[4]}, + }, + } + + for _, test := range tests { + f := NewFilter() + f.AddPeers(test.input) + filteredList := f.Apply(test.apply) + assert.Equal(t, test.expected, filteredList, "Filter apply") + } +} + +func TestSelection(t *testing.T) { + d := make([]peer.PeerDistance, 10) + for i := range d { + d[i].Remote = newTestPeer() + d[i].Distance = uint32(i + 1) + } + + type testCase struct { + nh *Neighborhood + expCandidate *peer.Peer + } + + tests := []testCase{ + { + nh: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0]}, + Size: 4}, + expCandidate: d[1].Remote, + }, + { + nh: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0], d[1], d[3]}, + Size: 4}, + expCandidate: d[2].Remote, + }, + { + nh: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, + Size: 4}, + expCandidate: d[3].Remote, + }, + { + nh: &Neighborhood{ + Neighbors: []peer.PeerDistance{d[0], d[1], d[2], d[3]}, + Size: 4}, + expCandidate: nil, + }, + } + + for _, test := range tests { + filter := NewFilter() + filter.AddPeers(test.nh.GetPeers()) + fList := filter.Apply(d) + + got := test.nh.Select(fList) + + assert.Equal(t, test.expCandidate, got.Remote, "Next Candidate", test) + } +} diff --git a/packages/autopeering/server/common.go b/packages/autopeering/server/common.go new file mode 100644 index 0000000000..4defddc2db --- /dev/null +++ b/packages/autopeering/server/common.go @@ -0,0 +1,41 @@ +package server + +import ( + "crypto/sha256" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" +) + +// MType is the type of message type enum. +type MType uint + +// The Sender interface specifies common method required to send requests. +type Sender interface { + LocalAddr() string + LocalNetwork() string + + Send(toAddr string, data []byte) + SendExpectingReply(toAddr string, toID peer.ID, data []byte, replyType MType, callback func(interface{}) bool) <-chan error +} + +// A Handler reacts to an incoming message. +type Handler interface { + // HandleMessage is called for each incoming message. + // It returns true, if that particular message type can be processed by the current Handler. + HandleMessage(s *Server, fromAddr string, fromID peer.ID, fromKey peer.PublicKey, data []byte) (bool, error) +} + +// The HandlerFunc type is an adapter to allow the use of ordinary functions as Server handlers. +// If f is a function with the appropriate signature, HandlerFunc(f) is a Handler that calls f. +type HandlerFunc func(*Server, string, peer.ID, peer.PublicKey, []byte) (bool, error) + +// HandleMessage returns f(s, from, data). +func (f HandlerFunc) HandleMessage(s *Server, fromAddr string, fromID peer.ID, fromKey peer.PublicKey, data []byte) (bool, error) { + return f(s, fromAddr, fromID, fromKey, data) +} + +// PacketHash returns the hash of a packet +func PacketHash(data []byte) []byte { + sum := sha256.Sum256(data) + return sum[:] +} diff --git a/packages/autopeering/server/errors.go b/packages/autopeering/server/errors.go new file mode 100644 index 0000000000..54c5d51a35 --- /dev/null +++ b/packages/autopeering/server/errors.go @@ -0,0 +1,17 @@ +package server + +import "github.com/pkg/errors" + +var ( + // ErrTimeout is returned when an expected response was not received in time. + ErrTimeout = errors.New("response timeout") + + // ErrClosed means that the server was shut down before a response could be received. + ErrClosed = errors.New("socket closed") + + // ErrNoMessage is returned when the package did not contain any data. + ErrNoMessage = errors.New("packet does not contain a message") + + // ErrInvalidMessage means that no handler could process the received message. + ErrInvalidMessage = errors.New("invalid message") +) diff --git a/packages/autopeering/server/proto/packet.pb.go b/packages/autopeering/server/proto/packet.pb.go new file mode 100644 index 0000000000..9c8dd1f523 --- /dev/null +++ b/packages/autopeering/server/proto/packet.pb.go @@ -0,0 +1,97 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: server/proto/packet.proto + +package proto + +import ( + fmt "fmt" + proto "github.com/golang/protobuf/proto" + math "math" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// 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 + +type Packet struct { + PublicKey []byte `protobuf:"bytes,1,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *Packet) Reset() { *m = Packet{} } +func (m *Packet) String() string { return proto.CompactTextString(m) } +func (*Packet) ProtoMessage() {} +func (*Packet) Descriptor() ([]byte, []int) { + return fileDescriptor_c39379c1dd924f72, []int{0} +} + +func (m *Packet) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_Packet.Unmarshal(m, b) +} +func (m *Packet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_Packet.Marshal(b, m, deterministic) +} +func (m *Packet) XXX_Merge(src proto.Message) { + xxx_messageInfo_Packet.Merge(m, src) +} +func (m *Packet) XXX_Size() int { + return xxx_messageInfo_Packet.Size(m) +} +func (m *Packet) XXX_DiscardUnknown() { + xxx_messageInfo_Packet.DiscardUnknown(m) +} + +var xxx_messageInfo_Packet proto.InternalMessageInfo + +func (m *Packet) GetPublicKey() []byte { + if m != nil { + return m.PublicKey + } + return nil +} + +func (m *Packet) GetSignature() []byte { + if m != nil { + return m.Signature + } + return nil +} + +func (m *Packet) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +func init() { + proto.RegisterType((*Packet)(nil), "proto.Packet") +} + +func init() { proto.RegisterFile("server/proto/packet.proto", fileDescriptor_c39379c1dd924f72) } + +var fileDescriptor_c39379c1dd924f72 = []byte{ + // 166 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0x92, 0x2c, 0x4e, 0x2d, 0x2a, + 0x4b, 0x2d, 0xd2, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x2f, 0x48, 0x4c, 0xce, 0x4e, 0x2d, 0xd1, + 0x03, 0x73, 0x84, 0x58, 0xc1, 0x94, 0x52, 0x24, 0x17, 0x5b, 0x00, 0x58, 0x58, 0x48, 0x96, 0x8b, + 0xab, 0xa0, 0x34, 0x29, 0x27, 0x33, 0x39, 0x3e, 0x3b, 0xb5, 0x52, 0x82, 0x51, 0x81, 0x51, 0x83, + 0x27, 0x88, 0x13, 0x22, 0xe2, 0x9d, 0x5a, 0x29, 0x24, 0xc3, 0xc5, 0x59, 0x9c, 0x99, 0x9e, 0x97, + 0x58, 0x52, 0x5a, 0x94, 0x2a, 0xc1, 0x04, 0x91, 0x85, 0x0b, 0x08, 0x09, 0x71, 0xb1, 0xa4, 0x24, + 0x96, 0x24, 0x4a, 0x30, 0x83, 0x25, 0xc0, 0x6c, 0x27, 0x93, 0x28, 0xa3, 0xf4, 0xcc, 0x92, 0x8c, + 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xcc, 0xfc, 0x92, 0xc4, 0x9c, 0xd4, 0x94, 0x74, 0xa0, + 0x6b, 0x12, 0x4b, 0x4b, 0xf2, 0x0b, 0x52, 0x53, 0x8b, 0x32, 0xf3, 0xd2, 0x75, 0x8b, 0x33, 0x73, + 0xf5, 0x91, 0x1d, 0x99, 0xc4, 0x06, 0xa6, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x50, 0x6a, + 0x7d, 0xb7, 0xbb, 0x00, 0x00, 0x00, +} diff --git a/packages/autopeering/server/proto/packet.proto b/packages/autopeering/server/proto/packet.proto new file mode 100644 index 0000000000..59da610d3d --- /dev/null +++ b/packages/autopeering/server/proto/packet.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +option go_package = "github.com/iotaledger/goshimmer/packages/autopeering/server/proto"; + +package proto; + +message Packet { + bytes public_key = 1; + bytes signature = 2; + bytes data = 3; +} diff --git a/packages/autopeering/server/protocol.go b/packages/autopeering/server/protocol.go new file mode 100644 index 0000000000..bab76b712f --- /dev/null +++ b/packages/autopeering/server/protocol.go @@ -0,0 +1,42 @@ +package server + +import ( + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" +) + +const ( + packetExpiration = 20 * time.Second +) + +// Protocol provides a basis for server protocols handling incoming messages. +type Protocol struct { + Sender Sender // interface to send own requests +} + +// LocalAddr returns the local network address in string form. +func (p *Protocol) LocalAddr() string { + return p.Sender.LocalAddr() +} + +// LocalNetwork returns the name of the local network (for example, "tcp", "udp"). +func (p *Protocol) LocalNetwork() string { + return p.Sender.LocalNetwork() +} + +// Send sends the data to the given peer. +func (p *Protocol) Send(to *peer.Peer, data []byte) { + p.Sender.Send(to.Address(), data) +} + +// SendExpectingReply sends request data to a peer and expects a response of the given type. +// On an incoming matching request the callback is executed to perform additional verification steps. +func (p *Protocol) SendExpectingReply(toAddr string, toID peer.ID, data []byte, replyType MType, callback func(interface{}) bool) <-chan error { + return p.Sender.SendExpectingReply(toAddr, toID, data, replyType, callback) +} + +// IsExpired checks whether the given UNIX time stamp is too far in the past. +func (p *Protocol) IsExpired(ts int64) bool { + return time.Since(time.Unix(ts, 0)) >= packetExpiration +} diff --git a/packages/autopeering/server/server.go b/packages/autopeering/server/server.go new file mode 100644 index 0000000000..50506987e8 --- /dev/null +++ b/packages/autopeering/server/server.go @@ -0,0 +1,313 @@ +package server + +import ( + "container/list" + "io" + "net" + "sync" + "time" + + "github.com/golang/protobuf/proto" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + pb "github.com/iotaledger/goshimmer/packages/autopeering/server/proto" + "github.com/iotaledger/goshimmer/packages/autopeering/transport" + "github.com/pkg/errors" + "go.uber.org/zap" +) + +const ( + // ResponseTimeout specifies the time limit after which a response must have been received. + ResponseTimeout = 500 * time.Millisecond +) + +// Server offers the functionality to start a server that handles requests and responses from peers. +type Server struct { + local *peer.Local + trans transport.Transport + handlers []Handler + log *zap.SugaredLogger + network string + address string + + closeOnce sync.Once + wg sync.WaitGroup + + addReplyMatcher chan *replyMatcher + replyReceived chan reply + closing chan struct{} // if this channel gets closed all pending waits should terminate +} + +// a replyMatcher stores the information required to identify and react to an expected replay. +type replyMatcher struct { + // fromAddr must match the sender of the reply + fromAddr string + // fromID must match the sender ID + fromID peer.ID + // mtype must match the type of the reply + mtype MType + + // deadline when the request must complete + deadline time.Time + + // callback is called when a matching reply arrives + // If it returns true, the reply is acceptable. + callback func(msg interface{}) bool + + // errc receives nil when the callback indicates completion or an + // error if no further reply is received within the timeout + errc chan error +} + +// reply is a reply packet from a certain peer +type reply struct { + fromAddr string + fromID peer.ID + mtype MType + msg interface{} // the actual reply message + matchedRequest chan<- bool // a matching request is indicated via this channel +} + +// Listen starts a new peer server using the given transport layer for communication. +// Sent data is signed using the identity of the local peer, +// received data with a valid peer signature is handled according to the provided Handler. +func Listen(local *peer.Local, t transport.Transport, log *zap.SugaredLogger, h ...Handler) *Server { + srv := &Server{ + local: local, + trans: t, + handlers: h, + log: log, + network: local.Network(), + address: local.Address(), + addReplyMatcher: make(chan *replyMatcher), + replyReceived: make(chan reply), + closing: make(chan struct{}), + } + + srv.wg.Add(2) + go srv.replyLoop() + go srv.readLoop() + + return srv +} + +// Close shuts down the server. +func (s *Server) Close() { + s.closeOnce.Do(func() { + close(s.closing) + s.trans.Close() + s.wg.Wait() + }) +} + +// Local returns the the local peer. +func (s *Server) Local() *peer.Local { + return s.local +} + +// LocalNetwork returns the network of the local peer. +func (s *Server) LocalNetwork() string { + return s.network +} + +// LocalAddr returns the address of the local peer in string form. +func (s *Server) LocalAddr() string { + return s.address +} + +// Send sends a message to the given address +func (s *Server) Send(toAddr string, data []byte) { + pkt := s.encode(data) + s.write(toAddr, pkt) +} + +// SendExpectingReply sends a message to the given address and tells the Server +// to expect a reply message with the given specifications. +// If eventually nil is returned, a matching message was received. +func (s *Server) SendExpectingReply(toAddr string, toID peer.ID, data []byte, replyType MType, callback func(interface{}) bool) <-chan error { + errc := s.expectReply(toAddr, toID, replyType, callback) + s.Send(toAddr, data) + + return errc +} + +// expectReply tells the Server to expect a reply message with the given specifications. +// If eventually nil is returned, a matching message was received. +func (s *Server) expectReply(fromAddr string, fromID peer.ID, mtype MType, callback func(interface{}) bool) <-chan error { + ch := make(chan error, 1) + m := &replyMatcher{fromAddr: fromAddr, fromID: fromID, mtype: mtype, callback: callback, errc: ch} + select { + case s.addReplyMatcher <- m: + case <-s.closing: + ch <- ErrClosed + } + return ch +} + +// IsExpectedReply checks whether the given Message matches an expected reply added with SendExpectingReply. +func (s *Server) IsExpectedReply(fromAddr string, fromID peer.ID, mtype MType, msg interface{}) bool { + matched := make(chan bool, 1) + select { + case s.replyReceived <- reply{fromAddr, fromID, mtype, msg, matched}: + // wait for matcher and return whether a matching request was found + return <-matched + case <-s.closing: + return false + } +} + +// Loop checking for matching replies. +func (s *Server) replyLoop() { + defer s.wg.Done() + + var ( + matcherList = list.New() + timeout = time.NewTimer(0) + ) + defer timeout.Stop() + + <-timeout.C // ignore first timeout + + for { + + // Set the timer so that it fires when the next reply expires + if e := matcherList.Front(); e != nil { + // the first element always has the closest deadline + m := e.Value.(*replyMatcher) + timeout.Reset(time.Until(m.deadline)) + } else { + timeout.Stop() + } + + select { + + // add a new matcher to the list + case s := <-s.addReplyMatcher: + s.deadline = time.Now().Add(ResponseTimeout) + matcherList.PushBack(s) + + // on reply received, check all matchers for fits + case r := <-s.replyReceived: + matched := false + for e := matcherList.Front(); e != nil; e = e.Next() { + m := e.Value.(*replyMatcher) + if m.mtype == r.mtype && m.fromID == r.fromID && m.fromAddr == r.fromAddr { + if m.callback(r.msg) { + // request has been matched + matched = true + m.errc <- nil + matcherList.Remove(e) + } + } + } + r.matchedRequest <- matched + + // on timeout, check for expired matchers + case <-timeout.C: + now := time.Now() + + // notify and remove any expired matchers + for e := matcherList.Front(); e != nil; e = e.Next() { + m := e.Value.(*replyMatcher) + if now.After(m.deadline) || now.Equal(m.deadline) { + m.errc <- ErrTimeout + matcherList.Remove(e) + } + } + + // on close, notice all the matchers + case <-s.closing: + for e := matcherList.Front(); e != nil; e = e.Next() { + e.Value.(*replyMatcher).errc <- ErrClosed + } + return + + } + } +} + +func (s *Server) write(toAddr string, pkt *pb.Packet) { + b, err := proto.Marshal(pkt) + if err != nil { + s.log.Error("marshal error", "err", err) + return + } + if l := len(b); l > transport.MaxPacketSize { + s.log.Error("packet too large", "size", l, "max", transport.MaxPacketSize) + return + } + + err = s.trans.WriteTo(b, toAddr) + s.log.Debugw("write packet", "addr", toAddr, "size", len(b), "err", err) +} + +// encodes a message as a data packet that can be written. +func (s *Server) encode(data []byte) *pb.Packet { + if len(data) == 0 { + panic("server: no data") + } + + return &pb.Packet{ + PublicKey: s.local.PublicKey(), + Signature: s.local.Sign(data), + Data: append([]byte(nil), data...), + } +} + +func (s *Server) readLoop() { + defer s.wg.Done() + + for { + b, fromAddr, err := s.trans.ReadFrom() + if nerr, ok := err.(net.Error); ok && nerr.Temporary() { + // ignore temporary read errors. + s.log.Debugw("temporary read error", "err", err) + continue + } + if err != nil { + // return from the loop on all other errors + if err != io.EOF { + s.log.Warnw("read error", "err", err) + } + s.log.Debug("reading stopped") + return + } + + pkt := new(pb.Packet) + if err := proto.Unmarshal(b, pkt); err != nil { + s.log.Debugw("packet error", "err", err) + return + } + if err := s.handlePacket(pkt, fromAddr); err != nil { + s.log.Debugw("failed to handle packet", "from", fromAddr, "err", err) + } + } +} + +func (s *Server) handlePacket(pkt *pb.Packet, fromAddr string) error { + data, key, err := decode(pkt) + if err != nil { + return errors.Wrap(err, "invalid packet") + } + + fromID := key.ID() + s.log.Debugw("handlePacket", "addr", fromAddr, "id", fromID) + for _, handler := range s.handlers { + ok, err := handler.HandleMessage(s, fromAddr, fromID, key, data) + if ok { + return err + } + } + return ErrInvalidMessage +} + +func decode(pkt *pb.Packet) ([]byte, peer.PublicKey, error) { + if len(pkt.GetData()) == 0 { + return nil, nil, ErrNoMessage + } + + key, err := peer.RecoverKeyFromSignedData(pkt) + if err != nil { + return nil, nil, err + } + return pkt.GetData(), key, nil +} diff --git a/packages/autopeering/server/server_test.go b/packages/autopeering/server/server_test.go new file mode 100644 index 0000000000..80f3627473 --- /dev/null +++ b/packages/autopeering/server/server_test.go @@ -0,0 +1,218 @@ +package server + +import ( + "log" + "testing" + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/salt" + "github.com/iotaledger/goshimmer/packages/autopeering/transport" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + "go.uber.org/zap" +) + +const graceTime = 5 * time.Millisecond + +var logger *zap.SugaredLogger + +func init() { + l, err := zap.NewDevelopment() + if err != nil { + log.Fatalf("cannot initialize logger: %v", err) + } + logger = l.Sugar() +} + +const ( + MPing MType = iota + MPong +) + +type Message interface { + Type() MType + Marshal() []byte +} + +type Ping struct{} +type Pong struct{} + +func (m *Ping) Type() MType { return MPing } +func (m *Ping) Marshal() []byte { return append([]byte{}, byte(MPing)) } + +func (m *Pong) Type() MType { return MPong } +func (m *Pong) Marshal() []byte { return append([]byte{}, byte(MPong)) } + +func sendPong(args mock.Arguments) { + srv := args.Get(0).(*Server) + addr := args.Get(1).(string) + srv.Send(addr, new(Pong).Marshal()) +} + +var ( + pingMock *mock.Mock + pongMock *mock.Mock +) + +func setupTest() func(t *testing.T) { + pingMock = new(mock.Mock) + pongMock = new(mock.Mock) + + return func(t *testing.T) { + pingMock.AssertExpectations(t) + pingMock = nil + pongMock.AssertExpectations(t) + pongMock = nil + } +} + +func handle(s *Server, fromAddr string, fromID peer.ID, fromKey peer.PublicKey, data []byte) (bool, error) { + msg, err := unmarshal(data) + if err != nil { + return false, err + } + + switch msg.Type() { + case MPing: + pingMock.Called(s, fromAddr, fromID, fromKey, data) + + case MPong: + if s.IsExpectedReply(fromAddr, fromID, MPong, msg) { + pongMock.Called(s, fromAddr, fromID, fromKey, data) + } + + default: + panic("unknown message type") + } + + return true, nil +} + +func unmarshal(data []byte) (Message, error) { + if len(data) != 1 { + return nil, ErrInvalidMessage + } + + switch MType(data[0]) { + case MPing: + return new(Ping), nil + case MPong: + return new(Pong), nil + } + return nil, ErrInvalidMessage +} + +func TestSrvEncodeDecodePing(t *testing.T) { + // create minimal server just containing the local peer + local, err := peer.NewLocal("dummy", "local", peer.NewMemoryDB(logger)) + require.NoError(t, err) + s := &Server{local: local} + + ping := new(Ping) + packet := s.encode(ping.Marshal()) + + data, key, err := decode(packet) + require.NoError(t, err) + + msg, _ := unmarshal(data) + assert.Equal(t, local.ID(), key.ID()) + assert.Equal(t, msg, ping) +} + +func newTestServer(t require.TestingT, name string, trans transport.Transport, logger *zap.SugaredLogger) (*Server, func()) { + log := logger.Named(name) + db := peer.NewMemoryDB(log.Named("db")) + local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) + require.NoError(t, err) + + s, _ := salt.NewSalt(100 * time.Second) + local.SetPrivateSalt(s) + s, _ = salt.NewSalt(100 * time.Second) + local.SetPublicSalt(s) + + srv := Listen(local, trans, logger.Named(name), HandlerFunc(handle)) + + teardown := func() { + srv.Close() + db.Close() + } + return srv, teardown +} + +func sendPing(s *Server, p *peer.Peer) error { + ping := new(Ping) + isPong := func(msg interface{}) bool { + _, ok := msg.(*Pong) + return ok + } + + errc := s.SendExpectingReply(p.Address(), p.ID(), ping.Marshal(), MPong, isPong) + return <-errc +} + +func TestPingPong(t *testing.T) { + p2p := transport.P2P() + + srvA, closeA := newTestServer(t, "A", p2p.A, logger) + defer closeA() + srvB, closeB := newTestServer(t, "B", p2p.B, logger) + defer closeB() + + peerA := &srvA.Local().Peer + peerB := &srvB.Local().Peer + + t.Run("A->B", func(t *testing.T) { + defer setupTest()(t) + + // B expects valid ping from A and sends pong back + pingMock.On("handle", srvB, peerA.Address(), peerA.ID(), peerA.PublicKey(), mock.Anything).Run(sendPong).Once() + // A expects valid pong from B + pongMock.On("handle", srvA, peerB.Address(), peerB.ID(), peerB.PublicKey(), mock.Anything).Once() + + assert.NoError(t, sendPing(srvA, peerB)) + time.Sleep(graceTime) + + }) + + t.Run("B->A", func(t *testing.T) { + defer setupTest()(t) + + pingMock.On("handle", srvA, peerB.Address(), peerB.ID(), peerB.PublicKey(), mock.Anything).Run(sendPong).Once() // A expects valid ping from B and sends pong back + pongMock.On("handle", srvB, peerA.Address(), peerA.ID(), peerA.PublicKey(), mock.Anything).Once() // B expects valid pong from A + + assert.NoError(t, sendPing(srvB, peerA)) + time.Sleep(graceTime) + }) +} + +func TestSrvPingTimeout(t *testing.T) { + defer setupTest()(t) + + p2p := transport.P2P() + + srvA, closeA := newTestServer(t, "A", p2p.A, logger) + defer closeA() + srvB, closeB := newTestServer(t, "B", p2p.B, logger) + closeB() + + peerB := &srvB.Local().Peer + assert.EqualError(t, sendPing(srvA, peerB), ErrTimeout.Error()) +} + +func TestUnexpectedPong(t *testing.T) { + defer setupTest()(t) + + p2p := transport.P2P() + + srvA, closeA := newTestServer(t, "A", p2p.A, logger) + defer closeA() + srvB, closeB := newTestServer(t, "B", p2p.B, logger) + defer closeB() + + // there should never be a Ping.Handle + // there should never be a Pong.Handle + + srvA.Send(srvB.LocalAddr(), new(Pong).Marshal()) +} diff --git a/packages/autopeering/transport/chan.go b/packages/autopeering/transport/chan.go new file mode 100644 index 0000000000..d26a825879 --- /dev/null +++ b/packages/autopeering/transport/chan.go @@ -0,0 +1,116 @@ +package transport + +import ( + "io" + "net" + "sync" +) + +// ChanNetwork offers in-memory transfers between an arbitrary number of clients. +type ChanNetwork struct { + peers map[string]*chanPeer +} + +type chanPeer struct { + network *ChanNetwork + addr chanAddr + + c chan transfer + closeOnce sync.Once + closing chan struct{} +} + +// chanAddr represents the address of an end point in the in-memory transport network. +type chanAddr struct { + address string +} + +func (a chanAddr) Network() string { return "chan-network" } +func (a chanAddr) String() string { return a.address } + +// NewNetwork creates a new in-memory transport network. +// For each provided address a corresponding client is created. +func NewNetwork(addresses ...string) *ChanNetwork { + network := &ChanNetwork{ + peers: make(map[string]*chanPeer, len(addresses)), + } + + for _, addr := range addresses { + network.AddTransport(addr) + } + + return network +} + +// AddTransport adds a new client transport layer to the network. +func (n *ChanNetwork) AddTransport(addr string) { + n.peers[addr] = newChanPeer(addr, n) +} + +// GetTransport returns the corresponding client transport layer for the provided address. +// This function will panic, if no transport layer for that address exists. +func (n *ChanNetwork) GetTransport(addr string) Transport { + peer, ok := n.peers[addr] + if !ok { + panic(errPeer.Error()) + } + + return peer +} + +// Close closes each of the peers' transport layers. +func (n *ChanNetwork) Close() { + for _, peer := range n.peers { + peer.Close() + } +} + +func newChanPeer(address string, network *ChanNetwork) *chanPeer { + return &chanPeer{ + addr: chanAddr{address: address}, + network: network, + c: make(chan transfer, queueSize), + closing: make(chan struct{}), + } +} + +// ReadFrom implements the Transport ReadFrom method. +func (p *chanPeer) ReadFrom() ([]byte, string, error) { + select { + case res := <-p.c: + return res.pkt, res.addr, nil + case <-p.closing: + return nil, "", io.EOF + } +} + +// WriteTo implements the Transport WriteTo method. +func (p *chanPeer) WriteTo(pkt []byte, address string) error { + // determine the receiving peer + peer, ok := p.network.peers[address] + if !ok { + return errPeer + } + + // clone the packet before sending, just to make sure... + req := transfer{pkt: append([]byte{}, pkt...), addr: p.addr.address} + + select { + case peer.c <- req: + return nil + case <-p.closing: + return errClosed + } +} + +// Close closes the transport layer. +func (p *chanPeer) Close() { + p.closeOnce.Do(func() { + close(p.closing) + }) +} + +// LocalAddr returns the local network address. +func (p *chanPeer) LocalAddr() net.Addr { + return p.addr +} diff --git a/packages/autopeering/transport/chan_test.go b/packages/autopeering/transport/chan_test.go new file mode 100644 index 0000000000..09aa04dd49 --- /dev/null +++ b/packages/autopeering/transport/chan_test.go @@ -0,0 +1,78 @@ +package transport + +import ( + "io" + "sync" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestChanReadClosed(t *testing.T) { + network := NewNetwork("A") + defer network.Close() + + a := network.GetTransport("A") + a.Close() + _, _, err := a.ReadFrom() + assert.EqualError(t, err, io.EOF.Error()) +} + +func TestChanPacket(t *testing.T) { + network := NewNetwork("A", "B") + defer network.Close() + + a := network.GetTransport("A") + b := network.GetTransport("B") + + err := a.WriteTo(testPacket, b.LocalAddr().String()) + require.NoError(t, err) + + pkt, addr, err := b.ReadFrom() + require.NoError(t, err) + + assert.Equal(t, pkt, testPacket) + assert.Equal(t, addr, a.LocalAddr().String()) +} + +func TestChanConcurrentWrite(t *testing.T) { + network := NewNetwork("A", "B", "C", "D") + defer network.Close() + + a := network.GetTransport("A") + b := network.GetTransport("B") + c := network.GetTransport("C") + d := network.GetTransport("D") + + var wg sync.WaitGroup + numSender := 3 + + // reader + wg.Add(1) + go func() { + defer wg.Done() + for i := 0; i < numSender*1000; i++ { + _, _, err := d.ReadFrom() + assert.Equal(t, err, nil) + } + }() + + wg.Add(numSender) + burstWriteTo(a, d.LocalAddr().String(), 1000, &wg) + burstWriteTo(b, d.LocalAddr().String(), 1000, &wg) + burstWriteTo(c, d.LocalAddr().String(), 1000, &wg) + + // wait for everything to finish + wg.Wait() +} + +func burstWriteTo(t Transport, addr string, numPackets int, wg *sync.WaitGroup) { + defer wg.Done() + + go func() { + for i := 0; i < numPackets; i++ { + _ = t.WriteTo(testPacket, addr) + } + }() +} diff --git a/packages/autopeering/transport/conn.go b/packages/autopeering/transport/conn.go new file mode 100644 index 0000000000..1d67a76efd --- /dev/null +++ b/packages/autopeering/transport/conn.go @@ -0,0 +1,58 @@ +package transport + +import ( + "io" + "net" + "strings" +) + +// ResolveFunc resolves a string address to the corresponding net.Addr. +type ResolveFunc func(network, address string) (net.Addr, error) + +// TransportConn wraps a PacketConn my un-/marshaling the packets using protobuf. +type TransportConn struct { + conn net.PacketConn + res ResolveFunc +} + +// Conn creates a new transport layer by using the underlying PacketConn. +func Conn(conn net.PacketConn, res ResolveFunc) *TransportConn { + return &TransportConn{conn: conn, res: res} +} + +// ReadFrom implements the Transport ReadFrom method. +func (t *TransportConn) ReadFrom() ([]byte, string, error) { + b := make([]byte, MaxPacketSize) + n, addr, err := t.conn.ReadFrom(b) + if err != nil { + // make ErrNetClosing handled consistently + if strings.Contains(err.Error(), "use of closed network connection") { + err = io.EOF + } + return nil, "", err + } + + return b[:n], addr.String(), nil +} + +// WriteTo implements the Transport WriteTo method. +func (t *TransportConn) WriteTo(pkt []byte, address string) error { + network := t.conn.LocalAddr().Network() + addr, err := t.res(network, address) + if err != nil { + return err + } + + _, err = t.conn.WriteTo(pkt, addr) + return err +} + +// Close closes the transport layer. +func (t *TransportConn) Close() { + _ = t.conn.Close() +} + +// LocalAddr returns the local network address. +func (t *TransportConn) LocalAddr() net.Addr { + return t.conn.LocalAddr() +} diff --git a/packages/autopeering/transport/conn_test.go b/packages/autopeering/transport/conn_test.go new file mode 100644 index 0000000000..3066fae3a8 --- /dev/null +++ b/packages/autopeering/transport/conn_test.go @@ -0,0 +1,41 @@ +package transport + +import ( + "io" + "net" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestConnUdpClosed(t *testing.T) { + conn := openUDP(t) + + conn.Close() + _, _, err := conn.ReadFrom() + assert.EqualError(t, err, io.EOF.Error()) +} + +func TestConnUdpPacket(t *testing.T) { + a := openUDP(t) + defer a.Close() + b := openUDP(t) + defer b.Close() + + err := a.WriteTo(testPacket, b.LocalAddr().String()) + require.NoError(t, err) + + pkt, addr, err := b.ReadFrom() + require.NoError(t, err) + + assert.Equal(t, pkt, testPacket) + assert.Equal(t, addr, a.LocalAddr().String()) +} + +func openUDP(t *testing.T) *TransportConn { + c, err := net.ListenPacket("udp", "127.0.0.1:0") + require.NoError(t, err) + + return Conn(c, func(network, address string) (net.Addr, error) { return net.ResolveUDPAddr(network, address) }) +} diff --git a/packages/autopeering/transport/const.go b/packages/autopeering/transport/const.go new file mode 100644 index 0000000000..afff55cb33 --- /dev/null +++ b/packages/autopeering/transport/const.go @@ -0,0 +1,5 @@ +package transport + +const ( + queueSize = 5 +) diff --git a/packages/autopeering/transport/errors.go b/packages/autopeering/transport/errors.go new file mode 100644 index 0000000000..bb9ea0c1bf --- /dev/null +++ b/packages/autopeering/transport/errors.go @@ -0,0 +1,8 @@ +package transport + +import "errors" + +var ( + errClosed = errors.New("socket closed") + errPeer = errors.New("could not determine peer") +) diff --git a/packages/autopeering/transport/p2p.go b/packages/autopeering/transport/p2p.go new file mode 100644 index 0000000000..1bb3bb6ff9 --- /dev/null +++ b/packages/autopeering/transport/p2p.go @@ -0,0 +1,93 @@ +package transport + +import ( + "io" + "net" + "sync" +) + +// TransportP2P offers transfers between exactly two clients. +type TransportP2P struct { + A, B Transport +} + +// P2P creates a new in-memory two clients transport network. +// All writes in one client will always be received by the other client, no +// matter what address was specified. +func P2P() *TransportP2P { + chanA := make(chan transfer, queueSize) + chanB := make(chan transfer, queueSize) + + return &TransportP2P{ + A: newChanTransport(chanA, chanB, "A"), + B: newChanTransport(chanB, chanA, "B"), + } +} + +// Close closes each of the two client transport layers. +func (t *TransportP2P) Close() { + t.A.Close() + t.B.Close() +} + +// p2pAddr represents the address of an p2p end point. +type p2pAddr struct { + address string +} + +func (a p2pAddr) Network() string { return "p2p" } +func (a p2pAddr) String() string { return a.address } + +// chanTransport implements Transport by reading and writing to given channels. +type chanTransport struct { + in <-chan transfer + out chan<- transfer + addr p2pAddr + + closeOnce sync.Once + closing chan struct{} +} + +func newChanTransport(in <-chan transfer, out chan<- transfer, address string) *chanTransport { + return &chanTransport{ + in: in, + out: out, + addr: p2pAddr{address: address}, + closing: make(chan struct{}), + } +} + +// ReadFrom implements the Transport ReadFrom method. +func (t *chanTransport) ReadFrom() ([]byte, string, error) { + select { + case res := <-t.in: + return res.pkt, res.addr, nil + case <-t.closing: + return nil, "", io.EOF + } +} + +// WriteTo implements the Transport WriteTo method. +func (t *chanTransport) WriteTo(pkt []byte, _ string) error { + // clone the packet before sending, just to make sure... + req := transfer{pkt: append([]byte{}, pkt...), addr: t.addr.address} + + select { + case t.out <- req: + return nil + case <-t.closing: + return errClosed + } +} + +// Close closes the transport layer. +func (t *chanTransport) Close() { + t.closeOnce.Do(func() { + close(t.closing) + }) +} + +// LocalAddr returns the local network address. +func (t *chanTransport) LocalAddr() net.Addr { + return t.addr +} diff --git a/packages/autopeering/transport/p2p_test.go b/packages/autopeering/transport/p2p_test.go new file mode 100644 index 0000000000..78a454cc5d --- /dev/null +++ b/packages/autopeering/transport/p2p_test.go @@ -0,0 +1,34 @@ +package transport + +import ( + "io" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +var testPacket = []byte("TEST") + +func TestP2PReadClosed(t *testing.T) { + p2p := P2P() + defer p2p.Close() + + p2p.A.Close() + _, _, err := p2p.A.ReadFrom() + assert.EqualError(t, err, io.EOF.Error()) +} + +func TestP2PPacket(t *testing.T) { + p2p := P2P() + defer p2p.Close() + + err := p2p.A.WriteTo(testPacket, p2p.B.LocalAddr().String()) + require.NoError(t, err) + + pkt, addr, err := p2p.B.ReadFrom() + require.NoError(t, err) + + assert.Equal(t, pkt, testPacket) + assert.Equal(t, addr, p2p.A.LocalAddr().String()) +} diff --git a/packages/autopeering/transport/transport.go b/packages/autopeering/transport/transport.go new file mode 100644 index 0000000000..53a295e930 --- /dev/null +++ b/packages/autopeering/transport/transport.go @@ -0,0 +1,37 @@ +// Package transport provides implementations for simple address-based packet +// transfers. +package transport + +import ( + "net" +) + +const ( + // MaxPacketSize specifies the maximum allowed size of packets. + // Packets larger than this will be cut and thus treated as invalid. + MaxPacketSize = 1280 +) + +// Transport is generic network connection to transfer protobuf packages. +// Multiple goroutines may invoke methods on a Conn simultaneously. +type Transport interface { + // ReadFrom reads a packet from the connection. It returns the package and + // the return address for that package in string form. + ReadFrom() (pkt []byte, address string, err error) + + // WriteTo writes a packet to the string encoded target address. + WriteTo(pkt []byte, address string) error + + // Close closes the transport layer. + // Any blocked ReadFrom or WriteTo operations will return errors. + Close() + + // LocalAddr returns the local network address. + LocalAddr() net.Addr +} + +// transfer represents a send and contains the package and the return address. +type transfer struct { + pkt []byte + addr string +} diff --git a/packages/gossip/events.go b/packages/gossip/events.go index 5483e3f146..b7f82934ab 100644 --- a/packages/gossip/events.go +++ b/packages/gossip/events.go @@ -1,7 +1,7 @@ package gossip import ( - "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/iota.go/trinary" ) diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go index fb1073bf5d..6e6009394e 100644 --- a/packages/gossip/manager.go +++ b/packages/gossip/manager.go @@ -6,10 +6,10 @@ import ( "strings" "sync" - "github.com/iotaledger/autopeering-sim/peer/service" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/golang/protobuf/proto" - "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/gossip/server" "github.com/pkg/errors" diff --git a/packages/gossip/manager_test.go b/packages/gossip/manager_test.go index 6d0fd452b1..29a5634c67 100644 --- a/packages/gossip/manager_test.go +++ b/packages/gossip/manager_test.go @@ -8,8 +8,8 @@ import ( "time" "github.com/golang/protobuf/proto" - "github.com/iotaledger/autopeering-sim/peer" - "github.com/iotaledger/autopeering-sim/peer/service" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/gossip/server" "github.com/iotaledger/hive.go/events" diff --git a/packages/gossip/server/connection.go b/packages/gossip/server/connection.go index 076068f140..9c087ecbe4 100644 --- a/packages/gossip/server/connection.go +++ b/packages/gossip/server/connection.go @@ -4,7 +4,7 @@ import ( "net" "time" - "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" ) // Connection represents a network connection to a neighbor peer. diff --git a/packages/gossip/server/handshake.go b/packages/gossip/server/handshake.go index ef5bb60ec7..fb291c8e8e 100644 --- a/packages/gossip/server/handshake.go +++ b/packages/gossip/server/handshake.go @@ -5,7 +5,7 @@ import ( "time" "github.com/golang/protobuf/proto" - "github.com/iotaledger/autopeering-sim/server" + "github.com/iotaledger/goshimmer/packages/autopeering/server" pb "github.com/iotaledger/goshimmer/packages/gossip/server/proto" ) diff --git a/packages/gossip/server/server.go b/packages/gossip/server/server.go index fdb72cc096..ed21025702 100644 --- a/packages/gossip/server/server.go +++ b/packages/gossip/server/server.go @@ -11,9 +11,9 @@ import ( "time" "github.com/golang/protobuf/proto" - "github.com/iotaledger/autopeering-sim/peer" - "github.com/iotaledger/autopeering-sim/peer/service" - pb "github.com/iotaledger/autopeering-sim/server/proto" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + pb "github.com/iotaledger/goshimmer/packages/autopeering/server/proto" "github.com/pkg/errors" "go.uber.org/zap" ) diff --git a/packages/gossip/server/server_test.go b/packages/gossip/server/server_test.go index 517f948b9f..e7e88d83bc 100644 --- a/packages/gossip/server/server_test.go +++ b/packages/gossip/server/server_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/iotaledger/autopeering-sim/peer" - "github.com/iotaledger/autopeering-sim/peer/service" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap" diff --git a/packages/identity/identity.go b/packages/identity/identity.go index 14fc16fa9f..e561c81d42 100644 --- a/packages/identity/identity.go +++ b/packages/identity/identity.go @@ -5,7 +5,7 @@ import ( "crypto/sha256" "encoding/hex" - "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" ) type Identity struct { diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index 8d9d58baa3..8a0559bde4 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -7,8 +7,8 @@ import ( "github.com/iotaledger/goshimmer/plugins/autopeering/local" - "github.com/iotaledger/autopeering-sim/discover" - "github.com/iotaledger/autopeering-sim/selection" + "github.com/iotaledger/goshimmer/packages/autopeering/discover" + "github.com/iotaledger/goshimmer/packages/autopeering/selection" "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/timeutil" "github.com/iotaledger/goshimmer/plugins/analysis/types/addnode" diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 6875acbec5..9a6ccb670b 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -6,15 +6,14 @@ import ( "net" "strings" + "github.com/iotaledger/goshimmer/packages/autopeering/discover" + "github.com/iotaledger/goshimmer/packages/autopeering/logger" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/iotaledger/goshimmer/packages/autopeering/selection" + "github.com/iotaledger/goshimmer/packages/autopeering/server" + "github.com/iotaledger/goshimmer/packages/autopeering/transport" "github.com/iotaledger/goshimmer/plugins/autopeering/local" - - "github.com/iotaledger/autopeering-sim/discover" - "github.com/iotaledger/autopeering-sim/logger" - "github.com/iotaledger/autopeering-sim/peer" - "github.com/iotaledger/autopeering-sim/peer/service" - "github.com/iotaledger/autopeering-sim/selection" - "github.com/iotaledger/autopeering-sim/server" - "github.com/iotaledger/autopeering-sim/transport" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/parameter" "github.com/pkg/errors" diff --git a/plugins/autopeering/local/local.go b/plugins/autopeering/local/local.go index 095648e570..a477cd8abd 100644 --- a/plugins/autopeering/local/local.go +++ b/plugins/autopeering/local/local.go @@ -9,7 +9,7 @@ import ( "strconv" "sync" - "github.com/iotaledger/autopeering-sim/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/hive.go/parameter" "go.uber.org/zap" ) diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 1deaa3684b..4ba57d0c0e 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -1,7 +1,7 @@ package autopeering import ( - "github.com/iotaledger/autopeering-sim/discover" + "github.com/iotaledger/goshimmer/packages/autopeering/discover" "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index dae769cf05..eff0dfa925 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -5,8 +5,8 @@ import ( "net" "strconv" - "github.com/iotaledger/autopeering-sim/logger" - "github.com/iotaledger/autopeering-sim/peer/service" + "github.com/iotaledger/goshimmer/packages/autopeering/logger" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/errors" gp "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/gossip/server" diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 39fd6f1936..9b17659979 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -1,8 +1,8 @@ package gossip import ( - "github.com/iotaledger/autopeering-sim/peer/service" - "github.com/iotaledger/autopeering-sim/selection" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/iotaledger/goshimmer/packages/autopeering/selection" "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/typeutils" From c7c5501fc527cfd56e9d548a1e391afb6831520c Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Sat, 4 Jan 2020 15:38:49 +0100 Subject: [PATCH 065/184] refactor: remove unused packages --- packages/byteutils/byteutils.go | 17 ----- packages/crypto/hash20.go | 17 ----- packages/iac/area.go | 38 ---------- packages/iac/errors.go | 8 --- packages/iac/iac.go | 25 ------- packages/iac/olc_conversion.go | 56 --------------- packages/identity/constants.go | 20 ------ packages/identity/errors.go | 8 --- packages/identity/identity.go | 120 -------------------------------- packages/identity/types.go | 3 - packages/network/udp/events.go | 18 ----- packages/network/udp/server.go | 71 ------------------- packages/network/udp/types.go | 9 --- 13 files changed, 410 deletions(-) delete mode 100644 packages/byteutils/byteutils.go delete mode 100644 packages/crypto/hash20.go delete mode 100644 packages/iac/area.go delete mode 100644 packages/iac/errors.go delete mode 100644 packages/iac/iac.go delete mode 100644 packages/iac/olc_conversion.go delete mode 100644 packages/identity/constants.go delete mode 100644 packages/identity/errors.go delete mode 100644 packages/identity/identity.go delete mode 100644 packages/identity/types.go delete mode 100644 packages/network/udp/events.go delete mode 100644 packages/network/udp/server.go delete mode 100644 packages/network/udp/types.go diff --git a/packages/byteutils/byteutils.go b/packages/byteutils/byteutils.go deleted file mode 100644 index 1f5311f07d..0000000000 --- a/packages/byteutils/byteutils.go +++ /dev/null @@ -1,17 +0,0 @@ -package byteutils - -func ReadAvailableBytesToBuffer(target []byte, targetOffset int, source []byte, sourceOffset int, sourceLength int) int { - availableBytes := sourceLength - sourceOffset - requiredBytes := len(target) - targetOffset - - var bytesToRead int - if availableBytes < requiredBytes { - bytesToRead = availableBytes - } else { - bytesToRead = requiredBytes - } - - copy(target[targetOffset:], source[sourceOffset:sourceOffset+bytesToRead]) - - return bytesToRead -} diff --git a/packages/crypto/hash20.go b/packages/crypto/hash20.go deleted file mode 100644 index d27ef21a2b..0000000000 --- a/packages/crypto/hash20.go +++ /dev/null @@ -1,17 +0,0 @@ -package crypto - -import ( - "crypto/sha256" - - "golang.org/x/crypto/ripemd160" -) - -func Hash20(input []byte) []byte { - sha256Hasher := sha256.New() - sha256Hasher.Write(input) - - ripemd160Hasher := ripemd160.New() - ripemd160Hasher.Write(sha256Hasher.Sum(nil)) - - return ripemd160Hasher.Sum(nil) -} diff --git a/packages/iac/area.go b/packages/iac/area.go deleted file mode 100644 index 7140e553e0..0000000000 --- a/packages/iac/area.go +++ /dev/null @@ -1,38 +0,0 @@ -package iac - -import ( - "math" - - olc "github.com/google/open-location-code/go" - "github.com/iotaledger/iota.go/trinary" -) - -type Area struct { - olc.CodeArea - IACCode trinary.Trytes - OLCCode string -} - -func (area *Area) Distance(other *Area) float64 { - lat1, lng1 := area.Center() - lat2, lng2 := other.Center() - - return distance(lat1, lng1, lat2, lng2) -} - -func distance(lat1, lon1, lat2, lon2 float64) float64 { - la1 := lat1 * math.Pi / 180 - lo1 := lon1 * math.Pi / 180 - la2 := lat2 * math.Pi / 180 - lo2 := lon2 * math.Pi / 180 - - return 2 * EARTH_RADIUS_IN_METERS * math.Asin(math.Sqrt(hsin(la2-la1)+math.Cos(la1)*math.Cos(la2)*hsin(lo2-lo1))) -} - -func hsin(theta float64) float64 { - return math.Pow(math.Sin(theta/2), 2) -} - -const ( - EARTH_RADIUS_IN_METERS = 6371000 -) diff --git a/packages/iac/errors.go b/packages/iac/errors.go deleted file mode 100644 index 021c0a0bf7..0000000000 --- a/packages/iac/errors.go +++ /dev/null @@ -1,8 +0,0 @@ -package iac - -import "github.com/iotaledger/goshimmer/packages/errors" - -var ( - ErrConversionFailed = errors.New("conversion between IAC and internal OLC format failed") - ErrDecodeFailed = errors.Wrap(errors.New("decoding error"), "failed to decode the IAC") -) diff --git a/packages/iac/iac.go b/packages/iac/iac.go deleted file mode 100644 index e1e69661f2..0000000000 --- a/packages/iac/iac.go +++ /dev/null @@ -1,25 +0,0 @@ -package iac - -import ( - olc "github.com/google/open-location-code/go" - "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/iota.go/trinary" -) - -func Decode(trytes trinary.Trytes) (result *Area, err errors.IdentifiableError) { - if olcCode, conversionErr := OLCCodeFromTrytes(trytes); conversionErr != nil { - err = conversionErr - } else { - if codeArea, olcErr := olc.Decode(olcCode); olcErr == nil { - result = &Area{ - IACCode: trytes, - OLCCode: olcCode, - CodeArea: codeArea, - } - } else { - err = ErrDecodeFailed.Derive(olcErr, "failed to decode the IAC") - } - } - - return -} diff --git a/packages/iac/olc_conversion.go b/packages/iac/olc_conversion.go deleted file mode 100644 index 632280d778..0000000000 --- a/packages/iac/olc_conversion.go +++ /dev/null @@ -1,56 +0,0 @@ -package iac - -import ( - "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/iota.go/trinary" -) - -var ( - OLC_ALPHABET = []rune{'2', '3', '4', '5', '6', '7', '8', '9', 'C', 'F', 'G', 'H', 'J', 'M', 'P', 'Q', 'R', 'V', 'W', 'X'} - IAC_ALPHABET = []rune{'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'X', 'W', 'Y', 'Z'} - OLC_TO_IAC_MAP = make(map[rune]rune, 22) - IAC_TO_OLC_MAP = make(map[rune]rune, 22) -) - -const ( - OLC_SEPARATOR = '+' - OLC_PADDING = '0' - IAC_SEPARATOR = '9' - IAC_PADDING = 'A' -) - -func init() { - for pos, char := range OLC_ALPHABET { - OLC_TO_IAC_MAP[char] = IAC_ALPHABET[pos] - IAC_TO_OLC_MAP[IAC_ALPHABET[pos]] = char - } - - OLC_TO_IAC_MAP[OLC_SEPARATOR] = IAC_SEPARATOR - OLC_TO_IAC_MAP[OLC_PADDING] = IAC_PADDING - IAC_TO_OLC_MAP[IAC_SEPARATOR] = OLC_SEPARATOR - IAC_TO_OLC_MAP[IAC_PADDING] = OLC_PADDING -} - -func TrytesFromOLCCode(code string) (result trinary.Trytes, err errors.IdentifiableError) { - for _, char := range code { - if translatedChar, exists := OLC_TO_IAC_MAP[char]; exists { - result += trinary.Trytes(translatedChar) - } else { - err = ErrConversionFailed.Derive("invalid character in input") - } - } - - return -} - -func OLCCodeFromTrytes(trytes trinary.Trytes) (result string, err errors.IdentifiableError) { - for _, char := range trytes { - if translatedChar, exists := IAC_TO_OLC_MAP[char]; exists { - result += string(translatedChar) - } else { - err = ErrConversionFailed.Derive("invalid character in input") - } - } - - return -} diff --git a/packages/identity/constants.go b/packages/identity/constants.go deleted file mode 100644 index 0e23d6ede9..0000000000 --- a/packages/identity/constants.go +++ /dev/null @@ -1,20 +0,0 @@ -package identity - -import "crypto/ed25519" - -const ( - IDENTIFIER_BYTE_LENGTH = 20 - PUBLIC_KEY_BYTE_LENGTH = ed25519.PublicKeySize - SIGNATURE_BYTE_LENGTH = ed25519.PublicKeySize + ed25519.SignatureSize - - MARSHALED_IDENTITY_PUBLIC_KEY_START = 0 - MARSHALED_IDENTITY_PRIVATE_KEY_START = MARSHALED_IDENTITY_PUBLIC_KEY_END - - MARSHALED_IDENTITY_PUBLIC_KEY_SIZE = PUBLIC_KEY_BYTE_LENGTH - MARSHALED_IDENTITY_PRIVATE_KEY_SIZE = ed25519.PrivateKeySize - - MARSHALED_IDENTITY_PUBLIC_KEY_END = MARSHALED_IDENTITY_PUBLIC_KEY_START + MARSHALED_IDENTITY_PUBLIC_KEY_SIZE - MARSHALED_IDENTITY_PRIVATE_KEY_END = MARSHALED_IDENTITY_PRIVATE_KEY_START + MARSHALED_IDENTITY_PRIVATE_KEY_SIZE - - MARSHALED_IDENTITY_TOTAL_SIZE = MARSHALED_IDENTITY_PRIVATE_KEY_END -) diff --git a/packages/identity/errors.go b/packages/identity/errors.go deleted file mode 100644 index 60f5d59b12..0000000000 --- a/packages/identity/errors.go +++ /dev/null @@ -1,8 +0,0 @@ -package identity - -import "errors" - -var ( - ErrInvalidDataLen = errors.New("identity: invalid input data length") - ErrInvalidSignature = errors.New("identity: invalid signature") -) diff --git a/packages/identity/identity.go b/packages/identity/identity.go deleted file mode 100644 index e561c81d42..0000000000 --- a/packages/identity/identity.go +++ /dev/null @@ -1,120 +0,0 @@ -package identity - -import ( - "crypto/ed25519" - "crypto/sha256" - "encoding/hex" - - "github.com/iotaledger/goshimmer/packages/autopeering/peer" -) - -type Identity struct { - Identifier peer.ID - StringIdentifier string - PublicKey ed25519.PublicKey - privateKey ed25519.PrivateKey -} - -// Creates a new identity based on the given public key. -func NewPublicIdentity(publicKey ed25519.PublicKey) *Identity { - identifier := sha256.Sum256(publicKey) - - return &Identity{ - Identifier: identifier, - StringIdentifier: hex.EncodeToString(identifier[:8]), - PublicKey: publicKey, - privateKey: nil, - } -} - -// Generates a identity based on a newly generated public/private key pair. -// It will panic if no such pair could be generated. -func GeneratePrivateIdentity() *Identity { - publicKey, privateKey, err := ed25519.GenerateKey(nil) - if err != nil { - panic("identity: failed generating key: " + err.Error()) - } - - return newPrivateIdentity(publicKey, privateKey) -} - -// Sign signs the message with privateKey and returns the message plus the signature. -func (id *Identity) AddSignature(msg []byte) []byte { - signatureStart := len(msg) - - signature := ed25519.Sign(id.privateKey, msg) - - data := make([]byte, signatureStart+SIGNATURE_BYTE_LENGTH) - - copy(data[:signatureStart], msg) - - // add public key and signature - copy(data[signatureStart:signatureStart+ed25519.PublicKeySize], id.PublicKey) - copy(data[signatureStart+ed25519.PublicKeySize:], signature) - - return data -} - -// Verifies whether the data contains a valid signature of the message. -func (id *Identity) VerifySignature(data []byte) error { - signatureStart := len(data) - SIGNATURE_BYTE_LENGTH - if signatureStart <= 0 { - return ErrInvalidDataLen - } - - msg := data[:signatureStart] - - // ignore the public key - sig := data[signatureStart+ed25519.PublicKeySize:] - - if !ed25519.Verify(id.PublicKey, msg, sig) { - return ErrInvalidSignature - } - - return nil -} - -// Returns the identitiy derived from the signed message. -func FromSignedData(data []byte) (*Identity, error) { - signatureStart := len(data) - SIGNATURE_BYTE_LENGTH - if signatureStart <= 0 { - return nil, ErrInvalidDataLen - } - - pubKey := data[signatureStart : signatureStart+ed25519.PublicKeySize] - - identity := NewPublicIdentity(pubKey) - if err := identity.VerifySignature(data); err != nil { - return nil, err - } - - return identity, nil -} - -func (id *Identity) Marshal() []byte { - data := make([]byte, MARSHALED_IDENTITY_TOTAL_SIZE) - - copy(data[MARSHALED_IDENTITY_PUBLIC_KEY_START:MARSHALED_IDENTITY_PUBLIC_KEY_END], id.PublicKey) - copy(data[MARSHALED_IDENTITY_PRIVATE_KEY_START:MARSHALED_IDENTITY_PRIVATE_KEY_END], id.privateKey) - - return data -} - -func Unmarshal(data []byte) (*Identity, error) { - if len(data) != MARSHALED_IDENTITY_TOTAL_SIZE { - return nil, ErrInvalidDataLen - } - - publicKey := data[MARSHALED_IDENTITY_PUBLIC_KEY_START:MARSHALED_IDENTITY_PUBLIC_KEY_END] - privateKey := data[MARSHALED_IDENTITY_PRIVATE_KEY_START:MARSHALED_IDENTITY_PRIVATE_KEY_END] - - return newPrivateIdentity(publicKey, privateKey), nil -} - -func newPrivateIdentity(publicKey []byte, privateKey []byte) *Identity { - - identity := NewPublicIdentity(publicKey) - identity.privateKey = privateKey - - return identity -} diff --git a/packages/identity/types.go b/packages/identity/types.go deleted file mode 100644 index 30565ab678..0000000000 --- a/packages/identity/types.go +++ /dev/null @@ -1,3 +0,0 @@ -package identity - -type IdentityType int diff --git a/packages/network/udp/events.go b/packages/network/udp/events.go deleted file mode 100644 index 590c6c256b..0000000000 --- a/packages/network/udp/events.go +++ /dev/null @@ -1,18 +0,0 @@ -package udp - -import ( - "net" - - "github.com/iotaledger/hive.go/events" -) - -type serverEvents struct { - Start *events.Event - Shutdown *events.Event - ReceiveData *events.Event - Error *events.Event -} - -func dataCaller(handler interface{}, params ...interface{}) { - handler.(func(*net.UDPAddr, []byte))(params[0].(*net.UDPAddr), params[1].([]byte)) -} diff --git a/packages/network/udp/server.go b/packages/network/udp/server.go deleted file mode 100644 index 00fe86864c..0000000000 --- a/packages/network/udp/server.go +++ /dev/null @@ -1,71 +0,0 @@ -package udp - -import ( - "net" - "strconv" - "sync" - - "github.com/iotaledger/hive.go/events" -) - -type Server struct { - socket net.PacketConn - socketMutex sync.RWMutex - ReceiveBufferSize int - Events serverEvents -} - -func (this *Server) GetSocket() net.PacketConn { - this.socketMutex.RLock() - defer this.socketMutex.RUnlock() - return this.socket -} - -func (this *Server) Shutdown() { - this.socketMutex.Lock() - defer this.socketMutex.Unlock() - if this.socket != nil { - socket := this.socket - this.socket = nil - - socket.Close() - } -} - -func (this *Server) Listen(address string, port int) { - if socket, err := net.ListenPacket("udp", address+":"+strconv.Itoa(port)); err != nil { - this.Events.Error.Trigger(err) - - return - } else { - this.socketMutex.Lock() - this.socket = socket - this.socketMutex.Unlock() - } - - this.Events.Start.Trigger() - defer this.Events.Shutdown.Trigger() - - buf := make([]byte, this.ReceiveBufferSize) - for this.GetSocket() != nil { - if bytesRead, addr, err := this.GetSocket().ReadFrom(buf); err != nil { - if this.GetSocket() != nil { - this.Events.Error.Trigger(err) - } - } else { - this.Events.ReceiveData.Trigger(addr.(*net.UDPAddr), buf[:bytesRead]) - } - } -} - -func NewServer(receiveBufferSize int) *Server { - return &Server{ - ReceiveBufferSize: receiveBufferSize, - Events: serverEvents{ - Start: events.NewEvent(events.CallbackCaller), - Shutdown: events.NewEvent(events.CallbackCaller), - ReceiveData: events.NewEvent(dataCaller), - Error: events.NewEvent(events.ErrorCaller), - }, - } -} diff --git a/packages/network/udp/types.go b/packages/network/udp/types.go deleted file mode 100644 index 5ee6236e77..0000000000 --- a/packages/network/udp/types.go +++ /dev/null @@ -1,9 +0,0 @@ -package udp - -import "net" - -type Callback = func() - -type AddressDataConsumer = func(addr *net.UDPAddr, data []byte) - -type ErrorConsumer = func(err error) From 81a60105f90f55e4a15478e4104ca3ee912b0faa Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Sat, 4 Jan 2020 15:43:21 +0100 Subject: [PATCH 066/184] fix: use hive.go bitmask --- packages/bitutils/bitmask.go | 15 -------- packages/bitutils/bitmask_test.go | 34 ------------------- packages/model/bundle/bundle.go | 6 ++-- .../transactionmetadata.go | 6 ++-- 4 files changed, 6 insertions(+), 55 deletions(-) delete mode 100644 packages/bitutils/bitmask.go delete mode 100644 packages/bitutils/bitmask_test.go diff --git a/packages/bitutils/bitmask.go b/packages/bitutils/bitmask.go deleted file mode 100644 index 64bc506723..0000000000 --- a/packages/bitutils/bitmask.go +++ /dev/null @@ -1,15 +0,0 @@ -package bitutils - -type BitMask byte - -func (bitmask BitMask) SetFlag(pos uint) BitMask { - return bitmask | (1 << pos) -} - -func (bitmask BitMask) ClearFlag(pos uint) BitMask { - return bitmask & ^(1 << pos) -} - -func (bitmask BitMask) HasFlag(pos uint) bool { - return (bitmask&(1< 0) -} diff --git a/packages/bitutils/bitmask_test.go b/packages/bitutils/bitmask_test.go deleted file mode 100644 index 1d04a89546..0000000000 --- a/packages/bitutils/bitmask_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package bitutils - -import ( - "testing" -) - -func TestBitmask(t *testing.T) { - var b BitMask - - if b.HasFlag(0) { - t.Error("flag at pos 0 should not be set") - } - if b.HasFlag(1) { - t.Error("flag at pos 1 should not be set") - } - - b = b.SetFlag(0) - if !b.HasFlag(0) { - t.Error("flag at pos 0 should be set") - } - b = b.SetFlag(1) - if !b.HasFlag(1) { - t.Error("flag at pos 1 should be set") - } - - b = b.ClearFlag(0) - if b.HasFlag(0) { - t.Error("flag at pos 0 should not be set") - } - b = b.ClearFlag(1) - if b.HasFlag(1) { - t.Error("flag at pos 1 should not be set") - } -} diff --git a/packages/model/bundle/bundle.go b/packages/model/bundle/bundle.go index e2e3aa8b4d..3c9c6208eb 100644 --- a/packages/model/bundle/bundle.go +++ b/packages/model/bundle/bundle.go @@ -6,9 +6,9 @@ import ( "sync" "unsafe" - "github.com/iotaledger/goshimmer/packages/bitutils" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/typeutils" + "github.com/iotaledger/hive.go/bitmask" "github.com/iotaledger/iota.go/trinary" ) @@ -116,7 +116,7 @@ func (bundle *Bundle) Marshal() (result []byte) { copy(result[MARSHALED_HASH_START:MARSHALED_HASH_END], typeutils.StringToBytes(bundle.hash)) copy(result[MARSHALED_BUNDLE_ESSENCE_HASH_START:MARSHALED_BUNDLE_ESSENCE_HASH_END], typeutils.StringToBytes(bundle.bundleEssenceHash)) - var flags bitutils.BitMask + var flags bitmask.BitMask if bundle.isValueBundle { flags = flags.SetFlag(0) } @@ -161,7 +161,7 @@ func (bundle *Bundle) Unmarshal(data []byte) (err errors.IdentifiableError) { bundle.hash = trinary.Trytes(typeutils.BytesToString(data[MARSHALED_HASH_START:MARSHALED_HASH_END])) bundle.bundleEssenceHash = trinary.Trytes(typeutils.BytesToString(data[MARSHALED_BUNDLE_ESSENCE_HASH_START:MARSHALED_BUNDLE_ESSENCE_HASH_END])) - flags := bitutils.BitMask(data[MARSHALED_FLAGS_START]) + flags := bitmask.BitMask(data[MARSHALED_FLAGS_START]) if flags.HasFlag(0) { bundle.isValueBundle = true } diff --git a/packages/model/transactionmetadata/transactionmetadata.go b/packages/model/transactionmetadata/transactionmetadata.go index 6fd4ab4ecd..b86188108c 100644 --- a/packages/model/transactionmetadata/transactionmetadata.go +++ b/packages/model/transactionmetadata/transactionmetadata.go @@ -4,9 +4,9 @@ import ( "sync" "time" - "github.com/iotaledger/goshimmer/packages/bitutils" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/typeutils" + "github.com/iotaledger/hive.go/bitmask" "github.com/iotaledger/iota.go/trinary" ) @@ -226,7 +226,7 @@ func (metadata *TransactionMetadata) Marshal() ([]byte, errors.IdentifiableError } copy(marshaledMetadata[MARSHALED_RECEIVED_TIME_START:MARSHALED_RECEIVED_TIME_END], marshaledReceivedTime) - var booleanFlags bitutils.BitMask + var booleanFlags bitmask.BitMask if metadata.solid { booleanFlags = booleanFlags.SetFlag(0) } @@ -259,7 +259,7 @@ func (metadata *TransactionMetadata) Unmarshal(data []byte) errors.IdentifiableE return ErrUnmarshalFailed.Derive(err, "could not unmarshal the received time") } - booleanFlags := bitutils.BitMask(data[MARSHALED_FLAGS_START]) + booleanFlags := bitmask.BitMask(data[MARSHALED_FLAGS_START]) if booleanFlags.HasFlag(0) { metadata.solid = true } From c5bad7b5adac2b99dc410e2b7ca217b8273fcd4f Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Sat, 4 Jan 2020 15:55:20 +0100 Subject: [PATCH 067/184] fix: use hive.go typeutils --- packages/datastructure/lru_cache.go | 2 +- packages/filter/byte_array_filter.go | 2 +- packages/model/approvers/approvers.go | 2 +- packages/model/bundle/bundle.go | 2 +- .../transactionmetadata.go | 2 +- packages/typeutils/typeutils.go | 10 -- packages/typeutils/unsafe.go | 30 ------ packages/typeutils/unsafe_test.go | 92 ------------------- plugins/gossip/gossip.go | 2 +- plugins/gossip/plugin.go | 2 +- plugins/tangle/approvers.go | 2 +- plugins/tangle/bundle.go | 2 +- plugins/tangle/transaction.go | 2 +- plugins/tangle/transaction_metadata.go | 2 +- 14 files changed, 11 insertions(+), 143 deletions(-) delete mode 100644 packages/typeutils/typeutils.go delete mode 100644 packages/typeutils/unsafe.go delete mode 100644 packages/typeutils/unsafe_test.go diff --git a/packages/datastructure/lru_cache.go b/packages/datastructure/lru_cache.go index 469e54a961..fe15c42469 100644 --- a/packages/datastructure/lru_cache.go +++ b/packages/datastructure/lru_cache.go @@ -3,7 +3,7 @@ package datastructure import ( "sync" - "github.com/iotaledger/goshimmer/packages/typeutils" + "github.com/iotaledger/hive.go/typeutils" ) type lruCacheElement struct { diff --git a/packages/filter/byte_array_filter.go b/packages/filter/byte_array_filter.go index d8cb89fe01..e5955c32c3 100644 --- a/packages/filter/byte_array_filter.go +++ b/packages/filter/byte_array_filter.go @@ -3,7 +3,7 @@ package filter import ( "sync" - "github.com/iotaledger/goshimmer/packages/typeutils" + "github.com/iotaledger/hive.go/typeutils" ) type ByteArrayFilter struct { diff --git a/packages/model/approvers/approvers.go b/packages/model/approvers/approvers.go index f885fd6af1..1c98156dcd 100644 --- a/packages/model/approvers/approvers.go +++ b/packages/model/approvers/approvers.go @@ -6,7 +6,7 @@ import ( "sync" "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/typeutils" + "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) diff --git a/packages/model/bundle/bundle.go b/packages/model/bundle/bundle.go index 3c9c6208eb..977592c4c7 100644 --- a/packages/model/bundle/bundle.go +++ b/packages/model/bundle/bundle.go @@ -7,8 +7,8 @@ import ( "unsafe" "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/typeutils" "github.com/iotaledger/hive.go/bitmask" + "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) diff --git a/packages/model/transactionmetadata/transactionmetadata.go b/packages/model/transactionmetadata/transactionmetadata.go index b86188108c..daf4a2342e 100644 --- a/packages/model/transactionmetadata/transactionmetadata.go +++ b/packages/model/transactionmetadata/transactionmetadata.go @@ -5,8 +5,8 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/errors" - "github.com/iotaledger/goshimmer/packages/typeutils" "github.com/iotaledger/hive.go/bitmask" + "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) diff --git a/packages/typeutils/typeutils.go b/packages/typeutils/typeutils.go deleted file mode 100644 index 6bd97c8827..0000000000 --- a/packages/typeutils/typeutils.go +++ /dev/null @@ -1,10 +0,0 @@ -package typeutils - -import ( - "unsafe" -) - -// Checks whether an interface is nil or has the value nil. -func IsInterfaceNil(param interface{}) bool { - return param == nil || (*[2]uintptr)(unsafe.Pointer(¶m))[1] == 0 -} diff --git a/packages/typeutils/unsafe.go b/packages/typeutils/unsafe.go deleted file mode 100644 index 56e8a99697..0000000000 --- a/packages/typeutils/unsafe.go +++ /dev/null @@ -1,30 +0,0 @@ -package typeutils - -import ( - "reflect" - "runtime" - "unsafe" -) - -// Converts a slice of bytes into a string without performing a copy. -// NOTE: This is an unsafe operation and may lead to problems if the bytes -// passed as argument are changed while the string is used. No checking whether -// bytes are valid UTF-8 data is performed. -func BytesToString(b []byte) string { - return *(*string)(unsafe.Pointer(&b)) -} - -// Converts a string into a slice of bytes without performing a copy. -// NOTE: This is an unsafe operation and may lead to problems if the bytes are changed. -func StringToBytes(s string) []byte { - sh := (*reflect.StringHeader)(unsafe.Pointer(&s)) - b := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{ - Data: sh.Data, - Len: sh.Len, - Cap: sh.Len, - })) - // ensure the underlying string doesn't get GC'ed before the assignment happens - runtime.KeepAlive(&s) - - return b -} diff --git a/packages/typeutils/unsafe_test.go b/packages/typeutils/unsafe_test.go deleted file mode 100644 index d28a5c06f4..0000000000 --- a/packages/typeutils/unsafe_test.go +++ /dev/null @@ -1,92 +0,0 @@ -package typeutils - -import ( - "bytes" - "strings" - "testing" -) - -var testStrings = []string{ - "", - " ", - "test", - "こんにちは、 世界", - strings.Repeat(" ", 10), - strings.Repeat(" ", 100), - strings.Repeat(" ", 10000), - strings.Repeat(" ", 1000000), -} - -func TestBytesToString(t *testing.T) { - for _, expected := range testStrings { - arg := []byte(expected) - actual := BytesToString(arg) - if actual != expected { - t.Errorf("BytesToString(%q) = %q but expected %q", arg, actual, expected) - } - } -} - -func TestStringToBytes(t *testing.T) { - for _, arg := range testStrings { - expected := []byte(arg) - actual := StringToBytes(arg) - if !bytes.Equal(actual, expected) { - t.Errorf("Bytes(%q) = %q but expected %q", arg, actual, expected) - } - } -} - -func TestNil(t *testing.T) { - actual := BytesToString(nil) - expected := "" - if actual != expected { - t.Errorf("String(nil) = %q but expected %q", actual, expected) - } -} - -func createTestBytes() [][]byte { - result := make([][]byte, len(testStrings)) - for i, str := range testStrings { - result[i] = []byte(str) - } - return result -} - -func BenchmarkNativeBytesToString(b *testing.B) { - testBytes := createTestBytes() - b.ResetTimer() - - for i := 0; i < b.N; i++ { - for _, bs := range testBytes { - _ = string(bs) - } - } -} - -func BenchmarkUnsafeBytesToString(b *testing.B) { - testBytes := createTestBytes() - b.ResetTimer() - - for i := 0; i < b.N; i++ { - for _, bs := range testBytes { - _ = BytesToString(bs) - } - } -} - -func BenchmarkNativeStringToBytes(b *testing.B) { - for i := 0; i < b.N; i++ { - for _, str := range testStrings { - _ = []byte(str) - } - } -} - -func BenchmarkUnsafeStringToBytes(b *testing.B) { - for i := 0; i < b.N; i++ { - for _, str := range testStrings { - _ = StringToBytes(str) - } - } -} diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index eff0dfa925..16433e336c 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -10,11 +10,11 @@ import ( "github.com/iotaledger/goshimmer/packages/errors" gp "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/gossip/server" - "github.com/iotaledger/goshimmer/packages/typeutils" "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/parameter" + "github.com/iotaledger/hive.go/typeutils" ) var ( diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 9b17659979..56babd44a2 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -5,12 +5,12 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/selection" "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/packages/typeutils" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/typeutils" ) const ( diff --git a/plugins/tangle/approvers.go b/plugins/tangle/approvers.go index e150339650..fd4461aa1e 100644 --- a/plugins/tangle/approvers.go +++ b/plugins/tangle/approvers.go @@ -5,8 +5,8 @@ import ( "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/approvers" - "github.com/iotaledger/goshimmer/packages/typeutils" "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) diff --git a/plugins/tangle/bundle.go b/plugins/tangle/bundle.go index d8c33fc7ae..bd55c6e67e 100644 --- a/plugins/tangle/bundle.go +++ b/plugins/tangle/bundle.go @@ -5,8 +5,8 @@ import ( "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/bundle" - "github.com/iotaledger/goshimmer/packages/typeutils" "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) diff --git a/plugins/tangle/transaction.go b/plugins/tangle/transaction.go index 01bbe222b9..aeb4c915af 100644 --- a/plugins/tangle/transaction.go +++ b/plugins/tangle/transaction.go @@ -5,8 +5,8 @@ import ( "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/packages/typeutils" "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) diff --git a/plugins/tangle/transaction_metadata.go b/plugins/tangle/transaction_metadata.go index 07dc28f573..e1032ed635 100644 --- a/plugins/tangle/transaction_metadata.go +++ b/plugins/tangle/transaction_metadata.go @@ -5,8 +5,8 @@ import ( "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" - "github.com/iotaledger/goshimmer/packages/typeutils" "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) From 9743ed8bf549bd5138cdaa5c3fe8f6199567ff46 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Sat, 4 Jan 2020 15:59:54 +0100 Subject: [PATCH 068/184] feat: upgrade iota.go --- go.mod | 3 +-- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 8524bdb29e..8c74798251 100644 --- a/go.mod +++ b/go.mod @@ -10,10 +10,9 @@ require ( github.com/gdamore/tcell v1.3.0 github.com/go-zeromq/zmq4 v0.7.0 github.com/golang/protobuf v1.3.2 - github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 github.com/gorilla/websocket v1.4.1 github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20 - github.com/iotaledger/iota.go v1.0.0-beta.12 + github.com/iotaledger/iota.go v1.0.0-beta.13 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect github.com/lucasb-eyer/go-colorful v1.0.3 // indirect diff --git a/go.sum b/go.sum index 5163fbe2ae..1a6b6612f4 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20 h1:ZIJAeQSEdmVbmZNIW2198IwD23+wBteb4WE4pyjxk+c= github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20/go.mod h1:7iqun29a1x0lymTrn0UJ3Z/yy0sUzUpoOZ1OYMrYN20= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= -github.com/iotaledger/iota.go v1.0.0-beta.12 h1:p6Pk3N8tmb6Kaj8F45O5XVJQfH5qQYqpvUnXiSMrtiE= -github.com/iotaledger/iota.go v1.0.0-beta.12/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= +github.com/iotaledger/iota.go v1.0.0-beta.13 h1:6m6JRcKtjTflU2PbjvDA9Tv6NTEJX1PijBDOkH9weQc= +github.com/iotaledger/iota.go v1.0.0-beta.13/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= From b76fc53b5d43f76ff0a2eed9ca50c31a55dc770b Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Tue, 7 Jan 2020 07:05:58 +0100 Subject: [PATCH 069/184] fix: do not stop reading on bad packet --- packages/autopeering/server/server.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/autopeering/server/server.go b/packages/autopeering/server/server.go index 50506987e8..dcfcb47257 100644 --- a/packages/autopeering/server/server.go +++ b/packages/autopeering/server/server.go @@ -274,8 +274,8 @@ func (s *Server) readLoop() { pkt := new(pb.Packet) if err := proto.Unmarshal(b, pkt); err != nil { - s.log.Debugw("packet error", "err", err) - return + s.log.Debugw("bad packet", "from", fromAddr, "err", err) + continue } if err := s.handlePacket(pkt, fromAddr); err != nil { s.log.Debugw("failed to handle packet", "from", fromAddr, "err", err) From 1e804bbfcbc6e4d702d76d35057570147c2c65bb Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Tue, 7 Jan 2020 07:23:47 +0100 Subject: [PATCH 070/184] fix: reduce log verbosity --- packages/autopeering/server/server.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/autopeering/server/server.go b/packages/autopeering/server/server.go index dcfcb47257..d403b523fd 100644 --- a/packages/autopeering/server/server.go +++ b/packages/autopeering/server/server.go @@ -237,7 +237,9 @@ func (s *Server) write(toAddr string, pkt *pb.Packet) { } err = s.trans.WriteTo(b, toAddr) - s.log.Debugw("write packet", "addr", toAddr, "size", len(b), "err", err) + if err != nil { + s.log.Debugw("failed to write packet", "addr", toAddr, "err", err) + } } // encodes a message as a data packet that can be written. @@ -290,7 +292,6 @@ func (s *Server) handlePacket(pkt *pb.Packet, fromAddr string) error { } fromID := key.ID() - s.log.Debugw("handlePacket", "addr", fromAddr, "id", fromID) for _, handler := range s.handlers { ok, err := handler.HandleMessage(s, fromAddr, fromID, key, data) if ok { From 55ad3e2337fce96339ff385f7ba69744014da6a0 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Tue, 7 Jan 2020 07:24:25 +0100 Subject: [PATCH 071/184] fix: do not use docker host mode by default --- docker-compose.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index cc59aa4d05..b4af6fb9da 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,6 @@ version: "3" services: goshimmer: - network_mode: host image: iotaledger/goshimmer build: context: ./ From d592db29ee0c0628e42991290b7386e2901048f2 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Tue, 7 Jan 2020 12:34:47 +0100 Subject: [PATCH 072/184] updates to latest hive.go --- go.mod | 6 +-- go.sum | 23 +++++++++ main.go | 48 +++++++++++-------- packages/database/badger_instance.go | 2 +- packages/parameter/parameter.go | 34 +++++++++++++ packages/timeutil/sleep.go | 17 ------- packages/timeutil/ticker.go | 20 -------- .../transactionspammer/transactionspammer.go | 4 +- plugins/analysis/client/plugin.go | 19 ++++---- plugins/analysis/plugin.go | 3 +- plugins/analysis/server/plugin.go | 4 +- .../webinterface/httpserver/plugin.go | 2 +- plugins/autopeering/autopeering.go | 7 ++- plugins/autopeering/local/local.go | 2 +- plugins/bundleprocessor/plugin.go | 4 +- plugins/cli/plugin.go | 6 ++- plugins/dashboard/plugin.go | 2 +- plugins/gossip/gossip.go | 7 ++- plugins/metrics/plugin.go | 6 ++- plugins/statusscreen-tps/plugin.go | 4 +- plugins/statusscreen/statusscreen.go | 6 +-- plugins/tangle/solidifier.go | 2 +- plugins/ui/ui.go | 4 +- plugins/webapi/plugin.go | 2 +- plugins/webauth/webauth.go | 2 +- plugins/zeromq/plugin.go | 4 +- 26 files changed, 134 insertions(+), 106 deletions(-) create mode 100644 packages/parameter/parameter.go delete mode 100644 packages/timeutil/sleep.go delete mode 100644 packages/timeutil/ticker.go diff --git a/go.mod b/go.mod index 8c74798251..5b3fb068ca 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/go-zeromq/zmq4 v0.7.0 github.com/golang/protobuf v1.3.2 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20 + github.com/iotaledger/hive.go v0.0.0-20200107010340-3674684388b3 github.com/iotaledger/iota.go v1.0.0-beta.13 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect @@ -21,15 +21,13 @@ require ( github.com/mattn/go-isatty v0.0.11 // indirect github.com/mattn/go-runewidth v0.0.7 // indirect github.com/pelletier/go-toml v1.6.0 // indirect - github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect github.com/pkg/errors v0.8.1 github.com/rivo/tview v0.0.0-20191229165609-1ee8d9874dcf - github.com/sasha-s/go-deadlock v0.2.0 // indirect github.com/spf13/afero v1.2.2 // indirect github.com/spf13/cast v1.3.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 - github.com/spf13/viper v1.6.1 // indirect + github.com/spf13/viper v1.6.1 github.com/stretchr/objx v0.2.0 // indirect github.com/stretchr/testify v1.4.0 github.com/valyala/fasttemplate v1.1.0 // indirect diff --git a/go.sum b/go.sum index 1a6b6612f4..4d8c9d4c12 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,7 @@ github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIo github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -24,7 +25,10 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgraph-io/badger v1.5.4/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ= +github.com/dgraph-io/badger v1.6.0 h1:DshxFxZWXUcO0xX476VJC07Xsr6ZCBVRHKZ93Oh7Evo= github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= +github.com/dgraph-io/badger/v2 v2.0.0/go.mod h1:YoRSIp1LmAJ7zH7tZwRvjNMUYLxB4wl3ebYkaIruZ04= +github.com/dgraph-io/ristretto v0.0.0-20191025175511-c1f00be0418e/go.mod h1:edzKIzGvqUCMzhTVWbiTSe75zD9Xxq0GtSBtFmaUTZs= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190323231341-8198c7b169ec/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= @@ -32,8 +36,11 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUn github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b h1:SeiGBzKrEtuDddnBABHkp4kq9sBGE9nuYmk6FPTg0zg= github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/tcell v1.3.0 h1:r35w0JBADPZCVQijYebl6YMWWtHRqVEGt7kL2eBADRM= github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM= @@ -53,6 +60,7 @@ github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4er github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -69,12 +77,15 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmg github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20 h1:ZIJAeQSEdmVbmZNIW2198IwD23+wBteb4WE4pyjxk+c= github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20/go.mod h1:7iqun29a1x0lymTrn0UJ3Z/yy0sUzUpoOZ1OYMrYN20= +github.com/iotaledger/hive.go v0.0.0-20200107010340-3674684388b3 h1:Ognd+3Z0qhQz9LAAwKA6ma8nDiDfClEIsxrUfZnvmmU= +github.com/iotaledger/hive.go v0.0.0-20200107010340-3674684388b3/go.mod h1:vrZrvGaWT1o5kz3Jj2B/PcUtqsFzZnLWrO3zEsGSuwk= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/iotaledger/iota.go v1.0.0-beta.13 h1:6m6JRcKtjTflU2PbjvDA9Tv6NTEJX1PijBDOkH9weQc= github.com/iotaledger/iota.go v1.0.0-beta.13/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= @@ -91,6 +102,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= github.com/labstack/echo v3.3.10+incompatible/go.mod h1:0INS7j/VjnFxD4E2wkz67b8cVwCLbBmJyDaka6Cmk1s= github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0= github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= @@ -98,6 +110,7 @@ github.com/lucasb-eyer/go-colorful v1.0.2/go.mod h1:0MS4r+7BZKSJ5mw4/S5MPN+qHFF1 github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= @@ -111,6 +124,7 @@ github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+tw github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= @@ -120,12 +134,14 @@ github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/panjf2000/ants/v2 v2.2.2/go.mod h1:1GFm8bV8nyCQvU5K4WvBCTG1/YBFOD2VzjffD8fV55A= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.6.0 h1:aetoXYr0Tv7xRU/V4B4IZJ2QcbtMUFoNb3ORp7TzIK4= github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -139,6 +155,7 @@ github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7z github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rivo/tview v0.0.0-20191229165609-1ee8d9874dcf h1:rh73WIukDlFIRqk1lk76or+LExEjTci2789EDvDD67U= github.com/rivo/tview v0.0.0-20191229165609-1ee8d9874dcf/go.mod h1:/rBeY22VG2QprWnEqG57IBC8biVu3i0DOIjRLc9I8H0= +github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= @@ -153,13 +170,16 @@ github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIK github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -181,6 +201,7 @@ github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhV github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.1.0 h1:RZqt0yGBsps8NGvLSGW804QQqCUYYLsaOjTVHy1Ocw4= @@ -254,6 +275,7 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 h1:JA8d3MPx/IToSyXZG/RhwYEtfrKO1Fxrqe8KrkiLXKM= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -279,6 +301,7 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= diff --git a/main.go b/main.go index 1ac904adae..e55cd40dd6 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,9 @@ package main import ( + "net/http" + _ "net/http/pprof" + "github.com/iotaledger/goshimmer/plugins/analysis" "github.com/iotaledger/goshimmer/plugins/autopeering" "github.com/iotaledger/goshimmer/plugins/bundleprocessor" @@ -25,29 +28,34 @@ import ( ) func main() { + + go http.ListenAndServe("localhost:6060", nil) // pprof Server for Debbuging Mutexes + node.Run( - cli.PLUGIN, - autopeering.PLUGIN, - gossip.PLUGIN, - tangle.PLUGIN, - bundleprocessor.PLUGIN, - analysis.PLUGIN, - gracefulshutdown.PLUGIN, - tipselection.PLUGIN, - zeromq.PLUGIN, - dashboard.PLUGIN, - metrics.PLUGIN, + node.Plugins( + cli.PLUGIN, + autopeering.PLUGIN, + gossip.PLUGIN, + tangle.PLUGIN, + bundleprocessor.PLUGIN, + analysis.PLUGIN, + gracefulshutdown.PLUGIN, + tipselection.PLUGIN, + zeromq.PLUGIN, + dashboard.PLUGIN, + metrics.PLUGIN, - statusscreen.PLUGIN, - statusscreen_tps.PLUGIN, + statusscreen.PLUGIN, + statusscreen_tps.PLUGIN, - webapi.PLUGIN, - webapi_gtta.PLUGIN, - webapi_spammer.PLUGIN, - webapi_send_data.PLUGIN, - webapi_tx_request.PLUGIN, + webapi.PLUGIN, + webapi_gtta.PLUGIN, + webapi_spammer.PLUGIN, + webapi_send_data.PLUGIN, + webapi_tx_request.PLUGIN, - ui.PLUGIN, - webauth.PLUGIN, + ui.PLUGIN, + webauth.PLUGIN, + ), ) } diff --git a/packages/database/badger_instance.go b/packages/database/badger_instance.go index fcaae5f51a..3f6fd82fdc 100644 --- a/packages/database/badger_instance.go +++ b/packages/database/badger_instance.go @@ -6,7 +6,7 @@ import ( "github.com/dgraph-io/badger" "github.com/dgraph-io/badger/options" - "github.com/iotaledger/hive.go/parameter" + "github.com/iotaledger/goshimmer/packages/parameter" "github.com/pkg/errors" ) diff --git a/packages/parameter/parameter.go b/packages/parameter/parameter.go new file mode 100644 index 0000000000..86cfd4503c --- /dev/null +++ b/packages/parameter/parameter.go @@ -0,0 +1,34 @@ +package parameter + +import ( + flag "github.com/spf13/pflag" + "github.com/spf13/viper" + + "github.com/iotaledger/hive.go/parameter" +) + +var ( + // flags + configName = flag.StringP("config", "c", "config", "Filename of the config file without the file extension") + configDirPath = flag.StringP("config-dir", "d", ".", "Path to the directory containing the config file") + + // Viper + NodeConfig = viper.New() +) + +// FetchConfig fetches config values from a dir defined via CLI flag --config-dir (or the current working dir if not set). +// +// It automatically reads in a single config file starting with "config" (can be changed via the --config CLI flag) +// and ending with: .json, .toml, .yaml or .yml (in this sequence). +func FetchConfig(printConfig bool, ignoreSettingsAtPrint ...[]string) error { + + err := parameter.LoadConfigFile(NodeConfig, *configDirPath, *configName, true, false) + if err != nil { + return err + } + + if printConfig { + parameter.PrintConfig(NodeConfig, ignoreSettingsAtPrint...) + } + return nil +} diff --git a/packages/timeutil/sleep.go b/packages/timeutil/sleep.go deleted file mode 100644 index 448c54d0fb..0000000000 --- a/packages/timeutil/sleep.go +++ /dev/null @@ -1,17 +0,0 @@ -package timeutil - -import ( - "time" - - "github.com/iotaledger/hive.go/daemon" -) - -func Sleep(interval time.Duration) bool { - select { - case <-daemon.ShutdownSignal: - return false - - case <-time.After(interval): - return true - } -} diff --git a/packages/timeutil/ticker.go b/packages/timeutil/ticker.go deleted file mode 100644 index 7530cd0999..0000000000 --- a/packages/timeutil/ticker.go +++ /dev/null @@ -1,20 +0,0 @@ -package timeutil - -import ( - "time" - - "github.com/iotaledger/hive.go/daemon" -) - -func Ticker(handler func(), interval time.Duration) { - ticker := time.NewTicker(interval) -ticker: - for { - select { - case <-daemon.ShutdownSignal: - break ticker - case <-ticker.C: - handler() - } - } -} diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index aaf868830f..8767c14a89 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -34,13 +34,13 @@ func Start(tps uint) { spamming = true spammingMutex.Unlock() - daemon.BackgroundWorker("Transaction Spammer", func() { + daemon.BackgroundWorker("Transaction Spammer", func(daemonShutdownSignal <-chan struct{}) { start := time.Now() totalSentCounter := int64(0) for { select { - case <-daemon.ShutdownSignal: + case <-daemonShutdownSignal: return case <-shutdownSignal: diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index 8a0559bde4..1dd3054876 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -5,41 +5,40 @@ import ( "net" "time" - "github.com/iotaledger/goshimmer/plugins/autopeering/local" - "github.com/iotaledger/goshimmer/packages/autopeering/discover" "github.com/iotaledger/goshimmer/packages/autopeering/selection" "github.com/iotaledger/goshimmer/packages/network" - "github.com/iotaledger/goshimmer/packages/timeutil" + "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/analysis/types/addnode" "github.com/iotaledger/goshimmer/plugins/analysis/types/connectnodes" "github.com/iotaledger/goshimmer/plugins/analysis/types/disconnectnodes" "github.com/iotaledger/goshimmer/plugins/analysis/types/ping" "github.com/iotaledger/goshimmer/plugins/analysis/types/removenode" "github.com/iotaledger/goshimmer/plugins/autopeering" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" - "github.com/iotaledger/hive.go/parameter" + "github.com/iotaledger/hive.go/timeutil" ) var log = logger.NewLogger("Analysis-Client") func Run(plugin *node.Plugin) { - daemon.BackgroundWorker("Analysis Client", func() { + daemon.BackgroundWorker("Analysis Client", func(shutdownSignal <-chan struct{}) { shuttingDown := false for !shuttingDown { select { - case <-daemon.ShutdownSignal: + case <-shutdownSignal: return default: if conn, err := net.Dial("tcp", parameter.NodeConfig.GetString(CFG_SERVER_ADDRESS)); err != nil { log.Debugf("Could not connect to reporting server: %s", err.Error()) - timeutil.Sleep(1 * time.Second) + timeutil.Sleep(1*time.Second, shutdownSignal) } else { managedConn := network.NewManagedConnection(conn) eventDispatchers := getEventDispatchers(managedConn) @@ -47,7 +46,7 @@ func Run(plugin *node.Plugin) { reportCurrentStatus(eventDispatchers) setupHooks(plugin, managedConn, eventDispatchers) - shuttingDown = keepConnectionAlive(managedConn) + shuttingDown = keepConnectionAlive(managedConn, shutdownSignal) } } } @@ -138,13 +137,13 @@ func reportChosenNeighbors(dispatchers *EventDispatchers) { } } -func keepConnectionAlive(conn *network.ManagedConnection) bool { +func keepConnectionAlive(conn *network.ManagedConnection, shutdownSignal <-chan struct{}) bool { go conn.Read(make([]byte, 1)) ticker := time.NewTicker(1 * time.Second) for { select { - case <-daemon.ShutdownSignal: + case <-shutdownSignal: return true case <-ticker.C: diff --git a/plugins/analysis/plugin.go b/plugins/analysis/plugin.go index 7721f971f8..f7ffdbc3d9 100644 --- a/plugins/analysis/plugin.go +++ b/plugins/analysis/plugin.go @@ -1,6 +1,7 @@ package analysis import ( + "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/analysis/client" "github.com/iotaledger/goshimmer/plugins/analysis/server" "github.com/iotaledger/goshimmer/plugins/analysis/webinterface" @@ -8,7 +9,6 @@ import ( "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" - "github.com/iotaledger/hive.go/parameter" ) var PLUGIN = node.NewPlugin("Analysis", node.Enabled, configure, run) @@ -35,6 +35,7 @@ func run(plugin *node.Plugin) { if parameter.NodeConfig.GetString(client.CFG_SERVER_ADDRESS) != "" { client.Run(plugin) + log.Info("Stopping Analysis-Client ... done") } else { log.Info("Starting Plugin: Analysis ... client is disabled (server-address is empty)") } diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index c5733df3fd..4f67de7d0e 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -6,6 +6,7 @@ import ( "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/network/tcp" + "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/analysis/types/addnode" "github.com/iotaledger/goshimmer/plugins/analysis/types/connectnodes" "github.com/iotaledger/goshimmer/plugins/analysis/types/disconnectnodes" @@ -15,7 +16,6 @@ import ( "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" - "github.com/iotaledger/hive.go/parameter" "github.com/pkg/errors" ) @@ -39,7 +39,7 @@ func Configure(plugin *node.Plugin) { } func Run(plugin *node.Plugin) { - daemon.BackgroundWorker("Analysis Server", func() { + daemon.BackgroundWorker("Analysis Server", func(shutdownSignal <-chan struct{}) { log.Infof("Starting Server (port %d) ... done", parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) server.Listen(parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) }) diff --git a/plugins/analysis/webinterface/httpserver/plugin.go b/plugins/analysis/webinterface/httpserver/plugin.go index d02d449ed0..20051f0f1a 100644 --- a/plugins/analysis/webinterface/httpserver/plugin.go +++ b/plugins/analysis/webinterface/httpserver/plugin.go @@ -32,7 +32,7 @@ func Configure(plugin *node.Plugin) { } func Run(plugin *node.Plugin) { - daemon.BackgroundWorker("Analysis HTTP Server", func() { + daemon.BackgroundWorker("Analysis HTTP Server", func(shutdownSignal <-chan struct{}) { httpServer.ListenAndServe() }) } diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 9a6ccb670b..3bbbd33957 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -13,9 +13,8 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/selection" "github.com/iotaledger/goshimmer/packages/autopeering/server" "github.com/iotaledger/goshimmer/packages/autopeering/transport" + "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/autopeering/local" - "github.com/iotaledger/hive.go/daemon" - "github.com/iotaledger/hive.go/parameter" "github.com/pkg/errors" ) @@ -72,7 +71,7 @@ func configureAP() { } } -func start() { +func start(shutdownSignal <-chan struct{}) { defer log.Info("Stopping Auto Peering server ... done") addr := local.GetInstance().Services().Get(service.PeeringKey) @@ -120,7 +119,7 @@ func start() { log.Infof("Auto Peering server started: ID=%x, address=%s", local.GetInstance().ID(), srv.LocalAddr()) - <-daemon.ShutdownSignal + <-shutdownSignal log.Info("Stopping Auto Peering server ...") } diff --git a/plugins/autopeering/local/local.go b/plugins/autopeering/local/local.go index a477cd8abd..58381256ae 100644 --- a/plugins/autopeering/local/local.go +++ b/plugins/autopeering/local/local.go @@ -10,7 +10,7 @@ import ( "sync" "github.com/iotaledger/goshimmer/packages/autopeering/peer" - "github.com/iotaledger/hive.go/parameter" + "github.com/iotaledger/goshimmer/packages/parameter" "go.uber.org/zap" ) diff --git a/plugins/bundleprocessor/plugin.go b/plugins/bundleprocessor/plugin.go index 2344caa6c4..d7f6dbb7bd 100644 --- a/plugins/bundleprocessor/plugin.go +++ b/plugins/bundleprocessor/plugin.go @@ -38,7 +38,7 @@ func configure(plugin *node.Plugin) { func run(plugin *node.Plugin) { log.Info("Starting Bundle Processor ...") - daemon.BackgroundWorker("Bundle Processor", func() { + daemon.BackgroundWorker("Bundle Processor", func(shutdownSignal <-chan struct{}) { log.Info("Starting Bundle Processor ... done") workerPool.Run() log.Info("Stopping Bundle Processor ... done") @@ -46,7 +46,7 @@ func run(plugin *node.Plugin) { log.Info("Starting Value Bundle Processor ...") - daemon.BackgroundWorker("Value Bundle Processor", func() { + daemon.BackgroundWorker("Value Bundle Processor", func(shutdownSignal <-chan struct{}) { log.Info("Starting Value Bundle Processor ... done") valueBundleProcessorWorkerPool.Run() log.Info("Stopping Value Bundle Processor ... done") diff --git a/plugins/cli/plugin.go b/plugins/cli/plugin.go index 51b86bcb26..d4da0e2a5c 100644 --- a/plugins/cli/plugin.go +++ b/plugins/cli/plugin.go @@ -4,9 +4,9 @@ import ( "fmt" "strings" + "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" - "github.com/iotaledger/hive.go/parameter" flag "github.com/spf13/pflag" ) @@ -53,7 +53,9 @@ func configure(ctx *node.Plugin) { fmt.Printf(" \\____/\\_| |_/\\___/\\_| |_/\\_| |_/\\____/\\_| \\_| fullnode %s", AppVersion) fmt.Println() - parameter.FetchConfig(false) + if err := parameter.FetchConfig(true); err != nil { + panic(err) + } parseParameters() ctx.Node.Logger.Info("Loading plugins ...") diff --git a/plugins/dashboard/plugin.go b/plugins/dashboard/plugin.go index 1601f24377..708a801e35 100644 --- a/plugins/dashboard/plugin.go +++ b/plugins/dashboard/plugin.go @@ -43,7 +43,7 @@ func configure(plugin *node.Plugin) { } func run(plugin *node.Plugin) { - daemon.BackgroundWorker("Dashboard Updater", func() { + daemon.BackgroundWorker("Dashboard Updater", func(shutdownSignal <-chan struct{}) { go func() { if err := server.ListenAndServe(); err != nil { log.Error(err.Error()) diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 16433e336c..8b552c69f8 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -10,10 +10,9 @@ import ( "github.com/iotaledger/goshimmer/packages/errors" gp "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/gossip/server" + "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/tangle" - "github.com/iotaledger/hive.go/daemon" - "github.com/iotaledger/hive.go/parameter" "github.com/iotaledger/hive.go/typeutils" ) @@ -61,7 +60,7 @@ func configureGossip() { mgr = gp.NewManager(lPeer, getTransaction, zLogger) } -func start() { +func start(shutdownSignal <-chan struct{}) { defer log.Info("Stopping Gossip ... done") srv, err := server.ListenTCP(local.GetInstance(), zLogger) @@ -75,7 +74,7 @@ func start() { log.Infof("Gossip started: address=%v", mgr.LocalAddr()) - <-daemon.ShutdownSignal + <-shutdownSignal log.Info("Stopping Gossip ...") } diff --git a/plugins/metrics/plugin.go b/plugins/metrics/plugin.go index 65a4418120..4774c72d3c 100644 --- a/plugins/metrics/plugin.go +++ b/plugins/metrics/plugin.go @@ -4,10 +4,10 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/gossip" - "github.com/iotaledger/goshimmer/packages/timeutil" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/timeutil" ) var PLUGIN = node.NewPlugin("Metrics", node.Enabled, configure, run) @@ -19,5 +19,7 @@ func configure(plugin *node.Plugin) { func run(plugin *node.Plugin) { // create a background worker that "measures" the TPS value every second - daemon.BackgroundWorker("Metrics TPS Updater", func() { timeutil.Ticker(measureReceivedTPS, 1*time.Second) }) + daemon.BackgroundWorker("Metrics TPS Updater", func(shutdownSignal <-chan struct{}) { + timeutil.Ticker(measureReceivedTPS, 1*time.Second, shutdownSignal) + }) } diff --git a/plugins/statusscreen-tps/plugin.go b/plugins/statusscreen-tps/plugin.go index 7433b286a9..c4909e45e6 100644 --- a/plugins/statusscreen-tps/plugin.go +++ b/plugins/statusscreen-tps/plugin.go @@ -35,12 +35,12 @@ var PLUGIN = node.NewPlugin("Statusscreen TPS", node.Enabled, func(plugin *node. return "TPS", strconv.FormatUint(atomic.LoadUint64(&receivedTps), 10) + " received / " + strconv.FormatUint(atomic.LoadUint64(&solidTps), 10) + " new" }) }, func(plugin *node.Plugin) { - daemon.BackgroundWorker("Statusscreen TPS Tracker", func() { + daemon.BackgroundWorker("Statusscreen TPS Tracker", func(shutdownSignal <-chan struct{}) { ticker := time.NewTicker(time.Second) for { select { - case <-daemon.ShutdownSignal: + case <-shutdownSignal: return case <-ticker.C: diff --git a/plugins/statusscreen/statusscreen.go b/plugins/statusscreen/statusscreen.go index 575a1b3bc9..06057fd4a6 100644 --- a/plugins/statusscreen/statusscreen.go +++ b/plugins/statusscreen/statusscreen.go @@ -136,10 +136,10 @@ func run(plugin *node.Plugin) { return false }) - daemon.BackgroundWorker("Statusscreen Refresher", func() { + daemon.BackgroundWorker("Statusscreen Refresher", func(shutdownSignal <-chan struct{}) { for { select { - case <-daemon.ShutdownSignal: + case <-shutdownSignal: return case <-time.After(1 * time.Second): app.QueueUpdateDraw(func() {}) @@ -147,7 +147,7 @@ func run(plugin *node.Plugin) { } }) - daemon.BackgroundWorker("Statusscreen App", func() { + daemon.BackgroundWorker("Statusscreen App", func(shutdownSignal <-chan struct{}) { if err := app.SetRoot(frame, true).SetFocus(frame).Run(); err != nil { panic(err) } diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index dddd71e960..de2526d6ce 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -54,7 +54,7 @@ func configureSolidifier(plugin *node.Plugin) { func runSolidifier(plugin *node.Plugin) { log.Info("Starting Solidifier ...") - daemon.BackgroundWorker("Tangle Solidifier", func() { + daemon.BackgroundWorker("Tangle Solidifier", func(shutdownSignal <-chan struct{}) { log.Info("Starting Solidifier ... done") workerPool.Run() log.Info("Stopping Solidifier ... done") diff --git a/plugins/ui/ui.go b/plugins/ui/ui.go index 86add4dfce..02e248a3f6 100644 --- a/plugins/ui/ui.go +++ b/plugins/ui/ui.go @@ -72,10 +72,10 @@ func staticFileServer(c echo.Context) error { func run(plugin *node.Plugin) { - daemon.BackgroundWorker("UI Refresher", func() { + daemon.BackgroundWorker("UI Refresher", func(shutdownSignal <-chan struct{}) { for { select { - case <-daemon.ShutdownSignal: + case <-shutdownSignal: return case <-time.After(1 * time.Second): wsMutex.Lock() diff --git a/plugins/webapi/plugin.go b/plugins/webapi/plugin.go index 325a091861..4d3177ee78 100644 --- a/plugins/webapi/plugin.go +++ b/plugins/webapi/plugin.go @@ -36,7 +36,7 @@ func configure(plugin *node.Plugin) { func run(plugin *node.Plugin) { log.Info("Starting Web Server ...") - daemon.BackgroundWorker("WebAPI Server", func() { + daemon.BackgroundWorker("WebAPI Server", func(shutdownSignal <-chan struct{}) { log.Info("Starting Web Server ... done") if err := Server.Start(":8080"); err != nil { diff --git a/plugins/webauth/webauth.go b/plugins/webauth/webauth.go index b8e118147f..b2c898a873 100644 --- a/plugins/webauth/webauth.go +++ b/plugins/webauth/webauth.go @@ -40,7 +40,7 @@ func configure(plugin *node.Plugin) { } func run(plugin *node.Plugin) { - daemon.BackgroundWorker("webauth", func() { + daemon.BackgroundWorker("webauth", func(shutdownSignal <-chan struct{}) { webapi.AddEndpoint("login", func(c echo.Context) error { username := c.FormValue("username") password := c.FormValue("password") diff --git a/plugins/zeromq/plugin.go b/plugins/zeromq/plugin.go index 5406b95216..aa547901ae 100644 --- a/plugins/zeromq/plugin.go +++ b/plugins/zeromq/plugin.go @@ -6,12 +6,12 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" - "github.com/iotaledger/hive.go/parameter" ) // zeromq logging is disabled by default @@ -48,7 +48,7 @@ func run(plugin *node.Plugin) { zeromqPort := parameter.NodeConfig.GetInt(ZEROMQ_PORT) log.Infof("Starting ZeroMQ Publisher (port %d) ...", zeromqPort) - daemon.BackgroundWorker("ZeroMQ Publisher", func() { + daemon.BackgroundWorker("ZeroMQ Publisher", func(shutdownSignal <-chan struct{}) { if err := startPublisher(plugin); err != nil { log.Errorf("Stopping ZeroMQ Publisher: %s", err.Error()) } else { From e53cfef013d2cb973b8a90587f611f87278ec438 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Tue, 7 Jan 2020 13:42:00 +0100 Subject: [PATCH 073/184] removes daemon.Events.Shutdown listeners --- plugins/analysis/plugin.go | 7 ----- plugins/analysis/server/plugin.go | 8 ++++-- .../webinterface/httpserver/plugin.go | 14 ++++------ plugins/bundleprocessor/plugin.go | 20 ++++++------- plugins/dashboard/plugin.go | 12 ++++---- plugins/statusscreen/statusscreen.go | 6 ++-- plugins/tangle/solidifier.go | 10 +++---- plugins/webapi/plugin.go | 28 +++++++++---------- plugins/zeromq/plugin.go | 20 ++++++------- 9 files changed, 53 insertions(+), 72 deletions(-) diff --git a/plugins/analysis/plugin.go b/plugins/analysis/plugin.go index f7ffdbc3d9..0208ca1d91 100644 --- a/plugins/analysis/plugin.go +++ b/plugins/analysis/plugin.go @@ -5,8 +5,6 @@ import ( "github.com/iotaledger/goshimmer/plugins/analysis/client" "github.com/iotaledger/goshimmer/plugins/analysis/server" "github.com/iotaledger/goshimmer/plugins/analysis/webinterface" - "github.com/iotaledger/hive.go/daemon" - "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" ) @@ -18,10 +16,6 @@ func configure(plugin *node.Plugin) { if parameter.NodeConfig.GetInt(server.CFG_SERVER_PORT) != 0 { webinterface.Configure(plugin) server.Configure(plugin) - - daemon.Events.Shutdown.Attach(events.NewClosure(func() { - server.Shutdown(plugin) - })) } } @@ -35,7 +29,6 @@ func run(plugin *node.Plugin) { if parameter.NodeConfig.GetString(client.CFG_SERVER_ADDRESS) != "" { client.Run(plugin) - log.Info("Stopping Analysis-Client ... done") } else { log.Info("Starting Plugin: Analysis ... client is disabled (server-address is empty)") } diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index 4f67de7d0e..40fabc28ac 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -41,14 +41,16 @@ func Configure(plugin *node.Plugin) { func Run(plugin *node.Plugin) { daemon.BackgroundWorker("Analysis Server", func(shutdownSignal <-chan struct{}) { log.Infof("Starting Server (port %d) ... done", parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) - server.Listen(parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) + go server.Listen(parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) + <-shutdownSignal + Shutdown() }) } -func Shutdown(plugin *node.Plugin) { +func Shutdown() { log.Info("Stopping Server ...") - server.Shutdown() + log.Info("Stopping Server ... done") } func HandleConnection(conn *network.ManagedConnection) { diff --git a/plugins/analysis/webinterface/httpserver/plugin.go b/plugins/analysis/webinterface/httpserver/plugin.go index 20051f0f1a..0299e173ed 100644 --- a/plugins/analysis/webinterface/httpserver/plugin.go +++ b/plugins/analysis/webinterface/httpserver/plugin.go @@ -5,7 +5,6 @@ import ( "time" "github.com/iotaledger/hive.go/daemon" - "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" "golang.org/x/net/context" "golang.org/x/net/websocket" @@ -22,17 +21,14 @@ func Configure(plugin *node.Plugin) { router.Handle("/datastream", websocket.Handler(dataStream)) router.HandleFunc("/", index) - - daemon.Events.Shutdown.Attach(events.NewClosure(func() { - ctx, cancel := context.WithTimeout(context.Background(), 0*time.Second) - defer cancel() - - httpServer.Shutdown(ctx) - })) } func Run(plugin *node.Plugin) { daemon.BackgroundWorker("Analysis HTTP Server", func(shutdownSignal <-chan struct{}) { - httpServer.ListenAndServe() + go httpServer.ListenAndServe() + <-shutdownSignal + ctx, cancel := context.WithTimeout(context.Background(), 0*time.Second) + defer cancel() + httpServer.Shutdown(ctx) }) } diff --git a/plugins/bundleprocessor/plugin.go b/plugins/bundleprocessor/plugin.go index d7f6dbb7bd..c95eeeed59 100644 --- a/plugins/bundleprocessor/plugin.go +++ b/plugins/bundleprocessor/plugin.go @@ -23,16 +23,6 @@ func configure(plugin *node.Plugin) { Events.Error.Attach(events.NewClosure(func(err errors.IdentifiableError) { log.Error(err.Error()) })) - - daemon.Events.Shutdown.Attach(events.NewClosure(func() { - log.Info("Stopping Bundle Processor ...") - - workerPool.Stop() - - log.Info("Stopping Value Bundle Processor ...") - - valueBundleProcessorWorkerPool.Stop() - })) } func run(plugin *node.Plugin) { @@ -40,7 +30,10 @@ func run(plugin *node.Plugin) { daemon.BackgroundWorker("Bundle Processor", func(shutdownSignal <-chan struct{}) { log.Info("Starting Bundle Processor ... done") - workerPool.Run() + workerPool.Start() + <-shutdownSignal + log.Info("Stopping Bundle Processor ...") + workerPool.Stop() log.Info("Stopping Bundle Processor ... done") }) @@ -48,7 +41,10 @@ func run(plugin *node.Plugin) { daemon.BackgroundWorker("Value Bundle Processor", func(shutdownSignal <-chan struct{}) { log.Info("Starting Value Bundle Processor ... done") - valueBundleProcessorWorkerPool.Run() + valueBundleProcessorWorkerPool.Start() + <-shutdownSignal + log.Info("Stopping Value Bundle Processor ...") + valueBundleProcessorWorkerPool.Stop() log.Info("Stopping Value Bundle Processor ... done") }) } diff --git a/plugins/dashboard/plugin.go b/plugins/dashboard/plugin.go index 708a801e35..f263b4b88a 100644 --- a/plugins/dashboard/plugin.go +++ b/plugins/dashboard/plugin.go @@ -33,13 +33,6 @@ func configure(plugin *node.Plugin) { TPSQ = TPSQ[1:] } })) - - daemon.Events.Shutdown.Attach(events.NewClosure(func() { - ctx, cancel := context.WithTimeout(context.Background(), 0*time.Second) - defer cancel() - - _ = server.Shutdown(ctx) - })) } func run(plugin *node.Plugin) { @@ -49,5 +42,10 @@ func run(plugin *node.Plugin) { log.Error(err.Error()) } }() + + <-shutdownSignal + ctx, cancel := context.WithTimeout(context.Background(), 0*time.Second) + defer cancel() + _ = server.Shutdown(ctx) }) } diff --git a/plugins/statusscreen/statusscreen.go b/plugins/statusscreen/statusscreen.go index 06057fd4a6..e488b59ac4 100644 --- a/plugins/statusscreen/statusscreen.go +++ b/plugins/statusscreen/statusscreen.go @@ -36,14 +36,14 @@ func configure(plugin *node.Plugin) { }) logger.Events.AnyMsg.Attach(anyLogMsgClosure) - daemon.Events.Shutdown.Attach(events.NewClosure(func() { + daemon.BackgroundWorker("UI-Detach", func(shutdownSignal <-chan struct{}) { + <-shutdownSignal logger.InjectWriters(os.Stdout) logger.Events.AnyMsg.Detach(anyLogMsgClosure) - if app != nil { app.Stop() } - })) + }, 1) } func run(plugin *node.Plugin) { diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index de2526d6ce..af7b07c525 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -44,11 +44,6 @@ func configureSolidifier(plugin *node.Plugin) { workerPool.Submit(metaTx) })) - - daemon.Events.Shutdown.Attach(events.NewClosure(func() { - log.Info("Stopping Solidifier ...") - workerPool.Stop() - })) } func runSolidifier(plugin *node.Plugin) { @@ -56,7 +51,10 @@ func runSolidifier(plugin *node.Plugin) { daemon.BackgroundWorker("Tangle Solidifier", func(shutdownSignal <-chan struct{}) { log.Info("Starting Solidifier ... done") - workerPool.Run() + workerPool.Start() + <-shutdownSignal + log.Info("Stopping Solidifier ...") + workerPool.Stop() log.Info("Stopping Solidifier ... done") }) } diff --git a/plugins/webapi/plugin.go b/plugins/webapi/plugin.go index 4d3177ee78..e7d7c5a32f 100644 --- a/plugins/webapi/plugin.go +++ b/plugins/webapi/plugin.go @@ -5,7 +5,6 @@ import ( "time" "github.com/iotaledger/hive.go/daemon" - "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" "github.com/labstack/echo" @@ -20,17 +19,6 @@ func configure(plugin *node.Plugin) { Server.HideBanner = true Server.HidePort = true Server.GET("/", IndexRequest) - - daemon.Events.Shutdown.Attach(events.NewClosure(func() { - log.Info("Stopping Web Server ...") - - ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) - defer cancel() - - if err := Server.Shutdown(ctx); err != nil { - log.Errorf("Couldn't stop server cleanly: %s", err.Error()) - } - })) } func run(plugin *node.Plugin) { @@ -39,8 +27,20 @@ func run(plugin *node.Plugin) { daemon.BackgroundWorker("WebAPI Server", func(shutdownSignal <-chan struct{}) { log.Info("Starting Web Server ... done") - if err := Server.Start(":8080"); err != nil { - log.Info("Stopping Web Server ... done") + go func() { + if err := Server.Start(":8080"); err != nil { + log.Info("Stopping Web Server ... done") + } + }() + + <-shutdownSignal + + log.Info("Stopping Web Server ...") + ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second) + defer cancel() + + if err := Server.Shutdown(ctx); err != nil { + log.Errorf("Couldn't stop server cleanly: %s", err.Error()) } }) } diff --git a/plugins/zeromq/plugin.go b/plugins/zeromq/plugin.go index aa547901ae..c9d469a85a 100644 --- a/plugins/zeromq/plugin.go +++ b/plugins/zeromq/plugin.go @@ -22,17 +22,6 @@ var emptyTag = strings.Repeat("9", 27) // Configure the zeromq plugin func configure(plugin *node.Plugin) { - - daemon.Events.Shutdown.Attach(events.NewClosure(func() { - log.Info("Stopping ZeroMQ Publisher ...") - - if err := publisher.Shutdown(); err != nil { - log.Errorf("Stopping ZeroMQ Publisher: %s", err.Error()) - } else { - log.Info("Stopping ZeroMQ Publisher ... done") - } - })) - tangle.Events.TransactionStored.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { // create goroutine for every event go func() { @@ -54,6 +43,15 @@ func run(plugin *node.Plugin) { } else { log.Infof("Starting ZeroMQ Publisher (port %d) ... done", zeromqPort) } + + <-shutdownSignal + + log.Info("Stopping ZeroMQ Publisher ...") + if err := publisher.Shutdown(); err != nil { + log.Errorf("Stopping ZeroMQ Publisher: %s", err.Error()) + } else { + log.Info("Stopping ZeroMQ Publisher ... done") + } }) } From e7b6c51e9e38925675755b29400a79edf9bbfc75 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Tue, 7 Jan 2020 13:45:58 +0100 Subject: [PATCH 074/184] update to latest hive.go --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 5b3fb068ca..ea59aaa234 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/go-zeromq/zmq4 v0.7.0 github.com/golang/protobuf v1.3.2 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/hive.go v0.0.0-20200107010340-3674684388b3 + github.com/iotaledger/hive.go v0.0.0-20200107124343-d0fddfc88dea github.com/iotaledger/iota.go v1.0.0-beta.13 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect diff --git a/go.sum b/go.sum index 4d8c9d4c12..81cc42b6a8 100644 --- a/go.sum +++ b/go.sum @@ -86,6 +86,8 @@ github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20 h1:ZIJAeQSEdmVb github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20/go.mod h1:7iqun29a1x0lymTrn0UJ3Z/yy0sUzUpoOZ1OYMrYN20= github.com/iotaledger/hive.go v0.0.0-20200107010340-3674684388b3 h1:Ognd+3Z0qhQz9LAAwKA6ma8nDiDfClEIsxrUfZnvmmU= github.com/iotaledger/hive.go v0.0.0-20200107010340-3674684388b3/go.mod h1:vrZrvGaWT1o5kz3Jj2B/PcUtqsFzZnLWrO3zEsGSuwk= +github.com/iotaledger/hive.go v0.0.0-20200107124343-d0fddfc88dea h1:kLGh9F6KOOygmJPynFSgy7DSlFOg4/x5jmOMOF8vFaA= +github.com/iotaledger/hive.go v0.0.0-20200107124343-d0fddfc88dea/go.mod h1:vrZrvGaWT1o5kz3Jj2B/PcUtqsFzZnLWrO3zEsGSuwk= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/iotaledger/iota.go v1.0.0-beta.13 h1:6m6JRcKtjTflU2PbjvDA9Tv6NTEJX1PijBDOkH9weQc= github.com/iotaledger/iota.go v1.0.0-beta.13/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= From 2324812ee0dcda544f5bfdb3598093d20baa17f3 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 8 Jan 2020 08:15:19 +0100 Subject: [PATCH 075/184] fix: fix makefile --- Makefile | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 60211a35d7..045cb830fc 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,21 @@ SHELL := /bin/bash REPO := $(shell pwd) +GOFILES_NOVENDOR := $(shell go list -f "{{.Dir}}" ./...) +PACKAGES_NOVENDOR := $(shell go list ./...) PROTOC_GEN_GO := $(GOPATH)/bin/protoc-gen-go + # Protobuf generated go files PROTO_FILES = $(shell find . -path ./vendor -prune -o -type f -name '*.proto' -print) PROTO_GO_FILES = $(patsubst %.proto, %.pb.go, $(PROTO_FILES)) +PROTO_GO_FILES_REAL = $(shell find . -path ./vendor -prune -o -type f -name '*.pb.go' -print) + +.PHONY: build +build: proto + go build -o shimmer + +# Protobuffing +.PHONY: proto +proto: $(PROTO_GO_FILES) # If $GOPATH/bin/protoc-gen-go does not exist, we'll run this command to install it. $(PROTOC_GEN_GO): @@ -13,5 +25,15 @@ $(PROTOC_GEN_GO): %.pb.go: %.proto | $(PROTOC_GEN_GO) protoc $< --go_out=plugins=grpc,paths=source_relative:. -.PHONY: compile -compile: $(PROTO_GO_FILES) +.PHONY: clean_proto +clean_proto: + @rm -f $(PROTO_GO_FILES_REAL) + +.PHONY: vet +vet: + @echo "Running go vet." + @go vet ${PACKAGES_NOVENDOR} + +.PHONY: test +test: vet + go test -timeout 30s ./... ${GOPACKAGES_NOVENDOR} From 25f6b8888b7278698d10209a44e100bd60fdaacc Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 8 Jan 2020 08:16:05 +0100 Subject: [PATCH 076/184] fix: resolve compiler errors in tests --- go.sum | 5 +-- packages/parameter/parameter.go | 25 +++++++++--- .../bundleprocessor/bundleprocessor_test.go | 39 +++++++------------ plugins/tangle/solidifier_test.go | 13 ++++--- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/go.sum b/go.sum index 81cc42b6a8..c70612451b 100644 --- a/go.sum +++ b/go.sum @@ -82,10 +82,6 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20 h1:ZIJAeQSEdmVbmZNIW2198IwD23+wBteb4WE4pyjxk+c= -github.com/iotaledger/hive.go v0.0.0-20191229233341-c3732738ee20/go.mod h1:7iqun29a1x0lymTrn0UJ3Z/yy0sUzUpoOZ1OYMrYN20= -github.com/iotaledger/hive.go v0.0.0-20200107010340-3674684388b3 h1:Ognd+3Z0qhQz9LAAwKA6ma8nDiDfClEIsxrUfZnvmmU= -github.com/iotaledger/hive.go v0.0.0-20200107010340-3674684388b3/go.mod h1:vrZrvGaWT1o5kz3Jj2B/PcUtqsFzZnLWrO3zEsGSuwk= github.com/iotaledger/hive.go v0.0.0-20200107124343-d0fddfc88dea h1:kLGh9F6KOOygmJPynFSgy7DSlFOg4/x5jmOMOF8vFaA= github.com/iotaledger/hive.go v0.0.0-20200107124343-d0fddfc88dea/go.mod h1:vrZrvGaWT1o5kz3Jj2B/PcUtqsFzZnLWrO3zEsGSuwk= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= @@ -303,6 +299,7 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= diff --git a/packages/parameter/parameter.go b/packages/parameter/parameter.go index 86cfd4503c..fa1adfee75 100644 --- a/packages/parameter/parameter.go +++ b/packages/parameter/parameter.go @@ -1,19 +1,18 @@ package parameter import ( + "github.com/iotaledger/hive.go/parameter" flag "github.com/spf13/pflag" "github.com/spf13/viper" - - "github.com/iotaledger/hive.go/parameter" ) var ( // flags - configName = flag.StringP("config", "c", "config", "Filename of the config file without the file extension") - configDirPath = flag.StringP("config-dir", "d", ".", "Path to the directory containing the config file") + configName = flag.StringP("config", "c", "config", "Filename of the config file without the file extension") + configDirPath = flag.StringP("config-dir", "d", ".", "Path to the directory containing the config file") // Viper - NodeConfig = viper.New() + NodeConfig = viper.New() ) // FetchConfig fetches config values from a dir defined via CLI flag --config-dir (or the current working dir if not set). @@ -21,7 +20,6 @@ var ( // It automatically reads in a single config file starting with "config" (can be changed via the --config CLI flag) // and ending with: .json, .toml, .yaml or .yml (in this sequence). func FetchConfig(printConfig bool, ignoreSettingsAtPrint ...[]string) error { - err := parameter.LoadConfigFile(NodeConfig, *configDirPath, *configName, true, false) if err != nil { return err @@ -32,3 +30,18 @@ func FetchConfig(printConfig bool, ignoreSettingsAtPrint ...[]string) error { } return nil } + +// LoadDefaultConfig only binds the flags, but does not load any config file. +func LoadDefaultConfig(printConfig bool) error { + // only bind the flags + flag.Parse() + err := NodeConfig.BindPFlags(flag.CommandLine) + if err != nil { + return err + } + + if printConfig { + parameter.PrintConfig(NodeConfig) + } + return nil +} diff --git a/plugins/bundleprocessor/bundleprocessor_test.go b/plugins/bundleprocessor/bundleprocessor_test.go index f1b52a48f0..484d6a29b3 100644 --- a/plugins/bundleprocessor/bundleprocessor_test.go +++ b/plugins/bundleprocessor/bundleprocessor_test.go @@ -1,24 +1,30 @@ package bundleprocessor import ( - "os" "sync" "testing" "github.com/iotaledger/goshimmer/packages/client" "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/goshimmer/plugins/tipselection" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" - "github.com/iotaledger/hive.go/parameter" "github.com/iotaledger/iota.go/consts" "github.com/magiconair/properties/assert" ) var seed = client.NewSeed("YFHQWAUPCXC9S9DSHP9NDF9RLNPMZVCMSJKUKQP9SWUSUCPRQXCMDVDVZ9SHHESHIQNCXWBJF9UJSWE9Z", consts.SecurityLevelMedium) +func init() { + err := parameter.LoadDefaultConfig(false) + if err != nil { + log.Fatalf("Failed to initialize config: %s", err) + } +} + func BenchmarkValidateSignatures(b *testing.B) { bundleFactory := client.NewBundleFactory() bundleFactory.AddInput(seed.GetAddress(0), -400) @@ -44,11 +50,6 @@ func BenchmarkValidateSignatures(b *testing.B) { wg.Wait() } -func TestMain(m *testing.M) { - parameter.FetchConfig(false) - os.Exit(m.Run()) -} - func TestValidateSignatures(t *testing.T) { bundleFactory := client.NewBundleFactory() bundleFactory.AddInput(seed.GetAddress(0), -400) @@ -65,11 +66,9 @@ func TestValidateSignatures(t *testing.T) { } func TestProcessSolidBundleHead_Data(t *testing.T) { - // show all error messages for tests - // TODO: adjust logger package - // start a test node - node.Start(tangle.PLUGIN, PLUGIN) + node.Start(node.Plugins(tangle.PLUGIN, PLUGIN)) + defer node.Shutdown() bundleFactory := client.NewBundleFactory() bundleFactory.AddOutput(seed.GetAddress(1), 400, "Testmessage") @@ -90,6 +89,7 @@ func TestProcessSolidBundleHead_Data(t *testing.T) { wg.Done() }) Events.BundleSolid.Attach(testResults) + defer Events.BundleSolid.Detach(testResults) wg.Add(1) @@ -98,19 +98,12 @@ func TestProcessSolidBundleHead_Data(t *testing.T) { } wg.Wait() - - Events.BundleSolid.Detach(testResults) - - // shutdown test node - node.Shutdown() } func TestProcessSolidBundleHead_Value(t *testing.T) { - // show all error messages for tests - // TODO: adjust logger package - // start a test node - node.Start(tangle.PLUGIN, PLUGIN) + node.Start(node.Plugins(tangle.PLUGIN, PLUGIN)) + defer node.Shutdown() bundleFactory := client.NewBundleFactory() bundleFactory.AddInput(seed.GetAddress(0), -400) @@ -133,6 +126,7 @@ func TestProcessSolidBundleHead_Value(t *testing.T) { }) Events.BundleSolid.Attach(testResults) + defer Events.BundleSolid.Detach(testResults) wg.Add(1) @@ -141,9 +135,4 @@ func TestProcessSolidBundleHead_Value(t *testing.T) { } wg.Wait() - - Events.BundleSolid.Detach(testResults) - - // shutdown test node - node.Shutdown() } diff --git a/plugins/tangle/solidifier_test.go b/plugins/tangle/solidifier_test.go index 7b8aaf1dea..139febe3a4 100644 --- a/plugins/tangle/solidifier_test.go +++ b/plugins/tangle/solidifier_test.go @@ -1,22 +1,23 @@ package tangle import ( - "os" "sync" "testing" "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" - "github.com/iotaledger/hive.go/parameter" "github.com/stretchr/testify/require" ) -func TestMain(m *testing.M) { - parameter.FetchConfig(false) - os.Exit(m.Run()) +func init() { + err := parameter.LoadDefaultConfig(false) + if err != nil { + log.Fatalf("Failed to initialize config: %s", err) + } } func TestSolidifier(t *testing.T) { @@ -24,7 +25,7 @@ func TestSolidifier(t *testing.T) { // TODO: adjust logger package // start a test node - node.Start(PLUGIN) + node.Start(node.Plugins(PLUGIN)) // create transactions and chain them together transaction1 := value_transaction.New() From 86048b4a078df3713b3101a095acaed783d43c08 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 8 Jan 2020 08:18:33 +0100 Subject: [PATCH 077/184] fix: format main.go --- main.go | 1 - 1 file changed, 1 deletion(-) diff --git a/main.go b/main.go index e55cd40dd6..54e57babf9 100644 --- a/main.go +++ b/main.go @@ -28,7 +28,6 @@ import ( ) func main() { - go http.ListenAndServe("localhost:6060", nil) // pprof Server for Debbuging Mutexes node.Run( From 254815d9e82714ef4f3f483e42ed3b88eba97af9 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 8 Jan 2020 08:21:47 +0100 Subject: [PATCH 078/184] fix: run make test in travis --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index eb260d0f6c..ee06a55b21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,3 +13,6 @@ env: # we are using go modules, so there is nothing to install install: true + +# use the makefile goal for testing +script: make test From dfdeee43fc1a84585d47e939dd4aed9c3da844a7 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Wed, 8 Jan 2020 11:44:17 +0100 Subject: [PATCH 079/184] updates to new logger --- go.mod | 6 +----- go.sum | 11 +++++++---- main.go | 2 ++ .../transactionspammer/transactionspammer.go | 5 +++-- plugins/analysis/client/plugin.go | 3 ++- plugins/analysis/plugin.go | 3 ++- plugins/analysis/server/plugin.go | 3 ++- plugins/autopeering/plugin.go | 4 +++- plugins/bundleprocessor/plugin.go | 3 ++- plugins/cli/plugin.go | 17 ++++++++++++----- plugins/dashboard/plugin.go | 3 ++- plugins/gossip/plugin.go | 3 ++- plugins/gracefulshutdown/plugin.go | 8 +++++--- plugins/statusscreen/logger.go | 2 +- plugins/statusscreen/status_message.go | 2 +- plugins/statusscreen/statusscreen.go | 8 +------- plugins/statusscreen/ui_log_entry.go | 6 +----- plugins/tangle/plugin.go | 3 ++- plugins/tangle/solidifier.go | 2 +- plugins/ui/logger.go | 10 +++++----- plugins/ui/ui.go | 2 +- plugins/validator/plugin.go | 4 ++-- plugins/webapi-send-data/plugin.go | 5 +++-- plugins/webapi-tx-request/plugin.go | 3 ++- plugins/webapi/plugin.go | 3 ++- plugins/zeromq/plugin.go | 3 ++- 26 files changed, 69 insertions(+), 55 deletions(-) diff --git a/go.mod b/go.mod index ea59aaa234..e07f8c2e3e 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/go-zeromq/zmq4 v0.7.0 github.com/golang/protobuf v1.3.2 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/hive.go v0.0.0-20200107124343-d0fddfc88dea + github.com/iotaledger/hive.go v0.0.0-20200107205115-986a54f82a30 github.com/iotaledger/iota.go v1.0.0-beta.13 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect @@ -31,15 +31,11 @@ require ( github.com/stretchr/objx v0.2.0 // indirect github.com/stretchr/testify v1.4.0 github.com/valyala/fasttemplate v1.1.0 // indirect - go.uber.org/atomic v1.5.1 // indirect - go.uber.org/multierr v1.4.0 // indirect go.uber.org/zap v1.13.0 golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 - golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 // indirect - golang.org/x/tools v0.0.0-20191230181014-9fb4d21460e1 // indirect golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect gopkg.in/ini.v1 v1.51.1 // indirect gopkg.in/yaml.v2 v2.2.7 // indirect diff --git a/go.sum b/go.sum index c70612451b..4f7c64308f 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= @@ -82,8 +83,8 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/hive.go v0.0.0-20200107124343-d0fddfc88dea h1:kLGh9F6KOOygmJPynFSgy7DSlFOg4/x5jmOMOF8vFaA= -github.com/iotaledger/hive.go v0.0.0-20200107124343-d0fddfc88dea/go.mod h1:vrZrvGaWT1o5kz3Jj2B/PcUtqsFzZnLWrO3zEsGSuwk= +github.com/iotaledger/hive.go v0.0.0-20200107205115-986a54f82a30 h1:eE0sEnnQ/HV7QtkUBEPFXPqMXPjUET2UIWDCDcUuGhk= +github.com/iotaledger/hive.go v0.0.0-20200107205115-986a54f82a30/go.mod h1:obs07gqna53/Yw1ltzLsQzJBMyA6lGu7Fb/ltjqWMnQ= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/iotaledger/iota.go v1.0.0-beta.13 h1:6m6JRcKtjTflU2PbjvDA9Tv6NTEJX1PijBDOkH9weQc= github.com/iotaledger/iota.go v1.0.0-beta.13/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= @@ -141,6 +142,7 @@ github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCr github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= @@ -192,6 +194,7 @@ github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= @@ -285,8 +288,8 @@ golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191230181014-9fb4d21460e1 h1:vNFL7Do+hbqZGmVjqkjTBUugGFXohWPyiHMLqLUbtP4= -golang.org/x/tools v0.0.0-20191230181014-9fb4d21460e1/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114 h1:DnSr2mCsxyCE6ZgIkmcWUQY2R5cH/6wL7eIxEmQOMSE= +golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= diff --git a/main.go b/main.go index 54e57babf9..64789962bb 100644 --- a/main.go +++ b/main.go @@ -28,6 +28,8 @@ import ( ) func main() { + cli.LoadConfig() + go http.ListenAndServe("localhost:6060", nil) // pprof Server for Debbuging Mutexes node.Run( diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index 8767c14a89..a2cae4aefa 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -14,7 +14,7 @@ import ( "github.com/iotaledger/hive.go/logger" ) -var log = logger.NewLogger("Transaction Spammer") +var log *logger.Logger var spamming = false var spammingMutex sync.Mutex @@ -30,6 +30,7 @@ func init() { } func Start(tps uint) { + log = logger.NewLogger("Transaction Spammer") spammingMutex.Lock() spamming = true spammingMutex.Unlock() @@ -59,7 +60,7 @@ func Start(tps uint) { tx.SetTrunkTransactionHash(tipselection.GetRandomTip()) tx.SetTimestamp(uint(time.Now().Unix())) if err := tx.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE); err != nil { - log.Warning("PoW failed", err) + log.Warn("PoW failed", err) continue } diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index 1dd3054876..da700fadea 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -23,9 +23,10 @@ import ( "github.com/iotaledger/hive.go/timeutil" ) -var log = logger.NewLogger("Analysis-Client") +var log *logger.Logger func Run(plugin *node.Plugin) { + log = logger.NewLogger("Analysis-Client") daemon.BackgroundWorker("Analysis Client", func(shutdownSignal <-chan struct{}) { shuttingDown := false diff --git a/plugins/analysis/plugin.go b/plugins/analysis/plugin.go index 0208ca1d91..8be4a8422f 100644 --- a/plugins/analysis/plugin.go +++ b/plugins/analysis/plugin.go @@ -10,9 +10,10 @@ import ( ) var PLUGIN = node.NewPlugin("Analysis", node.Enabled, configure, run) -var log = logger.NewLogger("Analysis") +var log *logger.Logger func configure(plugin *node.Plugin) { + log = logger.NewLogger("Analysis") if parameter.NodeConfig.GetInt(server.CFG_SERVER_PORT) != 0 { webinterface.Configure(plugin) server.Configure(plugin) diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index 40fabc28ac..35973f84a6 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -21,9 +21,10 @@ import ( var server *tcp.Server -var log = logger.NewLogger("Analysis-Server") +var log *logger.Logger func Configure(plugin *node.Plugin) { + log = logger.NewLogger("Analysis-Server") server = tcp.NewServer() server.Events.Connect.Attach(events.NewClosure(HandleConnection)) diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 4ba57d0c0e..1952d5c7d9 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -16,9 +16,11 @@ const ( var PLUGIN = node.NewPlugin(name, node.Enabled, configure, run) -var log = logger.NewLogger(name) +var log *logger.Logger func configure(*node.Plugin) { + log = logger.NewLogger(name) + configureEvents() configureAP() } diff --git a/plugins/bundleprocessor/plugin.go b/plugins/bundleprocessor/plugin.go index c95eeeed59..0f013307ae 100644 --- a/plugins/bundleprocessor/plugin.go +++ b/plugins/bundleprocessor/plugin.go @@ -11,9 +11,10 @@ import ( ) var PLUGIN = node.NewPlugin("Bundle Processor", node.Enabled, configure, run) -var log = logger.NewLogger("Bundle Processor") +var log *logger.Logger func configure(plugin *node.Plugin) { + log = logger.NewLogger("Bundle Processor") tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { if tx.IsHead() { workerPool.Submit(tx) diff --git a/plugins/cli/plugin.go b/plugins/cli/plugin.go index d4da0e2a5c..fe3bbc0aa2 100644 --- a/plugins/cli/plugin.go +++ b/plugins/cli/plugin.go @@ -6,6 +6,7 @@ import ( "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" flag "github.com/spf13/pflag" ) @@ -43,6 +44,17 @@ func parseParameters() { } } +func LoadConfig(){ + if err := parameter.FetchConfig(true); err != nil { + panic(err) + } + parseParameters() + + if err := logger.InitGlobalLogger(parameter.NodeConfig); err != nil { + panic(err) + } +} + func configure(ctx *node.Plugin) { fmt.Println(" _____ _ _ ________ ______ ___ ___________ ") @@ -53,11 +65,6 @@ func configure(ctx *node.Plugin) { fmt.Printf(" \\____/\\_| |_/\\___/\\_| |_/\\_| |_/\\____/\\_| \\_| fullnode %s", AppVersion) fmt.Println() - if err := parameter.FetchConfig(true); err != nil { - panic(err) - } - parseParameters() - ctx.Node.Logger.Info("Loading plugins ...") } diff --git a/plugins/dashboard/plugin.go b/plugins/dashboard/plugin.go index f263b4b88a..4321e0b5c5 100644 --- a/plugins/dashboard/plugin.go +++ b/plugins/dashboard/plugin.go @@ -17,9 +17,10 @@ var server *http.Server var router *http.ServeMux var PLUGIN = node.NewPlugin("Dashboard", node.Disabled, configure, run) -var log = logger.NewLogger("Dashboard") +var log *logger.Logger func configure(plugin *node.Plugin) { + log = logger.NewLogger("Dashboard") router = http.NewServeMux() server = &http.Server{Addr: ":8081", Handler: router} diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 56babd44a2..2c6d6a8d0c 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -20,9 +20,10 @@ const ( var PLUGIN = node.NewPlugin(name, node.Enabled, configure, run) -var log = logger.NewLogger(name) +var log *logger.Logger func configure(*node.Plugin) { + log = logger.NewLogger(name) configureGossip() configureEvents() } diff --git a/plugins/gracefulshutdown/plugin.go b/plugins/gracefulshutdown/plugin.go index 15d5cbe646..2cc5237981 100644 --- a/plugins/gracefulshutdown/plugin.go +++ b/plugins/gracefulshutdown/plugin.go @@ -15,8 +15,10 @@ import ( // maximum amount of time to wait for background processes to terminate. After that the process is killed. const WAIT_TO_KILL_TIME_IN_SECONDS = 10 -var log = logger.NewLogger("Graceful Shutdown") +var log *logger.Logger + var PLUGIN = node.NewPlugin("Graceful Shutdown", node.Enabled, func(plugin *node.Plugin) { + log = logger.NewLogger("Graceful Shutdown") gracefulStop := make(chan os.Signal) signal.Notify(gracefulStop, syscall.SIGTERM) @@ -25,7 +27,7 @@ var PLUGIN = node.NewPlugin("Graceful Shutdown", node.Enabled, func(plugin *node go func() { <-gracefulStop - log.Warningf("Received shutdown request - waiting (max %d) to finish processing ...", WAIT_TO_KILL_TIME_IN_SECONDS) + log.Warnf("Received shutdown request - waiting (max %d) to finish processing ...", WAIT_TO_KILL_TIME_IN_SECONDS) go func() { start := time.Now() @@ -38,7 +40,7 @@ var PLUGIN = node.NewPlugin("Graceful Shutdown", node.Enabled, func(plugin *node if len(runningBackgroundWorkers) >= 1 { processList = "(" + strings.Join(runningBackgroundWorkers, ", ") + ") " } - log.Warningf("Received shutdown request - waiting (max %d seconds) to finish processing %s...", WAIT_TO_KILL_TIME_IN_SECONDS-int(secondsSinceStart), processList) + log.Warnf("Received shutdown request - waiting (max %d seconds) to finish processing %s...", WAIT_TO_KILL_TIME_IN_SECONDS-int(secondsSinceStart), processList) } else { log.Error("Background processes did not terminate in time! Forcing shutdown ...") os.Exit(1) diff --git a/plugins/statusscreen/logger.go b/plugins/statusscreen/logger.go index 871472bf48..5d9d780b24 100644 --- a/plugins/statusscreen/logger.go +++ b/plugins/statusscreen/logger.go @@ -6,7 +6,7 @@ import ( "github.com/iotaledger/hive.go/logger" ) -func storeStatusMessage(logLevel logger.LogLevel, prefix string, message string) { +func storeStatusMessage(logLevel logger.Level, prefix string, message string) { mutex.Lock() defer mutex.Unlock() messageLog = append(messageLog, &StatusMessage{ diff --git a/plugins/statusscreen/status_message.go b/plugins/statusscreen/status_message.go index 96ae34ee95..2ec23aff1d 100644 --- a/plugins/statusscreen/status_message.go +++ b/plugins/statusscreen/status_message.go @@ -8,7 +8,7 @@ import ( type StatusMessage struct { Source string - LogLevel logger.LogLevel + LogLevel logger.Level Message string Time time.Time } diff --git a/plugins/statusscreen/statusscreen.go b/plugins/statusscreen/statusscreen.go index e488b59ac4..0d51af1e13 100644 --- a/plugins/statusscreen/statusscreen.go +++ b/plugins/statusscreen/statusscreen.go @@ -1,7 +1,6 @@ package statusscreen import ( - "io/ioutil" "os" "sync" "time" @@ -26,19 +25,14 @@ func configure(plugin *node.Plugin) { return } - // don't write anything to stdout anymore - // as log messages are now stored and displayed via this plugin - logger.InjectWriters(ioutil.Discard) - // store any log message for display - anyLogMsgClosure := events.NewClosure(func(logLevel logger.LogLevel, prefix string, msg string) { + anyLogMsgClosure := events.NewClosure(func(logLevel logger.Level, prefix string, msg string) { storeStatusMessage(logLevel, prefix, msg) }) logger.Events.AnyMsg.Attach(anyLogMsgClosure) daemon.BackgroundWorker("UI-Detach", func(shutdownSignal <-chan struct{}) { <-shutdownSignal - logger.InjectWriters(os.Stdout) logger.Events.AnyMsg.Detach(anyLogMsgClosure) if app != nil { app.Stop() diff --git a/plugins/statusscreen/ui_log_entry.go b/plugins/statusscreen/ui_log_entry.go index fc8db3a76d..4134636d1d 100644 --- a/plugins/statusscreen/ui_log_entry.go +++ b/plugins/statusscreen/ui_log_entry.go @@ -39,16 +39,12 @@ func NewUILogEntry(message StatusMessage) *UILogEntry { switch message.LogLevel { case logger.LevelInfo: fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [blue::d]INFO [black::d]]") - case logger.LevelNotice: - fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [blue::d]NOTICE [black::d]]") - case logger.LevelWarning: + case logger.LevelWarn: fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [yellow::d]WARN [black::d]]") textColor = "yellow::d" case logger.LevelError: fallthrough - case logger.LevelCritical: - fallthrough case logger.LevelPanic: fallthrough case logger.LevelFatal: diff --git a/plugins/tangle/plugin.go b/plugins/tangle/plugin.go index 62006c6be9..020480129d 100644 --- a/plugins/tangle/plugin.go +++ b/plugins/tangle/plugin.go @@ -8,9 +8,10 @@ import ( // region plugin module setup ////////////////////////////////////////////////////////////////////////////////////////// var PLUGIN = node.NewPlugin("Tangle", node.Enabled, configure, run) -var log = logger.NewLogger("Tangle") +var log *logger.Logger func configure(plugin *node.Plugin) { + log = logger.NewLogger("Tangle") configureTransactionDatabase(plugin) configureTransactionMetaDataDatabase(plugin) configureApproversDatabase(plugin) diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index af7b07c525..696bd3d03b 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -38,7 +38,7 @@ func configureSolidifier(plugin *node.Plugin) { gossip.Events.TransactionReceived.Attach(events.NewClosure(func(ev *gossip.TransactionReceivedEvent) { metaTx := meta_transaction.FromBytes(ev.Data) if err := metaTx.Validate(); err != nil { - log.Warningf("invalid transaction: %s", err) + log.Warnf("invalid transaction: %s", err) return } diff --git a/plugins/ui/logger.go b/plugins/ui/logger.go index 08658c4317..cf48842712 100644 --- a/plugins/ui/logger.go +++ b/plugins/ui/logger.go @@ -11,15 +11,15 @@ var logMutex = sync.RWMutex{} var logHistory = make([]*statusMessage, 0) type statusMessage struct { - Source string `json:"source"` - Level logger.LogLevel `json:"level"` - Message string `json:"message"` - Time time.Time `json:"time"` + Source string `json:"source"` + Level logger.Level `json:"level"` + Message string `json:"message"` + Time time.Time `json:"time"` } type resp map[string]interface{} -func storeAndSendStatusMessage(logLevel logger.LogLevel, pluginName string, message string) { +func storeAndSendStatusMessage(logLevel logger.Level, pluginName string, message string) { msg := &statusMessage{ Source: pluginName, diff --git a/plugins/ui/ui.go b/plugins/ui/ui.go index 02e248a3f6..f4458e5843 100644 --- a/plugins/ui/ui.go +++ b/plugins/ui/ui.go @@ -50,7 +50,7 @@ func configure(plugin *node.Plugin) { })) // store log messages to send them down via the websocket - anyMsgClosure := events.NewClosure(func(logLvl logger.LogLevel, prefix string, msg string) { + anyMsgClosure := events.NewClosure(func(logLvl logger.Level, prefix string, msg string) { storeAndSendStatusMessage(logLvl, prefix, msg) }) logger.Events.AnyMsg.Attach(anyMsgClosure) diff --git a/plugins/validator/plugin.go b/plugins/validator/plugin.go index 11217efc46..b20ba75d57 100644 --- a/plugins/validator/plugin.go +++ b/plugins/validator/plugin.go @@ -13,7 +13,7 @@ import ( ) var PLUGIN = node.NewPlugin("Validator", node.Enabled, configure, run) -var log = logger.NewLogger("Validator") +var log *logger.Logger func validateSignatures(bundleHash Hash, txs []*value_transaction.ValueTransaction) (bool, error) { for i, tx := range txs { @@ -51,7 +51,7 @@ func validateSignatures(bundleHash Hash, txs []*value_transaction.ValueTransacti } func configure(plugin *node.Plugin) { - + log = logger.NewLogger("Validator") bundleprocessor.Events.BundleSolid.Attach(events.NewClosure(func(b *bundle.Bundle, txs []*value_transaction.ValueTransaction) { // signature are verified against the bundle hash valid, err := validateSignatures(b.GetBundleEssenceHash(), txs) diff --git a/plugins/webapi-send-data/plugin.go b/plugins/webapi-send-data/plugin.go index 778a41b27b..c7029181b5 100644 --- a/plugins/webapi-send-data/plugin.go +++ b/plugins/webapi-send-data/plugin.go @@ -18,9 +18,10 @@ import ( ) var PLUGIN = node.NewPlugin("WebAPI SendData Endpoint", node.Enabled, configure) -var log = logger.NewLogger("API-sendData") +var log *logger.Logger func configure(plugin *node.Plugin) { + log = logger.NewLogger("API-sendData") webapi.AddEndpoint("sendData", SendDataHandler) } @@ -55,7 +56,7 @@ func SendDataHandler(c echo.Context) error { tx.SetTrunkTransactionHash(tipselection.GetRandomTip()) tx.SetTimestamp(uint(time.Now().Unix())) if err := tx.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE); err != nil { - log.Warning("PoW failed", err) + log.Warn("PoW failed", err) } gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: tx.GetBytes(), Peer: &local.GetInstance().Peer}) diff --git a/plugins/webapi-tx-request/plugin.go b/plugins/webapi-tx-request/plugin.go index a10ac0eada..5f4e428254 100644 --- a/plugins/webapi-tx-request/plugin.go +++ b/plugins/webapi-tx-request/plugin.go @@ -12,9 +12,10 @@ import ( ) var PLUGIN = node.NewPlugin("WebAPI Transaction Request Endpoint", node.Enabled, configure) -var log = logger.NewLogger("API-TxRequest") +var log *logger.Logger func configure(plugin *node.Plugin) { + log = logger.NewLogger("API-TxRequest") webapi.AddEndpoint("txRequest", Handler) } diff --git a/plugins/webapi/plugin.go b/plugins/webapi/plugin.go index e7d7c5a32f..6cd2e037b3 100644 --- a/plugins/webapi/plugin.go +++ b/plugins/webapi/plugin.go @@ -11,11 +11,12 @@ import ( ) var PLUGIN = node.NewPlugin("WebAPI", node.Enabled, configure, run) -var log = logger.NewLogger("WebAPI") +var log *logger.Logger var Server = echo.New() func configure(plugin *node.Plugin) { + log = logger.NewLogger("WebAPI") Server.HideBanner = true Server.HidePort = true Server.GET("/", IndexRequest) diff --git a/plugins/zeromq/plugin.go b/plugins/zeromq/plugin.go index c9d469a85a..11ddb33c23 100644 --- a/plugins/zeromq/plugin.go +++ b/plugins/zeromq/plugin.go @@ -16,12 +16,13 @@ import ( // zeromq logging is disabled by default var PLUGIN = node.NewPlugin("ZeroMQ", node.Disabled, configure, run) -var log = logger.NewLogger("ZeroMQ") +var log *logger.Logger var publisher *Publisher var emptyTag = strings.Repeat("9", 27) // Configure the zeromq plugin func configure(plugin *node.Plugin) { + log = logger.NewLogger("ZeroMQ") tangle.Events.TransactionStored.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { // create goroutine for every event go func() { From 9aa423a99a02bf977d31edaf74ba0372060797d1 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Wed, 8 Jan 2020 12:02:43 +0100 Subject: [PATCH 080/184] init global logger in tests --- plugins/bundleprocessor/bundleprocessor_test.go | 3 +++ plugins/tangle/solidifier_test.go | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/plugins/bundleprocessor/bundleprocessor_test.go b/plugins/bundleprocessor/bundleprocessor_test.go index 484d6a29b3..b8cdd9dff3 100644 --- a/plugins/bundleprocessor/bundleprocessor_test.go +++ b/plugins/bundleprocessor/bundleprocessor_test.go @@ -11,9 +11,11 @@ import ( "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/goshimmer/plugins/tipselection" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/consts" "github.com/magiconair/properties/assert" + "github.com/spf13/viper" ) var seed = client.NewSeed("YFHQWAUPCXC9S9DSHP9NDF9RLNPMZVCMSJKUKQP9SWUSUCPRQXCMDVDVZ9SHHESHIQNCXWBJF9UJSWE9Z", consts.SecurityLevelMedium) @@ -23,6 +25,7 @@ func init() { if err != nil { log.Fatalf("Failed to initialize config: %s", err) } + logger.InitGlobalLogger(&viper.Viper{}) } func BenchmarkValidateSignatures(b *testing.B) { diff --git a/plugins/tangle/solidifier_test.go b/plugins/tangle/solidifier_test.go index 139febe3a4..e93cfdce6f 100644 --- a/plugins/tangle/solidifier_test.go +++ b/plugins/tangle/solidifier_test.go @@ -9,7 +9,9 @@ import ( "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" + "github.com/spf13/viper" "github.com/stretchr/testify/require" ) @@ -18,6 +20,8 @@ func init() { if err != nil { log.Fatalf("Failed to initialize config: %s", err) } + + logger.InitGlobalLogger(&viper.Viper{}) } func TestSolidifier(t *testing.T) { From e4447dbdf4760a4c0bee76e28d424d0fe438ecea Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 8 Jan 2020 19:33:30 +0100 Subject: [PATCH 081/184] fix: run all bundle processor tests as sub tests --- .../bundleprocessor/bundleprocessor_test.go | 96 +++++++++---------- plugins/bundleprocessor/plugin.go | 8 +- 2 files changed, 48 insertions(+), 56 deletions(-) diff --git a/plugins/bundleprocessor/bundleprocessor_test.go b/plugins/bundleprocessor/bundleprocessor_test.go index 484d6a29b3..5b78beae1e 100644 --- a/plugins/bundleprocessor/bundleprocessor_test.go +++ b/plugins/bundleprocessor/bundleprocessor_test.go @@ -65,74 +65,66 @@ func TestValidateSignatures(t *testing.T) { assert.Equal(t, successful, true, "validation failed") } -func TestProcessSolidBundleHead_Data(t *testing.T) { +func TestProcessSolidBundleHead(t *testing.T) { // start a test node node.Start(node.Plugins(tangle.PLUGIN, PLUGIN)) defer node.Shutdown() - bundleFactory := client.NewBundleFactory() - bundleFactory.AddOutput(seed.GetAddress(1), 400, "Testmessage") - bundleFactory.AddOutput(client.NewAddress("SJKUKQP9SWUSUCPRQXCMDVDVZ9SHHESHIQNCXWBJF9UJSWE9ZYFHQWAUPCXC9S9DSHP9NDF9RLNPMZVCM"), 400, "Testmessage") + t.Run("data", func(t *testing.T) { + bundleFactory := client.NewBundleFactory() + bundleFactory.AddOutput(seed.GetAddress(1), 400, "Testmessage") + bundleFactory.AddOutput(client.NewAddress("SJKUKQP9SWUSUCPRQXCMDVDVZ9SHHESHIQNCXWBJF9UJSWE9ZYFHQWAUPCXC9S9DSHP9NDF9RLNPMZVCM"), 400, "Testmessage") - generatedBundle := bundleFactory.GenerateBundle(tipselection.GetRandomTip(), tipselection.GetRandomTip()) + generatedBundle := bundleFactory.GenerateBundle(tipselection.GetRandomTip(), tipselection.GetRandomTip()) + for _, transaction := range generatedBundle.GetTransactions() { + tangle.StoreTransaction(transaction) + } - for _, transaction := range generatedBundle.GetTransactions() { - tangle.StoreTransaction(transaction) - } + var wg sync.WaitGroup + testResults := events.NewClosure(func(bundle *bundle.Bundle, transactions []*value_transaction.ValueTransaction) { + assert.Equal(t, bundle.GetHash(), generatedBundle.GetTransactions()[0].GetHash(), "invalid bundle hash") + assert.Equal(t, bundle.IsValueBundle(), false, "invalid value bundle status") - var wg sync.WaitGroup + wg.Done() + }) + Events.BundleSolid.Attach(testResults) + defer Events.BundleSolid.Detach(testResults) - testResults := events.NewClosure(func(bundle *bundle.Bundle, transactions []*value_transaction.ValueTransaction) { - assert.Equal(t, bundle.GetHash(), generatedBundle.GetTransactions()[0].GetHash(), "invalid bundle hash") - assert.Equal(t, bundle.IsValueBundle(), false, "invalid value bundle status") + wg.Add(1) + if err := ProcessSolidBundleHead(generatedBundle.GetTransactions()[0]); err != nil { + t.Error(err) + } - wg.Done() + wg.Wait() }) - Events.BundleSolid.Attach(testResults) - defer Events.BundleSolid.Detach(testResults) - - wg.Add(1) - if err := ProcessSolidBundleHead(generatedBundle.GetTransactions()[0]); err != nil { - t.Error(err) - } - - wg.Wait() -} - -func TestProcessSolidBundleHead_Value(t *testing.T) { - // start a test node - node.Start(node.Plugins(tangle.PLUGIN, PLUGIN)) - defer node.Shutdown() + t.Run("value", func(t *testing.T) { + bundleFactory := client.NewBundleFactory() + bundleFactory.AddInput(seed.GetAddress(0), -400) + bundleFactory.AddOutput(seed.GetAddress(1), 400, "Testmessage") + bundleFactory.AddOutput(client.NewAddress("SJKUKQP9SWUSUCPRQXCMDVDVZ9SHHESHIQNCXWBJF9UJSWE9ZYFHQWAUPCXC9S9DSHP9NDF9RLNPMZVCM"), 400, "Testmessage") - bundleFactory := client.NewBundleFactory() - bundleFactory.AddInput(seed.GetAddress(0), -400) - bundleFactory.AddOutput(seed.GetAddress(1), 400, "Testmessage") - bundleFactory.AddOutput(client.NewAddress("SJKUKQP9SWUSUCPRQXCMDVDVZ9SHHESHIQNCXWBJF9UJSWE9ZYFHQWAUPCXC9S9DSHP9NDF9RLNPMZVCM"), 400, "Testmessage") + generatedBundle := bundleFactory.GenerateBundle(tipselection.GetRandomTip(), tipselection.GetRandomTip()) + for _, transaction := range generatedBundle.GetTransactions() { + tangle.StoreTransaction(transaction) + } - generatedBundle := bundleFactory.GenerateBundle(tipselection.GetRandomTip(), tipselection.GetRandomTip()) + var wg sync.WaitGroup + testResults := events.NewClosure(func(bundle *bundle.Bundle, transactions []*value_transaction.ValueTransaction) { + assert.Equal(t, bundle.GetHash(), generatedBundle.GetTransactions()[0].GetHash(), "invalid bundle hash") + assert.Equal(t, bundle.IsValueBundle(), true, "invalid value bundle status") - for _, transaction := range generatedBundle.GetTransactions() { - tangle.StoreTransaction(transaction) - } + wg.Done() + }) - var wg sync.WaitGroup + wg.Add(1) + Events.BundleSolid.Attach(testResults) + defer Events.BundleSolid.Detach(testResults) - testResults := events.NewClosure(func(bundle *bundle.Bundle, transactions []*value_transaction.ValueTransaction) { - assert.Equal(t, bundle.GetHash(), generatedBundle.GetTransactions()[0].GetHash(), "invalid bundle hash") - assert.Equal(t, bundle.IsValueBundle(), true, "invalid value bundle status") + if err := ProcessSolidBundleHead(generatedBundle.GetTransactions()[0]); err != nil { + t.Error(err) + } - wg.Done() + wg.Wait() }) - - Events.BundleSolid.Attach(testResults) - defer Events.BundleSolid.Detach(testResults) - - wg.Add(1) - - if err := ProcessSolidBundleHead(generatedBundle.GetTransactions()[0]); err != nil { - t.Error(err) - } - - wg.Wait() } diff --git a/plugins/bundleprocessor/plugin.go b/plugins/bundleprocessor/plugin.go index c95eeeed59..b369771567 100644 --- a/plugins/bundleprocessor/plugin.go +++ b/plugins/bundleprocessor/plugin.go @@ -13,7 +13,7 @@ import ( var PLUGIN = node.NewPlugin("Bundle Processor", node.Enabled, configure, run) var log = logger.NewLogger("Bundle Processor") -func configure(plugin *node.Plugin) { +func configure(*node.Plugin) { tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { if tx.IsHead() { workerPool.Submit(tx) @@ -25,7 +25,7 @@ func configure(plugin *node.Plugin) { })) } -func run(plugin *node.Plugin) { +func run(*node.Plugin) { log.Info("Starting Bundle Processor ...") daemon.BackgroundWorker("Bundle Processor", func(shutdownSignal <-chan struct{}) { @@ -33,7 +33,7 @@ func run(plugin *node.Plugin) { workerPool.Start() <-shutdownSignal log.Info("Stopping Bundle Processor ...") - workerPool.Stop() + workerPool.StopAndWait() log.Info("Stopping Bundle Processor ... done") }) @@ -44,7 +44,7 @@ func run(plugin *node.Plugin) { valueBundleProcessorWorkerPool.Start() <-shutdownSignal log.Info("Stopping Value Bundle Processor ...") - valueBundleProcessorWorkerPool.Stop() + valueBundleProcessorWorkerPool.StopAndWait() log.Info("Stopping Value Bundle Processor ... done") }) } From c7496bf654ebeb98cf218496fb052f07e5c8b157 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 8 Jan 2020 19:37:44 +0100 Subject: [PATCH 082/184] refactor: remove unnecessary plugin parameters --- plugins/tangle/approvers.go | 3 +-- plugins/tangle/bundle.go | 3 +-- plugins/tangle/plugin.go | 16 ++++++++-------- plugins/tangle/solidifier.go | 15 +++++++-------- plugins/tangle/transaction.go | 3 +-- plugins/tangle/transaction_metadata.go | 3 +-- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/plugins/tangle/approvers.go b/plugins/tangle/approvers.go index fd4461aa1e..38d44aa908 100644 --- a/plugins/tangle/approvers.go +++ b/plugins/tangle/approvers.go @@ -5,7 +5,6 @@ import ( "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/approvers" - "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) @@ -75,7 +74,7 @@ const ( var approversDatabase database.Database -func configureApproversDatabase(plugin *node.Plugin) { +func configureApproversDatabase() { if db, err := database.Get("approvers"); err != nil { panic(err) } else { diff --git a/plugins/tangle/bundle.go b/plugins/tangle/bundle.go index bd55c6e67e..fa607ba127 100644 --- a/plugins/tangle/bundle.go +++ b/plugins/tangle/bundle.go @@ -5,7 +5,6 @@ import ( "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/bundle" - "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) @@ -79,7 +78,7 @@ const ( var bundleDatabase database.Database -func configureBundleDatabase(plugin *node.Plugin) { +func configureBundleDatabase() { if db, err := database.Get("bundle"); err != nil { panic(err) } else { diff --git a/plugins/tangle/plugin.go b/plugins/tangle/plugin.go index 62006c6be9..d7aa7c8f3f 100644 --- a/plugins/tangle/plugin.go +++ b/plugins/tangle/plugin.go @@ -10,16 +10,16 @@ import ( var PLUGIN = node.NewPlugin("Tangle", node.Enabled, configure, run) var log = logger.NewLogger("Tangle") -func configure(plugin *node.Plugin) { - configureTransactionDatabase(plugin) - configureTransactionMetaDataDatabase(plugin) - configureApproversDatabase(plugin) - configureBundleDatabase(plugin) - configureSolidifier(plugin) +func configure(*node.Plugin) { + configureTransactionDatabase() + configureTransactionMetaDataDatabase() + configureApproversDatabase() + configureBundleDatabase() + configureSolidifier() } -func run(plugin *node.Plugin) { - runSolidifier(plugin) +func run(*node.Plugin) { + runSolidifier() } // endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index af7b07c525..d3d9127167 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -13,7 +13,6 @@ import ( "github.com/iotaledger/goshimmer/packages/workerpool" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" - "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/trinary" ) @@ -26,9 +25,9 @@ var ( unsolidTxs *UnsolidTxs ) -func configureSolidifier(plugin *node.Plugin) { +func configureSolidifier() { workerPool = workerpool.New(func(task workerpool.Task) { - processMetaTransaction(plugin, task.Param(0).(*meta_transaction.MetaTransaction)) + processMetaTransaction(task.Param(0).(*meta_transaction.MetaTransaction)) task.Return(nil) }, workerpool.WorkerCount(WORKER_COUNT), workerpool.QueueSize(10000)) @@ -46,7 +45,7 @@ func configureSolidifier(plugin *node.Plugin) { })) } -func runSolidifier(plugin *node.Plugin) { +func runSolidifier() { log.Info("Starting Solidifier ...") daemon.BackgroundWorker("Tangle Solidifier", func(shutdownSignal <-chan struct{}) { @@ -54,7 +53,7 @@ func runSolidifier(plugin *node.Plugin) { workerPool.Start() <-shutdownSignal log.Info("Stopping Solidifier ...") - workerPool.Stop() + workerPool.StopAndWait() log.Info("Stopping Solidifier ... done") }) } @@ -169,7 +168,7 @@ func propagateSolidity(transactionHash trinary.Trytes) errors.IdentifiableError return nil } -func processMetaTransaction(plugin *node.Plugin, metaTransaction *meta_transaction.MetaTransaction) { +func processMetaTransaction(metaTransaction *meta_transaction.MetaTransaction) { var newTransaction bool if tx, err := GetTransaction(metaTransaction.GetHash(), func(transactionHash trinary.Trytes) *value_transaction.ValueTransaction { newTransaction = true @@ -179,11 +178,11 @@ func processMetaTransaction(plugin *node.Plugin, metaTransaction *meta_transacti log.Errorf("Unable to load transaction %s: %s", metaTransaction.GetHash(), err.Error()) } else if newTransaction { updateUnsolidTxs(tx) - processTransaction(plugin, tx) + processTransaction(tx) } } -func processTransaction(plugin *node.Plugin, transaction *value_transaction.ValueTransaction) { +func processTransaction(transaction *value_transaction.ValueTransaction) { Events.TransactionStored.Trigger(transaction) transactionHash := transaction.GetHash() diff --git a/plugins/tangle/transaction.go b/plugins/tangle/transaction.go index aeb4c915af..31edfc4f8c 100644 --- a/plugins/tangle/transaction.go +++ b/plugins/tangle/transaction.go @@ -5,7 +5,6 @@ import ( "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) @@ -76,7 +75,7 @@ const ( var transactionDatabase database.Database -func configureTransactionDatabase(plugin *node.Plugin) { +func configureTransactionDatabase() { if db, err := database.Get("transaction"); err != nil { panic(err) } else { diff --git a/plugins/tangle/transaction_metadata.go b/plugins/tangle/transaction_metadata.go index e1032ed635..6713ecc8b0 100644 --- a/plugins/tangle/transaction_metadata.go +++ b/plugins/tangle/transaction_metadata.go @@ -5,7 +5,6 @@ import ( "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" - "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) @@ -76,7 +75,7 @@ const ( var transactionMetadataDatabase database.Database -func configureTransactionMetaDataDatabase(plugin *node.Plugin) { +func configureTransactionMetaDataDatabase() { if db, err := database.Get("transactionMetadata"); err != nil { panic(err) } else { From 31dfa603868a29632e4a4756f19b206604db6f77 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 8 Jan 2020 20:43:29 +0100 Subject: [PATCH 083/184] fix: integrate autopeering logging into global logger --- packages/autopeering/logger/logger.go | 60 --------------------------- plugins/autopeering/autopeering.go | 33 +++------------ plugins/autopeering/plugin.go | 11 ++--- plugins/cli/plugin.go | 2 +- plugins/gossip/gossip.go | 30 ++------------ plugins/gossip/plugin.go | 12 +++--- 6 files changed, 20 insertions(+), 128 deletions(-) delete mode 100644 packages/autopeering/logger/logger.go diff --git a/packages/autopeering/logger/logger.go b/packages/autopeering/logger/logger.go deleted file mode 100644 index 9a14bb0586..0000000000 --- a/packages/autopeering/logger/logger.go +++ /dev/null @@ -1,60 +0,0 @@ -package logger - -import ( - "encoding/json" - "fmt" - - "go.uber.org/zap" - "go.uber.org/zap/zapcore" -) - -// NewLogger creates a logger with the supplied configuration. -func NewLogger(configJSON string, levelOverride string, opts ...zap.Option) *zap.SugaredLogger { - var loggingCfg zap.Config - if err := json.Unmarshal([]byte(configJSON), &loggingCfg); err != nil { - return newFallbackLogger(err, levelOverride, opts...) - } - if len(levelOverride) > 0 { - if level, err := levelFromString(levelOverride); err == nil { - loggingCfg.Level = zap.NewAtomicLevelAt(*level) - } - } - - logger, err := loggingCfg.Build(opts...) - if err != nil { - return newFallbackLogger(err, levelOverride, opts...) - } - - logger.Info("Successfully created the logger.") - logger.Sugar().Infof("Logging level set to %v", loggingCfg.Level) - - return logger.Sugar() -} - -func levelFromString(level string) (*zapcore.Level, error) { - var zapLevel zapcore.Level - if err := zapLevel.UnmarshalText([]byte(level)); err != nil { - return nil, fmt.Errorf("invalid logging level: %v", level) - } - return &zapLevel, nil -} - -func newFallbackLogger(cause error, levelOverride string, opts ...zap.Option) *zap.SugaredLogger { - loggingCfg := zap.NewProductionConfig() - if len(levelOverride) > 0 { - if level, err := levelFromString(levelOverride); err == nil { - loggingCfg.Level = zap.NewAtomicLevelAt(*level) - } - } - - logger, err := loggingCfg.Build(opts...) - if err != nil { - panic(err) - } - logger = logger.Named("fallback-logger") - - logger.Warn("Failed to create logger, using fallback:", zap.Error(cause)) - logger.Sugar().Infof("Logging level set to %v", loggingCfg.Level) - - return logger.Sugar() -} diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 3bbbd33957..4d70e09eae 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -7,7 +7,6 @@ import ( "strings" "github.com/iotaledger/goshimmer/packages/autopeering/discover" - "github.com/iotaledger/goshimmer/packages/autopeering/logger" "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/autopeering/selection" @@ -15,6 +14,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/transport" "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/hive.go/logger" "github.com/pkg/errors" ) @@ -23,30 +23,9 @@ var ( Discovery *discover.Protocol // Selection is the peer selection protocol. Selection *selection.Protocol -) - -const defaultZLC = `{ - "level": "info", - "development": false, - "outputPaths": ["./autopeering.log"], - "errorOutputPaths": ["stderr"], - "encoding": "console", - "encoderConfig": { - "timeKey": "ts", - "levelKey": "level", - "nameKey": "logger", - "callerKey": "caller", - "messageKey": "msg", - "stacktraceKey": "stacktrace", - "lineEnding": "", - "levelEncoder": "", - "timeEncoder": "iso8601", - "durationEncoder": "", - "callerEncoder": "" - } - }` -var zLogger = logger.NewLogger(defaultZLC, logLevel) + log *logger.Logger +) func configureAP() { masterPeers, err := parseEntryNodes() @@ -56,13 +35,13 @@ func configureAP() { log.Debugf("Master peers: %v", masterPeers) Discovery = discover.New(local.GetInstance(), discover.Config{ - Log: zLogger.Named("disc"), + Log: log.Named("disc"), MasterPeers: masterPeers, }) if parameter.NodeConfig.GetBool(CFG_SELECTION) { Selection = selection.New(local.GetInstance(), Discovery, selection.Config{ - Log: zLogger.Named("sel"), + Log: log.Named("sel"), Param: &selection.Parameters{ SaltLifetime: selection.DefaultSaltLifetime, RequiredService: []service.Key{service.GossipKey}, @@ -104,7 +83,7 @@ func start(shutdownSignal <-chan struct{}) { } // start a server doing discovery and peering - srv := server.Listen(local.GetInstance(), trans, zLogger.Named("srv"), handlers...) + srv := server.Listen(local.GetInstance(), trans, log.Named("srv"), handlers...) defer srv.Close() // start the discovery on that connection diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 1952d5c7d9..da2fd92088 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -9,15 +9,10 @@ import ( "github.com/iotaledger/hive.go/node" ) -const ( - name = "Autopeering" // name of the plugin - logLevel = "info" -) +const name = "Autopeering" // name of the plugin var PLUGIN = node.NewPlugin(name, node.Enabled, configure, run) -var log *logger.Logger - func configure(*node.Plugin) { log = logger.NewLogger(name) @@ -26,7 +21,9 @@ func configure(*node.Plugin) { } func run(*node.Plugin) { - daemon.BackgroundWorker(name, start) + if err := daemon.BackgroundWorker(name, start); err != nil { + log.Errorf("Failed to start as daemon: %s", err) + } } func configureEvents() { diff --git a/plugins/cli/plugin.go b/plugins/cli/plugin.go index fe3bbc0aa2..39791c7c52 100644 --- a/plugins/cli/plugin.go +++ b/plugins/cli/plugin.go @@ -44,7 +44,7 @@ func parseParameters() { } } -func LoadConfig(){ +func LoadConfig() { if err := parameter.FetchConfig(true); err != nil { panic(err) } diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 8b552c69f8..aff925c7b9 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -5,7 +5,6 @@ import ( "net" "strconv" - "github.com/iotaledger/goshimmer/packages/autopeering/logger" "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/errors" gp "github.com/iotaledger/goshimmer/packages/gossip" @@ -13,36 +12,15 @@ import ( "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/tangle" + "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/typeutils" ) var ( + log *logger.Logger mgr *gp.Manager ) -const defaultZLC = `{ - "level": "info", - "development": false, - "outputPaths": ["./gossip.log"], - "errorOutputPaths": ["stderr"], - "encoding": "console", - "encoderConfig": { - "timeKey": "ts", - "levelKey": "level", - "nameKey": "logger", - "callerKey": "caller", - "messageKey": "msg", - "stacktraceKey": "stacktrace", - "lineEnding": "", - "levelEncoder": "", - "timeEncoder": "iso8601", - "durationEncoder": "", - "callerEncoder": "" - } - }` - -var zLogger = logger.NewLogger(defaultZLC, logLevel) - func configureGossip() { lPeer := local.GetInstance() @@ -57,13 +35,13 @@ func configureGossip() { log.Fatalf("could not update services: %v", err) } - mgr = gp.NewManager(lPeer, getTransaction, zLogger) + mgr = gp.NewManager(lPeer, getTransaction, log) } func start(shutdownSignal <-chan struct{}) { defer log.Info("Stopping Gossip ... done") - srv, err := server.ListenTCP(local.GetInstance(), zLogger) + srv, err := server.ListenTCP(local.GetInstance(), log) if err != nil { log.Fatalf("ListenTCP: %v", err) } diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 2c6d6a8d0c..774364674f 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -13,23 +13,21 @@ import ( "github.com/iotaledger/hive.go/typeutils" ) -const ( - name = "Gossip" // name of the plugin - logLevel = "info" -) +const name = "Gossip" // name of the plugin var PLUGIN = node.NewPlugin(name, node.Enabled, configure, run) -var log *logger.Logger - func configure(*node.Plugin) { log = logger.NewLogger(name) + configureGossip() configureEvents() } func run(*node.Plugin) { - daemon.BackgroundWorker(name, start) + if err := daemon.BackgroundWorker(name, start); err != nil { + log.Errorf("Failed to start as daemon: %s", err) + } } func configureEvents() { From 43e837e5d80c193b58188bc1439b082a9fc680ea Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 8 Jan 2020 21:09:05 +0100 Subject: [PATCH 084/184] fix: add logger config to config.json --- config.json | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/config.json b/config.json index b86b494423..1b885d18b1 100644 --- a/config.json +++ b/config.json @@ -1,28 +1,35 @@ { - "node": { - "logLevel": 3, - "disablePlugins": [], - "enablePlugins": [] + "analysis":{ + "serveraddress":"ressims.iota.cafe:188", + "serverport":0 }, - "database": { - "directory": "mainnetdb" - }, - "analysis": { - "serverPort": 0, - "serverAddress": "ressims.iota.cafe:188" + "autopeering":{ + "address":"0.0.0.0", + "entrynodes":[ + "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626" + ], + "port":14626, + "selection":true }, - "gossip": { - "port": 14666 + "database":{ + "directory":"mainnetdb" }, - "zeromq": { - "port": 5556 + "gossip":{ + "port":14666 }, - "autopeering": { - "address": "0.0.0.0", - "port": 14626, - "entryNodes": [ - "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626" + "logger":{ + "Level":"info", + "DisableCaller":false, + "DisableStacktrace":false, + "Encoding":"console", + "OutputPaths":[ + "stdout" ], - "selection": true + "DisableEvents":false + }, + "node":{ + "disableplugins":"", + "enableplugins":"", + "loglevel":0 } } \ No newline at end of file From a32056dca10973db5da78cdb050be7cddfbe6e94 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 8 Jan 2020 22:55:42 +0100 Subject: [PATCH 085/184] fix: log to console if status screen is not running --- config.json | 5 +- plugins/statusscreen/constants.go | 7 -- plugins/statusscreen/logger.go | 58 ++++++++++++----- plugins/statusscreen/plugin.go | 81 +++++++++++++++++++++++ plugins/statusscreen/status_message.go | 14 ---- plugins/statusscreen/statusscreen.go | 90 ++++++-------------------- plugins/statusscreen/ui_log.go | 15 ----- plugins/statusscreen/ui_log_entry.go | 12 ++-- 8 files changed, 150 insertions(+), 132 deletions(-) delete mode 100644 plugins/statusscreen/constants.go create mode 100644 plugins/statusscreen/plugin.go delete mode 100644 plugins/statusscreen/status_message.go delete mode 100644 plugins/statusscreen/ui_log.go diff --git a/config.json b/config.json index 1b885d18b1..8550f6286b 100644 --- a/config.json +++ b/config.json @@ -23,9 +23,8 @@ "DisableStacktrace":false, "Encoding":"console", "OutputPaths":[ - "stdout" - ], - "DisableEvents":false + "shimmer.log" + ] }, "node":{ "disableplugins":"", diff --git a/plugins/statusscreen/constants.go b/plugins/statusscreen/constants.go deleted file mode 100644 index 1fa6c46dac..0000000000 --- a/plugins/statusscreen/constants.go +++ /dev/null @@ -1,7 +0,0 @@ -package statusscreen - -import "time" - -const ( - REPAINT_INTERVAL = 500 * time.Millisecond -) diff --git a/plugins/statusscreen/logger.go b/plugins/statusscreen/logger.go index 5d9d780b24..10606990e2 100644 --- a/plugins/statusscreen/logger.go +++ b/plugins/statusscreen/logger.go @@ -1,31 +1,55 @@ package statusscreen import ( + stdlog "log" + "sync" "time" "github.com/iotaledger/hive.go/logger" ) -func storeStatusMessage(logLevel logger.Level, prefix string, message string) { - mutex.Lock() - defer mutex.Unlock() - messageLog = append(messageLog, &StatusMessage{ - Source: prefix, - LogLevel: logLevel, - Message: message, - Time: time.Now(), +var ( + mu sync.Mutex + logMessages = make([]*logMessage, 0) + logMessagesByName = make(map[string]*logMessage) +) + +type logMessage struct { + time time.Time + name string + level logger.Level + msg string +} + +func stdLogMsg(level logger.Level, name string, msg string) { + stdlog.Printf("[ %s ] %s: %s", + level.CapitalString(), + name, + msg, + ) +} + +func storeLogMsg(level logger.Level, name string, message string) { + mu.Lock() + defer mu.Unlock() + + logMessages = append(logMessages, &logMessage{ + time: time.Now(), + name: name, + level: level, + msg: message, }) - if statusMessage, exists := statusMessages[prefix]; !exists { - statusMessages[prefix] = &StatusMessage{ - Source: prefix, - LogLevel: logLevel, - Message: message, - Time: time.Now(), + if statusMessage, exists := logMessagesByName[name]; !exists { + logMessagesByName[name] = &logMessage{ + time: time.Now(), + name: name, + level: level, + msg: message, } } else { - statusMessage.LogLevel = logLevel - statusMessage.Message = message - statusMessage.Time = time.Now() + statusMessage.time = time.Now() + statusMessage.level = level + statusMessage.msg = message } } diff --git a/plugins/statusscreen/plugin.go b/plugins/statusscreen/plugin.go new file mode 100644 index 0000000000..544e190041 --- /dev/null +++ b/plugins/statusscreen/plugin.go @@ -0,0 +1,81 @@ +package statusscreen + +import ( + "time" + + "github.com/iotaledger/hive.go/daemon" + "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" +) + +const ( + name = "Statusscreen" + repaintInterval = 1 * time.Second +) + +var PLUGIN = node.NewPlugin(name, node.Enabled, configure, run) + +var ( + stdLogMsgClosure = events.NewClosure(stdLogMsg) + storeLogMsgClosure = events.NewClosure(storeLogMsg) +) + +func init() { + // use standard go logger by default + logger.Events.AnyMsg.Attach(stdLogMsgClosure) +} + +func configure(*node.Plugin) { + if !isTerminal() { + return + } + + // store any log message for display + logger.Events.AnyMsg.Attach(storeLogMsgClosure) + + log = logger.NewLogger(name) + configureTview() +} + +func run(*node.Plugin) { + if !isTerminal() { + return + } + + stopped := make(chan struct{}) + err := daemon.BackgroundWorker(name+" Refresher", func(shutdown <-chan struct{}) { + for { + select { + case <-time.After(repaintInterval): + app.QueueUpdateDraw(func() {}) + case <-shutdown: + logger.Events.AnyMsg.Detach(storeLogMsgClosure) + app.Stop() + return + case <-stopped: + return + } + } + }) + if err != nil { + log.Errorf("Failed to start as daemon: %s", err) + return + } + + err = daemon.BackgroundWorker(name+" App", func(<-chan struct{}) { + defer close(stopped) + + // switch logging to status screen + logger.Events.AnyMsg.Detach(stdLogMsgClosure) + defer logger.Events.AnyMsg.Attach(stdLogMsgClosure) + + if err := app.SetRoot(frame, true).SetFocus(frame).Run(); err != nil { + log.Errorf("Error running application: %s", err) + } + }) + if err != nil { + log.Errorf("Failed to start as daemon: %s", err) + close(stopped) + } +} diff --git a/plugins/statusscreen/status_message.go b/plugins/statusscreen/status_message.go deleted file mode 100644 index 2ec23aff1d..0000000000 --- a/plugins/statusscreen/status_message.go +++ /dev/null @@ -1,14 +0,0 @@ -package statusscreen - -import ( - "time" - - "github.com/iotaledger/hive.go/logger" -) - -type StatusMessage struct { - Source string - LogLevel logger.Level - Message string - Time time.Time -} diff --git a/plugins/statusscreen/statusscreen.go b/plugins/statusscreen/statusscreen.go index 0d51af1e13..40acb01ba3 100644 --- a/plugins/statusscreen/statusscreen.go +++ b/plugins/statusscreen/statusscreen.go @@ -2,61 +2,21 @@ package statusscreen import ( "os" - "sync" - "time" "github.com/gdamore/tcell" "github.com/iotaledger/hive.go/daemon" - "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" - "github.com/iotaledger/hive.go/node" "github.com/rivo/tview" "golang.org/x/crypto/ssh/terminal" ) -var statusMessages = make(map[string]*StatusMessage) -var messageLog = make([]*StatusMessage, 0) -var mutex sync.RWMutex - -var app *tview.Application - -func configure(plugin *node.Plugin) { - if !terminal.IsTerminal(int(os.Stdin.Fd())) { - return - } - - // store any log message for display - anyLogMsgClosure := events.NewClosure(func(logLevel logger.Level, prefix string, msg string) { - storeStatusMessage(logLevel, prefix, msg) - }) - logger.Events.AnyMsg.Attach(anyLogMsgClosure) - - daemon.BackgroundWorker("UI-Detach", func(shutdownSignal <-chan struct{}) { - <-shutdownSignal - logger.Events.AnyMsg.Detach(anyLogMsgClosure) - if app != nil { - app.Stop() - } - }, 1) -} - -func run(plugin *node.Plugin) { - if !terminal.IsTerminal(int(os.Stdin.Fd())) { - return - } - - newPrimitive := func(text string) *tview.TextView { - textView := tview.NewTextView() - - textView. - SetTextAlign(tview.AlignLeft). - SetText(" " + text) - - return textView - } - - app = tview.NewApplication() +var ( + log *logger.Logger + app *tview.Application + frame *tview.Frame +) +func configureTview() { headerBar := NewUIHeaderBar() content := tview.NewGrid() @@ -78,30 +38,28 @@ func run(plugin *node.Plugin) { AddItem(content, 1, 0, 1, 1, 0, 0, false). AddItem(footer, 2, 0, 1, 1, 0, 0, false) - frame := tview.NewFrame(grid). + frame = tview.NewFrame(grid). SetBorders(1, 1, 0, 0, 2, 2) frame.SetBackgroundColor(tcell.ColorDarkGray) + app = tview.NewApplication() app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { + // end the daemon on ctrl+c if event.Key() == tcell.KeyCtrlC || event.Key() == tcell.KeyESC { daemon.Shutdown() - return nil } - return event }) app.SetBeforeDrawFunc(func(screen tcell.Screen) bool { - mutex.RLock() - defer mutex.RUnlock() headerBar.Update() rows := make([]int, 2) rows[0] = 1 rows[1] = 1 _, _, _, height := content.GetRect() - for i := 0; i < len(messageLog) && i < height-2; i++ { + for i := 0; i < len(logMessages) && i < height-2; i++ { rows = append(rows, 1) } @@ -112,12 +70,12 @@ func run(plugin *node.Plugin) { blankLine.SetBackgroundColor(tcell.ColorWhite) content.AddItem(blankLine, 0, 0, 1, 1, 0, 0, false) - logStart := len(messageLog) - (len(rows) - 2) + logStart := len(logMessages) - (len(rows) - 2) if logStart < 0 { logStart = 0 } - for i, message := range messageLog[logStart:] { + for i, message := range logMessages[logStart:] { if i < height-2 { content.AddItem(NewUILogEntry(*message).Primitive, i+1, 0, 1, 1, 0, 0, false) } @@ -129,23 +87,15 @@ func run(plugin *node.Plugin) { return false }) +} - daemon.BackgroundWorker("Statusscreen Refresher", func(shutdownSignal <-chan struct{}) { - for { - select { - case <-shutdownSignal: - return - case <-time.After(1 * time.Second): - app.QueueUpdateDraw(func() {}) - } - } - }) +func newPrimitive(text string) *tview.TextView { + textView := tview.NewTextView() + textView.SetTextAlign(tview.AlignLeft).SetText(" " + text) - daemon.BackgroundWorker("Statusscreen App", func(shutdownSignal <-chan struct{}) { - if err := app.SetRoot(frame, true).SetFocus(frame).Run(); err != nil { - panic(err) - } - }) + return textView } -var PLUGIN = node.NewPlugin("Status Screen", node.Enabled, configure, run) +func isTerminal() bool { + return terminal.IsTerminal(int(os.Stdin.Fd())) +} diff --git a/plugins/statusscreen/ui_log.go b/plugins/statusscreen/ui_log.go deleted file mode 100644 index 6dae65662b..0000000000 --- a/plugins/statusscreen/ui_log.go +++ /dev/null @@ -1,15 +0,0 @@ -package statusscreen - -import "github.com/rivo/tview" - -type UILog struct { - Primitive *tview.Grid -} - -func NewUILog() *UILog { - uiLog := &UILog{ - Primitive: tview.NewGrid(), - } - - return uiLog -} diff --git a/plugins/statusscreen/ui_log_entry.go b/plugins/statusscreen/ui_log_entry.go index 4134636d1d..57cbc6e7eb 100644 --- a/plugins/statusscreen/ui_log_entry.go +++ b/plugins/statusscreen/ui_log_entry.go @@ -15,7 +15,7 @@ type UILogEntry struct { LogLevelContainer *tview.TextView } -func NewUILogEntry(message StatusMessage) *UILogEntry { +func NewUILogEntry(message logMessage) *UILogEntry { logEntry := &UILogEntry{ Primitive: tview.NewGrid(), TimeContainer: tview.NewTextView(), @@ -36,7 +36,7 @@ func NewUILogEntry(message StatusMessage) *UILogEntry { logEntry.LogLevelContainer.SetDynamicColors(true) textColor := "black::d" - switch message.LogLevel { + switch message.level { case logger.LevelInfo: fmt.Fprintf(logEntry.LogLevelContainer, " [black::d][ [blue::d]INFO [black::d]]") case logger.LevelWarn: @@ -57,11 +57,11 @@ func NewUILogEntry(message StatusMessage) *UILogEntry { textColor = "black::b" } - fmt.Fprintf(logEntry.TimeContainer, " [black::b]"+message.Time.Format("15:04:05")) - if message.Source == "Node" { - fmt.Fprintf(logEntry.MessageContainer, "["+textColor+"]"+message.Message) + fmt.Fprintf(logEntry.TimeContainer, " [black::b]"+message.time.Format("15:04:05")) + if message.name == "Node" { + fmt.Fprintf(logEntry.MessageContainer, "["+textColor+"]"+message.msg) } else { - fmt.Fprintf(logEntry.MessageContainer, "["+textColor+"]"+message.Source+": "+message.Message) + fmt.Fprintf(logEntry.MessageContainer, "["+textColor+"]"+message.name+": "+message.msg) } logEntry.Primitive. From bcf3977ffb2cf45ff719673f61976520c917b3ae Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 8 Jan 2020 22:56:58 +0100 Subject: [PATCH 086/184] fix: use global logger for local --- plugins/autopeering/local/local.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/plugins/autopeering/local/local.go b/plugins/autopeering/local/local.go index 58381256ae..cfafcb89f9 100644 --- a/plugins/autopeering/local/local.go +++ b/plugins/autopeering/local/local.go @@ -11,7 +11,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/parameter" - "go.uber.org/zap" + "github.com/iotaledger/hive.go/logger" ) var ( @@ -35,11 +35,7 @@ func configureLocal() *peer.Local { port := strconv.Itoa(parameter.NodeConfig.GetInt(CFG_PORT)) // create a new local node - logger, err := zap.NewProduction() - if err != nil { - log.Fatalf("Could not create logger: %v", err) - } - db := peer.NewPersistentDB(logger.Named("db").Sugar()) + db := peer.NewPersistentDB(logger.NewLogger("local")) local, err := peer.NewLocal("udp", net.JoinHostPort(ip.String(), port), db) if err != nil { From d20afa8ac45eb7210c3c3eac21944643332f8e87 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Thu, 9 Jan 2020 19:15:06 +0100 Subject: [PATCH 087/184] Upgrade hive.go version --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e07f8c2e3e..ffdc776252 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/go-zeromq/zmq4 v0.7.0 github.com/golang/protobuf v1.3.2 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/hive.go v0.0.0-20200107205115-986a54f82a30 + github.com/iotaledger/hive.go v0.0.0-20200109143501-f876e7457f15 github.com/iotaledger/iota.go v1.0.0-beta.13 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect diff --git a/go.sum b/go.sum index 4f7c64308f..1a4c5f51d7 100644 --- a/go.sum +++ b/go.sum @@ -83,8 +83,8 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/hive.go v0.0.0-20200107205115-986a54f82a30 h1:eE0sEnnQ/HV7QtkUBEPFXPqMXPjUET2UIWDCDcUuGhk= -github.com/iotaledger/hive.go v0.0.0-20200107205115-986a54f82a30/go.mod h1:obs07gqna53/Yw1ltzLsQzJBMyA6lGu7Fb/ltjqWMnQ= +github.com/iotaledger/hive.go v0.0.0-20200109143501-f876e7457f15 h1:3QiXbekFTcuJJFnZUGZ9roLLykCD78Yz2aPZYh1QYLA= +github.com/iotaledger/hive.go v0.0.0-20200109143501-f876e7457f15/go.mod h1:obs07gqna53/Yw1ltzLsQzJBMyA6lGu7Fb/ltjqWMnQ= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/iotaledger/iota.go v1.0.0-beta.13 h1:6m6JRcKtjTflU2PbjvDA9Tv6NTEJX1PijBDOkH9weQc= github.com/iotaledger/iota.go v1.0.0-beta.13/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= From 312b67af6e50c011108e4a5b5c7f5138a17f3c54 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Thu, 9 Jan 2020 19:15:41 +0100 Subject: [PATCH 088/184] test: use example logger in autopeering tests --- packages/autopeering/discover/manager_test.go | 4 +- .../autopeering/discover/protocol_test.go | 48 ++++++++----------- .../autopeering/selection/manager_test.go | 40 ++++++---------- .../autopeering/selection/protocol_test.go | 39 ++++++--------- packages/autopeering/server/server_test.go | 33 +++++-------- 5 files changed, 64 insertions(+), 100 deletions(-) diff --git a/packages/autopeering/discover/manager_test.go b/packages/autopeering/discover/manager_test.go index 580b87e78d..ddd255656f 100644 --- a/packages/autopeering/discover/manager_test.go +++ b/packages/autopeering/discover/manager_test.go @@ -33,7 +33,7 @@ func (m *NetworkMock) discoveryRequest(p *peer.Peer) ([]*peer.Peer, error) { } func newNetworkMock() *NetworkMock { - local, _ := peer.NewLocal("mock", "0", peer.NewMemoryDB(logger)) + local, _ := peer.NewLocal("mock", "0", peer.NewMemoryDB(log)) return &NetworkMock{ // no database needed loc: local, @@ -49,7 +49,7 @@ func newDummyPeer(name string) *peer.Peer { func newTestManager() (*manager, *NetworkMock, func()) { networkMock := newNetworkMock() - mgr := newManager(networkMock, nil, logger, nil) + mgr := newManager(networkMock, nil, log, nil) teardown := func() { mgr.close() } diff --git a/packages/autopeering/discover/protocol_test.go b/packages/autopeering/discover/protocol_test.go index 5de6c010b5..f7c5d328eb 100644 --- a/packages/autopeering/discover/protocol_test.go +++ b/packages/autopeering/discover/protocol_test.go @@ -1,7 +1,6 @@ package discover import ( - "log" "testing" "time" @@ -9,6 +8,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/autopeering/server" "github.com/iotaledger/goshimmer/packages/autopeering/transport" + "github.com/iotaledger/hive.go/logger" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap" @@ -16,15 +16,9 @@ import ( const graceTime = 100 * time.Millisecond -var logger *zap.SugaredLogger +var log = logger.NewExampleLogger("discover") func init() { - l, err := zap.NewDevelopment() - if err != nil { - log.Fatalf("cannot initialize logger: %v", err) - } - logger = l.Sugar() - // decrease parameters to simplify and speed up tests reverifyInterval = 500 * time.Millisecond queryInterval = 1000 * time.Millisecond @@ -33,7 +27,7 @@ func init() { } // newTest creates a new discovery server and also returns the teardown. -func newTest(t require.TestingT, trans transport.Transport, logger *zap.SugaredLogger, masters ...*peer.Peer) (*server.Server, *Protocol, func()) { +func newTest(t require.TestingT, trans transport.Transport, logger *logger.Logger, masters ...*peer.Peer) (*server.Server, *Protocol, func()) { log := logger.Named(trans.LocalAddr().String()) db := peer.NewMemoryDB(log.Named("db")) local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) @@ -63,12 +57,12 @@ func TestProtVerifyMaster(t *testing.T) { p2p := transport.P2P() defer p2p.Close() - srvA, _, closeA := newTest(t, p2p.A, logger) + srvA, _, closeA := newTest(t, p2p.A, log) defer closeA() peerA := getPeer(srvA) // use peerA as masters peer - _, protB, closeB := newTest(t, p2p.B, logger, peerA) + _, protB, closeB := newTest(t, p2p.B, log, peerA) time.Sleep(graceTime) // wait for the packages to ripple through the network closeB() // close srvB to avoid race conditions, when asserting @@ -83,9 +77,9 @@ func TestProtPingPong(t *testing.T) { p2p := transport.P2P() defer p2p.Close() - srvA, protA, closeA := newTest(t, p2p.A, logger) + srvA, protA, closeA := newTest(t, p2p.A, log) defer closeA() - srvB, protB, closeB := newTest(t, p2p.B, logger) + srvB, protB, closeB := newTest(t, p2p.B, log) defer closeB() peerA := getPeer(srvA) @@ -104,9 +98,9 @@ func TestProtPingTimeout(t *testing.T) { p2p := transport.P2P() defer p2p.Close() - _, protA, closeA := newTest(t, p2p.A, logger) + _, protA, closeA := newTest(t, p2p.A, log) defer closeA() - srvB, _, closeB := newTest(t, p2p.B, logger) + srvB, _, closeB := newTest(t, p2p.B, log) closeB() // close the connection right away to prevent any replies peerB := getPeer(srvB) @@ -120,9 +114,9 @@ func TestProtVerifiedPeers(t *testing.T) { p2p := transport.P2P() defer p2p.Close() - _, protA, closeA := newTest(t, p2p.A, logger) + _, protA, closeA := newTest(t, p2p.A, log) defer closeA() - srvB, _, closeB := newTest(t, p2p.B, logger) + srvB, _, closeB := newTest(t, p2p.B, log) defer closeB() peerB := getPeer(srvB) @@ -142,9 +136,9 @@ func TestProtVerifiedPeer(t *testing.T) { p2p := transport.P2P() defer p2p.Close() - srvA, protA, closeA := newTest(t, p2p.A, logger) + srvA, protA, closeA := newTest(t, p2p.A, log) defer closeA() - srvB, _, closeB := newTest(t, p2p.B, logger) + srvB, _, closeB := newTest(t, p2p.B, log) defer closeB() peerA := getPeer(srvA) @@ -166,9 +160,9 @@ func TestProtDiscoveryRequest(t *testing.T) { p2p := transport.P2P() defer p2p.Close() - srvA, protA, closeA := newTest(t, p2p.A, logger) + srvA, protA, closeA := newTest(t, p2p.A, log) defer closeA() - srvB, protB, closeB := newTest(t, p2p.B, logger) + srvB, protB, closeB := newTest(t, p2p.B, log) defer closeB() peerA := getPeer(srvA) @@ -192,13 +186,13 @@ func TestProtServices(t *testing.T) { p2p := transport.P2P() defer p2p.Close() - srvA, _, closeA := newTest(t, p2p.A, logger) + srvA, _, closeA := newTest(t, p2p.A, log) defer closeA() err := srvA.Local().UpdateService(service.FPCKey, "fpc", p2p.A.LocalAddr().String()) require.NoError(t, err) // use peerA as masters peer - _, protB, closeB := newTest(t, p2p.B, logger, getPeer(srvA)) + _, protB, closeB := newTest(t, p2p.B, log, getPeer(srvA)) defer closeB() time.Sleep(graceTime) // wait for the packages to ripple through the network @@ -213,15 +207,15 @@ func TestProtDiscovery(t *testing.T) { net := transport.NewNetwork("M", "A", "B", "C") defer net.Close() - srvM, protM, closeM := newTest(t, net.GetTransport("M"), logger) + srvM, protM, closeM := newTest(t, net.GetTransport("M"), log) defer closeM() time.Sleep(graceTime) // wait for the master to initialize - srvA, protA, closeA := newTest(t, net.GetTransport("A"), logger, getPeer(srvM)) + srvA, protA, closeA := newTest(t, net.GetTransport("A"), log, getPeer(srvM)) defer closeA() - srvB, protB, closeB := newTest(t, net.GetTransport("B"), logger, getPeer(srvM)) + srvB, protB, closeB := newTest(t, net.GetTransport("B"), log, getPeer(srvM)) defer closeB() - srvC, protC, closeC := newTest(t, net.GetTransport("C"), logger, getPeer(srvM)) + srvC, protC, closeC := newTest(t, net.GetTransport("C"), log, getPeer(srvM)) defer closeC() time.Sleep(queryInterval + graceTime) // wait for the next discovery cycle diff --git a/packages/autopeering/selection/manager_test.go b/packages/autopeering/selection/manager_test.go index 8c3939d8fc..daffe4b0ae 100644 --- a/packages/autopeering/selection/manager_test.go +++ b/packages/autopeering/selection/manager_test.go @@ -2,15 +2,14 @@ package selection import ( "fmt" - "log" "math/rand" "testing" "time" "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/salt" + "github.com/iotaledger/hive.go/logger" "github.com/stretchr/testify/assert" - "go.uber.org/zap" ) var ( @@ -21,23 +20,12 @@ type testPeer struct { local *peer.Local peer *peer.Peer db peer.DB - log *zap.SugaredLogger + log *logger.Logger rand *rand.Rand // random number generator } func newPeer(name string) testPeer { - var l *zap.Logger - var err error - if name == "1" { - l, err = zap.NewDevelopment() - } else { - l, err = zap.NewDevelopment() //zap.NewProduction() - } - if err != nil { - log.Fatalf("cannot initialize logger: %v", err) - } - logger := l.Sugar() - log := logger.Named(name) + log := log.Named(name) db := peer.NewMemoryDB(log.Named("db")) local, _ := peer.NewLocal("", name, db) s, _ := salt.NewSalt(100 * time.Second) @@ -84,12 +72,12 @@ func (n testNet) RequestPeering(p *peer.Peer, s *salt.Salt) (bool, error) { func (n testNet) GetKnownPeers() []*peer.Peer { list := make([]*peer.Peer, len(allPeers)-1) i := 0 - for _, peer := range allPeers { - if peer.ID() == n.self.ID() { + for _, p := range allPeers { + if p.ID() == n.self.ID() { continue } - list[i] = peer + list[i] = p i++ } return list @@ -102,16 +90,16 @@ func TestSimManager(t *testing.T) { mgrMap := make(map[peer.ID]*manager) for i := range allPeers { - peer := newPeer(fmt.Sprintf("%d", i)) - allPeers[i] = peer.peer + p := newPeer(fmt.Sprintf("%d", i)) + allPeers[i] = p.peer net := testNet{ mgr: mgrMap, - loc: peer.local, - self: peer.peer, - rand: peer.rand, + loc: p.local, + self: p.peer, + rand: p.rand, } - mgrMap[peer.local.ID()] = newManager(net, net.GetKnownPeers, peer.log, &Parameters{SaltLifetime: 100 * time.Second}) + mgrMap[p.local.ID()] = newManager(net, net.GetKnownPeers, p.log, &Parameters{SaltLifetime: 100 * time.Second}) } // start all the managers @@ -121,8 +109,8 @@ func TestSimManager(t *testing.T) { time.Sleep(6 * time.Second) - for i, peer := range allPeers { - neighbors := mgrMap[peer.ID()].getNeighbors() + for i, p := range allPeers { + neighbors := mgrMap[p.ID()].getNeighbors() assert.NotEmpty(t, neighbors, "Peer %d has no neighbors", i) assert.Equal(t, removeDuplicatePeers(neighbors), neighbors, "Peer %d has non unique neighbors", i) diff --git a/packages/autopeering/selection/protocol_test.go b/packages/autopeering/selection/protocol_test.go index 2d3a129582..37871352ff 100644 --- a/packages/autopeering/selection/protocol_test.go +++ b/packages/autopeering/selection/protocol_test.go @@ -1,7 +1,6 @@ package selection import ( - "log" "testing" "time" @@ -10,36 +9,28 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/salt" "github.com/iotaledger/goshimmer/packages/autopeering/server" "github.com/iotaledger/goshimmer/packages/autopeering/transport" + "github.com/iotaledger/hive.go/logger" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.uber.org/zap" ) const graceTime = 100 * time.Millisecond -var logger *zap.SugaredLogger - -func init() { - l, err := zap.NewDevelopment() - if err != nil { - log.Fatalf("cannot initialize logger: %v", err) - } - logger = l.Sugar() -} +var log = logger.NewExampleLogger("selection") var peerMap = make(map[peer.ID]*peer.Peer) // dummyDiscovery is a dummy implementation of DiscoveryProtocol never returning any verified peers. type dummyDiscovery struct{} -func (d dummyDiscovery) IsVerified(peer.ID, string) bool { return true } -func (d dummyDiscovery) EnsureVerified(*peer.Peer) {} -func (d dummyDiscovery) GetVerifiedPeer(id peer.ID, addr string) *peer.Peer { return peerMap[id] } -func (d dummyDiscovery) GetVerifiedPeers() []*peer.Peer { return []*peer.Peer{} } +func (d dummyDiscovery) IsVerified(peer.ID, string) bool { return true } +func (d dummyDiscovery) EnsureVerified(*peer.Peer) {} +func (d dummyDiscovery) GetVerifiedPeer(id peer.ID, _ string) *peer.Peer { return peerMap[id] } +func (d dummyDiscovery) GetVerifiedPeers() []*peer.Peer { return []*peer.Peer{} } // newTest creates a new neighborhood server and also returns the teardown. -func newTest(t require.TestingT, trans transport.Transport, logger *zap.SugaredLogger) (*server.Server, *Protocol, func()) { - log := logger.Named(trans.LocalAddr().String()) +func newTest(t require.TestingT, trans transport.Transport) (*server.Server, *Protocol, func()) { + log := log.Named(trans.LocalAddr().String()) db := peer.NewMemoryDB(log.Named("db")) local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) require.NoError(t, err) @@ -70,9 +61,9 @@ func TestProtPeeringRequest(t *testing.T) { p2p := transport.P2P() defer p2p.Close() - srvA, protA, closeA := newTest(t, p2p.A, logger) + srvA, protA, closeA := newTest(t, p2p.A) defer closeA() - srvB, protB, closeB := newTest(t, p2p.B, logger) + srvB, protB, closeB := newTest(t, p2p.B) defer closeB() peerA := getPeer(srvA) @@ -98,9 +89,9 @@ func TestProtExpiredSalt(t *testing.T) { p2p := transport.P2P() defer p2p.Close() - _, protA, closeA := newTest(t, p2p.A, logger) + _, protA, closeA := newTest(t, p2p.A) defer closeA() - srvB, _, closeB := newTest(t, p2p.B, logger) + srvB, _, closeB := newTest(t, p2p.B) defer closeB() saltA, _ := salt.NewSalt(-1 * time.Second) @@ -115,9 +106,9 @@ func TestProtDropPeer(t *testing.T) { p2p := transport.P2P() defer p2p.Close() - srvA, protA, closeA := newTest(t, p2p.A, logger) + srvA, protA, closeA := newTest(t, p2p.A) defer closeA() - srvB, protB, closeB := newTest(t, p2p.B, logger) + srvB, protB, closeB := newTest(t, p2p.B) defer closeB() peerA := getPeer(srvA) @@ -139,7 +130,7 @@ func TestProtDropPeer(t *testing.T) { // newTest creates a new server handling discover as well as neighborhood and also returns the teardown. func newFullTest(t require.TestingT, trans transport.Transport, masterPeers ...*peer.Peer) (*server.Server, *Protocol, func()) { - log := logger.Named(trans.LocalAddr().String()) + log := log.Named(trans.LocalAddr().String()) db := peer.NewMemoryDB(log.Named("db")) local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) require.NoError(t, err) diff --git a/packages/autopeering/server/server_test.go b/packages/autopeering/server/server_test.go index 80f3627473..3e784af584 100644 --- a/packages/autopeering/server/server_test.go +++ b/packages/autopeering/server/server_test.go @@ -1,30 +1,21 @@ package server import ( - "log" "testing" "time" "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/salt" "github.com/iotaledger/goshimmer/packages/autopeering/transport" + "github.com/iotaledger/hive.go/logger" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "go.uber.org/zap" ) const graceTime = 5 * time.Millisecond -var logger *zap.SugaredLogger - -func init() { - l, err := zap.NewDevelopment() - if err != nil { - log.Fatalf("cannot initialize logger: %v", err) - } - logger = l.Sugar() -} +var log = logger.NewExampleLogger("server") const ( MPing MType = iota @@ -106,7 +97,7 @@ func unmarshal(data []byte) (Message, error) { func TestSrvEncodeDecodePing(t *testing.T) { // create minimal server just containing the local peer - local, err := peer.NewLocal("dummy", "local", peer.NewMemoryDB(logger)) + local, err := peer.NewLocal("dummy", "local", peer.NewMemoryDB(log)) require.NoError(t, err) s := &Server{local: local} @@ -121,8 +112,8 @@ func TestSrvEncodeDecodePing(t *testing.T) { assert.Equal(t, msg, ping) } -func newTestServer(t require.TestingT, name string, trans transport.Transport, logger *zap.SugaredLogger) (*Server, func()) { - log := logger.Named(name) +func newTestServer(t require.TestingT, name string, trans transport.Transport) (*Server, func()) { + log := log.Named(name) db := peer.NewMemoryDB(log.Named("db")) local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) require.NoError(t, err) @@ -132,7 +123,7 @@ func newTestServer(t require.TestingT, name string, trans transport.Transport, l s, _ = salt.NewSalt(100 * time.Second) local.SetPublicSalt(s) - srv := Listen(local, trans, logger.Named(name), HandlerFunc(handle)) + srv := Listen(local, trans, log, HandlerFunc(handle)) teardown := func() { srv.Close() @@ -155,9 +146,9 @@ func sendPing(s *Server, p *peer.Peer) error { func TestPingPong(t *testing.T) { p2p := transport.P2P() - srvA, closeA := newTestServer(t, "A", p2p.A, logger) + srvA, closeA := newTestServer(t, "A", p2p.A) defer closeA() - srvB, closeB := newTestServer(t, "B", p2p.B, logger) + srvB, closeB := newTestServer(t, "B", p2p.B) defer closeB() peerA := &srvA.Local().Peer @@ -192,9 +183,9 @@ func TestSrvPingTimeout(t *testing.T) { p2p := transport.P2P() - srvA, closeA := newTestServer(t, "A", p2p.A, logger) + srvA, closeA := newTestServer(t, "A", p2p.A) defer closeA() - srvB, closeB := newTestServer(t, "B", p2p.B, logger) + srvB, closeB := newTestServer(t, "B", p2p.B) closeB() peerB := &srvB.Local().Peer @@ -206,9 +197,9 @@ func TestUnexpectedPong(t *testing.T) { p2p := transport.P2P() - srvA, closeA := newTestServer(t, "A", p2p.A, logger) + srvA, closeA := newTestServer(t, "A", p2p.A) defer closeA() - srvB, closeB := newTestServer(t, "B", p2p.B, logger) + srvB, closeB := newTestServer(t, "B", p2p.B) defer closeB() // there should never be a Ping.Handle From e7e4f19ee56f47b3fa5a89444fe2d7bff610f2ca Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Fri, 10 Jan 2020 11:08:56 +0100 Subject: [PATCH 089/184] Fix potential race conditions in gossip (#94) * fix: use queue for neighbor connection * refactor: do not request transactions via event * fix: remove unused connection * chore: fix linter warnings * feat: improve gossip events and logs * fix: log after connection is closed --- .../autopeering/discover/protocol_test.go | 8 +- .../autopeering/selection/protocol_test.go | 18 +- packages/autopeering/server/server_test.go | 6 +- packages/gossip/common.go | 20 ++ packages/gossip/errors.go | 1 + packages/gossip/events.go | 32 +-- packages/gossip/manager.go | 143 ++++------ packages/gossip/manager_test.go | 262 +++++++++++------- packages/gossip/neighbor.go | 145 ++++++++++ packages/gossip/neighbor_test.go | 152 ++++++++++ packages/gossip/server/connection.go | 29 -- packages/gossip/server/server.go | 10 +- packages/gossip/server/server_test.go | 15 +- plugins/autopeering/plugin.go | 12 +- plugins/gossip/gossip.go | 13 +- plugins/gossip/plugin.go | 47 ++-- plugins/statusscreen/plugin.go | 10 +- plugins/tangle/events.go | 10 +- plugins/tangle/plugin.go | 10 + plugins/tangle/solidifier.go | 23 +- plugins/tangle/solidifier_test.go | 20 +- plugins/webapi/routes.go | 9 - 22 files changed, 652 insertions(+), 343 deletions(-) create mode 100644 packages/gossip/common.go create mode 100644 packages/gossip/neighbor.go create mode 100644 packages/gossip/neighbor_test.go delete mode 100644 packages/gossip/server/connection.go delete mode 100644 plugins/webapi/routes.go diff --git a/packages/autopeering/discover/protocol_test.go b/packages/autopeering/discover/protocol_test.go index f7c5d328eb..7f6432f7ba 100644 --- a/packages/autopeering/discover/protocol_test.go +++ b/packages/autopeering/discover/protocol_test.go @@ -28,17 +28,17 @@ func init() { // newTest creates a new discovery server and also returns the teardown. func newTest(t require.TestingT, trans transport.Transport, logger *logger.Logger, masters ...*peer.Peer) (*server.Server, *Protocol, func()) { - log := logger.Named(trans.LocalAddr().String()) - db := peer.NewMemoryDB(log.Named("db")) + l := logger.Named(trans.LocalAddr().String()) + db := peer.NewMemoryDB(l.Named("db")) local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) require.NoError(t, err) cfg := Config{ - Log: log, + Log: l, MasterPeers: masters, } prot := New(local, cfg) - srv := server.Listen(local, trans, log.Named("srv"), prot) + srv := server.Listen(local, trans, l.Named("srv"), prot) prot.Start(srv) teardown := func() { diff --git a/packages/autopeering/selection/protocol_test.go b/packages/autopeering/selection/protocol_test.go index 37871352ff..8caf9174c5 100644 --- a/packages/autopeering/selection/protocol_test.go +++ b/packages/autopeering/selection/protocol_test.go @@ -30,8 +30,8 @@ func (d dummyDiscovery) GetVerifiedPeers() []*peer.Peer { retur // newTest creates a new neighborhood server and also returns the teardown. func newTest(t require.TestingT, trans transport.Transport) (*server.Server, *Protocol, func()) { - log := log.Named(trans.LocalAddr().String()) - db := peer.NewMemoryDB(log.Named("db")) + l := log.Named(trans.LocalAddr().String()) + db := peer.NewMemoryDB(l.Named("db")) local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) require.NoError(t, err) @@ -39,10 +39,10 @@ func newTest(t require.TestingT, trans transport.Transport) (*server.Server, *Pr peerMap[local.ID()] = &local.Peer cfg := Config{ - Log: log, + Log: l, } prot := New(local, dummyDiscovery{}, cfg) - srv := server.Listen(local, trans, log.Named("srv"), prot) + srv := server.Listen(local, trans, l.Named("srv"), prot) prot.Start(srv) teardown := func() { @@ -130,20 +130,20 @@ func TestProtDropPeer(t *testing.T) { // newTest creates a new server handling discover as well as neighborhood and also returns the teardown. func newFullTest(t require.TestingT, trans transport.Transport, masterPeers ...*peer.Peer) (*server.Server, *Protocol, func()) { - log := log.Named(trans.LocalAddr().String()) - db := peer.NewMemoryDB(log.Named("db")) + l := log.Named(trans.LocalAddr().String()) + db := peer.NewMemoryDB(l.Named("db")) local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) require.NoError(t, err) discovery := discover.New(local, discover.Config{ - Log: log.Named("disc"), + Log: l.Named("disc"), MasterPeers: masterPeers, }) selection := New(local, discovery, Config{ - Log: log.Named("sel"), + Log: l.Named("sel"), }) - srv := server.Listen(local, trans, log.Named("srv"), discovery, selection) + srv := server.Listen(local, trans, l.Named("srv"), discovery, selection) discovery.Start(srv) selection.Start(srv) diff --git a/packages/autopeering/server/server_test.go b/packages/autopeering/server/server_test.go index 3e784af584..f3cff2c83e 100644 --- a/packages/autopeering/server/server_test.go +++ b/packages/autopeering/server/server_test.go @@ -113,8 +113,8 @@ func TestSrvEncodeDecodePing(t *testing.T) { } func newTestServer(t require.TestingT, name string, trans transport.Transport) (*Server, func()) { - log := log.Named(name) - db := peer.NewMemoryDB(log.Named("db")) + l := log.Named(name) + db := peer.NewMemoryDB(l.Named("db")) local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) require.NoError(t, err) @@ -123,7 +123,7 @@ func newTestServer(t require.TestingT, name string, trans transport.Transport) ( s, _ = salt.NewSalt(100 * time.Second) local.SetPublicSalt(s) - srv := Listen(local, trans, log, HandlerFunc(handle)) + srv := Listen(local, trans, l, HandlerFunc(handle)) teardown := func() { srv.Close() diff --git a/packages/gossip/common.go b/packages/gossip/common.go new file mode 100644 index 0000000000..6f48f378c7 --- /dev/null +++ b/packages/gossip/common.go @@ -0,0 +1,20 @@ +package gossip + +import ( + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" +) + +// IsSupported returns whether the peer supports the gossip service. +func IsSupported(p *peer.Peer) bool { + return p.Services().Get(service.GossipKey) != nil +} + +// GetAddress returns the address of the gossip service. +func GetAddress(p *peer.Peer) string { + gossip := p.Services().Get(service.GossipKey) + if gossip == nil { + panic("peer does not support gossip") + } + return gossip.String() +} diff --git a/packages/gossip/errors.go b/packages/gossip/errors.go index 160ed5513d..e32a15305c 100644 --- a/packages/gossip/errors.go +++ b/packages/gossip/errors.go @@ -7,4 +7,5 @@ var ( ErrClosed = errors.New("manager closed") ErrNotANeighbor = errors.New("peer is not a neighbor") ErrDuplicateNeighbor = errors.New("peer already connected") + ErrInvalidPacket = errors.New("invalid packet") ) diff --git a/packages/gossip/events.go b/packages/gossip/events.go index b7f82934ab..169ec219b8 100644 --- a/packages/gossip/events.go +++ b/packages/gossip/events.go @@ -3,25 +3,23 @@ package gossip import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/hive.go/events" - "github.com/iotaledger/iota.go/trinary" ) // Events contains all the events related to the gossip protocol. var Events = struct { - // A NeighborDropped event is triggered when a neighbor has been dropped. - NeighborDropped *events.Event + // A ConnectionFailed event is triggered when a neighbor connection to a peer could not be established. + ConnectionFailed *events.Event + // A NeighborAdded event is triggered when a connection to a new neighbor has been established. + NeighborAdded *events.Event + // A NeighborRemoved event is triggered when a neighbor has been dropped. + NeighborRemoved *events.Event // A TransactionReceived event is triggered when a new transaction is received by the gossip protocol. TransactionReceived *events.Event - // A RequestTransaction should be triggered for a transaction to be requested through the gossip protocol. - RequestTransaction *events.Event }{ - NeighborDropped: events.NewEvent(neighborDropped), + ConnectionFailed: events.NewEvent(peerCaller), + NeighborAdded: events.NewEvent(neighborCaller), + NeighborRemoved: events.NewEvent(peerCaller), TransactionReceived: events.NewEvent(transactionReceived), - RequestTransaction: events.NewEvent(requestTransaction), -} - -type NeighborDroppedEvent struct { - Peer *peer.Peer } type TransactionReceivedEvent struct { @@ -29,18 +27,14 @@ type TransactionReceivedEvent struct { Peer *peer.Peer // peer that send the transaction } -type RequestTransactionEvent struct { - Hash trinary.Trytes // hash of the transaction to request +func peerCaller(handler interface{}, params ...interface{}) { + handler.(func(*peer.Peer))(params[0].(*peer.Peer)) } -func neighborDropped(handler interface{}, params ...interface{}) { - handler.(func(*NeighborDroppedEvent))(params[0].(*NeighborDroppedEvent)) +func neighborCaller(handler interface{}, params ...interface{}) { + handler.(func(*Neighbor))(params[0].(*Neighbor)) } func transactionReceived(handler interface{}, params ...interface{}) { handler.(func(*TransactionReceivedEvent))(params[0].(*TransactionReceivedEvent)) } - -func requestTransaction(handler interface{}, params ...interface{}) { - handler.(func(*RequestTransactionEvent))(params[0].(*RequestTransactionEvent)) -} diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go index 6e6009394e..1050243f82 100644 --- a/packages/gossip/manager.go +++ b/packages/gossip/manager.go @@ -1,17 +1,15 @@ package gossip import ( - "io" "net" - "strings" "sync" - "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" - "github.com/golang/protobuf/proto" "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/gossip/server" + "github.com/iotaledger/hive.go/events" "github.com/pkg/errors" "go.uber.org/zap" ) @@ -32,22 +30,17 @@ type Manager struct { mu sync.RWMutex srv *server.TCP - neighbors map[peer.ID]*neighbor + neighbors map[peer.ID]*Neighbor running bool } -type neighbor struct { - peer *peer.Peer - conn *server.Connection -} - func NewManager(local *peer.Local, f GetTransaction, log *zap.SugaredLogger) *Manager { return &Manager{ local: local, getTransaction: f, log: log, srv: nil, - neighbors: make(map[peer.ID]*neighbor), + neighbors: make(map[peer.ID]*Neighbor), running: false, } } @@ -62,15 +55,20 @@ func (m *Manager) Start(srv *server.TCP) { // Close stops the manager and closes all established connections. func (m *Manager) Close() { + m.stop() + m.wg.Wait() +} + +func (m *Manager) stop() { m.mu.Lock() + defer m.mu.Unlock() + m.running = false - // close all connections - for _, n := range m.neighbors { - _ = n.conn.Close() - } - m.mu.Unlock() - m.wg.Wait() + // close all neighbor connections + for _, nbr := range m.neighbors { + _ = nbr.Close() + } } // LocalAddr returns the public address of the gossip service. @@ -104,7 +102,7 @@ func (m *Manager) AddInbound(p *peer.Peer) error { return m.addNeighbor(p, srv.AcceptPeer) } -// NeighborDropped disconnects the neighbor with the given ID. +// NeighborRemoved disconnects the neighbor with the given ID. func (m *Manager) DropNeighbor(id peer.ID) error { m.mu.Lock() defer m.mu.Unlock() @@ -113,9 +111,10 @@ func (m *Manager) DropNeighbor(id peer.ID) error { } n := m.neighbors[id] delete(m.neighbors, id) - disconnect(n.conn) - return nil + err := n.Close() + Events.NeighborRemoved.Trigger(n.Peer) + return err } // RequestTransaction requests the transaction with the given hash from the neighbors. @@ -127,8 +126,8 @@ func (m *Manager) RequestTransaction(txHash []byte, to ...peer.ID) { m.send(marshal(req), to...) } -// SendTransaction sends the given transaction data to the neighbors. -// If no peer is provided, it is send to all neighbors. +// SendTransaction adds the given transaction data to the send queue of the neighbors. +// The actual send then happens asynchronously. If no peer is provided, it is send to all neighbors. func (m *Manager) SendTransaction(txData []byte, to ...peer.ID) { tx := &pb.Transaction{ Data: txData, @@ -136,16 +135,16 @@ func (m *Manager) SendTransaction(txData []byte, to ...peer.ID) { m.send(marshal(tx), to...) } -func (m *Manager) getNeighbors(ids ...peer.ID) []*neighbor { +func (m *Manager) getNeighbors(ids ...peer.ID) []*Neighbor { if len(ids) > 0 { return m.getNeighborsById(ids) } return m.getAllNeighbors() } -func (m *Manager) getAllNeighbors() []*neighbor { +func (m *Manager) getAllNeighbors() []*Neighbor { m.mu.RLock() - result := make([]*neighbor, 0, len(m.neighbors)) + result := make([]*Neighbor, 0, len(m.neighbors)) for _, n := range m.neighbors { result = append(result, n) } @@ -154,8 +153,8 @@ func (m *Manager) getAllNeighbors() []*neighbor { return result } -func (m *Manager) getNeighborsById(ids []peer.ID) []*neighbor { - result := make([]*neighbor, 0, len(ids)) +func (m *Manager) getNeighborsById(ids []peer.ID) []*Neighbor { + result := make([]*Neighbor, 0, len(ids)) m.mu.RLock() for _, id := range ids { @@ -168,102 +167,74 @@ func (m *Manager) getNeighborsById(ids []peer.ID) []*neighbor { return result } -func (m *Manager) send(msg []byte, to ...peer.ID) { - if l := len(msg); l > maxPacketSize { - m.log.Errorw("message too large", "len", l, "max", maxPacketSize) - } +func (m *Manager) send(b []byte, to ...peer.ID) { neighbors := m.getNeighbors(to...) for _, nbr := range neighbors { - m.log.Debugw("Sending", "to", nbr.peer.ID(), "msg", msg) - _, err := nbr.conn.Write(msg) - if err != nil { - m.log.Debugw("send error", "err", err) + if _, err := nbr.Write(b); err != nil { + m.log.Warnw("send error", "err", err) } } } -func (m *Manager) addNeighbor(peer *peer.Peer, connectorFunc func(*peer.Peer) (*server.Connection, error)) error { +func (m *Manager) addNeighbor(peer *peer.Peer, connectorFunc func(*peer.Peer) (net.Conn, error)) error { conn, err := connectorFunc(peer) if err != nil { - m.log.Debugw("addNeighbor failed", "peer", peer.ID(), "err", err) - Events.NeighborDropped.Trigger(&NeighborDroppedEvent{Peer: peer}) + Events.ConnectionFailed.Trigger(peer) return err } m.mu.Lock() defer m.mu.Unlock() if !m.running { - disconnect(conn) + _ = conn.Close() + Events.ConnectionFailed.Trigger(peer) return ErrClosed } if _, ok := m.neighbors[peer.ID()]; ok { - disconnect(conn) + _ = conn.Close() + Events.ConnectionFailed.Trigger(peer) return ErrDuplicateNeighbor } - // add the neighbor - n := &neighbor{ - peer: peer, - conn: conn, - } + // create and add the neighbor + n := NewNeighbor(peer, conn, m.log) + n.Events.Close.Attach(events.NewClosure(func() { _ = m.DropNeighbor(peer.ID()) })) + n.Events.ReceiveData.Attach(events.NewClosure(func(data []byte) { + if err := m.handlePacket(data, peer); err != nil { + m.log.Debugw("error handling packet", "err", err) + } + })) + m.neighbors[peer.ID()] = n - go m.readLoop(n) + n.Listen() + Events.NeighborAdded.Trigger(n) return nil } -func (m *Manager) readLoop(nbr *neighbor) { - m.wg.Add(1) - defer m.wg.Done() - - // create a buffer for the packages - b := make([]byte, maxPacketSize) - - for { - n, err := nbr.conn.Read(b) - if nerr, ok := err.(net.Error); ok && nerr.Temporary() { - // ignore temporary read errors. - m.log.Debugw("temporary read error", "err", err) - continue - } else if err != nil { - // return from the loop on all other errors - if err != io.EOF && !strings.Contains(err.Error(), "use of closed network connection") { - m.log.Warnw("read error", "err", err) - } - - m.log.Debugw("connection closed", - "id", nbr.peer.ID(), - "addr", nbr.conn.RemoteAddr().String(), - ) - _ = nbr.conn.Close() // just make sure that the connection is closed as fast as possible - _ = m.DropNeighbor(nbr.peer.ID()) - return - } - - if err := m.handlePacket(b[:n], nbr); err != nil { - m.log.Warnw("failed to handle packet", "id", nbr.peer.ID(), "err", err) - } +func (m *Manager) handlePacket(data []byte, p *peer.Peer) error { + // ignore empty packages + if len(data) == 0 { + return nil } -} -func (m *Manager) handlePacket(data []byte, n *neighbor) error { switch pb.MType(data[0]) { // Incoming Transaction case pb.MTransaction: msg := new(pb.Transaction) if err := proto.Unmarshal(data[1:], msg); err != nil { - return errors.Wrap(err, "invalid message") + return errors.Wrap(err, "invalid packet") } m.log.Debugw("Received Transaction", "data", msg.GetData()) - Events.TransactionReceived.Trigger(&TransactionReceivedEvent{Data: msg.GetData(), Peer: n.peer}) + Events.TransactionReceived.Trigger(&TransactionReceivedEvent{Data: msg.GetData(), Peer: p}) // Incoming Transaction request case pb.MTransactionRequest: msg := new(pb.TransactionRequest) if err := proto.Unmarshal(data[1:], msg); err != nil { - return errors.Wrap(err, "invalid message") + return errors.Wrap(err, "invalid packet") } m.log.Debugw("Received Tx Req", "data", msg.GetHash()) // do something @@ -272,10 +243,11 @@ func (m *Manager) handlePacket(data []byte, n *neighbor) error { m.log.Debugw("Tx not available", "tx", msg.GetHash()) } else { m.log.Debugw("Tx found", "tx", tx) - m.SendTransaction(tx, n.peer.ID()) + m.SendTransaction(tx, p.ID()) } default: + return ErrInvalidPacket } return nil @@ -293,8 +265,3 @@ func marshal(msg pb.Message) []byte { } return append([]byte{byte(mType)}, data...) } - -func disconnect(conn *server.Connection) { - _ = conn.Close() - Events.NeighborDropped.Trigger(&NeighborDroppedEvent{Peer: conn.Peer()}) -} diff --git a/packages/gossip/manager_test.go b/packages/gossip/manager_test.go index 29a5634c67..eb86bf01e7 100644 --- a/packages/gossip/manager_test.go +++ b/packages/gossip/manager_test.go @@ -1,7 +1,6 @@ package gossip import ( - "log" "net" "sync" "testing" @@ -13,54 +12,25 @@ import ( pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/gossip/server" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" - "go.uber.org/zap" ) const graceTime = 10 * time.Millisecond var ( - logger *zap.SugaredLogger - eventMock mock.Mock - + log = logger.NewExampleLogger("gossip") testTxData = []byte("testTx") ) -func transactionReceivedEvent(ev *TransactionReceivedEvent) { eventMock.Called(ev) } -func neighborDroppedEvent(ev *NeighborDroppedEvent) { eventMock.Called(ev) } - -// assertEvents initializes the mock and asserts the expectations -func assertEvents(t *testing.T) func() { - eventMock = mock.Mock{} - return func() { - if !t.Failed() { - eventMock.AssertExpectations(t) - } - } -} - -func init() { - l, err := zap.NewDevelopment() - if err != nil { - log.Fatalf("cannot initialize logger: %v", err) - } - logger = l.Sugar() - - // mock the events triggered by the gossip - Events.TransactionReceived.Attach(events.NewClosure(transactionReceivedEvent)) - Events.NeighborDropped.Attach(events.NewClosure(neighborDroppedEvent)) -} - -func getTestTransaction([]byte) ([]byte, error) { - return testTxData, nil -} +func getTestTransaction([]byte) ([]byte, error) { return testTxData, nil } func getTCPAddress(t require.TestingT) string { - laddr, err := net.ResolveTCPAddr("tcp", "localhost:0") + tcpAddr, err := net.ResolveTCPAddr("tcp", "localhost:0") require.NoError(t, err) - lis, err := net.ListenTCP("tcp", laddr) + lis, err := net.ListenTCP("tcp", tcpAddr) require.NoError(t, err) addr := lis.Addr().String() @@ -69,8 +39,8 @@ func getTCPAddress(t require.TestingT) string { return addr } -func newTest(t require.TestingT, name string) (*Manager, func(), *peer.Peer) { - l := logger.Named(name) +func newTestManager(t require.TestingT, name string) (*Manager, func(), *peer.Peer) { + l := log.Named(name) db := peer.NewMemoryDB(l.Named("db")) local, err := peer.NewLocal("peering", name, db) require.NoError(t, err) @@ -89,31 +59,36 @@ func newTest(t require.TestingT, name string) (*Manager, func(), *peer.Peer) { // start the actual gossipping mgr.Start(srv) - teardown := func() { + detach := func() { mgr.Close() srv.Close() db.Close() } - return mgr, teardown, &local.Peer + return mgr, detach, &local.Peer } func TestClose(t *testing.T) { - defer assertEvents(t)() + _, detach := newEventMock(t) + defer detach() - _, teardown, _ := newTest(t, "A") + _, teardown, _ := newTestManager(t, "A") teardown() } func TestClosedConnection(t *testing.T) { - defer assertEvents(t)() + e, detach := newEventMock(t) + defer detach() - mgrA, closeA, peerA := newTest(t, "A") + mgrA, closeA, peerA := newTestManager(t, "A") defer closeA() - mgrB, closeB, peerB := newTest(t, "B") + mgrB, closeB, peerB := newTestManager(t, "B") defer closeB() + connections := 2 + e.On("neighborAdded", mock.Anything).Times(connections) + var wg sync.WaitGroup - wg.Add(2) + wg.Add(connections) // connect in the following way // B -> A @@ -132,8 +107,8 @@ func TestClosedConnection(t *testing.T) { // wait for the connections to establish wg.Wait() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Once() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerB}).Once() + e.On("neighborRemoved", peerA).Once() + e.On("neighborRemoved", peerB).Once() // A drops B err := mgrA.DropNeighbor(peerB.ID()) @@ -141,19 +116,21 @@ func TestClosedConnection(t *testing.T) { time.Sleep(graceTime) // the events should be there even before we close - eventMock.AssertExpectations(t) + e.AssertExpectations(t) } func TestP2PSend(t *testing.T) { - defer assertEvents(t)() + e, detach := newEventMock(t) + defer detach() - mgrA, closeA, peerA := newTest(t, "A") - defer closeA() - mgrB, closeB, peerB := newTest(t, "B") - defer closeB() + mgrA, closeA, peerA := newTestManager(t, "A") + mgrB, closeB, peerB := newTestManager(t, "B") + + connections := 2 + e.On("neighborAdded", mock.Anything).Times(connections) var wg sync.WaitGroup - wg.Add(2) + wg.Add(connections) // connect in the following way // B -> A @@ -172,27 +149,36 @@ func TestP2PSend(t *testing.T) { // wait for the connections to establish wg.Wait() - eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ + e.On("transactionReceived", &TransactionReceivedEvent{ Data: testTxData, Peer: peerA, }).Once() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Once() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerB}).Once() mgrA.SendTransaction(testTxData) time.Sleep(graceTime) + + e.On("neighborRemoved", peerA).Once() + e.On("neighborRemoved", peerB).Once() + + closeA() + closeB() + time.Sleep(graceTime) + + e.AssertExpectations(t) } func TestP2PSendTwice(t *testing.T) { - defer assertEvents(t)() + e, detach := newEventMock(t) + defer detach() - mgrA, closeA, peerA := newTest(t, "A") - defer closeA() - mgrB, closeB, peerB := newTest(t, "B") - defer closeB() + mgrA, closeA, peerA := newTestManager(t, "A") + mgrB, closeB, peerB := newTestManager(t, "B") + + connections := 2 + e.On("neighborAdded", mock.Anything).Times(connections) var wg sync.WaitGroup - wg.Add(2) + wg.Add(connections) // connect in the following way // B -> A @@ -211,31 +197,39 @@ func TestP2PSendTwice(t *testing.T) { // wait for the connections to establish wg.Wait() - eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ + e.On("transactionReceived", &TransactionReceivedEvent{ Data: testTxData, Peer: peerA, }).Twice() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Once() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerB}).Once() mgrA.SendTransaction(testTxData) time.Sleep(1 * time.Second) // wait a bit between the sends, to test timeouts mgrA.SendTransaction(testTxData) time.Sleep(graceTime) + + e.On("neighborRemoved", peerA).Once() + e.On("neighborRemoved", peerB).Once() + + closeA() + closeB() + time.Sleep(graceTime) + + e.AssertExpectations(t) } func TestBroadcast(t *testing.T) { - defer assertEvents(t)() + e, detach := newEventMock(t) + defer detach() - mgrA, closeA, peerA := newTest(t, "A") - defer closeA() - mgrB, closeB, peerB := newTest(t, "B") - defer closeB() - mgrC, closeC, peerC := newTest(t, "C") - defer closeC() + mgrA, closeA, peerA := newTestManager(t, "A") + mgrB, closeB, peerB := newTestManager(t, "B") + mgrC, closeC, peerC := newTestManager(t, "C") + + connections := 4 + e.On("neighborAdded", mock.Anything).Times(connections) var wg sync.WaitGroup - wg.Add(4) + wg.Add(connections) // connect in the following way // B -> A <- C @@ -264,30 +258,39 @@ func TestBroadcast(t *testing.T) { // wait for the connections to establish wg.Wait() - eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ + e.On("transactionReceived", &TransactionReceivedEvent{ Data: testTxData, Peer: peerA, }).Twice() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Twice() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerB}).Once() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerC}).Once() mgrA.SendTransaction(testTxData) time.Sleep(graceTime) + + e.On("neighborRemoved", peerA).Twice() + e.On("neighborRemoved", peerB).Once() + e.On("neighborRemoved", peerC).Once() + + closeA() + closeB() + closeC() + time.Sleep(graceTime) + + e.AssertExpectations(t) } func TestSingleSend(t *testing.T) { - defer assertEvents(t)() + e, detach := newEventMock(t) + defer detach() - mgrA, closeA, peerA := newTest(t, "A") - defer closeA() - mgrB, closeB, peerB := newTest(t, "B") - defer closeB() - mgrC, closeC, peerC := newTest(t, "C") - defer closeC() + mgrA, closeA, peerA := newTestManager(t, "A") + mgrB, closeB, peerB := newTestManager(t, "B") + mgrC, closeC, peerC := newTestManager(t, "C") + + connections := 4 + e.On("neighborAdded", mock.Anything).Times(connections) var wg sync.WaitGroup - wg.Add(4) + wg.Add(connections) // connect in the following way // B -> A <- C @@ -316,45 +319,56 @@ func TestSingleSend(t *testing.T) { // wait for the connections to establish wg.Wait() - eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ + e.On("transactionReceived", &TransactionReceivedEvent{ Data: testTxData, Peer: peerA, }).Once() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Twice() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerB}).Once() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerC}).Once() // A sends the transaction only to B mgrA.SendTransaction(testTxData, peerB.ID()) time.Sleep(graceTime) + + e.On("neighborRemoved", peerA).Twice() + e.On("neighborRemoved", peerB).Once() + e.On("neighborRemoved", peerC).Once() + + closeA() + closeB() + closeC() + time.Sleep(graceTime) + + e.AssertExpectations(t) } func TestDropUnsuccessfulAccept(t *testing.T) { - defer assertEvents(t)() + e, detach := newEventMock(t) + defer detach() - mgrA, closeA, _ := newTest(t, "A") + mgrA, closeA, _ := newTestManager(t, "A") defer closeA() - _, closeB, peerB := newTest(t, "B") + _, closeB, peerB := newTestManager(t, "B") defer closeB() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{ - Peer: peerB, - }).Once() + e.On("connectionFailed", peerB).Once() err := mgrA.AddInbound(peerB) assert.Error(t, err) + + e.AssertExpectations(t) } func TestTxRequest(t *testing.T) { - defer assertEvents(t)() + e, detach := newEventMock(t) + defer detach() - mgrA, closeA, peerA := newTest(t, "A") - defer closeA() - mgrB, closeB, peerB := newTest(t, "B") - defer closeB() + mgrA, closeA, peerA := newTestManager(t, "A") + mgrB, closeB, peerB := newTestManager(t, "B") + + connections := 2 + e.On("neighborAdded", mock.Anything).Times(connections) var wg sync.WaitGroup - wg.Add(2) + wg.Add(connections) // connect in the following way // B -> A @@ -375,15 +389,53 @@ func TestTxRequest(t *testing.T) { txHash := []byte("Hello!") - eventMock.On("transactionReceivedEvent", &TransactionReceivedEvent{ + e.On("transactionReceived", &TransactionReceivedEvent{ Data: testTxData, Peer: peerB, }).Once() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerA}).Once() - eventMock.On("neighborDroppedEvent", &NeighborDroppedEvent{Peer: peerB}).Once() b, err := proto.Marshal(&pb.TransactionRequest{Hash: txHash}) require.NoError(t, err) mgrA.RequestTransaction(b) time.Sleep(graceTime) + + e.On("neighborRemoved", peerA).Once() + e.On("neighborRemoved", peerB).Once() + + closeA() + closeB() + time.Sleep(graceTime) + + e.AssertExpectations(t) } + +func newEventMock(t mock.TestingT) (*eventMock, func()) { + e := &eventMock{} + e.Test(t) + + connectionFailedC := events.NewClosure(e.connectionFailed) + neighborAddedC := events.NewClosure(e.neighborAdded) + neighborRemoved := events.NewClosure(e.neighborRemoved) + transactionReceivedC := events.NewClosure(e.transactionReceived) + + Events.ConnectionFailed.Attach(connectionFailedC) + Events.NeighborAdded.Attach(neighborAddedC) + Events.NeighborRemoved.Attach(neighborRemoved) + Events.TransactionReceived.Attach(transactionReceivedC) + + return e, func() { + Events.ConnectionFailed.Detach(connectionFailedC) + Events.NeighborAdded.Detach(neighborAddedC) + Events.NeighborRemoved.Detach(neighborRemoved) + Events.TransactionReceived.Detach(transactionReceivedC) + } +} + +type eventMock struct { + mock.Mock +} + +func (e *eventMock) connectionFailed(p *peer.Peer) { e.Called(p) } +func (e *eventMock) neighborAdded(n *Neighbor) { e.Called(n) } +func (e *eventMock) neighborRemoved(p *peer.Peer) { e.Called(p) } +func (e *eventMock) transactionReceived(ev *TransactionReceivedEvent) { e.Called(ev) } diff --git a/packages/gossip/neighbor.go b/packages/gossip/neighbor.go new file mode 100644 index 0000000000..178105a497 --- /dev/null +++ b/packages/gossip/neighbor.go @@ -0,0 +1,145 @@ +package gossip + +import ( + "errors" + "io" + "net" + "strings" + "sync" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/network" +) + +var ( + ErrNeighborQueueFull = errors.New("send queue is full") +) + +const neighborQueueSize = 1000 + +type Neighbor struct { + *peer.Peer + *network.ManagedConnection + + log *logger.Logger + queue chan []byte + + wg sync.WaitGroup + closing chan struct{} + disconnectOnce sync.Once +} + +// NewNeighbor creates a new neighbor from the provided peer and connection. +func NewNeighbor(peer *peer.Peer, conn net.Conn, log *logger.Logger) *Neighbor { + if !IsSupported(peer) { + panic("peer does not support gossip") + } + + // always include ID and address with every log message + log = log.With( + "id", peer.ID(), + "network", conn.LocalAddr().Network(), + "addr", conn.RemoteAddr().String(), + ) + + return &Neighbor{ + Peer: peer, + ManagedConnection: network.NewManagedConnection(conn), + log: log, + queue: make(chan []byte, neighborQueueSize), + closing: make(chan struct{}), + } +} + +// Listen starts the communication to the neighbor. +func (n *Neighbor) Listen() { + n.wg.Add(2) + go n.readLoop() + go n.writeLoop() + + n.log.Info("Connection established") +} + +// Close closes the connection to the neighbor and stops all communication. +func (n *Neighbor) Close() error { + err := n.disconnect() + // wait for everything to finish + n.wg.Wait() + + n.log.Infow("Connection closed", + "read", n.BytesRead, + "written", n.BytesWritten, + ) + return err +} + +// IsOutbound returns true if the neighbor is an outbound neighbor. +func (n *Neighbor) IsOutbound() bool { + return GetAddress(n.Peer) == n.Conn.RemoteAddr().String() +} + +func (n *Neighbor) disconnect() (err error) { + n.disconnectOnce.Do(func() { + close(n.closing) + close(n.queue) + err = n.ManagedConnection.Close() + }) + return +} + +func (n *Neighbor) writeLoop() { + defer n.wg.Done() + + for { + select { + case msg := <-n.queue: + if len(msg) == 0 { + continue + } + if _, err := n.ManagedConnection.Write(msg); err != nil { + n.log.Warn("write error", "err", err) + } + case <-n.closing: + return + } + } +} + +func (n *Neighbor) readLoop() { + defer n.wg.Done() + + // create a buffer for the packages + b := make([]byte, maxPacketSize) + + for { + _, err := n.ManagedConnection.Read(b) + if nerr, ok := err.(net.Error); ok && nerr.Temporary() { + // ignore temporary read errors. + n.log.Debugw("temporary read error", "err", err) + continue + } else if err != nil { + // return from the loop on all other errors + if err != io.EOF && !strings.Contains(err.Error(), "use of closed network connection") { + n.log.Warnw("read error", "err", err) + } + _ = n.ManagedConnection.Close() + return + } + } +} + +func (n *Neighbor) Write(b []byte) (int, error) { + l := len(b) + if l > maxPacketSize { + n.log.Errorw("message too large", "len", l, "max", maxPacketSize) + } + + // add to queue + select { + case n.queue <- b: + return l, nil + default: + return 0, ErrNeighborQueueFull + } +} diff --git a/packages/gossip/neighbor_test.go b/packages/gossip/neighbor_test.go new file mode 100644 index 0000000000..3ad65b09f8 --- /dev/null +++ b/packages/gossip/neighbor_test.go @@ -0,0 +1,152 @@ +package gossip + +import ( + "net" + "sync" + "sync/atomic" + "testing" + "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/iotaledger/hive.go/events" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +var testData = []byte("foobar") + +func TestNeighborClose(t *testing.T) { + a, _, teardown := newPipe() + defer teardown() + + n := newTestNeighbor("A", a) + n.Listen() + require.NoError(t, n.Close()) +} + +func TestNeighborCloseTwice(t *testing.T) { + a, _, teardown := newPipe() + defer teardown() + + n := newTestNeighbor("A", a) + n.Listen() + require.NoError(t, n.Close()) + require.NoError(t, n.Close()) +} + +func TestNeighborWriteToClosed(t *testing.T) { + a, _, teardown := newPipe() + defer teardown() + + n := newTestNeighbor("A", a) + n.Listen() + require.NoError(t, n.Close()) + + assert.Panics(t, func() { + _, _ = n.Write(testData) + }) +} + +func TestNeighborWrite(t *testing.T) { + a, b, teardown := newPipe() + defer teardown() + + neighborA := newTestNeighbor("A", a) + defer neighborA.Close() + neighborA.Listen() + + neighborB := newTestNeighbor("B", b) + defer neighborB.Close() + + var count uint32 + neighborB.Events.ReceiveData.Attach(events.NewClosure(func(data []byte) { + assert.Equal(t, testData, data) + atomic.AddUint32(&count, 1) + })) + neighborB.Listen() + + _, err := neighborA.Write(testData) + require.NoError(t, err) + + assert.Eventually(t, func() bool { return atomic.LoadUint32(&count) == 1 }, time.Second, 10*time.Millisecond) +} + +func TestNeighborParallelWrite(t *testing.T) { + a, b, teardown := newPipe() + defer teardown() + + neighborA := newTestNeighbor("A", a) + defer neighborA.Close() + neighborA.Listen() + + neighborB := newTestNeighbor("B", b) + defer neighborB.Close() + + var count uint32 + neighborB.Events.ReceiveData.Attach(events.NewClosure(func(data []byte) { + assert.Equal(t, testData, data) + atomic.AddUint32(&count, 1) + })) + neighborB.Listen() + + var ( + wg sync.WaitGroup + expected uint32 + ) + wg.Add(2) + + // Writer 1 + go func() { + defer wg.Done() + for i := 0; i < neighborQueueSize; i++ { + _, err := neighborA.Write(testData) + if err == ErrNeighborQueueFull { + continue + } + assert.NoError(t, err) + atomic.AddUint32(&expected, 1) + } + }() + // Writer 2 + go func() { + defer wg.Done() + for i := 0; i < neighborQueueSize; i++ { + _, err := neighborA.Write(testData) + if err == ErrNeighborQueueFull { + continue + } + assert.NoError(t, err) + atomic.AddUint32(&expected, 1) + } + }() + + wg.Wait() + + done := func() bool { + actual := atomic.LoadUint32(&count) + return expected == actual + } + assert.Eventually(t, done, time.Second, 10*time.Millisecond) +} + +func newTestNeighbor(name string, conn net.Conn) *Neighbor { + return NewNeighbor(newTestPeer(name, conn.LocalAddr()), conn, log.Named(name)) +} + +func newTestPeer(name string, addr net.Addr) *peer.Peer { + services := service.New() + services.Update(service.PeeringKey, addr.Network(), addr.String()) + services.Update(service.GossipKey, addr.Network(), addr.String()) + + return peer.NewPeer([]byte(name), services) +} + +func newPipe() (net.Conn, net.Conn, func()) { + a, b := net.Pipe() + teardown := func() { + _ = a.Close() + _ = b.Close() + } + return a, b, teardown +} diff --git a/packages/gossip/server/connection.go b/packages/gossip/server/connection.go deleted file mode 100644 index 9c087ecbe4..0000000000 --- a/packages/gossip/server/connection.go +++ /dev/null @@ -1,29 +0,0 @@ -package server - -import ( - "net" - "time" - - "github.com/iotaledger/goshimmer/packages/autopeering/peer" -) - -// Connection represents a network connection to a neighbor peer. -type Connection struct { - net.Conn - peer *peer.Peer -} - -func newConnection(c net.Conn, p *peer.Peer) *Connection { - // make sure the connection has no timeouts - _ = c.SetDeadline(time.Time{}) - - return &Connection{ - Conn: c, - peer: p, - } -} - -// Peer returns the peer associated with that connection. -func (c *Connection) Peer() *peer.Peer { - return c.peer -} diff --git a/packages/gossip/server/server.go b/packages/gossip/server/server.go index ed21025702..ade291bddb 100644 --- a/packages/gossip/server/server.go +++ b/packages/gossip/server/server.go @@ -55,7 +55,7 @@ type TCP struct { // connect contains the result of an incoming connection. type connect struct { - c *Connection + c net.Conn err error } @@ -133,7 +133,7 @@ func (t *TCP) LocalAddr() net.Addr { // DialPeer establishes a gossip connection to the given peer. // If the peer does not accept the connection or the handshake fails, an error is returned. -func (t *TCP) DialPeer(p *peer.Peer) (*Connection, error) { +func (t *TCP) DialPeer(p *peer.Peer) (net.Conn, error) { gossipAddr := p.Services().Get(service.GossipKey) if gossipAddr == nil { return nil, ErrNoGossip @@ -153,12 +153,12 @@ func (t *TCP) DialPeer(p *peer.Peer) (*Connection, error) { "id", p.ID(), "addr", conn.RemoteAddr(), ) - return newConnection(conn, p), nil + return conn, nil } // AcceptPeer awaits an incoming connection from the given peer. // If the peer does not establish the connection or the handshake fails, an error is returned. -func (t *TCP) AcceptPeer(p *peer.Peer) (*Connection, error) { +func (t *TCP) AcceptPeer(p *peer.Peer) (net.Conn, error) { if p.Services().Get(service.GossipKey) == nil { return nil, ErrNoGossip } @@ -273,7 +273,7 @@ func (t *TCP) matchAccept(m *acceptMatcher, req []byte, conn net.Conn) { t.closeConnection(conn) return } - m.connected <- connect{newConnection(conn, m.peer), nil} + m.connected <- connect{conn, nil} } func (t *TCP) listenLoop() { diff --git a/packages/gossip/server/server_test.go b/packages/gossip/server/server_test.go index e7e88d83bc..9aa398fb88 100644 --- a/packages/gossip/server/server_test.go +++ b/packages/gossip/server/server_test.go @@ -1,7 +1,6 @@ package server import ( - "log" "net" "sync" "testing" @@ -9,22 +8,14 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/iotaledger/hive.go/logger" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.uber.org/zap" ) const graceTime = 5 * time.Millisecond -var logger *zap.SugaredLogger - -func init() { - l, err := zap.NewDevelopment() - if err != nil { - log.Fatalf("cannot initialize logger: %v", err) - } - logger = l.Sugar() -} +var log = logger.NewExampleLogger("server") func getTCPAddress(t require.TestingT) string { laddr, err := net.ResolveTCPAddr("tcp", "localhost:0") @@ -39,7 +30,7 @@ func getTCPAddress(t require.TestingT) string { } func newTest(t require.TestingT, name string) (*TCP, func()) { - l := logger.Named(name) + l := log.Named(name) db := peer.NewMemoryDB(l.Named("db")) local, err := peer.NewLocal("peering", name, db) require.NoError(t, err) diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index da2fd92088..dd93e39843 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -2,6 +2,7 @@ package autopeering import ( "github.com/iotaledger/goshimmer/packages/autopeering/discover" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" @@ -27,11 +28,12 @@ func run(*node.Plugin) { } func configureEvents() { - gossip.Events.NeighborDropped.Attach(events.NewClosure(func(ev *gossip.NeighborDroppedEvent) { - log.Info("neighbor dropped: " + ev.Peer.Address() + " / " + ev.Peer.ID().String()) - if Selection != nil { - Selection.DropPeer(ev.Peer) - } + // notify the selection when a connection is closed or failed. + gossip.Events.ConnectionFailed.Attach(events.NewClosure(func(p *peer.Peer) { + Selection.DropPeer(p) + })) + gossip.Events.NeighborRemoved.Attach(events.NewClosure(func(p *peer.Peer) { + Selection.DropPeer(p) })) discover.Events.PeerDiscovered.Attach(events.NewClosure(func(ev *discover.DiscoveredEvent) { diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index aff925c7b9..0c793d5568 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -14,6 +14,7 @@ import ( "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/typeutils" + "github.com/iotaledger/iota.go/trinary" ) var ( @@ -35,7 +36,7 @@ func configureGossip() { log.Fatalf("could not update services: %v", err) } - mgr = gp.NewManager(lPeer, getTransaction, log) + mgr = gp.NewManager(lPeer, loadTransaction, log) } func start(shutdownSignal <-chan struct{}) { @@ -56,7 +57,7 @@ func start(shutdownSignal <-chan struct{}) { log.Info("Stopping Gossip ...") } -func getTransaction(hash []byte) ([]byte, error) { +func loadTransaction(hash []byte) ([]byte, error) { log.Infof("Retrieving tx: hash=%s", hash) tx, err := tangle.GetTransaction(typeutils.BytesToString(hash)) @@ -68,3 +69,11 @@ func getTransaction(hash []byte) ([]byte, error) { } return tx.GetBytes(), nil } + +func requestTransaction(hash trinary.Hash) { + if contains, _ := tangle.ContainsTransaction(hash); contains { + // Do not request tx that we already know + return + } + mgr.RequestTransaction(typeutils.StringToBytes(hash)) +} diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 774364674f..0a4f61e4b8 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -1,7 +1,7 @@ package gossip import ( - "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/selection" "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/value_transaction" @@ -10,7 +10,6 @@ import ( "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" - "github.com/iotaledger/hive.go/typeutils" ) const name = "Gossip" // name of the plugin @@ -32,33 +31,37 @@ func run(*node.Plugin) { func configureEvents() { selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) { - log.Info("neighbor removed: " + ev.DroppedID.String()) - go mgr.DropNeighbor(ev.DroppedID) + go func() { + if err := mgr.DropNeighbor(ev.DroppedID); err != nil { + log.Debugw("error dropping neighbor", "id", ev.DroppedID, "err", err) + } + }() })) - selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { - gossipService := ev.Peer.Services().Get(service.GossipKey) - if gossipService != nil { - log.Info("accepted neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - go mgr.AddInbound(ev.Peer) - } + go func() { + if err := mgr.AddInbound(ev.Peer); err != nil { + log.Debugw("error adding inbound", "id", ev.Peer.ID(), "err", err) + } + }() })) - selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { - gossipService := ev.Peer.Services().Get(service.GossipKey) - if gossipService != nil { - log.Info("chosen neighbor added: " + ev.Peer.Address() + " / " + ev.Peer.String()) - go mgr.AddOutbound(ev.Peer) - } + go func() { + if err := mgr.AddOutbound(ev.Peer); err != nil { + log.Debugw("error adding outbound", "id", ev.Peer.ID(), "err", err) + } + }() })) - tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { - log.Debugf("gossip solid tx: hash=%s", tx.GetHash()) - go mgr.SendTransaction(tx.GetBytes()) + gossip.Events.NeighborAdded.Attach(events.NewClosure(func(n *gossip.Neighbor) { + log.Infof("Neighbor added: %s / %s", gossip.GetAddress(n.Peer), n.ID()) + })) + gossip.Events.NeighborRemoved.Attach(events.NewClosure(func(p *peer.Peer) { + log.Infof("Neighbor removed: %s / %s", gossip.GetAddress(p), p.ID()) })) - gossip.Events.RequestTransaction.Attach(events.NewClosure(func(ev *gossip.RequestTransactionEvent) { - log.Debugf("gossip tx request: hash=%s", ev.Hash) - go mgr.RequestTransaction(typeutils.StringToBytes(ev.Hash)) + // gossip transactions on solidification + tangle.Events.TransactionSolid.Attach(events.NewClosure(func(tx *value_transaction.ValueTransaction) { + mgr.SendTransaction(tx.GetBytes()) })) + tangle.SetRequester(tangle.RequesterFunc(requestTransaction)) } diff --git a/plugins/statusscreen/plugin.go b/plugins/statusscreen/plugin.go index 544e190041..f79ca05ebf 100644 --- a/plugins/statusscreen/plugin.go +++ b/plugins/statusscreen/plugin.go @@ -44,7 +44,7 @@ func run(*node.Plugin) { } stopped := make(chan struct{}) - err := daemon.BackgroundWorker(name+" Refresher", func(shutdown <-chan struct{}) { + if err := daemon.BackgroundWorker(name+" Refresher", func(shutdown <-chan struct{}) { for { select { case <-time.After(repaintInterval): @@ -57,13 +57,12 @@ func run(*node.Plugin) { return } } - }) - if err != nil { + }); err != nil { log.Errorf("Failed to start as daemon: %s", err) return } - err = daemon.BackgroundWorker(name+" App", func(<-chan struct{}) { + if err := daemon.BackgroundWorker(name+" App", func(<-chan struct{}) { defer close(stopped) // switch logging to status screen @@ -73,8 +72,7 @@ func run(*node.Plugin) { if err := app.SetRoot(frame, true).SetFocus(frame).Run(); err != nil { log.Errorf("Error running application: %s", err) } - }) - if err != nil { + }); err != nil { log.Errorf("Failed to start as daemon: %s", err) close(stopped) } diff --git a/plugins/tangle/events.go b/plugins/tangle/events.go index 3cc90ba431..2a89c7248a 100644 --- a/plugins/tangle/events.go +++ b/plugins/tangle/events.go @@ -5,14 +5,12 @@ import ( "github.com/iotaledger/hive.go/events" ) -var Events = pluginEvents{ - TransactionStored: events.NewEvent(transactionCaller), - TransactionSolid: events.NewEvent(transactionCaller), -} - -type pluginEvents struct { +var Events = struct { TransactionStored *events.Event TransactionSolid *events.Event +}{ + TransactionStored: events.NewEvent(transactionCaller), + TransactionSolid: events.NewEvent(transactionCaller), } func transactionCaller(handler interface{}, params ...interface{}) { diff --git a/plugins/tangle/plugin.go b/plugins/tangle/plugin.go index 6684986c55..50cbafaa0c 100644 --- a/plugins/tangle/plugin.go +++ b/plugins/tangle/plugin.go @@ -3,6 +3,7 @@ package tangle import ( "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/iota.go/trinary" ) // region plugin module setup ////////////////////////////////////////////////////////////////////////////////////////// @@ -24,4 +25,13 @@ func run(*node.Plugin) { runSolidifier() } +// Requester provides the functionality to request a transaction from the network. +type Requester interface { + RequestTransaction(hash trinary.Hash) +} + +type RequesterFunc func(hash trinary.Hash) + +func (f RequesterFunc) RequestTransaction(hash trinary.Hash) { f(hash) } + // endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index e30ae82e9a..4b3dd663e5 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -21,16 +21,23 @@ import ( const UnsolidInterval = 30 var ( - workerPool *workerpool.WorkerPool - unsolidTxs *UnsolidTxs + workerCount = runtime.NumCPU() + workerPool *workerpool.WorkerPool + unsolidTxs *UnsolidTxs + + requester Requester ) +func SetRequester(req Requester) { + requester = req +} + func configureSolidifier() { workerPool = workerpool.New(func(task workerpool.Task) { processMetaTransaction(task.Param(0).(*meta_transaction.MetaTransaction)) task.Return(nil) - }, workerpool.WorkerCount(WORKER_COUNT), workerpool.QueueSize(10000)) + }, workerpool.WorkerCount(workerCount), workerpool.QueueSize(10000)) unsolidTxs = NewUnsolidTxs() @@ -221,8 +228,10 @@ func updateUnsolidTxs(tx *value_transaction.ValueTransaction) { } func requestTransaction(hash trinary.Trytes) { - log.Infof("Requesting hash: hash=%s", hash) - gossip.Events.RequestTransaction.Trigger(&gossip.RequestTransactionEvent{Hash: hash}) -} + if requester == nil { + return + } -var WORKER_COUNT = runtime.NumCPU() + log.Infow("Requesting tx", "hash", hash) + requester.RequestTransaction(hash) +} diff --git a/plugins/tangle/solidifier_test.go b/plugins/tangle/solidifier_test.go index e93cfdce6f..14573d43de 100644 --- a/plugins/tangle/solidifier_test.go +++ b/plugins/tangle/solidifier_test.go @@ -11,23 +11,20 @@ import ( "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" - "github.com/spf13/viper" + "github.com/iotaledger/iota.go/trinary" "github.com/stretchr/testify/require" ) func init() { - err := parameter.LoadDefaultConfig(false) - if err != nil { + if err := parameter.LoadDefaultConfig(false); err != nil { + log.Fatalf("Failed to initialize config: %s", err) + } + if err := logger.InitGlobalLogger(parameter.NodeConfig); err != nil { log.Fatalf("Failed to initialize config: %s", err) } - - logger.InitGlobalLogger(&viper.Viper{}) } func TestSolidifier(t *testing.T) { - // show all error messages for tests - // TODO: adjust logger package - // start a test node node.Start(node.Plugins(PLUGIN)) @@ -54,12 +51,12 @@ func TestSolidifier(t *testing.T) { // setup event handlers var wg sync.WaitGroup Events.TransactionSolid.Attach(events.NewClosure(func(transaction *value_transaction.ValueTransaction) { - t.Log("Tx solidified", transaction.GetValue()) wg.Done() })) - gossip.Events.RequestTransaction.Attach(events.NewClosure(func(ev *gossip.RequestTransactionEvent) { - require.Equal(t, transaction3.GetHash(), ev.Hash) + // only transaction3 should be requested + SetRequester(RequesterFunc(func(hash trinary.Hash) { + require.Equal(t, transaction3.GetHash(), hash) // return the transaction data gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: transaction3.GetBytes()}) })) @@ -77,5 +74,4 @@ func TestSolidifier(t *testing.T) { // shutdown test node node.Shutdown() - } diff --git a/plugins/webapi/routes.go b/plugins/webapi/routes.go deleted file mode 100644 index 2f5e375418..0000000000 --- a/plugins/webapi/routes.go +++ /dev/null @@ -1,9 +0,0 @@ -package webapi - -import ( - "github.com/labstack/echo" -) - -func setupRoutes(e *echo.Echo) { - -} From 2d72324b12a6d78175989f25050aadc465fe8fb0 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Fri, 10 Jan 2020 10:49:24 +0100 Subject: [PATCH 090/184] feat: improve logging --- packages/autopeering/discover/manager.go | 15 +++++++------ packages/autopeering/peer/peer.go | 3 ++- plugins/analysis/client/plugin.go | 10 ++++----- plugins/autopeering/autopeering.go | 2 +- plugins/autopeering/local/local.go | 27 ++++++++++++++++++------ plugins/autopeering/plugin.go | 16 +++++++++++++- plugins/cli/plugin.go | 4 ++-- 7 files changed, 53 insertions(+), 24 deletions(-) diff --git a/packages/autopeering/discover/manager.go b/packages/autopeering/discover/manager.go index 33e41c788d..d7697aede7 100644 --- a/packages/autopeering/discover/manager.go +++ b/packages/autopeering/discover/manager.go @@ -202,8 +202,8 @@ func (m *manager) peerToReverify() *mpeer { } // updatePeer moves the peer with the given ID to the front of the list of managed peers. -// It returns true if a peer was bumped or false if there was no peer with that id -func (m *manager) updatePeer(update *peer.Peer) bool { +// It returns 0 if there was no peer with that id, otherwise the verifiedCount of the updated peer is returned. +func (m *manager) updatePeer(update *peer.Peer) uint { id := update.ID() for i, p := range m.active { if p.ID() == id { @@ -217,11 +217,10 @@ func (m *manager) updatePeer(update *peer.Peer) bool { verifiedCount: p.verifiedCount + 1, lastNewPeers: p.lastNewPeers, } - - return true + return p.verifiedCount + 1 } } - return false + return 0 } func (m *manager) addReplacement(p *mpeer) bool { @@ -289,7 +288,11 @@ func (m *manager) addVerifiedPeer(p *peer.Peer) bool { defer m.mutex.Unlock() // if already in the list, move it to the front - if m.updatePeer(p) { + if v := m.updatePeer(p); v > 0 { + // trigger the event only for the first time the peer is updated + if v == 1 { + Events.PeerDiscovered.Trigger(&DiscoveredEvent{Peer: p}) + } return false } diff --git a/packages/autopeering/peer/peer.go b/packages/autopeering/peer/peer.go index c7200dd1bb..30a1882f2f 100644 --- a/packages/autopeering/peer/peer.go +++ b/packages/autopeering/peer/peer.go @@ -2,6 +2,7 @@ package peer import ( "crypto/ed25519" + "encoding/base64" "errors" "fmt" "net/url" @@ -50,7 +51,7 @@ func (p *Peer) Services() service.Service { func (p *Peer) String() string { u := url.URL{ Scheme: "peer", - User: url.User(fmt.Sprintf("%x", p.publicKey)), + User: url.User(base64.StdEncoding.EncodeToString(p.PublicKey())), Host: p.Address(), } return u.String() diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index da700fadea..506982347c 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -1,7 +1,6 @@ package client import ( - "encoding/hex" "net" "time" @@ -57,15 +56,19 @@ func Run(plugin *node.Plugin) { func getEventDispatchers(conn *network.ManagedConnection) *EventDispatchers { return &EventDispatchers{ AddNode: func(nodeId []byte) { + log.Debugw("AddNode", "nodeId", nodeId) _, _ = conn.Write((&addnode.Packet{NodeId: nodeId}).Marshal()) }, RemoveNode: func(nodeId []byte) { + log.Debugw("RemoveNode", "nodeId", nodeId) _, _ = conn.Write((&removenode.Packet{NodeId: nodeId}).Marshal()) }, ConnectNodes: func(sourceId []byte, targetId []byte) { + log.Debugw("ConnectNodes", "sourceId", sourceId, "targetId", targetId) _, _ = conn.Write((&connectnodes.Packet{SourceId: sourceId, TargetId: targetId}).Marshal()) }, DisconnectNodes: func(sourceId []byte, targetId []byte) { + log.Debugw("DisconnectNodes", "sourceId", sourceId, "targetId", targetId) _, _ = conn.Write((&disconnectnodes.Packet{SourceId: sourceId, TargetId: targetId}).Marshal()) }, } @@ -83,27 +86,22 @@ func setupHooks(plugin *node.Plugin, conn *network.ManagedConnection, eventDispa // define hooks //////////////////////////////////////////////////////////////////////////////////////////////////// onDiscoverPeer := events.NewClosure(func(ev *discover.DiscoveredEvent) { - log.Info("onDiscoverPeer: " + hex.EncodeToString(ev.Peer.ID().Bytes())) eventDispatchers.AddNode(ev.Peer.ID().Bytes()) }) onDeletePeer := events.NewClosure(func(ev *discover.DeletedEvent) { - log.Info("onDeletePeer: " + hex.EncodeToString(ev.Peer.ID().Bytes())) eventDispatchers.RemoveNode(ev.Peer.ID().Bytes()) }) onAddAcceptedNeighbor := events.NewClosure(func(ev *selection.PeeringEvent) { - log.Info("onAddAcceptedNeighbor: " + hex.EncodeToString(ev.Peer.ID().Bytes()) + " - " + hex.EncodeToString(local.GetInstance().ID().Bytes())) eventDispatchers.ConnectNodes(ev.Peer.ID().Bytes(), local.GetInstance().ID().Bytes()) }) onRemoveNeighbor := events.NewClosure(func(ev *selection.DroppedEvent) { - log.Info("onRemoveNeighbor: " + hex.EncodeToString(ev.DroppedID.Bytes()) + " - " + hex.EncodeToString(local.GetInstance().ID().Bytes())) eventDispatchers.DisconnectNodes(ev.DroppedID.Bytes(), local.GetInstance().ID().Bytes()) }) onAddChosenNeighbor := events.NewClosure(func(ev *selection.PeeringEvent) { - log.Info("onAddChosenNeighbor: " + hex.EncodeToString(local.GetInstance().ID().Bytes()) + " - " + hex.EncodeToString(ev.Peer.ID().Bytes())) eventDispatchers.ConnectNodes(local.GetInstance().ID().Bytes(), ev.Peer.ID().Bytes()) }) diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 4d70e09eae..59d3588023 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -96,7 +96,7 @@ func start(shutdownSignal <-chan struct{}) { defer Selection.Close() } - log.Infof("Auto Peering server started: ID=%x, address=%s", local.GetInstance().ID(), srv.LocalAddr()) + log.Infof("Auto Peering started: address=%s", srv.LocalAddr()) <-shutdownSignal log.Info("Stopping Auto Peering server ...") diff --git a/plugins/autopeering/local/local.go b/plugins/autopeering/local/local.go index cfafcb89f9..71e358c0f9 100644 --- a/plugins/autopeering/local/local.go +++ b/plugins/autopeering/local/local.go @@ -3,7 +3,6 @@ package local import ( "fmt" "io/ioutil" - "log" "net" "net/http" "strconv" @@ -20,33 +19,47 @@ var ( ) func configureLocal() *peer.Local { + log := logger.NewLogger("Local") + ip := net.ParseIP(parameter.NodeConfig.GetString(CFG_ADDRESS)) if ip == nil { log.Fatalf("Invalid IP address: %s", parameter.NodeConfig.GetString(CFG_ADDRESS)) } if ip.IsUnspecified() { - myIp, err := getMyIP() + log.Info("Querying public IP ...") + myIp, err := getPublicIP(isIPv4(ip)) if err != nil { - log.Fatalf("Could not query public IP: %v", err) + log.Fatalf("Error querying public IP: %s", err) } ip = myIp + log.Infof("Public IP queried: address=%s", ip.String()) } port := strconv.Itoa(parameter.NodeConfig.GetInt(CFG_PORT)) // create a new local node - db := peer.NewPersistentDB(logger.NewLogger("local")) + db := peer.NewPersistentDB(log) local, err := peer.NewLocal("udp", net.JoinHostPort(ip.String(), port), db) if err != nil { - log.Fatalf("NewLocal: %v", err) + log.Fatalf("Error creating local: %s", err) } + log.Infof("Initialized local: %v", local) return local } -func getMyIP() (net.IP, error) { - url := "https://api.ipify.org?format=text" +func isIPv4(ip net.IP) bool { + return ip.To4() != nil +} + +func getPublicIP(ipv4 bool) (net.IP, error) { + var url string + if ipv4 { + url = "https://api.ipify.org" + } else { + url = "https://api6.ipify.org" + } resp, err := http.Get(url) if err != nil { return nil, err diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index dd93e39843..04321f98b2 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -3,6 +3,7 @@ package autopeering import ( "github.com/iotaledger/goshimmer/packages/autopeering/discover" "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/selection" "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" @@ -37,6 +38,19 @@ func configureEvents() { })) discover.Events.PeerDiscovered.Attach(events.NewClosure(func(ev *discover.DiscoveredEvent) { - log.Info("new peer discovered: " + ev.Peer.Address() + " / " + ev.Peer.ID().String()) + log.Infof("Discovered: %s / %s", ev.Peer.Address(), ev.Peer.ID()) + })) + discover.Events.PeerDeleted.Attach(events.NewClosure(func(ev *discover.DeletedEvent) { + log.Infof("Removed offline: %s / %s", ev.Peer.Address(), ev.Peer.ID()) + })) + + selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { + log.Infof("Peering chosen: %s / %s", ev.Peer.Address(), ev.Peer.ID()) + })) + selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { + log.Infof("Peering accepted: %s / %s", ev.Peer.Address(), ev.Peer.ID()) + })) + selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) { + log.Infof("Peering dropped: %s", ev.DroppedID) })) } diff --git a/plugins/cli/plugin.go b/plugins/cli/plugin.go index 39791c7c52..b18b78b37e 100644 --- a/plugins/cli/plugin.go +++ b/plugins/cli/plugin.go @@ -45,7 +45,7 @@ func parseParameters() { } func LoadConfig() { - if err := parameter.FetchConfig(true); err != nil { + if err := parameter.FetchConfig(false); err != nil { panic(err) } parseParameters() @@ -56,7 +56,6 @@ func LoadConfig() { } func configure(ctx *node.Plugin) { - fmt.Println(" _____ _ _ ________ ______ ___ ___________ ") fmt.Println(" / ___| | | |_ _| \\/ || \\/ || ___| ___ \\") fmt.Println(" \\ `--.| |_| | | | | . . || . . || |__ | |_/ /") @@ -64,6 +63,7 @@ func configure(ctx *node.Plugin) { fmt.Println(" /\\__/ / | | |_| |_| | | || | | || |___| |\\ \\ ") fmt.Printf(" \\____/\\_| |_/\\___/\\_| |_/\\_| |_/\\____/\\_| \\_| fullnode %s", AppVersion) fmt.Println() + fmt.Println() ctx.Node.Logger.Info("Loading plugins ...") } From 7f32bff75dd000a6469fcee5cdc1107f433e5a55 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Fri, 10 Jan 2020 14:56:25 +0100 Subject: [PATCH 091/184] ports glumb plugin from Hornet to GoShimmer --- config.json | 52 +++++++------ go.mod | 2 + go.sum | 107 +++++++++++++++++++++++++++ main.go | 4 + plugins/graph/README.md | 9 +++ plugins/graph/graph.go | 144 ++++++++++++++++++++++++++++++++++++ plugins/graph/parameters.go | 26 +++++++ plugins/graph/plugin.go | 132 +++++++++++++++++++++++++++++++++ 8 files changed, 454 insertions(+), 22 deletions(-) create mode 100644 plugins/graph/README.md create mode 100644 plugins/graph/graph.go create mode 100644 plugins/graph/parameters.go create mode 100644 plugins/graph/plugin.go diff --git a/config.json b/config.json index 8550f6286b..2e956d2032 100644 --- a/config.json +++ b/config.json @@ -1,34 +1,42 @@ { - "analysis":{ - "serveraddress":"ressims.iota.cafe:188", - "serverport":0 + "analysis": { + "serveraddress": "ressims.iota.cafe:188", + "serverport": 0 }, - "autopeering":{ - "address":"0.0.0.0", - "entrynodes":[ + "autopeering": { + "address": "0.0.0.0", + "entrynodes": [ "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626" ], - "port":14626, - "selection":true + "port": 14626, + "selection": true }, - "database":{ - "directory":"mainnetdb" + "database": { + "directory": "mainnetdb" }, - "gossip":{ - "port":14666 + "gossip": { + "port": 14666 }, - "logger":{ - "Level":"info", - "DisableCaller":false, - "DisableStacktrace":false, - "Encoding":"console", - "OutputPaths":[ + "graph": { + "webrootPath": "./IOTAtangle/webroot", + "socketioPath": "./socket.io-client/dist/socket.io.js", + "domain": "", + "host": "127.0.0.1", + "port": 8083, + "networkName": "GoShimmer" + }, + "logger": { + "Level": "info", + "DisableCaller": false, + "DisableStacktrace": false, + "Encoding": "console", + "OutputPaths": [ "shimmer.log" ] }, - "node":{ - "disableplugins":"", - "enableplugins":"", - "loglevel":0 + "node": { + "disableplugins": "", + "enableplugins": [], + "loglevel": 0 } } \ No newline at end of file diff --git a/go.mod b/go.mod index ffdc776252..8fb5568896 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,8 @@ require ( github.com/gdamore/tcell v1.3.0 github.com/go-zeromq/zmq4 v0.7.0 github.com/golang/protobuf v1.3.2 + github.com/googollee/go-engine.io v1.4.3-0.20190924125625-798118fc0dd2 + github.com/googollee/go-socket.io v1.4.3-0.20191204093753-683f8725b6d0 github.com/gorilla/websocket v1.4.1 github.com/iotaledger/hive.go v0.0.0-20200109143501-f876e7457f15 github.com/iotaledger/iota.go v1.0.0-beta.13 diff --git a/go.sum b/go.sum index 1a4c5f51d7..9776749839 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,11 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.31.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.36.0/go.mod h1:RUoy9p/M4ge0HzT8L+SDZ8jg+Q6fth0CiBuhFJpSV40= +dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU= +dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU= +dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= +dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= +git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M= github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= @@ -9,16 +16,19 @@ github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= @@ -39,6 +49,7 @@ github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b/go.mod h1:SqUrOPUn github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= @@ -46,6 +57,7 @@ github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo github.com/gdamore/tcell v1.3.0 h1:r35w0JBADPZCVQijYebl6YMWWtHRqVEGt7kL2eBADRM= github.com/gdamore/tcell v1.3.0/go.mod h1:Hjvr+Ofd+gLglo7RYKxxnzCBmev3BzsS67MebKS4zMM= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= @@ -58,24 +70,44 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= +github.com/golang/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51 h1:OdVal38kmXn0U3M3CYmPF4cpMLLvD4ioshwrooNfmxs= github.com/google/open-location-code/go v0.0.0-20190903173953-119bc96a3a51/go.mod h1:eJfRN6aj+kR/rnua/rw9jAgYhqoMHldQkdTi+sePRKk= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= +github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= +github.com/googollee/go-engine.io v1.4.1 h1:m3WlZAug1SODuWT++UX2nbzk9IUCn9T1SnmHoqppdqo= +github.com/googollee/go-engine.io v1.4.1/go.mod h1:26oFqHsnuWIzNOM0T08x21eQOydBosKOCgK3tyhzPPI= +github.com/googollee/go-engine.io v1.4.3-0.20190924125625-798118fc0dd2 h1:6LbNP1ft0muA4LgoPMvwbxFpVhsRAGimY0Rp+4L7Q1M= +github.com/googollee/go-engine.io v1.4.3-0.20190924125625-798118fc0dd2/go.mod h1:iaugrHMOoal16IKAWvH6y6RrXXIzfOULxjNwvXBCV4o= +github.com/googollee/go-socket.io v1.4.3-0.20191204093753-683f8725b6d0 h1:7yrvhLv25w1vtVKrcg8CZAn4Pnkb6pzCAqnZ5y9O4q8= +github.com/googollee/go-socket.io v1.4.3-0.20191204093753-683f8725b6d0/go.mod h1:yjlQxKcAZXZjpGwQVW/y1sgyL1ou+DdCpkswURDCRrU= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gordonklaus/ineffassign v0.0.0-20180909121442-1003c8bd00dc/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= @@ -88,6 +120,7 @@ github.com/iotaledger/hive.go v0.0.0-20200109143501-f876e7457f15/go.mod h1:obs07 github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/iotaledger/iota.go v1.0.0-beta.13 h1:6m6JRcKtjTflU2PbjvDA9Tv6NTEJX1PijBDOkH9weQc= github.com/iotaledger/iota.go v1.0.0-beta.13/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= +github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -99,6 +132,7 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/labstack/echo v3.3.10+incompatible h1:pGRcYk231ExFAyoAjAfD85kQzRJCRI8bbnE7CX5OEgg= @@ -122,17 +156,21 @@ github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp github.com/mattn/go-runewidth v0.0.7 h1:Ei8KR0497xHyKJPAv59M1dkC+rOZCMBJ+t3fZ+twI54= github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms= +github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= +github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.5.0 h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/panjf2000/ants/v2 v2.2.2/go.mod h1:1GFm8bV8nyCQvU5K4WvBCTG1/YBFOD2VzjffD8fV55A= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.6.0 h1:aetoXYr0Tv7xRU/V4B4IZJ2QcbtMUFoNb3ORp7TzIK4= @@ -144,12 +182,15 @@ github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= @@ -162,6 +203,29 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/sasha-s/go-deadlock v0.2.0 h1:lMqc+fUb7RrFS3gQLtoQsJ7/6TV/pAIFvBsqX73DK8Y= github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= +github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= +github.com/shurcooL/github_flavored_markdown v0.0.0-20181002035957-2122de532470/go.mod h1:2dOwnU2uBioM+SGy2aZoq1f/Sd1l9OkAeAUvjSyvgU0= +github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= +github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= +github.com/shurcooL/gofontwoff v0.0.0-20180329035133-29b52fc0a18d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw= +github.com/shurcooL/gopherjslib v0.0.0-20160914041154-feb6d3990c2c/go.mod h1:8d3azKNyqcHP1GaQE/c6dDgjkgSx2BZ4IoEi4F1reUI= +github.com/shurcooL/highlight_diff v0.0.0-20170515013008-09bb4053de1b/go.mod h1:ZpfEhSmds4ytuByIcDnOLkTHGUI6KNqRNPDLHDk+mUU= +github.com/shurcooL/highlight_go v0.0.0-20181028180052-98c3abbbae20/go.mod h1:UDKB5a1T23gOMUJrI+uSuH0VRDStOiUVSjBTRDVBVag= +github.com/shurcooL/home v0.0.0-20181020052607-80b7ffcb30f9/go.mod h1:+rgNQw2P9ARFAs37qieuu7ohDNQ3gds9msbT2yn85sg= +github.com/shurcooL/htmlg v0.0.0-20170918183704-d01228ac9e50/go.mod h1:zPn1wHpTIePGnXSHpsVPWEktKXHr6+SS6x/IKRb7cpw= +github.com/shurcooL/httperror v0.0.0-20170206035902-86b7830d14cc/go.mod h1:aYMfkZ6DWSJPJ6c4Wwz3QtW22G7mf/PEgaB9k/ik5+Y= +github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= +github.com/shurcooL/httpgzip v0.0.0-20180522190206-b1c53ac65af9/go.mod h1:919LwcH0M7/W4fcZ0/jy0qGght1GIhqyS/EgWGH2j5Q= +github.com/shurcooL/issues v0.0.0-20181008053335-6292fdc1e191/go.mod h1:e2qWDig5bLteJ4fwvDAc2NHzqFEthkqn7aOZAOpj+PQ= +github.com/shurcooL/issuesapp v0.0.0-20180602232740-048589ce2241/go.mod h1:NPpHK2TI7iSaM0buivtFUc9offApnI0Alt/K8hcHy0I= +github.com/shurcooL/notifications v0.0.0-20181007000457-627ab5aea122/go.mod h1:b5uSkrEVM1jQUspwbixRBhaIjIzL2xazXp6kntxYle0= +github.com/shurcooL/octicon v0.0.0-20181028054416-fa4f57f9efb2/go.mod h1:eWdoE5JD4R5UVWDucdOPg1g2fqQRq78IQa9zlOV1vpQ= +github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1lToEk4d2s07G3XGfz2QrgHXg4RJBvjrOozvoWfk= +github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= +github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= github.com/simia-tech/env v0.1.0/go.mod h1:eVRQ7W5NXXHifpPAcTJ3r5EmoGgMn++dXfSVbZv3Opo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= @@ -169,6 +233,8 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1 github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE= +github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= @@ -198,6 +264,7 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= @@ -213,6 +280,7 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.mongodb.org/mongo-driver v1.0.0/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.5.1 h1:rsqfU5vBkVknbhUGbAUwQKR2H4ItV8tjJ+6kJX4cxHM= @@ -226,14 +294,20 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0 h1:nR6NoDBgAf67s68NhaXbsojM+2gxp3S1hWkHDl27pVU= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= +golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 h1:sKJQZMuxjOAR/Uo2LBfU90onWEf1dF4C+0hPJCc9Mpc= golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= @@ -241,10 +315,14 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f h1:J5lckAjkw6qYlOZNj90mLYNT golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181029044818-c44066c5c816/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= @@ -252,6 +330,9 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -261,6 +342,7 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -276,12 +358,18 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 h1:JA8d3MPx/IToSyXZG/RhwYEtfrKO1Fxrqe8KrkiLXKM= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190214204934-8dcb7bc8c7fe/go.mod h1:E6PF97AdD6v0s+fPshSmumCW1S1Ne85RbPQxELkKa44= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= @@ -294,8 +382,21 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= +google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= +google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= +google.golang.org/genproto v0.0.0-20190201180003-4b09977fb922/go.mod h1:L3J43x8/uS+qIUoksaLKe6OS3nUKxOKuIFz1sl2/jx4= +google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= +google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= @@ -308,6 +409,7 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/h2non/gock.v1 v1.0.14/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.51.1 h1:GyboHr4UqMiLUybYjd22ZjQIKEJEpgtLXtuGbR21Oho= gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= @@ -320,6 +422,11 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= +sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= diff --git a/main.go b/main.go index 64789962bb..14c100a854 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,7 @@ import ( "github.com/iotaledger/goshimmer/plugins/dashboard" "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/goshimmer/plugins/gracefulshutdown" + "github.com/iotaledger/goshimmer/plugins/graph" "github.com/iotaledger/goshimmer/plugins/metrics" "github.com/iotaledger/goshimmer/plugins/statusscreen" statusscreen_tps "github.com/iotaledger/goshimmer/plugins/statusscreen-tps" @@ -54,9 +55,12 @@ func main() { webapi_spammer.PLUGIN, webapi_send_data.PLUGIN, webapi_tx_request.PLUGIN, + webapi_spammer.PLUGIN, ui.PLUGIN, webauth.PLUGIN, + + graph.PLUGIN, ), ) } diff --git a/plugins/graph/README.md b/plugins/graph/README.md new file mode 100644 index 0000000000..da7c4ca792 --- /dev/null +++ b/plugins/graph/README.md @@ -0,0 +1,9 @@ +# How to install this plugin +- Run the following commands in this folder (or set `graph.socketioPath` and `graph.webrootPath` in your config if you want to use another path) + +```bash +git clone https://github.com/glumb/IOTAtangle.git +cd IOTAtangle && git reset --hard 07bba77a296a2d06277cdae56aa963abeeb5f66e +cd ../ +git clone https://github.com/socketio/socket.io-client.git +``` \ No newline at end of file diff --git a/plugins/graph/graph.go b/plugins/graph/graph.go new file mode 100644 index 0000000000..6b5442e80a --- /dev/null +++ b/plugins/graph/graph.go @@ -0,0 +1,144 @@ +package graph + +import ( + "container/ring" + "fmt" + "strconv" + "strings" + + socketio "github.com/googollee/go-socket.io" + "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/parameter" + "github.com/iotaledger/iota.go/consts" + + "github.com/iotaledger/hive.go/syncutils" +) + +const ( + TX_BUFFER_SIZE = 1800 +) + +var ( + txRingBuffer *ring.Ring // transactions + snRingBuffer *ring.Ring // confirmed transactions + msRingBuffer *ring.Ring // Milestones + + broadcastLock = syncutils.Mutex{} + txRingBufferLock = syncutils.Mutex{} +) + +type wsTransaction struct { + Hash string `json:"hash"` + Address string `json:"address"` + Value string `json:"value"` + Tag string `json:"tag"` + Timestamp string `json:"timestamp"` + CurrentIndex string `json:"current_index"` + LastIndex string `json:"last_index"` + Bundle string `json:"bundle_hash"` + TrunkTransaction string `json:"transaction_trunk"` + BranchTransaction string `json:"transaction_branch"` +} + +type wsTransactionSn struct { + Hash string `json:"hash"` + Address string `json:"address"` + TrunkTransaction string `json:"transaction_trunk"` + BranchTransaction string `json:"transaction_branch"` + Bundle string `json:"bundle"` +} + +type wsConfig struct { + NetworkName string `json:"networkName"` +} + +func initRingBuffers() { + txRingBuffer = ring.New(TX_BUFFER_SIZE) + snRingBuffer = ring.New(TX_BUFFER_SIZE) + msRingBuffer = ring.New(20) +} + +func onConnectHandler(s socketio.Conn) error { + infoMsg := "Graph client connection established" + if s != nil { + infoMsg = fmt.Sprintf("%s (ID: %v)", infoMsg, s.ID()) + } + log.Info(infoMsg) + socketioServer.JoinRoom("broadcast", s) + + config := &wsConfig{NetworkName: parameter.NodeConfig.GetString("graph.networkName")} + + var initTxs []*wsTransaction + txRingBuffer.Do(func(tx interface{}) { + if tx != nil { + initTxs = append(initTxs, tx.(*wsTransaction)) + } + }) + + var initSns []*wsTransactionSn + snRingBuffer.Do(func(sn interface{}) { + if sn != nil { + initSns = append(initSns, sn.(*wsTransactionSn)) + } + }) + + var initMs []string + msRingBuffer.Do(func(ms interface{}) { + if ms != nil { + initMs = append(initMs, ms.(string)) + } + }) + + s.Emit("config", config) + s.Emit("inittx", initTxs) + s.Emit("initsn", initSns) + s.Emit("initms", initMs) + s.Emit("donation", "0") + s.Emit("donations", []int{}) + s.Emit("donation-address", "-") + + return nil +} + +func onErrorHandler(conn socketio.Conn, e error) { + errorMsg := "Graph meet error" + if e != nil { + errorMsg = fmt.Sprintf("%s: %s", errorMsg, e.Error()) + } + log.Error(errorMsg) +} + +func onDisconnectHandler(s socketio.Conn, msg string) { + infoMsg := "Graph client connection closed" + if s != nil { + infoMsg = fmt.Sprintf("%s (ID: %v)", infoMsg, s.ID()) + } + log.Info(fmt.Sprintf("%s: %s", infoMsg, msg)) + socketioServer.LeaveAllRooms(s) +} + +var emptyTag = strings.Repeat("9", consts.TagTrinarySize/3) + +func onNewTx(tx *value_transaction.ValueTransaction) { + wsTx := &wsTransaction{ + Hash: tx.GetHash(), + Address: tx.GetAddress(), + Value: strconv.FormatInt(tx.GetValue(), 10), + Tag: emptyTag, + Timestamp: strconv.FormatInt(int64(tx.GetTimestamp()), 10), + CurrentIndex: "0", + LastIndex: "0", + Bundle: consts.NullHashTrytes, + TrunkTransaction: tx.GetTrunkTransactionHash(), + BranchTransaction: tx.GetBranchTransactionHash(), + } + + txRingBufferLock.Lock() + txRingBuffer.Value = wsTx + txRingBuffer = txRingBuffer.Next() + txRingBufferLock.Unlock() + + broadcastLock.Lock() + socketioServer.BroadcastToRoom("broadcast", "tx", wsTx) + broadcastLock.Unlock() +} diff --git a/plugins/graph/parameters.go b/plugins/graph/parameters.go new file mode 100644 index 0000000000..5bc6386996 --- /dev/null +++ b/plugins/graph/parameters.go @@ -0,0 +1,26 @@ +package graph + +import ( + "github.com/iotaledger/goshimmer/packages/parameter" +) + +func init() { + + // "Path to IOTA Tangle Visualiser webroot files" + parameter.NodeConfig.SetDefault("graph.webrootPath", "IOTAtangle/webroot") + + // "Path to socket.io.js" + parameter.NodeConfig.SetDefault("graph.socketioPath", "socket.io-client/dist/socket.io.js") + + // "Set the domain on which IOTA Tangle Visualiser is served" + parameter.NodeConfig.SetDefault("graph.domain", "") + + // "Set the host to which the IOTA Tangle Visualiser listens" + parameter.NodeConfig.SetDefault("graph.host", "127.0.0.1") + + // "IOTA Tangle Visualiser webserver port" + parameter.NodeConfig.SetDefault("graph.port", 8083) + + // "Name of the network shown in IOTA Tangle Visualiser" + parameter.NodeConfig.SetDefault("graph.networkName", "meets HORNET") +} diff --git a/plugins/graph/plugin.go b/plugins/graph/plugin.go new file mode 100644 index 0000000000..39e3df4703 --- /dev/null +++ b/plugins/graph/plugin.go @@ -0,0 +1,132 @@ +package graph + +import ( + "fmt" + "net/http" + "time" + + "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/parameter" + "github.com/iotaledger/goshimmer/plugins/tangle" + "golang.org/x/net/context" + + engineio "github.com/googollee/go-engine.io" + "github.com/googollee/go-engine.io/transport" + "github.com/googollee/go-engine.io/transport/polling" + "github.com/googollee/go-engine.io/transport/websocket" + socketio "github.com/googollee/go-socket.io" + + "github.com/iotaledger/hive.go/daemon" + "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/workerpool" +) + +var ( + PLUGIN = node.NewPlugin("Graph", node.Disabled, configure, run) + + log *logger.Logger + + newTxWorkerCount = 1 + newTxWorkerQueueSize = 10000 + newTxWorkerPool *workerpool.WorkerPool + + server *http.Server + router *http.ServeMux + socketioServer *socketio.Server +) + +func downloadSocketIOHandler(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, parameter.NodeConfig.GetString("graph.socketioPath")) +} + +func configureSocketIOServer() error { + var err error + + socketioServer, err = socketio.NewServer(&engineio.Options{ + PingTimeout: time.Second * 20, + PingInterval: time.Second * 5, + Transports: []transport.Transport{ + polling.Default, + websocket.Default, + }, + }) + if err != nil { + return err + } + + socketioServer.OnConnect("/", onConnectHandler) + socketioServer.OnError("/", onErrorHandler) + socketioServer.OnDisconnect("/", onDisconnectHandler) + + return nil +} + +func configure(plugin *node.Plugin) { + log = logger.NewLogger("Graph") + initRingBuffers() + + router = http.NewServeMux() + + // socket.io and web server + server = &http.Server{ + Addr: fmt.Sprintf("%s:%d", parameter.NodeConfig.GetString("graph.host"), parameter.NodeConfig.GetInt("graph.port")), + Handler: router, + } + + fs := http.FileServer(http.Dir(parameter.NodeConfig.GetString("graph.webrootPath"))) + + if err := configureSocketIOServer(); err != nil { + log.Panicf("Graph: %v", err.Error()) + } + + router.Handle("/", fs) + router.HandleFunc("/socket.io/socket.io.js", downloadSocketIOHandler) + router.Handle("/socket.io/", socketioServer) + + newTxWorkerPool = workerpool.New(func(task workerpool.Task) { + onNewTx(task.Param(0).(*value_transaction.ValueTransaction)) + task.Return(nil) + }, workerpool.WorkerCount(newTxWorkerCount), workerpool.QueueSize(newTxWorkerQueueSize)) +} + +func run(plugin *node.Plugin) { + + notifyNewTx := events.NewClosure(func(transaction *value_transaction.ValueTransaction) { + newTxWorkerPool.TrySubmit(transaction) + }) + + daemon.BackgroundWorker("Graph[NewTxWorker]", func(shutdownSignal <-chan struct{}) { + log.Info("Starting Graph[NewTxWorker] ... done") + tangle.Events.TransactionStored.Attach(notifyNewTx) + newTxWorkerPool.Start() + <-shutdownSignal + tangle.Events.TransactionStored.Detach(notifyNewTx) + newTxWorkerPool.Stop() + log.Info("Stopping Graph[NewTxWorker] ... done") + }) + + daemon.BackgroundWorker("Graph Webserver", func(shutdownSignal <-chan struct{}) { + go socketioServer.Serve() + + go func() { + if err := server.ListenAndServe(); err != nil { + log.Error(err.Error()) + } + }() + + log.Infof("You can now access IOTA Tangle Visualiser using: http://%s:%d", parameter.NodeConfig.GetString("graph.host"), parameter.NodeConfig.GetInt("graph.port")) + + <-shutdownSignal + log.Info("Stopping Graph ...") + + socketioServer.Close() + + ctx, cancel := context.WithTimeout(context.Background(), 0*time.Second) + defer cancel() + + _ = server.Shutdown(ctx) + log.Info("Stopping Graph ... done") + }) +} From fc92e9ab9c836d1b1b381dd592b597c745f924d9 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Fri, 10 Jan 2020 15:11:30 +0100 Subject: [PATCH 092/184] move visualizer install instructions --- README.md | 11 +++++++++++ plugins/graph/README.md | 9 --------- 2 files changed, 11 insertions(+), 9 deletions(-) delete mode 100644 plugins/graph/README.md diff --git a/README.md b/README.md index 32af7dfd75..d85f7d547b 100644 --- a/README.md +++ b/README.md @@ -69,3 +69,14 @@ To start Shimmer in the background, you can also simply use [Docker Compose](htt ``` docker-compose up -d ``` + +### Install Glumb visualizer + +Install both the Glumb visualizer and socket.io client lib within the root folder/where the binary is located: +```bash +git clone https://github.com/glumb/IOTAtangle.git +// only this version seems to be stable +cd IOTAtangle && git reset --hard 07bba77a296a2d06277cdae56aa963abeeb5f66e +cd ../ +git clone https://github.com/socketio/socket.io-client.git +``` diff --git a/plugins/graph/README.md b/plugins/graph/README.md deleted file mode 100644 index da7c4ca792..0000000000 --- a/plugins/graph/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# How to install this plugin -- Run the following commands in this folder (or set `graph.socketioPath` and `graph.webrootPath` in your config if you want to use another path) - -```bash -git clone https://github.com/glumb/IOTAtangle.git -cd IOTAtangle && git reset --hard 07bba77a296a2d06277cdae56aa963abeeb5f66e -cd ../ -git clone https://github.com/socketio/socket.io-client.git -``` \ No newline at end of file From ef5ab377679b696ea52b0e3b3c8e6e01fa821f01 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Fri, 10 Jan 2020 15:48:56 +0100 Subject: [PATCH 093/184] Fix: Allow starting a node with gossip disabled (#97) * fix: remove selection flag and use gossip plugin * Upgrade hive.go --- config.json | 3 +-- go.mod | 2 +- go.sum | 4 ++-- plugins/autopeering/autopeering.go | 5 ++++- plugins/autopeering/parameters.go | 2 -- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/config.json b/config.json index 8550f6286b..ce6d80bac4 100644 --- a/config.json +++ b/config.json @@ -8,8 +8,7 @@ "entrynodes":[ "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626" ], - "port":14626, - "selection":true + "port":14626 }, "database":{ "directory":"mainnetdb" diff --git a/go.mod b/go.mod index ffdc776252..90a5f49567 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/go-zeromq/zmq4 v0.7.0 github.com/golang/protobuf v1.3.2 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/hive.go v0.0.0-20200109143501-f876e7457f15 + github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e github.com/iotaledger/iota.go v1.0.0-beta.13 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect diff --git a/go.sum b/go.sum index 1a4c5f51d7..94b4893cc1 100644 --- a/go.sum +++ b/go.sum @@ -83,8 +83,8 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/hive.go v0.0.0-20200109143501-f876e7457f15 h1:3QiXbekFTcuJJFnZUGZ9roLLykCD78Yz2aPZYh1QYLA= -github.com/iotaledger/hive.go v0.0.0-20200109143501-f876e7457f15/go.mod h1:obs07gqna53/Yw1ltzLsQzJBMyA6lGu7Fb/ltjqWMnQ= +github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e h1:bowQHvFQoUWPgxlF9cQRWDzREswR09HpihMiNX1q+AU= +github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e/go.mod h1:obs07gqna53/Yw1ltzLsQzJBMyA6lGu7Fb/ltjqWMnQ= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/iotaledger/iota.go v1.0.0-beta.13 h1:6m6JRcKtjTflU2PbjvDA9Tv6NTEJX1PijBDOkH9weQc= github.com/iotaledger/iota.go v1.0.0-beta.13/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 4d70e09eae..9f019a64dd 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -14,7 +14,9 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/transport" "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" "github.com/pkg/errors" ) @@ -39,7 +41,8 @@ func configureAP() { MasterPeers: masterPeers, }) - if parameter.NodeConfig.GetBool(CFG_SELECTION) { + // enable peer selection only when gossip is enabled + if !node.IsSkipped(gossip.PLUGIN) { Selection = selection.New(local.GetInstance(), Discovery, selection.Config{ Log: log.Named("sel"), Param: &selection.Parameters{ diff --git a/plugins/autopeering/parameters.go b/plugins/autopeering/parameters.go index 0c2454272e..138b8d56e4 100644 --- a/plugins/autopeering/parameters.go +++ b/plugins/autopeering/parameters.go @@ -6,10 +6,8 @@ import ( const ( CFG_ENTRY_NODES = "autopeering.entryNodes" - CFG_SELECTION = "autopeering.selection" ) func init() { flag.StringSlice(CFG_ENTRY_NODES, []string{"V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626"}, "list of trusted entry nodes for auto peering") - flag.Bool(CFG_SELECTION, true, "enable peer selection") } From aebc62e00402bc4cc0ca60df31830f5bca65b4a1 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Fri, 10 Jan 2020 16:02:22 +0100 Subject: [PATCH 094/184] feat: improve analysis status --- plugins/analysis/plugin.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/analysis/plugin.go b/plugins/analysis/plugin.go index 8be4a8422f..1dc75fff1e 100644 --- a/plugins/analysis/plugin.go +++ b/plugins/analysis/plugin.go @@ -25,12 +25,12 @@ func run(plugin *node.Plugin) { webinterface.Run(plugin) server.Run(plugin) } else { - log.Info("Starting Plugin: Analysis ... server is disabled (server-port is 0)") + log.Info("Server is disabled (server-port is 0)") } if parameter.NodeConfig.GetString(client.CFG_SERVER_ADDRESS) != "" { client.Run(plugin) } else { - log.Info("Starting Plugin: Analysis ... client is disabled (server-address is empty)") + log.Info("Client is disabled (server-address is empty)") } } From da29a7c2ede3fde0e31af69923dc0ef9679ed696 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Fri, 10 Jan 2020 17:52:16 +0100 Subject: [PATCH 095/184] chore: remove unused packages (#99) --- packages/batchworkerpool/batchworkerpool.go | 163 ------------------ packages/batchworkerpool/options.go | 55 ------ packages/batchworkerpool/task.go | 15 -- packages/client/bundle.go | 12 +- packages/client/options.go | 1 - packages/client/valuebundlefactory.go | 26 --- packages/curl/batch_hasher.go | 66 ------- packages/curl/batch_hasher_test.go | 96 ----------- packages/curl/bct_curl.go | 124 ------------- packages/curl/curl.go | 103 ----------- packages/curl/curlp81.go | 10 -- packages/filter/byte_array_filter.go | 54 ------ packages/filter/byte_array_filter_test.go | 45 ----- packages/settings/settings.go | 31 ---- packages/ternary/bc_ternary.go | 13 -- packages/ternary/bc_ternary_demultiplexer.go | 41 ----- packages/ternary/bc_ternary_multiplexer.go | 64 ------- .../bundleprocessor/valuebundleprocessor.go | 12 +- plugins/validator/plugin.go | 69 -------- plugins/validator/validator_test.go | 54 ------ runMasternode.bat | 8 - runSimulation.bat | 20 --- 22 files changed, 10 insertions(+), 1072 deletions(-) delete mode 100644 packages/batchworkerpool/batchworkerpool.go delete mode 100644 packages/batchworkerpool/options.go delete mode 100644 packages/batchworkerpool/task.go delete mode 100644 packages/client/options.go delete mode 100644 packages/client/valuebundlefactory.go delete mode 100644 packages/curl/batch_hasher.go delete mode 100644 packages/curl/batch_hasher_test.go delete mode 100644 packages/curl/bct_curl.go delete mode 100644 packages/curl/curl.go delete mode 100644 packages/curl/curlp81.go delete mode 100644 packages/filter/byte_array_filter.go delete mode 100644 packages/filter/byte_array_filter_test.go delete mode 100644 packages/settings/settings.go delete mode 100644 packages/ternary/bc_ternary.go delete mode 100644 packages/ternary/bc_ternary_demultiplexer.go delete mode 100644 packages/ternary/bc_ternary_multiplexer.go delete mode 100644 plugins/validator/plugin.go delete mode 100644 plugins/validator/validator_test.go delete mode 100644 runMasternode.bat delete mode 100644 runSimulation.bat diff --git a/packages/batchworkerpool/batchworkerpool.go b/packages/batchworkerpool/batchworkerpool.go deleted file mode 100644 index 071015ff28..0000000000 --- a/packages/batchworkerpool/batchworkerpool.go +++ /dev/null @@ -1,163 +0,0 @@ -package batchworkerpool - -import ( - "sync" - "time" -) - -type BatchWorkerPool struct { - workerFnc func([]Task) - options *Options - - calls chan Task - batchedCalls chan []Task - terminate chan int - - running bool - mutex sync.RWMutex - wait sync.WaitGroup -} - -func New(workerFnc func([]Task), optionalOptions ...Option) (result *BatchWorkerPool) { - options := DEFAULT_OPTIONS.Override(optionalOptions...) - - result = &BatchWorkerPool{ - workerFnc: workerFnc, - options: options, - } - - result.resetChannels() - - return -} - -func (wp *BatchWorkerPool) Submit(params ...interface{}) (result chan interface{}) { - result = make(chan interface{}, 1) - - wp.mutex.RLock() - - if wp.running { - wp.calls <- Task{ - params: params, - resultChan: result, - } - } else { - close(result) - } - - wp.mutex.RUnlock() - - return -} - -func (wp *BatchWorkerPool) Start() { - wp.mutex.Lock() - - if !wp.running { - wp.running = true - - wp.startBatchDispatcher() - wp.startBatchWorkers() - } - - wp.mutex.Unlock() -} - -func (wp *BatchWorkerPool) Run() { - wp.Start() - - wp.wait.Wait() -} - -func (wp *BatchWorkerPool) Stop() { - go wp.StopAndWait() -} - -func (wp *BatchWorkerPool) StopAndWait() { - wp.mutex.Lock() - - if wp.running { - wp.running = false - - close(wp.terminate) - wp.resetChannels() - } - - wp.wait.Wait() - - wp.mutex.Unlock() -} - -func (wp *BatchWorkerPool) resetChannels() { - wp.calls = make(chan Task, wp.options.QueueSize) - wp.batchedCalls = make(chan []Task, 2*wp.options.WorkerCount) - wp.terminate = make(chan int, 1) -} - -func (wp *BatchWorkerPool) startBatchDispatcher() { - calls := wp.calls - terminate := wp.terminate - - wp.wait.Add(1) - - go func() { - for { - select { - case <-terminate: - wp.wait.Done() - - return - case firstCall := <-calls: - batchTask := append(make([]Task, 0), firstCall) - - collectionTimeout := time.After(wp.options.BatchCollectionTimeout) - - // collect additional requests that arrive within the timeout - CollectAdditionalCalls: - for { - select { - case <-terminate: - wp.wait.Done() - - return - case <-collectionTimeout: - break CollectAdditionalCalls - case call := <-wp.calls: - batchTask = append(batchTask, call) - - if len(batchTask) == wp.options.BatchSize { - break CollectAdditionalCalls - } - } - } - - wp.batchedCalls <- batchTask - } - } - }() -} - -func (wp *BatchWorkerPool) startBatchWorkers() { - batchedCalls := wp.batchedCalls - terminate := wp.terminate - - for i := 0; i < wp.options.WorkerCount; i++ { - wp.wait.Add(1) - - go func() { - aborted := false - - for !aborted { - select { - case <-terminate: - aborted = true - - case batchTask := <-batchedCalls: - wp.workerFnc(batchTask) - } - } - - wp.wait.Done() - }() - } -} diff --git a/packages/batchworkerpool/options.go b/packages/batchworkerpool/options.go deleted file mode 100644 index 47e53b7593..0000000000 --- a/packages/batchworkerpool/options.go +++ /dev/null @@ -1,55 +0,0 @@ -package batchworkerpool - -import ( - "runtime" - "time" -) - -var DEFAULT_OPTIONS = &Options{ - WorkerCount: 2 * runtime.NumCPU(), - QueueSize: 2 * runtime.NumCPU() * 64, - BatchSize: 64, - BatchCollectionTimeout: 15 * time.Millisecond, -} - -func WorkerCount(workerCount int) Option { - return func(args *Options) { - args.WorkerCount = workerCount - } -} - -func BatchSize(batchSize int) Option { - return func(args *Options) { - args.BatchSize = batchSize - } -} - -func BatchCollectionTimeout(batchCollectionTimeout time.Duration) Option { - return func(args *Options) { - args.BatchCollectionTimeout = batchCollectionTimeout - } -} - -func QueueSize(queueSize int) Option { - return func(args *Options) { - args.QueueSize = queueSize - } -} - -type Options struct { - WorkerCount int - QueueSize int - BatchSize int - BatchCollectionTimeout time.Duration -} - -func (options Options) Override(optionalOptions ...Option) *Options { - result := &options - for _, option := range optionalOptions { - option(result) - } - - return result -} - -type Option func(*Options) diff --git a/packages/batchworkerpool/task.go b/packages/batchworkerpool/task.go deleted file mode 100644 index 7d4ea82e80..0000000000 --- a/packages/batchworkerpool/task.go +++ /dev/null @@ -1,15 +0,0 @@ -package batchworkerpool - -type Task struct { - params []interface{} - resultChan chan interface{} -} - -func (task *Task) Return(result interface{}) { - task.resultChan <- result - close(task.resultChan) -} - -func (task *Task) Param(index int) interface{} { - return task.params[index] -} diff --git a/packages/client/bundle.go b/packages/client/bundle.go index 200cd04aea..da25cb6f3a 100644 --- a/packages/client/bundle.go +++ b/packages/client/bundle.go @@ -1,8 +1,8 @@ package client import ( - "github.com/iotaledger/goshimmer/packages/curl" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/iota.go/curl" "github.com/iotaledger/iota.go/trinary" ) @@ -31,11 +31,9 @@ func CalculateBundleHash(transactions []*value_transaction.ValueTransaction) tri copy(concatenatedBundleEssences[value_transaction.BUNDLE_ESSENCE_SIZE*i:value_transaction.BUNDLE_ESSENCE_SIZE*(i+1)], bundleTransaction.GetBundleEssence(lastInputAddress != bundleTransaction.GetAddress())) } - var bundleHash = make(trinary.Trits, 243) - - hasher := curl.NewCurl(243, 81) - hasher.Absorb(concatenatedBundleEssences, 0, len(concatenatedBundleEssences)) - hasher.Squeeze(bundleHash, 0, 243) - + bundleHash, err := curl.HashTrits(concatenatedBundleEssences) + if err != nil { + panic(err) + } return trinary.MustTritsToTrytes(bundleHash) } diff --git a/packages/client/options.go b/packages/client/options.go deleted file mode 100644 index da13c8ef3c..0000000000 --- a/packages/client/options.go +++ /dev/null @@ -1 +0,0 @@ -package client diff --git a/packages/client/valuebundlefactory.go b/packages/client/valuebundlefactory.go deleted file mode 100644 index 066c087762..0000000000 --- a/packages/client/valuebundlefactory.go +++ /dev/null @@ -1,26 +0,0 @@ -package client - -import ( - "github.com/iotaledger/iota.go/consts" - "github.com/iotaledger/iota.go/trinary" -) - -type ValueBundleFactory struct { - seed trinary.Trytes - securityLevel consts.SecurityLevel - seedInputs map[uint64]uint64 - seedOutputs map[uint64]uint64 -} - -func New(seed trinary.Trytes, securityLevel consts.SecurityLevel) *ValueBundleFactory { - return &ValueBundleFactory{ - seed: seed, - securityLevel: securityLevel, - seedInputs: make(map[uint64]uint64), - seedOutputs: make(map[uint64]uint64), - } -} - -func (factory *ValueBundleFactory) AddInput(addressIndex uint64, value uint64) { - factory.seedInputs[addressIndex] = value -} diff --git a/packages/curl/batch_hasher.go b/packages/curl/batch_hasher.go deleted file mode 100644 index 1a4d14681b..0000000000 --- a/packages/curl/batch_hasher.go +++ /dev/null @@ -1,66 +0,0 @@ -package curl - -import ( - "strconv" - - "github.com/iotaledger/goshimmer/packages/batchworkerpool" - "github.com/iotaledger/goshimmer/packages/ternary" - "github.com/iotaledger/iota.go/trinary" -) - -type BatchHasher struct { - hashLength int - rounds int - workerPool *batchworkerpool.BatchWorkerPool -} - -func NewBatchHasher(hashLength int, rounds int) (result *BatchHasher) { - result = &BatchHasher{ - hashLength: hashLength, - rounds: rounds, - } - - result.workerPool = batchworkerpool.New(result.processHashes, batchworkerpool.BatchSize(strconv.IntSize), batchworkerpool.WorkerCount(100), batchworkerpool.QueueSize(500000)) - result.workerPool.Start() - - return -} - -func (this *BatchHasher) Hash(trits trinary.Trits) trinary.Trits { - return (<-this.workerPool.Submit(trits)).(trinary.Trits) -} - -func (this *BatchHasher) processHashes(tasks []batchworkerpool.Task) { - if len(tasks) > 1 { - // multiplex the requests - multiplexer := ternary.NewBCTernaryMultiplexer() - for _, hashRequest := range tasks { - multiplexer.Add(hashRequest.Param(0).(trinary.Trits)) - } - bcTrits, err := multiplexer.Extract() - if err != nil { - panic(err) - } - - // calculate the hash - bctCurl := NewBCTCurl(this.hashLength, this.rounds, strconv.IntSize) - bctCurl.Reset() - bctCurl.Absorb(bcTrits) - - // extract the results from the demultiplexer - demux := ternary.NewBCTernaryDemultiplexer(bctCurl.Squeeze(243)) - for i, task := range tasks { - task.Return(demux.Get(i)) - } - } else { - var resp = make(trinary.Trits, this.hashLength) - - trits := tasks[0].Param(0).(trinary.Trits) - - curl := NewCurl(this.hashLength, this.rounds) - curl.Absorb(trits, 0, len(trits)) - curl.Squeeze(resp, 0, this.hashLength) - - tasks[0].Return(resp) - } -} diff --git a/packages/curl/batch_hasher_test.go b/packages/curl/batch_hasher_test.go deleted file mode 100644 index 71eac47150..0000000000 --- a/packages/curl/batch_hasher_test.go +++ /dev/null @@ -1,96 +0,0 @@ -package curl - -import ( - "crypto/ed25519" - "sync" - "testing" - - "github.com/iotaledger/iota.go/trinary" - "golang.org/x/crypto/blake2b" -) - -type zeroReader struct{} - -func (zeroReader) Read(buf []byte) (int, error) { - for i := range buf { - buf[i] = 0 - } - return len(buf), nil -} - -func BenchmarkEd25519(b *testing.B) { - var zero zeroReader - public, private, _ := ed25519.GenerateKey(zero) - - message := make([]byte, 75) - sig := ed25519.Sign(private, message) - - b.ResetTimer() - - var wg sync.WaitGroup - for i := 0; i < b.N; i++ { - wg.Add(1) - - go func() { - if !ed25519.Verify(public, message, sig) { - panic("valid signature rejected") - } - - wg.Done() - }() - } - wg.Wait() -} - -var sampleTransactionData = make([]byte, 750) - -func BenchmarkBytesToTrits(b *testing.B) { - bytes := blake2b.Sum512(sampleTransactionData) - - b.ResetTimer() - - var wg sync.WaitGroup - for i := 0; i < b.N; i++ { - wg.Add(1) - - go func() { - _, _ = trinary.BytesToTrits(bytes[:]) - - wg.Done() - }() - } - wg.Wait() -} - -func BenchmarkBlake2b(b *testing.B) { - var wg sync.WaitGroup - for i := 0; i < b.N; i++ { - wg.Add(1) - - go func() { - blake2b.Sum256(sampleTransactionData) - - wg.Done() - }() - } - wg.Wait() -} - -func BenchmarkBatchHasher_Hash(b *testing.B) { - batchHasher := NewBatchHasher(243, 81) - tritsToHash := make(trinary.Trits, 7500) - - b.ResetTimer() - - var wg sync.WaitGroup - for i := 0; i < b.N; i++ { - wg.Add(1) - - go func() { - batchHasher.Hash(tritsToHash) - - wg.Done() - }() - } - wg.Wait() -} diff --git a/packages/curl/bct_curl.go b/packages/curl/bct_curl.go deleted file mode 100644 index 8a5e7a5be2..0000000000 --- a/packages/curl/bct_curl.go +++ /dev/null @@ -1,124 +0,0 @@ -package curl - -import "github.com/iotaledger/goshimmer/packages/ternary" - -const ( - NUMBER_OF_TRITS_IN_A_TRYTE = 3 -) - -type BCTCurl struct { - hashLength int - numberOfRounds int - highLongBits uint - stateLength int - state ternary.BCTrits - cTransform func() -} - -func NewBCTCurl(hashLength int, numberOfRounds int, batchSize int) *BCTCurl { - - var highLongBits uint - for i := 0; i < batchSize; i++ { - highLongBits += 1 << uint(i) - } - - this := &BCTCurl{ - hashLength: hashLength, - numberOfRounds: numberOfRounds, - highLongBits: highLongBits, - stateLength: NUMBER_OF_TRITS_IN_A_TRYTE * hashLength, - state: ternary.BCTrits{ - Lo: make([]uint, NUMBER_OF_TRITS_IN_A_TRYTE*hashLength), - Hi: make([]uint, NUMBER_OF_TRITS_IN_A_TRYTE*hashLength), - }, - cTransform: nil, - } - - this.Reset() - - return this -} - -func (this *BCTCurl) Reset() { - for i := 0; i < this.stateLength; i++ { - this.state.Lo[i] = this.highLongBits - this.state.Hi[i] = this.highLongBits - } -} - -func (this *BCTCurl) Transform() { - scratchPadLo := make([]uint, this.stateLength) - scratchPadHi := make([]uint, this.stateLength) - scratchPadIndex := 0 - - for round := this.numberOfRounds; round > 0; round-- { - copy(scratchPadLo, this.state.Lo) - copy(scratchPadHi, this.state.Hi) - for stateIndex := 0; stateIndex < this.stateLength; stateIndex++ { - alpha := scratchPadLo[scratchPadIndex] - beta := scratchPadHi[scratchPadIndex] - - if scratchPadIndex < 365 { - scratchPadIndex += 364 - } else { - scratchPadIndex -= 365 - } - - delta := beta ^ scratchPadLo[scratchPadIndex] - - this.state.Lo[stateIndex] = ^(delta & alpha) - this.state.Hi[stateIndex] = delta | (alpha ^ scratchPadHi[scratchPadIndex]) - } - } -} - -func (this *BCTCurl) Absorb(bcTrits ternary.BCTrits) { - length := len(bcTrits.Lo) - offset := 0 - - for { - var lengthToCopy int - if length < this.hashLength { - lengthToCopy = length - } else { - lengthToCopy = this.hashLength - } - - copy(this.state.Lo[0:lengthToCopy], bcTrits.Lo[offset:offset+lengthToCopy]) - copy(this.state.Hi[0:lengthToCopy], bcTrits.Hi[offset:offset+lengthToCopy]) - this.Transform() - - offset += lengthToCopy - length -= lengthToCopy - - if length <= 0 { - break - } - } -} - -func (this *BCTCurl) Squeeze(tritCount int) ternary.BCTrits { - result := ternary.BCTrits{ - Lo: make([]uint, tritCount), - Hi: make([]uint, tritCount), - } - hashCount := tritCount / this.hashLength - - for i := 0; i < hashCount; i++ { - copy(result.Lo[i*this.hashLength:(i+1)*this.hashLength], this.state.Lo[0:this.hashLength]) - copy(result.Hi[i*this.hashLength:(i+1)*this.hashLength], this.state.Hi[0:this.hashLength]) - - this.Transform() - } - - last := tritCount - hashCount*this.hashLength - - copy(result.Lo[tritCount-last:], this.state.Lo[0:last]) - copy(result.Hi[tritCount-last:], this.state.Hi[0:last]) - - if tritCount%this.hashLength != 0 { - this.Transform() - } - - return result -} diff --git a/packages/curl/curl.go b/packages/curl/curl.go deleted file mode 100644 index 621ada160b..0000000000 --- a/packages/curl/curl.go +++ /dev/null @@ -1,103 +0,0 @@ -package curl - -import ( - "math" - - "github.com/iotaledger/iota.go/trinary" -) - -const ( - HASH_LENGTH = 243 - STATE_LENGTH = 3 * HASH_LENGTH -) - -var ( - TRUTH_TABLE = trinary.Trits{1, 0, -1, 2, 1, -1, 0, 2, -1, 1, 0} -) - -type Hash interface { - Initialize() - InitializeCurl(trits *[]int8, length int, rounds int) - Reset() - Absorb(trits *[]int8, offset int, length int) - Squeeze(resp []int8, offset int, length int) []int -} - -type Curl struct { - Hash - state trinary.Trits - hashLength int - rounds int -} - -func NewCurl(hashLength int, rounds int) *Curl { - this := &Curl{ - hashLength: hashLength, - rounds: rounds, - } - - this.Reset() - - return this -} - -func (curl *Curl) Initialize() { - curl.InitializeCurl(nil, 0, curl.rounds) -} - -func (curl *Curl) InitializeCurl(trits trinary.Trits, length int, rounds int) { - curl.rounds = rounds - if trits != nil { - curl.state = trits - } else { - curl.state = make(trinary.Trits, STATE_LENGTH) - } -} - -func (curl *Curl) Reset() { - curl.InitializeCurl(nil, 0, curl.rounds) -} - -func (curl *Curl) Absorb(trits trinary.Trits, offset int, length int) { - for { - limit := int(math.Min(HASH_LENGTH, float64(length))) - copy(curl.state, trits[offset:offset+limit]) - curl.Transform() - offset += HASH_LENGTH - length -= HASH_LENGTH - if length <= 0 { - break - } - } -} - -func (curl *Curl) Squeeze(resp trinary.Trits, offset int, length int) trinary.Trits { - for { - limit := int(math.Min(HASH_LENGTH, float64(length))) - copy(resp[offset:offset+limit], curl.state) - curl.Transform() - offset += HASH_LENGTH - length -= HASH_LENGTH - if length <= 0 { - break - } - } - return resp -} - -func (curl *Curl) Transform() { - var index = 0 - for round := 0; round < curl.rounds; round++ { - stateCopy := make(trinary.Trits, STATE_LENGTH) - copy(stateCopy, curl.state) - for i := 0; i < STATE_LENGTH; i++ { - incr := 364 - if index >= 365 { - incr = -365 - } - index2 := index + incr - curl.state[i] = TRUTH_TABLE[stateCopy[index]+(stateCopy[index2]<<2)+5] - index = index2 - } - } -} diff --git a/packages/curl/curlp81.go b/packages/curl/curlp81.go deleted file mode 100644 index 579271500b..0000000000 --- a/packages/curl/curlp81.go +++ /dev/null @@ -1,10 +0,0 @@ -package curl - -const ( - CURLP81_HASH_LENGTH = 243 - CURLP81_ROUNDS = 81 -) - -var ( - CURLP81 = NewBatchHasher(CURLP81_HASH_LENGTH, CURLP81_ROUNDS) -) diff --git a/packages/filter/byte_array_filter.go b/packages/filter/byte_array_filter.go deleted file mode 100644 index e5955c32c3..0000000000 --- a/packages/filter/byte_array_filter.go +++ /dev/null @@ -1,54 +0,0 @@ -package filter - -import ( - "sync" - - "github.com/iotaledger/hive.go/typeutils" -) - -type ByteArrayFilter struct { - byteArrays [][]byte - byteArraysByKey map[string]bool - size int - mutex sync.RWMutex -} - -func NewByteArrayFilter(size int) *ByteArrayFilter { - return &ByteArrayFilter{ - byteArrays: make([][]byte, 0, size), - byteArraysByKey: make(map[string]bool, size), - size: size, - } -} - -func (filter *ByteArrayFilter) Contains(byteArray []byte) bool { - filter.mutex.RLock() - defer filter.mutex.RUnlock() - - _, exists := filter.byteArraysByKey[typeutils.BytesToString(byteArray)] - - return exists -} - -func (filter *ByteArrayFilter) Add(byteArray []byte) bool { - key := typeutils.BytesToString(byteArray) - - filter.mutex.Lock() - defer filter.mutex.Unlock() - - if _, exists := filter.byteArraysByKey[key]; !exists { - if len(filter.byteArrays) == filter.size { - delete(filter.byteArraysByKey, typeutils.BytesToString(filter.byteArrays[0])) - - filter.byteArrays = append(filter.byteArrays[1:], byteArray) - } else { - filter.byteArrays = append(filter.byteArrays, byteArray) - } - - filter.byteArraysByKey[key] = true - - return true - } else { - return false - } -} diff --git a/packages/filter/byte_array_filter_test.go b/packages/filter/byte_array_filter_test.go deleted file mode 100644 index a017866b4e..0000000000 --- a/packages/filter/byte_array_filter_test.go +++ /dev/null @@ -1,45 +0,0 @@ -package filter - -import "testing" - -func BenchmarkAdd(b *testing.B) { - filter, byteArray := setupFilter(15000, 1604) - - b.ResetTimer() - - for i := 0; i < b.N; i++ { - filter.Add(byteArray) - } -} - -func BenchmarkContains(b *testing.B) { - filter, byteArray := setupFilter(15000, 1604) - - b.ResetTimer() - - for i := 0; i < b.N; i++ { - filter.Contains(byteArray) - } -} - -func setupFilter(filterSize int, byteArraySize int) (*ByteArrayFilter, []byte) { - filter := NewByteArrayFilter(filterSize) - - for j := 0; j < filterSize; j++ { - byteArray := make([]byte, byteArraySize) - - for i := 0; i < len(byteArray); i++ { - byteArray[(i+j)%byteArraySize] = byte((i + j) % 128) - } - - filter.Add(byteArray) - } - - byteArray := make([]byte, byteArraySize) - - for i := 0; i < len(byteArray); i++ { - byteArray[i] = byte(i % 128) - } - - return filter, byteArray -} diff --git a/packages/settings/settings.go b/packages/settings/settings.go deleted file mode 100644 index df0ad335fa..0000000000 --- a/packages/settings/settings.go +++ /dev/null @@ -1,31 +0,0 @@ -package settings - -import ( - "sync" - - "github.com/iotaledger/goshimmer/packages/database" -) - -var settingsDatabase database.Database - -var lazyInit sync.Once - -func Get(key []byte) ([]byte, error) { - lazyInit.Do(initDb) - - return settingsDatabase.Get(key) -} - -func Set(key []byte, value []byte) error { - lazyInit.Do(initDb) - - return settingsDatabase.Set(key, value) -} - -func initDb() { - if db, err := database.Get("settings"); err != nil { - panic(err) - } else { - settingsDatabase = db - } -} diff --git a/packages/ternary/bc_ternary.go b/packages/ternary/bc_ternary.go deleted file mode 100644 index cc7432ca0f..0000000000 --- a/packages/ternary/bc_ternary.go +++ /dev/null @@ -1,13 +0,0 @@ -package ternary - -// a Binary Coded Trit encodes a Trit in 2 bits with -1 => 00, 0 => 01 and 1 => 10 -type BCTrit struct { - Lo uint - Hi uint -} - -// a Binary Coded Trytes consists out of many Binary Coded Trits -type BCTrits struct { - Lo []uint - Hi []uint -} diff --git a/packages/ternary/bc_ternary_demultiplexer.go b/packages/ternary/bc_ternary_demultiplexer.go deleted file mode 100644 index 96733a7471..0000000000 --- a/packages/ternary/bc_ternary_demultiplexer.go +++ /dev/null @@ -1,41 +0,0 @@ -package ternary - -import ( - . "github.com/iotaledger/iota.go/trinary" -) - -type BCTernaryDemultiplexer struct { - bcTrits BCTrits -} - -func NewBCTernaryDemultiplexer(bcTrits BCTrits) *BCTernaryDemultiplexer { - this := &BCTernaryDemultiplexer{bcTrits: bcTrits} - - return this -} - -func (this *BCTernaryDemultiplexer) Get(index int) Trits { - length := len(this.bcTrits.Lo) - result := make(Trits, length) - - for i := 0; i < length; i++ { - low := (this.bcTrits.Lo[i] >> uint(index)) & 1 - hi := (this.bcTrits.Hi[i] >> uint(index)) & 1 - - switch true { - case low == 1 && hi == 0: - result[i] = -1 - - case low == 0 && hi == 1: - result[i] = 1 - - case low == 1 && hi == 1: - result[i] = 0 - - default: - result[i] = 0 - } - } - - return result -} diff --git a/packages/ternary/bc_ternary_multiplexer.go b/packages/ternary/bc_ternary_multiplexer.go deleted file mode 100644 index f98991b621..0000000000 --- a/packages/ternary/bc_ternary_multiplexer.go +++ /dev/null @@ -1,64 +0,0 @@ -package ternary - -import ( - "errors" - "strconv" - - . "github.com/iotaledger/iota.go/trinary" -) - -type BCTernaryMultiplexer struct { - trinaries []Trits -} - -func NewBCTernaryMultiplexer() *BCTernaryMultiplexer { - this := &BCTernaryMultiplexer{make([]Trits, 0)} - - return this -} - -func (this *BCTernaryMultiplexer) Add(trits Trits) int { - this.trinaries = append(this.trinaries, trits) - - return len(this.trinaries) - 1 -} - -func (this *BCTernaryMultiplexer) Get(index int) Trits { - return this.trinaries[index] -} - -func (this *BCTernaryMultiplexer) Extract() (BCTrits, error) { - trinariesCount := len(this.trinaries) - tritsCount := len(this.trinaries[0]) - - result := BCTrits{ - Lo: make([]uint, tritsCount), - Hi: make([]uint, tritsCount), - } - - for i := 0; i < tritsCount; i++ { - bcTrit := &BCTrit{0, 0} - - for j := 0; j < trinariesCount; j++ { - switch this.trinaries[j][i] { - case -1: - bcTrit.Lo |= 1 << uint(j) - - case 1: - bcTrit.Hi |= 1 << uint(j) - - case 0: - bcTrit.Lo |= 1 << uint(j) - bcTrit.Hi |= 1 << uint(j) - - default: - return result, errors.New("Invalid trit #" + strconv.Itoa(i) + " in trits #" + strconv.Itoa(j)) - } - } - - result.Lo[i] = bcTrit.Lo - result.Hi[i] = bcTrit.Hi - } - - return result, nil -} diff --git a/plugins/bundleprocessor/valuebundleprocessor.go b/plugins/bundleprocessor/valuebundleprocessor.go index 271fdb0633..63c772e12d 100644 --- a/plugins/bundleprocessor/valuebundleprocessor.go +++ b/plugins/bundleprocessor/valuebundleprocessor.go @@ -1,11 +1,11 @@ package bundleprocessor import ( - "github.com/iotaledger/goshimmer/packages/curl" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/workerpool" + "github.com/iotaledger/iota.go/curl" "github.com/iotaledger/iota.go/signing" "github.com/iotaledger/iota.go/trinary" ) @@ -38,12 +38,10 @@ func CalculateBundleHash(transactions []*value_transaction.ValueTransaction) tri copy(concatenatedBundleEssences[value_transaction.BUNDLE_ESSENCE_SIZE*i:value_transaction.BUNDLE_ESSENCE_SIZE*(i+1)], bundleTransaction.GetBundleEssence(lastInputAddress != bundleTransaction.GetAddress())) } - var bundleHash = make(trinary.Trits, 243) - - hasher := curl.NewCurl(243, 81) - hasher.Absorb(concatenatedBundleEssences, 0, len(concatenatedBundleEssences)) - hasher.Squeeze(bundleHash, 0, 243) - + bundleHash, err := curl.HashTrits(concatenatedBundleEssences) + if err != nil { + panic(err) + } return trinary.MustTritsToTrytes(bundleHash) } diff --git a/plugins/validator/plugin.go b/plugins/validator/plugin.go deleted file mode 100644 index b20ba75d57..0000000000 --- a/plugins/validator/plugin.go +++ /dev/null @@ -1,69 +0,0 @@ -package validator - -import ( - "github.com/iotaledger/goshimmer/packages/model/bundle" - "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/plugins/bundleprocessor" - "github.com/iotaledger/hive.go/events" - "github.com/iotaledger/hive.go/logger" - "github.com/iotaledger/hive.go/node" - "github.com/iotaledger/iota.go/kerl" - "github.com/iotaledger/iota.go/signing" - . "github.com/iotaledger/iota.go/trinary" -) - -var PLUGIN = node.NewPlugin("Validator", node.Enabled, configure, run) -var log *logger.Logger - -func validateSignatures(bundleHash Hash, txs []*value_transaction.ValueTransaction) (bool, error) { - for i, tx := range txs { - // ignore all non-input transactions - if tx.GetValue() >= 0 { - continue - } - - address := tx.GetAddress() - - // it is unknown how many fragments there will be - fragments := []Trytes{tx.GetSignatureMessageFragment()} - - // each consecutive meta transaction with the same address contains another signature fragment - for j := i; j < len(txs)-1; j++ { - otherTx := txs[j+1] - if otherTx.GetValue() != 0 || otherTx.GetAddress() != address { - break - } - - fragments = append(fragments, otherTx.GetSignatureMessageFragment()) - } - - // validate all the fragments against the address using Kerl - valid, err := signing.ValidateSignatures(address, fragments, bundleHash, kerl.NewKerl()) - if err != nil { - return false, err - } - if !valid { - return false, nil - } - } - - return true, nil -} - -func configure(plugin *node.Plugin) { - log = logger.NewLogger("Validator") - bundleprocessor.Events.BundleSolid.Attach(events.NewClosure(func(b *bundle.Bundle, txs []*value_transaction.ValueTransaction) { - // signature are verified against the bundle hash - valid, err := validateSignatures(b.GetBundleEssenceHash(), txs) - if !valid { - if err != nil { - log.Errorf("Invalid signature: %s", err.Error()) - } else { - log.Error("Invalid signature") - } - } - })) -} - -func run(*node.Plugin) { -} diff --git a/plugins/validator/validator_test.go b/plugins/validator/validator_test.go deleted file mode 100644 index fd4f70b431..0000000000 --- a/plugins/validator/validator_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package validator - -import ( - "fmt" - - "github.com/iotaledger/iota.go/address" - . "github.com/iotaledger/iota.go/consts" - "github.com/iotaledger/iota.go/signing" - . "github.com/iotaledger/iota.go/trinary" -) - -const ( - exampleHash = "999999999999999999999999999999999999999999999999999999999999999999999999999999999" - exampleSeed = exampleHash - exmapleIndex = 0 - exampleSec = SecurityLevelLow -) - -// Creates bundle signature fragments for the given address index and bundle hash. -// Each signature fragment after the first must go into its own meta transaction with value = 0. -func signature(seed Trytes, index uint64, sec SecurityLevel, bundleHash Hash) []Trytes { - // compute seed based on address index - subseed, _ := signing.Subseed(seed, index) - // generate the private key - prvKey, _ := signing.Key(subseed, sec) - - normalizedBundleHash := signing.NormalizedBundleHash(bundleHash) - - signatureFragments := make([]Trytes, sec) - for i := 0; i < int(sec); i++ { - // each security level signs one third of the (normalized) bundle hash - signedFragTrits, _ := signing.SignatureFragment( - normalizedBundleHash[i*HashTrytesSize/3:(i+1)*HashTrytesSize/3], - prvKey[i*KeyFragmentLength:(i+1)*KeyFragmentLength], - ) - signatureFragments[i] = MustTritsToTrytes(signedFragTrits) - } - - return signatureFragments -} - -func ExamplePLUGIN() { - // corresponding address to validate against. - addr, _ := address.GenerateAddress(exampleSeed, exmapleIndex, exampleSec) - fmt.Println(addr) - - // compute the signature fragments which would be added to the (meta) transactions - signatureFragments := signature(exampleSeed, exmapleIndex, exampleSec, exampleHash) - fmt.Println(signatureFragments[0]) - - // Output: - // BSIXFJENGVJSOWPVHVALMPOPO9PUKHXDQI9VDELCBJXN9TCNQPTFEDMPQCVBOJSZUHEOABYYYAT9IAHHY - // GHHKPBXOOBOEHGGEEKYPH9MANWEKSQTQJFJ9KUTMJQAVITYRZMNLUESQARNHAWUJAPPZSQ9A9RUKABCE9KZPJDUEHVZEOSCQMTCC9AWBGWZLZEXMJ9YOQUVIBGMXSINCOLUATYDDUBAALHCBIONNRQIVIPUFPOIFHYRBFBGXXNVYXFZUSTTA9LYGGITTAJCVDE9GCFRGIOTXLQ9ZJDLONDLZ9OPS9TNYVKLTCGFBH9QPJWLIGADWMTJVCLAUCOZFDSRRCAMVWYFXRPGPMIOPIW9GBWANVSMPONQOTNLLYYHXAMZMMNRHMRXHEIXPVNORNGZZ9ZAU9RAWASOZNIBKDWYZWKCMLEUE9UVDHZ9XXGPXZABB9FGTNDTDFTYCKLKRRC9GZFKHKDGAWPBWEUPPWISYBBNZCIBERPXTMZPZHPKKUQUPBIJBIKZAGFHDDNAGCRQMWOMLUMAYKRBMHPMDWZK9JRBDWCJCBJQYMDUBNKOIRSJSVTCNKROZ9KLFBZLOXQOASLCFETCNZRPZULOABOFCUO9WKNQILLLTQ9GWVDBASBGSKUHFHRXOKQIBRCLUYZBZMTXTIG9BJNYHTJQQOECXOWLIDOYKMFJWKRCYW99VZILSPU9I9ZSTTBZVGISUHPCWLGKCFNLIHJNCL9OWQD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PNMZYMJJHVZSNEIJOAPGHAIVCZHQIULTRIZ9ML9LCWTQVGLBKKBGJYZTOZZIYUBCBKHKYUHCFGZKDERTWYHNYWSWLGPUGRB9WNQTHOMBFPKUQZREUQCNXL9MFSZCNBN9PTAVCERMWTTFDZL9BJQMC9OUBWGDTURAEYTYRDNFUBATOWFSVNXJC9JUPARMU9MINY9RWRHIXBPNIUADFAEP9F9FWNJNRPNGLWHRYYCV9ZIWBOUZPFZTWDLOCNOYZQLWFJHZ99ZBLUDSIQBJOJXMQJBUCYYMROBCJJJNCETVUYRXKHAWGUBIWOKQXOIOYBQKNDXZCKXQZLWEMXYLJPODRMOQUYOAATZZQ9JZDR9KPIHRQKIEAQNO9OVXNHDFCUUIZRQDWYGKUAYIGHGIIJIOIERLVNDUEBZUAQGDZMWNGXQPYSNWUEGF9BQDFJEQRPEGFGJTQFWO9PWECFGNDH9LW -} diff --git a/runMasternode.bat b/runMasternode.bat deleted file mode 100644 index 9049e5cd1b..0000000000 --- a/runMasternode.bat +++ /dev/null @@ -1,8 +0,0 @@ -@echo off -SETLOCAL EnableDelayedExpansion - -Set PEERING_PORT=14000 - -cd entryNode -start /b "" "go_build_github_com_iotaledger_goshimmer.exe" -autopeering-port %PEERING_PORT% -autopeering-entry-nodes e83c2e1f0ba552cbb6d08d819b7b2196332f8423@127.0.0.1:14000 -node-log-level 4 -node-disable-plugins statusscreen -cd .. \ No newline at end of file diff --git a/runSimulation.bat b/runSimulation.bat deleted file mode 100644 index 02b60bb377..0000000000 --- a/runSimulation.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off -SETLOCAL EnableDelayedExpansion - -Set PEERING_PORT=14000 - -mkdir testNodes -cd testNodes - -FOR /L %%i IN (1,1,100) DO ( - set /A PEERING_PORT=PEERING_PORT+1 - - del /Q /S node%%i - mkdir node%%i - copy ..\entryNode\go_build_github_com_iotaledger_goshimmer.exe node%%i\goshimmer.exe - cd node%%i - start /b "" "goshimmer.exe" -autopeering-port !PEERING_PORT! -autopeering-entry-nodes e83c2e1f0ba552cbb6d08d819b7b2196332f8423@127.0.0.1:14000 -node-log-level 4 -node-disable-plugins statusscreen - cd .. -) - -cd .. \ No newline at end of file From 629d6b5eef45207923e0307b6b989e2bf2a0b2f2 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Sat, 11 Jan 2020 16:35:24 +0100 Subject: [PATCH 096/184] Fix: Use docker specific config (#100) * Use docker specific config * Format JSON --- Dockerfile | 2 ++ docker-compose.yml | 2 +- docker.config.json | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 docker.config.json diff --git a/Dockerfile b/Dockerfile index df77e135bd..381f8824dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,5 +31,7 @@ EXPOSE 14626/tcp # Copy the Pre-built binary file from the previous stage COPY --from=build /go/bin/goshimmer . +# Copy the docker config +COPY docker.config.json config.json ENTRYPOINT ["./goshimmer"] diff --git a/docker-compose.yml b/docker-compose.yml index b4af6fb9da..c119216fda 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,7 @@ version: "3" services: goshimmer: + network_mode: host image: iotaledger/goshimmer build: context: ./ @@ -15,4 +16,3 @@ services: - "14666:14666/tcp" - "14626:14626/udp" - "14626:14626/tcp" - command: "--node.disablePlugins statusscreen" diff --git a/docker.config.json b/docker.config.json new file mode 100644 index 0000000000..37dea0df98 --- /dev/null +++ b/docker.config.json @@ -0,0 +1,36 @@ +{ + "analysis": { + "serveraddress": "ressims.iota.cafe:188", + "serverport": 0 + }, + "autopeering": { + "address": "0.0.0.0", + "entrynodes": [ + "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626" + ], + "port": 14626 + }, + "database": { + "directory": "mainnetdb" + }, + "gossip": { + "port": 14666 + }, + "logger": { + "Level": "info", + "DisableCaller": true, + "DisableStacktrace": false, + "Encoding": "console", + "OutputPaths": [ + "stdout", + "shimmer.log" + ], + "DisableEvents": true + }, + "node": { + "disablePlugins": [ + "statusscreen" + ], + "enablePlugins": [] + } +} From b0bfea5e16423df45dfaef1a96d0a20584806af1 Mon Sep 17 00:00:00 2001 From: capossele Date: Tue, 14 Jan 2020 20:02:58 +0000 Subject: [PATCH 097/184] :construction: WIP --- plugins/tangle/misc.go | 11 ++++++ plugins/tangle/tx_per_address.go | 62 ++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 plugins/tangle/misc.go create mode 100644 plugins/tangle/tx_per_address.go diff --git a/plugins/tangle/misc.go b/plugins/tangle/misc.go new file mode 100644 index 0000000000..08fc8de933 --- /dev/null +++ b/plugins/tangle/misc.go @@ -0,0 +1,11 @@ +package tangle + +import "github.com/iotaledger/iota.go/trinary" + +func databaseKeyForHashPrefixedHash(address trinary.Hash, transactionHash trinary.Hash) []byte { + return append(databaseKeyForHashPrefix(address), trinary.MustTrytesToBytes(transactionHash)...) +} + +func databaseKeyForHashPrefix(hash trinary.Hash) []byte { + return trinary.MustTrytesToBytes(hash) +} diff --git a/plugins/tangle/tx_per_address.go b/plugins/tangle/tx_per_address.go new file mode 100644 index 0000000000..87a568284b --- /dev/null +++ b/plugins/tangle/tx_per_address.go @@ -0,0 +1,62 @@ +package tangle + +import ( + "github.com/iotaledger/goshimmer/packages/database" + "github.com/iotaledger/iota.go/trinary" +) + +var ( + transactionsHashesForAddressDatabase database.Database +) + +func configureTransactionHashesForAddressDatabase() { + if db, err := database.Get("transactionsHashesForAddress"); err != nil { + panic(err) + } else { + transactionsHashesForAddressDatabase = db + } +} + +type TxHashForAddress struct { + Address trinary.Hash + TxHash trinary.Hash +} + +func StoreTransactionHashForAddressInDatabase(address *TxHashForAddress) error { + if err := transactionsHashesForAddressDatabase.Set( + databaseKeyForHashPrefixedHash(address.Address, address.TxHash), + []byte{}, + ); err != nil { + return ErrDatabaseError.Derive(err, "failed to store tx for address in database") + } + log.Info("Stored Address:", address.Address) + log.Info("TxHash:", address.TxHash) + log.Info("txForAddr: ", trinary.MustBytesToTrytes(databaseKeyForHashPrefixedHash(address.Address, address.TxHash), 81)) + return nil +} + +func DeleteTransactionHashForAddressInDatabase(address *TxHashForAddress) error { + if err := transactionsHashesForAddressDatabase.Delete( + databaseKeyForHashPrefixedHash(address.Address, address.TxHash), + ); err != nil { + return ErrDatabaseError.Derive(err, "failed to delete tx for address") + } + + return nil +} + +func ReadTransactionHashesForAddressFromDatabase(address trinary.Hash) ([]trinary.Hash, error) { + var transactionHashes []trinary.Hash + err := transactionsHashesForAddressDatabase.ForEachWithPrefix(databaseKeyForHashPrefix(address), func(key []byte, value []byte) { + log.Info("Len key:", len(key)) + txHash := trinary.MustBytesToTrytes(key)[81:] + log.Info("Len ALL:", len(txHash)) + transactionHashes = append(transactionHashes, txHash) + }) + + if err != nil { + return nil, ErrDatabaseError.Derive(err, "failed to read tx per address from database") + } else { + return transactionHashes, nil + } +} From 05733160270e2cf9684781e3e9a521f035527d8b Mon Sep 17 00:00:00 2001 From: capossele Date: Tue, 14 Jan 2020 21:58:09 +0000 Subject: [PATCH 098/184] :sparkles: adds txs per address --- plugins/tangle/misc.go | 11 ++++++++--- plugins/tangle/plugin.go | 1 + plugins/tangle/solidifier.go | 15 +++++++++++++-- plugins/tangle/solidifier_test.go | 5 +++++ plugins/tangle/tx_per_address.go | 13 ++++++------- 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/plugins/tangle/misc.go b/plugins/tangle/misc.go index 08fc8de933..490f52d74a 100644 --- a/plugins/tangle/misc.go +++ b/plugins/tangle/misc.go @@ -1,11 +1,16 @@ package tangle -import "github.com/iotaledger/iota.go/trinary" +import ( + "github.com/iotaledger/hive.go/typeutils" + "github.com/iotaledger/iota.go/trinary" +) func databaseKeyForHashPrefixedHash(address trinary.Hash, transactionHash trinary.Hash) []byte { - return append(databaseKeyForHashPrefix(address), trinary.MustTrytesToBytes(transactionHash)...) + //return append(databaseKeyForHashPrefix(address), trinary.MustTrytesToBytes(transactionHash)...) + return append(databaseKeyForHashPrefix(address), typeutils.StringToBytes(transactionHash)...) } func databaseKeyForHashPrefix(hash trinary.Hash) []byte { - return trinary.MustTrytesToBytes(hash) + //return trinary.MustTrytesToBytes(hash) + return typeutils.StringToBytes(hash) } diff --git a/plugins/tangle/plugin.go b/plugins/tangle/plugin.go index 50cbafaa0c..483d57b7b0 100644 --- a/plugins/tangle/plugin.go +++ b/plugins/tangle/plugin.go @@ -18,6 +18,7 @@ func configure(*node.Plugin) { configureTransactionMetaDataDatabase() configureApproversDatabase() configureBundleDatabase() + configureTransactionHashesForAddressDatabase() configureSolidifier() } diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index 4b3dd663e5..7e6e8c4f84 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -192,6 +192,17 @@ func processMetaTransaction(metaTransaction *meta_transaction.MetaTransaction) { func processTransaction(transaction *value_transaction.ValueTransaction) { Events.TransactionStored.Trigger(transaction) + // store transaction hash for address in DB + err := StoreTransactionHashForAddressInDatabase( + &TxHashForAddress{ + Address: transaction.GetAddress(), + TxHash: transaction.GetHash(), + }, + ) + if err != nil { + log.Errorw(err.Error()) + } + transactionHash := transaction.GetHash() // register tx as approver for trunk @@ -211,7 +222,7 @@ func processTransaction(transaction *value_transaction.ValueTransaction) { } // update the solidity flags of this transaction and its approvers - _, err := IsSolid(transaction) + _, err = IsSolid(transaction) if err != nil { log.Errorf("Unable to check solidity: %s", err.Error()) return @@ -232,6 +243,6 @@ func requestTransaction(hash trinary.Trytes) { return } - log.Infow("Requesting tx", "hash", hash) + log.Debugw("Requesting tx", "hash", hash) requester.RequestTransaction(hash) } diff --git a/plugins/tangle/solidifier_test.go b/plugins/tangle/solidifier_test.go index 14573d43de..bb677a5c62 100644 --- a/plugins/tangle/solidifier_test.go +++ b/plugins/tangle/solidifier_test.go @@ -46,6 +46,7 @@ func TestSolidifier(t *testing.T) { transaction4 := value_transaction.New() transaction4.SetValue(4) transaction4.SetBranchTransactionHash(transaction3.GetHash()) + transaction4.SetAddress("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") require.NoError(t, transaction4.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE)) // setup event handlers @@ -72,6 +73,10 @@ func TestSolidifier(t *testing.T) { // wait until all are solid wg.Wait() + txAddr, err := ReadTransactionHashesForAddressFromDatabase(transaction4.GetAddress()) + require.NoError(t, err) + require.Equal(t, transaction4.GetHash(), txAddr[0]) + // shutdown test node node.Shutdown() } diff --git a/plugins/tangle/tx_per_address.go b/plugins/tangle/tx_per_address.go index 87a568284b..c344aeda60 100644 --- a/plugins/tangle/tx_per_address.go +++ b/plugins/tangle/tx_per_address.go @@ -2,6 +2,7 @@ package tangle import ( "github.com/iotaledger/goshimmer/packages/database" + "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) @@ -29,9 +30,7 @@ func StoreTransactionHashForAddressInDatabase(address *TxHashForAddress) error { ); err != nil { return ErrDatabaseError.Derive(err, "failed to store tx for address in database") } - log.Info("Stored Address:", address.Address) - log.Info("TxHash:", address.TxHash) - log.Info("txForAddr: ", trinary.MustBytesToTrytes(databaseKeyForHashPrefixedHash(address.Address, address.TxHash), 81)) + return nil } @@ -48,10 +47,10 @@ func DeleteTransactionHashForAddressInDatabase(address *TxHashForAddress) error func ReadTransactionHashesForAddressFromDatabase(address trinary.Hash) ([]trinary.Hash, error) { var transactionHashes []trinary.Hash err := transactionsHashesForAddressDatabase.ForEachWithPrefix(databaseKeyForHashPrefix(address), func(key []byte, value []byte) { - log.Info("Len key:", len(key)) - txHash := trinary.MustBytesToTrytes(key)[81:] - log.Info("Len ALL:", len(txHash)) - transactionHashes = append(transactionHashes, txHash) + k := typeutils.BytesToString(key) + if len(k) > 81 { + transactionHashes = append(transactionHashes, k[81:]) + } }) if err != nil { From ed435f7df56e96f06b855f7725436e259eae7420 Mon Sep 17 00:00:00 2001 From: Angelo Capossele Date: Wed, 15 Jan 2020 09:09:28 +0000 Subject: [PATCH 099/184] Adds a HTTP API to query and create transactions (#95) * :art: moves all webapi into one * :art: adds public key log * :art: changes txRequest to getTrytes * :art: rename packages * :pencil: adds comments * :art: changes status to error * :recycle: removes duration from API - getTrytes converts trits to trytes - set default spammer TPS to 1 Fix: Allow starting a node with gossip disabled (#97) * fix: remove selection flag and use gossip plugin * Upgrade hive.go feat: improve logging feat: improve analysis status chore: remove unused packages (#99) Fix: Use docker specific config (#100) * Use docker specific config * Format JSON :heavy_minus_sign: removes status :art: adds omitempty :lipstick: updates style import :sparkles: adds getNeighbors API :sparkles: adds getTransaction :heavy_minus_sign: removes addEndpoint * :construction: WIP * :construction: WIP * :sparkles: adds txs per address * :sparkles: adds findTransactions API --- main.go | 19 +-- packages/model/value_transaction/constants.go | 2 +- plugins/autopeering/autopeering.go | 1 + plugins/tangle/tx_per_address.go | 1 - plugins/ui/ui.go | 10 +- plugins/webapi-tx-request/plugin.go | 66 ----------- plugins/webapi/api.go | 9 -- .../broadcastData}/plugin.go | 57 +++++---- plugins/webapi/findTransactions/plugin.go | 67 +++++++++++ plugins/webapi/getNeighbors/plugin.go | 112 ++++++++++++++++++ plugins/webapi/getTransactions/plugin.go | 100 ++++++++++++++++ plugins/webapi/getTrytes/plugin.go | 77 ++++++++++++ .../{webapi-gtta => webapi/gtta}/plugin.go | 10 +- .../spammer}/plugin.go | 22 ++-- plugins/webauth/webauth.go | 2 +- 15 files changed, 419 insertions(+), 136 deletions(-) delete mode 100644 plugins/webapi-tx-request/plugin.go delete mode 100644 plugins/webapi/api.go rename plugins/{webapi-send-data => webapi/broadcastData}/plugin.go (55%) create mode 100644 plugins/webapi/findTransactions/plugin.go create mode 100644 plugins/webapi/getNeighbors/plugin.go create mode 100644 plugins/webapi/getTransactions/plugin.go create mode 100644 plugins/webapi/getTrytes/plugin.go rename plugins/{webapi-gtta => webapi/gtta}/plugin.go (68%) rename plugins/{webapi-spammer => webapi/spammer}/plugin.go (67%) diff --git a/main.go b/main.go index 14c100a854..7822849a32 100644 --- a/main.go +++ b/main.go @@ -19,10 +19,13 @@ import ( "github.com/iotaledger/goshimmer/plugins/tipselection" "github.com/iotaledger/goshimmer/plugins/ui" "github.com/iotaledger/goshimmer/plugins/webapi" - webapi_gtta "github.com/iotaledger/goshimmer/plugins/webapi-gtta" - webapi_send_data "github.com/iotaledger/goshimmer/plugins/webapi-send-data" - webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi-spammer" - webapi_tx_request "github.com/iotaledger/goshimmer/plugins/webapi-tx-request" + webapi_broadcastData "github.com/iotaledger/goshimmer/plugins/webapi/broadcastData" + webapi_findTransactions "github.com/iotaledger/goshimmer/plugins/webapi/findTransactions" + webapi_getNeighbors "github.com/iotaledger/goshimmer/plugins/webapi/getNeighbors" + webapi_getTransactions "github.com/iotaledger/goshimmer/plugins/webapi/getTransactions" + webapi_getTrytes "github.com/iotaledger/goshimmer/plugins/webapi/getTrytes" + webapi_gtta "github.com/iotaledger/goshimmer/plugins/webapi/gtta" + webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi/spammer" "github.com/iotaledger/goshimmer/plugins/webauth" "github.com/iotaledger/goshimmer/plugins/zeromq" "github.com/iotaledger/hive.go/node" @@ -53,9 +56,11 @@ func main() { webapi.PLUGIN, webapi_gtta.PLUGIN, webapi_spammer.PLUGIN, - webapi_send_data.PLUGIN, - webapi_tx_request.PLUGIN, - webapi_spammer.PLUGIN, + webapi_broadcastData.PLUGIN, + webapi_getTrytes.PLUGIN, + webapi_getTransactions.PLUGIN, + webapi_findTransactions.PLUGIN, + webapi_getNeighbors.PLUGIN, ui.PLUGIN, webauth.PLUGIN, diff --git a/packages/model/value_transaction/constants.go b/packages/model/value_transaction/constants.go index c602d1ea6d..06a4c749b4 100644 --- a/packages/model/value_transaction/constants.go +++ b/packages/model/value_transaction/constants.go @@ -10,7 +10,7 @@ const ( ADDRESS_OFFSET = 0 VALUE_OFFSET = ADDRESS_END TIMESTAMP_OFFSET = VALUE_END - SIGNATURE_MESSAGE_FRAGMENT_OFFSET = TIMESTAMP_SIZE + SIGNATURE_MESSAGE_FRAGMENT_OFFSET = TIMESTAMP_END ADDRESS_SIZE = 243 VALUE_SIZE = 81 diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 474fe2bd3f..95b2b8e48f 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -100,6 +100,7 @@ func start(shutdownSignal <-chan struct{}) { } log.Infof("Auto Peering started: address=%s", srv.LocalAddr()) + log.Debugf("Auto Peering server started: PubKey=%s", base64.StdEncoding.EncodeToString(local.GetInstance().PublicKey())) <-shutdownSignal log.Info("Stopping Auto Peering server ...") diff --git a/plugins/tangle/tx_per_address.go b/plugins/tangle/tx_per_address.go index c344aeda60..c6bb03cdce 100644 --- a/plugins/tangle/tx_per_address.go +++ b/plugins/tangle/tx_per_address.go @@ -30,7 +30,6 @@ func StoreTransactionHashForAddressInDatabase(address *TxHashForAddress) error { ); err != nil { return ErrDatabaseError.Derive(err, "failed to store tx for address in database") } - return nil } diff --git a/plugins/ui/ui.go b/plugins/ui/ui.go index f4458e5843..9d9b8b1cb5 100644 --- a/plugins/ui/ui.go +++ b/plugins/ui/ui.go @@ -20,18 +20,18 @@ import ( func configure(plugin *node.Plugin) { //webapi.Server.Static("ui", "plugins/ui/src") - webapi.AddEndpoint("ui", func(c echo.Context) error { + webapi.Server.GET("ui", func(c echo.Context) error { return c.HTML(http.StatusOK, files["index.html"]) }) - webapi.AddEndpoint("ui/**", staticFileServer) + webapi.Server.GET("ui/**", staticFileServer) - webapi.AddEndpoint("ws", upgrader) - webapi.AddEndpoint("loghistory", func(c echo.Context) error { + webapi.Server.GET("ws", upgrader) + webapi.Server.GET("loghistory", func(c echo.Context) error { logMutex.RLock() defer logMutex.RUnlock() return c.JSON(http.StatusOK, logHistory) }) - webapi.AddEndpoint("tpsqueue", func(c echo.Context) error { + webapi.Server.GET("tpsqueue", func(c echo.Context) error { tpsQueueMutex.RLock() defer tpsQueueMutex.RUnlock() return c.JSON(http.StatusOK, tpsQueue) diff --git a/plugins/webapi-tx-request/plugin.go b/plugins/webapi-tx-request/plugin.go deleted file mode 100644 index 5f4e428254..0000000000 --- a/plugins/webapi-tx-request/plugin.go +++ /dev/null @@ -1,66 +0,0 @@ -package webapi_tx_request - -import ( - "net/http" - "time" - - "github.com/iotaledger/goshimmer/plugins/tangle" - "github.com/iotaledger/goshimmer/plugins/webapi" - "github.com/iotaledger/hive.go/logger" - "github.com/iotaledger/hive.go/node" - "github.com/labstack/echo" -) - -var PLUGIN = node.NewPlugin("WebAPI Transaction Request Endpoint", node.Enabled, configure) -var log *logger.Logger - -func configure(plugin *node.Plugin) { - log = logger.NewLogger("API-TxRequest") - webapi.AddEndpoint("txRequest", Handler) -} - -func Handler(c echo.Context) error { - c.Set("requestStartTime", time.Now()) - - var request webRequest - if err := c.Bind(&request); err != nil { - log.Info(err.Error()) - return requestFailed(c, err.Error()) - } - log.Info("Received:", request.TransactionHash) - - tx, err := tangle.GetTransaction(request.TransactionHash) - if err != nil { - return requestFailed(c, err.Error()) - } - if tx == nil { - return requestFailed(c, "Tx not found") - } - - return requestSuccessful(c, tx.GetBytes()) -} - -func requestSuccessful(c echo.Context, tx []byte) error { - return c.JSON(http.StatusOK, webResponse{ - Duration: time.Since(c.Get("requestStartTime").(time.Time)).Nanoseconds() / 1e6, - Transaction: tx, - Status: "OK", - }) -} - -func requestFailed(c echo.Context, message string) error { - return c.JSON(http.StatusNotFound, webResponse{ - Duration: time.Since(c.Get("requestStartTime").(time.Time)).Nanoseconds() / 1e6, - Status: message, - }) -} - -type webResponse struct { - Duration int64 `json:"duration"` - Transaction []byte `json:"transaction"` - Status string `json:"status"` -} - -type webRequest struct { - TransactionHash string `json:"transactionHash"` -} diff --git a/plugins/webapi/api.go b/plugins/webapi/api.go deleted file mode 100644 index 5c50d71bc4..0000000000 --- a/plugins/webapi/api.go +++ /dev/null @@ -1,9 +0,0 @@ -package webapi - -import ( - "github.com/labstack/echo" -) - -func AddEndpoint(url string, handler func(c echo.Context) error) { - Server.GET(url, handler) -} diff --git a/plugins/webapi-send-data/plugin.go b/plugins/webapi/broadcastData/plugin.go similarity index 55% rename from plugins/webapi-send-data/plugin.go rename to plugins/webapi/broadcastData/plugin.go index c7029181b5..ef85788270 100644 --- a/plugins/webapi-send-data/plugin.go +++ b/plugins/webapi/broadcastData/plugin.go @@ -1,62 +1,74 @@ -package webapi_send_data +package broadcastData import ( "net/http" "time" - "github.com/iotaledger/goshimmer/plugins/autopeering/local" - "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/tipselection" "github.com/iotaledger/goshimmer/plugins/webapi" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/typeutils" + "github.com/iotaledger/iota.go/address" "github.com/iotaledger/iota.go/trinary" "github.com/labstack/echo" ) -var PLUGIN = node.NewPlugin("WebAPI SendData Endpoint", node.Enabled, configure) +var PLUGIN = node.NewPlugin("WebAPI broadcastData Endpoint", node.Enabled, configure) var log *logger.Logger func configure(plugin *node.Plugin) { - log = logger.NewLogger("API-sendData") - webapi.AddEndpoint("sendData", SendDataHandler) + log = logger.NewLogger("API-broadcastData") + webapi.Server.POST("broadcastData", broadcastData) } -func SendDataHandler(c echo.Context) error { - c.Set("requestStartTime", time.Now()) +// broadcastData creates a data (0-value) transaction given an input of bytes and +// broadcasts it to the node's neighbors. It returns the transaction hash if successful. +func broadcastData(c echo.Context) error { var request webRequest if err := c.Bind(&request); err != nil { log.Info(err.Error()) return requestFailed(c, err.Error()) } - log.Info("Received:", request.Data) + log.Debug("Received - address:", request.Address, " data:", request.Data) tx := value_transaction.New() tx.SetHead(true) tx.SetTail(true) - buffer := make([]byte, 6561) - if len(request.Data) > 6561 { - return requestFailed(c, "data exceding 6561 byte limit") + buffer := make([]byte, 2187) + if len(request.Data) > 2187 { + log.Warn("Data exceeding 2187 byte limit -", len(request.Data)) + return requestFailed(c, "Data exceeding 2187 byte limit") } - copy(buffer, []byte(request.Data)) + copy(buffer, typeutils.StringToBytes(request.Data)) trytes, err := trinary.BytesToTrytes(buffer) if err != nil { - log.Info("Trytes conversion", err.Error()) + log.Warn("Trytes conversion failed", err.Error()) + return requestFailed(c, err.Error()) + } + + err = address.ValidAddress(request.Address) + if err != nil { + log.Warn("Invalid Address:", request.Address) return requestFailed(c, err.Error()) } + tx.SetAddress(request.Address) tx.SetSignatureMessageFragment(trytes) + tx.SetValue(0) tx.SetBranchTransactionHash(tipselection.GetRandomTip()) tx.SetTrunkTransactionHash(tipselection.GetRandomTip()) tx.SetTimestamp(uint(time.Now().Unix())) if err := tx.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE); err != nil { log.Warn("PoW failed", err) + return requestFailed(c, err.Error()) } gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: tx.GetBytes(), Peer: &local.GetInstance().Peer}) @@ -65,25 +77,22 @@ func SendDataHandler(c echo.Context) error { func requestSuccessful(c echo.Context, txHash string) error { return c.JSON(http.StatusCreated, webResponse{ - Duration: time.Since(c.Get("requestStartTime").(time.Time)).Nanoseconds() / 1e6, - TransactionHash: txHash, - Status: "OK", + Hash: txHash, }) } func requestFailed(c echo.Context, message string) error { - return c.JSON(http.StatusNotModified, webResponse{ - Duration: time.Since(c.Get("requestStartTime").(time.Time)).Nanoseconds() / 1e6, - Status: message, + return c.JSON(http.StatusBadRequest, webResponse{ + Error: message, }) } type webResponse struct { - Duration int64 `json:"duration"` - TransactionHash string `json:"transactionHash"` - Status string `json:"status"` + Hash string `json:"hash,omitempty"` + Error string `json:"error,omitempty"` } type webRequest struct { - Data string `json:"data"` + Address string `json:"address"` + Data string `json:"data"` } diff --git a/plugins/webapi/findTransactions/plugin.go b/plugins/webapi/findTransactions/plugin.go new file mode 100644 index 0000000000..cf0f12397c --- /dev/null +++ b/plugins/webapi/findTransactions/plugin.go @@ -0,0 +1,67 @@ +package findTransactions + +import ( + "net/http" + + "github.com/iotaledger/goshimmer/plugins/tangle" + "github.com/iotaledger/goshimmer/plugins/webapi" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/iota.go/trinary" + "github.com/labstack/echo" +) + +var PLUGIN = node.NewPlugin("WebAPI findTransactions Endpoint", node.Enabled, configure) +var log *logger.Logger + +func configure(plugin *node.Plugin) { + log = logger.NewLogger("API-findTransactions") + webapi.Server.GET("findTransactions", findTransactions) +} + +// findTransactions returns the array of transaction hashes for the +// given addresses (in the same order as the parameters). +// If a node doesn't have any transaction hash for a given address in its ledger, +// the value at the index of that address is empty. +func findTransactions(c echo.Context) error { + + var request webRequest + + if err := c.Bind(&request); err != nil { + log.Info(err.Error()) + return requestFailed(c, err.Error()) + } + log.Debug("Received:", request.Addresses) + result := make([][]trinary.Trytes, len(request.Addresses)) + + for i, address := range request.Addresses { + txs, err := tangle.ReadTransactionHashesForAddressFromDatabase(address) + if err != nil { + return requestFailed(c, err.Error()) + } + result[i] = append(result[i], txs...) + } + + return requestSuccessful(c, result) +} + +func requestSuccessful(c echo.Context, txHashes [][]trinary.Trytes) error { + return c.JSON(http.StatusOK, webResponse{ + Transactions: txHashes, + }) +} + +func requestFailed(c echo.Context, message string) error { + return c.JSON(http.StatusNotFound, webResponse{ + Error: message, + }) +} + +type webResponse struct { + Transactions [][]trinary.Trytes `json:"transactions,omitempty"` //string + Error string `json:"error,omitempty"` +} + +type webRequest struct { + Addresses []string `json:"addresses"` +} diff --git a/plugins/webapi/getNeighbors/plugin.go b/plugins/webapi/getNeighbors/plugin.go new file mode 100644 index 0000000000..01457705fc --- /dev/null +++ b/plugins/webapi/getNeighbors/plugin.go @@ -0,0 +1,112 @@ +package getNeighbors + +import ( + "encoding/base64" + "net/http" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" + "github.com/iotaledger/goshimmer/plugins/autopeering" + "github.com/iotaledger/goshimmer/plugins/webapi" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" + "github.com/labstack/echo" +) + +var PLUGIN = node.NewPlugin("WebAPI getNeighbors Endpoint", node.Enabled, configure) +var log *logger.Logger + +func configure(plugin *node.Plugin) { + log = logger.NewLogger("API-getNeighbors") + webapi.Server.GET("getNeighbors", getNeighbors) +} + +// getNeighbors returns the chosen and accepted neighbors of the node +func getNeighbors(c echo.Context) error { + + chosen := []neighbor{} + accepted := []neighbor{} + + if autopeering.Selection == nil { + return requestFailed(c, "Neighbor Selection is not enabled") + } + + for _, peer := range autopeering.Selection.GetOutgoingNeighbors() { + + n := neighbor{ + ID: peer.ID().String(), + PublicKey: base64.StdEncoding.EncodeToString(peer.PublicKey()), + } + n.Services = getServices(peer) + chosen = append(chosen, n) + } + for _, peer := range autopeering.Selection.GetIncomingNeighbors() { + n := neighbor{ + ID: peer.ID().String(), + PublicKey: base64.StdEncoding.EncodeToString(peer.PublicKey()), + } + n.Services = getServices(peer) + accepted = append(accepted, n) + } + return requestSuccessful(c, chosen, accepted) + +} + +func requestSuccessful(c echo.Context, chosen, accepted []neighbor) error { + return c.JSON(http.StatusOK, webResponse{ + Chosen: chosen, + Accepted: accepted, + }) +} + +func requestFailed(c echo.Context, message string) error { + return c.JSON(http.StatusNotFound, webResponse{ + Error: message, + }) +} + +type webResponse struct { + Chosen []neighbor `json:"chosen"` + Accepted []neighbor `json:"accepted"` + Error string `json:"error,omitempty"` +} + +type neighbor struct { + ID string `json:"id"` // comparable node identifier + PublicKey string `json:"publicKey"` // public key used to verify signatures + Services []peerService +} + +type peerService struct { + ID string `json:"id"` // ID of the service + Address string `json:"address"` // network address of the service +} + +func getServices(p *peer.Peer) []peerService { + services := []peerService{} + peeringService := p.Services().Get(service.PeeringKey) + if peeringService != nil { + services = append(services, peerService{ + ID: "peering", + Address: peeringService.String(), + }) + } + + gossipService := p.Services().Get(service.GossipKey) + if gossipService != nil { + services = append(services, peerService{ + ID: "gossip", + Address: gossipService.String(), + }) + } + + fpcService := p.Services().Get(service.FPCKey) + if fpcService != nil { + services = append(services, peerService{ + ID: "FPC", + Address: fpcService.String(), + }) + } + + return services +} diff --git a/plugins/webapi/getTransactions/plugin.go b/plugins/webapi/getTransactions/plugin.go new file mode 100644 index 0000000000..2dfb696f2d --- /dev/null +++ b/plugins/webapi/getTransactions/plugin.go @@ -0,0 +1,100 @@ +package getTransactions + +import ( + "net/http" + + "github.com/iotaledger/goshimmer/plugins/tangle" + "github.com/iotaledger/goshimmer/plugins/webapi" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/iota.go/trinary" + "github.com/labstack/echo" +) + +var PLUGIN = node.NewPlugin("WebAPI getTransaction Endpoint", node.Enabled, configure) +var log *logger.Logger + +func configure(plugin *node.Plugin) { + log = logger.NewLogger("API-getTransactions") + webapi.Server.GET("getTransactions", getTransactions) +} + +// getTransactions returns the array of transactions for the +// given transaction hashes (in the same order as the parameters). +// If a node doesn't have the transaction for a given transaction hash in its ledger, +// the value at the index of that transaction hash is empty. +func getTransactions(c echo.Context) error { + + var request webRequest + result := []transaction{} + + if err := c.Bind(&request); err != nil { + log.Info(err.Error()) + return requestFailed(c, err.Error()) + } + log.Debug("Received:", request.Hashes) + + for _, hash := range request.Hashes { + tx, err := tangle.GetTransaction(hash) + if err != nil { + return requestFailed(c, err.Error()) + } + if tx != nil { + t := transaction{ + Hash: tx.GetHash(), + WeightMagnitude: tx.GetWeightMagnitude(), + TrunkTransactionHash: tx.GetTrunkTransactionHash(), + BranchTransactionHash: tx.GetBranchTransactionHash(), + Head: tx.IsHead(), + Tail: tx.IsTail(), + Nonce: tx.GetNonce(), + Address: tx.GetAddress(), + Value: tx.GetValue(), + Timestamp: tx.GetTimestamp(), + SignatureMessageFragment: tx.GetSignatureMessageFragment(), + } + result = append(result, t) + } else { + //tx not found + result = append(result, transaction{}) + } + + } + + return requestSuccessful(c, result) +} + +func requestSuccessful(c echo.Context, txs []transaction) error { + return c.JSON(http.StatusOK, webResponse{ + Transactions: txs, + }) +} + +func requestFailed(c echo.Context, message string) error { + return c.JSON(http.StatusNotFound, webResponse{ + Error: message, + }) +} + +type webResponse struct { + Transactions []transaction `json:"transaction,omitempty"` + Error string `json:"error,omitempty"` +} + +type webRequest struct { + Hashes []string `json:"hashes"` +} + +type transaction struct { + Hash trinary.Trytes `json:"hash,omitempty"` + WeightMagnitude int `json:"weightMagnitude,omitempty"` + TrunkTransactionHash trinary.Trytes `json:"trunkTransactionHash,omitempty"` + BranchTransactionHash trinary.Trytes `json:"branchTransactionHash,omitempty"` + Head bool `json:"head,omitempty"` + Tail bool `json:"tail,omitempty"` + Nonce trinary.Trytes `json:"nonce,omitempty"` + Address trinary.Trytes `json:"address,omitempty"` + Value int64 `json:"value,omitempty"` + Timestamp uint `json:"timestamp,omitempty"` + SignatureMessageFragment trinary.Trytes `json:"signatureMessageFragment,omitempty"` +} diff --git a/plugins/webapi/getTrytes/plugin.go b/plugins/webapi/getTrytes/plugin.go new file mode 100644 index 0000000000..4dac6f1b97 --- /dev/null +++ b/plugins/webapi/getTrytes/plugin.go @@ -0,0 +1,77 @@ +package getTrytes + +import ( + "net/http" + + "github.com/iotaledger/goshimmer/plugins/tangle" + "github.com/iotaledger/goshimmer/plugins/webapi" + "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/iota.go/trinary" + "github.com/labstack/echo" +) + +var PLUGIN = node.NewPlugin("WebAPI getTrytes Endpoint", node.Enabled, configure) +var log *logger.Logger + +func configure(plugin *node.Plugin) { + log = logger.NewLogger("API-getTrytes") + webapi.Server.GET("getTrytes", getTrytes) +} + +// getTrytes returns the array of transaction trytes for the +// given transaction hashes (in the same order as the parameters). +// If a node doesn't have the trytes for a given transaction hash in its ledger, +// the value at the index of that transaction hash is empty. +func getTrytes(c echo.Context) error { + + var request webRequest + result := []trinary.Trytes{} + if err := c.Bind(&request); err != nil { + log.Info(err.Error()) + return requestFailed(c, err.Error()) + } + log.Debug("Received:", request.Hashes) + + for _, hash := range request.Hashes { + tx, err := tangle.GetTransaction(hash) + if err != nil { + return requestFailed(c, err.Error()) + } + if tx != nil { + trytes, err := trinary.TritsToTrytes(tx.GetTrits()) + // Returns an error if len(tx.GetTrits())%3!=0 + if err != nil { + return requestFailed(c, err.Error()) + } + result = append(result, trytes) + } else { + //tx not found + result = append(result, "") + } + + } + + return requestSuccessful(c, result) +} + +func requestSuccessful(c echo.Context, txTrytes []trinary.Trytes) error { + return c.JSON(http.StatusOK, webResponse{ + Trytes: txTrytes, + }) +} + +func requestFailed(c echo.Context, message string) error { + return c.JSON(http.StatusNotFound, webResponse{ + Error: message, + }) +} + +type webResponse struct { + Trytes []trinary.Trytes `json:"trytes,omitempty"` //string + Error string `json:"error,omitempty"` +} + +type webRequest struct { + Hashes []string `json:"hashes"` +} diff --git a/plugins/webapi-gtta/plugin.go b/plugins/webapi/gtta/plugin.go similarity index 68% rename from plugins/webapi-gtta/plugin.go rename to plugins/webapi/gtta/plugin.go index c873f7a402..3234ddc61d 100644 --- a/plugins/webapi-gtta/plugin.go +++ b/plugins/webapi/gtta/plugin.go @@ -1,8 +1,7 @@ -package webapi_gtta +package gtta import ( "net/http" - "time" "github.com/iotaledger/goshimmer/plugins/tipselection" "github.com/iotaledger/goshimmer/plugins/webapi" @@ -11,25 +10,22 @@ import ( "github.com/labstack/echo" ) -var PLUGIN = node.NewPlugin("WebAPI GTTA Endpoint", node.Enabled, func(plugin *node.Plugin) { - webapi.AddEndpoint("getTransactionsToApprove", Handler) +var PLUGIN = node.NewPlugin("WebAPI GTTA Endpoint", node.Disabled, func(plugin *node.Plugin) { + webapi.Server.GET("getTransactionsToApprove", Handler) }) func Handler(c echo.Context) error { - start := time.Now() branchTransactionHash := tipselection.GetRandomTip() trunkTransactionHash := tipselection.GetRandomTip() return c.JSON(http.StatusOK, webResponse{ - Duration: time.Since(start).Nanoseconds() / 1e6, BranchTransaction: branchTransactionHash, TrunkTransaction: trunkTransactionHash, }) } type webResponse struct { - Duration int64 `json:"duration"` BranchTransaction trinary.Trytes `json:"branchTransaction"` TrunkTransaction trinary.Trytes `json:"trunkTransaction"` } diff --git a/plugins/webapi-spammer/plugin.go b/plugins/webapi/spammer/plugin.go similarity index 67% rename from plugins/webapi-spammer/plugin.go rename to plugins/webapi/spammer/plugin.go index fb169eb86b..fe29875dad 100644 --- a/plugins/webapi-spammer/plugin.go +++ b/plugins/webapi/spammer/plugin.go @@ -1,8 +1,7 @@ -package webapi_spammer +package spammer import ( "net/http" - "time" "github.com/iotaledger/goshimmer/packages/transactionspammer" "github.com/iotaledger/goshimmer/plugins/webapi" @@ -13,11 +12,10 @@ import ( var PLUGIN = node.NewPlugin("Spammer", node.Disabled, configure) func configure(plugin *node.Plugin) { - webapi.AddEndpoint("spammer", WebApiHandler) + webapi.Server.GET("spammer", WebApiHandler) } func WebApiHandler(c echo.Context) error { - c.Set("requestStartTime", time.Now()) var request webRequest if err := c.Bind(&request); err != nil { @@ -27,7 +25,7 @@ func WebApiHandler(c echo.Context) error { switch request.Cmd { case "start": if request.Tps == 0 { - request.Tps = 1000 + request.Tps = 1 } transactionspammer.Stop() @@ -47,24 +45,18 @@ func WebApiHandler(c echo.Context) error { func requestSuccessful(c echo.Context, message string) error { return c.JSON(http.StatusOK, webResponse{ - Duration: time.Since(c.Get("requestStartTime").(time.Time)).Nanoseconds() / 1e6, - Status: "success", - Message: message, + Message: message, }) } func requestFailed(c echo.Context, message string) error { - return c.JSON(http.StatusOK, webResponse{ - Duration: time.Since(c.Get("requestStartTime").(time.Time)).Nanoseconds() / 1e6, - Status: "failed", - Message: message, + return c.JSON(http.StatusNotFound, webResponse{ + Message: message, }) } type webResponse struct { - Duration int64 `json:"duration"` - Status string `json:"status"` - Message string `json:"message"` + Message string `json:"message"` } type webRequest struct { diff --git a/plugins/webauth/webauth.go b/plugins/webauth/webauth.go index b2c898a873..2b9048781f 100644 --- a/plugins/webauth/webauth.go +++ b/plugins/webauth/webauth.go @@ -41,7 +41,7 @@ func configure(plugin *node.Plugin) { func run(plugin *node.Plugin) { daemon.BackgroundWorker("webauth", func(shutdownSignal <-chan struct{}) { - webapi.AddEndpoint("login", func(c echo.Context) error { + webapi.Server.GET("login", func(c echo.Context) error { username := c.FormValue("username") password := c.FormValue("password") uiUser := os.Getenv("UI_USER") From c0fc4fc0cb67bab34ec8455ae8c1726a597acadd Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Wed, 15 Jan 2020 10:43:38 +0100 Subject: [PATCH 100/184] makes shutdown routines cleaner (#115) Signed-off-by: Luca Moser --- packages/shutdown/order.go | 18 +++++++++++++++ .../transactionspammer/transactionspammer.go | 3 ++- plugins/analysis/client/plugin.go | 3 ++- plugins/analysis/server/plugin.go | 3 ++- .../webinterface/httpserver/plugin.go | 3 ++- plugins/autopeering/plugin.go | 3 ++- plugins/bundleprocessor/plugin.go | 5 +++-- plugins/dashboard/plugin.go | 3 ++- plugins/gossip/plugin.go | 3 ++- plugins/graph/plugin.go | 5 +++-- plugins/metrics/plugin.go | 3 ++- plugins/statusscreen-tps/plugin.go | 3 ++- plugins/statusscreen/plugin.go | 5 +++-- plugins/tangle/approvers.go | 22 ++++++++++++------- plugins/tangle/bundle.go | 22 ++++++++++++------- plugins/tangle/plugin.go | 19 ++++++++++++++++ plugins/tangle/solidifier.go | 3 ++- plugins/tangle/transaction.go | 22 ++++++++++++------- plugins/tangle/transaction_metadata.go | 22 ++++++++++++------- plugins/ui/ui.go | 3 ++- plugins/webapi/plugin.go | 3 ++- plugins/webauth/webauth.go | 3 ++- plugins/zeromq/plugin.go | 3 ++- 23 files changed, 130 insertions(+), 52 deletions(-) create mode 100644 packages/shutdown/order.go diff --git a/packages/shutdown/order.go b/packages/shutdown/order.go new file mode 100644 index 0000000000..b16bc91e04 --- /dev/null +++ b/packages/shutdown/order.go @@ -0,0 +1,18 @@ +package shutdown + +const ( + ShutdownPriorityTangle = iota + ShutdownPrioritySolidifier + ShutdownPriorityBundleProcessor + ShutdownPriorityAnalysis + ShutdownPriorityMetrics + ShutdownPriorityWebAPI + ShutdownPriorityGossip + ShutdownPriorityZMQ + ShutdownPriorityAutopeering + ShutdownPriorityGraph + ShutdownPriorityUI + ShutdownPriorityDashboard + ShutdownPriorityTangleSpammer + ShutdownPriorityStatusScreen +) diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index a2cae4aefa..dcfb1da1ed 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -4,6 +4,7 @@ import ( "sync" "time" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/packages/gossip" @@ -79,7 +80,7 @@ func Start(tps uint) { } } } - }) + }, shutdown.ShutdownPriorityTangleSpammer) } func Stop() { diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index 506982347c..ccec3955a9 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -8,6 +8,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/selection" "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/parameter" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/analysis/types/addnode" "github.com/iotaledger/goshimmer/plugins/analysis/types/connectnodes" "github.com/iotaledger/goshimmer/plugins/analysis/types/disconnectnodes" @@ -50,7 +51,7 @@ func Run(plugin *node.Plugin) { } } } - }) + }, shutdown.ShutdownPriorityAnalysis) } func getEventDispatchers(conn *network.ManagedConnection) *EventDispatchers { diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index 35973f84a6..a46f4c2fe9 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -7,6 +7,7 @@ import ( "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/network/tcp" "github.com/iotaledger/goshimmer/packages/parameter" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/analysis/types/addnode" "github.com/iotaledger/goshimmer/plugins/analysis/types/connectnodes" "github.com/iotaledger/goshimmer/plugins/analysis/types/disconnectnodes" @@ -45,7 +46,7 @@ func Run(plugin *node.Plugin) { go server.Listen(parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) <-shutdownSignal Shutdown() - }) + }, shutdown.ShutdownPriorityAnalysis) } func Shutdown() { diff --git a/plugins/analysis/webinterface/httpserver/plugin.go b/plugins/analysis/webinterface/httpserver/plugin.go index 0299e173ed..fa3f2b501b 100644 --- a/plugins/analysis/webinterface/httpserver/plugin.go +++ b/plugins/analysis/webinterface/httpserver/plugin.go @@ -4,6 +4,7 @@ import ( "net/http" "time" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/node" "golang.org/x/net/context" @@ -30,5 +31,5 @@ func Run(plugin *node.Plugin) { ctx, cancel := context.WithTimeout(context.Background(), 0*time.Second) defer cancel() httpServer.Shutdown(ctx) - }) + }, shutdown.ShutdownPriorityAnalysis) } diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index 04321f98b2..c6e9ec88f5 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -5,6 +5,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/selection" "github.com/iotaledger/goshimmer/packages/gossip" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" @@ -23,7 +24,7 @@ func configure(*node.Plugin) { } func run(*node.Plugin) { - if err := daemon.BackgroundWorker(name, start); err != nil { + if err := daemon.BackgroundWorker(name, start, shutdown.ShutdownPriorityAutopeering); err != nil { log.Errorf("Failed to start as daemon: %s", err) } } diff --git a/plugins/bundleprocessor/plugin.go b/plugins/bundleprocessor/plugin.go index ad4ecb52eb..822a2952df 100644 --- a/plugins/bundleprocessor/plugin.go +++ b/plugins/bundleprocessor/plugin.go @@ -3,6 +3,7 @@ package bundleprocessor import ( "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" @@ -37,7 +38,7 @@ func run(*node.Plugin) { log.Info("Stopping Bundle Processor ...") workerPool.StopAndWait() log.Info("Stopping Bundle Processor ... done") - }) + }, shutdown.ShutdownPriorityBundleProcessor) log.Info("Starting Value Bundle Processor ...") @@ -48,5 +49,5 @@ func run(*node.Plugin) { log.Info("Stopping Value Bundle Processor ...") valueBundleProcessorWorkerPool.StopAndWait() log.Info("Stopping Value Bundle Processor ... done") - }) + }, shutdown.ShutdownPriorityBundleProcessor) } diff --git a/plugins/dashboard/plugin.go b/plugins/dashboard/plugin.go index 4321e0b5c5..5fa26f6982 100644 --- a/plugins/dashboard/plugin.go +++ b/plugins/dashboard/plugin.go @@ -4,6 +4,7 @@ import ( "net/http" "time" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/metrics" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" @@ -48,5 +49,5 @@ func run(plugin *node.Plugin) { ctx, cancel := context.WithTimeout(context.Background(), 0*time.Second) defer cancel() _ = server.Shutdown(ctx) - }) + }, shutdown.ShutdownPriorityDashboard) } diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 0a4f61e4b8..3829565b38 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -5,6 +5,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/selection" "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" @@ -24,7 +25,7 @@ func configure(*node.Plugin) { } func run(*node.Plugin) { - if err := daemon.BackgroundWorker(name, start); err != nil { + if err := daemon.BackgroundWorker(name, start, shutdown.ShutdownPriorityGossip); err != nil { log.Errorf("Failed to start as daemon: %s", err) } } diff --git a/plugins/graph/plugin.go b/plugins/graph/plugin.go index 39e3df4703..f6dcc3eea3 100644 --- a/plugins/graph/plugin.go +++ b/plugins/graph/plugin.go @@ -7,6 +7,7 @@ import ( "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/parameter" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/tangle" "golang.org/x/net/context" @@ -105,7 +106,7 @@ func run(plugin *node.Plugin) { tangle.Events.TransactionStored.Detach(notifyNewTx) newTxWorkerPool.Stop() log.Info("Stopping Graph[NewTxWorker] ... done") - }) + }, shutdown.ShutdownPriorityGraph) daemon.BackgroundWorker("Graph Webserver", func(shutdownSignal <-chan struct{}) { go socketioServer.Serve() @@ -128,5 +129,5 @@ func run(plugin *node.Plugin) { _ = server.Shutdown(ctx) log.Info("Stopping Graph ... done") - }) + }, shutdown.ShutdownPriorityGraph) } diff --git a/plugins/metrics/plugin.go b/plugins/metrics/plugin.go index 4774c72d3c..3624874e70 100644 --- a/plugins/metrics/plugin.go +++ b/plugins/metrics/plugin.go @@ -4,6 +4,7 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/gossip" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/node" @@ -21,5 +22,5 @@ func run(plugin *node.Plugin) { // create a background worker that "measures" the TPS value every second daemon.BackgroundWorker("Metrics TPS Updater", func(shutdownSignal <-chan struct{}) { timeutil.Ticker(measureReceivedTPS, 1*time.Second, shutdownSignal) - }) + }, shutdown.ShutdownPriorityMetrics) } diff --git a/plugins/statusscreen-tps/plugin.go b/plugins/statusscreen-tps/plugin.go index c4909e45e6..dbe6b89276 100644 --- a/plugins/statusscreen-tps/plugin.go +++ b/plugins/statusscreen-tps/plugin.go @@ -7,6 +7,7 @@ import ( "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/statusscreen" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" @@ -51,5 +52,5 @@ var PLUGIN = node.NewPlugin("Statusscreen TPS", node.Enabled, func(plugin *node. atomic.StoreUint64(&solidTpsCounter, 0) } } - }) + }, shutdown.ShutdownPriorityStatusScreen) }) diff --git a/plugins/statusscreen/plugin.go b/plugins/statusscreen/plugin.go index f79ca05ebf..e117234f75 100644 --- a/plugins/statusscreen/plugin.go +++ b/plugins/statusscreen/plugin.go @@ -3,6 +3,7 @@ package statusscreen import ( "time" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" @@ -57,7 +58,7 @@ func run(*node.Plugin) { return } } - }); err != nil { + }, shutdown.ShutdownPriorityStatusScreen); err != nil { log.Errorf("Failed to start as daemon: %s", err) return } @@ -72,7 +73,7 @@ func run(*node.Plugin) { if err := app.SetRoot(frame, true).SetFocus(frame).Run(); err != nil { log.Errorf("Error running application: %s", err) } - }); err != nil { + }, shutdown.ShutdownPriorityStatusScreen); err != nil { log.Errorf("Failed to start as daemon: %s", err) close(stopped) } diff --git a/plugins/tangle/approvers.go b/plugins/tangle/approvers.go index 38d44aa908..166b1a7ed0 100644 --- a/plugins/tangle/approvers.go +++ b/plugins/tangle/approvers.go @@ -2,9 +2,9 @@ package tangle import ( "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/approvers" + "github.com/iotaledger/hive.go/lru_cache" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) @@ -50,20 +50,26 @@ func StoreApprovers(approvers *approvers.Approvers) { // region lru cache //////////////////////////////////////////////////////////////////////////////////////////////////// -var approversCache = datastructure.NewLRUCache(APPROVERS_CACHE_SIZE, &datastructure.LRUCacheOptions{ - EvictionCallback: onEvictApprovers, +var approversCache = lru_cache.NewLRUCache(APPROVERS_CACHE_SIZE, &lru_cache.LRUCacheOptions{ + EvictionCallback: onEvictApprovers, + EvictionBatchSize: 100, }) -func onEvictApprovers(_ interface{}, value interface{}) { - if evictedApprovers := value.(*approvers.Approvers); evictedApprovers.GetModified() { - go func(evictedApprovers *approvers.Approvers) { - if err := storeApproversInDatabase(evictedApprovers); err != nil { +func onEvictApprovers(_ interface{}, values interface{}) { + // TODO: replace with apply + for _, obj := range values.([]interface{}) { + if approvers := obj.(*approvers.Approvers); approvers.GetModified() { + if err := storeApproversInDatabase(approvers); err != nil { panic(err) } - }(evictedApprovers) + } } } +func FlushApproversCache() { + approversCache.DeleteAll() +} + const ( APPROVERS_CACHE_SIZE = 50000 ) diff --git a/plugins/tangle/bundle.go b/plugins/tangle/bundle.go index fa607ba127..ca7208a932 100644 --- a/plugins/tangle/bundle.go +++ b/plugins/tangle/bundle.go @@ -2,9 +2,9 @@ package tangle import ( "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/bundle" + "github.com/iotaledger/hive.go/lru_cache" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) @@ -54,20 +54,26 @@ func StoreBundle(bundle *bundle.Bundle) { // region lru cache //////////////////////////////////////////////////////////////////////////////////////////////////// -var bundleCache = datastructure.NewLRUCache(BUNDLE_CACHE_SIZE, &datastructure.LRUCacheOptions{ - EvictionCallback: onEvictBundle, +var bundleCache = lru_cache.NewLRUCache(BUNDLE_CACHE_SIZE, &lru_cache.LRUCacheOptions{ + EvictionCallback: onEvictBundles, + EvictionBatchSize: 100, }) -func onEvictBundle(_ interface{}, value interface{}) { - if evictedBundle := value.(*bundle.Bundle); evictedBundle.GetModified() { - go func(evictedBundle *bundle.Bundle) { - if err := storeBundleInDatabase(evictedBundle); err != nil { +func onEvictBundles(_ interface{}, values interface{}) { + // TODO: replace with apply + for _, obj := range values.([]interface{}) { + if bndl := obj.(*bundle.Bundle); bndl.GetModified() { + if err := storeBundleInDatabase(bndl); err != nil { panic(err) } - }(evictedBundle) + } } } +func FlushBundleCache() { + bundleCache.DeleteAll() +} + const ( BUNDLE_CACHE_SIZE = 500 ) diff --git a/plugins/tangle/plugin.go b/plugins/tangle/plugin.go index 483d57b7b0..252c2b987d 100644 --- a/plugins/tangle/plugin.go +++ b/plugins/tangle/plugin.go @@ -1,6 +1,9 @@ package tangle import ( + "github.com/iotaledger/goshimmer/packages/database" + "github.com/iotaledger/goshimmer/packages/shutdown" + "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" "github.com/iotaledger/iota.go/trinary" @@ -20,6 +23,22 @@ func configure(*node.Plugin) { configureBundleDatabase() configureTransactionHashesForAddressDatabase() configureSolidifier() + + daemon.BackgroundWorker("Cache Flush", func(shutdownSignal <-chan struct{}) { + <-shutdownSignal + + log.Info("Flushing caches to database...") + FlushTransactionCache() + FlushTransactionMetadata() + FlushApproversCache() + FlushBundleCache() + log.Info("Flushing caches to database... done") + + log.Info("Syncing database to disk...") + database.GetBadgerInstance().Close() + log.Info("Syncing database to disk... done") + }, shutdown.ShutdownPriorityTangle) + } func run(*node.Plugin) { diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index 7e6e8c4f84..2ab00159f6 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -10,6 +10,7 @@ import ( "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/packages/workerpool" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" @@ -62,7 +63,7 @@ func runSolidifier() { log.Info("Stopping Solidifier ...") workerPool.StopAndWait() log.Info("Stopping Solidifier ... done") - }) + }, shutdown.ShutdownPrioritySolidifier) } // endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/tangle/transaction.go b/plugins/tangle/transaction.go index 31edfc4f8c..0de47154fd 100644 --- a/plugins/tangle/transaction.go +++ b/plugins/tangle/transaction.go @@ -2,9 +2,9 @@ package tangle import ( "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/hive.go/lru_cache" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) @@ -51,20 +51,26 @@ func StoreTransaction(transaction *value_transaction.ValueTransaction) { // region lru cache //////////////////////////////////////////////////////////////////////////////////////////////////// -var transactionCache = datastructure.NewLRUCache(TRANSACTION_CACHE_SIZE, &datastructure.LRUCacheOptions{ - EvictionCallback: onEvictTransaction, +var transactionCache = lru_cache.NewLRUCache(TRANSACTION_CACHE_SIZE, &lru_cache.LRUCacheOptions{ + EvictionCallback: onEvictTransactions, + EvictionBatchSize: 200, }) -func onEvictTransaction(_ interface{}, value interface{}) { - if evictedTransaction := value.(*value_transaction.ValueTransaction); evictedTransaction.GetModified() { - go func(evictedTransaction *value_transaction.ValueTransaction) { - if err := storeTransactionInDatabase(evictedTransaction); err != nil { +func onEvictTransactions(_ interface{}, values interface{}) { + // TODO: replace with apply + for _, obj := range values.([]interface{}) { + if tx := obj.(*value_transaction.ValueTransaction); tx.GetModified() { + if err := storeTransactionInDatabase(tx); err != nil { panic(err) } - }(evictedTransaction) + } } } +func FlushTransactionCache() { + transactionCache.DeleteAll() +} + const ( TRANSACTION_CACHE_SIZE = 500 ) diff --git a/plugins/tangle/transaction_metadata.go b/plugins/tangle/transaction_metadata.go index 6713ecc8b0..0ea3c9828c 100644 --- a/plugins/tangle/transaction_metadata.go +++ b/plugins/tangle/transaction_metadata.go @@ -2,9 +2,9 @@ package tangle import ( "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/datastructure" "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" + "github.com/iotaledger/hive.go/lru_cache" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) @@ -51,20 +51,26 @@ func StoreTransactionMetadata(transactionMetadata *transactionmetadata.Transacti // region lru cache //////////////////////////////////////////////////////////////////////////////////////////////////// -var transactionMetadataCache = datastructure.NewLRUCache(TRANSACTION_METADATA_CACHE_SIZE, &datastructure.LRUCacheOptions{ - EvictionCallback: onEvictTransactionMetadata, +var transactionMetadataCache = lru_cache.NewLRUCache(TRANSACTION_METADATA_CACHE_SIZE, &lru_cache.LRUCacheOptions{ + EvictionCallback: onEvictTransactionMetadatas, + EvictionBatchSize: 200, }) -func onEvictTransactionMetadata(_ interface{}, value interface{}) { - if evictedTransactionMetadata := value.(*transactionmetadata.TransactionMetadata); evictedTransactionMetadata.GetModified() { - go func(evictedTransactionMetadata *transactionmetadata.TransactionMetadata) { - if err := storeTransactionMetadataInDatabase(evictedTransactionMetadata); err != nil { +func onEvictTransactionMetadatas(_ interface{}, values interface{}) { + // TODO: replace with apply + for _, obj := range values.([]interface{}) { + if txMetadata := obj.(*transactionmetadata.TransactionMetadata); txMetadata.GetModified() { + if err := storeTransactionMetadataInDatabase(txMetadata); err != nil { panic(err) } - }(evictedTransactionMetadata) + } } } +func FlushTransactionMetadata() { + transactionCache.DeleteAll() +} + const ( TRANSACTION_METADATA_CACHE_SIZE = 500 ) diff --git a/plugins/ui/ui.go b/plugins/ui/ui.go index 9d9b8b1cb5..3c41121078 100644 --- a/plugins/ui/ui.go +++ b/plugins/ui/ui.go @@ -8,6 +8,7 @@ import ( "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/goshimmer/plugins/webapi" "github.com/iotaledger/hive.go/daemon" @@ -86,7 +87,7 @@ func run(plugin *node.Plugin) { wsMutex.Unlock() } } - }) + }, shutdown.ShutdownPriorityUI) } // PLUGIN plugs the UI into the main program diff --git a/plugins/webapi/plugin.go b/plugins/webapi/plugin.go index 6cd2e037b3..c7bd41f334 100644 --- a/plugins/webapi/plugin.go +++ b/plugins/webapi/plugin.go @@ -4,6 +4,7 @@ import ( "context" "time" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" @@ -43,5 +44,5 @@ func run(plugin *node.Plugin) { if err := Server.Shutdown(ctx); err != nil { log.Errorf("Couldn't stop server cleanly: %s", err.Error()) } - }) + }, shutdown.ShutdownPriorityWebAPI) } diff --git a/plugins/webauth/webauth.go b/plugins/webauth/webauth.go index 2b9048781f..aa7ba5b340 100644 --- a/plugins/webauth/webauth.go +++ b/plugins/webauth/webauth.go @@ -6,6 +6,7 @@ import ( "strings" "time" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/webapi" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/node" @@ -66,7 +67,7 @@ func run(plugin *node.Plugin) { "token": t, }) }) - }) + }, shutdown.ShutdownPriorityWebAPI) } // PLUGIN plugs the UI into the main program diff --git a/plugins/zeromq/plugin.go b/plugins/zeromq/plugin.go index 11ddb33c23..0bf553b331 100644 --- a/plugins/zeromq/plugin.go +++ b/plugins/zeromq/plugin.go @@ -7,6 +7,7 @@ import ( "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/parameter" + "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" @@ -53,7 +54,7 @@ func run(plugin *node.Plugin) { } else { log.Info("Stopping ZeroMQ Publisher ... done") } - }) + }, shutdown.ShutdownPriorityZMQ) } // Start the zmq publisher. From 3f7ac60ec00bcf54e33285ba5143c331fd65df7f Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Wed, 15 Jan 2020 10:56:35 +0100 Subject: [PATCH 101/184] Adds a client lib as a wrapper for the HTTP API (#118) * :art: moves all webapi into one * :art: adds public key log * :art: changes txRequest to getTrytes * :art: rename packages * :pencil: adds comments * :art: changes status to error * :recycle: removes duration from API - getTrytes converts trits to trytes - set default spammer TPS to 1 Fix: Allow starting a node with gossip disabled (#97) * fix: remove selection flag and use gossip plugin * Upgrade hive.go feat: improve logging feat: improve analysis status chore: remove unused packages (#99) Fix: Use docker specific config (#100) * Use docker specific config * Format JSON :heavy_minus_sign: removes status :art: adds omitempty :lipstick: updates style import :sparkles: adds getNeighbors API :sparkles: adds getTransaction :heavy_minus_sign: removes addEndpoint * ports glumb plugin from Hornet to GoShimmer * :construction: WIP * implements HTTP API wrapper client lib * removes empty lines * clean line in autopeering * normalize client lib imports Co-authored-by: Angelo Capossele --- client/lib.go | 229 ++++++++++++++++++++++ main.go | 1 + plugins/graph/README.md | 9 + plugins/webapi/broadcastData/plugin.go | 12 +- plugins/webapi/findTransactions/plugin.go | 10 +- plugins/webapi/getNeighbors/plugin.go | 22 +-- plugins/webapi/getTransactions/plugin.go | 23 +-- plugins/webapi/getTrytes/plugin.go | 10 +- plugins/webapi/gtta/plugin.go | 4 +- plugins/webapi/spammer/plugin.go | 10 +- 10 files changed, 286 insertions(+), 44 deletions(-) create mode 100644 client/lib.go create mode 100644 plugins/graph/README.md diff --git a/client/lib.go b/client/lib.go new file mode 100644 index 0000000000..4bc52b4bfb --- /dev/null +++ b/client/lib.go @@ -0,0 +1,229 @@ +// Implements a very simple wrapper for GoShimmer's HTTP API . +package shimmer + +import ( + "bytes" + "encoding/json" + "fmt" + "io/ioutil" + "net/http" + + "github.com/iotaledger/goshimmer/packages/errors" + webapi_broadcastData "github.com/iotaledger/goshimmer/plugins/webapi/broadcastData" + webapi_findTransactions "github.com/iotaledger/goshimmer/plugins/webapi/findTransactions" + webapi_getNeighbors "github.com/iotaledger/goshimmer/plugins/webapi/getNeighbors" + webapi_getTransactions "github.com/iotaledger/goshimmer/plugins/webapi/getTransactions" + webapi_getTrytes "github.com/iotaledger/goshimmer/plugins/webapi/getTrytes" + webapi_gtta "github.com/iotaledger/goshimmer/plugins/webapi/gtta" + webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi/spammer" + "github.com/iotaledger/iota.go/consts" + "github.com/iotaledger/iota.go/guards" + "github.com/iotaledger/iota.go/trinary" +) + +var ( + ErrBadRequest = errors.New("bad request") + ErrInternalServerError = errors.New("internal server error") + ErrNotFound = errors.New("not found") + ErrUnknownError = errors.New("unknown error") +) + +const ( + routeBroadcastData = "broadcastData" + routeGetTrytes = "getTrytes" + routeGetTransactions = "getTransactions" + routeFindTransactions = "findTransactions" + routeGetNeighbors = "getNeighbors" + routeGetTransactionsToApprove = "getTransactionsToApprove" + routeSpammer = "spammer" + + contentTypeJSON = "application/json" +) + +func NewShimmerAPI(node string) *ShimmerAPI { + return &ShimmerAPI{node: node} +} + +type ShimmerAPI struct { + http.Client + node string +} + +type errorresponse struct { + Error string `json:"error"` +} + +func interpretBody(res *http.Response, decodeTo interface{}) error { + resBody, err := ioutil.ReadAll(res.Body) + if err != nil { + return errors.Wrap(err, "unable to read response body") + } + defer res.Body.Close() + + if res.StatusCode == http.StatusOK { + return json.Unmarshal(resBody, decodeTo) + } + + errRes := &errorresponse{} + if err := json.Unmarshal(resBody, errRes); err != nil { + return errors.Wrap(err, "unable to read error from response body") + } + + switch res.StatusCode { + case http.StatusInternalServerError: + return errors.Wrap(ErrInternalServerError, errRes.Error) + case http.StatusNotFound: + return errors.Wrap(ErrNotFound, errRes.Error) + case http.StatusBadRequest: + return errors.Wrap(ErrBadRequest, errRes.Error) + } + return errors.Wrap(ErrUnknownError, errRes.Error) +} + +func (api *ShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data trinary.Trytes) (trinary.Hash, error) { + if !guards.IsHash(targetAddress) { + return "", errors.Wrapf(consts.ErrInvalidHash, "invalid address: %s", targetAddress) + } + if !guards.IsTrytes(data) { + return "", errors.Wrapf(consts.ErrInvalidTrytes, "invalid trytes: %s", data) + } + + reqBytes, err := json.Marshal(&webapi_broadcastData.Request{Address: targetAddress, Data: data}) + if err != nil { + return "", err + } + + res, err := api.Post(fmt.Sprintf("%s/%s", api.node, routeBroadcastData), contentTypeJSON, bytes.NewReader(reqBytes)) + if err != nil { + return "", err + } + + resObj := &webapi_broadcastData.Response{} + if err := interpretBody(res, resObj); err != nil { + return "", err + } + + return resObj.Hash, nil +} + +func (api *ShimmerAPI) GetTrytes(txHashes trinary.Hashes) ([]trinary.Trytes, error) { + for _, hash := range txHashes { + if !guards.IsTrytes(hash) { + return nil, errors.Wrapf(consts.ErrInvalidHash, "invalid hash: %s", hash) + } + } + + reqBytes, err := json.Marshal(&webapi_getTrytes.Request{Hashes: txHashes}) + if err != nil { + return nil, err + } + + res, err := api.Post(fmt.Sprintf("%s/%s", api.node, routeGetTrytes), contentTypeJSON, bytes.NewReader(reqBytes)) + if err != nil { + return nil, err + } + + resObj := &webapi_getTrytes.Response{} + if err := interpretBody(res, resObj); err != nil { + return nil, err + } + + return resObj.Trytes, nil +} + +func (api *ShimmerAPI) GetTransactions(txHashes trinary.Hashes) ([]webapi_getTransactions.Transaction, error) { + for _, hash := range txHashes { + if !guards.IsTrytes(hash) { + return nil, errors.Wrapf(consts.ErrInvalidHash, "invalid hash: %s", hash) + } + } + + reqBytes, err := json.Marshal(&webapi_getTransactions.Request{Hashes: txHashes}) + if err != nil { + return nil, err + } + + res, err := api.Post(fmt.Sprintf("%s/%s", api.node, routeGetTransactions), contentTypeJSON, bytes.NewReader(reqBytes)) + if err != nil { + return nil, err + } + + resObj := &webapi_getTransactions.Response{} + if err := interpretBody(res, resObj); err != nil { + return nil, err + } + + return resObj.Transactions, nil +} + +func (api *ShimmerAPI) FindTransactions(query *webapi_findTransactions.Request) ([]trinary.Hashes, error) { + for _, hash := range query.Addresses { + if !guards.IsTrytes(hash) { + return nil, errors.Wrapf(consts.ErrInvalidHash, "invalid hash: %s", hash) + } + } + + reqBytes, err := json.Marshal(&query) + if err != nil { + return nil, err + } + + res, err := api.Post(fmt.Sprintf("%s/%s", api.node, routeFindTransactions), contentTypeJSON, bytes.NewReader(reqBytes)) + if err != nil { + return nil, err + } + + resObj := &webapi_findTransactions.Response{} + if err := interpretBody(res, resObj); err != nil { + return nil, err + } + + return resObj.Transactions, nil +} + +func (api *ShimmerAPI) GetNeighbors() (*webapi_getNeighbors.Response, error) { + res, err := api.Get(fmt.Sprintf("%s/%s", api.node, routeGetNeighbors)) + if err != nil { + return nil, err + } + + resObj := &webapi_getNeighbors.Response{} + if err := interpretBody(res, resObj); err != nil { + return nil, err + } + + return resObj, nil +} + +func (api *ShimmerAPI) GetTips() (*webapi_gtta.Response, error) { + res, err := api.Get(fmt.Sprintf("%s/%s", api.node, routeGetTransactionsToApprove)) + if err != nil { + return nil, err + } + + resObj := &webapi_gtta.Response{} + if err := interpretBody(res, resObj); err != nil { + return nil, err + } + + return resObj, nil +} + +func (api *ShimmerAPI) ToggleSpammer(enable bool) (*webapi_spammer.Response, error) { + res, err := api.Get(fmt.Sprintf("%s/%s?cmd=%s", api.node, routeSpammer, func() string { + if enable { + return "start" + } + return "stop" + }())) + if err != nil { + return nil, err + } + + resObj := &webapi_spammer.Response{} + if err := interpretBody(res, resObj); err != nil { + return nil, err + } + + return resObj, nil +} diff --git a/main.go b/main.go index 7822849a32..f7d202d11a 100644 --- a/main.go +++ b/main.go @@ -61,6 +61,7 @@ func main() { webapi_getTransactions.PLUGIN, webapi_findTransactions.PLUGIN, webapi_getNeighbors.PLUGIN, + webapi_spammer.PLUGIN, ui.PLUGIN, webauth.PLUGIN, diff --git a/plugins/graph/README.md b/plugins/graph/README.md new file mode 100644 index 0000000000..da7c4ca792 --- /dev/null +++ b/plugins/graph/README.md @@ -0,0 +1,9 @@ +# How to install this plugin +- Run the following commands in this folder (or set `graph.socketioPath` and `graph.webrootPath` in your config if you want to use another path) + +```bash +git clone https://github.com/glumb/IOTAtangle.git +cd IOTAtangle && git reset --hard 07bba77a296a2d06277cdae56aa963abeeb5f66e +cd ../ +git clone https://github.com/socketio/socket.io-client.git +``` \ No newline at end of file diff --git a/plugins/webapi/broadcastData/plugin.go b/plugins/webapi/broadcastData/plugin.go index ef85788270..0ed2562f14 100644 --- a/plugins/webapi/broadcastData/plugin.go +++ b/plugins/webapi/broadcastData/plugin.go @@ -30,12 +30,14 @@ func configure(plugin *node.Plugin) { // broadcasts it to the node's neighbors. It returns the transaction hash if successful. func broadcastData(c echo.Context) error { - var request webRequest + var request Request if err := c.Bind(&request); err != nil { log.Info(err.Error()) return requestFailed(c, err.Error()) } + log.Debug("Received - address:", request.Address, " data:", request.Data) + tx := value_transaction.New() tx.SetHead(true) tx.SetTail(true) @@ -76,23 +78,23 @@ func broadcastData(c echo.Context) error { } func requestSuccessful(c echo.Context, txHash string) error { - return c.JSON(http.StatusCreated, webResponse{ + return c.JSON(http.StatusCreated, Response{ Hash: txHash, }) } func requestFailed(c echo.Context, message string) error { - return c.JSON(http.StatusBadRequest, webResponse{ + return c.JSON(http.StatusBadRequest, Response{ Error: message, }) } -type webResponse struct { +type Response struct { Hash string `json:"hash,omitempty"` Error string `json:"error,omitempty"` } -type webRequest struct { +type Request struct { Address string `json:"address"` Data string `json:"data"` } diff --git a/plugins/webapi/findTransactions/plugin.go b/plugins/webapi/findTransactions/plugin.go index cf0f12397c..9c4fc937a2 100644 --- a/plugins/webapi/findTransactions/plugin.go +++ b/plugins/webapi/findTransactions/plugin.go @@ -25,7 +25,7 @@ func configure(plugin *node.Plugin) { // the value at the index of that address is empty. func findTransactions(c echo.Context) error { - var request webRequest + var request Request if err := c.Bind(&request); err != nil { log.Info(err.Error()) @@ -46,22 +46,22 @@ func findTransactions(c echo.Context) error { } func requestSuccessful(c echo.Context, txHashes [][]trinary.Trytes) error { - return c.JSON(http.StatusOK, webResponse{ + return c.JSON(http.StatusOK, Response{ Transactions: txHashes, }) } func requestFailed(c echo.Context, message string) error { - return c.JSON(http.StatusNotFound, webResponse{ + return c.JSON(http.StatusNotFound, Response{ Error: message, }) } -type webResponse struct { +type Response struct { Transactions [][]trinary.Trytes `json:"transactions,omitempty"` //string Error string `json:"error,omitempty"` } -type webRequest struct { +type Request struct { Addresses []string `json:"addresses"` } diff --git a/plugins/webapi/getNeighbors/plugin.go b/plugins/webapi/getNeighbors/plugin.go index 01457705fc..097793e18a 100644 --- a/plugins/webapi/getNeighbors/plugin.go +++ b/plugins/webapi/getNeighbors/plugin.go @@ -24,8 +24,8 @@ func configure(plugin *node.Plugin) { // getNeighbors returns the chosen and accepted neighbors of the node func getNeighbors(c echo.Context) error { - chosen := []neighbor{} - accepted := []neighbor{} + chosen := []Neighbor{} + accepted := []Neighbor{} if autopeering.Selection == nil { return requestFailed(c, "Neighbor Selection is not enabled") @@ -33,7 +33,7 @@ func getNeighbors(c echo.Context) error { for _, peer := range autopeering.Selection.GetOutgoingNeighbors() { - n := neighbor{ + n := Neighbor{ ID: peer.ID().String(), PublicKey: base64.StdEncoding.EncodeToString(peer.PublicKey()), } @@ -41,7 +41,7 @@ func getNeighbors(c echo.Context) error { chosen = append(chosen, n) } for _, peer := range autopeering.Selection.GetIncomingNeighbors() { - n := neighbor{ + n := Neighbor{ ID: peer.ID().String(), PublicKey: base64.StdEncoding.EncodeToString(peer.PublicKey()), } @@ -52,26 +52,26 @@ func getNeighbors(c echo.Context) error { } -func requestSuccessful(c echo.Context, chosen, accepted []neighbor) error { - return c.JSON(http.StatusOK, webResponse{ +func requestSuccessful(c echo.Context, chosen, accepted []Neighbor) error { + return c.JSON(http.StatusOK, Response{ Chosen: chosen, Accepted: accepted, }) } func requestFailed(c echo.Context, message string) error { - return c.JSON(http.StatusNotFound, webResponse{ + return c.JSON(http.StatusNotFound, Response{ Error: message, }) } -type webResponse struct { - Chosen []neighbor `json:"chosen"` - Accepted []neighbor `json:"accepted"` +type Response struct { + Chosen []Neighbor `json:"chosen"` + Accepted []Neighbor `json:"accepted"` Error string `json:"error,omitempty"` } -type neighbor struct { +type Neighbor struct { ID string `json:"id"` // comparable node identifier PublicKey string `json:"publicKey"` // public key used to verify signatures Services []peerService diff --git a/plugins/webapi/getTransactions/plugin.go b/plugins/webapi/getTransactions/plugin.go index 2dfb696f2d..448243f94b 100644 --- a/plugins/webapi/getTransactions/plugin.go +++ b/plugins/webapi/getTransactions/plugin.go @@ -25,13 +25,14 @@ func configure(plugin *node.Plugin) { // the value at the index of that transaction hash is empty. func getTransactions(c echo.Context) error { - var request webRequest - result := []transaction{} + var request Request + result := []Transaction{} if err := c.Bind(&request); err != nil { log.Info(err.Error()) return requestFailed(c, err.Error()) } + log.Debug("Received:", request.Hashes) for _, hash := range request.Hashes { @@ -40,7 +41,7 @@ func getTransactions(c echo.Context) error { return requestFailed(c, err.Error()) } if tx != nil { - t := transaction{ + t := Transaction{ Hash: tx.GetHash(), WeightMagnitude: tx.GetWeightMagnitude(), TrunkTransactionHash: tx.GetTrunkTransactionHash(), @@ -56,7 +57,7 @@ func getTransactions(c echo.Context) error { result = append(result, t) } else { //tx not found - result = append(result, transaction{}) + result = append(result, Transaction{}) } } @@ -64,28 +65,28 @@ func getTransactions(c echo.Context) error { return requestSuccessful(c, result) } -func requestSuccessful(c echo.Context, txs []transaction) error { - return c.JSON(http.StatusOK, webResponse{ +func requestSuccessful(c echo.Context, txs []Transaction) error { + return c.JSON(http.StatusOK, Response{ Transactions: txs, }) } func requestFailed(c echo.Context, message string) error { - return c.JSON(http.StatusNotFound, webResponse{ + return c.JSON(http.StatusNotFound, Response{ Error: message, }) } -type webResponse struct { - Transactions []transaction `json:"transaction,omitempty"` +type Response struct { + Transactions []Transaction `json:"transaction,omitempty"` Error string `json:"error,omitempty"` } -type webRequest struct { +type Request struct { Hashes []string `json:"hashes"` } -type transaction struct { +type Transaction struct { Hash trinary.Trytes `json:"hash,omitempty"` WeightMagnitude int `json:"weightMagnitude,omitempty"` TrunkTransactionHash trinary.Trytes `json:"trunkTransactionHash,omitempty"` diff --git a/plugins/webapi/getTrytes/plugin.go b/plugins/webapi/getTrytes/plugin.go index 4dac6f1b97..8c9a8e2596 100644 --- a/plugins/webapi/getTrytes/plugin.go +++ b/plugins/webapi/getTrytes/plugin.go @@ -25,7 +25,7 @@ func configure(plugin *node.Plugin) { // the value at the index of that transaction hash is empty. func getTrytes(c echo.Context) error { - var request webRequest + var request Request result := []trinary.Trytes{} if err := c.Bind(&request); err != nil { log.Info(err.Error()) @@ -56,22 +56,22 @@ func getTrytes(c echo.Context) error { } func requestSuccessful(c echo.Context, txTrytes []trinary.Trytes) error { - return c.JSON(http.StatusOK, webResponse{ + return c.JSON(http.StatusOK, Response{ Trytes: txTrytes, }) } func requestFailed(c echo.Context, message string) error { - return c.JSON(http.StatusNotFound, webResponse{ + return c.JSON(http.StatusNotFound, Response{ Error: message, }) } -type webResponse struct { +type Response struct { Trytes []trinary.Trytes `json:"trytes,omitempty"` //string Error string `json:"error,omitempty"` } -type webRequest struct { +type Request struct { Hashes []string `json:"hashes"` } diff --git a/plugins/webapi/gtta/plugin.go b/plugins/webapi/gtta/plugin.go index 3234ddc61d..61217f8e6b 100644 --- a/plugins/webapi/gtta/plugin.go +++ b/plugins/webapi/gtta/plugin.go @@ -19,13 +19,13 @@ func Handler(c echo.Context) error { branchTransactionHash := tipselection.GetRandomTip() trunkTransactionHash := tipselection.GetRandomTip() - return c.JSON(http.StatusOK, webResponse{ + return c.JSON(http.StatusOK, Response{ BranchTransaction: branchTransactionHash, TrunkTransaction: trunkTransactionHash, }) } -type webResponse struct { +type Response struct { BranchTransaction trinary.Trytes `json:"branchTransaction"` TrunkTransaction trinary.Trytes `json:"trunkTransaction"` } diff --git a/plugins/webapi/spammer/plugin.go b/plugins/webapi/spammer/plugin.go index fe29875dad..97b9056a44 100644 --- a/plugins/webapi/spammer/plugin.go +++ b/plugins/webapi/spammer/plugin.go @@ -17,7 +17,7 @@ func configure(plugin *node.Plugin) { func WebApiHandler(c echo.Context) error { - var request webRequest + var request Request if err := c.Bind(&request); err != nil { return requestFailed(c, err.Error()) } @@ -44,22 +44,22 @@ func WebApiHandler(c echo.Context) error { } func requestSuccessful(c echo.Context, message string) error { - return c.JSON(http.StatusOK, webResponse{ + return c.JSON(http.StatusOK, Response{ Message: message, }) } func requestFailed(c echo.Context, message string) error { - return c.JSON(http.StatusNotFound, webResponse{ + return c.JSON(http.StatusNotFound, Response{ Message: message, }) } -type webResponse struct { +type Response struct { Message string `json:"message"` } -type webRequest struct { +type Request struct { Cmd string `json:"cmd"` Tps uint `json:"tps"` } From 396392f951cb3eb619d5490fa5a3e3ee408ffbdd Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Wed, 15 Jan 2020 13:17:35 +0100 Subject: [PATCH 102/184] renames the client lib main struct (#122) --- client/lib.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/client/lib.go b/client/lib.go index 4bc52b4bfb..fbe735e7c5 100644 --- a/client/lib.go +++ b/client/lib.go @@ -1,5 +1,5 @@ // Implements a very simple wrapper for GoShimmer's HTTP API . -package shimmer +package goshimmer import ( "bytes" @@ -40,11 +40,11 @@ const ( contentTypeJSON = "application/json" ) -func NewShimmerAPI(node string) *ShimmerAPI { - return &ShimmerAPI{node: node} +func NewGoShimmerAPI(node string) *GoShimmerAPI { + return &GoShimmerAPI{node: node} } -type ShimmerAPI struct { +type GoShimmerAPI struct { http.Client node string } @@ -80,7 +80,7 @@ func interpretBody(res *http.Response, decodeTo interface{}) error { return errors.Wrap(ErrUnknownError, errRes.Error) } -func (api *ShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data trinary.Trytes) (trinary.Hash, error) { +func (api *GoShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data trinary.Trytes) (trinary.Hash, error) { if !guards.IsHash(targetAddress) { return "", errors.Wrapf(consts.ErrInvalidHash, "invalid address: %s", targetAddress) } @@ -106,7 +106,7 @@ func (api *ShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data trinary. return resObj.Hash, nil } -func (api *ShimmerAPI) GetTrytes(txHashes trinary.Hashes) ([]trinary.Trytes, error) { +func (api *GoShimmerAPI) GetTrytes(txHashes trinary.Hashes) ([]trinary.Trytes, error) { for _, hash := range txHashes { if !guards.IsTrytes(hash) { return nil, errors.Wrapf(consts.ErrInvalidHash, "invalid hash: %s", hash) @@ -131,7 +131,7 @@ func (api *ShimmerAPI) GetTrytes(txHashes trinary.Hashes) ([]trinary.Trytes, err return resObj.Trytes, nil } -func (api *ShimmerAPI) GetTransactions(txHashes trinary.Hashes) ([]webapi_getTransactions.Transaction, error) { +func (api *GoShimmerAPI) GetTransactions(txHashes trinary.Hashes) ([]webapi_getTransactions.Transaction, error) { for _, hash := range txHashes { if !guards.IsTrytes(hash) { return nil, errors.Wrapf(consts.ErrInvalidHash, "invalid hash: %s", hash) @@ -156,7 +156,7 @@ func (api *ShimmerAPI) GetTransactions(txHashes trinary.Hashes) ([]webapi_getTra return resObj.Transactions, nil } -func (api *ShimmerAPI) FindTransactions(query *webapi_findTransactions.Request) ([]trinary.Hashes, error) { +func (api *GoShimmerAPI) FindTransactions(query *webapi_findTransactions.Request) ([]trinary.Hashes, error) { for _, hash := range query.Addresses { if !guards.IsTrytes(hash) { return nil, errors.Wrapf(consts.ErrInvalidHash, "invalid hash: %s", hash) @@ -181,7 +181,7 @@ func (api *ShimmerAPI) FindTransactions(query *webapi_findTransactions.Request) return resObj.Transactions, nil } -func (api *ShimmerAPI) GetNeighbors() (*webapi_getNeighbors.Response, error) { +func (api *GoShimmerAPI) GetNeighbors() (*webapi_getNeighbors.Response, error) { res, err := api.Get(fmt.Sprintf("%s/%s", api.node, routeGetNeighbors)) if err != nil { return nil, err @@ -195,7 +195,7 @@ func (api *ShimmerAPI) GetNeighbors() (*webapi_getNeighbors.Response, error) { return resObj, nil } -func (api *ShimmerAPI) GetTips() (*webapi_gtta.Response, error) { +func (api *GoShimmerAPI) GetTips() (*webapi_gtta.Response, error) { res, err := api.Get(fmt.Sprintf("%s/%s", api.node, routeGetTransactionsToApprove)) if err != nil { return nil, err @@ -209,7 +209,7 @@ func (api *ShimmerAPI) GetTips() (*webapi_gtta.Response, error) { return resObj, nil } -func (api *ShimmerAPI) ToggleSpammer(enable bool) (*webapi_spammer.Response, error) { +func (api *GoShimmerAPI) ToggleSpammer(enable bool) (*webapi_spammer.Response, error) { res, err := api.Get(fmt.Sprintf("%s/%s?cmd=%s", api.node, routeSpammer, func() string { if enable { return "start" From 75e70285e67aff576cbe5a3f3a730ec906c5d042 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Wed, 15 Jan 2020 13:38:44 +0100 Subject: [PATCH 103/184] Removes TravisCI in favor of GitHub workflows and adds GoReleaser (#116) * remove travis in favor of github workflows * adjust release repository name * Update .github/workflows/build.yml Co-Authored-By: Wolfgang Welz * Update .github/workflows/build.yml Co-Authored-By: Wolfgang Welz * Update .github/workflows/release.yml Co-Authored-By: Wolfgang Welz * changes according to Wolfgang's review * removes id from step in test.yml * only run twice up on PR open * Update .github/workflows/test.yml Co-Authored-By: Wolfgang Welz Co-authored-by: Wolfgang Welz --- .github/ISSUE_TEMPLATE/bug_report.md | 33 +++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 +++++ .github/workflows/release.yml | 21 +++++ .github/workflows/test.yml | 22 +++++ .goreleaser.yml | 102 ++++++++++++++++++++++ .travis.yml | 18 ---- 6 files changed, 198 insertions(+), 18 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml create mode 100644 .goreleaser.yml delete mode 100644 .travis.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000000..ca1e599517 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,33 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "" +labels: bug +assignees: '' + +--- + + + + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +- Go to ... +- Edit config to ... +- See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Environment information:** + - OS: [e.g. Ubuntu 18.04] + - RAM: [e.g. 4 GB] + - Cores: [e.g. 4 Cores] + - Type: [e.g. Raspberry Pi 3B+, VPS, ...] + - GoShimmer version [e.g. 0.2.1] + +**Additional context** +Add any other context about the problem here [e.g. GoShimmer logs, errors, screenshots] diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000000..139d1fa5c4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "" +labels: feature +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..cee5c81c8b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,21 @@ +name: Release + +on: + release: + types: [published] + +jobs: + Release: + name: Release + runs-on: [ubuntu-latest] + container: + image: iotmod/goreleaser-cgo-cross-compiler:1.13.5 + volumes: [/repo] + + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + - name: Release GoShimmer + run: goreleaser --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000000..35389be90f --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,22 @@ +name: Test GoShimmer +on: + push: + pull_request: + types: [opened, reopened] +jobs: + + build: + name: Test GoShimmer + runs-on: ubuntu-latest + steps: + + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13.x + + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + + - name: Run Tests + run: make test diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000000..3d250a1508 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,102 @@ +# Documentation at http://goreleaser.com + +# Project name +project_name: GoShimmer + +# Environment variables +env: + - GO111MODULE=on + +# Builds +builds: + # macOS AMD64 + - id: goshimmer-darwin-amd64 + binary: goshimmer + env: + - CGO_ENABLED=1 + - CC=o64-clang + - CXX=o64-clang++ + ldflags: + - -s -w -X github.com/iotaledger/goshimmer/plugins/cli.AppVersion={{.Version}} + flags: + - -tags=pow_avx + main: main.go + goos: + - darwin + goarch: + - amd64 + # Linux AMD64 + - id: goshimmer-linux-amd64 + binary: goshimmer + env: + - CGO_ENABLED=1 + ldflags: + - -s -w -X github.com/iotaledger/goshimmer/plugins/cli.AppVersion={{.Version}} + flags: + - -tags=pow_avx + main: main.go + goos: + - linux + goarch: + - amd64 + # Windows AMD64 + - id: goshimmer-windows-amd64 + binary: goshimmer + env: + - CGO_ENABLED=1 + - CC=x86_64-w64-mingw32-gcc + - CXX=x86_64-w64-mingw32-g++ + ldflags: + - -s -w -X github.com/iotaledger/goshimmer/plugins/cli.AppVersion={{.Version}} + flags: + - -tags=pow_avx + main: main.go + goos: + - windows + goarch: + - amd64 + +# Archives +archives: + - format: tar.gz + wrap_in_directory: true + format_overrides: + - goos: windows + format: zip + name_template: "{{.ProjectName}}-{{.Version}}_{{.Os}}_{{.Arch}}" + replacements: + amd64: x86_64 + 386: 32bit + arm: ARM + arm64: ARM64 + darwin: macOS + linux: Linux + windows: Windows + openbsd: OpenBSD + netbsd: NetBSD + freebsd: FreeBSD + dragonfly: DragonFlyBSD + files: + - README.md + - LICENSE + - config.json + +# Checksum +checksum: + name_template: "checksums.txt" + +# Snapshot +snapshot: + name_template: "{{ .Tag }}" + +# Changelog +changelog: + skip: true + +# Release +release: + prerelease: auto + name_template: "{{.ProjectName}}-{{.Version}}" + github: + owner: iotaledger + name: goshimmer \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ee06a55b21..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -os: linux -language: go - -go: - - 1.13 - -cache: - directories: - - $HOME/gopath/pkg/mod - -env: - - GO111MODULE=on - -# we are using go modules, so there is nothing to install -install: true - -# use the makefile goal for testing -script: make test From cc36b0621b0dd68d327c52a3acb916cd096284cc Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Wed, 15 Jan 2020 13:49:21 +0100 Subject: [PATCH 104/184] Adds the glumb visualizer as git submodules to the repository (#123) --- .gitmodules | 6 ++++++ IOTAtangle | 1 + socket.io-client | 1 + 3 files changed, 8 insertions(+) create mode 100644 .gitmodules create mode 160000 IOTAtangle create mode 160000 socket.io-client diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..38c720d5cd --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "IOTAtangle"] + path = IOTAtangle + url = https://github.com/glumb/IOTAtangle.git +[submodule "socket.io-client"] + path = socket.io-client + url = https://github.com/socketio/socket.io-client.git diff --git a/IOTAtangle b/IOTAtangle new file mode 160000 index 0000000000..07bba77a29 --- /dev/null +++ b/IOTAtangle @@ -0,0 +1 @@ +Subproject commit 07bba77a296a2d06277cdae56aa963abeeb5f66e diff --git a/socket.io-client b/socket.io-client new file mode 160000 index 0000000000..661f1e7fac --- /dev/null +++ b/socket.io-client @@ -0,0 +1 @@ +Subproject commit 661f1e7fac2488b6d3d206f96bb59073c4c98b1c From d054e4182eebbb20a4bace44c6c7b4d768b9ddff Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Wed, 15 Jan 2020 14:23:43 +0100 Subject: [PATCH 105/184] Set new txs as modified, adjusts webapi endpoint methods (#120) --- client/lib.go | 32 ++++++++++++----------- plugins/tangle/solidifier.go | 4 ++- plugins/webapi/findTransactions/plugin.go | 3 +-- plugins/webapi/getTransactions/plugin.go | 2 +- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/client/lib.go b/client/lib.go index fbe735e7c5..d60200d611 100644 --- a/client/lib.go +++ b/client/lib.go @@ -40,13 +40,16 @@ const ( contentTypeJSON = "application/json" ) -func NewGoShimmerAPI(node string) *GoShimmerAPI { +func NewGoShimmerAPI(node string, httpClient ...http.Client) *GoShimmerAPI { + if len(httpClient) > 0 { + return &GoShimmerAPI{node: node, httpClient: httpClient[0]} + } return &GoShimmerAPI{node: node} } type GoShimmerAPI struct { - http.Client - node string + httpClient http.Client + node string } type errorresponse struct { @@ -60,7 +63,7 @@ func interpretBody(res *http.Response, decodeTo interface{}) error { } defer res.Body.Close() - if res.StatusCode == http.StatusOK { + if res.StatusCode == http.StatusOK || res.StatusCode == http.StatusCreated { return json.Unmarshal(resBody, decodeTo) } @@ -80,20 +83,17 @@ func interpretBody(res *http.Response, decodeTo interface{}) error { return errors.Wrap(ErrUnknownError, errRes.Error) } -func (api *GoShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data trinary.Trytes) (trinary.Hash, error) { +func (api *GoShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data string) (trinary.Hash, error) { if !guards.IsHash(targetAddress) { return "", errors.Wrapf(consts.ErrInvalidHash, "invalid address: %s", targetAddress) } - if !guards.IsTrytes(data) { - return "", errors.Wrapf(consts.ErrInvalidTrytes, "invalid trytes: %s", data) - } reqBytes, err := json.Marshal(&webapi_broadcastData.Request{Address: targetAddress, Data: data}) if err != nil { return "", err } - res, err := api.Post(fmt.Sprintf("%s/%s", api.node, routeBroadcastData), contentTypeJSON, bytes.NewReader(reqBytes)) + res, err := api.httpClient.Post(fmt.Sprintf("%s/%s", api.node, routeBroadcastData), contentTypeJSON, bytes.NewReader(reqBytes)) if err != nil { return "", err } @@ -118,7 +118,7 @@ func (api *GoShimmerAPI) GetTrytes(txHashes trinary.Hashes) ([]trinary.Trytes, e return nil, err } - res, err := api.Post(fmt.Sprintf("%s/%s", api.node, routeGetTrytes), contentTypeJSON, bytes.NewReader(reqBytes)) + res, err := api.httpClient.Post(fmt.Sprintf("%s/%s", api.node, routeGetTrytes), contentTypeJSON, bytes.NewReader(reqBytes)) if err != nil { return nil, err } @@ -143,7 +143,7 @@ func (api *GoShimmerAPI) GetTransactions(txHashes trinary.Hashes) ([]webapi_getT return nil, err } - res, err := api.Post(fmt.Sprintf("%s/%s", api.node, routeGetTransactions), contentTypeJSON, bytes.NewReader(reqBytes)) + res, err := api.httpClient.Post(fmt.Sprintf("%s/%s", api.node, routeGetTransactions), contentTypeJSON, bytes.NewReader(reqBytes)) if err != nil { return nil, err } @@ -168,7 +168,7 @@ func (api *GoShimmerAPI) FindTransactions(query *webapi_findTransactions.Request return nil, err } - res, err := api.Post(fmt.Sprintf("%s/%s", api.node, routeFindTransactions), contentTypeJSON, bytes.NewReader(reqBytes)) + res, err := api.httpClient.Post(fmt.Sprintf("%s/%s", api.node, routeFindTransactions), contentTypeJSON, bytes.NewReader(reqBytes)) if err != nil { return nil, err } @@ -181,8 +181,9 @@ func (api *GoShimmerAPI) FindTransactions(query *webapi_findTransactions.Request return resObj.Transactions, nil } + func (api *GoShimmerAPI) GetNeighbors() (*webapi_getNeighbors.Response, error) { - res, err := api.Get(fmt.Sprintf("%s/%s", api.node, routeGetNeighbors)) + res, err := api.httpClient.Get(fmt.Sprintf("%s/%s", api.node, routeGetNeighbors)) if err != nil { return nil, err } @@ -195,8 +196,9 @@ func (api *GoShimmerAPI) GetNeighbors() (*webapi_getNeighbors.Response, error) { return resObj, nil } + func (api *GoShimmerAPI) GetTips() (*webapi_gtta.Response, error) { - res, err := api.Get(fmt.Sprintf("%s/%s", api.node, routeGetTransactionsToApprove)) + res, err := api.httpClient.Get(fmt.Sprintf("%s/%s", api.node, routeGetTransactionsToApprove)) if err != nil { return nil, err } @@ -210,7 +212,7 @@ func (api *GoShimmerAPI) GetTips() (*webapi_gtta.Response, error) { } func (api *GoShimmerAPI) ToggleSpammer(enable bool) (*webapi_spammer.Response, error) { - res, err := api.Get(fmt.Sprintf("%s/%s?cmd=%s", api.node, routeSpammer, func() string { + res, err := api.httpClient.Get(fmt.Sprintf("%s/%s?cmd=%s", api.node, routeSpammer, func() string { if enable { return "start" } diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index 2ab00159f6..1a90076bad 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -181,7 +181,9 @@ func processMetaTransaction(metaTransaction *meta_transaction.MetaTransaction) { if tx, err := GetTransaction(metaTransaction.GetHash(), func(transactionHash trinary.Trytes) *value_transaction.ValueTransaction { newTransaction = true - return value_transaction.FromMetaTransaction(metaTransaction) + tx := value_transaction.FromMetaTransaction(metaTransaction) + tx.SetModified(true) + return tx }); err != nil { log.Errorf("Unable to load transaction %s: %s", metaTransaction.GetHash(), err.Error()) } else if newTransaction { diff --git a/plugins/webapi/findTransactions/plugin.go b/plugins/webapi/findTransactions/plugin.go index 9c4fc937a2..ff9b406ad2 100644 --- a/plugins/webapi/findTransactions/plugin.go +++ b/plugins/webapi/findTransactions/plugin.go @@ -16,7 +16,7 @@ var log *logger.Logger func configure(plugin *node.Plugin) { log = logger.NewLogger("API-findTransactions") - webapi.Server.GET("findTransactions", findTransactions) + webapi.Server.POST("findTransactions", findTransactions) } // findTransactions returns the array of transaction hashes for the @@ -24,7 +24,6 @@ func configure(plugin *node.Plugin) { // If a node doesn't have any transaction hash for a given address in its ledger, // the value at the index of that address is empty. func findTransactions(c echo.Context) error { - var request Request if err := c.Bind(&request); err != nil { diff --git a/plugins/webapi/getTransactions/plugin.go b/plugins/webapi/getTransactions/plugin.go index 448243f94b..70c231328b 100644 --- a/plugins/webapi/getTransactions/plugin.go +++ b/plugins/webapi/getTransactions/plugin.go @@ -16,7 +16,7 @@ var log *logger.Logger func configure(plugin *node.Plugin) { log = logger.NewLogger("API-getTransactions") - webapi.Server.GET("getTransactions", getTransactions) + webapi.Server.POST("getTransactions", getTransactions) } // getTransactions returns the array of transactions for the From 384b317f543f2181b43bc9601e095b559f2b9926 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 15 Jan 2020 18:38:20 +0100 Subject: [PATCH 106/184] fix: resolve potential race condition in mapdb (#125) --- packages/autopeering/peer/mapdb.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/autopeering/peer/mapdb.go b/packages/autopeering/peer/mapdb.go index 548830f3a9..5baa569d65 100644 --- a/packages/autopeering/peer/mapdb.go +++ b/packages/autopeering/peer/mapdb.go @@ -80,19 +80,20 @@ func (db *mapDB) LocalServices() (service.Service, error) { // UpdateLocalServices updates the services stored in the database. func (db *mapDB) UpdateLocalServices(services service.Service) error { - db.mutex.Lock() - db.services = services.CreateRecord() - db.mutex.Unlock() + record := services.CreateRecord() + db.mutex.Lock() + defer db.mutex.Unlock() + db.services = record return nil } // LastPing returns that property for the given peer ID and address. func (db *mapDB) LastPing(id ID, address string) time.Time { db.mutex.RLock() - peerEntry := db.m[string(id.Bytes())] - db.mutex.RUnlock() + defer db.mutex.RUnlock() + peerEntry := db.m[string(id.Bytes())] return time.Unix(peerEntry.properties[address].lastPing, 0) } @@ -101,6 +102,8 @@ func (db *mapDB) UpdateLastPing(id ID, address string, t time.Time) error { key := string(id.Bytes()) db.mutex.Lock() + defer db.mutex.Unlock() + peerEntry := db.m[key] if peerEntry.properties == nil { peerEntry.properties = make(map[string]peerPropEntry) @@ -109,7 +112,6 @@ func (db *mapDB) UpdateLastPing(id ID, address string, t time.Time) error { entry.lastPing = t.Unix() peerEntry.properties[address] = entry db.m[key] = peerEntry - db.mutex.Unlock() return nil } @@ -117,9 +119,9 @@ func (db *mapDB) UpdateLastPing(id ID, address string, t time.Time) error { // LastPong returns that property for the given peer ID and address. func (db *mapDB) LastPong(id ID, address string) time.Time { db.mutex.RLock() - peerEntry := db.m[string(id.Bytes())] - db.mutex.RUnlock() + defer db.mutex.RUnlock() + peerEntry := db.m[string(id.Bytes())] return time.Unix(peerEntry.properties[address].lastPong, 0) } @@ -128,6 +130,8 @@ func (db *mapDB) UpdateLastPong(id ID, address string, t time.Time) error { key := string(id.Bytes()) db.mutex.Lock() + defer db.mutex.Unlock() + peerEntry := db.m[key] if peerEntry.properties == nil { peerEntry.properties = make(map[string]peerPropEntry) @@ -136,7 +140,6 @@ func (db *mapDB) UpdateLastPong(id ID, address string, t time.Time) error { entry.lastPong = t.Unix() peerEntry.properties[address] = entry db.m[key] = peerEntry - db.mutex.Unlock() return nil } @@ -150,10 +153,11 @@ func (db *mapDB) UpdatePeer(p *Peer) error { key := string(p.ID().Bytes()) db.mutex.Lock() + defer db.mutex.Unlock() + peerEntry := db.m[key] peerEntry.data = data db.m[key] = peerEntry - db.mutex.Unlock() return nil } From bcbcf50c4e296fe5d853b1a99146aecea1e06581 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 15 Jan 2020 18:41:34 +0100 Subject: [PATCH 107/184] Improve tangle tests (#126) --- plugins/tangle/solidifier_test.go | 166 ++++++++++++++++++++---------- 1 file changed, 112 insertions(+), 54 deletions(-) diff --git a/plugins/tangle/solidifier_test.go b/plugins/tangle/solidifier_test.go index bb677a5c62..850f87501e 100644 --- a/plugins/tangle/solidifier_test.go +++ b/plugins/tangle/solidifier_test.go @@ -1,9 +1,14 @@ package tangle import ( - "sync" + "io/ioutil" + stdlog "log" + "os" + "sync/atomic" "testing" + "time" + "github.com/iotaledger/goshimmer/packages/database" "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" @@ -15,68 +20,121 @@ import ( "github.com/stretchr/testify/require" ) +// use much lower min weight magnitude for the tests +const testMWM = 8 + func init() { if err := parameter.LoadDefaultConfig(false); err != nil { - log.Fatalf("Failed to initialize config: %s", err) + stdlog.Fatalf("Failed to initialize config: %s", err) } if err := logger.InitGlobalLogger(parameter.NodeConfig); err != nil { - log.Fatalf("Failed to initialize config: %s", err) + stdlog.Fatalf("Failed to initialize config: %s", err) } } -func TestSolidifier(t *testing.T) { +func TestTangle(t *testing.T) { + dir, err := ioutil.TempDir("", "example") + require.NoError(t, err) + defer os.Remove(dir) + // use the tempdir for the database + parameter.NodeConfig.Set(database.CFG_DIRECTORY, dir) + // start a test node node.Start(node.Plugins(PLUGIN)) + defer node.Shutdown() - // create transactions and chain them together - transaction1 := value_transaction.New() - transaction1.SetValue(1) - require.NoError(t, transaction1.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE)) - - transaction2 := value_transaction.New() - transaction2.SetValue(2) - transaction2.SetBranchTransactionHash(transaction1.GetHash()) - require.NoError(t, transaction2.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE)) - - transaction3 := value_transaction.New() - transaction3.SetValue(3) - transaction3.SetBranchTransactionHash(transaction2.GetHash()) - require.NoError(t, transaction3.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE)) - - transaction4 := value_transaction.New() - transaction4.SetValue(4) - transaction4.SetBranchTransactionHash(transaction3.GetHash()) - transaction4.SetAddress("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") - require.NoError(t, transaction4.DoProofOfWork(meta_transaction.MIN_WEIGHT_MAGNITUDE)) - - // setup event handlers - var wg sync.WaitGroup - Events.TransactionSolid.Attach(events.NewClosure(func(transaction *value_transaction.ValueTransaction) { - wg.Done() - })) - - // only transaction3 should be requested - SetRequester(RequesterFunc(func(hash trinary.Hash) { - require.Equal(t, transaction3.GetHash(), hash) - // return the transaction data - gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: transaction3.GetBytes()}) - })) - - // issue transactions - wg.Add(4) - - gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: transaction1.GetBytes()}) - gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: transaction2.GetBytes()}) - // gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: transaction3.GetBytes()}) - gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: transaction4.GetBytes()}) - - // wait until all are solid - wg.Wait() - - txAddr, err := ReadTransactionHashesForAddressFromDatabase(transaction4.GetAddress()) - require.NoError(t, err) - require.Equal(t, transaction4.GetHash(), txAddr[0]) + t.Run("ReadTransactionHashesForAddressFromDatabase", func(t *testing.T) { + tx1 := value_transaction.New() + tx1.SetAddress("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") + tx1.SetTimestamp(uint(time.Now().UnixNano())) + require.NoError(t, tx1.DoProofOfWork(testMWM)) + + tx2 := value_transaction.New() + tx2.SetTimestamp(uint(time.Now().UnixNano())) + require.NoError(t, tx2.DoProofOfWork(testMWM)) + + transactionReceived(&gossip.TransactionReceivedEvent{Data: tx1.GetBytes()}) + + txAddr, err := ReadTransactionHashesForAddressFromDatabase(tx1.GetAddress()) + require.NoError(t, err) + require.ElementsMatch(t, []trinary.Hash{tx1.GetHash()}, txAddr) + }) + + t.Run("ProofOfWork", func(t *testing.T) { + tx1 := value_transaction.New() + tx1.SetTimestamp(uint(time.Now().UnixNano())) + require.NoError(t, tx1.DoProofOfWork(1)) + + tx2 := value_transaction.New() + tx2.SetTimestamp(uint(time.Now().UnixNano())) + require.NoError(t, tx2.DoProofOfWork(testMWM)) + + var counter int32 + closure := events.NewClosure(func(transaction *value_transaction.ValueTransaction) { + atomic.AddInt32(&counter, 1) + }) + Events.TransactionSolid.Attach(closure) + defer Events.TransactionSolid.Detach(closure) + + transactionReceived(&gossip.TransactionReceivedEvent{Data: tx1.GetBytes()}) + transactionReceived(&gossip.TransactionReceivedEvent{Data: tx2.GetBytes()}) - // shutdown test node - node.Shutdown() + time.Sleep(100 * time.Millisecond) + require.EqualValues(t, 1, counter) + }) + + t.Run("Solidifier", func(t *testing.T) { + transaction1 := value_transaction.New() + transaction1.SetTimestamp(uint(time.Now().UnixNano())) + require.NoError(t, transaction1.DoProofOfWork(testMWM)) + + transaction2 := value_transaction.New() + transaction2.SetTimestamp(uint(time.Now().UnixNano())) + transaction2.SetBranchTransactionHash(transaction1.GetHash()) + require.NoError(t, transaction2.DoProofOfWork(testMWM)) + + transaction3 := value_transaction.New() + transaction3.SetTimestamp(uint(time.Now().UnixNano())) + transaction3.SetBranchTransactionHash(transaction2.GetHash()) + require.NoError(t, transaction3.DoProofOfWork(testMWM)) + + transaction4 := value_transaction.New() + transaction4.SetTimestamp(uint(time.Now().UnixNano())) + transaction4.SetBranchTransactionHash(transaction3.GetHash()) + require.NoError(t, transaction4.DoProofOfWork(testMWM)) + + var counter int32 + closure := events.NewClosure(func(tx *value_transaction.ValueTransaction) { + atomic.AddInt32(&counter, 1) + log.Infof("Transaction solid: hash=%s", tx.GetHash()) + }) + Events.TransactionSolid.Attach(closure) + defer Events.TransactionSolid.Detach(closure) + + // only transaction3 should be requested + SetRequester(RequesterFunc(func(hash trinary.Hash) { + if transaction3.GetHash() == hash { + // return the transaction data + transactionReceived(&gossip.TransactionReceivedEvent{Data: transaction3.GetBytes()}) + } + })) + + transactionReceived(&gossip.TransactionReceivedEvent{Data: transaction1.GetBytes()}) + transactionReceived(&gossip.TransactionReceivedEvent{Data: transaction2.GetBytes()}) + // transactionReceived(&gossip.TransactionReceivedEvent{Data: transaction3.GetBytes()}) + transactionReceived(&gossip.TransactionReceivedEvent{Data: transaction4.GetBytes()}) + + time.Sleep(100 * time.Millisecond) + require.EqualValues(t, 4, counter) + }) +} + +// transactionReceived mocks the TransactionReceived event by allowing lower mwm +func transactionReceived(ev *gossip.TransactionReceivedEvent) { + metaTx := meta_transaction.FromBytes(ev.Data) + if metaTx.GetWeightMagnitude() < testMWM { + log.Warnf("invalid weight magnitude: %d / %d", metaTx.GetWeightMagnitude(), testMWM) + return + } + processMetaTransaction(metaTx) } From 5434044281cc2e2a2a0970a2a83acc7ea4f27f99 Mon Sep 17 00:00:00 2001 From: Angelo Capossele Date: Wed, 15 Jan 2020 18:04:54 +0000 Subject: [PATCH 108/184] Use the workerpool from hive.go (#127) * :arrow_up: uses workerpool from hive.go * :heavy_minus_sign: removes internal workerpool --- packages/workerpool/options.go | 38 ------ packages/workerpool/task.go | 15 --- packages/workerpool/workerpool.go | 116 ------------------ packages/workerpool/workerpool_test.go | 26 ---- plugins/bundleprocessor/bundleprocessor.go | 2 +- .../bundleprocessor/valuebundleprocessor.go | 2 +- plugins/tangle/solidifier.go | 2 +- 7 files changed, 3 insertions(+), 198 deletions(-) delete mode 100644 packages/workerpool/options.go delete mode 100644 packages/workerpool/task.go delete mode 100644 packages/workerpool/workerpool.go delete mode 100644 packages/workerpool/workerpool_test.go diff --git a/packages/workerpool/options.go b/packages/workerpool/options.go deleted file mode 100644 index dc6b27e4da..0000000000 --- a/packages/workerpool/options.go +++ /dev/null @@ -1,38 +0,0 @@ -package workerpool - -import ( - "runtime" -) - -var DEFAULT_OPTIONS = &Options{ - WorkerCount: 2 * runtime.NumCPU(), - QueueSize: 4 * runtime.NumCPU(), -} - -func WorkerCount(workerCount int) Option { - return func(args *Options) { - args.WorkerCount = workerCount - } -} - -func QueueSize(queueSize int) Option { - return func(args *Options) { - args.QueueSize = queueSize - } -} - -type Options struct { - WorkerCount int - QueueSize int -} - -func (options Options) Override(optionalOptions ...Option) *Options { - result := &options - for _, option := range optionalOptions { - option(result) - } - - return result -} - -type Option func(*Options) diff --git a/packages/workerpool/task.go b/packages/workerpool/task.go deleted file mode 100644 index 8c56b1a927..0000000000 --- a/packages/workerpool/task.go +++ /dev/null @@ -1,15 +0,0 @@ -package workerpool - -type Task struct { - params []interface{} - resultChan chan interface{} -} - -func (task *Task) Return(result interface{}) { - task.resultChan <- result - close(task.resultChan) -} - -func (task *Task) Param(index int) interface{} { - return task.params[index] -} diff --git a/packages/workerpool/workerpool.go b/packages/workerpool/workerpool.go deleted file mode 100644 index 95b6a2a7d2..0000000000 --- a/packages/workerpool/workerpool.go +++ /dev/null @@ -1,116 +0,0 @@ -package workerpool - -import ( - "sync" -) - -type WorkerPool struct { - workerFnc func(Task) - options *Options - - calls chan Task - terminate chan int - - running bool - mutex sync.RWMutex - wait sync.WaitGroup -} - -func New(workerFnc func(Task), optionalOptions ...Option) (result *WorkerPool) { - options := DEFAULT_OPTIONS.Override(optionalOptions...) - - result = &WorkerPool{ - workerFnc: workerFnc, - options: options, - } - - result.resetChannels() - - return -} - -func (wp *WorkerPool) Submit(params ...interface{}) (result chan interface{}) { - result = make(chan interface{}, 1) - - wp.mutex.RLock() - - if wp.running { - wp.calls <- Task{ - params: params, - resultChan: result, - } - } else { - close(result) - } - - wp.mutex.RUnlock() - - return -} - -func (wp *WorkerPool) Start() { - wp.mutex.Lock() - - if !wp.running { - wp.running = true - - wp.startWorkers() - } - - wp.mutex.Unlock() -} - -func (wp *WorkerPool) Run() { - wp.Start() - - wp.wait.Wait() -} - -func (wp *WorkerPool) Stop() { - go wp.StopAndWait() -} - -func (wp *WorkerPool) StopAndWait() { - wp.mutex.Lock() - - if wp.running { - wp.running = false - - close(wp.terminate) - wp.resetChannels() - } - - wp.wait.Wait() - - wp.mutex.Unlock() -} - -func (wp *WorkerPool) resetChannels() { - wp.calls = make(chan Task, wp.options.QueueSize) - wp.terminate = make(chan int, 1) -} - -func (wp *WorkerPool) startWorkers() { - calls := wp.calls - terminate := wp.terminate - - for i := 0; i < wp.options.WorkerCount; i++ { - wp.wait.Add(1) - - go func() { - aborted := false - - for !aborted { - select { - case <-terminate: - aborted = true - - case batchTask := <-calls: - wp.workerFnc(batchTask) - } - } - - wp.wait.Done() - }() - } -} diff --git a/packages/workerpool/workerpool_test.go b/packages/workerpool/workerpool_test.go deleted file mode 100644 index deab7db702..0000000000 --- a/packages/workerpool/workerpool_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package workerpool - -import ( - "sync" - "testing" -) - -func Benchmark(b *testing.B) { - pool := New(func(task Task) { - task.Return(task.Param(0)) - }, WorkerCount(10), QueueSize(2000)) - pool.Start() - - var wg sync.WaitGroup - for i := 0; i < b.N; i++ { - wg.Add(1) - - go func(i int) { - <-pool.Submit(i) - - wg.Done() - }(i) - } - - wg.Wait() -} diff --git a/plugins/bundleprocessor/bundleprocessor.go b/plugins/bundleprocessor/bundleprocessor.go index 32c7bcd21b..a09fabf2c9 100644 --- a/plugins/bundleprocessor/bundleprocessor.go +++ b/plugins/bundleprocessor/bundleprocessor.go @@ -8,8 +8,8 @@ import ( "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/packages/workerpool" "github.com/iotaledger/goshimmer/plugins/tangle" + "github.com/iotaledger/hive.go/workerpool" "github.com/iotaledger/iota.go/trinary" ) diff --git a/plugins/bundleprocessor/valuebundleprocessor.go b/plugins/bundleprocessor/valuebundleprocessor.go index 63c772e12d..1ab5c77928 100644 --- a/plugins/bundleprocessor/valuebundleprocessor.go +++ b/plugins/bundleprocessor/valuebundleprocessor.go @@ -4,7 +4,7 @@ import ( "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/value_transaction" - "github.com/iotaledger/goshimmer/packages/workerpool" + "github.com/iotaledger/hive.go/workerpool" "github.com/iotaledger/iota.go/curl" "github.com/iotaledger/iota.go/signing" "github.com/iotaledger/iota.go/trinary" diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index 1a90076bad..014a20db15 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -11,9 +11,9 @@ import ( "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/shutdown" - "github.com/iotaledger/goshimmer/packages/workerpool" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" + "github.com/iotaledger/hive.go/workerpool" "github.com/iotaledger/iota.go/trinary" ) From 002ee26f163ed1ad52edae395fcecb3dedbf0c72 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Thu, 16 Jan 2020 12:42:36 +0100 Subject: [PATCH 109/184] Feat: Improve peer selection logic to avoid parallel connections (#101) * Log failed connection attempts * Only trigger drop event, when a neighbor was removed * Remove unused dropNeighbors * Use only one loop to process channels in selection * Update out neighbors less often * feat: introduce SaltUpdated event * fix: use global parameters * Update salt log messages * fix: do not close public channels to prevent panics during shutdown * fix: assure correct order of events * feat: add selection event tests * Set update interval to 1s and full updat interval to 1m * Use subtests for the protocol tests * fix: send peering drop message only when event is triggered * Update packages/autopeering/selection/manager.go Co-Authored-By: jkrvivian Co-authored-by: jkrvivian --- packages/autopeering/discover/common.go | 74 ++- packages/autopeering/discover/manager.go | 40 +- packages/autopeering/discover/manager_test.go | 2 +- packages/autopeering/discover/protocol.go | 8 +- .../autopeering/discover/protocol_test.go | 11 +- packages/autopeering/peer/mapdb.go | 6 +- packages/autopeering/peer/mapdb_test.go | 35 +- packages/autopeering/peer/peerdb.go | 6 +- packages/autopeering/salt/salt.go | 2 +- packages/autopeering/selection/common.go | 79 ++- packages/autopeering/selection/events.go | 19 +- packages/autopeering/selection/manager.go | 537 ++++++++---------- .../autopeering/selection/manager_test.go | 239 +++++--- .../autopeering/selection/neighborhood.go | 124 ++-- .../selection/neighborhood_test.go | 70 +-- packages/autopeering/selection/protocol.go | 31 +- .../autopeering/selection/protocol_test.go | 165 +++--- .../autopeering/selection/selection_test.go | 16 +- packages/autopeering/server/server.go | 6 +- plugins/autopeering/autopeering.go | 7 +- plugins/autopeering/plugin.go | 9 +- plugins/gossip/plugin.go | 3 + 22 files changed, 816 insertions(+), 673 deletions(-) diff --git a/packages/autopeering/discover/common.go b/packages/autopeering/discover/common.go index 7249d1beea..826ad2cd12 100644 --- a/packages/autopeering/discover/common.go +++ b/packages/autopeering/discover/common.go @@ -4,47 +4,35 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/autopeering/peer" - "go.uber.org/zap" + "github.com/iotaledger/hive.go/logger" ) +// Default values for the global parameters const ( - // PingExpiration is the time until a peer verification expires. - PingExpiration = 12 * time.Hour - // MaxPeersInResponse is the maximum number of peers returned in DiscoveryResponse. - MaxPeersInResponse = 6 - // MaxServices is the maximum number of services a peer can support. - MaxServices = 5 - - // VersionNum specifies the expected version number for this Protocol. - VersionNum = 0 + DefaultReverifyInterval = 10 * time.Second + DefaultReverifyTries = 2 + DefaultQueryInterval = 60 * time.Second + DefaultMaxManaged = 1000 + DefaultMaxReplacements = 10 +) + +var ( + reverifyInterval = DefaultReverifyInterval // time interval after which the next peer is reverified + reverifyTries = DefaultReverifyTries // number of times a peer is pinged before it is removed + queryInterval = DefaultQueryInterval // time interval after which peers are queried for new peers + maxManaged = DefaultMaxManaged // maximum number of peers that can be managed + maxReplacements = DefaultMaxReplacements // maximum number of peers kept in the replacement list ) // Config holds discovery related settings. type Config struct { // These settings are required and configure the listener: - Log *zap.SugaredLogger + Log *logger.Logger // These settings are optional: MasterPeers []*peer.Peer // list of master peers used for bootstrapping - Param *Parameters // parameters } -// default parameter values -const ( - // DefaultReverifyInterval is the default time interval after which a new peer is reverified. - DefaultReverifyInterval = 10 * time.Second - // DefaultReverifyTries is the default number of times a peer is pinged before it is removed. - DefaultReverifyTries = 2 - - // DefaultQueryInterval is the default time interval after which known peers are queried for new peers. - DefaultQueryInterval = 60 * time.Second - - // DefaultMaxManaged is the default maximum number of peers that can be managed. - DefaultMaxManaged = 1000 - // DefaultMaxReplacements is the default maximum number of peers kept in the replacement list. - DefaultMaxReplacements = 10 -) - // Parameters holds the parameters that can be configured. type Parameters struct { ReverifyInterval time.Duration // time interval after which the next peer is reverified @@ -53,3 +41,33 @@ type Parameters struct { MaxManaged int // maximum number of peers that can be managed MaxReplacements int // maximum number of peers kept in the replacement list } + +// SetParameters sets the global parameters for this package. +// This function cannot be used concurrently. +func SetParameter(param Parameters) { + if param.ReverifyInterval > 0 { + reverifyInterval = param.ReverifyInterval + } else { + reverifyInterval = DefaultReverifyInterval + } + if param.ReverifyTries > 0 { + reverifyTries = param.ReverifyTries + } else { + reverifyTries = DefaultReverifyTries + } + if param.QueryInterval > 0 { + queryInterval = param.QueryInterval + } else { + queryInterval = DefaultQueryInterval + } + if param.MaxManaged > 0 { + maxManaged = param.MaxManaged + } else { + maxManaged = DefaultMaxManaged + } + if param.MaxReplacements > 0 { + maxReplacements = param.MaxReplacements + } else { + maxReplacements = DefaultMaxReplacements + } +} diff --git a/packages/autopeering/discover/manager.go b/packages/autopeering/discover/manager.go index d7697aede7..055dd9bb02 100644 --- a/packages/autopeering/discover/manager.go +++ b/packages/autopeering/discover/manager.go @@ -7,15 +7,19 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/server" - "go.uber.org/zap" + "github.com/iotaledger/hive.go/logger" ) -var ( - reverifyInterval = DefaultReverifyInterval // time interval after which the next peer is reverified - reverifyTries = DefaultReverifyTries // number of times a peer is pinged before it is removed - queryInterval = DefaultQueryInterval // time interval after which peers are queried for new peers - maxManaged = DefaultMaxManaged // maximum number of peers that can be managed - maxReplacements = DefaultMaxReplacements // maximum number of peers kept in the replacement list +const ( + // PingExpiration is the time until a peer verification expires. + PingExpiration = 12 * time.Hour + // MaxPeersInResponse is the maximum number of peers returned in DiscoveryResponse. + MaxPeersInResponse = 6 + // MaxServices is the maximum number of services a peer can support. + MaxServices = 5 + + // VersionNum specifies the expected version number for this Protocol. + VersionNum = 0 ) type network interface { @@ -31,31 +35,13 @@ type manager struct { replacements []*mpeer net network - log *zap.SugaredLogger + log *logger.Logger wg sync.WaitGroup closing chan struct{} } -func newManager(net network, masters []*peer.Peer, log *zap.SugaredLogger, param *Parameters) *manager { - if param != nil { - if param.ReverifyInterval > 0 { - reverifyInterval = param.ReverifyInterval - } - if param.ReverifyTries > 0 { - reverifyTries = param.ReverifyTries - } - if param.QueryInterval > 0 { - queryInterval = param.QueryInterval - } - if param.MaxManaged > 0 { - maxManaged = param.MaxManaged - } - if param.MaxReplacements > 0 { - maxReplacements = param.MaxReplacements - } - } - +func newManager(net network, masters []*peer.Peer, log *logger.Logger) *manager { m := &manager{ active: make([]*mpeer, 0, maxManaged), replacements: make([]*mpeer, 0, maxReplacements), diff --git a/packages/autopeering/discover/manager_test.go b/packages/autopeering/discover/manager_test.go index ddd255656f..fba880e418 100644 --- a/packages/autopeering/discover/manager_test.go +++ b/packages/autopeering/discover/manager_test.go @@ -49,7 +49,7 @@ func newDummyPeer(name string) *peer.Peer { func newTestManager() (*manager, *NetworkMock, func()) { networkMock := newNetworkMock() - mgr := newManager(networkMock, nil, log, nil) + mgr := newManager(networkMock, nil, log) teardown := func() { mgr.close() } diff --git a/packages/autopeering/discover/protocol.go b/packages/autopeering/discover/protocol.go index 7202c66dbe..242016f7b4 100644 --- a/packages/autopeering/discover/protocol.go +++ b/packages/autopeering/discover/protocol.go @@ -11,8 +11,8 @@ import ( peerpb "github.com/iotaledger/goshimmer/packages/autopeering/peer/proto" "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/autopeering/server" + "github.com/iotaledger/hive.go/logger" "github.com/pkg/errors" - "go.uber.org/zap" ) // The Protocol handles the peer discovery. @@ -20,8 +20,8 @@ import ( type Protocol struct { server.Protocol - loc *peer.Local // local peer that runs the protocol - log *zap.SugaredLogger // logging + loc *peer.Local // local peer that runs the protocol + log *logger.Logger // logging mgr *manager // the manager handles the actual peer discovery and re-verification closeOnce sync.Once @@ -34,7 +34,7 @@ func New(local *peer.Local, cfg Config) *Protocol { loc: local, log: cfg.Log, } - p.mgr = newManager(p, cfg.MasterPeers, cfg.Log.Named("mgr"), cfg.Param) + p.mgr = newManager(p, cfg.MasterPeers, cfg.Log.Named("mgr")) return p } diff --git a/packages/autopeering/discover/protocol_test.go b/packages/autopeering/discover/protocol_test.go index 7f6432f7ba..223c2c3ef1 100644 --- a/packages/autopeering/discover/protocol_test.go +++ b/packages/autopeering/discover/protocol_test.go @@ -20,10 +20,13 @@ var log = logger.NewExampleLogger("discover") func init() { // decrease parameters to simplify and speed up tests - reverifyInterval = 500 * time.Millisecond - queryInterval = 1000 * time.Millisecond - maxManaged = 10 - maxReplacements = 2 + SetParameter(Parameters{ + ReverifyInterval: 500 * time.Millisecond, + ReverifyTries: 1, + QueryInterval: 1000 * time.Millisecond, + MaxManaged: 10, + MaxReplacements: 2, + }) } // newTest creates a new discovery server and also returns the teardown. diff --git a/packages/autopeering/peer/mapdb.go b/packages/autopeering/peer/mapdb.go index 5baa569d65..03719614de 100644 --- a/packages/autopeering/peer/mapdb.go +++ b/packages/autopeering/peer/mapdb.go @@ -5,7 +5,7 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" - "go.uber.org/zap" + "github.com/iotaledger/hive.go/logger" ) // mapDB is a simple implementation of DB using a map. @@ -15,7 +15,7 @@ type mapDB struct { key PrivateKey services *service.Record - log *zap.SugaredLogger + log *logger.Logger wg sync.WaitGroup closeOnce sync.Once @@ -32,7 +32,7 @@ type peerPropEntry struct { } // NewMemoryDB creates a new DB that uses a GO map. -func NewMemoryDB(log *zap.SugaredLogger) DB { +func NewMemoryDB(log *logger.Logger) DB { db := &mapDB{ m: make(map[string]peerEntry), services: service.New(), diff --git a/packages/autopeering/peer/mapdb_test.go b/packages/autopeering/peer/mapdb_test.go index 516d735165..5c7580b743 100644 --- a/packages/autopeering/peer/mapdb_test.go +++ b/packages/autopeering/peer/mapdb_test.go @@ -2,50 +2,41 @@ package peer import ( "crypto/ed25519" - "log" "testing" "time" + "github.com/iotaledger/hive.go/logger" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.uber.org/zap" ) -var logger *zap.SugaredLogger - -func init() { - l, err := zap.NewDevelopment() - if err != nil { - log.Fatalf("cannot initialize logger: %v", err) - } - logger = l.Sugar() -} +var log = logger.NewExampleLogger("peer") func TestMapDBPing(t *testing.T) { p := newTestPeer() - db := NewMemoryDB(logger) + db := NewMemoryDB(log) - time := time.Now() - err := db.UpdateLastPing(p.ID(), p.Address(), time) + now := time.Now() + err := db.UpdateLastPing(p.ID(), p.Address(), now) require.NoError(t, err) - assert.Equal(t, time.Unix(), db.LastPing(p.ID(), p.Address()).Unix()) + assert.Equal(t, now.Unix(), db.LastPing(p.ID(), p.Address()).Unix()) } func TestMapDBPong(t *testing.T) { p := newTestPeer() - db := NewMemoryDB(logger) + db := NewMemoryDB(log) - time := time.Now() - err := db.UpdateLastPong(p.ID(), p.Address(), time) + now := time.Now() + err := db.UpdateLastPong(p.ID(), p.Address(), now) require.NoError(t, err) - assert.Equal(t, time.Unix(), db.LastPong(p.ID(), p.Address()).Unix()) + assert.Equal(t, now.Unix(), db.LastPong(p.ID(), p.Address()).Unix()) } func TestMapDBPeer(t *testing.T) { p := newTestPeer() - db := NewMemoryDB(logger) + db := NewMemoryDB(log) err := db.UpdatePeer(p) require.NoError(t, err) @@ -55,7 +46,7 @@ func TestMapDBPeer(t *testing.T) { func TestMapDBSeedPeers(t *testing.T) { p := newTestPeer() - db := NewMemoryDB(logger) + db := NewMemoryDB(log) require.NoError(t, db.UpdatePeer(p)) require.NoError(t, db.UpdateLastPong(p.ID(), p.Address(), time.Now())) @@ -65,7 +56,7 @@ func TestMapDBSeedPeers(t *testing.T) { } func TestMapDBLocal(t *testing.T) { - db := NewMemoryDB(logger) + db := NewMemoryDB(log) l1, err := NewLocal(testNetwork, testAddress, db) require.NoError(t, err) diff --git a/packages/autopeering/peer/peerdb.go b/packages/autopeering/peer/peerdb.go index 3947f3afb1..b5cfcdfbb8 100644 --- a/packages/autopeering/peer/peerdb.go +++ b/packages/autopeering/peer/peerdb.go @@ -9,7 +9,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/database" - "go.uber.org/zap" + "github.com/iotaledger/hive.go/logger" ) const ( @@ -57,7 +57,7 @@ type DB interface { type persistentDB struct { db database.Database - log *zap.SugaredLogger + log *logger.Logger closeOnce sync.Once } @@ -77,7 +77,7 @@ const ( ) // NewPersistentDB creates a new persistent DB. -func NewPersistentDB(log *zap.SugaredLogger) DB { +func NewPersistentDB(log *logger.Logger) DB { db, err := database.Get("peer") if err != nil { panic(err) diff --git a/packages/autopeering/salt/salt.go b/packages/autopeering/salt/salt.go index 917f5a9127..07afb2ea52 100644 --- a/packages/autopeering/salt/salt.go +++ b/packages/autopeering/salt/salt.go @@ -37,7 +37,7 @@ func NewSalt(lifetime time.Duration) (salt *Salt, err error) { func (s *Salt) GetBytes() []byte { s.mutex.RLock() defer s.mutex.RUnlock() - return s.bytes + return append([]byte{}, s.bytes...) } func (s *Salt) GetExpiration() time.Time { diff --git a/packages/autopeering/selection/common.go b/packages/autopeering/selection/common.go index e31c84168e..679de027c3 100644 --- a/packages/autopeering/selection/common.go +++ b/packages/autopeering/selection/common.go @@ -4,38 +4,71 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" - "go.uber.org/zap" + "github.com/iotaledger/hive.go/logger" +) + +// Default values for the global parameters +const ( + DefaultInboundNeighborSize = 4 + DefaultOutboundNeighborSize = 4 + DefaultSaltLifetime = 30 * time.Minute + DefaultOutboundUpdateInterval = 1 * time.Second + DefaultFullOutboundUpdateInterval = 1 * time.Minute +) + +var ( + inboundNeighborSize = DefaultInboundNeighborSize // number of inbound neighbors + outboundNeighborSize = DefaultOutboundNeighborSize // number of outbound neighbors + saltLifetime = DefaultSaltLifetime // lifetime of the private and public local salt + outboundUpdateInterval = DefaultOutboundUpdateInterval // time after which out neighbors are updated + fullOutboundUpdateInterval = DefaultFullOutboundUpdateInterval // time after which full out neighbors are updated ) // Config holds settings for the peer selection. type Config struct { // Logger - Log *zap.SugaredLogger + Log *logger.Logger // These settings are optional: - Param *Parameters // parameters + DropOnUpdate bool // set true to drop all neighbors when the salt is updated + RequiredServices []service.Key // services required in order to select/be selected during autopeering } -// default parameter values -const ( - // DefaultInboundNeighborSize is the default number of inbound neighbors. - DefaultInboundNeighborSize = 4 - // DefaultOutboundNeighborSize is the default number of outbound neighbors. - DefaultOutboundNeighborSize = 4 - - // DefaultSaltLifetime is the default lifetime of the private and public local salt. - DefaultSaltLifetime = 30 * time.Minute - - // DefaultUpdateOutboundInterval is the default time interval after which the outbound neighbors are checked. - DefaultUpdateOutboundInterval = 200 * time.Millisecond -) - // Parameters holds the parameters that can be configured. type Parameters struct { - InboundNeighborSize int // number of inbound neighbors - OutboundNeighborSize int // number of outbound neighbors - SaltLifetime time.Duration // lifetime of the private and public local salt - UpdateOutboundInterval time.Duration // time interval after which the outbound neighbors are checked - DropNeighborsOnUpdate bool // set true to drop all neighbors when the distance is updated - RequiredService []service.Key // services required in order to select/be selected during autopeering + InboundNeighborSize int // number of inbound neighbors + OutboundNeighborSize int // number of outbound neighbors + SaltLifetime time.Duration // lifetime of the private and public local salt + OutboundUpdateInterval time.Duration // time interval after which the outbound neighbors are checked + FullOutboundUpdateInterval time.Duration // time after which the full outbound neighbors are updated +} + +// SetParameters sets the global parameters for this package. +// This function cannot be used concurrently. +func SetParameters(param Parameters) { + if param.InboundNeighborSize > 0 { + inboundNeighborSize = param.InboundNeighborSize + } else { + inboundNeighborSize = DefaultInboundNeighborSize + } + if param.OutboundNeighborSize > 0 { + outboundNeighborSize = param.OutboundNeighborSize + } else { + outboundNeighborSize = DefaultOutboundNeighborSize + } + if param.SaltLifetime > 0 { + saltLifetime = param.SaltLifetime + } else { + saltLifetime = DefaultSaltLifetime + } + if param.OutboundUpdateInterval > 0 { + outboundUpdateInterval = param.OutboundUpdateInterval + } else { + outboundUpdateInterval = DefaultOutboundUpdateInterval + } + if param.FullOutboundUpdateInterval > 0 { + fullOutboundUpdateInterval = param.FullOutboundUpdateInterval + } else { + fullOutboundUpdateInterval = DefaultFullOutboundUpdateInterval + } } diff --git a/packages/autopeering/selection/events.go b/packages/autopeering/selection/events.go index 9a312b2fee..bc927e9173 100644 --- a/packages/autopeering/selection/events.go +++ b/packages/autopeering/selection/events.go @@ -2,25 +2,34 @@ package selection import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/salt" "github.com/iotaledger/hive.go/events" ) // Events contains all the events that are triggered during the neighbor selection. var Events = struct { + // A SaltUpdated event is triggered, when the private and public salt were updated. + SaltUpdated *events.Event // An OutgoingPeering event is triggered, when a valid response of PeeringRequest has been received. OutgoingPeering *events.Event // An IncomingPeering event is triggered, when a valid PeerRequest has been received. IncomingPeering *events.Event - - // A Dropped event is triggered, when a neigbhor is dropped or when a drop message is received. + // A Dropped event is triggered, when a neighbor is dropped or when a drop message is received. Dropped *events.Event }{ + SaltUpdated: events.NewEvent(saltUpdatedCaller), OutgoingPeering: events.NewEvent(peeringCaller), IncomingPeering: events.NewEvent(peeringCaller), Dropped: events.NewEvent(droppedCaller), } -// PeeringEvent bundles the information sent in a peering event. +// SaltUpdatedEvent bundles the information sent in the SaltUpdated event. +type SaltUpdatedEvent struct { + Self peer.ID // ID of the peer triggering the event. + Public, Private *salt.Salt // the updated salt +} + +// PeeringEvent bundles the information sent in the OutgoingPeering and IncomingPeering event. type PeeringEvent struct { Self peer.ID // ID of the peer triggering the event. Peer *peer.Peer // peering partner @@ -33,6 +42,10 @@ type DroppedEvent struct { DroppedID peer.ID // ID of the peer that gets dropped. } +func saltUpdatedCaller(handler interface{}, params ...interface{}) { + handler.(func(*SaltUpdatedEvent))(params[0].(*SaltUpdatedEvent)) +} + func peeringCaller(handler interface{}, params ...interface{}) { handler.(func(*PeeringEvent))(params[0].(*PeeringEvent)) } diff --git a/packages/autopeering/selection/manager.go b/packages/autopeering/selection/manager.go index c30ef6aef1..0ac30f101d 100644 --- a/packages/autopeering/selection/manager.go +++ b/packages/autopeering/selection/manager.go @@ -1,14 +1,13 @@ package selection import ( - "math/rand" "sync" "time" "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/autopeering/salt" - "go.uber.org/zap" + "github.com/iotaledger/hive.go/logger" ) const ( @@ -16,20 +15,7 @@ const ( reject = false // buffer size of the channels handling inbound requests and drops. - queueSize = 100 -) - -var ( - // number of neighbors - inboundNeighborSize = DefaultInboundNeighborSize - outboundNeighborSize = DefaultOutboundNeighborSize - - // lifetime of the private and public local salt - saltLifetime = DefaultSaltLifetime - // time interval after which the outbound neighbors are checked - updateOutboundInterval = DefaultUpdateOutboundInterval - - dropNeighborsOnUpdate bool // whether all neighbors are dropped on distance update + queueSize = 10 ) // A network represents the communication layer for the manager. @@ -37,7 +23,7 @@ type network interface { local() *peer.Local RequestPeering(*peer.Peer, *salt.Salt) (bool, error) - DropPeer(*peer.Peer) + SendPeeringDrop(*peer.Peer) } type peeringRequest struct { @@ -46,367 +32,342 @@ type peeringRequest struct { } type manager struct { - net network - peersFunc func() []*peer.Peer - - log *zap.SugaredLogger - dropNeighbors bool + net network + getPeersToConnect func() []*peer.Peer + log *logger.Logger + dropOnUpdate bool // set true to drop all neighbors when the salt is updated + requiredServices []service.Key // services required in order to select/be selected during autopeering inbound *Neighborhood outbound *Neighborhood - inboundRequestChan chan peeringRequest - inboundReplyChan chan bool - inboundDropChan chan peer.ID - outboundDropChan chan peer.ID - rejectionFilter *Filter - wg sync.WaitGroup - inboundClosing chan struct{} - outboundClosing chan struct{} + dropChan chan peer.ID + requestChan chan peeringRequest + replyChan chan bool - requiredService []service.Key + wg sync.WaitGroup + closing chan struct{} } -func newManager(net network, peersFunc func() []*peer.Peer, log *zap.SugaredLogger, param *Parameters) *manager { - var requiredService []service.Key - - if param != nil { - if param.InboundNeighborSize > 0 { - inboundNeighborSize = param.InboundNeighborSize - } - if param.OutboundNeighborSize > 0 { - outboundNeighborSize = param.OutboundNeighborSize - } - if param.SaltLifetime > 0 { - saltLifetime = param.SaltLifetime - } - if param.UpdateOutboundInterval > 0 { - updateOutboundInterval = param.UpdateOutboundInterval - } - requiredService = param.RequiredService - dropNeighborsOnUpdate = param.DropNeighborsOnUpdate - } - +func newManager(net network, peersFunc func() []*peer.Peer, log *logger.Logger, config Config) *manager { return &manager{ - net: net, - peersFunc: peersFunc, - log: log, - dropNeighbors: dropNeighborsOnUpdate, - inboundClosing: make(chan struct{}), - outboundClosing: make(chan struct{}), - rejectionFilter: NewFilter(), - inboundRequestChan: make(chan peeringRequest, queueSize), - inboundReplyChan: make(chan bool), - inboundDropChan: make(chan peer.ID, queueSize), - outboundDropChan: make(chan peer.ID, queueSize), - inbound: &Neighborhood{ - Neighbors: []peer.PeerDistance{}, - Size: inboundNeighborSize}, - outbound: &Neighborhood{ - Neighbors: []peer.PeerDistance{}, - Size: outboundNeighborSize}, - requiredService: requiredService, + net: net, + getPeersToConnect: peersFunc, + log: log, + dropOnUpdate: config.DropOnUpdate, + requiredServices: config.RequiredServices, + inbound: NewNeighborhood(inboundNeighborSize), + outbound: NewNeighborhood(outboundNeighborSize), + rejectionFilter: NewFilter(), + dropChan: make(chan peer.ID, queueSize), + requestChan: make(chan peeringRequest, queueSize), + replyChan: make(chan bool, 1), + closing: make(chan struct{}), } } func (m *manager) start() { - // create valid salts - if m.net.local().GetPublicSalt() == nil || m.net.local().GetPrivateSalt() == nil { + if m.getPublicSalt() == nil || m.getPrivateSalt() == nil { m.updateSalt() } - - m.wg.Add(2) - go m.loopOutbound() - go m.loopInbound() + m.wg.Add(1) + go m.loop() } func (m *manager) close() { - close(m.inboundClosing) - close(m.outboundClosing) + close(m.closing) m.wg.Wait() } -func (m *manager) self() peer.ID { +func (m *manager) getID() peer.ID { return m.net.local().ID() } -func (m *manager) loopOutbound() { - defer m.wg.Done() - - var ( - updateOutboundDone chan struct{} - updateOutbound = time.NewTimer(0) // setting this to 0 will cause a trigger right away - backoff = 10 - ) - defer updateOutbound.Stop() +func (m *manager) getPublicSalt() *salt.Salt { + return m.net.local().GetPublicSalt() +} -Loop: - for { - select { - case <-updateOutbound.C: - // if there is no updateOutbound, this means doUpdateOutbound is not running - if updateOutboundDone == nil { - // check salt and update if necessary (this will drop the whole neighborhood) - if m.net.local().GetPublicSalt().Expired() { - m.updateSalt() - } +func (m *manager) getPrivateSalt() *salt.Salt { + return m.net.local().GetPrivateSalt() +} - //remove potential duplicates - dup := m.getDuplicates() - for _, peerToDrop := range dup { - toDrop := m.inbound.GetPeerFromID(peerToDrop) - time.Sleep(time.Duration(rand.Intn(backoff)) * time.Millisecond) - m.outbound.RemovePeer(peerToDrop) - m.inbound.RemovePeer(peerToDrop) - if toDrop != nil { - m.dropPeer(toDrop) - } - } +func (m *manager) getNeighbors() []*peer.Peer { + var neighbors []*peer.Peer + neighbors = append(neighbors, m.inbound.GetPeers()...) + neighbors = append(neighbors, m.outbound.GetPeers()...) - updateOutboundDone = make(chan struct{}) - go m.updateOutbound(updateOutboundDone) - } + return neighbors +} - case <-updateOutboundDone: - updateOutboundDone = nil - updateOutbound.Reset(updateOutboundInterval) // updateOutbound again after the given interval +func (m *manager) getInNeighbors() []*peer.Peer { + return m.inbound.GetPeers() +} - case peerToDrop := <-m.outboundDropChan: - if containsPeer(m.outbound.GetPeers(), peerToDrop) { - m.outbound.RemovePeer(peerToDrop) - m.rejectionFilter.AddPeer(peerToDrop) - m.log.Debug("Outbound Dropped BY ", peerToDrop, " (", len(m.outbound.GetPeers()), ",", len(m.inbound.GetPeers()), ")") - } +func (m *manager) getOutNeighbors() []*peer.Peer { + return m.outbound.GetPeers() +} - // on close, exit the loop - case <-m.outboundClosing: - break Loop - } +func (m *manager) requestPeering(p *peer.Peer, s *salt.Salt) bool { + var status bool + select { + case m.requestChan <- peeringRequest{p, s}: + status = <-m.replyChan + default: + // a full queue should count as a failed request + status = false } + return status +} - // wait for the updateOutbound to finish - if updateOutboundDone != nil { - <-updateOutboundDone - } +func (m *manager) removeNeighbor(id peer.ID) { + m.dropChan <- id } -func (m *manager) loopInbound() { +func (m *manager) loop() { defer m.wg.Done() + var updateOutResultChan chan peer.PeerDistance + updateTimer := time.NewTimer(0) // setting this to 0 will cause a trigger right away + defer updateTimer.Stop() + Loop: for { select { - case req := <-m.inboundRequestChan: - m.updateInbound(req.peer, req.salt) - case peerToDrop := <-m.inboundDropChan: - if containsPeer(m.inbound.GetPeers(), peerToDrop) { - m.inbound.RemovePeer(peerToDrop) - m.log.Debug("Inbound Dropped BY ", peerToDrop, " (", len(m.outbound.GetPeers()), ",", len(m.inbound.GetPeers()), ")") + // update the outbound neighbors + case <-updateTimer.C: + updateOutResultChan = make(chan peer.PeerDistance) + // check salt and update if necessary + if m.getPublicSalt().Expired() { + m.updateSalt() } + // check for new peers to connect to in a separate go routine + go m.updateOutbound(updateOutResultChan) + + // handle the result of updateOutbound + case req := <-updateOutResultChan: + if req.Remote != nil { + // if the peer is already in inbound, do not add it and remove it from inbound + if p := m.inbound.RemovePeer(req.Remote.ID()); p != nil { + m.triggerPeeringEvent(true, req.Remote, false) + m.dropPeering(p) + } else { + m.addNeighbor(m.outbound, req) + m.triggerPeeringEvent(true, req.Remote, true) + } + } + // call updateOutbound again after the given interval + updateOutResultChan = nil + updateTimer.Reset(m.getUpdateTimeout()) + + // handle a drop request + case id := <-m.dropChan: + droppedPeer := m.inbound.RemovePeer(id) + if p := m.outbound.RemovePeer(id); p != nil { + droppedPeer = p + m.rejectionFilter.AddPeer(id) + // if not yet updating, trigger an immediate update + if updateOutResultChan == nil && updateTimer.Stop() { + updateTimer.Reset(0) + } + } + if droppedPeer != nil { + m.dropPeering(droppedPeer) + } + + // handle an inbound request + case req := <-m.requestChan: + status := m.handleInRequest(req) + // trigger in the main loop to guarantee order of events + m.triggerPeeringEvent(false, req.peer, status) // on close, exit the loop - case <-m.inboundClosing: + case <-m.closing: break Loop } } + + // wait for the updateOutbound to finish + if updateOutResultChan != nil { + <-updateOutResultChan + } +} + +func (m *manager) getUpdateTimeout() time.Duration { + result := outboundUpdateInterval + if m.outbound.IsFull() { + result = fullOutboundUpdateInterval + } + saltExpiration := time.Until(m.getPublicSalt().GetExpiration()) + if saltExpiration < result { + result = saltExpiration + } + return result } // updateOutbound updates outbound neighbors. -func (m *manager) updateOutbound(done chan<- struct{}) { - defer func() { - done <- struct{}{} - }() // always signal, when the function returns +func (m *manager) updateOutbound(resultChan chan<- peer.PeerDistance) { + var result peer.PeerDistance + defer func() { resultChan <- result }() // assure that a result is always sent to the channel // sort verified peers by distance - distList := peer.SortBySalt(m.self().Bytes(), m.net.local().GetPublicSalt().GetBytes(), m.peersFunc()) - - filter := NewFilter() - filter.AddPeer(m.self()) //set filter for ourself - filter.AddPeers(m.inbound.GetPeers()) // set filter for inbound neighbors - filter.AddPeers(m.outbound.GetPeers()) // set filter for outbound neighbors - - filteredList := filter.Apply(distList) // filter out current neighbors - filteredList = m.rejectionFilter.Apply(filteredList) // filter out previous rejection + distList := peer.SortBySalt(m.getID().Bytes(), m.getPublicSalt().GetBytes(), m.getPeersToConnect()) + + // filter out current neighbors + filter := m.getConnectedFilter() + filteredList := filter.Apply(distList) + // filter out previous rejections + filteredList = m.rejectionFilter.Apply(filteredList) + if len(filteredList) == 0 { + return + } // select new candidate candidate := m.outbound.Select(filteredList) + if candidate.Remote == nil { + return + } - if candidate.Remote != nil { - // reject if required services are missing - for _, reqService := range m.requiredService { - if candidate.Remote.Services().Get(reqService) == nil { - m.rejectionFilter.AddPeer(candidate.Remote.ID()) - return - } - } - - furthest, _ := m.outbound.getFurthest() - - // send peering request - mySalt := m.net.local().GetPublicSalt() - status, err := m.net.RequestPeering(candidate.Remote, mySalt) - if err != nil { - m.rejectionFilter.AddPeer(candidate.Remote.ID()) // TODO: add retries - return - } - - // add candidate to the outbound neighborhood - if status { - //m.acceptedFilter.AddPeer(candidate.Remote.ID()) - if furthest.Remote != nil { - m.outbound.RemovePeer(furthest.Remote.ID()) - m.dropPeer(furthest.Remote) - m.log.Debug("Outbound furthest removed ", furthest.Remote.ID()) - } - m.outbound.Add(candidate) - m.log.Debug("Peering request TO ", candidate.Remote.ID(), " status ACCEPTED (", len(m.outbound.GetPeers()), ",", len(m.inbound.GetPeers()), ")") - } else { - m.log.Debug("Peering request TO ", candidate.Remote.ID(), " status REJECTED (", len(m.outbound.GetPeers()), ",", len(m.inbound.GetPeers()), ")") - m.rejectionFilter.AddPeer(candidate.Remote.ID()) - //m.log.Debug("Rejection Filter ", candidate.Remote.ID()) - } - - // signal the result of the outgoing peering request - Events.OutgoingPeering.Trigger(&PeeringEvent{Self: m.self(), Peer: candidate.Remote, Status: status}) + // send peering request + status, err := m.net.RequestPeering(candidate.Remote, m.getPublicSalt()) + if err != nil { + m.rejectionFilter.AddPeer(candidate.Remote.ID()) + m.log.Debugw("error requesting peering", + "id", candidate.Remote.ID(), + "addr", candidate.Remote.Address(), "err", err, + ) + return } + if !status { + m.rejectionFilter.AddPeer(candidate.Remote.ID()) + m.triggerPeeringEvent(true, candidate.Remote, false) + return + } + + result = candidate } -func (m *manager) updateInbound(requester *peer.Peer, salt *salt.Salt) { - // TODO: check request legitimacy - //m.log.Debug("Evaluating peering request FROM ", requester.ID()) - reqDistance := peer.NewPeerDistance(m.self().Bytes(), m.net.local().GetPrivateSalt().GetBytes(), requester) +func (m *manager) handleInRequest(req peeringRequest) (resp bool) { + resp = reject + defer func() { m.replyChan <- resp }() // assure that a response is always issued - candidateList := []peer.PeerDistance{reqDistance} + if !m.isValidNeighbor(req.peer) { + return + } - filter := NewFilter() - filter.AddPeers(m.outbound.GetPeers()) // set filter for outbound neighbors - filteredList := filter.Apply(candidateList) // filter out current neighbors + reqDistance := peer.NewPeerDistance(m.getID().Bytes(), m.getPrivateSalt().GetBytes(), req.peer) + filter := m.getConnectedFilter() + filteredList := filter.Apply([]peer.PeerDistance{reqDistance}) + if len(filteredList) == 0 { + return + } - // make decision toAccept := m.inbound.Select(filteredList) - for _, reqService := range m.requiredService { - if requester.Services().Get(reqService) == nil { - toAccept.Remote = nil // reject if required services are missing - break - } - } - // reject request if toAccept.Remote == nil { - m.log.Debug("Peering request FROM ", requester.ID(), " status REJECTED (", len(m.outbound.GetPeers()), ",", len(m.inbound.GetPeers()), ")") - m.inboundReplyChan <- reject return } - // accept request - m.inboundReplyChan <- accept - furthest, _ := m.inbound.getFurthest() - // drop furthest neighbor - if furthest.Remote != nil { - m.inbound.RemovePeer(furthest.Remote.ID()) - m.dropPeer(furthest.Remote) - m.log.Debug("Inbound furthest removed ", furthest.Remote.ID()) - } - // update inbound neighborhood - m.inbound.Add(toAccept) - m.log.Debug("Peering request FROM ", toAccept.Remote.ID(), " status ACCEPTED (", len(m.outbound.GetPeers()), ",", len(m.inbound.GetPeers()), ")") + + m.addNeighbor(m.inbound, toAccept) + resp = accept + return } -func (m *manager) updateSalt() (*salt.Salt, *salt.Salt) { - pubSalt, _ := salt.NewSalt(saltLifetime) - m.net.local().SetPublicSalt(pubSalt) +func (m *manager) addNeighbor(nh *Neighborhood, toAdd peer.PeerDistance) { + // drop furthest neighbor if necessary + if furthest, _ := nh.getFurthest(); furthest.Remote != nil { + if p := nh.RemovePeer(furthest.Remote.ID()); p != nil { + m.dropPeering(p) + } + } + nh.Add(toAdd) +} - privSalt, _ := salt.NewSalt(saltLifetime) - m.net.local().SetPrivateSalt(privSalt) +func (m *manager) updateSalt() { + public, _ := salt.NewSalt(saltLifetime) + m.net.local().SetPublicSalt(public) + private, _ := salt.NewSalt(saltLifetime) + m.net.local().SetPrivateSalt(private) + // clean the rejection filter m.rejectionFilter.Clean() - if !dropNeighborsOnUpdate { // update distance without dropping neighbors - m.outbound.UpdateDistance(m.self().Bytes(), m.net.local().GetPublicSalt().GetBytes()) - m.inbound.UpdateDistance(m.self().Bytes(), m.net.local().GetPrivateSalt().GetBytes()) + if !m.dropOnUpdate { // update distance without dropping neighbors + m.outbound.UpdateDistance(m.getID().Bytes(), m.getPublicSalt().GetBytes()) + m.inbound.UpdateDistance(m.getID().Bytes(), m.getPrivateSalt().GetBytes()) } else { // drop all the neighbors m.dropNeighborhood(m.inbound) m.dropNeighborhood(m.outbound) } - return pubSalt, privSalt -} - -func (m *manager) dropNeighbor(peerToDrop peer.ID) { - m.inboundDropChan <- peerToDrop - m.outboundDropChan <- peerToDrop - - // signal the dropped peer - Events.Dropped.Trigger(&DroppedEvent{Self: m.self(), DroppedID: peerToDrop}) + m.log.Debugw("salt updated", + "public", saltLifetime, + "private", saltLifetime, + ) + Events.SaltUpdated.Trigger(&SaltUpdatedEvent{Self: m.getID(), Public: public, Private: private}) } -// containsPeer returns true if a peer with the given ID is in the list. -func containsPeer(list []*peer.Peer, id peer.ID) bool { - for _, p := range list { - if p.ID() == id { - return true - } +func (m *manager) dropNeighborhood(nh *Neighborhood) { + for _, p := range nh.GetPeers() { + nh.RemovePeer(p.ID()) + m.dropPeering(p) } - return false } -func (m *manager) acceptRequest(p *peer.Peer, s *salt.Salt) bool { - m.inboundRequestChan <- peeringRequest{p, s} - status := <-m.inboundReplyChan +// dropPeering sends the peering drop over the network and triggers the corresponding event. +func (m *manager) dropPeering(p *peer.Peer) { + m.net.SendPeeringDrop(p) - // signal the received request - Events.IncomingPeering.Trigger(&PeeringEvent{Self: m.self(), Peer: p, Status: status}) - - return status -} - -func (m *manager) getNeighbors() []*peer.Peer { - var neighbors []*peer.Peer - - neighbors = append(neighbors, m.inbound.GetPeers()...) - neighbors = append(neighbors, m.outbound.GetPeers()...) - - return neighbors -} - -func (m *manager) getIncomingNeighbors() []*peer.Peer { - var neighbors []*peer.Peer - - neighbors = append(neighbors, m.inbound.GetPeers()...) - - return neighbors + m.log.Debugw("peering dropped", + "id", p.ID(), + "#out", m.outbound, + "#in", m.inbound, + ) + Events.Dropped.Trigger(&DroppedEvent{Self: m.getID(), DroppedID: p.ID()}) } -func (m *manager) getOutgoingNeighbors() []*peer.Peer { - var neighbors []*peer.Peer - - neighbors = append(neighbors, m.outbound.GetPeers()...) - - return neighbors +func (m *manager) getConnectedFilter() *Filter { + filter := NewFilter() + filter.AddPeer(m.getID()) //set filter for oneself + filter.AddPeers(m.inbound.GetPeers()) // set filter for inbound neighbors + filter.AddPeers(m.outbound.GetPeers()) // set filter for outbound neighbors + return filter } -func (m *manager) getDuplicates() []peer.ID { - var d []peer.ID - - for _, p := range m.inbound.GetPeers() { - if containsPeer(m.outbound.GetPeers(), p.ID()) { - d = append(d, p.ID()) +// isValidNeighbor returns whether the given peer is a valid neighbor candidate. +func (m *manager) isValidNeighbor(p *peer.Peer) bool { + // do not connect to oneself + if m.getID() == p.ID() { + return false + } + // reject if required services are missing + for _, reqService := range m.requiredServices { + if p.Services().Get(reqService) == nil { + return false } } - return d + return true } -func (m *manager) dropNeighborhood(nh *Neighborhood) { - for _, p := range nh.GetPeers() { - nh.RemovePeer(p.ID()) - m.dropPeer(p) +func (m *manager) triggerPeeringEvent(isOut bool, p *peer.Peer, status bool) { + if isOut { + m.log.Debugw("peering requested", + "direction", "out", + "status", status, + "to", p.ID(), + "#out", m.outbound, + "#in", m.inbound, + ) + Events.OutgoingPeering.Trigger(&PeeringEvent{Self: m.getID(), Peer: p, Status: status}) + } else { + m.log.Debugw("peering requested", + "direction", "in", + "status", status, + "from", p.ID(), + "#out", m.outbound, + "#in", m.inbound, + ) + Events.IncomingPeering.Trigger(&PeeringEvent{Self: m.getID(), Peer: p, Status: status}) } } - -func (m *manager) dropPeer(p *peer.Peer) { - // send the drop request over the network - m.net.DropPeer(p) - // signal the drop - Events.Dropped.Trigger(&DroppedEvent{Self: m.self(), DroppedID: p.ID()}) -} diff --git a/packages/autopeering/selection/manager_test.go b/packages/autopeering/selection/manager_test.go index daffe4b0ae..15e472a20c 100644 --- a/packages/autopeering/selection/manager_test.go +++ b/packages/autopeering/selection/manager_test.go @@ -2,47 +2,105 @@ package selection import ( "fmt" - "math/rand" + "sync" "testing" "time" "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/salt" + "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" "github.com/stretchr/testify/assert" ) -var ( - allPeers []*peer.Peer +const ( + testSaltLifetime = time.Hour // disable salt updates + testUpdateInterval = 2 * graceTime // very short update interval to speed up tests ) -type testPeer struct { - local *peer.Local - peer *peer.Peer - db peer.DB - log *logger.Logger - rand *rand.Rand // random number generator +func TestMgrNoDuplicates(t *testing.T) { + const ( + nNeighbors = 4 + nNodes = 2*nNeighbors + 1 + ) + SetParameters(Parameters{ + OutboundNeighborSize: nNeighbors, + InboundNeighborSize: nNeighbors, + SaltLifetime: testSaltLifetime, + OutboundUpdateInterval: testUpdateInterval, + }) + + mgrMap := make(map[peer.ID]*manager) + runTestNetwork(nNodes, mgrMap) + + for _, mgr := range mgrMap { + assert.NotEmpty(t, mgr.getOutNeighbors()) + assert.NotEmpty(t, mgr.getInNeighbors()) + assert.Empty(t, getDuplicates(mgr.getNeighbors())) + } +} + +func TestEvents(t *testing.T) { + // we want many drops/connects + const ( + nNeighbors = 2 + nNodes = 10 + ) + SetParameters(Parameters{ + OutboundNeighborSize: nNeighbors, + InboundNeighborSize: nNeighbors, + SaltLifetime: 3 * testUpdateInterval, + OutboundUpdateInterval: testUpdateInterval, + }) + + e, teardown := newEventMock(t) + defer teardown() + mgrMap := make(map[peer.ID]*manager) + runTestNetwork(nNodes, mgrMap) + + // the events should lead to exactly the same neighbors + for _, mgr := range mgrMap { + nc := e.m[mgr.getID()] + assert.ElementsMatchf(t, mgr.getOutNeighbors(), getValues(nc.out), + "out neighbors of %s do not match", mgr.getID()) + assert.ElementsMatch(t, mgr.getInNeighbors(), getValues(nc.in), + "in neighbors of %s do not match", mgr.getID()) + } } -func newPeer(name string) testPeer { - log := log.Named(name) - db := peer.NewMemoryDB(log.Named("db")) - local, _ := peer.NewLocal("", name, db) - s, _ := salt.NewSalt(100 * time.Second) - local.SetPrivateSalt(s) - s, _ = salt.NewSalt(100 * time.Second) - local.SetPublicSalt(s) - p := &local.Peer - return testPeer{local, p, db, log, rand.New(rand.NewSource(time.Now().UnixNano()))} +func getValues(m map[peer.ID]*peer.Peer) []*peer.Peer { + result := make([]*peer.Peer, 0, len(m)) + for _, p := range m { + result = append(result, p) + } + return result } -func removeDuplicatePeers(peers []*peer.Peer) []*peer.Peer { +func runTestNetwork(n int, mgrMap map[peer.ID]*manager) { + for i := 0; i < n; i++ { + _ = newTestManager(fmt.Sprintf("%d", i), mgrMap) + } + for _, mgr := range mgrMap { + mgr.start() + } + + // give the managers time to potentially connect all other peers + time.Sleep((time.Duration(n) - 1) * (outboundUpdateInterval + graceTime)) + + // close all the managers + for _, mgr := range mgrMap { + mgr.close() + } +} + +func getDuplicates(peers []*peer.Peer) []*peer.Peer { seen := make(map[peer.ID]bool, len(peers)) result := make([]*peer.Peer, 0, len(peers)) for _, p := range peers { if !seen[p.ID()] { seen[p.ID()] = true + } else { result = append(result, p) } } @@ -50,74 +108,115 @@ func removeDuplicatePeers(peers []*peer.Peer) []*peer.Peer { return result } -type testNet struct { - loc *peer.Local - self *peer.Peer - mgr map[peer.ID]*manager - rand *rand.Rand +type neighbors struct { + out, in map[peer.ID]*peer.Peer } -func (n testNet) local() *peer.Local { - return n.loc +type eventMock struct { + t *testing.T + lock sync.Mutex + m map[peer.ID]neighbors } -func (n testNet) DropPeer(p *peer.Peer) { - n.mgr[p.ID()].dropNeighbor(n.local().ID()) -} +func newEventMock(t *testing.T) (*eventMock, func()) { + e := &eventMock{ + t: t, + m: make(map[peer.ID]neighbors), + } -func (n testNet) RequestPeering(p *peer.Peer, s *salt.Salt) (bool, error) { - return n.mgr[p.ID()].acceptRequest(n.self, s), nil -} + outgoingPeeringC := events.NewClosure(e.outgoingPeering) + incomingPeeringC := events.NewClosure(e.incomingPeering) + droppedC := events.NewClosure(e.dropped) -func (n testNet) GetKnownPeers() []*peer.Peer { - list := make([]*peer.Peer, len(allPeers)-1) - i := 0 - for _, p := range allPeers { - if p.ID() == n.self.ID() { - continue - } + Events.OutgoingPeering.Attach(outgoingPeeringC) + Events.IncomingPeering.Attach(incomingPeeringC) + Events.Dropped.Attach(droppedC) - list[i] = p - i++ + teardown := func() { + Events.OutgoingPeering.Detach(outgoingPeeringC) + Events.IncomingPeering.Detach(incomingPeeringC) + Events.Dropped.Detach(droppedC) } - return list + return e, teardown } -func TestSimManager(t *testing.T) { - N := 9 // number of peers to generate +func (e *eventMock) outgoingPeering(ev *PeeringEvent) { + if !ev.Status { + return + } + e.lock.Lock() + defer e.lock.Unlock() + s, ok := e.m[ev.Self] + if !ok { + s = neighbors{out: make(map[peer.ID]*peer.Peer), in: make(map[peer.ID]*peer.Peer)} + e.m[ev.Self] = s + } + assert.NotContains(e.t, s.out, ev.Peer) + s.out[ev.Peer.ID()] = ev.Peer +} - allPeers = make([]*peer.Peer, N) +func (e *eventMock) incomingPeering(ev *PeeringEvent) { + if !ev.Status { + return + } + e.lock.Lock() + defer e.lock.Unlock() + s, ok := e.m[ev.Self] + if !ok { + s = neighbors{out: make(map[peer.ID]*peer.Peer), in: make(map[peer.ID]*peer.Peer)} + e.m[ev.Self] = s + } + assert.NotContains(e.t, s.in, ev.Peer) + s.in[ev.Peer.ID()] = ev.Peer +} - mgrMap := make(map[peer.ID]*manager) - for i := range allPeers { - p := newPeer(fmt.Sprintf("%d", i)) - allPeers[i] = p.peer - - net := testNet{ - mgr: mgrMap, - loc: p.local, - self: p.peer, - rand: p.rand, - } - mgrMap[p.local.ID()] = newManager(net, net.GetKnownPeers, p.log, &Parameters{SaltLifetime: 100 * time.Second}) +func (e *eventMock) dropped(ev *DroppedEvent) { + e.lock.Lock() + defer e.lock.Unlock() + if assert.Contains(e.t, e.m, ev.Self) { + s := e.m[ev.Self] + delete(s.out, ev.DroppedID) + delete(s.in, ev.DroppedID) } +} - // start all the managers - for _, mgr := range mgrMap { - mgr.start() +type networkMock struct { + loc *peer.Local + mgr map[peer.ID]*manager +} + +func newNetworkMock(name string, mgrMap map[peer.ID]*manager, log *logger.Logger) *networkMock { + local, _ := peer.NewLocal("mock", name, peer.NewMemoryDB(log)) + return &networkMock{ + loc: local, + mgr: mgrMap, } +} - time.Sleep(6 * time.Second) +func (n *networkMock) local() *peer.Local { + return n.loc +} - for i, p := range allPeers { - neighbors := mgrMap[p.ID()].getNeighbors() +func (n *networkMock) SendPeeringDrop(p *peer.Peer) { + n.mgr[p.ID()].removeNeighbor(n.local().ID()) +} - assert.NotEmpty(t, neighbors, "Peer %d has no neighbors", i) - assert.Equal(t, removeDuplicatePeers(neighbors), neighbors, "Peer %d has non unique neighbors", i) - } +func (n *networkMock) RequestPeering(p *peer.Peer, s *salt.Salt) (bool, error) { + return n.mgr[p.ID()].requestPeering(&n.local().Peer, s), nil +} - // close all the managers - for _, mgr := range mgrMap { - mgr.close() +func (n *networkMock) GetKnownPeers() []*peer.Peer { + peers := make([]*peer.Peer, 0, len(n.mgr)) + for _, m := range n.mgr { + peers = append(peers, &m.net.local().Peer) } + return peers +} + +func newTestManager(name string, mgrMap map[peer.ID]*manager) *manager { + l := log.Named(name) + net := newNetworkMock(name, mgrMap, l) + m := newManager(net, net.GetKnownPeers, l, Config{}) + mgrMap[m.getID()] = m + return m } diff --git a/packages/autopeering/selection/neighborhood.go b/packages/autopeering/selection/neighborhood.go index e3e138b22f..638874b0ba 100644 --- a/packages/autopeering/selection/neighborhood.go +++ b/packages/autopeering/selection/neighborhood.go @@ -1,6 +1,7 @@ package selection import ( + "fmt" "sync" "github.com/iotaledger/goshimmer/packages/autopeering/distance" @@ -8,26 +9,37 @@ import ( ) type Neighborhood struct { - Neighbors []peer.PeerDistance - Size int - mutex sync.RWMutex + neighbors []peer.PeerDistance + size int + mu sync.RWMutex +} + +func NewNeighborhood(size int) *Neighborhood { + return &Neighborhood{ + neighbors: []peer.PeerDistance{}, + size: size, + } +} + +func (nh *Neighborhood) String() string { + return fmt.Sprintf("%d/%d", nh.GetNumPeers(), nh.size) } func (nh *Neighborhood) getFurthest() (peer.PeerDistance, int) { - nh.mutex.RLock() - defer nh.mutex.RUnlock() - if len(nh.Neighbors) < nh.Size { + nh.mu.RLock() + defer nh.mu.RUnlock() + if len(nh.neighbors) < nh.size { return peer.PeerDistance{ Remote: nil, Distance: distance.Max, - }, len(nh.Neighbors) + }, len(nh.neighbors) } index := 0 - furthest := nh.Neighbors[index] - for i, neighbor := range nh.Neighbors { - if neighbor.Distance > furthest.Distance { - furthest = neighbor + furthest := nh.neighbors[index] + for i, n := range nh.neighbors { + if n.Distance > furthest.Distance { + furthest = n index = i } } @@ -46,63 +58,75 @@ func (nh *Neighborhood) Select(candidates []peer.PeerDistance) peer.PeerDistance return peer.PeerDistance{} } -func (nh *Neighborhood) Add(toAdd peer.PeerDistance) { - nh.mutex.Lock() - defer nh.mutex.Unlock() - if len(nh.Neighbors) < nh.Size { - nh.Neighbors = append(nh.Neighbors, toAdd) +// Add tries to add a new peer with distance to the neighborhood. +// It returns true, if the peer was added, or false if the neighborhood was full. +func (nh *Neighborhood) Add(toAdd peer.PeerDistance) bool { + nh.mu.Lock() + defer nh.mu.Unlock() + if len(nh.neighbors) >= nh.size { + return false } + nh.neighbors = append(nh.neighbors, toAdd) + return true } -func (nh *Neighborhood) RemovePeer(toRemove peer.ID) { - index := nh.getPeerIndex(toRemove) - nh.mutex.Lock() - defer nh.mutex.Unlock() - if index < 0 || len(nh.Neighbors) == 0 || len(nh.Neighbors) < index+1 { - return +// RemovePeer removes the peer with the given ID from the neighborhood. +// It returns the peer that was removed or nil of no such peer exists. +func (nh *Neighborhood) RemovePeer(id peer.ID) *peer.Peer { + nh.mu.Lock() + defer nh.mu.Unlock() + + index := nh.getPeerIndex(id) + if index < 0 { + return nil + } + n := nh.neighbors[index] + + // remove index from slice + if index < len(nh.neighbors)-1 { + copy(nh.neighbors[index:], nh.neighbors[index+1:]) } - nh.Neighbors[index] = peer.PeerDistance{} - copy(nh.Neighbors[index:], nh.Neighbors[index+1:]) - nh.Neighbors = nh.Neighbors[:len(nh.Neighbors)-1] + nh.neighbors[len(nh.neighbors)-1] = peer.PeerDistance{} + nh.neighbors = nh.neighbors[:len(nh.neighbors)-1] + + return n.Remote } -func (nh *Neighborhood) getPeerIndex(target peer.ID) int { - nh.mutex.RLock() - defer nh.mutex.RUnlock() - for i, peer := range nh.Neighbors { - if peer.Remote.ID() == target { +func (nh *Neighborhood) getPeerIndex(id peer.ID) int { + for i, p := range nh.neighbors { + if p.Remote.ID() == id { return i } } return -1 - } func (nh *Neighborhood) UpdateDistance(anchor, salt []byte) { - nh.mutex.Lock() - defer nh.mutex.Unlock() - for i, peer := range nh.Neighbors { - nh.Neighbors[i].Distance = distance.BySalt(anchor, peer.Remote.ID().Bytes(), salt) + nh.mu.Lock() + defer nh.mu.Unlock() + for i, n := range nh.neighbors { + nh.neighbors[i].Distance = distance.BySalt(anchor, n.Remote.ID().Bytes(), salt) } } +func (nh *Neighborhood) IsFull() bool { + nh.mu.RLock() + defer nh.mu.RUnlock() + return len(nh.neighbors) >= nh.size +} + func (nh *Neighborhood) GetPeers() []*peer.Peer { - nh.mutex.RLock() - defer nh.mutex.RUnlock() - list := make([]*peer.Peer, len(nh.Neighbors)) - for i, peer := range nh.Neighbors { - list[i] = peer.Remote + nh.mu.RLock() + defer nh.mu.RUnlock() + result := make([]*peer.Peer, len(nh.neighbors)) + for i, n := range nh.neighbors { + result[i] = n.Remote } - return list + return result } -func (nh *Neighborhood) GetPeerFromID(id peer.ID) *peer.Peer { - nh.mutex.RLock() - defer nh.mutex.RUnlock() - for _, peer := range nh.Neighbors { - if peer.Remote.ID() == id { - return peer.Remote - } - } - return nil +func (nh *Neighborhood) GetNumPeers() int { + nh.mu.RLock() + defer nh.mu.RUnlock() + return len(nh.neighbors) } diff --git a/packages/autopeering/selection/neighborhood_test.go b/packages/autopeering/selection/neighborhood_test.go index 40fcf5978f..19dc521169 100644 --- a/packages/autopeering/selection/neighborhood_test.go +++ b/packages/autopeering/selection/neighborhood_test.go @@ -26,8 +26,8 @@ func TestGetFurthest(t *testing.T) { tests := []testCase{ { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0]}, + size: 4}, expected: peer.PeerDistance{ Remote: nil, Distance: distance.Max}, @@ -35,15 +35,15 @@ func TestGetFurthest(t *testing.T) { }, { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0], d[1], d[2], d[3]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0], d[1], d[2], d[3]}, + size: 4}, expected: d[3], index: 3, }, { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, + size: 4}, expected: d[4], index: 2, }, @@ -72,22 +72,22 @@ func TestGetPeerIndex(t *testing.T) { tests := []testCase{ { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0]}, + size: 4}, target: d[0].Remote, index: 0, }, { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0], d[1], d[2], d[3]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0], d[1], d[2], d[3]}, + size: 4}, target: d[3].Remote, index: 3, }, { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, + size: 4}, target: d[3].Remote, index: -1, }, @@ -115,22 +115,22 @@ func TestRemove(t *testing.T) { tests := []testCase{ { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0]}, + size: 4}, toRemove: d[0].Remote, expected: []peer.PeerDistance{}, }, { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0], d[1], d[3]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0], d[1], d[3]}, + size: 4}, toRemove: d[1].Remote, expected: []peer.PeerDistance{d[0], d[3]}, }, { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, + size: 4}, toRemove: d[2].Remote, expected: []peer.PeerDistance{d[0], d[1], d[4]}, }, @@ -138,7 +138,7 @@ func TestRemove(t *testing.T) { for _, test := range tests { test.input.RemovePeer(test.toRemove.ID()) - assert.Equal(t, test.expected, test.input.Neighbors, "Remove") + assert.Equal(t, test.expected, test.input.neighbors, "Remove") } } @@ -158,22 +158,22 @@ func TestAdd(t *testing.T) { tests := []testCase{ { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0]}, + size: 4}, toAdd: d[2], expected: []peer.PeerDistance{d[0], d[2]}, }, { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0], d[1], d[3]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0], d[1], d[3]}, + size: 4}, toAdd: d[2], expected: []peer.PeerDistance{d[0], d[1], d[3], d[2]}, }, { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, + size: 4}, toAdd: d[3], expected: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, }, @@ -181,7 +181,7 @@ func TestAdd(t *testing.T) { for _, test := range tests { test.input.Add(test.toAdd) - assert.Equal(t, test.expected, test.input.Neighbors, "Add") + assert.Equal(t, test.expected, test.input.neighbors, "Add") } } @@ -201,12 +201,12 @@ func TestUpdateDistance(t *testing.T) { } neighborhood := Neighborhood{ - Neighbors: d[1:], - Size: 4} + neighbors: d[1:], + size: 4} neighborhood.UpdateDistance(d[0].Remote.ID().Bytes(), s.GetBytes()) - assert.Equal(t, d2, neighborhood.Neighbors, "UpdateDistance") + assert.Equal(t, d2, neighborhood.neighbors, "UpdateDistance") } func TestGetPeers(t *testing.T) { @@ -227,20 +227,20 @@ func TestGetPeers(t *testing.T) { tests := []testCase{ { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{}, - Size: 4}, + neighbors: []peer.PeerDistance{}, + size: 4}, expected: []*peer.Peer{}, }, { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0]}, + size: 4}, expected: []*peer.Peer{peers[0]}, }, { input: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0], d[1], d[3], d[2]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0], d[1], d[3], d[2]}, + size: 4}, expected: []*peer.Peer{peers[0], peers[1], peers[3], peers[2]}, }, } diff --git a/packages/autopeering/selection/protocol.go b/packages/autopeering/selection/protocol.go index 3b4b36c1a5..dd92c1f2f7 100644 --- a/packages/autopeering/selection/protocol.go +++ b/packages/autopeering/selection/protocol.go @@ -10,8 +10,8 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/salt" pb "github.com/iotaledger/goshimmer/packages/autopeering/selection/proto" "github.com/iotaledger/goshimmer/packages/autopeering/server" + "github.com/iotaledger/hive.go/logger" "github.com/pkg/errors" - "go.uber.org/zap" ) // DiscoverProtocol specifies the methods from the peer discovery that are required. @@ -28,9 +28,9 @@ type DiscoverProtocol interface { type Protocol struct { server.Protocol - disc DiscoverProtocol // reference to the peer discovery to query verified peers - loc *peer.Local // local peer that runs the protocol - log *zap.SugaredLogger // logging + disc DiscoverProtocol // reference to the peer discovery to query verified peers + loc *peer.Local // local peer that runs the protocol + log *logger.Logger // logging mgr *manager // the manager handles the actual neighbor selection closeOnce sync.Once @@ -44,7 +44,7 @@ func New(local *peer.Local, disc DiscoverProtocol, cfg Config) *Protocol { disc: disc, log: cfg.Log, } - p.mgr = newManager(p, disc.GetVerifiedPeers, cfg.Log.Named("mgr"), cfg.Param) + p.mgr = newManager(p, disc.GetVerifiedPeers, cfg.Log.Named("mgr"), cfg) return p } @@ -78,12 +78,19 @@ func (p *Protocol) GetNeighbors() []*peer.Peer { // GetIncomingNeighbors returns the current incoming neighbors. func (p *Protocol) GetIncomingNeighbors() []*peer.Peer { - return p.mgr.getIncomingNeighbors() + return p.mgr.getInNeighbors() } // GetOutgoingNeighbors returns the current outgoing neighbors. func (p *Protocol) GetOutgoingNeighbors() []*peer.Peer { - return p.mgr.getOutgoingNeighbors() + return p.mgr.getOutNeighbors() +} + +// RemoveNeighbor removes the peer with the given id from the incoming and outgoing neighbors. +// If such a peer was actually contained in anyone of the neighbor sets, the corresponding event is triggered +// and the corresponding peering drop is sent. Otherwise the call is ignored. +func (p *Protocol) RemoveNeighbor(id peer.ID) { + p.mgr.removeNeighbor(id) } // HandleMessage responds to incoming neighbor selection messages. @@ -160,10 +167,8 @@ func (p *Protocol) RequestPeering(to *peer.Peer, salt *salt.Salt) (bool, error) return status, err } -// DropPeer sends a PeeringDrop to the given peer. -func (p *Protocol) DropPeer(to *peer.Peer) { - p.mgr.dropNeighbor(to.ID()) - +// SendPeeringDrop sends a peering drop to the given peer and does not wait for any responses. +func (p *Protocol) SendPeeringDrop(to *peer.Peer) { toAddr := to.Address() drop := newPeeringDrop(toAddr) @@ -282,7 +287,7 @@ func (p *Protocol) handlePeeringRequest(s *server.Server, fromAddr string, fromI return } - res := newPeeringResponse(rawData, p.mgr.acceptRequest(from, salt)) + res := newPeeringResponse(rawData, p.mgr.requestPeering(from, salt)) p.log.Debugw("send message", "type", res.Name(), @@ -334,5 +339,5 @@ func (p *Protocol) validatePeeringDrop(s *server.Server, fromAddr string, m *pb. } func (p *Protocol) handlePeeringDrop(fromID peer.ID) { - p.mgr.dropNeighbor(fromID) + p.mgr.removeNeighbor(fromID) } diff --git a/packages/autopeering/selection/protocol_test.go b/packages/autopeering/selection/protocol_test.go index 8caf9174c5..d43820f87d 100644 --- a/packages/autopeering/selection/protocol_test.go +++ b/packages/autopeering/selection/protocol_test.go @@ -38,10 +38,7 @@ func newTest(t require.TestingT, trans transport.Transport) (*server.Server, *Pr // add the new peer to the global map for dummyDiscovery peerMap[local.ID()] = &local.Peer - cfg := Config{ - Log: l, - } - prot := New(local, dummyDiscovery{}, cfg) + prot := New(local, dummyDiscovery{}, Config{Log: l}) srv := server.Listen(local, trans, l.Named("srv"), prot) prot.Start(srv) @@ -57,75 +54,102 @@ func getPeer(s *server.Server) *peer.Peer { return &s.Local().Peer } -func TestProtPeeringRequest(t *testing.T) { - p2p := transport.P2P() - defer p2p.Close() - - srvA, protA, closeA := newTest(t, p2p.A) - defer closeA() - srvB, protB, closeB := newTest(t, p2p.B) - defer closeB() - - peerA := getPeer(srvA) - saltA, _ := salt.NewSalt(100 * time.Second) - peerB := getPeer(srvB) - saltB, _ := salt.NewSalt(100 * time.Second) - - // request peering to peer B - t.Run("A->B", func(t *testing.T) { - if services, err := protA.RequestPeering(peerB, saltA); assert.NoError(t, err) { - assert.NotEmpty(t, services) - } +func TestProtocol(t *testing.T) { + // assure that the default test parameters are used for all protocol tests + SetParameters(Parameters{ + SaltLifetime: testSaltLifetime, + OutboundUpdateInterval: testUpdateInterval, }) - // request peering to peer A - t.Run("B->A", func(t *testing.T) { - if services, err := protB.RequestPeering(peerA, saltB); assert.NoError(t, err) { - assert.NotEmpty(t, services) - } + + t.Run("PeeringRequest", func(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() + + srvA, protA, closeA := newTest(t, p2p.A) + defer closeA() + srvB, protB, closeB := newTest(t, p2p.B) + defer closeB() + + peerA := getPeer(srvA) + saltA, _ := salt.NewSalt(100 * time.Second) + peerB := getPeer(srvB) + saltB, _ := salt.NewSalt(100 * time.Second) + + // request peering to peer B + t.Run("A->B", func(t *testing.T) { + if services, err := protA.RequestPeering(peerB, saltA); assert.NoError(t, err) { + assert.NotEmpty(t, services) + } + }) + // request peering to peer A + t.Run("B->A", func(t *testing.T) { + if services, err := protB.RequestPeering(peerA, saltB); assert.NoError(t, err) { + assert.NotEmpty(t, services) + } + }) }) -} -func TestProtExpiredSalt(t *testing.T) { - p2p := transport.P2P() - defer p2p.Close() + t.Run("ExpiredSalt", func(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() - _, protA, closeA := newTest(t, p2p.A) - defer closeA() - srvB, _, closeB := newTest(t, p2p.B) - defer closeB() + _, protA, closeA := newTest(t, p2p.A) + defer closeA() + srvB, _, closeB := newTest(t, p2p.B) + defer closeB() - saltA, _ := salt.NewSalt(-1 * time.Second) - peerB := getPeer(srvB) + saltA, _ := salt.NewSalt(-1 * time.Second) + peerB := getPeer(srvB) - // request peering to peer B - _, err := protA.RequestPeering(peerB, saltA) - assert.EqualError(t, err, server.ErrTimeout.Error()) -} + // request peering to peer B + _, err := protA.RequestPeering(peerB, saltA) + assert.EqualError(t, err, server.ErrTimeout.Error()) + }) -func TestProtDropPeer(t *testing.T) { - p2p := transport.P2P() - defer p2p.Close() + t.Run("PeeringDrop", func(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() - srvA, protA, closeA := newTest(t, p2p.A) - defer closeA() - srvB, protB, closeB := newTest(t, p2p.B) - defer closeB() + srvA, protA, closeA := newTest(t, p2p.A) + defer closeA() + srvB, protB, closeB := newTest(t, p2p.B) + defer closeB() - peerA := getPeer(srvA) - saltA, _ := salt.NewSalt(100 * time.Second) - peerB := getPeer(srvB) + peerA := getPeer(srvA) + saltA, _ := salt.NewSalt(100 * time.Second) + peerB := getPeer(srvB) - // request peering to peer B - services, err := protA.RequestPeering(peerB, saltA) - require.NoError(t, err) - assert.NotEmpty(t, services) + // request peering to peer B + services, err := protA.RequestPeering(peerB, saltA) + require.NoError(t, err) + assert.NotEmpty(t, services) + + require.Contains(t, protB.GetNeighbors(), peerA) + + // drop peer A + protA.SendPeeringDrop(peerB) + time.Sleep(graceTime) + require.NotContains(t, protB.GetNeighbors(), peerA) + }) + + t.Run("FullTest", func(t *testing.T) { + p2p := transport.P2P() + defer p2p.Close() + + srvA, protA, closeA := newFullTest(t, p2p.A) + defer closeA() - require.Contains(t, protB.GetNeighbors(), peerA) + time.Sleep(graceTime) // wait for the master to initialize - // drop peer A - protA.DropPeer(peerB) - time.Sleep(graceTime) - require.NotContains(t, protB.GetNeighbors(), peerA) + srvB, protB, closeB := newFullTest(t, p2p.B, getPeer(srvA)) + defer closeB() + + time.Sleep(outboundUpdateInterval + graceTime) // wait for the next outbound cycle + + // the two peers should be peered + assert.ElementsMatch(t, []*peer.Peer{getPeer(srvB)}, protA.GetNeighbors()) + assert.ElementsMatch(t, []*peer.Peer{getPeer(srvA)}, protB.GetNeighbors()) + }) } // newTest creates a new server handling discover as well as neighborhood and also returns the teardown. @@ -156,22 +180,3 @@ func newFullTest(t require.TestingT, trans transport.Transport, masterPeers ...* } return srv, selection, teardown } - -func TestProtFull(t *testing.T) { - p2p := transport.P2P() - defer p2p.Close() - - srvA, protA, closeA := newFullTest(t, p2p.A) - defer closeA() - - time.Sleep(graceTime) // wait for the master to initialize - - srvB, protB, closeB := newFullTest(t, p2p.B, getPeer(srvA)) - defer closeB() - - time.Sleep(updateOutboundInterval + graceTime) // wait for the next outbound cycle - - // the two peers should be peered - assert.ElementsMatch(t, []*peer.Peer{getPeer(srvB)}, protA.GetNeighbors()) - assert.ElementsMatch(t, []*peer.Peer{getPeer(srvA)}, protB.GetNeighbors()) -} diff --git a/packages/autopeering/selection/selection_test.go b/packages/autopeering/selection/selection_test.go index cdd89874aa..cc2235e812 100644 --- a/packages/autopeering/selection/selection_test.go +++ b/packages/autopeering/selection/selection_test.go @@ -146,26 +146,26 @@ func TestSelection(t *testing.T) { tests := []testCase{ { nh: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0]}, + size: 4}, expCandidate: d[1].Remote, }, { nh: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0], d[1], d[3]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0], d[1], d[3]}, + size: 4}, expCandidate: d[2].Remote, }, { nh: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0], d[1], d[4], d[2]}, + size: 4}, expCandidate: d[3].Remote, }, { nh: &Neighborhood{ - Neighbors: []peer.PeerDistance{d[0], d[1], d[2], d[3]}, - Size: 4}, + neighbors: []peer.PeerDistance{d[0], d[1], d[2], d[3]}, + size: 4}, expCandidate: nil, }, } diff --git a/packages/autopeering/server/server.go b/packages/autopeering/server/server.go index d403b523fd..2c6303e573 100644 --- a/packages/autopeering/server/server.go +++ b/packages/autopeering/server/server.go @@ -11,8 +11,8 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer" pb "github.com/iotaledger/goshimmer/packages/autopeering/server/proto" "github.com/iotaledger/goshimmer/packages/autopeering/transport" + "github.com/iotaledger/hive.go/logger" "github.com/pkg/errors" - "go.uber.org/zap" ) const ( @@ -25,7 +25,7 @@ type Server struct { local *peer.Local trans transport.Transport handlers []Handler - log *zap.SugaredLogger + log *logger.Logger network string address string @@ -70,7 +70,7 @@ type reply struct { // Listen starts a new peer server using the given transport layer for communication. // Sent data is signed using the identity of the local peer, // received data with a valid peer signature is handled according to the provided Handler. -func Listen(local *peer.Local, t transport.Transport, log *zap.SugaredLogger, h ...Handler) *Server { +func Listen(local *peer.Local, t transport.Transport, log *logger.Logger, h ...Handler) *Server { srv := &Server{ local: local, trans: t, diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 95b2b8e48f..ff21679ca5 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -44,11 +44,8 @@ func configureAP() { // enable peer selection only when gossip is enabled if !node.IsSkipped(gossip.PLUGIN) { Selection = selection.New(local.GetInstance(), Discovery, selection.Config{ - Log: log.Named("sel"), - Param: &selection.Parameters{ - SaltLifetime: selection.DefaultSaltLifetime, - RequiredService: []service.Key{service.GossipKey}, - }, + Log: log.Named("sel"), + RequiredServices: []service.Key{service.GossipKey}, }) } } diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index c6e9ec88f5..f40c3746d8 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -1,6 +1,8 @@ package autopeering import ( + "time" + "github.com/iotaledger/goshimmer/packages/autopeering/discover" "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/selection" @@ -32,10 +34,10 @@ func run(*node.Plugin) { func configureEvents() { // notify the selection when a connection is closed or failed. gossip.Events.ConnectionFailed.Attach(events.NewClosure(func(p *peer.Peer) { - Selection.DropPeer(p) + Selection.RemoveNeighbor(p.ID()) })) gossip.Events.NeighborRemoved.Attach(events.NewClosure(func(p *peer.Peer) { - Selection.DropPeer(p) + Selection.RemoveNeighbor(p.ID()) })) discover.Events.PeerDiscovered.Attach(events.NewClosure(func(ev *discover.DiscoveredEvent) { @@ -45,6 +47,9 @@ func configureEvents() { log.Infof("Removed offline: %s / %s", ev.Peer.Address(), ev.Peer.ID()) })) + selection.Events.SaltUpdated.Attach(events.NewClosure(func(ev *selection.SaltUpdatedEvent) { + log.Infof("Salt updated; expires=%s", ev.Public.GetExpiration().Format(time.RFC822)) + })) selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { log.Infof("Peering chosen: %s / %s", ev.Peer.Address(), ev.Peer.ID()) })) diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 3829565b38..6d84cd4fb1 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -53,6 +53,9 @@ func configureEvents() { }() })) + gossip.Events.ConnectionFailed.Attach(events.NewClosure(func(p *peer.Peer) { + log.Infof("Connection to neighbor failed: %s / %s", gossip.GetAddress(p), p.ID()) + })) gossip.Events.NeighborAdded.Attach(events.NewClosure(func(n *gossip.Neighbor) { log.Infof("Neighbor added: %s / %s", gossip.GetAddress(n.Peer), n.ID()) })) From 2274beb068a3f1f5c5a66e81f6f6668f94e9cfcd Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Thu, 16 Jan 2020 18:46:08 +0100 Subject: [PATCH 110/184] Fix linter warnings (#138) --- client/lib.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/lib.go b/client/lib.go index d60200d611..87e8189699 100644 --- a/client/lib.go +++ b/client/lib.go @@ -181,7 +181,6 @@ func (api *GoShimmerAPI) FindTransactions(query *webapi_findTransactions.Request return resObj.Transactions, nil } - func (api *GoShimmerAPI) GetNeighbors() (*webapi_getNeighbors.Response, error) { res, err := api.httpClient.Get(fmt.Sprintf("%s/%s", api.node, routeGetNeighbors)) if err != nil { @@ -196,7 +195,6 @@ func (api *GoShimmerAPI) GetNeighbors() (*webapi_getNeighbors.Response, error) { return resObj, nil } - func (api *GoShimmerAPI) GetTips() (*webapi_gtta.Response, error) { res, err := api.httpClient.Get(fmt.Sprintf("%s/%s", api.node, routeGetTransactionsToApprove)) if err != nil { From db7c2e5b6c5296e254571fb070be96eba0e377d4 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Thu, 16 Jan 2020 18:58:18 +0100 Subject: [PATCH 111/184] Fix linter warning --- plugins/webapi/getNeighbors/plugin.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/webapi/getNeighbors/plugin.go b/plugins/webapi/getNeighbors/plugin.go index 097793e18a..3d36b4f408 100644 --- a/plugins/webapi/getNeighbors/plugin.go +++ b/plugins/webapi/getNeighbors/plugin.go @@ -8,16 +8,13 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/plugins/autopeering" "github.com/iotaledger/goshimmer/plugins/webapi" - "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" "github.com/labstack/echo" ) var PLUGIN = node.NewPlugin("WebAPI getNeighbors Endpoint", node.Enabled, configure) -var log *logger.Logger func configure(plugin *node.Plugin) { - log = logger.NewLogger("API-getNeighbors") webapi.Server.GET("getNeighbors", getNeighbors) } From 12eefe1cc586233d304593ab7b23014daa4fc06e Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Thu, 16 Jan 2020 19:30:48 +0100 Subject: [PATCH 112/184] Updates to iota.go v1.0.0-beta.14 (#133) * updates to iota.go v1.0.0-beta.14 * Use trinary.Must.. Co-authored-by: Wolfgang Welz --- go.mod | 4 ++-- go.sum | 7 +++++-- packages/client/bundlefactory.go | 2 +- packages/model/meta_transaction/meta_transaction.go | 8 ++------ packages/model/value_transaction/value_transaction.go | 8 ++------ plugins/webapi/getTrytes/plugin.go | 6 +----- 6 files changed, 13 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index 989cd7ff78..9209c98680 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/googollee/go-socket.io v1.4.3-0.20191204093753-683f8725b6d0 github.com/gorilla/websocket v1.4.1 github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e - github.com/iotaledger/iota.go v1.0.0-beta.13 + github.com/iotaledger/iota.go v1.0.0-beta.14 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect github.com/lucasb-eyer/go-colorful v1.0.3 // indirect @@ -23,7 +23,7 @@ require ( github.com/mattn/go-isatty v0.0.11 // indirect github.com/mattn/go-runewidth v0.0.7 // indirect github.com/pelletier/go-toml v1.6.0 // indirect - github.com/pkg/errors v0.8.1 + github.com/pkg/errors v0.9.1 github.com/rivo/tview v0.0.0-20191229165609-1ee8d9874dcf github.com/spf13/afero v1.2.2 // indirect github.com/spf13/cast v1.3.1 // indirect diff --git a/go.sum b/go.sum index 1ee1b7b40f..3e2ecd231d 100644 --- a/go.sum +++ b/go.sum @@ -22,6 +22,7 @@ github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NR github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= +github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= @@ -118,8 +119,8 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e h1:bowQHvFQoUWPgxlF9cQRWDzREswR09HpihMiNX1q+AU= github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e/go.mod h1:obs07gqna53/Yw1ltzLsQzJBMyA6lGu7Fb/ltjqWMnQ= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= -github.com/iotaledger/iota.go v1.0.0-beta.13 h1:6m6JRcKtjTflU2PbjvDA9Tv6NTEJX1PijBDOkH9weQc= -github.com/iotaledger/iota.go v1.0.0-beta.13/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= +github.com/iotaledger/iota.go v1.0.0-beta.14 h1:Oeb28MfBuJEeXcGrLhTCJFtbsnc8y1u7xidsAmiOD5A= +github.com/iotaledger/iota.go v1.0.0-beta.14/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= @@ -180,6 +181,8 @@ github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCr github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= diff --git a/packages/client/bundlefactory.go b/packages/client/bundlefactory.go index e064d76966..dc2d653493 100644 --- a/packages/client/bundlefactory.go +++ b/packages/client/bundlefactory.go @@ -37,7 +37,7 @@ func (bundleFactory *BundleFactory) AddOutput(address *Address, value int64, mes bundleFactory.outputs = append(bundleFactory.outputs, bundleFactoryOutputEntry{ address: address, value: value, - message: trinary.Pad(messageTrytes, value_transaction.SIGNATURE_MESSAGE_FRAGMENT_SIZE), + message: trinary.MustPad(messageTrytes, value_transaction.SIGNATURE_MESSAGE_FRAGMENT_SIZE), }) } else { bundleFactory.outputs = append(bundleFactory.outputs, bundleFactoryOutputEntry{ diff --git a/packages/model/meta_transaction/meta_transaction.go b/packages/model/meta_transaction/meta_transaction.go index d85160a615..1ed461447c 100644 --- a/packages/model/meta_transaction/meta_transaction.go +++ b/packages/model/meta_transaction/meta_transaction.go @@ -53,11 +53,7 @@ func FromTrits(trits trinary.Trits) *MetaTransaction { } func FromBytes(bytes []byte) (result *MetaTransaction) { - trits, err := trinary.BytesToTrits(bytes) - if err != nil { - panic(err) - } - + trits := trinary.MustBytesToTrits(bytes) result = FromTrits(trits[:MARSHALED_TOTAL_SIZE]) result.bytes = bytes @@ -477,7 +473,7 @@ func (this *MetaTransaction) GetBytes() (result []byte) { defer this.bytesMutex.Unlock() this.hasherMutex.Lock() - this.bytes = trinary.TritsToBytes(this.trits) + this.bytes = trinary.MustTritsToBytes(this.trits) this.hasherMutex.Unlock() } else { this.bytesMutex.RUnlock() diff --git a/packages/model/value_transaction/value_transaction.go b/packages/model/value_transaction/value_transaction.go index b42a647348..393e6560a0 100644 --- a/packages/model/value_transaction/value_transaction.go +++ b/packages/model/value_transaction/value_transaction.go @@ -40,11 +40,7 @@ func FromMetaTransaction(metaTransaction *meta_transaction.MetaTransaction) *Val } func FromBytes(bytes []byte) (result *ValueTransaction) { - trits, err := trinary.BytesToTrits(bytes) - if err != nil { - panic(err) - } - + trits := trinary.MustBytesToTrits(bytes) result = &ValueTransaction{ MetaTransaction: meta_transaction.FromTrits(trits[:meta_transaction.MARSHALED_TOTAL_SIZE]), } @@ -180,7 +176,7 @@ func (this *ValueTransaction) SetTimestamp(timestamp uint) bool { this.timestamp = ×tamp this.BlockHasher() - copy(this.trits[TIMESTAMP_OFFSET:TIMESTAMP_END], trinary.PadTrits(trinary.IntToTrits(int64(timestamp)), TIMESTAMP_SIZE)[:TIMESTAMP_SIZE]) + copy(this.trits[TIMESTAMP_OFFSET:TIMESTAMP_END], trinary.MustPadTrits(trinary.IntToTrits(int64(timestamp)), TIMESTAMP_SIZE)[:TIMESTAMP_SIZE]) this.UnblockHasher() this.SetModified(true) diff --git a/plugins/webapi/getTrytes/plugin.go b/plugins/webapi/getTrytes/plugin.go index 8c9a8e2596..b29b83fa76 100644 --- a/plugins/webapi/getTrytes/plugin.go +++ b/plugins/webapi/getTrytes/plugin.go @@ -39,11 +39,7 @@ func getTrytes(c echo.Context) error { return requestFailed(c, err.Error()) } if tx != nil { - trytes, err := trinary.TritsToTrytes(tx.GetTrits()) - // Returns an error if len(tx.GetTrits())%3!=0 - if err != nil { - return requestFailed(c, err.Error()) - } + trytes := trinary.MustTritsToTrytes(tx.GetTrits()) result = append(result, trytes) } else { //tx not found From 4e70593d63ae1598f9139eb6daa7c2250113b9d7 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Fri, 17 Jan 2020 09:14:33 +0100 Subject: [PATCH 113/184] Fix: Ignore rejected peering requests (#137) * fix: ignore rejected peering requests * Do not store local services in DB --- packages/autopeering/peer/local.go | 19 +++------------- packages/autopeering/peer/mapdb.go | 33 +++++---------------------- packages/autopeering/peer/peerdb.go | 35 +---------------------------- plugins/analysis/client/plugin.go | 14 +++++++----- plugins/autopeering/plugin.go | 8 +++++-- plugins/gossip/plugin.go | 6 +++++ 6 files changed, 31 insertions(+), 84 deletions(-) diff --git a/packages/autopeering/peer/local.go b/packages/autopeering/peer/local.go index 65638ae185..32a7a9dfbe 100644 --- a/packages/autopeering/peer/local.go +++ b/packages/autopeering/peer/local.go @@ -50,18 +50,9 @@ func NewLocal(network string, address string, db DB) (*Local, error) { if l := len(key); l != ed25519.PrivateKeySize { return nil, fmt.Errorf("invalid key length: %d, need %d", l, ed25519.PublicKeySize) } - services, err := db.LocalServices() - if err != nil { - return nil, err - } - serviceRecord := services.CreateRecord() - - // update the external address used for the peering and store back in DB + // update the external address used for the peering + serviceRecord := service.New() serviceRecord.Update(service.PeeringKey, network, address) - err = db.UpdateLocalServices(serviceRecord) - if err != nil { - return nil, err - } return newLocal(key, serviceRecord, db), nil } @@ -81,12 +72,8 @@ func (l *Local) UpdateService(key service.Key, network string, address string) e l.mu.Lock() defer l.mu.Unlock() - // update the service in the read protected map and store back in DB + // update the service in the read protected map l.serviceRecord.Update(key, network, address) - err := l.db.UpdateLocalServices(l.serviceRecord) - if err != nil { - return err - } // create a new peer with the corresponding services l.Peer = *NewPeer(l.key.Public(), l.serviceRecord) diff --git a/packages/autopeering/peer/mapdb.go b/packages/autopeering/peer/mapdb.go index 03719614de..df3ead3f55 100644 --- a/packages/autopeering/peer/mapdb.go +++ b/packages/autopeering/peer/mapdb.go @@ -4,16 +4,14 @@ import ( "sync" "time" - "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/hive.go/logger" ) // mapDB is a simple implementation of DB using a map. type mapDB struct { - mutex sync.RWMutex - m map[string]peerEntry - key PrivateKey - services *service.Record + mutex sync.RWMutex + m map[string]peerEntry + key PrivateKey log *logger.Logger @@ -34,10 +32,9 @@ type peerPropEntry struct { // NewMemoryDB creates a new DB that uses a GO map. func NewMemoryDB(log *logger.Logger) DB { db := &mapDB{ - m: make(map[string]peerEntry), - services: service.New(), - log: log, - closing: make(chan struct{}), + m: make(map[string]peerEntry), + log: log, + closing: make(chan struct{}), } // start the expirer routine @@ -70,24 +67,6 @@ func (db *mapDB) LocalPrivateKey() (PrivateKey, error) { return db.key, nil } -// LocalServices returns the services stored in the database or creates an empty map. -func (db *mapDB) LocalServices() (service.Service, error) { - db.mutex.RLock() - defer db.mutex.RUnlock() - - return db.services, nil -} - -// UpdateLocalServices updates the services stored in the database. -func (db *mapDB) UpdateLocalServices(services service.Service) error { - record := services.CreateRecord() - - db.mutex.Lock() - defer db.mutex.Unlock() - db.services = record - return nil -} - // LastPing returns that property for the given peer ID and address. func (db *mapDB) LastPing(id ID, address string) time.Time { db.mutex.RLock() diff --git a/packages/autopeering/peer/peerdb.go b/packages/autopeering/peer/peerdb.go index b5cfcdfbb8..106517aa56 100644 --- a/packages/autopeering/peer/peerdb.go +++ b/packages/autopeering/peer/peerdb.go @@ -7,7 +7,6 @@ import ( "sync" "time" - "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/database" "github.com/iotaledger/hive.go/logger" ) @@ -29,10 +28,6 @@ const ( type DB interface { // LocalPrivateKey returns the private key stored in the database or creates a new one. LocalPrivateKey() (PrivateKey, error) - // LocalServices returns the services stored in the database or creates an empty services. - LocalServices() (service.Service, error) - // UpdateLocalServices updates the services stored in the database. - UpdateLocalServices(services service.Service) error // Peer retrieves a peer from the database. Peer(id ID) *Peer @@ -72,8 +67,7 @@ const ( dbNodePong = "lastpong" // Local information is keyed by ID only. Use localFieldKey to create those keys. - dbLocalKey = "key" - dbLocalServices = "services" + dbLocalKey = "key" ) // NewPersistentDB creates a new persistent DB. @@ -192,33 +186,6 @@ func (db *persistentDB) LocalPrivateKey() (PrivateKey, error) { return key, nil } -// LocalServices returns the services stored in the database or creates an empty services. -func (db *persistentDB) LocalServices() (service.Service, error) { - key, err := db.db.Get(localFieldKey(dbLocalServices)) - if err == database.ErrKeyNotFound { - return service.New(), nil - } - if err != nil { - return nil, err - } - - services, err := service.Unmarshal(key) - if err != nil { - return nil, err - } - - return services, nil -} - -// UpdateLocalServices updates the services stored in the database. -func (db *persistentDB) UpdateLocalServices(services service.Service) error { - value, err := services.CreateRecord().CreateRecord().Marshal() - if err != nil { - return err - } - return db.db.Set(localFieldKey(dbLocalServices), value) -} - // LastPing returns that property for the given peer ID and address. func (db *persistentDB) LastPing(id ID, address string) time.Time { return time.Unix(db.getInt64(nodeFieldKey(id, address, dbNodePing)), 0) diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index ccec3955a9..b9179be123 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -94,18 +94,22 @@ func setupHooks(plugin *node.Plugin, conn *network.ManagedConnection, eventDispa eventDispatchers.RemoveNode(ev.Peer.ID().Bytes()) }) + onAddChosenNeighbor := events.NewClosure(func(ev *selection.PeeringEvent) { + if ev.Status { + eventDispatchers.ConnectNodes(local.GetInstance().ID().Bytes(), ev.Peer.ID().Bytes()) + } + }) + onAddAcceptedNeighbor := events.NewClosure(func(ev *selection.PeeringEvent) { - eventDispatchers.ConnectNodes(ev.Peer.ID().Bytes(), local.GetInstance().ID().Bytes()) + if ev.Status { + eventDispatchers.ConnectNodes(ev.Peer.ID().Bytes(), local.GetInstance().ID().Bytes()) + } }) onRemoveNeighbor := events.NewClosure(func(ev *selection.DroppedEvent) { eventDispatchers.DisconnectNodes(ev.DroppedID.Bytes(), local.GetInstance().ID().Bytes()) }) - onAddChosenNeighbor := events.NewClosure(func(ev *selection.PeeringEvent) { - eventDispatchers.ConnectNodes(local.GetInstance().ID().Bytes(), ev.Peer.ID().Bytes()) - }) - // setup hooks ///////////////////////////////////////////////////////////////////////////////////////////////////// discover.Events.PeerDiscovered.Attach(onDiscoverPeer) diff --git a/plugins/autopeering/plugin.go b/plugins/autopeering/plugin.go index f40c3746d8..4688b6b0d7 100644 --- a/plugins/autopeering/plugin.go +++ b/plugins/autopeering/plugin.go @@ -51,10 +51,14 @@ func configureEvents() { log.Infof("Salt updated; expires=%s", ev.Public.GetExpiration().Format(time.RFC822)) })) selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { - log.Infof("Peering chosen: %s / %s", ev.Peer.Address(), ev.Peer.ID()) + if ev.Status { + log.Infof("Peering chosen: %s / %s", ev.Peer.Address(), ev.Peer.ID()) + } })) selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { - log.Infof("Peering accepted: %s / %s", ev.Peer.Address(), ev.Peer.ID()) + if ev.Status { + log.Infof("Peering accepted: %s / %s", ev.Peer.Address(), ev.Peer.ID()) + } })) selection.Events.Dropped.Attach(events.NewClosure(func(ev *selection.DroppedEvent) { log.Infof("Peering dropped: %s", ev.DroppedID) diff --git a/plugins/gossip/plugin.go b/plugins/gossip/plugin.go index 6d84cd4fb1..f6f5717ed0 100644 --- a/plugins/gossip/plugin.go +++ b/plugins/gossip/plugin.go @@ -39,6 +39,9 @@ func configureEvents() { }() })) selection.Events.IncomingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { + if !ev.Status { + return // ignore rejected peering + } go func() { if err := mgr.AddInbound(ev.Peer); err != nil { log.Debugw("error adding inbound", "id", ev.Peer.ID(), "err", err) @@ -46,6 +49,9 @@ func configureEvents() { }() })) selection.Events.OutgoingPeering.Attach(events.NewClosure(func(ev *selection.PeeringEvent) { + if !ev.Status { + return // ignore rejected peering + } go func() { if err := mgr.AddOutbound(ev.Peer); err != nil { log.Debugw("error adding outbound", "id", ev.Peer.ID(), "err", err) From 17b58973058ec230284104518cc50a24f3f8a804 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Fri, 17 Jan 2020 09:16:24 +0100 Subject: [PATCH 114/184] Rename instances of Shimmer to GoShimmer (#132) --- Makefile | 2 +- config.json | 2 +- docker.config.json | 2 +- plugins/cli/cli.go | 2 +- plugins/cli/plugin.go | 19 +++++++++++-------- plugins/statusscreen/ui_header_bar.go | 5 +++-- plugins/ui/files.go | 4 ++-- plugins/ui/src/index.html | 4 ++-- runNetwork.sh | 4 ++-- 9 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 045cb830fc..2391a72080 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ PROTO_GO_FILES_REAL = $(shell find . -path ./vendor -prune -o -type f -name '*.p .PHONY: build build: proto - go build -o shimmer + go build -o goshimmer # Protobuffing .PHONY: proto diff --git a/config.json b/config.json index 1e24d5f01c..e28d03a947 100644 --- a/config.json +++ b/config.json @@ -30,7 +30,7 @@ "DisableStacktrace": false, "Encoding": "console", "OutputPaths": [ - "shimmer.log" + "goshimmer.log" ] }, "node": { diff --git a/docker.config.json b/docker.config.json index 37dea0df98..1bb3a722ba 100644 --- a/docker.config.json +++ b/docker.config.json @@ -23,7 +23,7 @@ "Encoding": "console", "OutputPaths": [ "stdout", - "shimmer.log" + "goshimmer.log" ], "DisableEvents": true }, diff --git a/plugins/cli/cli.go b/plugins/cli/cli.go index 39ea901ff1..bd36209325 100644 --- a/plugins/cli/cli.go +++ b/plugins/cli/cli.go @@ -32,7 +32,7 @@ func printUsage() { fmt.Fprintf( os.Stderr, "\n"+ - "SHIMMER\n\n"+ + "GoShimmer\n\n"+ " A lightweight modular IOTA node.\n\n"+ "Usage:\n\n"+ " %s [OPTIONS]\n\n"+ diff --git a/plugins/cli/plugin.go b/plugins/cli/plugin.go index b18b78b37e..03bbc6faf2 100644 --- a/plugins/cli/plugin.go +++ b/plugins/cli/plugin.go @@ -13,7 +13,7 @@ import ( const ( // AppVersion version number - AppVersion = "v0.0.1" + AppVersion = "v0.1.0" // AppName app code name AppName = "GoShimmer" ) @@ -56,15 +56,18 @@ func LoadConfig() { } func configure(ctx *node.Plugin) { - fmt.Println(" _____ _ _ ________ ______ ___ ___________ ") - fmt.Println(" / ___| | | |_ _| \\/ || \\/ || ___| ___ \\") - fmt.Println(" \\ `--.| |_| | | | | . . || . . || |__ | |_/ /") - fmt.Println(" `--. \\ _ | | | | |\\/| || |\\/| || __|| / ") - fmt.Println(" /\\__/ / | | |_| |_| | | || | | || |___| |\\ \\ ") - fmt.Printf(" \\____/\\_| |_/\\___/\\_| |_/\\_| |_/\\____/\\_| \\_| fullnode %s", AppVersion) - fmt.Println() + fmt.Printf(` + _____ ____ _____ _ _ _____ __ __ __ __ ______ _____ + / ____|/ __ \ / ____| | | |_ _| \/ | \/ | ____| __ \ + | | __| | | | (___ | |__| | | | | \ / | \ / | |__ | |__) | + | | |_ | | | |\___ \| __ | | | | |\/| | |\/| | __| | _ / + | |__| | |__| |____) | | | |_| |_| | | | | | | |____| | \ \ + \_____|\____/|_____/|_| |_|_____|_| |_|_| |_|______|_| \_\ + %s +`, AppVersion) fmt.Println() + ctx.Node.Logger.Infof("GoShimmer version %s ...", AppVersion) ctx.Node.Logger.Info("Loading plugins ...") } diff --git a/plugins/statusscreen/ui_header_bar.go b/plugins/statusscreen/ui_header_bar.go index 607be9d4e6..541893d56c 100644 --- a/plugins/statusscreen/ui_header_bar.go +++ b/plugins/statusscreen/ui_header_bar.go @@ -6,6 +6,7 @@ import ( "strconv" "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/goshimmer/plugins/cli" //"strconv" "time" @@ -49,7 +50,7 @@ func NewUIHeaderBar() *UIHeaderBar { SetBackgroundColor(tcell.ColorDarkMagenta) headerBar.Primitive. - SetColumns(17, 0). + SetColumns(20, 0). SetRows(0). SetBorders(false). AddItem(headerBar.LogoContainer, 0, 0, 1, 1, 0, 0, false). @@ -142,7 +143,7 @@ func (headerBar *UIHeaderBar) Update() { func (headerBar *UIHeaderBar) printLogo() { fmt.Fprintln(headerBar.LogoContainer, "") - fmt.Fprintln(headerBar.LogoContainer, " SHIMMER 0.0.1") + fmt.Fprintln(headerBar.LogoContainer, " GOSHIMMER", cli.AppVersion) fmt.Fprintln(headerBar.LogoContainer, " ┌──────┬──────┐") fmt.Fprintln(headerBar.LogoContainer, " ───┐ │ ┌───") fmt.Fprintln(headerBar.LogoContainer, " ┐ │ │ │ ┌") diff --git a/plugins/ui/files.go b/plugins/ui/files.go index a336e08738..4d32815b92 100644 --- a/plugins/ui/files.go +++ b/plugins/ui/files.go @@ -213,7 +213,7 @@ body.fade { - Shimmer UI + GoShimmer UI @@ -226,7 +226,7 @@ body.fade {

- Shimmer + GoShimmer

Status:{{synced}}
diff --git a/plugins/ui/src/index.html b/plugins/ui/src/index.html index b3825fe06e..a1ee5924fd 100644 --- a/plugins/ui/src/index.html +++ b/plugins/ui/src/index.html @@ -5,7 +5,7 @@ - Shimmer UI + GoShimmer UI @@ -18,7 +18,7 @@

- Shimmer + GoShimmer

Status:{{synced}}
diff --git a/runNetwork.sh b/runNetwork.sh index daa942e47e..6b918b58c3 100755 --- a/runNetwork.sh +++ b/runNetwork.sh @@ -25,8 +25,8 @@ for i in `seq 1 $1`; do GOSSIP_PORT=$((GOSSIP_PORT+1)) mkdir node_$i mkdir node_$i/logs - cp ../shimmer node_$i/ + cp ../goshimmer node_$i/ cd node_$i - ./shimmer --autopeering.port $PEERING_PORT --gossip.port $GOSSIP_PORT --autopeering.address 127.0.0.1 --autopeering.entryNodes 2TwlC5mtYVrCHNKG8zkFWmEUlL0pJPS1DOOC2U4yjwo=@127.0.0.1:14626 --node.LogLevel 4 --node.disablePlugins statusscreen --analysis.serverAddress 127.0.0.1:188 & + ./goshimmer --autopeering.port $PEERING_PORT --gossip.port $GOSSIP_PORT --autopeering.address 127.0.0.1 --autopeering.entryNodes 2TwlC5mtYVrCHNKG8zkFWmEUlL0pJPS1DOOC2U4yjwo=@127.0.0.1:14626 --node.LogLevel 4 --node.disablePlugins statusscreen --analysis.serverAddress 127.0.0.1:188 & cd .. done \ No newline at end of file From c37e7e2507479a47d1419809d927f5c3e908738e Mon Sep 17 00:00:00 2001 From: capossele Date: Fri, 17 Jan 2020 10:36:50 +0000 Subject: [PATCH 115/184] :wrench: increase acceptTimeout --- packages/gossip/server/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/gossip/server/server.go b/packages/gossip/server/server.go index ade291bddb..7723d4ee39 100644 --- a/packages/gossip/server/server.go +++ b/packages/gossip/server/server.go @@ -31,7 +31,7 @@ var ( // connection timeouts const ( - acceptTimeout = 250 * time.Millisecond + acceptTimeout = 1000 * time.Millisecond handshakeTimeout = 500 * time.Millisecond connectionTimeout = acceptTimeout + handshakeTimeout From e6d8eeaa1b9be57913b859739f633f4a72308607 Mon Sep 17 00:00:00 2001 From: capossele Date: Fri, 17 Jan 2020 15:43:58 +0000 Subject: [PATCH 116/184] :lipstick: updates import style --- plugins/statusscreen/ui_header_bar.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/statusscreen/ui_header_bar.go b/plugins/statusscreen/ui_header_bar.go index 541893d56c..32762a8674 100644 --- a/plugins/statusscreen/ui_header_bar.go +++ b/plugins/statusscreen/ui_header_bar.go @@ -4,15 +4,12 @@ import ( "fmt" "math" "strconv" - - "github.com/iotaledger/goshimmer/plugins/autopeering/local" - "github.com/iotaledger/goshimmer/plugins/cli" - - //"strconv" "time" "github.com/gdamore/tcell" "github.com/iotaledger/goshimmer/plugins/autopeering" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/goshimmer/plugins/cli" "github.com/rivo/tview" ) From b7ef514226b0536d16c21fdeeb22bd2525b1f1ec Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Fri, 17 Jan 2020 17:23:10 +0100 Subject: [PATCH 117/184] Feat: Add option for node identity seed (#142) * feat: add option to configure the private key seed * Improve log messages --- packages/autopeering/peer/local.go | 22 +++++++++++++++++----- packages/autopeering/peer/mapdb.go | 9 +++++++++ packages/autopeering/peer/peerdb.go | 9 ++++++++- plugins/autopeering/local/local.go | 24 ++++++++++++++++++++++-- plugins/autopeering/local/parameters.go | 2 ++ 5 files changed, 58 insertions(+), 8 deletions(-) diff --git a/packages/autopeering/peer/local.go b/packages/autopeering/peer/local.go index 32a7a9dfbe..19595a32cc 100644 --- a/packages/autopeering/peer/local.go +++ b/packages/autopeering/peer/local.go @@ -42,13 +42,25 @@ func newLocal(key PrivateKey, serviceRecord *service.Record, db DB) *Local { } // NewLocal creates a new local peer linked to the provided db. -func NewLocal(network string, address string, db DB) (*Local, error) { - key, err := db.LocalPrivateKey() - if err != nil { - return nil, err +// If an optional seed is provided, the seed is used to generate the private key. Without a seed, +// the provided key is loaded from the provided database and generated if not stored there. +func NewLocal(network string, address string, db DB, seed ...[]byte) (*Local, error) { + var key PrivateKey + if len(seed) > 0 { + key = PrivateKey(ed25519.NewKeyFromSeed(seed[0])) + if err := db.UpdateLocalPrivateKey(key); err != nil { + return nil, err + } + } else { + var err error + key, err = db.LocalPrivateKey() + if err != nil { + return nil, err + } } + if l := len(key); l != ed25519.PrivateKeySize { - return nil, fmt.Errorf("invalid key length: %d, need %d", l, ed25519.PublicKeySize) + return nil, fmt.Errorf("invalid key length: %d, need %d", l, ed25519.PrivateKeySize) } // update the external address used for the peering serviceRecord := service.New() diff --git a/packages/autopeering/peer/mapdb.go b/packages/autopeering/peer/mapdb.go index df3ead3f55..a3ebbb1a1a 100644 --- a/packages/autopeering/peer/mapdb.go +++ b/packages/autopeering/peer/mapdb.go @@ -67,6 +67,15 @@ func (db *mapDB) LocalPrivateKey() (PrivateKey, error) { return db.key, nil } +// UpdateLocalPrivateKey stores the provided key in the database. +func (db *mapDB) UpdateLocalPrivateKey(key PrivateKey) error { + db.mutex.Lock() + defer db.mutex.Unlock() + + db.key = key + return nil +} + // LastPing returns that property for the given peer ID and address. func (db *mapDB) LastPing(id ID, address string) time.Time { db.mutex.RLock() diff --git a/packages/autopeering/peer/peerdb.go b/packages/autopeering/peer/peerdb.go index 106517aa56..def6344b4f 100644 --- a/packages/autopeering/peer/peerdb.go +++ b/packages/autopeering/peer/peerdb.go @@ -28,6 +28,8 @@ const ( type DB interface { // LocalPrivateKey returns the private key stored in the database or creates a new one. LocalPrivateKey() (PrivateKey, error) + // UpdateLocalPrivateKey stores the provided key in the database. + UpdateLocalPrivateKey(key PrivateKey) error // Peer retrieves a peer from the database. Peer(id ID) *Peer @@ -175,7 +177,7 @@ func (db *persistentDB) LocalPrivateKey() (PrivateKey, error) { if err == database.ErrKeyNotFound { key, err = generatePrivateKey() if err == nil { - err = db.db.Set(localFieldKey(dbLocalKey), key) + err = db.UpdateLocalPrivateKey(key) } return key, err } @@ -186,6 +188,11 @@ func (db *persistentDB) LocalPrivateKey() (PrivateKey, error) { return key, nil } +// UpdateLocalPrivateKey stores the provided key in the database. +func (db *persistentDB) UpdateLocalPrivateKey(key PrivateKey) error { + return db.db.Set(localFieldKey(dbLocalKey), key) +} + // LastPing returns that property for the given peer ID and address. func (db *persistentDB) LastPing(id ID, address string) time.Time { return time.Unix(db.getInt64(nodeFieldKey(id, address, dbNodePing)), 0) diff --git a/plugins/autopeering/local/local.go b/plugins/autopeering/local/local.go index 71e358c0f9..ac43be56d9 100644 --- a/plugins/autopeering/local/local.go +++ b/plugins/autopeering/local/local.go @@ -1,6 +1,8 @@ package local import ( + "crypto/ed25519" + "encoding/base64" "fmt" "io/ioutil" "net" @@ -23,7 +25,7 @@ func configureLocal() *peer.Local { ip := net.ParseIP(parameter.NodeConfig.GetString(CFG_ADDRESS)) if ip == nil { - log.Fatalf("Invalid IP address: %s", parameter.NodeConfig.GetString(CFG_ADDRESS)) + log.Fatalf("Invalid %s address: %s", CFG_ADDRESS, parameter.NodeConfig.GetString(CFG_ADDRESS)) } if ip.IsUnspecified() { log.Info("Querying public IP ...") @@ -40,7 +42,25 @@ func configureLocal() *peer.Local { // create a new local node db := peer.NewPersistentDB(log) - local, err := peer.NewLocal("udp", net.JoinHostPort(ip.String(), port), db) + // the private key seed of the current local can be returned the following way: + // key, _ := db.LocalPrivateKey() + // fmt.Println(base64.StdEncoding.EncodeToString(ed25519.PrivateKey(key).Seed())) + + // set the private key from the seed provided in the config + var seed [][]byte + if parameter.NodeConfig.IsSet(CFG_SEED) { + str := parameter.NodeConfig.GetString(CFG_SEED) + bytes, err := base64.StdEncoding.DecodeString(str) + if err != nil { + log.Fatalf("Invalid %s: %s", CFG_SEED, err) + } + if l := len(bytes); l != ed25519.SeedSize { + log.Fatalf("Invalid %s length: %d, need %d", CFG_SEED, l, ed25519.SeedSize) + } + seed = append(seed, bytes) + } + + local, err := peer.NewLocal("udp", net.JoinHostPort(ip.String(), port), db, seed...) if err != nil { log.Fatalf("Error creating local: %s", err) } diff --git a/plugins/autopeering/local/parameters.go b/plugins/autopeering/local/parameters.go index 1bb7847d5b..ab7629e834 100644 --- a/plugins/autopeering/local/parameters.go +++ b/plugins/autopeering/local/parameters.go @@ -7,9 +7,11 @@ import ( const ( CFG_ADDRESS = "autopeering.address" CFG_PORT = "autopeering.port" + CFG_SEED = "autopeering.seed" ) func init() { flag.String(CFG_ADDRESS, "0.0.0.0", "address to bind for incoming peering requests") flag.Int(CFG_PORT, 14626, "udp port for incoming peering requests") + flag.BytesBase64(CFG_SEED, nil, "private key seed used to derive the node identity; optional Base64 encoded 256-bit string") } From 3da5d4c9ae3deb35d83b255450a92dd49aca1325 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Mon, 20 Jan 2020 13:16:57 +0100 Subject: [PATCH 118/184] Updates to latest hive.go (#147) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9209c98680..10d4c4c4cc 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/googollee/go-engine.io v1.4.3-0.20190924125625-798118fc0dd2 github.com/googollee/go-socket.io v1.4.3-0.20191204093753-683f8725b6d0 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e + github.com/iotaledger/hive.go v0.0.0-20200120092048-f168257b6ccc github.com/iotaledger/iota.go v1.0.0-beta.14 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect diff --git a/go.sum b/go.sum index 3e2ecd231d..6cba4d4943 100644 --- a/go.sum +++ b/go.sum @@ -116,8 +116,8 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e h1:bowQHvFQoUWPgxlF9cQRWDzREswR09HpihMiNX1q+AU= -github.com/iotaledger/hive.go v0.0.0-20200110132858-ea86cdb9d91e/go.mod h1:obs07gqna53/Yw1ltzLsQzJBMyA6lGu7Fb/ltjqWMnQ= +github.com/iotaledger/hive.go v0.0.0-20200120092048-f168257b6ccc h1:7SZQ3+4EvMd/iSOONrvD7Sa7qCm712KqTTKh8CK/9TU= +github.com/iotaledger/hive.go v0.0.0-20200120092048-f168257b6ccc/go.mod h1:obs07gqna53/Yw1ltzLsQzJBMyA6lGu7Fb/ltjqWMnQ= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/iotaledger/iota.go v1.0.0-beta.14 h1:Oeb28MfBuJEeXcGrLhTCJFtbsnc8y1u7xidsAmiOD5A= github.com/iotaledger/iota.go v1.0.0-beta.14/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= From ec9592a74c4c6d52a4925b0d4cecbfb8717a830a Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Mon, 20 Jan 2020 14:17:24 +0100 Subject: [PATCH 119/184] Feat: Remove error package in favor of stdlib's (#146) * refactors errors * fmt packages/model/error.go --- client/lib.go | 23 +- go.mod | 2 +- packages/autopeering/discover/protocol.go | 10 +- packages/autopeering/peer/peer.go | 13 +- packages/autopeering/selection/protocol.go | 8 +- packages/autopeering/server/errors.go | 2 +- packages/autopeering/server/server.go | 4 +- packages/database/badger_instance.go | 6 +- packages/datastructure/doubly_linked_list.go | 43 +-- packages/datastructure/errors.go | 2 +- packages/errors/errors.go | 365 ------------------ packages/errors/stack.go | 177 --------- packages/gossip/errors.go | 2 +- packages/gossip/manager.go | 6 +- packages/gossip/server/server.go | 12 +- packages/model/approvers/approvers.go | 12 +- packages/model/approvers/errors.go | 8 - packages/model/bundle/bundle.go | 12 +- packages/model/bundle/errors.go | 10 - packages/model/error.go | 8 + .../meta_transaction/meta_transaction.go | 10 +- packages/model/transactionmetadata/errors.go | 12 - .../transactionmetadata.go | 13 +- plugins/analysis/server/plugin.go | 15 +- plugins/analysis/types/addnode/packet.go | 8 +- plugins/analysis/types/connectnodes/packet.go | 8 +- .../analysis/types/disconnectnodes/packet.go | 8 +- plugins/analysis/types/ping/packet.go | 8 +- plugins/analysis/types/removenode/packet.go | 8 +- plugins/autopeering/autopeering.go | 8 +- plugins/bundleprocessor/bundleprocessor.go | 23 +- plugins/bundleprocessor/errors.go | 4 +- plugins/bundleprocessor/events.go | 3 +- plugins/bundleprocessor/plugin.go | 5 +- .../bundleprocessor/valuebundleprocessor.go | 3 +- plugins/gossip/gossip.go | 3 +- plugins/tangle/approvers.go | 20 +- plugins/tangle/bundle.go | 19 +- plugins/tangle/errors.go | 6 +- plugins/tangle/solidifier.go | 7 +- plugins/tangle/transaction.go | 20 +- plugins/tangle/transaction_metadata.go | 20 +- plugins/tangle/tx_per_address.go | 11 +- 43 files changed, 216 insertions(+), 751 deletions(-) delete mode 100644 packages/errors/errors.go delete mode 100644 packages/errors/stack.go delete mode 100644 packages/model/approvers/errors.go delete mode 100644 packages/model/bundle/errors.go create mode 100644 packages/model/error.go delete mode 100644 packages/model/transactionmetadata/errors.go diff --git a/client/lib.go b/client/lib.go index 87e8189699..ed2884bab4 100644 --- a/client/lib.go +++ b/client/lib.go @@ -4,11 +4,11 @@ package goshimmer import ( "bytes" "encoding/json" + "errors" "fmt" "io/ioutil" "net/http" - "github.com/iotaledger/goshimmer/packages/errors" webapi_broadcastData "github.com/iotaledger/goshimmer/plugins/webapi/broadcastData" webapi_findTransactions "github.com/iotaledger/goshimmer/plugins/webapi/findTransactions" webapi_getNeighbors "github.com/iotaledger/goshimmer/plugins/webapi/getNeighbors" @@ -59,7 +59,7 @@ type errorresponse struct { func interpretBody(res *http.Response, decodeTo interface{}) error { resBody, err := ioutil.ReadAll(res.Body) if err != nil { - return errors.Wrap(err, "unable to read response body") + return fmt.Errorf("unable to read response body: %w", err) } defer res.Body.Close() @@ -69,23 +69,24 @@ func interpretBody(res *http.Response, decodeTo interface{}) error { errRes := &errorresponse{} if err := json.Unmarshal(resBody, errRes); err != nil { - return errors.Wrap(err, "unable to read error from response body") + return fmt.Errorf("unable to read error from response body: %w", err) } switch res.StatusCode { case http.StatusInternalServerError: - return errors.Wrap(ErrInternalServerError, errRes.Error) + return fmt.Errorf("%w: %s", ErrInternalServerError, errRes.Error) case http.StatusNotFound: - return errors.Wrap(ErrNotFound, errRes.Error) + return fmt.Errorf("%w: %s", ErrNotFound, errRes.Error) case http.StatusBadRequest: - return errors.Wrap(ErrBadRequest, errRes.Error) + return fmt.Errorf("%w: %s", ErrBadRequest, errRes.Error) } - return errors.Wrap(ErrUnknownError, errRes.Error) + + return fmt.Errorf("%w: %s", ErrUnknownError, errRes.Error) } func (api *GoShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data string) (trinary.Hash, error) { if !guards.IsHash(targetAddress) { - return "", errors.Wrapf(consts.ErrInvalidHash, "invalid address: %s", targetAddress) + return "", fmt.Errorf("%w: invalid address: %s", consts.ErrInvalidHash, targetAddress) } reqBytes, err := json.Marshal(&webapi_broadcastData.Request{Address: targetAddress, Data: data}) @@ -109,7 +110,7 @@ func (api *GoShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data string func (api *GoShimmerAPI) GetTrytes(txHashes trinary.Hashes) ([]trinary.Trytes, error) { for _, hash := range txHashes { if !guards.IsTrytes(hash) { - return nil, errors.Wrapf(consts.ErrInvalidHash, "invalid hash: %s", hash) + return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash) } } @@ -134,7 +135,7 @@ func (api *GoShimmerAPI) GetTrytes(txHashes trinary.Hashes) ([]trinary.Trytes, e func (api *GoShimmerAPI) GetTransactions(txHashes trinary.Hashes) ([]webapi_getTransactions.Transaction, error) { for _, hash := range txHashes { if !guards.IsTrytes(hash) { - return nil, errors.Wrapf(consts.ErrInvalidHash, "invalid hash: %s", hash) + return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash) } } @@ -159,7 +160,7 @@ func (api *GoShimmerAPI) GetTransactions(txHashes trinary.Hashes) ([]webapi_getT func (api *GoShimmerAPI) FindTransactions(query *webapi_findTransactions.Request) ([]trinary.Hashes, error) { for _, hash := range query.Addresses { if !guards.IsTrytes(hash) { - return nil, errors.Wrapf(consts.ErrInvalidHash, "invalid hash: %s", hash) + return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash) } } diff --git a/go.mod b/go.mod index 10d4c4c4cc..0564d83750 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/mattn/go-isatty v0.0.11 // indirect github.com/mattn/go-runewidth v0.0.7 // indirect github.com/pelletier/go-toml v1.6.0 // indirect - github.com/pkg/errors v0.9.1 + github.com/pkg/errors v0.9.1 // indirect github.com/rivo/tview v0.0.0-20191229165609-1ee8d9874dcf github.com/spf13/afero v1.2.2 // indirect github.com/spf13/cast v1.3.1 // indirect diff --git a/packages/autopeering/discover/protocol.go b/packages/autopeering/discover/protocol.go index 242016f7b4..756f5fe1c2 100644 --- a/packages/autopeering/discover/protocol.go +++ b/packages/autopeering/discover/protocol.go @@ -2,6 +2,7 @@ package discover import ( "bytes" + "fmt" "sync" "time" @@ -12,7 +13,6 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/autopeering/server" "github.com/iotaledger/hive.go/logger" - "github.com/pkg/errors" ) // The Protocol handles the peer discovery. @@ -104,7 +104,7 @@ func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer. case pb.MPing: m := new(pb.Ping) if err := proto.Unmarshal(data[1:], m); err != nil { - return true, errors.Wrap(err, "invalid message") + return true, fmt.Errorf("invalid message: %w", err) } if p.validatePing(s, fromAddr, m) { p.handlePing(s, fromAddr, fromID, fromKey, data) @@ -114,7 +114,7 @@ func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer. case pb.MPong: m := new(pb.Pong) if err := proto.Unmarshal(data[1:], m); err != nil { - return true, errors.Wrap(err, "invalid message") + return true, fmt.Errorf("invalid message: %w", err) } if p.validatePong(s, fromAddr, fromID, m) { p.handlePong(fromAddr, fromID, fromKey, m) @@ -124,7 +124,7 @@ func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer. case pb.MDiscoveryRequest: m := new(pb.DiscoveryRequest) if err := proto.Unmarshal(data[1:], m); err != nil { - return true, errors.Wrap(err, "invalid message") + return true, fmt.Errorf("invalid message: %w", err) } if p.validateDiscoveryRequest(s, fromAddr, fromID, m) { p.handleDiscoveryRequest(s, fromAddr, data) @@ -134,7 +134,7 @@ func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer. case pb.MDiscoveryResponse: m := new(pb.DiscoveryResponse) if err := proto.Unmarshal(data[1:], m); err != nil { - return true, errors.Wrap(err, "invalid message") + return true, fmt.Errorf("invalid message: %w", err) } p.validateDiscoveryResponse(s, fromAddr, fromID, m) // DiscoveryResponse messages are handled in the handleReply function of the validation diff --git a/packages/autopeering/peer/peer.go b/packages/autopeering/peer/peer.go index 30a1882f2f..768511caf2 100644 --- a/packages/autopeering/peer/peer.go +++ b/packages/autopeering/peer/peer.go @@ -12,6 +12,11 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" ) +var ( + ErrNeedsPeeringService = errors.New("needs peering service") + ErrInvalidSignature = errors.New("invalid signature") +) + // PublicKey is the type of Ed25519 public keys used for peers. type PublicKey ed25519.PublicKey @@ -100,7 +105,7 @@ func FromProto(in *pb.Peer) (*Peer, error) { return nil, err } if services.Get(service.PeeringKey) == nil { - return nil, errors.New("need peering service") + return nil, ErrNeedsPeeringService } return NewPeer(in.GetPublicKey(), services), nil @@ -122,13 +127,13 @@ func Unmarshal(data []byte) (*Peer, error) { func recoverKey(key, data, sig []byte) (PublicKey, error) { if l := len(key); l != ed25519.PublicKeySize { - return nil, fmt.Errorf("invalid key length: %d, need %d", l, ed25519.PublicKeySize) + return nil, fmt.Errorf("%w: invalid key length: %d, need %d", ErrInvalidSignature, l, ed25519.PublicKeySize) } if l := len(sig); l != ed25519.SignatureSize { - return nil, fmt.Errorf("invalid signature length: %d, need %d", l, ed25519.SignatureSize) + return nil, fmt.Errorf("%w: invalid signature length: %d, need %d", ErrInvalidSignature, l, ed25519.SignatureSize) } if !ed25519.Verify(key, data, sig) { - return nil, errors.New("invalid signature") + return nil, ErrInvalidSignature } publicKey := make([]byte, ed25519.PublicKeySize) diff --git a/packages/autopeering/selection/protocol.go b/packages/autopeering/selection/protocol.go index dd92c1f2f7..f82697afd8 100644 --- a/packages/autopeering/selection/protocol.go +++ b/packages/autopeering/selection/protocol.go @@ -2,6 +2,7 @@ package selection import ( "bytes" + "fmt" "sync" "time" @@ -11,7 +12,6 @@ import ( pb "github.com/iotaledger/goshimmer/packages/autopeering/selection/proto" "github.com/iotaledger/goshimmer/packages/autopeering/server" "github.com/iotaledger/hive.go/logger" - "github.com/pkg/errors" ) // DiscoverProtocol specifies the methods from the peer discovery that are required. @@ -101,7 +101,7 @@ func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer. case pb.MPeeringRequest: m := new(pb.PeeringRequest) if err := proto.Unmarshal(data[1:], m); err != nil { - return true, errors.Wrap(err, "invalid message") + return true, fmt.Errorf("invalid message: %w", err) } if p.validatePeeringRequest(s, fromAddr, fromID, m) { p.handlePeeringRequest(s, fromAddr, fromID, data, m) @@ -111,7 +111,7 @@ func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer. case pb.MPeeringResponse: m := new(pb.PeeringResponse) if err := proto.Unmarshal(data[1:], m); err != nil { - return true, errors.Wrap(err, "invalid message") + return true, fmt.Errorf("invalid message: %w", err) } p.validatePeeringResponse(s, fromAddr, fromID, m) // PeeringResponse messages are handled in the handleReply function of the validation @@ -120,7 +120,7 @@ func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer. case pb.MPeeringDrop: m := new(pb.PeeringDrop) if err := proto.Unmarshal(data[1:], m); err != nil { - return true, errors.Wrap(err, "invalid message") + return true, fmt.Errorf("invalid message: %w", err) } if p.validatePeeringDrop(s, fromAddr, m) { p.handlePeeringDrop(fromID) diff --git a/packages/autopeering/server/errors.go b/packages/autopeering/server/errors.go index 54c5d51a35..c278c2f505 100644 --- a/packages/autopeering/server/errors.go +++ b/packages/autopeering/server/errors.go @@ -1,6 +1,6 @@ package server -import "github.com/pkg/errors" +import "errors" var ( // ErrTimeout is returned when an expected response was not received in time. diff --git a/packages/autopeering/server/server.go b/packages/autopeering/server/server.go index 2c6303e573..bd3d65da13 100644 --- a/packages/autopeering/server/server.go +++ b/packages/autopeering/server/server.go @@ -2,6 +2,7 @@ package server import ( "container/list" + "fmt" "io" "net" "sync" @@ -12,7 +13,6 @@ import ( pb "github.com/iotaledger/goshimmer/packages/autopeering/server/proto" "github.com/iotaledger/goshimmer/packages/autopeering/transport" "github.com/iotaledger/hive.go/logger" - "github.com/pkg/errors" ) const ( @@ -288,7 +288,7 @@ func (s *Server) readLoop() { func (s *Server) handlePacket(pkt *pb.Packet, fromAddr string) error { data, key, err := decode(pkt) if err != nil { - return errors.Wrap(err, "invalid packet") + return fmt.Errorf("invalid packet: %w", err) } fromID := key.ID() diff --git a/packages/database/badger_instance.go b/packages/database/badger_instance.go index 3f6fd82fdc..439aa4727d 100644 --- a/packages/database/badger_instance.go +++ b/packages/database/badger_instance.go @@ -1,13 +1,13 @@ package database import ( + "fmt" "os" "sync" "github.com/dgraph-io/badger" "github.com/dgraph-io/badger/options" "github.com/iotaledger/goshimmer/packages/parameter" - "github.com/pkg/errors" ) var instance *badger.DB @@ -40,7 +40,7 @@ func checkDir(dir string) error { func createDB() (*badger.DB, error) { directory := parameter.NodeConfig.GetString(CFG_DIRECTORY) if err := checkDir(directory); err != nil { - return nil, errors.Wrap(err, "Could not check directory") + return nil, fmt.Errorf("could not check directory: %w", err) } opts := badger.DefaultOptions(directory) @@ -50,7 +50,7 @@ func createDB() (*badger.DB, error) { db, err := badger.Open(opts) if err != nil { - return nil, errors.Wrap(err, "Could not open new DB") + return nil, fmt.Errorf("could not open new DB: %w", err) } return db, nil diff --git a/packages/datastructure/doubly_linked_list.go b/packages/datastructure/doubly_linked_list.go index 91d2e067e6..bc511e3f0f 100644 --- a/packages/datastructure/doubly_linked_list.go +++ b/packages/datastructure/doubly_linked_list.go @@ -1,9 +1,8 @@ package datastructure import ( + "fmt" "sync" - - "github.com/iotaledger/goshimmer/packages/errors" ) type DoublyLinkedList struct { @@ -66,7 +65,7 @@ func (list *DoublyLinkedList) Clear() { list.clear() } -func (list *DoublyLinkedList) GetFirst() (interface{}, errors.IdentifiableError) { +func (list *DoublyLinkedList) GetFirst() (interface{}, error) { if firstEntry, err := list.GetFirstEntry(); err != nil { return nil, err } else { @@ -74,14 +73,14 @@ func (list *DoublyLinkedList) GetFirst() (interface{}, errors.IdentifiableError) } } -func (list *DoublyLinkedList) GetFirstEntry() (*DoublyLinkedListEntry, errors.IdentifiableError) { +func (list *DoublyLinkedList) GetFirstEntry() (*DoublyLinkedListEntry, error) { list.mutex.RLock() defer list.mutex.RUnlock() return list.getFirstEntry() } -func (list *DoublyLinkedList) GetLast() (interface{}, errors.IdentifiableError) { +func (list *DoublyLinkedList) GetLast() (interface{}, error) { if lastEntry, err := list.GetLastEntry(); err != nil { return nil, err } else { @@ -89,14 +88,14 @@ func (list *DoublyLinkedList) GetLast() (interface{}, errors.IdentifiableError) } } -func (list *DoublyLinkedList) GetLastEntry() (*DoublyLinkedListEntry, errors.IdentifiableError) { +func (list *DoublyLinkedList) GetLastEntry() (*DoublyLinkedListEntry, error) { list.mutex.RLock() defer list.mutex.RUnlock() return list.getLastEntry() } -func (list *DoublyLinkedList) RemoveFirst() (interface{}, errors.IdentifiableError) { +func (list *DoublyLinkedList) RemoveFirst() (interface{}, error) { if firstEntry, err := list.RemoveFirstEntry(); err != nil { return nil, err } else { @@ -104,14 +103,14 @@ func (list *DoublyLinkedList) RemoveFirst() (interface{}, errors.IdentifiableErr } } -func (list *DoublyLinkedList) RemoveFirstEntry() (*DoublyLinkedListEntry, errors.IdentifiableError) { +func (list *DoublyLinkedList) RemoveFirstEntry() (*DoublyLinkedListEntry, error) { list.mutex.Lock() defer list.mutex.Unlock() return list.removeFirstEntry() } -func (list *DoublyLinkedList) RemoveLast() (interface{}, errors.IdentifiableError) { +func (list *DoublyLinkedList) RemoveLast() (interface{}, error) { if lastEntry, err := list.RemoveLastEntry(); err != nil { return nil, err } else { @@ -119,14 +118,14 @@ func (list *DoublyLinkedList) RemoveLast() (interface{}, errors.IdentifiableErro } } -func (list *DoublyLinkedList) RemoveLastEntry() (*DoublyLinkedListEntry, errors.IdentifiableError) { +func (list *DoublyLinkedList) RemoveLastEntry() (*DoublyLinkedListEntry, error) { list.mutex.Lock() defer list.mutex.Unlock() return list.removeLastEntry() } -func (list *DoublyLinkedList) Remove(value interface{}) errors.IdentifiableError { +func (list *DoublyLinkedList) Remove(value interface{}) error { list.mutex.RLock() currentEntry := list.head for currentEntry != nil { @@ -144,10 +143,10 @@ func (list *DoublyLinkedList) Remove(value interface{}) errors.IdentifiableError } list.mutex.RUnlock() - return ErrNoSuchElement.Derive("the entry is not part of the list") + return fmt.Errorf("%w: the entry is not part of the list", ErrNoSuchElement) } -func (list *DoublyLinkedList) RemoveEntry(entry *DoublyLinkedListEntry) errors.IdentifiableError { +func (list *DoublyLinkedList) RemoveEntry(entry *DoublyLinkedListEntry) error { list.mutex.Lock() defer list.mutex.Unlock() @@ -195,23 +194,23 @@ func (list *DoublyLinkedList) clear() { list.count = 0 } -func (list *DoublyLinkedList) getFirstEntry() (*DoublyLinkedListEntry, errors.IdentifiableError) { +func (list *DoublyLinkedList) getFirstEntry() (*DoublyLinkedListEntry, error) { if list.head == nil { - return nil, ErrNoSuchElement.Derive("the list is empty") + return nil, fmt.Errorf("%w: the list is empty", ErrNoSuchElement) } return list.head, nil } -func (list *DoublyLinkedList) getLastEntry() (*DoublyLinkedListEntry, errors.IdentifiableError) { +func (list *DoublyLinkedList) getLastEntry() (*DoublyLinkedListEntry, error) { if list.tail == nil { - return nil, ErrNoSuchElement.Derive("the list is empty") + return nil, fmt.Errorf("%w: the list is empty", ErrNoSuchElement) } return list.tail, nil } -func (list *DoublyLinkedList) removeFirstEntry() (*DoublyLinkedListEntry, errors.IdentifiableError) { +func (list *DoublyLinkedList) removeFirstEntry() (*DoublyLinkedListEntry, error) { entryToRemove := list.head if err := list.removeEntry(entryToRemove); err != nil { return nil, err @@ -220,7 +219,7 @@ func (list *DoublyLinkedList) removeFirstEntry() (*DoublyLinkedListEntry, errors return entryToRemove, nil } -func (list *DoublyLinkedList) removeLastEntry() (*DoublyLinkedListEntry, errors.IdentifiableError) { +func (list *DoublyLinkedList) removeLastEntry() (*DoublyLinkedListEntry, error) { entryToRemove := list.tail if err := list.removeEntry(entryToRemove); err != nil { return nil, err @@ -229,13 +228,13 @@ func (list *DoublyLinkedList) removeLastEntry() (*DoublyLinkedListEntry, errors. return entryToRemove, nil } -func (list *DoublyLinkedList) removeEntry(entry *DoublyLinkedListEntry) errors.IdentifiableError { +func (list *DoublyLinkedList) removeEntry(entry *DoublyLinkedListEntry) error { if entry == nil { - return ErrInvalidArgument.Derive("the entry must not be nil") + return fmt.Errorf("%w: the entry must not be nil", ErrInvalidArgument) } if list.head == nil { - return ErrNoSuchElement.Derive("the entry is not part of the list") + return fmt.Errorf("%w: the entry is not part of the list", ErrNoSuchElement) } prevEntry := entry.GetPrev() diff --git a/packages/datastructure/errors.go b/packages/datastructure/errors.go index bd52cc1cf5..757c2ef93e 100644 --- a/packages/datastructure/errors.go +++ b/packages/datastructure/errors.go @@ -1,7 +1,7 @@ package datastructure import ( - "github.com/iotaledger/goshimmer/packages/errors" + "errors" ) var ( diff --git a/packages/errors/errors.go b/packages/errors/errors.go deleted file mode 100644 index 738ed62970..0000000000 --- a/packages/errors/errors.go +++ /dev/null @@ -1,365 +0,0 @@ -// Package errors provides simple error handling primitives. -// -// The traditional error handling idiom in Go is roughly akin to -// -// if err != nil { -// return err -// } -// -// which when applied recursively up the call stack results in error reports -// without context or debugging information. The errors package allows -// programmers to add context to the failure path in their code in a way -// that does not destroy the original value of the error. -// -// Adding context to an error -// -// The errors.Wrap function returns a new error that adds context to the -// original error by recording a stack trace at the point Wrap is called, -// together with the supplied message. For example -// -// _, err := ioutil.ReadAll(r) -// if err != nil { -// return errors.Wrap(err, "read failed") -// } -// -// If additional control is required, the errors.WithStack and -// errors.WithMessage functions destructure errors.Wrap into its component -// operations: annotating an error with a stack trace and with a message, -// respectively. -// -// Retrieving the cause of an error -// -// Using errors.Wrap constructs a stack of errors, adding context to the -// preceding error. Depending on the nature of the error it may be necessary -// to reverse the operation of errors.Wrap to retrieve the original error -// for inspection. Any error value which implements this interface -// -// type causer interface { -// Cause() error -// } -// -// can be inspected by errors.Cause. errors.Cause will recursively retrieve -// the topmost error that does not implement causer, which is assumed to be -// the original cause. For example: -// -// switch err := errors.Cause(err).(type) { -// case *MyError: -// // handle specifically -// default: -// // unknown error -// } -// -// Although the causer interface is not exported by this package, it is -// considered a part of its stable public interface. -// -// Formatted printing of errors -// -// All error values returned from this package implement fmt.Formatter and can -// be formatted by the fmt package. The following verbs are supported: -// -// %s print the error. If the error has a Cause it will be -// printed recursively. -// %v see %s -// %+v extended format. Each Frame of the error's StackTrace will -// be printed in detail. -// -// Retrieving the stack trace of an error or wrapper -// -// New, Errorf, Wrap, and Wrapf record a stack trace at the point they are -// invoked. This information can be retrieved with the following interface: -// -// type stackTracer interface { -// StackTrace() errors.StackTrace -// } -// -// The returned errors.StackTrace type is defined as -// -// type StackTrace []Frame -// -// The Frame type represents a call site in the stack trace. Frame supports -// the fmt.Formatter interface that can be used for printing information about -// the stack trace of this error. For example: -// -// if err, ok := err.(stackTracer); ok { -// for _, f := range err.StackTrace() { -// fmt.Printf("%+s:%d\n", f, f) -// } -// } -// -// Although the stackTracer interface is not exported by this package, it is -// considered a part of its stable public interface. -// -// See the documentation for Frame.Format for more details. -package errors - -import ( - "fmt" - "io" -) - -var idCounter = 0 - -// New returns an error with the supplied message. -// New also records the stack trace at the point it was called. -func New(message string) *fundamental { - idCounter++ - - return &fundamental{ - id: idCounter, - msg: message, - stack: Callers(), - } -} - -// Errorf formats according to a format specifier and returns the string -// as a value that satisfies error. -// Errorf also records the stack trace at the point it was called. -func Errorf(format string, args ...interface{}) IdentifiableError { - idCounter++ - - return &fundamental{ - id: idCounter, - msg: fmt.Sprintf(format, args...), - stack: Callers(), - } -} - -// fundamental is an error that has a message and a stack, but no caller. -type fundamental struct { - id int - msg string - *stack -} - -func (f *fundamental) Derive(msg string) *fundamental { - return &fundamental{ - id: f.id, - msg: msg, - stack: Callers(), - } -} - -func (f *fundamental) Error() string { return f.msg } - -func (f *fundamental) Equals(err IdentifiableError) bool { - return f.id == err.Id() -} - -func (f *fundamental) Id() int { - return f.id -} - -func (f *fundamental) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - io.WriteString(s, f.msg) - f.stack.Format(s, verb) - return - } - fallthrough - case 's': - io.WriteString(s, f.msg) - case 'q': - fmt.Fprintf(s, "%q", f.msg) - } -} - -// WithStack annotates err with a stack trace at the point WithStack was called. -// If err is nil, WithStack returns nil. -func WithStack(err error) IdentifiableError { - if err == nil { - return nil - } - - idCounter++ - - return &withStack{ - idCounter, - err, - Callers(), - } -} - -type withStack struct { - int - error - *stack -} - -func (w *withStack) Equals(err IdentifiableError) bool { - return w.int == err.Id() -} - -func (w *withStack) Id() int { - return w.int -} - -func (w *withStack) Derive(err error, message string) *withStack { - if err == nil { - return nil - } - return &withStack{ - w.int, - &withMessage{ - cause: err, - msg: message, - }, - Callers(), - } -} - -func (w *withStack) Cause() error { return w.error } - -func (w *withStack) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - fmt.Fprintf(s, "%+v", w.Cause()) - w.stack.Format(s, verb) - return - } - fallthrough - case 's': - io.WriteString(s, w.Error()) - case 'q': - fmt.Fprintf(s, "%q", w.Error()) - } -} - -// Wrap returns an error annotating err with a stack trace -// at the point Wrap is called, and the supplied message. -// If err is nil, Wrap returns nil. -func Wrap(err error, message string) *withStack { - if err == nil { - return nil - } - err = &withMessage{ - cause: err, - msg: message, - } - - idCounter++ - - return &withStack{ - idCounter, - err, - Callers(), - } -} - -// Wrapf returns an error annotating err with a stack trace -// at the point Wrapf is called, and the format specifier. -// If err is nil, Wrapf returns nil. -func Wrapf(err error, format string, args ...interface{}) IdentifiableError { - if err == nil { - return nil - } - err = &withMessage{ - cause: err, - msg: fmt.Sprintf(format, args...), - } - - idCounter++ - - return &withStack{ - idCounter, - err, - Callers(), - } -} - -// WithMessage annotates err with a new message. -// If err is nil, WithMessage returns nil. -func WithMessage(err error, message string) IdentifiableError { - if err == nil { - return nil - } - - idCounter++ - - return &withMessage{ - id: idCounter, - cause: err, - msg: message, - } -} - -// WithMessagef annotates err with the format specifier. -// If err is nil, WithMessagef returns nil. -func WithMessagef(err error, format string, args ...interface{}) IdentifiableError { - if err == nil { - return nil - } - - idCounter++ - - return &withMessage{ - id: idCounter, - cause: err, - msg: fmt.Sprintf(format, args...), - } -} - -type withMessage struct { - id int - cause error - msg string -} - -func (w *withMessage) Equals(err IdentifiableError) bool { - return w.id == err.Id() -} - -func (w *withMessage) Id() int { - return w.id -} - -func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() } -func (w *withMessage) Cause() error { return w.cause } - -func (w *withMessage) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - fmt.Fprintf(s, "%+v\n", w.Cause()) - io.WriteString(s, w.msg) - return - } - fallthrough - case 's', 'q': - io.WriteString(s, w.Error()) - } -} - -// Cause returns the underlying cause of the error, if possible. -// An error value has a cause if it implements the following -// interface: -// -// type causer interface { -// Cause() error -// } -// -// If the error does not implement Cause, the original error will -// be returned. If the error is nil, nil will be returned without further -// investigation. -func Cause(err error) error { - type causer interface { - Cause() error - } - - for err != nil { - cause, ok := err.(causer) - if !ok { - break - } - err = cause.Cause() - } - return err -} - -type IdentifiableError interface { - Error() string - Equals(identifiableError IdentifiableError) bool - Id() int -} diff --git a/packages/errors/stack.go b/packages/errors/stack.go deleted file mode 100644 index 8752168799..0000000000 --- a/packages/errors/stack.go +++ /dev/null @@ -1,177 +0,0 @@ -package errors - -import ( - "fmt" - "io" - "path" - "runtime" - "strconv" - "strings" -) - -// Frame represents a program counter inside a stack frame. -// For historical reasons if Frame is interpreted as a uintptr -// its value represents the program counter + 1. -type Frame uintptr - -// pc returns the program counter for this frame; -// multiple frames may have the same PC value. -func (f Frame) pc() uintptr { return uintptr(f) - 1 } - -// file returns the full path to the file that contains the -// function for this Frame's pc. -func (f Frame) file() string { - fn := runtime.FuncForPC(f.pc()) - if fn == nil { - return "unknown" - } - file, _ := fn.FileLine(f.pc()) - return file -} - -// line returns the line number of source code of the -// function for this Frame's pc. -func (f Frame) line() int { - fn := runtime.FuncForPC(f.pc()) - if fn == nil { - return 0 - } - _, line := fn.FileLine(f.pc()) - return line -} - -// name returns the name of this function, if known. -func (f Frame) name() string { - fn := runtime.FuncForPC(f.pc()) - if fn == nil { - return "unknown" - } - return fn.Name() -} - -// Format formats the frame according to the fmt.Formatter interface. -// -// %s source file -// %d source line -// %n function name -// %v equivalent to %s:%d -// -// Format accepts flags that alter the printing of some verbs, as follows: -// -// %+s function name and path of source file relative to the compile time -// GOPATH separated by \n\t (\n\t) -// %+v equivalent to %+s:%d -func (f Frame) Format(s fmt.State, verb rune) { - switch verb { - case 's': - switch { - case s.Flag('+'): - io.WriteString(s, f.name()) - io.WriteString(s, "\n\t") - io.WriteString(s, f.file()) - default: - io.WriteString(s, path.Base(f.file())) - } - case 'd': - io.WriteString(s, strconv.Itoa(f.line())) - case 'n': - io.WriteString(s, funcname(f.name())) - case 'v': - f.Format(s, 's') - io.WriteString(s, ":") - f.Format(s, 'd') - } -} - -// MarshalText formats a stacktrace Frame as a text string. The output is the -// same as that of fmt.Sprintf("%+v", f), but without newlines or tabs. -func (f Frame) MarshalText() ([]byte, error) { - name := f.name() - if name == "unknown" { - return []byte(name), nil - } - return []byte(fmt.Sprintf("%s %s:%d", name, f.file(), f.line())), nil -} - -// StackTrace is stack of Frames from innermost (newest) to outermost (oldest). -type StackTrace []Frame - -// Format formats the stack of Frames according to the fmt.Formatter interface. -// -// %s lists source files for each Frame in the stack -// %v lists the source file and line number for each Frame in the stack -// -// Format accepts flags that alter the printing of some verbs, as follows: -// -// %+v Prints filename, function, and line number for each Frame in the stack. -func (st StackTrace) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - switch { - case s.Flag('+'): - for _, f := range st { - io.WriteString(s, "\n") - f.Format(s, verb) - } - case s.Flag('#'): - fmt.Fprintf(s, "%#v", []Frame(st)) - default: - st.formatSlice(s, verb) - } - case 's': - st.formatSlice(s, verb) - } -} - -// formatSlice will format this StackTrace into the given buffer as a slice of -// Frame, only valid when called with '%s' or '%v'. -func (st StackTrace) formatSlice(s fmt.State, verb rune) { - io.WriteString(s, "[") - for i, f := range st { - if i > 0 { - io.WriteString(s, " ") - } - f.Format(s, verb) - } - io.WriteString(s, "]") -} - -// stack represents a stack of program counters. -type stack []uintptr - -func (s *stack) Format(st fmt.State, verb rune) { - switch verb { - case 'v': - switch { - case st.Flag('+'): - for _, pc := range *s { - f := Frame(pc) - fmt.Fprintf(st, "\n%+v", f) - } - } - } -} - -func (s *stack) StackTrace() StackTrace { - f := make([]Frame, len(*s)) - for i := 0; i < len(f); i++ { - f[i] = Frame((*s)[i]) - } - return f -} - -func Callers() *stack { - const depth = 32 - var pcs [depth]uintptr - n := runtime.Callers(3, pcs[:]) - var st stack = pcs[0:n] - return &st -} - -// funcname removes the path prefix component of a function's name reported by func.Name(). -func funcname(name string) string { - i := strings.LastIndex(name, "/") - name = name[i+1:] - i = strings.Index(name, ".") - return name[i+1:] -} diff --git a/packages/gossip/errors.go b/packages/gossip/errors.go index e32a15305c..85e43340fe 100644 --- a/packages/gossip/errors.go +++ b/packages/gossip/errors.go @@ -1,6 +1,6 @@ package gossip -import "github.com/pkg/errors" +import "errors" var ( ErrNotStarted = errors.New("manager not started") diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go index 1050243f82..03bcb47502 100644 --- a/packages/gossip/manager.go +++ b/packages/gossip/manager.go @@ -1,6 +1,7 @@ package gossip import ( + "fmt" "net" "sync" @@ -10,7 +11,6 @@ import ( pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/gossip/server" "github.com/iotaledger/hive.go/events" - "github.com/pkg/errors" "go.uber.org/zap" ) @@ -225,7 +225,7 @@ func (m *Manager) handlePacket(data []byte, p *peer.Peer) error { case pb.MTransaction: msg := new(pb.Transaction) if err := proto.Unmarshal(data[1:], msg); err != nil { - return errors.Wrap(err, "invalid packet") + return fmt.Errorf("invalid packet: %w", err) } m.log.Debugw("Received Transaction", "data", msg.GetData()) Events.TransactionReceived.Trigger(&TransactionReceivedEvent{Data: msg.GetData(), Peer: p}) @@ -234,7 +234,7 @@ func (m *Manager) handlePacket(data []byte, p *peer.Peer) error { case pb.MTransactionRequest: msg := new(pb.TransactionRequest) if err := proto.Unmarshal(data[1:], msg); err != nil { - return errors.Wrap(err, "invalid packet") + return fmt.Errorf("invalid packet: %w", err) } m.log.Debugw("Received Tx Req", "data", msg.GetHash()) // do something diff --git a/packages/gossip/server/server.go b/packages/gossip/server/server.go index 7723d4ee39..8cbab0e37c 100644 --- a/packages/gossip/server/server.go +++ b/packages/gossip/server/server.go @@ -3,6 +3,7 @@ package server import ( "bytes" "container/list" + "errors" "fmt" "io" "net" @@ -14,7 +15,6 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" pb "github.com/iotaledger/goshimmer/packages/autopeering/server/proto" - "github.com/pkg/errors" "go.uber.org/zap" ) @@ -141,12 +141,12 @@ func (t *TCP) DialPeer(p *peer.Peer) (net.Conn, error) { conn, err := net.DialTimeout(gossipAddr.Network(), gossipAddr.String(), acceptTimeout) if err != nil { - return nil, errors.Wrap(err, "dial peer failed") + return nil, fmt.Errorf("dial peer failed: %w", err) } err = t.doHandshake(p.PublicKey(), gossipAddr.String(), conn) if err != nil { - return nil, errors.Wrap(err, "outgoing handshake failed") + return nil, fmt.Errorf("outgoing handshake failed: %w", err) } t.log.Debugw("outgoing connection established", @@ -166,7 +166,7 @@ func (t *TCP) AcceptPeer(p *peer.Peer) (net.Conn, error) { // wait for the connection connected := <-t.acceptPeer(p) if connected.err != nil { - return nil, errors.Wrap(connected.err, "accept peer failed") + return nil, fmt.Errorf("accept peer failed: %w", connected.err) } t.log.Debugw("incoming connection established", @@ -269,7 +269,7 @@ func (t *TCP) matchAccept(m *acceptMatcher, req []byte, conn net.Conn) { defer t.wg.Done() if err := t.writeHandshakeResponse(req, conn); err != nil { - m.connected <- connect{nil, errors.Wrap(err, "incoming handshake failed")} + m.connected <- connect{nil, fmt.Errorf("incoming handshake failed: %w", err)} t.closeConnection(conn) return } @@ -375,7 +375,7 @@ func (t *TCP) readHandshakeRequest(conn net.Conn) (peer.PublicKey, []byte, error b := make([]byte, maxHandshakePacketSize) n, err := conn.Read(b) if err != nil { - return nil, nil, errors.Wrap(err, ErrInvalidHandshake.Error()) + return nil, nil, fmt.Errorf("%w: %s", ErrInvalidHandshake, err.Error()) } pkt := &pb.Packet{} diff --git a/packages/model/approvers/approvers.go b/packages/model/approvers/approvers.go index 1c98156dcd..d84e02216e 100644 --- a/packages/model/approvers/approvers.go +++ b/packages/model/approvers/approvers.go @@ -2,10 +2,10 @@ package approvers import ( "encoding/binary" - "strconv" + "fmt" "sync" - "github.com/iotaledger/goshimmer/packages/errors" + "github.com/iotaledger/goshimmer/packages/model" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" ) @@ -86,17 +86,17 @@ func (approvers *Approvers) Marshal() (result []byte) { return } -func (approvers *Approvers) Unmarshal(data []byte) (err errors.IdentifiableError) { +func (approvers *Approvers) Unmarshal(data []byte) error { dataLen := len(data) if dataLen < MARSHALED_APPROVERS_MIN_SIZE { - return ErrMarshallFailed.Derive(errors.New("unmarshall failed"), "marshaled approvers are too short") + return fmt.Errorf("%w: marshaled approvers are too short", model.ErrMarshalFailed) } hashesCount := binary.BigEndian.Uint64(data[MARSHALED_APPROVERS_HASHES_COUNT_START:MARSHALED_APPROVERS_HASHES_COUNT_END]) if dataLen < MARSHALED_APPROVERS_MIN_SIZE+int(hashesCount)*MARSHALED_APPROVERS_HASH_SIZE { - return ErrMarshallFailed.Derive(errors.New("unmarshall failed"), "marshaled approvers are too short for "+strconv.FormatUint(hashesCount, 10)+" approvers") + return fmt.Errorf("%w: marshaled approvers are too short for %d approvers", model.ErrMarshalFailed, hashesCount) } approvers.hashesMutex.Lock() @@ -112,7 +112,7 @@ func (approvers *Approvers) Unmarshal(data []byte) (err errors.IdentifiableError approvers.hashesMutex.Unlock() - return + return nil } // endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/packages/model/approvers/errors.go b/packages/model/approvers/errors.go deleted file mode 100644 index 81e5d9e1c2..0000000000 --- a/packages/model/approvers/errors.go +++ /dev/null @@ -1,8 +0,0 @@ -package approvers - -import "github.com/iotaledger/goshimmer/packages/errors" - -var ( - ErrUnmarshalFailed = errors.Wrap(errors.New("unmarshall failed"), "input data is corrupted") - ErrMarshallFailed = errors.Wrap(errors.New("marshal failed"), "the source object contains invalid values") -) diff --git a/packages/model/bundle/bundle.go b/packages/model/bundle/bundle.go index 977592c4c7..d54092ed0e 100644 --- a/packages/model/bundle/bundle.go +++ b/packages/model/bundle/bundle.go @@ -2,11 +2,11 @@ package bundle import ( "encoding/binary" - "strconv" + "fmt" "sync" "unsafe" - "github.com/iotaledger/goshimmer/packages/errors" + "github.com/iotaledger/goshimmer/packages/model" "github.com/iotaledger/hive.go/bitmask" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" @@ -140,17 +140,17 @@ func (bundle *Bundle) Marshal() (result []byte) { return } -func (bundle *Bundle) Unmarshal(data []byte) (err errors.IdentifiableError) { +func (bundle *Bundle) Unmarshal(data []byte) error { dataLen := len(data) if dataLen < MARSHALED_MIN_SIZE { - return ErrMarshallFailed.Derive(errors.New("unmarshall failed"), "marshaled bundle is too short") + return fmt.Errorf("%w: marshaled bundle is too short", model.ErrMarshalFailed) } hashesCount := binary.BigEndian.Uint64(data[MARSHALED_TRANSACTIONS_COUNT_START:MARSHALED_TRANSACTIONS_COUNT_END]) if dataLen < MARSHALED_MIN_SIZE+int(hashesCount)*MARSHALED_TRANSACTION_HASH_SIZE { - return ErrMarshallFailed.Derive(errors.New("unmarshall failed"), "marshaled bundle is too short for "+strconv.FormatUint(hashesCount, 10)+" transactions") + return fmt.Errorf("%w: marshaled bundle is too short for %d transactions", model.ErrMarshalFailed, hashesCount) } bundle.hashMutex.Lock() @@ -179,5 +179,5 @@ func (bundle *Bundle) Unmarshal(data []byte) (err errors.IdentifiableError) { bundle.bundleEssenceHashMutex.Unlock() bundle.hashMutex.Unlock() - return + return nil } diff --git a/packages/model/bundle/errors.go b/packages/model/bundle/errors.go deleted file mode 100644 index c4805e6bb6..0000000000 --- a/packages/model/bundle/errors.go +++ /dev/null @@ -1,10 +0,0 @@ -package bundle - -import ( - "github.com/iotaledger/goshimmer/packages/errors" -) - -var ( - ErrUnmarshalFailed = errors.Wrap(errors.New("unmarshall failed"), "input data is corrupted") - ErrMarshallFailed = errors.Wrap(errors.New("marshal failed"), "the source object contains invalid values") -) diff --git a/packages/model/error.go b/packages/model/error.go new file mode 100644 index 0000000000..b060d2d30b --- /dev/null +++ b/packages/model/error.go @@ -0,0 +1,8 @@ +package model + +import "errors" + +var ( + ErrUnmarshalFailed = errors.New("unmarshal failed") + ErrMarshalFailed = errors.New("marshal failed") +) diff --git a/packages/model/meta_transaction/meta_transaction.go b/packages/model/meta_transaction/meta_transaction.go index 1ed461447c..45550786ca 100644 --- a/packages/model/meta_transaction/meta_transaction.go +++ b/packages/model/meta_transaction/meta_transaction.go @@ -1,6 +1,7 @@ package meta_transaction import ( + "errors" "fmt" "sync" @@ -8,7 +9,10 @@ import ( "github.com/iotaledger/iota.go/curl" "github.com/iotaledger/iota.go/pow" "github.com/iotaledger/iota.go/trinary" - "github.com/pkg/errors" +) + +var ( + ErrInvalidWeightMagnitude = errors.New("insufficient weight magnitude") ) type MetaTransaction struct { @@ -552,7 +556,7 @@ func (this *MetaTransaction) DoProofOfWork(mwm int) error { this.hasherMutex.Unlock() if err != nil { - return errors.Wrap(err, "PoW failed") + return fmt.Errorf("PoW failed: %w", err) } this.SetNonce(nonce) @@ -563,7 +567,7 @@ func (this *MetaTransaction) Validate() error { // check that the weight magnitude is valid weightMagnitude := this.GetWeightMagnitude() if weightMagnitude < MIN_WEIGHT_MAGNITUDE { - return fmt.Errorf("insufficient weight magnitude: got=%d, want=%d", weightMagnitude, MIN_WEIGHT_MAGNITUDE) + return fmt.Errorf("%w: got=%d, want=%d", ErrInvalidWeightMagnitude, weightMagnitude, MIN_WEIGHT_MAGNITUDE) } return nil diff --git a/packages/model/transactionmetadata/errors.go b/packages/model/transactionmetadata/errors.go deleted file mode 100644 index b8cfc22399..0000000000 --- a/packages/model/transactionmetadata/errors.go +++ /dev/null @@ -1,12 +0,0 @@ -package transactionmetadata - -import "github.com/iotaledger/goshimmer/packages/errors" - -// region errors /////////////////////////////////////////////////////////////////////////////////////////////////////// - -var ( - ErrUnmarshalFailed = errors.Wrap(errors.New("unmarshall failed"), "input data is corrupted") - ErrMarshallFailed = errors.Wrap(errors.New("marshal failed"), "the source object contains invalid values") -) - -// endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/packages/model/transactionmetadata/transactionmetadata.go b/packages/model/transactionmetadata/transactionmetadata.go index daf4a2342e..66a2796601 100644 --- a/packages/model/transactionmetadata/transactionmetadata.go +++ b/packages/model/transactionmetadata/transactionmetadata.go @@ -1,10 +1,11 @@ package transactionmetadata import ( + "fmt" "sync" "time" - "github.com/iotaledger/goshimmer/packages/errors" + "github.com/iotaledger/goshimmer/packages/model" "github.com/iotaledger/hive.go/bitmask" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" @@ -206,7 +207,7 @@ func (metadata *TransactionMetadata) SetModified(modified bool) { // region marshaling functions ///////////////////////////////////////////////////////////////////////////////////////// -func (metadata *TransactionMetadata) Marshal() ([]byte, errors.IdentifiableError) { +func (metadata *TransactionMetadata) Marshal() ([]byte, error) { marshaledMetadata := make([]byte, MARSHALED_TOTAL_SIZE) metadata.receivedTimeMutex.RLock() @@ -222,7 +223,7 @@ func (metadata *TransactionMetadata) Marshal() ([]byte, errors.IdentifiableError marshaledReceivedTime, err := metadata.receivedTime.MarshalBinary() if err != nil { - return nil, ErrMarshallFailed.Derive(err, "failed to marshal received time") + return nil, fmt.Errorf("%w: failed to marshal received time: %s", model.ErrMarshalFailed, err.Error()) } copy(marshaledMetadata[MARSHALED_RECEIVED_TIME_START:MARSHALED_RECEIVED_TIME_END], marshaledReceivedTime) @@ -241,7 +242,7 @@ func (metadata *TransactionMetadata) Marshal() ([]byte, errors.IdentifiableError return marshaledMetadata, nil } -func (metadata *TransactionMetadata) Unmarshal(data []byte) errors.IdentifiableError { +func (metadata *TransactionMetadata) Unmarshal(data []byte) error { metadata.hashMutex.Lock() defer metadata.hashMutex.Unlock() metadata.receivedTimeMutex.Lock() @@ -253,10 +254,10 @@ func (metadata *TransactionMetadata) Unmarshal(data []byte) errors.IdentifiableE metadata.finalizedMutex.Lock() defer metadata.finalizedMutex.Unlock() - metadata.hash = trinary.Trytes(typeutils.BytesToString(data[MARSHALED_HASH_START:MARSHALED_HASH_END])) + metadata.hash = typeutils.BytesToString(data[MARSHALED_HASH_START:MARSHALED_HASH_END]) if err := metadata.receivedTime.UnmarshalBinary(data[MARSHALED_RECEIVED_TIME_START:MARSHALED_RECEIVED_TIME_END]); err != nil { - return ErrUnmarshalFailed.Derive(err, "could not unmarshal the received time") + return fmt.Errorf("%w: could not unmarshal the received time: %s", model.ErrUnmarshalFailed, err.Error()) } booleanFlags := bitmask.BitMask(data[MARSHALED_FLAGS_START]) diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index a46f4c2fe9..ab1b14453c 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -2,6 +2,7 @@ package server import ( "encoding/hex" + "errors" "math" "github.com/iotaledger/goshimmer/packages/network" @@ -17,12 +18,14 @@ import ( "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" - "github.com/pkg/errors" ) -var server *tcp.Server - -var log *logger.Logger +var ( + ErrInvalidPackageHeader = errors.New("invalid package header") + ErrExpectedInitialAddNodePackage = errors.New("expected initial add node package") + server *tcp.Server + log *logger.Logger +) func Configure(plugin *node.Plugin) { log = logger.NewLogger("Analysis-Server") @@ -136,7 +139,7 @@ func processIncomingPacket(connectionState *byte, receiveBuffer *[]byte, conn *n if firstPackage { if *connectionState != STATE_ADD_NODE { - Events.Error.Trigger(errors.New("expected initial add node package")) + Events.Error.Trigger(ErrExpectedInitialAddNodePackage) } else { *connectionState = STATE_INITIAL_ADDNODE } @@ -194,7 +197,7 @@ func parsePackageHeader(data []byte) (ConnectionState, []byte, error) { connectionState = STATE_REMOVE_NODE default: - return 0, nil, errors.New("invalid package header") + return 0, nil, ErrInvalidPackageHeader } return connectionState, receiveBuffer, nil diff --git a/plugins/analysis/types/addnode/packet.go b/plugins/analysis/types/addnode/packet.go index 79d0274db2..da2ba9925b 100644 --- a/plugins/analysis/types/addnode/packet.go +++ b/plugins/analysis/types/addnode/packet.go @@ -1,6 +1,10 @@ package addnode -import "github.com/pkg/errors" +import "errors" + +var ( + ErrMalformedAddNodePacket = errors.New("malformed add node packet") +) type Packet struct { NodeId []byte @@ -8,7 +12,7 @@ type Packet struct { func Unmarshal(data []byte) (*Packet, error) { if len(data) < MARSHALED_TOTAL_SIZE || data[0] != MARSHALED_PACKET_HEADER { - return nil, errors.New("malformed add node packet") + return nil, ErrMalformedAddNodePacket } unmarshaledPackage := &Packet{ diff --git a/plugins/analysis/types/connectnodes/packet.go b/plugins/analysis/types/connectnodes/packet.go index 7d9c05a815..1e672c3ad4 100644 --- a/plugins/analysis/types/connectnodes/packet.go +++ b/plugins/analysis/types/connectnodes/packet.go @@ -1,6 +1,10 @@ package connectnodes -import "github.com/pkg/errors" +import "errors" + +var ( + ErrMalformedConnectNodesPacket = errors.New("malformed connect nodes packet") +) type Packet struct { SourceId []byte @@ -9,7 +13,7 @@ type Packet struct { func Unmarshal(data []byte) (*Packet, error) { if len(data) < MARSHALED_TOTAL_SIZE || data[0] != MARSHALED_PACKET_HEADER { - return nil, errors.New("malformed connect nodes packet") + return nil, ErrMalformedConnectNodesPacket } unmarshaledPackage := &Packet{ diff --git a/plugins/analysis/types/disconnectnodes/packet.go b/plugins/analysis/types/disconnectnodes/packet.go index 9193312e41..b810fa8fef 100644 --- a/plugins/analysis/types/disconnectnodes/packet.go +++ b/plugins/analysis/types/disconnectnodes/packet.go @@ -1,6 +1,10 @@ package disconnectnodes -import "github.com/pkg/errors" +import "errors" + +var ( + ErrMalformedDisconnectNodesPacket = errors.New("malformed disconnect nodes packet") +) type Packet struct { SourceId []byte @@ -9,7 +13,7 @@ type Packet struct { func Unmarshal(data []byte) (*Packet, error) { if len(data) < MARSHALED_TOTAL_SIZE || data[0] != MARSHALED_PACKET_HEADER { - return nil, errors.New("malformed disconnect nodes packet") + return nil, ErrMalformedDisconnectNodesPacket } unmarshaledPackage := &Packet{ diff --git a/plugins/analysis/types/ping/packet.go b/plugins/analysis/types/ping/packet.go index 6325771df3..68193e5153 100644 --- a/plugins/analysis/types/ping/packet.go +++ b/plugins/analysis/types/ping/packet.go @@ -1,12 +1,16 @@ package ping -import "github.com/pkg/errors" +import "errors" + +var ( + ErrMalformedPingPacket = errors.New("malformed ping packet") +) type Packet struct{} func Unmarshal(data []byte) (*Packet, error) { if len(data) < MARSHALED_TOTAL_SIZE || data[MARSHALED_PACKET_HEADER_START] != MARSHALED_PACKET_HEADER { - return nil, errors.New("malformed ping packet") + return nil, ErrMalformedPingPacket } unmarshaledPacket := &Packet{} diff --git a/plugins/analysis/types/removenode/packet.go b/plugins/analysis/types/removenode/packet.go index c44bf94b4b..aeb8903571 100644 --- a/plugins/analysis/types/removenode/packet.go +++ b/plugins/analysis/types/removenode/packet.go @@ -1,6 +1,10 @@ package removenode -import "github.com/pkg/errors" +import "errors" + +var ( + ErrMalformedRemovePacket = errors.New("malformed remove node packet") +) type Packet struct { NodeId []byte @@ -8,7 +12,7 @@ type Packet struct { func Unmarshal(data []byte) (*Packet, error) { if len(data) < MARSHALED_TOTAL_SIZE || data[0] != MARSHALED_PACKET_HEADER { - return nil, errors.New("malformed remove node packet") + return nil, ErrMalformedRemovePacket } unmarshaledPackage := &Packet{ diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index ff21679ca5..f2cac97dd1 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -2,6 +2,7 @@ package autopeering import ( "encoding/base64" + "errors" "fmt" "net" "strings" @@ -17,7 +18,6 @@ import ( "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" - "github.com/pkg/errors" ) var ( @@ -26,6 +26,8 @@ var ( // Selection is the peer selection protocol. Selection *selection.Protocol + ErrParsingMasterNode = errors.New("can't parse master node") + log *logger.Logger ) @@ -111,11 +113,11 @@ func parseEntryNodes() (result []*peer.Peer, err error) { parts := strings.Split(entryNodeDefinition, "@") if len(parts) != 2 { - return nil, fmt.Errorf("parseMaster") + return nil, fmt.Errorf("%w: master node parts must be 2, is %d", ErrParsingMasterNode, len(parts)) } pubKey, err := base64.StdEncoding.DecodeString(parts[0]) if err != nil { - return nil, errors.Wrap(err, "parseMaster") + return nil, fmt.Errorf("%w: can't decode public key: %s", ErrParsingMasterNode, err) } services := service.New() diff --git a/plugins/bundleprocessor/bundleprocessor.go b/plugins/bundleprocessor/bundleprocessor.go index a09fabf2c9..6085e2a97d 100644 --- a/plugins/bundleprocessor/bundleprocessor.go +++ b/plugins/bundleprocessor/bundleprocessor.go @@ -4,7 +4,6 @@ import ( "fmt" "runtime" - "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" "github.com/iotaledger/goshimmer/packages/model/value_transaction" @@ -23,12 +22,12 @@ var workerPool = workerpool.New(func(task workerpool.Task) { var WORKER_COUNT = runtime.NumCPU() -func ProcessSolidBundleHead(headTransaction *value_transaction.ValueTransaction) errors.IdentifiableError { +func ProcessSolidBundleHead(headTransaction *value_transaction.ValueTransaction) error { // only process the bundle if we didn't process it, yet - _, err := tangle.GetBundle(headTransaction.GetHash(), func(headTransactionHash trinary.Trytes) (*bundle.Bundle, errors.IdentifiableError) { + _, err := tangle.GetBundle(headTransaction.GetHash(), func(headTransactionHash trinary.Trytes) (*bundle.Bundle, error) { // abort if bundle syntax is wrong if !headTransaction.IsHead() { - return nil, ErrProcessBundleFailed.Derive(errors.New("invalid parameter"), "transaction needs to be head of bundle") + return nil, fmt.Errorf("%w: transaction needs to be the head of the bundle", ErrProcessBundleFailed) } // initialize event variables @@ -43,17 +42,16 @@ func ProcessSolidBundleHead(headTransaction *value_transaction.ValueTransaction) newBundle.SetTransactionHashes(mapTransactionsToTransactionHashes(bundleTransactions)) Events.InvalidBundle.Trigger(newBundle, bundleTransactions) - - return nil, ErrProcessBundleFailed.Derive(errors.New("invalid bundle found"), "missing bundle tail") + return nil, fmt.Errorf("%w: missing bundle tail", ErrProcessBundleFailed) } // update bundle transactions bundleTransactions = append(bundleTransactions, currentTransaction) // retrieve & update metadata - currentTransactionMetadata, dbErr := tangle.GetTransactionMetadata(currentTransaction.GetHash(), transactionmetadata.New) - if dbErr != nil { - return nil, ErrProcessBundleFailed.Derive(dbErr, "failed to retrieve transaction metadata") + currentTransactionMetadata, err := tangle.GetTransactionMetadata(currentTransaction.GetHash(), transactionmetadata.New) + if err != nil { + return nil, fmt.Errorf("%w: failed to retrieve transaction metadata: %s", ErrProcessBundleFailed, err) } currentTransactionMetadata.SetBundleHeadHash(headTransactionHash) @@ -79,10 +77,11 @@ func ProcessSolidBundleHead(headTransaction *value_transaction.ValueTransaction) // try to iterate to next turn if nextTransaction, err := tangle.GetTransaction(currentTransaction.GetTrunkTransactionHash()); err != nil { - return nil, ErrProcessBundleFailed.Derive(err, "failed to retrieve trunk while processing bundle") + return nil, fmt.Errorf("%w: failed to retrieve trunk while processing bundle: %s", ErrProcessBundleFailed, err) } else if nextTransaction == nil { - fmt.Println(ErrProcessBundleFailed.Derive(errors.New("missing transaction "+currentTransaction.GetTrunkTransactionHash()), "failed to retrieve trunk while processing bundle")) - return nil, ErrProcessBundleFailed.Derive(err, "failed to retrieve trunk while processing bundle") + err := fmt.Errorf("%w: failed to retrieve trunk while processing bundle: missing trunk transaction %s\n", ErrProcessBundleFailed, currentTransaction.GetTrunkTransactionHash()) + fmt.Println(err) + return nil, err } else { currentTransaction = nextTransaction } diff --git a/plugins/bundleprocessor/errors.go b/plugins/bundleprocessor/errors.go index 214b585911..7b488de18a 100644 --- a/plugins/bundleprocessor/errors.go +++ b/plugins/bundleprocessor/errors.go @@ -1,7 +1,7 @@ package bundleprocessor -import "github.com/iotaledger/goshimmer/packages/errors" +import "errors" var ( - ErrProcessBundleFailed = errors.Wrap(errors.New("bundle processing error"), "failed to process bundle") + ErrProcessBundleFailed = errors.New("failed to process bundle") ) diff --git a/plugins/bundleprocessor/events.go b/plugins/bundleprocessor/events.go index 7fcfb2d3e7..46eeaa5ca6 100644 --- a/plugins/bundleprocessor/events.go +++ b/plugins/bundleprocessor/events.go @@ -1,7 +1,6 @@ package bundleprocessor import ( - "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/hive.go/events" @@ -20,7 +19,7 @@ type pluginEvents struct { } func errorCaller(handler interface{}, params ...interface{}) { - handler.(func(errors.IdentifiableError))(params[0].(errors.IdentifiableError)) + handler.(func(error))(params[0].(error)) } func bundleEventCaller(handler interface{}, params ...interface{}) { diff --git a/plugins/bundleprocessor/plugin.go b/plugins/bundleprocessor/plugin.go index 822a2952df..d8a6303dfe 100644 --- a/plugins/bundleprocessor/plugin.go +++ b/plugins/bundleprocessor/plugin.go @@ -1,7 +1,6 @@ package bundleprocessor import ( - "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/tangle" @@ -23,8 +22,8 @@ func configure(*node.Plugin) { } })) - Events.Error.Attach(events.NewClosure(func(err errors.IdentifiableError) { - log.Error(err.Error()) + Events.Error.Attach(events.NewClosure(func(err error) { + log.Error(err) })) } diff --git a/plugins/bundleprocessor/valuebundleprocessor.go b/plugins/bundleprocessor/valuebundleprocessor.go index 1ab5c77928..984c2b244b 100644 --- a/plugins/bundleprocessor/valuebundleprocessor.go +++ b/plugins/bundleprocessor/valuebundleprocessor.go @@ -1,7 +1,6 @@ package bundleprocessor import ( - "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/hive.go/workerpool" @@ -18,7 +17,7 @@ var valueBundleProcessorWorkerPool = workerpool.New(func(task workerpool.Task) { task.Return(nil) }, workerpool.WorkerCount(WORKER_COUNT), workerpool.QueueSize(2*WORKER_COUNT)) -func ProcessSolidValueBundle(bundle *bundle.Bundle, bundleTransactions []*value_transaction.ValueTransaction) errors.IdentifiableError { +func ProcessSolidValueBundle(bundle *bundle.Bundle, bundleTransactions []*value_transaction.ValueTransaction) error { bundle.SetBundleEssenceHash(CalculateBundleHash(bundleTransactions)) Events.BundleSolid.Trigger(bundle, bundleTransactions) diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 0c793d5568..2e53b3364d 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -6,7 +6,6 @@ import ( "strconv" "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" - "github.com/iotaledger/goshimmer/packages/errors" gp "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/gossip/server" "github.com/iotaledger/goshimmer/packages/parameter" @@ -62,7 +61,7 @@ func loadTransaction(hash []byte) ([]byte, error) { tx, err := tangle.GetTransaction(typeutils.BytesToString(hash)) if err != nil { - return nil, errors.Wrap(err, "could not get transaction") + return nil, fmt.Errorf("could not get transaction: %w", err) } if tx == nil { return nil, fmt.Errorf("transaction not found: hash=%s", hash) diff --git a/plugins/tangle/approvers.go b/plugins/tangle/approvers.go index 166b1a7ed0..10073c3943 100644 --- a/plugins/tangle/approvers.go +++ b/plugins/tangle/approvers.go @@ -1,8 +1,9 @@ package tangle import ( + "fmt" + "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/approvers" "github.com/iotaledger/hive.go/lru_cache" "github.com/iotaledger/hive.go/typeutils" @@ -12,7 +13,7 @@ import ( // region global public api //////////////////////////////////////////////////////////////////////////////////////////// // GetApprovers retrieves approvers from the database. -func GetApprovers(transactionHash trinary.Trytes, computeIfAbsent ...func(trinary.Trytes) *approvers.Approvers) (result *approvers.Approvers, err errors.IdentifiableError) { +func GetApprovers(transactionHash trinary.Trytes, computeIfAbsent ...func(trinary.Trytes) *approvers.Approvers) (result *approvers.Approvers, err error) { if cacheResult := approversCache.ComputeIfAbsent(transactionHash, func() interface{} { if dbApprovers, dbErr := getApproversFromDatabase(transactionHash); dbErr != nil { err = dbErr @@ -34,7 +35,7 @@ func GetApprovers(transactionHash trinary.Trytes, computeIfAbsent ...func(trinar return } -func ContainsApprovers(transactionHash trinary.Trytes) (result bool, err errors.IdentifiableError) { +func ContainsApprovers(transactionHash trinary.Trytes) (result bool, err error) { if approversCache.Contains(transactionHash) { result = true } else { @@ -88,10 +89,10 @@ func configureApproversDatabase() { } } -func storeApproversInDatabase(approvers *approvers.Approvers) errors.IdentifiableError { +func storeApproversInDatabase(approvers *approvers.Approvers) error { if approvers.GetModified() { if err := approversDatabase.Set(typeutils.StringToBytes(approvers.GetHash()), approvers.Marshal()); err != nil { - return ErrDatabaseError.Derive(err, "failed to store approvers") + return fmt.Errorf("%w: failed to store approvers: %s", ErrDatabaseError, err) } approvers.SetModified(false) @@ -100,14 +101,13 @@ func storeApproversInDatabase(approvers *approvers.Approvers) errors.Identifiabl return nil } -func getApproversFromDatabase(transactionHash trinary.Trytes) (*approvers.Approvers, errors.IdentifiableError) { +func getApproversFromDatabase(transactionHash trinary.Trytes) (*approvers.Approvers, error) { approversData, err := approversDatabase.Get(typeutils.StringToBytes(transactionHash)) if err != nil { if err == database.ErrKeyNotFound { return nil, nil } - - return nil, ErrDatabaseError.Derive(err, "failed to retrieve approvers") + return nil, fmt.Errorf("%w: failed to retrieve approvers: %s", ErrDatabaseError, err) } var result approvers.Approvers @@ -118,9 +118,9 @@ func getApproversFromDatabase(transactionHash trinary.Trytes) (*approvers.Approv return &result, nil } -func databaseContainsApprovers(transactionHash trinary.Trytes) (bool, errors.IdentifiableError) { +func databaseContainsApprovers(transactionHash trinary.Trytes) (bool, error) { if contains, err := approversDatabase.Contains(typeutils.StringToBytes(transactionHash)); err != nil { - return false, ErrDatabaseError.Derive(err, "failed to check if the approvers exists") + return false, fmt.Errorf("%w: failed to check if the approvers exist: %s", ErrDatabaseError, err) } else { return contains, nil } diff --git a/plugins/tangle/bundle.go b/plugins/tangle/bundle.go index ca7208a932..55411764a2 100644 --- a/plugins/tangle/bundle.go +++ b/plugins/tangle/bundle.go @@ -1,8 +1,9 @@ package tangle import ( + "fmt" + "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/hive.go/lru_cache" "github.com/iotaledger/hive.go/typeutils" @@ -12,7 +13,7 @@ import ( // region global public api //////////////////////////////////////////////////////////////////////////////////////////// // GetBundle retrieves bundle from the database. -func GetBundle(headerTransactionHash trinary.Trytes, computeIfAbsent ...func(trinary.Trytes) (*bundle.Bundle, errors.IdentifiableError)) (result *bundle.Bundle, err errors.IdentifiableError) { +func GetBundle(headerTransactionHash trinary.Trytes, computeIfAbsent ...func(trinary.Trytes) (*bundle.Bundle, error)) (result *bundle.Bundle, err error) { if cacheResult := bundleCache.ComputeIfAbsent(headerTransactionHash, func() interface{} { if dbBundle, dbErr := getBundleFromDatabase(headerTransactionHash); dbErr != nil { err = dbErr @@ -38,7 +39,7 @@ func GetBundle(headerTransactionHash trinary.Trytes, computeIfAbsent ...func(tri return } -func ContainsBundle(headerTransactionHash trinary.Trytes) (result bool, err errors.IdentifiableError) { +func ContainsBundle(headerTransactionHash trinary.Trytes) (result bool, err error) { if bundleCache.Contains(headerTransactionHash) { result = true } else { @@ -92,10 +93,10 @@ func configureBundleDatabase() { } } -func storeBundleInDatabase(bundle *bundle.Bundle) errors.IdentifiableError { +func storeBundleInDatabase(bundle *bundle.Bundle) error { if bundle.GetModified() { if err := bundleDatabase.Set(typeutils.StringToBytes(bundle.GetHash()), bundle.Marshal()); err != nil { - return ErrDatabaseError.Derive(err, "failed to store bundle") + return fmt.Errorf("%w: failed to store bundle: %s", ErrDatabaseError, err) } bundle.SetModified(false) @@ -104,14 +105,14 @@ func storeBundleInDatabase(bundle *bundle.Bundle) errors.IdentifiableError { return nil } -func getBundleFromDatabase(transactionHash trinary.Trytes) (*bundle.Bundle, errors.IdentifiableError) { +func getBundleFromDatabase(transactionHash trinary.Trytes) (*bundle.Bundle, error) { bundleData, err := bundleDatabase.Get(typeutils.StringToBytes(transactionHash)) if err != nil { if err == database.ErrKeyNotFound { return nil, nil } - return nil, ErrDatabaseError.Derive(err, "failed to retrieve bundle") + return nil, fmt.Errorf("%w: failed to retrieve bundle: %s", ErrDatabaseError, err) } var result bundle.Bundle @@ -122,9 +123,9 @@ func getBundleFromDatabase(transactionHash trinary.Trytes) (*bundle.Bundle, erro return &result, nil } -func databaseContainsBundle(transactionHash trinary.Trytes) (bool, errors.IdentifiableError) { +func databaseContainsBundle(transactionHash trinary.Trytes) (bool, error) { if contains, err := bundleDatabase.Contains(typeutils.StringToBytes(transactionHash)); err != nil { - return false, ErrDatabaseError.Derive(err, "failed to check if the bundle exists") + return false, fmt.Errorf("%w: failed to check if the bundle exists: %s", ErrDatabaseError, err) } else { return contains, nil } diff --git a/plugins/tangle/errors.go b/plugins/tangle/errors.go index ffde1bcc9d..5ca8797f9f 100644 --- a/plugins/tangle/errors.go +++ b/plugins/tangle/errors.go @@ -1,9 +1,7 @@ package tangle -import "github.com/iotaledger/goshimmer/packages/errors" +import "errors" var ( - ErrDatabaseError = errors.Wrap(errors.New("database error"), "failed to access the database") - ErrUnmarshalFailed = errors.Wrap(errors.New("unmarshall failed"), "input data is corrupted") - ErrMarshallFailed = errors.Wrap(errors.New("marshal failed"), "the source object contains invalid values") + ErrDatabaseError = errors.New("database error") ) diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index 014a20db15..cfcb3da5f6 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -4,7 +4,6 @@ import ( "runtime" "time" - "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/approvers" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" @@ -69,7 +68,7 @@ func runSolidifier() { // endregion /////////////////////////////////////////////////////////////////////////////////////////////////////////// // Checks and updates the solid flag of a single transaction. -func checkSolidity(transaction *value_transaction.ValueTransaction) (result bool, err errors.IdentifiableError) { +func checkSolidity(transaction *value_transaction.ValueTransaction) (result bool, err error) { // abort if transaction is solid already txMetadata, metaDataErr := GetTransactionMetadata(transaction.GetHash(), transactionmetadata.New) if metaDataErr != nil { @@ -140,7 +139,7 @@ func checkSolidity(transaction *value_transaction.ValueTransaction) (result bool } // Checks and updates the solid flag of a transaction and its approvers (future cone). -func IsSolid(transaction *value_transaction.ValueTransaction) (bool, errors.IdentifiableError) { +func IsSolid(transaction *value_transaction.ValueTransaction) (bool, error) { if isSolid, err := checkSolidity(transaction); err != nil { return false, err } else if isSolid { @@ -154,7 +153,7 @@ func IsSolid(transaction *value_transaction.ValueTransaction) (bool, errors.Iden return false, nil } -func propagateSolidity(transactionHash trinary.Trytes) errors.IdentifiableError { +func propagateSolidity(transactionHash trinary.Trytes) error { if transactionApprovers, err := GetApprovers(transactionHash, approvers.New); err != nil { return err } else { diff --git a/plugins/tangle/transaction.go b/plugins/tangle/transaction.go index 0de47154fd..fc2e2f02dd 100644 --- a/plugins/tangle/transaction.go +++ b/plugins/tangle/transaction.go @@ -1,8 +1,9 @@ package tangle import ( + "fmt" + "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/hive.go/lru_cache" "github.com/iotaledger/hive.go/typeutils" @@ -11,7 +12,7 @@ import ( // region public api /////////////////////////////////////////////////////////////////////////////////////////////////// -func GetTransaction(transactionHash trinary.Trytes, computeIfAbsent ...func(trinary.Trytes) *value_transaction.ValueTransaction) (result *value_transaction.ValueTransaction, err errors.IdentifiableError) { +func GetTransaction(transactionHash trinary.Trytes, computeIfAbsent ...func(trinary.Trytes) *value_transaction.ValueTransaction) (result *value_transaction.ValueTransaction, err error) { if cacheResult := transactionCache.ComputeIfAbsent(transactionHash, func() interface{} { if transaction, dbErr := getTransactionFromDatabase(transactionHash); dbErr != nil { err = dbErr @@ -33,7 +34,7 @@ func GetTransaction(transactionHash trinary.Trytes, computeIfAbsent ...func(trin return } -func ContainsTransaction(transactionHash trinary.Trytes) (result bool, err errors.IdentifiableError) { +func ContainsTransaction(transactionHash trinary.Trytes) (result bool, err error) { if transactionCache.Contains(transactionHash) { result = true } else { @@ -89,10 +90,10 @@ func configureTransactionDatabase() { } } -func storeTransactionInDatabase(transaction *value_transaction.ValueTransaction) errors.IdentifiableError { +func storeTransactionInDatabase(transaction *value_transaction.ValueTransaction) error { if transaction.GetModified() { if err := transactionDatabase.Set(typeutils.StringToBytes(transaction.GetHash()), transaction.MetaTransaction.GetBytes()); err != nil { - return ErrDatabaseError.Derive(err, "failed to store transaction") + return fmt.Errorf("%w: failed to store transaction: %s", ErrDatabaseError, err.Error()) } transaction.SetModified(false) @@ -101,22 +102,21 @@ func storeTransactionInDatabase(transaction *value_transaction.ValueTransaction) return nil } -func getTransactionFromDatabase(transactionHash trinary.Trytes) (*value_transaction.ValueTransaction, errors.IdentifiableError) { +func getTransactionFromDatabase(transactionHash trinary.Trytes) (*value_transaction.ValueTransaction, error) { txData, err := transactionDatabase.Get(typeutils.StringToBytes(transactionHash)) if err != nil { if err == database.ErrKeyNotFound { return nil, nil - } else { - return nil, ErrDatabaseError.Derive(err, "failed to retrieve transaction") } + return nil, fmt.Errorf("%w: failed to retrieve transaction: %s", ErrDatabaseError, err) } return value_transaction.FromBytes(txData), nil } -func databaseContainsTransaction(transactionHash trinary.Trytes) (bool, errors.IdentifiableError) { +func databaseContainsTransaction(transactionHash trinary.Trytes) (bool, error) { if contains, err := transactionDatabase.Contains(typeutils.StringToBytes(transactionHash)); err != nil { - return contains, ErrDatabaseError.Derive(err, "failed to check if the transaction exists") + return contains, fmt.Errorf("%w: failed to check if the transaction exists: %s", ErrDatabaseError, err) } else { return contains, nil } diff --git a/plugins/tangle/transaction_metadata.go b/plugins/tangle/transaction_metadata.go index 0ea3c9828c..94d6177af9 100644 --- a/plugins/tangle/transaction_metadata.go +++ b/plugins/tangle/transaction_metadata.go @@ -1,8 +1,9 @@ package tangle import ( + "fmt" + "github.com/iotaledger/goshimmer/packages/database" - "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/goshimmer/packages/model/transactionmetadata" "github.com/iotaledger/hive.go/lru_cache" "github.com/iotaledger/hive.go/typeutils" @@ -11,7 +12,7 @@ import ( // region public api /////////////////////////////////////////////////////////////////////////////////////////////////// -func GetTransactionMetadata(transactionHash trinary.Trytes, computeIfAbsent ...func(trinary.Trytes) *transactionmetadata.TransactionMetadata) (result *transactionmetadata.TransactionMetadata, err errors.IdentifiableError) { +func GetTransactionMetadata(transactionHash trinary.Trytes, computeIfAbsent ...func(trinary.Trytes) *transactionmetadata.TransactionMetadata) (result *transactionmetadata.TransactionMetadata, err error) { if cacheResult := transactionMetadataCache.ComputeIfAbsent(transactionHash, func() interface{} { if transactionMetadata, dbErr := getTransactionMetadataFromDatabase(transactionHash); dbErr != nil { err = dbErr @@ -33,7 +34,7 @@ func GetTransactionMetadata(transactionHash trinary.Trytes, computeIfAbsent ...f return } -func ContainsTransactionMetadata(transactionHash trinary.Trytes) (result bool, err errors.IdentifiableError) { +func ContainsTransactionMetadata(transactionHash trinary.Trytes) (result bool, err error) { if transactionMetadataCache.Contains(transactionHash) { result = true } else { @@ -89,13 +90,13 @@ func configureTransactionMetaDataDatabase() { } } -func storeTransactionMetadataInDatabase(metadata *transactionmetadata.TransactionMetadata) errors.IdentifiableError { +func storeTransactionMetadataInDatabase(metadata *transactionmetadata.TransactionMetadata) error { if metadata.GetModified() { if marshaledMetadata, err := metadata.Marshal(); err != nil { return err } else { if err := transactionMetadataDatabase.Set(typeutils.StringToBytes(metadata.GetHash()), marshaledMetadata); err != nil { - return ErrDatabaseError.Derive(err, "failed to store transaction metadata") + return fmt.Errorf("%w: failed to store transaction metadata: %s", ErrDatabaseError, err) } metadata.SetModified(false) @@ -105,14 +106,13 @@ func storeTransactionMetadataInDatabase(metadata *transactionmetadata.Transactio return nil } -func getTransactionMetadataFromDatabase(transactionHash trinary.Trytes) (*transactionmetadata.TransactionMetadata, errors.IdentifiableError) { +func getTransactionMetadataFromDatabase(transactionHash trinary.Trytes) (*transactionmetadata.TransactionMetadata, error) { txMetadata, err := transactionMetadataDatabase.Get(typeutils.StringToBytes(transactionHash)) if err != nil { if err == database.ErrKeyNotFound { return nil, nil - } else { - return nil, ErrDatabaseError.Derive(err, "failed to retrieve transaction") } + return nil, fmt.Errorf("%w: failed to retrieve transaction: %s", ErrDatabaseError, err) } var result transactionmetadata.TransactionMetadata @@ -123,9 +123,9 @@ func getTransactionMetadataFromDatabase(transactionHash trinary.Trytes) (*transa return &result, nil } -func databaseContainsTransactionMetadata(transactionHash trinary.Trytes) (bool, errors.IdentifiableError) { +func databaseContainsTransactionMetadata(transactionHash trinary.Trytes) (bool, error) { if contains, err := transactionMetadataDatabase.Contains(typeutils.StringToBytes(transactionHash)); err != nil { - return contains, ErrDatabaseError.Derive(err, "failed to check if the transaction metadata exists") + return contains, fmt.Errorf("%w: failed to check if the transaction metadata exists: %s", ErrDatabaseError, err) } else { return contains, nil } diff --git a/plugins/tangle/tx_per_address.go b/plugins/tangle/tx_per_address.go index c6bb03cdce..1ab4950e6c 100644 --- a/plugins/tangle/tx_per_address.go +++ b/plugins/tangle/tx_per_address.go @@ -1,6 +1,8 @@ package tangle import ( + "fmt" + "github.com/iotaledger/goshimmer/packages/database" "github.com/iotaledger/hive.go/typeutils" "github.com/iotaledger/iota.go/trinary" @@ -28,7 +30,7 @@ func StoreTransactionHashForAddressInDatabase(address *TxHashForAddress) error { databaseKeyForHashPrefixedHash(address.Address, address.TxHash), []byte{}, ); err != nil { - return ErrDatabaseError.Derive(err, "failed to store tx for address in database") + return fmt.Errorf("%w: failed to store tx for address in database: %s", ErrDatabaseError, err) } return nil } @@ -37,7 +39,7 @@ func DeleteTransactionHashForAddressInDatabase(address *TxHashForAddress) error if err := transactionsHashesForAddressDatabase.Delete( databaseKeyForHashPrefixedHash(address.Address, address.TxHash), ); err != nil { - return ErrDatabaseError.Derive(err, "failed to delete tx for address") + return fmt.Errorf("%w: failed to delete tx for address: %s", ErrDatabaseError, err) } return nil @@ -53,8 +55,7 @@ func ReadTransactionHashesForAddressFromDatabase(address trinary.Hash) ([]trinar }) if err != nil { - return nil, ErrDatabaseError.Derive(err, "failed to read tx per address from database") - } else { - return transactionHashes, nil + return nil, fmt.Errorf("%w: failed to read tx per address from database: %s", ErrDatabaseError, err) } + return transactionHashes, nil } From f4a9646ae849731c7d1ef18600204c27aff15699 Mon Sep 17 00:00:00 2001 From: Angelo Capossele Date: Mon, 20 Jan 2020 14:57:55 +0000 Subject: [PATCH 120/184] :sparkles: adds open port check (#143) * :sparkles: adds open port check * Use gossip.server to check port * Use same messages in gossip and autopeering * Give correct error message when unreachable Co-authored-by: Wolfgang Welz --- packages/autopeering/discover/manager.go | 4 +-- packages/autopeering/discover/manager_test.go | 12 +++---- packages/autopeering/discover/protocol.go | 2 +- .../autopeering/discover/protocol_test.go | 14 ++++---- plugins/autopeering/autopeering.go | 26 +++++++++++--- plugins/gossip/gossip.go | 36 +++++++++++++++++-- 6 files changed, 71 insertions(+), 23 deletions(-) diff --git a/packages/autopeering/discover/manager.go b/packages/autopeering/discover/manager.go index 055dd9bb02..5fbded485b 100644 --- a/packages/autopeering/discover/manager.go +++ b/packages/autopeering/discover/manager.go @@ -25,7 +25,7 @@ const ( type network interface { local() *peer.Local - ping(*peer.Peer) error + Ping(*peer.Peer) error discoveryRequest(*peer.Peer) ([]*peer.Peer, error) } @@ -139,7 +139,7 @@ func (m *manager) doReverify(done chan<- struct{}) { var err error for i := 0; i < reverifyTries; i++ { - err = m.net.ping(unwrapPeer(p)) + err = m.net.Ping(unwrapPeer(p)) if err == nil { break } else { diff --git a/packages/autopeering/discover/manager_test.go b/packages/autopeering/discover/manager_test.go index fba880e418..0903712324 100644 --- a/packages/autopeering/discover/manager_test.go +++ b/packages/autopeering/discover/manager_test.go @@ -22,7 +22,7 @@ func (m *NetworkMock) local() *peer.Local { return m.loc } -func (m *NetworkMock) ping(p *peer.Peer) error { +func (m *NetworkMock) Ping(p *peer.Peer) error { args := m.Called(p) return args.Error(0) } @@ -70,7 +70,7 @@ func TestMgrVerifyDiscoveredPeer(t *testing.T) { p := newDummyPeer("p") // expect ping of peer p - m.On("ping", p).Return(nil).Once() + m.On("Ping", p).Return(nil).Once() // ignore discoveryRequest calls m.On("discoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() @@ -90,7 +90,7 @@ func TestMgrReverifyPeer(t *testing.T) { p := newDummyPeer("p") // expect ping of peer p - m.On("ping", p).Return(nil).Once() + m.On("Ping", p).Return(nil).Once() // ignore discoveryRequest calls m.On("discoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() @@ -113,7 +113,7 @@ func TestMgrRequestDiscoveredPeer(t *testing.T) { // expect discoveryRequest on the discovered peer m.On("discoveryRequest", p1).Return([]*peer.Peer{p2}, nil).Once() // ignore any ping - m.On("ping", mock.Anything).Return(nil).Maybe() + m.On("Ping", mock.Anything).Return(nil).Maybe() mgr.addVerifiedPeer(p1) mgr.addDiscoveredPeer(p2) @@ -129,7 +129,7 @@ func TestMgrAddManyVerifiedPeers(t *testing.T) { p := newDummyPeer("p") // expect ping of peer p - m.On("ping", p).Return(nil).Once() + m.On("Ping", p).Return(nil).Once() // ignore discoveryRequest calls m.On("discoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() @@ -157,7 +157,7 @@ func TestMgrDeleteUnreachablePeer(t *testing.T) { p := newDummyPeer("p") // expect ping of peer p, but return error - m.On("ping", p).Return(server.ErrTimeout).Times(reverifyTries) + m.On("Ping", p).Return(server.ErrTimeout).Times(reverifyTries) // ignore discoveryRequest calls m.On("discoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() diff --git a/packages/autopeering/discover/protocol.go b/packages/autopeering/discover/protocol.go index 756f5fe1c2..3cbe49361e 100644 --- a/packages/autopeering/discover/protocol.go +++ b/packages/autopeering/discover/protocol.go @@ -149,7 +149,7 @@ func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer. // ------ message senders ------ // ping sends a ping to the specified peer and blocks until a reply is received or timeout. -func (p *Protocol) ping(to *peer.Peer) error { +func (p *Protocol) Ping(to *peer.Peer) error { return <-p.sendPing(to.Address(), to.ID()) } diff --git a/packages/autopeering/discover/protocol_test.go b/packages/autopeering/discover/protocol_test.go index 223c2c3ef1..e262865122 100644 --- a/packages/autopeering/discover/protocol_test.go +++ b/packages/autopeering/discover/protocol_test.go @@ -89,11 +89,11 @@ func TestProtPingPong(t *testing.T) { peerB := getPeer(srvB) // send a ping from node A to B - t.Run("A->B", func(t *testing.T) { assert.NoError(t, protA.ping(peerB)) }) + t.Run("A->B", func(t *testing.T) { assert.NoError(t, protA.Ping(peerB)) }) time.Sleep(graceTime) // send a ping from node B to A - t.Run("B->A", func(t *testing.T) { assert.NoError(t, protB.ping(peerA)) }) + t.Run("B->A", func(t *testing.T) { assert.NoError(t, protB.Ping(peerA)) }) time.Sleep(graceTime) } @@ -109,7 +109,7 @@ func TestProtPingTimeout(t *testing.T) { peerB := getPeer(srvB) // send a ping from node A to B - err := protA.ping(peerB) + err := protA.Ping(peerB) assert.EqualError(t, err, server.ErrTimeout.Error()) } @@ -125,7 +125,7 @@ func TestProtVerifiedPeers(t *testing.T) { peerB := getPeer(srvB) // send a ping from node A to B - assert.NoError(t, protA.ping(peerB)) + assert.NoError(t, protA.Ping(peerB)) time.Sleep(graceTime) // protA should have peerB as the single verified peer @@ -148,7 +148,7 @@ func TestProtVerifiedPeer(t *testing.T) { peerB := getPeer(srvB) // send a ping from node A to B - assert.NoError(t, protA.ping(peerB)) + assert.NoError(t, protA.Ping(peerB)) time.Sleep(graceTime) // we should have peerB as a verified peer @@ -248,14 +248,14 @@ func BenchmarkPingPong(b *testing.B) { peerB := getPeer(srvB) // send initial ping to ensure that every peer is verified - err := protA.ping(peerB) + err := protA.Ping(peerB) require.NoError(b, err) time.Sleep(graceTime) b.ResetTimer() for n := 0; n < b.N; n++ { // send a ping from node A to B - _ = protA.ping(peerB) + _ = protA.Ping(peerB) } b.StopTimer() diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index f2cac97dd1..33fb047aa5 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -15,6 +15,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/transport" "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/goshimmer/plugins/cli" "github.com/iotaledger/goshimmer/plugins/gossip" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" @@ -53,7 +54,7 @@ func configureAP() { } func start(shutdownSignal <-chan struct{}) { - defer log.Info("Stopping Auto Peering server ... done") + defer log.Info("Stopping " + name + " ... done") addr := local.GetInstance().Services().Get(service.PeeringKey) udpAddr, err := net.ResolveUDPAddr(addr.Network(), addr.String()) @@ -92,17 +93,22 @@ func start(shutdownSignal <-chan struct{}) { Discovery.Start(srv) defer Discovery.Close() + //check that discovery is working and the port is open + log.Info("Testing service ...") + checkConnection(srv, &local.GetInstance().Peer) + log.Info("Testing service ... done") + if Selection != nil { // start the peering on that connection Selection.Start(srv) defer Selection.Close() } - log.Infof("Auto Peering started: address=%s", srv.LocalAddr()) - log.Debugf("Auto Peering server started: PubKey=%s", base64.StdEncoding.EncodeToString(local.GetInstance().PublicKey())) + log.Infof(name+" started: address=%s/udp", srv.LocalAddr()) + log.Debugf(name+" server started: PubKey=%s", base64.StdEncoding.EncodeToString(local.GetInstance().PublicKey())) <-shutdownSignal - log.Info("Stopping Auto Peering server ...") + log.Info("Stopping " + name + " ...") } func parseEntryNodes() (result []*peer.Peer, err error) { @@ -128,3 +134,15 @@ func parseEntryNodes() (result []*peer.Peer, err error) { return result, nil } + +func checkConnection(srv *server.Server, self *peer.Peer) { + if err := Discovery.Ping(self); err != nil { + if err == server.ErrTimeout { + log.Errorf("Error testing service: %s", err) + addr := self.Services().Get(service.PeeringKey) + log.Panicf("Please check that %s is publicly reachable at %s/%s", + cli.AppName, addr.String(), addr.Network()) + } + log.Panicf("Error: %s", err) + } +} diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 2e53b3364d..b6ea302a75 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -4,12 +4,15 @@ import ( "fmt" "net" "strconv" + "sync" + "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" gp "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/gossip/server" "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/autopeering/local" + "github.com/iotaledger/goshimmer/plugins/cli" "github.com/iotaledger/goshimmer/plugins/tangle" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/typeutils" @@ -39,7 +42,7 @@ func configureGossip() { } func start(shutdownSignal <-chan struct{}) { - defer log.Info("Stopping Gossip ... done") + defer log.Info("Stopping " + name + " ... done") srv, err := server.ListenTCP(local.GetInstance(), log) if err != nil { @@ -47,13 +50,40 @@ func start(shutdownSignal <-chan struct{}) { } defer srv.Close() + //check that the server is working and the port is open + log.Info("Testing service ...") + checkConnection(srv, &local.GetInstance().Peer) + log.Info("Testing service ... done") + mgr.Start(srv) defer mgr.Close() - log.Infof("Gossip started: address=%v", mgr.LocalAddr()) + log.Infof(name+" started: address=%s/%s", mgr.LocalAddr().String(), mgr.LocalAddr().Network()) <-shutdownSignal - log.Info("Stopping Gossip ...") + log.Info("Stopping " + name + " ...") +} + +func checkConnection(srv *server.TCP, self *peer.Peer) { + var wg sync.WaitGroup + wg.Add(1) + go func() { + defer wg.Done() + conn, err := srv.AcceptPeer(self) + if err != nil { + return + } + _ = conn.Close() + }() + conn, err := srv.DialPeer(self) + if err != nil { + log.Errorf("Error testing: %s", err) + addr := self.Services().Get(service.GossipKey) + log.Panicf("Please check that %s is publicly reachable at %s/%s", + cli.AppName, addr.String(), addr.Network()) + } + _ = conn.Close() + wg.Wait() } func loadTransaction(hash []byte) ([]byte, error) { From 262d7d8c4764bb43c5c421d8e31b9a35ccec4eb4 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Tue, 21 Jan 2020 20:43:25 +0100 Subject: [PATCH 121/184] Feat: Use backoff to retry sends (#153) --- packages/autopeering/discover/common.go | 8 ---- packages/autopeering/discover/manager.go | 26 ++++++------- packages/autopeering/discover/manager_test.go | 2 +- .../autopeering/discover/protocol_test.go | 1 - packages/autopeering/discover/query_strat.go | 19 ++++++++-- packages/gossip/server/server.go | 37 +++++++++++++------ 6 files changed, 55 insertions(+), 38 deletions(-) diff --git a/packages/autopeering/discover/common.go b/packages/autopeering/discover/common.go index 826ad2cd12..99b092ea1e 100644 --- a/packages/autopeering/discover/common.go +++ b/packages/autopeering/discover/common.go @@ -10,7 +10,6 @@ import ( // Default values for the global parameters const ( DefaultReverifyInterval = 10 * time.Second - DefaultReverifyTries = 2 DefaultQueryInterval = 60 * time.Second DefaultMaxManaged = 1000 DefaultMaxReplacements = 10 @@ -18,7 +17,6 @@ const ( var ( reverifyInterval = DefaultReverifyInterval // time interval after which the next peer is reverified - reverifyTries = DefaultReverifyTries // number of times a peer is pinged before it is removed queryInterval = DefaultQueryInterval // time interval after which peers are queried for new peers maxManaged = DefaultMaxManaged // maximum number of peers that can be managed maxReplacements = DefaultMaxReplacements // maximum number of peers kept in the replacement list @@ -36,7 +34,6 @@ type Config struct { // Parameters holds the parameters that can be configured. type Parameters struct { ReverifyInterval time.Duration // time interval after which the next peer is reverified - ReverifyTries int // number of times a peer is pinged before it is removed QueryInterval time.Duration // time interval after which peers are queried for new peers MaxManaged int // maximum number of peers that can be managed MaxReplacements int // maximum number of peers kept in the replacement list @@ -50,11 +47,6 @@ func SetParameter(param Parameters) { } else { reverifyInterval = DefaultReverifyInterval } - if param.ReverifyTries > 0 { - reverifyTries = param.ReverifyTries - } else { - reverifyTries = DefaultReverifyTries - } if param.QueryInterval > 0 { queryInterval = param.QueryInterval } else { diff --git a/packages/autopeering/discover/manager.go b/packages/autopeering/discover/manager.go index 5fbded485b..974b976a6f 100644 --- a/packages/autopeering/discover/manager.go +++ b/packages/autopeering/discover/manager.go @@ -7,6 +7,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/server" + "github.com/iotaledger/hive.go/backoff" "github.com/iotaledger/hive.go/logger" ) @@ -17,11 +18,17 @@ const ( MaxPeersInResponse = 6 // MaxServices is the maximum number of services a peer can support. MaxServices = 5 + // NetworkMaxRetries is the maximum number of times a failing network send is retried. + NetworkMaxRetries = 2 // VersionNum specifies the expected version number for this Protocol. VersionNum = 0 ) +// policy for retrying failed network calls +var networkRetryPolicy = backoff.ExponentialBackOff(500*time.Millisecond, 1.5).With( + backoff.Jitter(0.5), backoff.MaxRetries(NetworkMaxRetries)) + type network interface { local() *peer.Local @@ -137,20 +144,13 @@ func (m *manager) doReverify(done chan<- struct{}) { "addr", p.Address(), ) - var err error - for i := 0; i < reverifyTries; i++ { - err = m.net.Ping(unwrapPeer(p)) - if err == nil { - break - } else { - m.log.Debugw("ping failed", - "id", p.ID(), - "addr", p.Address(), - "err", err, - ) - time.Sleep(1 * time.Second) + err := backoff.Retry(networkRetryPolicy, func() error { + err := m.net.Ping(unwrapPeer(p)) + if err != nil && err != server.ErrTimeout { + return backoff.Permanent(err) } - } + return err + }) // could not verify the peer if err != nil { diff --git a/packages/autopeering/discover/manager_test.go b/packages/autopeering/discover/manager_test.go index 0903712324..07a35889bc 100644 --- a/packages/autopeering/discover/manager_test.go +++ b/packages/autopeering/discover/manager_test.go @@ -157,7 +157,7 @@ func TestMgrDeleteUnreachablePeer(t *testing.T) { p := newDummyPeer("p") // expect ping of peer p, but return error - m.On("Ping", p).Return(server.ErrTimeout).Times(reverifyTries) + m.On("Ping", p).Return(server.ErrTimeout).Times(NetworkMaxRetries + 1) // ignore discoveryRequest calls m.On("discoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() diff --git a/packages/autopeering/discover/protocol_test.go b/packages/autopeering/discover/protocol_test.go index e262865122..7a98bec242 100644 --- a/packages/autopeering/discover/protocol_test.go +++ b/packages/autopeering/discover/protocol_test.go @@ -22,7 +22,6 @@ func init() { // decrease parameters to simplify and speed up tests SetParameter(Parameters{ ReverifyInterval: 500 * time.Millisecond, - ReverifyTries: 1, QueryInterval: 1000 * time.Millisecond, MaxManaged: 10, MaxReplacements: 2, diff --git a/packages/autopeering/discover/query_strat.go b/packages/autopeering/discover/query_strat.go index 8095473551..80247c54e4 100644 --- a/packages/autopeering/discover/query_strat.go +++ b/packages/autopeering/discover/query_strat.go @@ -5,6 +5,10 @@ import ( "math/rand" "sync" "time" + + "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/server" + "github.com/iotaledger/hive.go/backoff" ) // doQuery is the main method of the query strategy. @@ -34,8 +38,17 @@ func (m *manager) doQuery(next chan<- time.Duration) { func (m *manager) requestWorker(p *mpeer, wg *sync.WaitGroup) { defer wg.Done() - r, err := m.net.discoveryRequest(unwrapPeer(p)) - if err != nil || len(r) == 0 { + var peers []*peer.Peer + err := backoff.Retry(networkRetryPolicy, func() error { + var err error + peers, err = m.net.discoveryRequest(unwrapPeer(p)) + if err != nil && err != server.ErrTimeout { + return backoff.Permanent(err) + } + return err + }) + + if err != nil || len(peers) == 0 { p.lastNewPeers = 0 m.log.Debugw("query failed", @@ -47,7 +60,7 @@ func (m *manager) requestWorker(p *mpeer, wg *sync.WaitGroup) { } var added uint - for _, rp := range r { + for _, rp := range peers { if m.addDiscoveredPeer(rp) { added++ } diff --git a/packages/gossip/server/server.go b/packages/gossip/server/server.go index 8cbab0e37c..f6fd2f8b8c 100644 --- a/packages/gossip/server/server.go +++ b/packages/gossip/server/server.go @@ -15,6 +15,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" pb "github.com/iotaledger/goshimmer/packages/autopeering/server/proto" + "github.com/iotaledger/hive.go/backoff" "go.uber.org/zap" ) @@ -31,13 +32,17 @@ var ( // connection timeouts const ( - acceptTimeout = 1000 * time.Millisecond - handshakeTimeout = 500 * time.Millisecond - connectionTimeout = acceptTimeout + handshakeTimeout + dialTimeout = 1 * time.Second // timeout for net.Dial + handshakeTimeout = 500 * time.Millisecond // read/write timeout of the handshake packages + acceptTimeout = 3 * time.Second // timeout to accept incoming connections + connectionTimeout = acceptTimeout + 2*handshakeTimeout // timeout after which the connection must be established maxHandshakePacketSize = 256 ) +// retry net.Dial once, on fail after 0.5s +var dialRetryPolicy = backoff.ConstantBackOff(500 * time.Millisecond).With(backoff.MaxRetries(1)) + // TCP establishes verified incoming and outgoing TCP connections to other peers. type TCP struct { local *peer.Local @@ -139,14 +144,20 @@ func (t *TCP) DialPeer(p *peer.Peer) (net.Conn, error) { return nil, ErrNoGossip } - conn, err := net.DialTimeout(gossipAddr.Network(), gossipAddr.String(), acceptTimeout) - if err != nil { - return nil, fmt.Errorf("dial peer failed: %w", err) - } + var conn net.Conn + if err := backoff.Retry(dialRetryPolicy, func() error { + var err error + conn, err = net.DialTimeout(gossipAddr.Network(), gossipAddr.String(), dialTimeout) + if err != nil { + return fmt.Errorf("dial %s / %s failed: %w", gossipAddr.String(), p.ID(), err) + } - err = t.doHandshake(p.PublicKey(), gossipAddr.String(), conn) - if err != nil { - return nil, fmt.Errorf("outgoing handshake failed: %w", err) + if err = t.doHandshake(p.PublicKey(), gossipAddr.String(), conn); err != nil { + return fmt.Errorf("handshake %s / %s failed: %w", gossipAddr.String(), p.ID(), err) + } + return nil + }); err != nil { + return nil, err } t.log.Debugw("outgoing connection established", @@ -159,14 +170,15 @@ func (t *TCP) DialPeer(p *peer.Peer) (net.Conn, error) { // AcceptPeer awaits an incoming connection from the given peer. // If the peer does not establish the connection or the handshake fails, an error is returned. func (t *TCP) AcceptPeer(p *peer.Peer) (net.Conn, error) { - if p.Services().Get(service.GossipKey) == nil { + gossipAddr := p.Services().Get(service.GossipKey) + if gossipAddr == nil { return nil, ErrNoGossip } // wait for the connection connected := <-t.acceptPeer(p) if connected.err != nil { - return nil, fmt.Errorf("accept peer failed: %w", connected.err) + return nil, fmt.Errorf("accept %s / %s failed: %w", gossipAddr.String(), p.ID(), connected.err) } t.log.Debugw("incoming connection established", @@ -248,6 +260,7 @@ func (t *TCP) run() { for e := matcherList.Front(); e != nil; e = e.Next() { m := e.Value.(*acceptMatcher) if now.After(m.deadline) || now.Equal(m.deadline) { + t.log.Debugw("accept timeout", "id", m.peer.ID()) m.connected <- connect{nil, ErrTimeout} matcherList.Remove(e) } From 8b3d0c77cf1291672935eade431dabad6a4e9532 Mon Sep 17 00:00:00 2001 From: jkrvivian Date: Wed, 22 Jan 2020 16:08:10 +0800 Subject: [PATCH 122/184] :bug: Get correct plugin names by removing spaces (#157) --- plugins/cli/plugin.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/cli/plugin.go b/plugins/cli/plugin.go index 03bbc6faf2..0b1937b55e 100644 --- a/plugins/cli/plugin.go +++ b/plugins/cli/plugin.go @@ -2,7 +2,6 @@ package cli import ( "fmt" - "strings" "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/hive.go/events" @@ -37,10 +36,10 @@ func init() { func parseParameters() { for _, pluginName := range parameter.NodeConfig.GetStringSlice(node.CFG_DISABLE_PLUGINS) { - node.DisabledPlugins[strings.ToLower(pluginName)] = true + node.DisabledPlugins[node.GetPluginIdentifier(pluginName)] = true } for _, pluginName := range parameter.NodeConfig.GetStringSlice(node.CFG_ENABLE_PLUGINS) { - node.EnabledPlugins[strings.ToLower(pluginName)] = true + node.EnabledPlugins[node.GetPluginIdentifier(pluginName)] = true } } From e0fc94a5f41fe6e29a380fc968519b3c618c1772 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 22 Jan 2020 09:09:46 +0100 Subject: [PATCH 123/184] Feat: Add netutil package (#159) * feat: add netutil package * use IsTemporaryError * remove unused import --- packages/autopeering/server/server.go | 4 +- packages/gossip/neighbor.go | 6 +- packages/gossip/server/server.go | 6 +- packages/netutil/netutil.go | 104 ++++++++++++++++++++++++++ packages/netutil/netutil_test.go | 71 ++++++++++++++++++ plugins/autopeering/local/local.go | 37 +-------- 6 files changed, 187 insertions(+), 41 deletions(-) create mode 100644 packages/netutil/netutil.go create mode 100644 packages/netutil/netutil_test.go diff --git a/packages/autopeering/server/server.go b/packages/autopeering/server/server.go index bd3d65da13..74d1bfbda4 100644 --- a/packages/autopeering/server/server.go +++ b/packages/autopeering/server/server.go @@ -4,7 +4,6 @@ import ( "container/list" "fmt" "io" - "net" "sync" "time" @@ -12,6 +11,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer" pb "github.com/iotaledger/goshimmer/packages/autopeering/server/proto" "github.com/iotaledger/goshimmer/packages/autopeering/transport" + "github.com/iotaledger/goshimmer/packages/netutil" "github.com/iotaledger/hive.go/logger" ) @@ -260,7 +260,7 @@ func (s *Server) readLoop() { for { b, fromAddr, err := s.trans.ReadFrom() - if nerr, ok := err.(net.Error); ok && nerr.Temporary() { + if netutil.IsTemporaryError(err) { // ignore temporary read errors. s.log.Debugw("temporary read error", "err", err) continue diff --git a/packages/gossip/neighbor.go b/packages/gossip/neighbor.go index 178105a497..6fa7566fb6 100644 --- a/packages/gossip/neighbor.go +++ b/packages/gossip/neighbor.go @@ -8,6 +8,7 @@ import ( "sync" "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/netutil" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/network" ) @@ -114,11 +115,12 @@ func (n *Neighbor) readLoop() { for { _, err := n.ManagedConnection.Read(b) - if nerr, ok := err.(net.Error); ok && nerr.Temporary() { + if netutil.IsTemporaryError(err) { // ignore temporary read errors. n.log.Debugw("temporary read error", "err", err) continue - } else if err != nil { + } + if err != nil { // return from the loop on all other errors if err != io.EOF && !strings.Contains(err.Error(), "use of closed network connection") { n.log.Warnw("read error", "err", err) diff --git a/packages/gossip/server/server.go b/packages/gossip/server/server.go index f6fd2f8b8c..bb52798c93 100644 --- a/packages/gossip/server/server.go +++ b/packages/gossip/server/server.go @@ -15,6 +15,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" pb "github.com/iotaledger/goshimmer/packages/autopeering/server/proto" + "github.com/iotaledger/goshimmer/packages/netutil" "github.com/iotaledger/hive.go/backoff" "go.uber.org/zap" ) @@ -294,10 +295,11 @@ func (t *TCP) listenLoop() { for { conn, err := t.listener.AcceptTCP() - if err, ok := err.(net.Error); ok && err.Temporary() { + if netutil.IsTemporaryError(err) { t.log.Debugw("temporary read error", "err", err) continue - } else if err != nil { + } + if err != nil { // return from the loop on all other errors if err != io.EOF && !strings.Contains(err.Error(), "use of closed network connection") { t.log.Warnw("listen error", "err", err) diff --git a/packages/netutil/netutil.go b/packages/netutil/netutil.go new file mode 100644 index 0000000000..b1137f562a --- /dev/null +++ b/packages/netutil/netutil.go @@ -0,0 +1,104 @@ +// Package netutil provides utility functions extending the stdnet package. +package netutil + +import ( + "bytes" + "encoding/binary" + "errors" + "fmt" + "io/ioutil" + "math/rand" + "net" + "net/http" + "time" +) + +var ( + errInvalidData = errors.New("invalid data received") +) + +// IsIPv4 returns true if ip is an IPv4 address. +func IsIPv4(ip net.IP) bool { + return ip.To4() != nil +} + +// GetPublicIP queries the ipify API for the public IP address. +func GetPublicIP(preferIPv6 bool) (net.IP, error) { + var url string + if preferIPv6 { + url = "https://api6.ipify.org" + } else { + url = "https://api.ipify.org" + } + resp, err := http.Get(url) + if err != nil { + return nil, fmt.Errorf("get failed: %w", err) + } + defer resp.Body.Close() + + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return nil, fmt.Errorf("read failed: %w", err) + } + + // the body only consists of the ip address + ip := net.ParseIP(string(body)) + if ip == nil { + return nil, fmt.Errorf("not an IP: %s", body) + } + return ip, nil +} + +// IsTemporaryError checks whether the given error should be considered temporary. +func IsTemporaryError(err error) bool { + tempErr, ok := err.(interface { + Temporary() bool + }) + return ok && tempErr.Temporary() +} + +// CheckUDP checks whether data send to remote is received at local, otherwise an error is returned. +// If checkAddress is set, it checks whether the IP address that was on the packet matches remote. +// If checkPort is set, it checks whether the port that was on the packet matches remote. +func CheckUDP(local, remote *net.UDPAddr, checkAddress bool, checkPort bool) error { + conn, err := net.ListenUDP("udp", local) + if err != nil { + return fmt.Errorf("listen failed: %w", err) + } + defer conn.Close() + + nonce := generateNonce() + _, err = conn.WriteTo(nonce, remote) + if err != nil { + return fmt.Errorf("write failed: %w", err) + } + + err = conn.SetReadDeadline(time.Now().Add(2 * time.Second)) + if err != nil { + return fmt.Errorf("set timeout failed: %w", err) + } + + p := make([]byte, len(nonce)+1) + n, from, err := conn.ReadFrom(p) + if err != nil { + return fmt.Errorf("read failed: %w", err) + } + if n != len(nonce) || !bytes.Equal(p[:n], nonce) { + return errInvalidData + } + udpAddr := from.(*net.UDPAddr) + if checkAddress && udpAddr.IP.Equal(remote.IP) { + return fmt.Errorf("IP changed: %s", udpAddr.IP) + } + if checkPort && udpAddr.Port != remote.Port { + return fmt.Errorf("port changed: %d", udpAddr.Port) + } + + return nil +} + +func generateNonce() []byte { + b := make([]byte, 8) + binary.BigEndian.PutUint64(b, rand.Uint64()) + return b +} diff --git a/packages/netutil/netutil_test.go b/packages/netutil/netutil_test.go new file mode 100644 index 0000000000..f5543f8db0 --- /dev/null +++ b/packages/netutil/netutil_test.go @@ -0,0 +1,71 @@ +package netutil + +import ( + "errors" + "fmt" + "net" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestIsIPv4(t *testing.T) { + tests := []struct { + in net.IP + out bool + }{ + {nil, false}, + {net.IPv4zero, true}, + {net.IPv6zero, false}, + {net.ParseIP("127.0.0.1"), true}, + {net.IPv6loopback, false}, + {net.ParseIP("8.8.8.8"), true}, + {net.ParseIP("2001:4860:4860::8888"), false}, + } + for _, tt := range tests { + t.Run(fmt.Sprintf("%v", tt.in), func(t *testing.T) { + assert.Equal(t, IsIPv4(tt.in), tt.out) + }) + } +} + +func TestIsTemporaryError(t *testing.T) { + tests := []struct { + in error + out bool + }{ + {nil, false}, + {errors.New("errorString"), false}, + } + for _, tt := range tests { + t.Run(fmt.Sprintf("%v", tt.in), func(t *testing.T) { + assert.Equal(t, IsTemporaryError(tt.in), tt.out) + }) + } +} + +func TestCheckUDP(t *testing.T) { + local, err := getLocalUDPAddr() + require.NoError(t, err) + assert.NoError(t, CheckUDP(local, local, true, true)) + + invalid := &net.UDPAddr{ + IP: local.IP, + Port: local.Port - 1, + Zone: local.Zone, + } + assert.Error(t, CheckUDP(local, invalid, false, false)) +} + +func getLocalUDPAddr() (*net.UDPAddr, error) { + addr, err := net.ResolveUDPAddr("udp", ":0") + if err != nil { + return nil, err + } + conn, err := net.ListenUDP("udp", addr) + if err != nil { + return nil, err + } + return conn.LocalAddr().(*net.UDPAddr), conn.Close() +} diff --git a/plugins/autopeering/local/local.go b/plugins/autopeering/local/local.go index ac43be56d9..c5ca19a110 100644 --- a/plugins/autopeering/local/local.go +++ b/plugins/autopeering/local/local.go @@ -3,14 +3,12 @@ package local import ( "crypto/ed25519" "encoding/base64" - "fmt" - "io/ioutil" "net" - "net/http" "strconv" "sync" "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/netutil" "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/hive.go/logger" ) @@ -29,7 +27,7 @@ func configureLocal() *peer.Local { } if ip.IsUnspecified() { log.Info("Querying public IP ...") - myIp, err := getPublicIP(isIPv4(ip)) + myIp, err := netutil.GetPublicIP(!netutil.IsIPv4(ip)) if err != nil { log.Fatalf("Error querying public IP: %s", err) } @@ -69,37 +67,6 @@ func configureLocal() *peer.Local { return local } -func isIPv4(ip net.IP) bool { - return ip.To4() != nil -} - -func getPublicIP(ipv4 bool) (net.IP, error) { - var url string - if ipv4 { - url = "https://api.ipify.org" - } else { - url = "https://api6.ipify.org" - } - resp, err := http.Get(url) - if err != nil { - return nil, err - } - defer resp.Body.Close() - - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } - - // the body only consists of the ip address - ip := net.ParseIP(string(body)) - if ip == nil { - return nil, fmt.Errorf("not an IP: %s", body) - } - - return ip, nil -} - func GetInstance() *peer.Local { once.Do(func() { instance = configureLocal() }) return instance From 29b53a5f752f89794bf5b4e5fdb6f8fec8c3acf0 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 22 Jan 2020 10:28:29 +0100 Subject: [PATCH 124/184] Do not run go vet since we use GolangCI --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 35389be90f..e7bc37ca3f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,10 +13,10 @@ jobs: - name: Set up Go 1.13 uses: actions/setup-go@v1 with: - go-version: 1.13.x + go-version: 1.13 - name: Check out code into the Go module directory uses: actions/checkout@v2 - name: Run Tests - run: make test + run: go test ./... From b5bc0d394376e77782565d57a0689f541f888d40 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 22 Jan 2020 10:57:11 +0100 Subject: [PATCH 125/184] Do not allow loopback connections --- packages/gossip/errors.go | 1 + packages/gossip/manager.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/packages/gossip/errors.go b/packages/gossip/errors.go index 85e43340fe..554e38618c 100644 --- a/packages/gossip/errors.go +++ b/packages/gossip/errors.go @@ -6,6 +6,7 @@ var ( ErrNotStarted = errors.New("manager not started") ErrClosed = errors.New("manager closed") ErrNotANeighbor = errors.New("peer is not a neighbor") + ErrLoopback = errors.New("loopback connection not allowed") ErrDuplicateNeighbor = errors.New("peer already connected") ErrInvalidPacket = errors.New("invalid packet") ) diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go index 03bcb47502..683cd24c96 100644 --- a/packages/gossip/manager.go +++ b/packages/gossip/manager.go @@ -78,6 +78,9 @@ func (m *Manager) LocalAddr() net.Addr { // AddOutbound tries to add a neighbor by connecting to that peer. func (m *Manager) AddOutbound(p *peer.Peer) error { + if p.ID() == m.local.ID() { + return ErrLoopback + } var srv *server.TCP m.mu.RLock() if m.srv == nil { @@ -91,6 +94,9 @@ func (m *Manager) AddOutbound(p *peer.Peer) error { // AddInbound tries to add a neighbor by accepting an incoming connection from that peer. func (m *Manager) AddInbound(p *peer.Peer) error { + if p.ID() == m.local.ID() { + return ErrLoopback + } var srv *server.TCP m.mu.RLock() if m.srv == nil { From b6beebfebd15eba0fd50f65c8faca1bc72ec3a31 Mon Sep 17 00:00:00 2001 From: Jonas Theis Date: Wed, 22 Jan 2020 11:41:56 +0100 Subject: [PATCH 126/184] Feat: Add known peers to getNeighbors request (#154) * Add known peers to getNeighbors request #151 * Check if autopeering discovery is enabled #151 --- plugins/webapi/getNeighbors/plugin.go | 38 ++++++++++++++++++++------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/plugins/webapi/getNeighbors/plugin.go b/plugins/webapi/getNeighbors/plugin.go index 3d36b4f408..71e718ff81 100644 --- a/plugins/webapi/getNeighbors/plugin.go +++ b/plugins/webapi/getNeighbors/plugin.go @@ -23,11 +23,27 @@ func getNeighbors(c echo.Context) error { chosen := []Neighbor{} accepted := []Neighbor{} + knownPeers := []Neighbor{} if autopeering.Selection == nil { return requestFailed(c, "Neighbor Selection is not enabled") } + if autopeering.Discovery == nil { + return requestFailed(c, "Neighbor Discovery is not enabled") + } + + if c.QueryParam("known") == "1" { + for _, peer := range autopeering.Discovery.GetVerifiedPeers() { + n := Neighbor{ + ID: peer.ID().String(), + PublicKey: base64.StdEncoding.EncodeToString(peer.PublicKey()), + } + n.Services = getServices(peer) + knownPeers = append(knownPeers, n) + } + } + for _, peer := range autopeering.Selection.GetOutgoingNeighbors() { n := Neighbor{ @@ -45,14 +61,15 @@ func getNeighbors(c echo.Context) error { n.Services = getServices(peer) accepted = append(accepted, n) } - return requestSuccessful(c, chosen, accepted) + return requestSuccessful(c, knownPeers, chosen, accepted) } -func requestSuccessful(c echo.Context, chosen, accepted []Neighbor) error { +func requestSuccessful(c echo.Context, knownPeers, chosen, accepted []Neighbor) error { return c.JSON(http.StatusOK, Response{ - Chosen: chosen, - Accepted: accepted, + KnownPeers: knownPeers, + Chosen: chosen, + Accepted: accepted, }) } @@ -63,15 +80,16 @@ func requestFailed(c echo.Context, message string) error { } type Response struct { - Chosen []Neighbor `json:"chosen"` - Accepted []Neighbor `json:"accepted"` - Error string `json:"error,omitempty"` + KnownPeers []Neighbor `json:"known,omitempty"` + Chosen []Neighbor `json:"chosen"` + Accepted []Neighbor `json:"accepted"` + Error string `json:"error,omitempty"` } type Neighbor struct { - ID string `json:"id"` // comparable node identifier - PublicKey string `json:"publicKey"` // public key used to verify signatures - Services []peerService + ID string `json:"id"` // comparable node identifier + PublicKey string `json:"publicKey"` // public key used to verify signatures + Services []peerService `json:"services,omitempty"` } type peerService struct { From 8bcd437d82c7ea2cfe0ad27a9e0e554b8e74a7a1 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 22 Jan 2020 12:20:41 +0100 Subject: [PATCH 127/184] Fix: netutil.CheckUDP tests (#161) --- packages/netutil/netutil.go | 2 +- packages/netutil/netutil_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/netutil/netutil.go b/packages/netutil/netutil.go index b1137f562a..b9c4932c95 100644 --- a/packages/netutil/netutil.go +++ b/packages/netutil/netutil.go @@ -87,7 +87,7 @@ func CheckUDP(local, remote *net.UDPAddr, checkAddress bool, checkPort bool) err return errInvalidData } udpAddr := from.(*net.UDPAddr) - if checkAddress && udpAddr.IP.Equal(remote.IP) { + if checkAddress && !udpAddr.IP.Equal(remote.IP) { return fmt.Errorf("IP changed: %s", udpAddr.IP) } if checkPort && udpAddr.Port != remote.Port { diff --git a/packages/netutil/netutil_test.go b/packages/netutil/netutil_test.go index f5543f8db0..99fca2cb3d 100644 --- a/packages/netutil/netutil_test.go +++ b/packages/netutil/netutil_test.go @@ -59,7 +59,7 @@ func TestCheckUDP(t *testing.T) { } func getLocalUDPAddr() (*net.UDPAddr, error) { - addr, err := net.ResolveUDPAddr("udp", ":0") + addr, err := net.ResolveUDPAddr("udp", "127.0.0.1:0") if err != nil { return nil, err } From 561483d3253b14697bdb22fa06d6e70a733debfb Mon Sep 17 00:00:00 2001 From: capossele Date: Wed, 22 Jan 2020 14:06:48 +0000 Subject: [PATCH 128/184] :bug: fixes removeNodeX --- plugins/analysis/webinterface/httpserver/index.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/analysis/webinterface/httpserver/index.go b/plugins/analysis/webinterface/httpserver/index.go index 9fce6f7698..15fea5145b 100644 --- a/plugins/analysis/webinterface/httpserver/index.go +++ b/plugins/analysis/webinterface/httpserver/index.go @@ -159,10 +159,9 @@ func index(w http.ResponseWriter, r *http.Request) { } function removeNodeX(node) { - if (!(node.id in nodesById)) { - addNode(sourceNodeId); + if (node.id in nodesById) { + removeNode(node.id); } - removeNode(node.id) } `) From f4adefc00d873bfe5b245c6f38bc354671c890f4 Mon Sep 17 00:00:00 2001 From: Angelo Capossele Date: Wed, 22 Jan 2020 14:59:57 +0000 Subject: [PATCH 129/184] :bug: Fixes removeNodeX (#162) --- plugins/analysis/webinterface/httpserver/index.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/analysis/webinterface/httpserver/index.go b/plugins/analysis/webinterface/httpserver/index.go index 9fce6f7698..15fea5145b 100644 --- a/plugins/analysis/webinterface/httpserver/index.go +++ b/plugins/analysis/webinterface/httpserver/index.go @@ -159,10 +159,9 @@ func index(w http.ResponseWriter, r *http.Request) { } function removeNodeX(node) { - if (!(node.id in nodesById)) { - addNode(sourceNodeId); + if (node.id in nodesById) { + removeNode(node.id); } - removeNode(node.id) } `) From fc01c115e96f9d616725ef61003527f760836552 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 22 Jan 2020 16:20:45 +0100 Subject: [PATCH 130/184] :rotating_light: Fix linter warning --- plugins/tangle/solidifier.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/tangle/solidifier.go b/plugins/tangle/solidifier.go index cfcb3da5f6..098b30ba08 100644 --- a/plugins/tangle/solidifier.go +++ b/plugins/tangle/solidifier.go @@ -195,13 +195,12 @@ func processTransaction(transaction *value_transaction.ValueTransaction) { Events.TransactionStored.Trigger(transaction) // store transaction hash for address in DB - err := StoreTransactionHashForAddressInDatabase( + if err := StoreTransactionHashForAddressInDatabase( &TxHashForAddress{ Address: transaction.GetAddress(), TxHash: transaction.GetHash(), }, - ) - if err != nil { + ); err != nil { log.Errorw(err.Error()) } @@ -224,8 +223,7 @@ func processTransaction(transaction *value_transaction.ValueTransaction) { } // update the solidity flags of this transaction and its approvers - _, err = IsSolid(transaction) - if err != nil { + if _, err := IsSolid(transaction); err != nil { log.Errorf("Unable to check solidity: %s", err.Error()) return } From 8dacb768a427aa5add134492e45ce5f679174a52 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Wed, 22 Jan 2020 20:03:57 +0100 Subject: [PATCH 131/184] :loud_sound: Add error handling to analysis http server" --- .../webinterface/httpserver/plugin.go | 45 ++++++++++++++----- plugins/analysis/webinterface/plugin.go | 4 +- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/plugins/analysis/webinterface/httpserver/plugin.go b/plugins/analysis/webinterface/httpserver/plugin.go index fa3f2b501b..d8330000f2 100644 --- a/plugins/analysis/webinterface/httpserver/plugin.go +++ b/plugins/analysis/webinterface/httpserver/plugin.go @@ -1,22 +1,29 @@ package httpserver import ( + "errors" "net/http" + "sync" "time" "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" - "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/logger" "golang.org/x/net/context" "golang.org/x/net/websocket" ) var ( + log *logger.Logger httpServer *http.Server router *http.ServeMux ) -func Configure(plugin *node.Plugin) { +const name = "Analysis HTTP Server" + +func Configure() { + log = logger.NewLogger(name) + router = http.NewServeMux() httpServer = &http.Server{Addr: ":80", Handler: router} @@ -24,12 +31,30 @@ func Configure(plugin *node.Plugin) { router.HandleFunc("/", index) } -func Run(plugin *node.Plugin) { - daemon.BackgroundWorker("Analysis HTTP Server", func(shutdownSignal <-chan struct{}) { - go httpServer.ListenAndServe() - <-shutdownSignal - ctx, cancel := context.WithTimeout(context.Background(), 0*time.Second) - defer cancel() - httpServer.Shutdown(ctx) - }, shutdown.ShutdownPriorityAnalysis) +func Run() { + if err := daemon.BackgroundWorker(name, start, shutdown.ShutdownPriorityAnalysis); err != nil { + log.Errorf("Error starting as daemon: %s", err) + } +} + +func start(shutdownSignal <-chan struct{}) { + var wg sync.WaitGroup + wg.Add(1) + go func() { + defer wg.Done() + log.Infof(name+" started: address=%s", httpServer.Addr) + if err := httpServer.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { + log.Warnf("Error listening: %s", err) + } + }() + <-shutdownSignal + log.Info("Stopping " + name + " ...") + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() + + if err := httpServer.Shutdown(ctx); err != nil { + log.Errorf("Error closing: %s", err) + } + wg.Wait() + log.Info("Stopping " + name + " ... done") } diff --git a/plugins/analysis/webinterface/plugin.go b/plugins/analysis/webinterface/plugin.go index f217dde659..68d1a33d2a 100644 --- a/plugins/analysis/webinterface/plugin.go +++ b/plugins/analysis/webinterface/plugin.go @@ -7,10 +7,10 @@ import ( ) func Configure(plugin *node.Plugin) { - httpserver.Configure(plugin) + httpserver.Configure() recordedevents.Configure(plugin) } func Run(plugin *node.Plugin) { - httpserver.Run(plugin) + httpserver.Run() } From 9c97a7a094ed9013ea5f520ff3f5a127c7952c41 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Thu, 23 Jan 2020 10:02:57 +0100 Subject: [PATCH 132/184] Migrates to database package of hive.go (#155) * migrates to hive.go database package * review fixes * alias types and vars from hive.go's db package * Move database to tempdir to prevent sideeffects in tests * fix import Co-authored-by: Wolfgang Welz --- go.mod | 5 +- go.sum | 17 +- packages/autopeering/peer/peerdb.go | 36 ++-- packages/database/badger_instance.go | 69 -------- packages/database/database.go | 166 ++++++------------ packages/database/interfaces.go | 13 -- packages/database/logger.go | 19 -- packages/database/prefixes.go | 11 ++ packages/database/versioning.go | 47 +++++ packages/shutdown/order.go | 1 + .../bundleprocessor/bundleprocessor_test.go | 10 ++ plugins/tangle/approvers.go | 7 +- plugins/tangle/bundle.go | 7 +- plugins/tangle/plugin.go | 10 ++ plugins/tangle/solidifier_test.go | 2 +- plugins/tangle/transaction.go | 7 +- plugins/tangle/transaction_metadata.go | 6 +- plugins/tangle/tx_per_address.go | 18 +- 18 files changed, 185 insertions(+), 266 deletions(-) delete mode 100644 packages/database/badger_instance.go delete mode 100644 packages/database/interfaces.go delete mode 100644 packages/database/logger.go create mode 100644 packages/database/prefixes.go create mode 100644 packages/database/versioning.go diff --git a/go.mod b/go.mod index 0564d83750..d0e1df7911 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,7 @@ module github.com/iotaledger/goshimmer go 1.13 require ( - github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 // indirect - github.com/dgraph-io/badger v1.6.0 + github.com/dgraph-io/badger/v2 v2.0.1 github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/dgryski/go-farm v0.0.0-20191112170834-c2139c5d712b // indirect github.com/gdamore/tcell v1.3.0 @@ -13,7 +12,7 @@ require ( github.com/googollee/go-engine.io v1.4.3-0.20190924125625-798118fc0dd2 github.com/googollee/go-socket.io v1.4.3-0.20191204093753-683f8725b6d0 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/hive.go v0.0.0-20200120092048-f168257b6ccc + github.com/iotaledger/hive.go v0.0.0-20200120174440-057de3927083 github.com/iotaledger/iota.go v1.0.0-beta.14 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect diff --git a/go.sum b/go.sum index 6cba4d4943..3664b27905 100644 --- a/go.sum +++ b/go.sum @@ -7,12 +7,12 @@ dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1 dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= -github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M= -github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/DataDog/zstd v1.4.1 h1:3oxKN3wbHibqx897utPC2LTQU4J+IHWWJO+glkAkpFM= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= +github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -36,10 +36,11 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgraph-io/badger v1.5.4 h1:gVTrpUTbbr/T24uvoCaqY2KSHfNLVGm0w+hbee2HMeg= github.com/dgraph-io/badger v1.5.4/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ= -github.com/dgraph-io/badger v1.6.0 h1:DshxFxZWXUcO0xX476VJC07Xsr6ZCBVRHKZ93Oh7Evo= -github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= -github.com/dgraph-io/badger/v2 v2.0.0/go.mod h1:YoRSIp1LmAJ7zH7tZwRvjNMUYLxB4wl3ebYkaIruZ04= +github.com/dgraph-io/badger/v2 v2.0.1 h1:+D6dhIqC6jIeCclnxMHqk4HPuXgrRN5UfBsLR4dNQ3A= +github.com/dgraph-io/badger/v2 v2.0.1/go.mod h1:YoRSIp1LmAJ7zH7tZwRvjNMUYLxB4wl3ebYkaIruZ04= +github.com/dgraph-io/ristretto v0.0.0-20191025175511-c1f00be0418e h1:aeUNgwup7PnDOBAD1BOKAqzb/W/NksOj6r3dwKKuqfg= github.com/dgraph-io/ristretto v0.0.0-20191025175511-c1f00be0418e/go.mod h1:edzKIzGvqUCMzhTVWbiTSe75zD9Xxq0GtSBtFmaUTZs= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= @@ -79,6 +80,7 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -116,8 +118,8 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/hive.go v0.0.0-20200120092048-f168257b6ccc h1:7SZQ3+4EvMd/iSOONrvD7Sa7qCm712KqTTKh8CK/9TU= -github.com/iotaledger/hive.go v0.0.0-20200120092048-f168257b6ccc/go.mod h1:obs07gqna53/Yw1ltzLsQzJBMyA6lGu7Fb/ltjqWMnQ= +github.com/iotaledger/hive.go v0.0.0-20200120174440-057de3927083 h1:dQx6NHouYh3KBStOuYrgMm6wYNnf4L+grKWQV4iBxNI= +github.com/iotaledger/hive.go v0.0.0-20200120174440-057de3927083/go.mod h1:S+v90R3u4Rqe4VoOg4DhiZrAKlKZhz2UFKuK/Neqa2o= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/iotaledger/iota.go v1.0.0-beta.14 h1:Oeb28MfBuJEeXcGrLhTCJFtbsnc8y1u7xidsAmiOD5A= github.com/iotaledger/iota.go v1.0.0-beta.14/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= @@ -239,6 +241,7 @@ github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4k github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE= github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= diff --git a/packages/autopeering/peer/peerdb.go b/packages/autopeering/peer/peerdb.go index def6344b4f..b20fcd052b 100644 --- a/packages/autopeering/peer/peerdb.go +++ b/packages/autopeering/peer/peerdb.go @@ -74,7 +74,7 @@ const ( // NewPersistentDB creates a new persistent DB. func NewPersistentDB(log *logger.Logger) DB { - db, err := database.Get("peer") + db, err := database.Get(database.DBPrefixAutoPeering, database.GetBadgerInstance()) if err != nil { panic(err) } @@ -157,26 +157,26 @@ func parseInt64(blob []byte) int64 { // getInt64 retrieves an integer associated with a particular key. func (db *persistentDB) getInt64(key []byte) int64 { - blob, err := db.db.Get(key) + entry, err := db.db.Get(key) if err != nil { return 0 } - return parseInt64(blob) + return parseInt64(entry.Value) } // setInt64 stores an integer in the given key. func (db *persistentDB) setInt64(key []byte, n int64) error { blob := make([]byte, binary.MaxVarintLen64) blob = blob[:binary.PutVarint(blob, n)] - return db.db.SetWithTTL(key, blob, peerExpiration) + return db.db.Set(database.Entry{Key: key, Value: blob, TTL: peerExpiration}) } // LocalPrivateKey returns the private key stored in the database or creates a new one. func (db *persistentDB) LocalPrivateKey() (PrivateKey, error) { - key, err := db.db.Get(localFieldKey(dbLocalKey)) + entry, err := db.db.Get(localFieldKey(dbLocalKey)) if err == database.ErrKeyNotFound { - key, err = generatePrivateKey() - if err == nil { + key, genErr := generatePrivateKey() + if genErr == nil { err = db.UpdateLocalPrivateKey(key) } return key, err @@ -184,13 +184,12 @@ func (db *persistentDB) LocalPrivateKey() (PrivateKey, error) { if err != nil { return nil, err } - - return key, nil + return PrivateKey(entry.Value), nil } // UpdateLocalPrivateKey stores the provided key in the database. func (db *persistentDB) UpdateLocalPrivateKey(key PrivateKey) error { - return db.db.Set(localFieldKey(dbLocalKey), key) + return db.db.Set(database.Entry{Key: localFieldKey(dbLocalKey), Value: []byte(key)}) } // LastPing returns that property for the given peer ID and address. @@ -218,7 +217,7 @@ func (db *persistentDB) setPeerWithTTL(p *Peer, ttl time.Duration) error { if err != nil { return err } - return db.db.SetWithTTL(nodeKey(p.ID()), data, ttl) + return db.db.Set(database.Entry{Key: nodeKey(p.ID()), Value: data, TTL: ttl}) } func (db *persistentDB) UpdatePeer(p *Peer) error { @@ -238,7 +237,7 @@ func (db *persistentDB) Peer(id ID) *Peer { if err != nil { return nil } - return parsePeer(data) + return parsePeer(data.Value) } func randomSubset(peers []*Peer, m int) []*Peer { @@ -259,21 +258,22 @@ func (db *persistentDB) getPeers(maxAge time.Duration) []*Peer { peers := make([]*Peer, 0) now := time.Now() - err := db.db.ForEachWithPrefix([]byte(dbNodePrefix), func(key []byte, value []byte) { - id, rest := splitNodeKey(key) + err := db.db.StreamForEachPrefix([]byte(dbNodePrefix), func(entry database.Entry) error { + id, rest := splitNodeKey(entry.Key) if len(rest) > 0 { - return + return nil } - p := parsePeer(value) + p := parsePeer(entry.Value) if p == nil || p.ID() != id { - return + return nil } if maxAge > 0 && now.Sub(db.LastPong(p.ID(), p.Address())) > maxAge { - return + return nil } peers = append(peers, p) + return nil }) if err != nil { return []*Peer{} diff --git a/packages/database/badger_instance.go b/packages/database/badger_instance.go deleted file mode 100644 index 439aa4727d..0000000000 --- a/packages/database/badger_instance.go +++ /dev/null @@ -1,69 +0,0 @@ -package database - -import ( - "fmt" - "os" - "sync" - - "github.com/dgraph-io/badger" - "github.com/dgraph-io/badger/options" - "github.com/iotaledger/goshimmer/packages/parameter" -) - -var instance *badger.DB -var once sync.Once - -// Returns whether the given file or directory exists. -func exists(path string) (bool, error) { - _, err := os.Stat(path) - if err == nil { - return true, nil - } - if os.IsNotExist(err) { - return false, nil - } - return false, err -} - -func checkDir(dir string) error { - exists, err := exists(dir) - if err != nil { - return err - } - - if !exists { - return os.Mkdir(dir, 0700) - } - return nil -} - -func createDB() (*badger.DB, error) { - directory := parameter.NodeConfig.GetString(CFG_DIRECTORY) - if err := checkDir(directory); err != nil { - return nil, fmt.Errorf("could not check directory: %w", err) - } - - opts := badger.DefaultOptions(directory) - opts.Logger = &logger{} - opts.Truncate = true - opts.TableLoadingMode = options.MemoryMap - - db, err := badger.Open(opts) - if err != nil { - return nil, fmt.Errorf("could not open new DB: %w", err) - } - - return db, nil -} - -func GetBadgerInstance() *badger.DB { - once.Do(func() { - db, err := createDB() - if err != nil { - // errors should cause a panic to avoid singleton deadlocks - panic(err) - } - instance = db - }) - return instance -} diff --git a/packages/database/database.go b/packages/database/database.go index 913ffc3f91..4da5818cd9 100644 --- a/packages/database/database.go +++ b/packages/database/database.go @@ -1,134 +1,78 @@ package database import ( + "io/ioutil" + "os" + "runtime" "sync" - "time" - "github.com/dgraph-io/badger" + "github.com/dgraph-io/badger/v2" + "github.com/iotaledger/goshimmer/packages/parameter" + "github.com/iotaledger/hive.go/database" + "github.com/iotaledger/hive.go/logger" ) var ( - ErrKeyNotFound = badger.ErrKeyNotFound - - dbMap = make(map[string]*prefixDb) - mu sync.Mutex + instance *badger.DB + once sync.Once + ErrKeyNotFound = database.ErrKeyNotFound ) -type prefixDb struct { - db *badger.DB - name string - prefix []byte -} - -func getPrefix(name string) []byte { - return []byte(name + "_") -} - -func Get(name string) (Database, error) { - mu.Lock() - defer mu.Unlock() - - if db, exists := dbMap[name]; exists { - return db, nil - } - - badger := GetBadgerInstance() - db := &prefixDb{ - db: badger, - name: name, - prefix: getPrefix(name), - } - - dbMap[name] = db - - return db, nil -} - -func (this *prefixDb) setEntry(e *badger.Entry) error { - err := this.db.Update(func(txn *badger.Txn) error { - return txn.SetEntry(e) - }) - return err -} - -func (this *prefixDb) Set(key []byte, value []byte) error { - e := badger.NewEntry(append(this.prefix, key...), value) - return this.setEntry(e) -} +type ( + Database = database.Database + Entry = database.Entry + KeyOnlyEntry = database.KeyOnlyEntry + KeyPrefix = database.KeyPrefix + Value = database.Value +) -func (this *prefixDb) SetWithTTL(key []byte, value []byte, ttl time.Duration) error { - e := badger.NewEntry(append(this.prefix, key...), value).WithTTL(ttl) - return this.setEntry(e) +func Get(dbPrefix byte, optionalBadger ...*badger.DB) (Database, error) { + return database.Get(dbPrefix, optionalBadger...) } -func (this *prefixDb) Contains(key []byte) (bool, error) { - err := this.db.View(func(txn *badger.Txn) error { - _, err := txn.Get(append(this.prefix, key...)) - return err - }) - - if err == ErrKeyNotFound { - return false, nil - } else { - return err == nil, err - } -} +func GetBadgerInstance() *badger.DB { + once.Do(func() { + dbDir := parameter.NodeConfig.GetString(CFG_DIRECTORY) -func (this *prefixDb) Get(key []byte) ([]byte, error) { - var result []byte = nil - - err := this.db.View(func(txn *badger.Txn) error { - item, err := txn.Get(append(this.prefix, key...)) + var dbDirClear bool + // check whether the database is new, by checking whether any file exists within + // the database directory + fileInfos, err := ioutil.ReadDir(dbDir) if err != nil { - return err + // panic on other errors, for example permission related + if !os.IsNotExist(err) { + panic(err) + } + dbDirClear = true + } + if len(fileInfos) == 0 { + dbDirClear = true } - return item.Value(func(val []byte) error { - result = append([]byte{}, val...) - - return nil - }) - }) - - return result, err -} - -func (this *prefixDb) Delete(key []byte) error { - err := this.db.Update(func(txn *badger.Txn) error { - return txn.Delete(append(this.prefix, key...)) - }) - return err -} - -func (this *prefixDb) forEach(prefix []byte, consumer func([]byte, []byte)) error { - err := this.db.View(func(txn *badger.Txn) error { - iteratorOptions := badger.DefaultIteratorOptions - iteratorOptions.Prefix = prefix // filter by prefix - - // create an iterator the default options - it := txn.NewIterator(iteratorOptions) - defer it.Close() - - // loop through every key-value-pair and call the function - for it.Rewind(); it.Valid(); it.Next() { - item := it.Item() - - value, err := item.ValueCopy(nil) - if err != nil { - return err - } + opts := badger.DefaultOptions(dbDir) + opts.Logger = nil + if runtime.GOOS == "windows" { + opts = opts.WithTruncate(true) + } - consumer(item.Key()[len(this.prefix):], value) + db, err := database.CreateDB(dbDir, opts) + if err != nil { + // errors should cause a panic to avoid singleton deadlocks + panic(err) } - return nil - }) - return err -} + instance = db -func (this *prefixDb) ForEachWithPrefix(prefix []byte, consumer func([]byte, []byte)) error { - return this.forEach(append(this.prefix, prefix...), consumer) + // up on the first caller, check whether the version of the database is compatible + checkDatabaseVersion(dbDirClear) + }) + return instance } -func (this *prefixDb) ForEach(consumer func([]byte, []byte)) error { - return this.forEach(this.prefix, consumer) +func CleanupBadgerInstance(log *logger.Logger) { + db := GetBadgerInstance() + log.Info("Running Badger database garbage collection") + var err error + for err == nil { + err = db.RunValueLogGC(0.7) + } } diff --git a/packages/database/interfaces.go b/packages/database/interfaces.go deleted file mode 100644 index 56d2b95738..0000000000 --- a/packages/database/interfaces.go +++ /dev/null @@ -1,13 +0,0 @@ -package database - -import "time" - -type Database interface { - Set(key []byte, value []byte) error - SetWithTTL(key []byte, value []byte, ttl time.Duration) error - Contains(key []byte) (bool, error) - Get(key []byte) ([]byte, error) - ForEach(consumer func(key []byte, value []byte)) error - ForEachWithPrefix(prefix []byte, consumer func(key []byte, value []byte)) error - Delete(key []byte) error -} diff --git a/packages/database/logger.go b/packages/database/logger.go deleted file mode 100644 index ac1de09145..0000000000 --- a/packages/database/logger.go +++ /dev/null @@ -1,19 +0,0 @@ -package database - -type logger struct{} - -func (this *logger) Errorf(string, ...interface{}) { - // disable logging -} - -func (this *logger) Infof(string, ...interface{}) { - // disable logging -} - -func (this *logger) Warningf(string, ...interface{}) { - // disable logging -} - -func (this *logger) Debugf(string, ...interface{}) { - // disable logging -} diff --git a/packages/database/prefixes.go b/packages/database/prefixes.go new file mode 100644 index 0000000000..c9dc488d40 --- /dev/null +++ b/packages/database/prefixes.go @@ -0,0 +1,11 @@ +package database + +const ( + DBPrefixApprovers byte = iota + DBPrefixTransaction + DBPrefixBundle + DBPrefixTransactionMetadata + DBPrefixAddressTransactions + DBPrefixAutoPeering + DBPrefixDatabaseVersion +) diff --git a/packages/database/versioning.go b/packages/database/versioning.go new file mode 100644 index 0000000000..a848eb0e50 --- /dev/null +++ b/packages/database/versioning.go @@ -0,0 +1,47 @@ +package database + +import ( + "errors" + "fmt" +) + +const ( + // DBVersion defines the version of the database schema this version of GoShimmer supports. + // everytime there's a breaking change regarding the stored data, this version flag should be adjusted. + DBVersion = 1 +) + +var ( + ErrDBVersionIncompatible = errors.New("database version is not compatible. please delete your database folder and restart") + // the key under which the database is stored + dbVersionKey = []byte{0} +) + +// checks whether the database is compatible with the current schema version. +// also automatically sets the version if the database is new. +func checkDatabaseVersion(dbIsNew bool) { + dbInstance, err := Get(DBPrefixDatabaseVersion, instance) + if err != nil { + panic(err) + } + + if dbIsNew { + // store db version for the first time in the new database + if err = dbInstance.Set(Entry{Key: dbVersionKey, Value: []byte{DBVersion}}); err != nil { + panic(fmt.Sprintf("unable to persist db version number: %s", err.Error())) + } + return + } + + // db version must be available + entry, err := dbInstance.Get(dbVersionKey) + if err != nil { + if err == ErrKeyNotFound { + panic(err) + } + panic(fmt.Errorf("%w: no database version was persisted", ErrDBVersionIncompatible)) + } + if entry.Value[0] != DBVersion { + panic(fmt.Errorf("%w: supported version: %d, version of database: %d", ErrDBVersionIncompatible, DBVersion, entry.Value[0])) + } +} diff --git a/packages/shutdown/order.go b/packages/shutdown/order.go index b16bc91e04..51ed31ec8d 100644 --- a/packages/shutdown/order.go +++ b/packages/shutdown/order.go @@ -14,5 +14,6 @@ const ( ShutdownPriorityUI ShutdownPriorityDashboard ShutdownPriorityTangleSpammer + ShutdownPriorityBadgerGarbageCollection ShutdownPriorityStatusScreen ) diff --git a/plugins/bundleprocessor/bundleprocessor_test.go b/plugins/bundleprocessor/bundleprocessor_test.go index 6505583f45..e7b90366bd 100644 --- a/plugins/bundleprocessor/bundleprocessor_test.go +++ b/plugins/bundleprocessor/bundleprocessor_test.go @@ -1,10 +1,13 @@ package bundleprocessor import ( + "io/ioutil" + "os" "sync" "testing" "github.com/iotaledger/goshimmer/packages/client" + "github.com/iotaledger/goshimmer/packages/database" "github.com/iotaledger/goshimmer/packages/model/bundle" "github.com/iotaledger/goshimmer/packages/model/value_transaction" "github.com/iotaledger/goshimmer/packages/parameter" @@ -16,6 +19,7 @@ import ( "github.com/iotaledger/iota.go/consts" "github.com/magiconair/properties/assert" "github.com/spf13/viper" + "github.com/stretchr/testify/require" ) var seed = client.NewSeed("YFHQWAUPCXC9S9DSHP9NDF9RLNPMZVCMSJKUKQP9SWUSUCPRQXCMDVDVZ9SHHESHIQNCXWBJF9UJSWE9Z", consts.SecurityLevelMedium) @@ -69,6 +73,12 @@ func TestValidateSignatures(t *testing.T) { } func TestProcessSolidBundleHead(t *testing.T) { + dir, err := ioutil.TempDir("", t.Name()) + require.NoError(t, err) + defer os.Remove(dir) + // use the tempdir for the database + parameter.NodeConfig.Set(database.CFG_DIRECTORY, dir) + // start a test node node.Start(node.Plugins(tangle.PLUGIN, PLUGIN)) defer node.Shutdown() diff --git a/plugins/tangle/approvers.go b/plugins/tangle/approvers.go index 10073c3943..3e50c29cae 100644 --- a/plugins/tangle/approvers.go +++ b/plugins/tangle/approvers.go @@ -82,7 +82,7 @@ const ( var approversDatabase database.Database func configureApproversDatabase() { - if db, err := database.Get("approvers"); err != nil { + if db, err := database.Get(database.DBPrefixApprovers, database.GetBadgerInstance()); err != nil { panic(err) } else { approversDatabase = db @@ -91,10 +91,9 @@ func configureApproversDatabase() { func storeApproversInDatabase(approvers *approvers.Approvers) error { if approvers.GetModified() { - if err := approversDatabase.Set(typeutils.StringToBytes(approvers.GetHash()), approvers.Marshal()); err != nil { + if err := approversDatabase.Set(database.Entry{Key: typeutils.StringToBytes(approvers.GetHash()), Value: approvers.Marshal()}); err != nil { return fmt.Errorf("%w: failed to store approvers: %s", ErrDatabaseError, err) } - approvers.SetModified(false) } @@ -111,7 +110,7 @@ func getApproversFromDatabase(transactionHash trinary.Trytes) (*approvers.Approv } var result approvers.Approvers - if err = result.Unmarshal(approversData); err != nil { + if err = result.Unmarshal(approversData.Value); err != nil { panic(err) } diff --git a/plugins/tangle/bundle.go b/plugins/tangle/bundle.go index 55411764a2..2cb1fb896a 100644 --- a/plugins/tangle/bundle.go +++ b/plugins/tangle/bundle.go @@ -86,7 +86,7 @@ const ( var bundleDatabase database.Database func configureBundleDatabase() { - if db, err := database.Get("bundle"); err != nil { + if db, err := database.Get(database.DBPrefixBundle, database.GetBadgerInstance()); err != nil { panic(err) } else { bundleDatabase = db @@ -95,10 +95,9 @@ func configureBundleDatabase() { func storeBundleInDatabase(bundle *bundle.Bundle) error { if bundle.GetModified() { - if err := bundleDatabase.Set(typeutils.StringToBytes(bundle.GetHash()), bundle.Marshal()); err != nil { + if err := bundleDatabase.Set(database.Entry{Key: typeutils.StringToBytes(bundle.GetHash()), Value: bundle.Marshal()}); err != nil { return fmt.Errorf("%w: failed to store bundle: %s", ErrDatabaseError, err) } - bundle.SetModified(false) } @@ -116,7 +115,7 @@ func getBundleFromDatabase(transactionHash trinary.Trytes) (*bundle.Bundle, erro } var result bundle.Bundle - if err = result.Unmarshal(bundleData); err != nil { + if err = result.Unmarshal(bundleData.Value); err != nil { panic(err) } diff --git a/plugins/tangle/plugin.go b/plugins/tangle/plugin.go index 252c2b987d..6c6bc09015 100644 --- a/plugins/tangle/plugin.go +++ b/plugins/tangle/plugin.go @@ -1,11 +1,14 @@ package tangle import ( + "time" + "github.com/iotaledger/goshimmer/packages/database" "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" + "github.com/iotaledger/hive.go/timeutil" "github.com/iotaledger/iota.go/trinary" ) @@ -42,6 +45,13 @@ func configure(*node.Plugin) { } func run(*node.Plugin) { + + daemon.BackgroundWorker("Badger garbage collection", func(shutdownSignal <-chan struct{}) { + timeutil.Ticker(func() { + database.CleanupBadgerInstance(log) + }, 5*time.Minute, shutdownSignal) + }, shutdown.ShutdownPriorityBadgerGarbageCollection) + runSolidifier() } diff --git a/plugins/tangle/solidifier_test.go b/plugins/tangle/solidifier_test.go index 850f87501e..28a63bc25a 100644 --- a/plugins/tangle/solidifier_test.go +++ b/plugins/tangle/solidifier_test.go @@ -33,7 +33,7 @@ func init() { } func TestTangle(t *testing.T) { - dir, err := ioutil.TempDir("", "example") + dir, err := ioutil.TempDir("", t.Name()) require.NoError(t, err) defer os.Remove(dir) // use the tempdir for the database diff --git a/plugins/tangle/transaction.go b/plugins/tangle/transaction.go index fc2e2f02dd..bff7b6b726 100644 --- a/plugins/tangle/transaction.go +++ b/plugins/tangle/transaction.go @@ -83,7 +83,7 @@ const ( var transactionDatabase database.Database func configureTransactionDatabase() { - if db, err := database.Get("transaction"); err != nil { + if db, err := database.Get(database.DBPrefixTransaction, database.GetBadgerInstance()); err != nil { panic(err) } else { transactionDatabase = db @@ -92,10 +92,9 @@ func configureTransactionDatabase() { func storeTransactionInDatabase(transaction *value_transaction.ValueTransaction) error { if transaction.GetModified() { - if err := transactionDatabase.Set(typeutils.StringToBytes(transaction.GetHash()), transaction.MetaTransaction.GetBytes()); err != nil { + if err := transactionDatabase.Set(database.Entry{Key: typeutils.StringToBytes(transaction.GetHash()), Value: transaction.MetaTransaction.GetBytes()}); err != nil { return fmt.Errorf("%w: failed to store transaction: %s", ErrDatabaseError, err.Error()) } - transaction.SetModified(false) } @@ -111,7 +110,7 @@ func getTransactionFromDatabase(transactionHash trinary.Trytes) (*value_transact return nil, fmt.Errorf("%w: failed to retrieve transaction: %s", ErrDatabaseError, err) } - return value_transaction.FromBytes(txData), nil + return value_transaction.FromBytes(txData.Value), nil } func databaseContainsTransaction(transactionHash trinary.Trytes) (bool, error) { diff --git a/plugins/tangle/transaction_metadata.go b/plugins/tangle/transaction_metadata.go index 94d6177af9..152f0126da 100644 --- a/plugins/tangle/transaction_metadata.go +++ b/plugins/tangle/transaction_metadata.go @@ -83,7 +83,7 @@ const ( var transactionMetadataDatabase database.Database func configureTransactionMetaDataDatabase() { - if db, err := database.Get("transactionMetadata"); err != nil { + if db, err := database.Get(database.DBPrefixTransactionMetadata, database.GetBadgerInstance()); err != nil { panic(err) } else { transactionMetadataDatabase = db @@ -95,7 +95,7 @@ func storeTransactionMetadataInDatabase(metadata *transactionmetadata.Transactio if marshaledMetadata, err := metadata.Marshal(); err != nil { return err } else { - if err := transactionMetadataDatabase.Set(typeutils.StringToBytes(metadata.GetHash()), marshaledMetadata); err != nil { + if err := transactionMetadataDatabase.Set(database.Entry{Key: typeutils.StringToBytes(metadata.GetHash()), Value: marshaledMetadata}); err != nil { return fmt.Errorf("%w: failed to store transaction metadata: %s", ErrDatabaseError, err) } @@ -116,7 +116,7 @@ func getTransactionMetadataFromDatabase(transactionHash trinary.Trytes) (*transa } var result transactionmetadata.TransactionMetadata - if err := result.Unmarshal(txMetadata); err != nil { + if err := result.Unmarshal(txMetadata.Value); err != nil { panic(err) } diff --git a/plugins/tangle/tx_per_address.go b/plugins/tangle/tx_per_address.go index 1ab4950e6c..092a752484 100644 --- a/plugins/tangle/tx_per_address.go +++ b/plugins/tangle/tx_per_address.go @@ -13,7 +13,7 @@ var ( ) func configureTransactionHashesForAddressDatabase() { - if db, err := database.Get("transactionsHashesForAddress"); err != nil { + if db, err := database.Get(database.DBPrefixAddressTransactions, database.GetBadgerInstance()); err != nil { panic(err) } else { transactionsHashesForAddressDatabase = db @@ -26,10 +26,10 @@ type TxHashForAddress struct { } func StoreTransactionHashForAddressInDatabase(address *TxHashForAddress) error { - if err := transactionsHashesForAddressDatabase.Set( - databaseKeyForHashPrefixedHash(address.Address, address.TxHash), - []byte{}, - ); err != nil { + if err := transactionsHashesForAddressDatabase.Set(database.Entry{ + Key: databaseKeyForHashPrefixedHash(address.Address, address.TxHash), + Value: []byte{}, + }); err != nil { return fmt.Errorf("%w: failed to store tx for address in database: %s", ErrDatabaseError, err) } return nil @@ -47,11 +47,9 @@ func DeleteTransactionHashForAddressInDatabase(address *TxHashForAddress) error func ReadTransactionHashesForAddressFromDatabase(address trinary.Hash) ([]trinary.Hash, error) { var transactionHashes []trinary.Hash - err := transactionsHashesForAddressDatabase.ForEachWithPrefix(databaseKeyForHashPrefix(address), func(key []byte, value []byte) { - k := typeutils.BytesToString(key) - if len(k) > 81 { - transactionHashes = append(transactionHashes, k[81:]) - } + err := transactionsHashesForAddressDatabase.StreamForEachPrefixKeyOnly(databaseKeyForHashPrefix(address), func(key database.KeyOnlyEntry) error { + transactionHashes = append(transactionHashes, typeutils.BytesToString(key.Key)) + return nil }) if err != nil { From 49bbb1863a099a7348bf8ee1eb6f93f23cda5031 Mon Sep 17 00:00:00 2001 From: jkrvivian Date: Thu, 23 Jan 2020 19:48:06 +0800 Subject: [PATCH 133/184] :sparkles: Implement relay-check (#139) * :sparkles: Implement relay-check * :construction: Rename files and minor tweaks * :construction: Move print function in to caller * :sparkles: Enable cli settings --- tools/relay-checker/config.go | 46 ++++++++++++++++++++ tools/relay-checker/config.json | 12 ++++++ tools/relay-checker/main.go | 72 +++++++++++++++++++++++++++++++ tools/relay-checker/parameters.go | 23 ++++++++++ 4 files changed, 153 insertions(+) create mode 100644 tools/relay-checker/config.go create mode 100644 tools/relay-checker/config.json create mode 100644 tools/relay-checker/main.go create mode 100644 tools/relay-checker/parameters.go diff --git a/tools/relay-checker/config.go b/tools/relay-checker/config.go new file mode 100644 index 0000000000..9096faf6f2 --- /dev/null +++ b/tools/relay-checker/config.go @@ -0,0 +1,46 @@ +package main + +import ( + "github.com/iotaledger/goshimmer/packages/parameter" +) + +var ( + nodes []string + target = "" + txnAddr = "GOSHIMMER99TEST999999999999999999999999999999999999999999999999999999999999999999" + txnData = "TEST99BROADCAST99DATA" + cooldown = 2 + maxQuery = 1 +) + +func LoadConfig() { + if err := parameter.FetchConfig(false); err != nil { + panic(err) + } +} + +func SetConfig() { + if parameter.NodeConfig.GetString(CFG_TARGET_NODE) == "" { + panic("Set the target node address\n") + } + target = parameter.NodeConfig.GetString(CFG_TARGET_NODE) + + if len(parameter.NodeConfig.GetStringSlice(CFG_TEST_NODES)) == 0 { + panic("Set node addresses\n") + } + nodes = append(nodes, parameter.NodeConfig.GetStringSlice(CFG_TEST_NODES)...) + + // optional settings + if parameter.NodeConfig.GetString(CFG_TXN_ADDRESS) != "" { + txnAddr = parameter.NodeConfig.GetString(CFG_TXN_ADDRESS) + } + if parameter.NodeConfig.GetString(CFG_DATA) != "" { + txnData = parameter.NodeConfig.GetString(CFG_DATA) + } + if parameter.NodeConfig.GetInt(CFG_COOL_DOWN_TIME) > 0 { + cooldown = parameter.NodeConfig.GetInt(CFG_COOL_DOWN_TIME) + } + if parameter.NodeConfig.GetInt(CFG_MAX_QUERY) > 0 { + maxQuery = parameter.NodeConfig.GetInt(CFG_MAX_QUERY) + } +} diff --git a/tools/relay-checker/config.json b/tools/relay-checker/config.json new file mode 100644 index 0000000000..d7c0df5512 --- /dev/null +++ b/tools/relay-checker/config.json @@ -0,0 +1,12 @@ +{ + "relaycheck": { + "targetnode": "http://127.0.0.1:8080", + "nodes": [ + "http://127.0.0.1:8080" + ], + "txnaddress": "SHIMMER99TEST99999999999999999999999999999999999999999999999999999999999999999999", + "data": "TEST99BROADCAST99DATA", + "cooldowntime": 10, + "maxquery": 2 + } +} diff --git a/tools/relay-checker/main.go b/tools/relay-checker/main.go new file mode 100644 index 0000000000..189babf7ea --- /dev/null +++ b/tools/relay-checker/main.go @@ -0,0 +1,72 @@ +package main + +import ( + "fmt" + "time" + + client "github.com/iotaledger/goshimmer/client" + "github.com/iotaledger/goshimmer/packages/errors" + "github.com/iotaledger/iota.go/trinary" +) + +func testBroadcastData(api *client.GoShimmerAPI) (trinary.Hash, error) { + txnHash, err := api.BroadcastData(txnAddr, txnData) + if err != nil { + return "", errors.Wrapf(err, "Broadcast failed") + } + return txnHash, nil +} + +func testTargetGetTransactions(api *client.GoShimmerAPI, txnHash trinary.Hash) error { + // query target node for broadcasted data + _, err := api.GetTransactions([]trinary.Hash{txnHash}) + if err != nil { + return errors.Wrapf(err, "Query target failed") + } + return nil +} + +func testNodesGetTransactions(txnHash trinary.Hash) error { + // query nodes node for broadcasted data + for _, n := range nodes { + nodesApi := client.NewGoShimmerAPI(n) + _, err := nodesApi.GetTransactions([]trinary.Hash{txnHash}) + if err != nil { + return errors.Wrapf(err, "Query %s failed", n) + } + fmt.Printf("txn found in %s\n", n) + } + return nil +} + +func main() { + LoadConfig() + SetConfig() + + api := client.NewGoShimmerAPI(target) + for i := 0; i < maxQuery; i++ { + txnHash, err := testBroadcastData(api) + if err != nil { + fmt.Printf("%s\n", err) + break + } + fmt.Printf("txnHash: %s\n", txnHash) + + // cooldown time + time.Sleep(time.Duration(cooldown) * time.Second) + + // query target node + err = testTargetGetTransactions(api, txnHash) + if err != nil { + fmt.Printf("%s\n", err) + break + } + + // query nodes node + err = testNodesGetTransactions(txnHash) + if err != nil { + fmt.Printf("%s\n", err) + break + } + } +} diff --git a/tools/relay-checker/parameters.go b/tools/relay-checker/parameters.go new file mode 100644 index 0000000000..b1ee2b9b5a --- /dev/null +++ b/tools/relay-checker/parameters.go @@ -0,0 +1,23 @@ +package main + +import ( + flag "github.com/spf13/pflag" +) + +const ( + CFG_TARGET_NODE = "relaycheck.targetNode" + CFG_TEST_NODES = "relaycheck.nodes" + CFG_TXN_ADDRESS = "relaycheck.txnAddress" + CFG_DATA = "relaycheck.data" + CFG_COOL_DOWN_TIME = "relaycheck.cooldownTime" + CFG_MAX_QUERY = "relaycheck.maxQuery" +) + +func init() { + flag.StringSlice(CFG_TEST_NODES, []string{""}, "list of trusted entry nodes for auto peering") + flag.String(CFG_TARGET_NODE, "http://127.0.0.1:8080", "target node to test") + flag.String(CFG_TXN_ADDRESS, "SHIMMER99TEST99999999999999999999999999999999999999999999999999999999999999999999", "transaction address") + flag.String(CFG_DATA, "TEST99BROADCAST99DATA", "data to broadcast") + flag.Int(CFG_COOL_DOWN_TIME, 10, "cooldown time after broadcast data") + flag.Int(CFG_MAX_QUERY, 1, "the repeat times of relay-checker") +} From d01c5f3cab072706eb360521c5b978cbb1335e28 Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 23 Jan 2020 11:57:26 +0000 Subject: [PATCH 134/184] :loud_sound: adds report for knownPeers and AcceptedNeighbors --- plugins/analysis/client/plugin.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index b9179be123..df532eec75 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -80,7 +80,9 @@ func reportCurrentStatus(eventDispatchers *EventDispatchers) { eventDispatchers.AddNode(local.GetInstance().ID().Bytes()) } + reportKnownPeers(eventDispatchers) reportChosenNeighbors(eventDispatchers) + reportAcceptedNeighbors(eventDispatchers) } func setupHooks(plugin *node.Plugin, conn *network.ManagedConnection, eventDispatchers *EventDispatchers) { @@ -123,6 +125,7 @@ func setupHooks(plugin *node.Plugin, conn *network.ManagedConnection, eventDispa var onClose *events.Closure onClose = events.NewClosure(func() { discover.Events.PeerDiscovered.Detach(onDiscoverPeer) + discover.Events.PeerDeleted.Detach(onDeletePeer) selection.Events.IncomingPeering.Detach(onAddAcceptedNeighbor) selection.Events.OutgoingPeering.Detach(onAddChosenNeighbor) selection.Events.Dropped.Detach(onRemoveNeighbor) @@ -132,15 +135,32 @@ func setupHooks(plugin *node.Plugin, conn *network.ManagedConnection, eventDispa conn.Events.Close.Attach(onClose) } +func reportKnownPeers(dispatchers *EventDispatchers) { + if autopeering.Discovery != nil { + for _, peer := range autopeering.Discovery.GetVerifiedPeers() { + dispatchers.AddNode(peer.ID().Bytes()) + } + } +} + func reportChosenNeighbors(dispatchers *EventDispatchers) { if autopeering.Selection != nil { for _, chosenNeighbor := range autopeering.Selection.GetOutgoingNeighbors() { - dispatchers.AddNode(chosenNeighbor.ID().Bytes()) + //dispatchers.AddNode(chosenNeighbor.ID().Bytes()) dispatchers.ConnectNodes(local.GetInstance().ID().Bytes(), chosenNeighbor.ID().Bytes()) } } } +func reportAcceptedNeighbors(dispatchers *EventDispatchers) { + if autopeering.Selection != nil { + for _, acceptedNeighbor := range autopeering.Selection.GetIncomingNeighbors() { + //dispatchers.AddNode(acceptedNeighbor.ID().Bytes()) + dispatchers.ConnectNodes(local.GetInstance().ID().Bytes(), acceptedNeighbor.ID().Bytes()) + } + } +} + func keepConnectionAlive(conn *network.ManagedConnection, shutdownSignal <-chan struct{}) bool { go conn.Read(make([]byte, 1)) From b553b4320fb34c20677e060be5867be27d6d37ff Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Thu, 23 Jan 2020 13:04:25 +0100 Subject: [PATCH 135/184] Fix: Use netutil to check UDP ports instead of discover's ping (#160) * fix: use netutil to check UDP connection * Make ping private * use public address from local * add missing import * update hive.go version * repeat sends directly in protocol * retry ping to ensure verified * Apply suggestions from code review Co-Authored-By: Luca Moser Co-authored-by: Luca Moser --- go.mod | 2 +- go.sum | 4 +- packages/autopeering/discover/manager.go | 19 +- packages/autopeering/discover/manager_test.go | 34 ++-- packages/autopeering/discover/protocol.go | 162 ++++++++++-------- .../autopeering/discover/protocol_test.go | 24 +-- packages/autopeering/discover/query_strat.go | 15 +- packages/autopeering/selection/manager.go | 9 +- .../autopeering/selection/manager_test.go | 4 +- packages/autopeering/selection/protocol.go | 102 ++++++----- .../autopeering/selection/protocol_test.go | 12 +- packages/autopeering/selection/selection.go | 18 +- packages/autopeering/server/common.go | 3 - packages/autopeering/server/protocol.go | 10 -- packages/autopeering/server/server.go | 12 +- packages/autopeering/server/server_test.go | 2 +- packages/gossip/manager.go | 6 - plugins/autopeering/autopeering.go | 46 ++--- plugins/gossip/gossip.go | 8 +- 19 files changed, 246 insertions(+), 246 deletions(-) diff --git a/go.mod b/go.mod index d0e1df7911..7a2417445e 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/googollee/go-engine.io v1.4.3-0.20190924125625-798118fc0dd2 github.com/googollee/go-socket.io v1.4.3-0.20191204093753-683f8725b6d0 github.com/gorilla/websocket v1.4.1 - github.com/iotaledger/hive.go v0.0.0-20200120174440-057de3927083 + github.com/iotaledger/hive.go v0.0.0-20200121213505-28904d5f037c github.com/iotaledger/iota.go v1.0.0-beta.14 github.com/labstack/echo v3.3.10+incompatible github.com/labstack/gommon v0.3.0 // indirect diff --git a/go.sum b/go.sum index 3664b27905..47bfbc4884 100644 --- a/go.sum +++ b/go.sum @@ -118,8 +118,8 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iotaledger/hive.go v0.0.0-20200120174440-057de3927083 h1:dQx6NHouYh3KBStOuYrgMm6wYNnf4L+grKWQV4iBxNI= -github.com/iotaledger/hive.go v0.0.0-20200120174440-057de3927083/go.mod h1:S+v90R3u4Rqe4VoOg4DhiZrAKlKZhz2UFKuK/Neqa2o= +github.com/iotaledger/hive.go v0.0.0-20200121213505-28904d5f037c h1:3T0MLyZIL74kYLqVrmv1xQlwE2ktS1IO8kjM+NyXEMU= +github.com/iotaledger/hive.go v0.0.0-20200121213505-28904d5f037c/go.mod h1:S+v90R3u4Rqe4VoOg4DhiZrAKlKZhz2UFKuK/Neqa2o= github.com/iotaledger/iota.go v1.0.0-beta.9/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= github.com/iotaledger/iota.go v1.0.0-beta.14 h1:Oeb28MfBuJEeXcGrLhTCJFtbsnc8y1u7xidsAmiOD5A= github.com/iotaledger/iota.go v1.0.0-beta.14/go.mod h1:F6WBmYd98mVjAmmPVYhnxg8NNIWCjjH8VWT9qvv3Rc8= diff --git a/packages/autopeering/discover/manager.go b/packages/autopeering/discover/manager.go index 974b976a6f..e451a3cf6c 100644 --- a/packages/autopeering/discover/manager.go +++ b/packages/autopeering/discover/manager.go @@ -7,7 +7,6 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/peer" "github.com/iotaledger/goshimmer/packages/autopeering/server" - "github.com/iotaledger/hive.go/backoff" "github.com/iotaledger/hive.go/logger" ) @@ -18,22 +17,16 @@ const ( MaxPeersInResponse = 6 // MaxServices is the maximum number of services a peer can support. MaxServices = 5 - // NetworkMaxRetries is the maximum number of times a failing network send is retried. - NetworkMaxRetries = 2 // VersionNum specifies the expected version number for this Protocol. VersionNum = 0 ) -// policy for retrying failed network calls -var networkRetryPolicy = backoff.ExponentialBackOff(500*time.Millisecond, 1.5).With( - backoff.Jitter(0.5), backoff.MaxRetries(NetworkMaxRetries)) - type network interface { local() *peer.Local Ping(*peer.Peer) error - discoveryRequest(*peer.Peer) ([]*peer.Peer, error) + DiscoveryRequest(*peer.Peer) ([]*peer.Peer, error) } type manager struct { @@ -144,16 +137,8 @@ func (m *manager) doReverify(done chan<- struct{}) { "addr", p.Address(), ) - err := backoff.Retry(networkRetryPolicy, func() error { - err := m.net.Ping(unwrapPeer(p)) - if err != nil && err != server.ErrTimeout { - return backoff.Permanent(err) - } - return err - }) - // could not verify the peer - if err != nil { + if m.net.Ping(unwrapPeer(p)) != nil { m.mutex.Lock() defer m.mutex.Unlock() diff --git a/packages/autopeering/discover/manager_test.go b/packages/autopeering/discover/manager_test.go index 07a35889bc..afe6a3899c 100644 --- a/packages/autopeering/discover/manager_test.go +++ b/packages/autopeering/discover/manager_test.go @@ -27,7 +27,7 @@ func (m *NetworkMock) Ping(p *peer.Peer) error { return args.Error(0) } -func (m *NetworkMock) discoveryRequest(p *peer.Peer) ([]*peer.Peer, error) { +func (m *NetworkMock) DiscoveryRequest(p *peer.Peer) ([]*peer.Peer, error) { args := m.Called(p) return args.Get(0).([]*peer.Peer), args.Error(1) } @@ -69,10 +69,10 @@ func TestMgrVerifyDiscoveredPeer(t *testing.T) { p := newDummyPeer("p") - // expect ping of peer p + // expect Ping of peer p m.On("Ping", p).Return(nil).Once() - // ignore discoveryRequest calls - m.On("discoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() + // ignore DiscoveryRequest calls + m.On("DiscoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() // let the manager initialize time.Sleep(graceTime) @@ -89,10 +89,10 @@ func TestMgrReverifyPeer(t *testing.T) { p := newDummyPeer("p") - // expect ping of peer p + // expect Ping of peer p m.On("Ping", p).Return(nil).Once() - // ignore discoveryRequest calls - m.On("discoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() + // ignore DiscoveryRequest calls + m.On("DiscoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() // let the manager initialize time.Sleep(graceTime) @@ -110,9 +110,9 @@ func TestMgrRequestDiscoveredPeer(t *testing.T) { p1 := newDummyPeer("verified") p2 := newDummyPeer("discovered") - // expect discoveryRequest on the discovered peer - m.On("discoveryRequest", p1).Return([]*peer.Peer{p2}, nil).Once() - // ignore any ping + // expect DiscoveryRequest on the discovered peer + m.On("DiscoveryRequest", p1).Return([]*peer.Peer{p2}, nil).Once() + // ignore any Ping m.On("Ping", mock.Anything).Return(nil).Maybe() mgr.addVerifiedPeer(p1) @@ -128,10 +128,10 @@ func TestMgrAddManyVerifiedPeers(t *testing.T) { p := newDummyPeer("p") - // expect ping of peer p + // expect Ping of peer p m.On("Ping", p).Return(nil).Once() - // ignore discoveryRequest calls - m.On("discoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() + // ignore DiscoveryRequest calls + m.On("DiscoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() // let the manager initialize time.Sleep(graceTime) @@ -156,10 +156,10 @@ func TestMgrDeleteUnreachablePeer(t *testing.T) { p := newDummyPeer("p") - // expect ping of peer p, but return error - m.On("Ping", p).Return(server.ErrTimeout).Times(NetworkMaxRetries + 1) - // ignore discoveryRequest calls - m.On("discoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() + // expect Ping of peer p, but return error + m.On("Ping", p).Return(server.ErrTimeout).Times(1) + // ignore DiscoveryRequest calls + m.On("DiscoveryRequest", mock.Anything).Return([]*peer.Peer{}, nil).Maybe() // let the manager initialize time.Sleep(graceTime) diff --git a/packages/autopeering/discover/protocol.go b/packages/autopeering/discover/protocol.go index 3cbe49361e..8fbda7d714 100644 --- a/packages/autopeering/discover/protocol.go +++ b/packages/autopeering/discover/protocol.go @@ -2,6 +2,7 @@ package discover import ( "bytes" + "errors" "fmt" "sync" "time" @@ -12,9 +13,19 @@ import ( peerpb "github.com/iotaledger/goshimmer/packages/autopeering/peer/proto" "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/autopeering/server" + "github.com/iotaledger/hive.go/backoff" "github.com/iotaledger/hive.go/logger" ) +const ( + maxRetries = 2 + logSends = true +) + +// policy for retrying failed network calls +var retryPolicy = backoff.ExponentialBackOff(500*time.Millisecond, 1.5).With( + backoff.Jitter(0.5), backoff.MaxRetries(maxRetries)) + // The Protocol handles the peer discovery. // It responds to incoming messages and sends own requests when needed. type Protocol struct { @@ -39,19 +50,12 @@ func New(local *peer.Local, cfg Config) *Protocol { return p } -// local returns the associated local peer of the neighbor selection. -func (p *Protocol) local() *peer.Local { - return p.loc -} - // Start starts the actual peer discovery over the provided Sender. func (p *Protocol) Start(s server.Sender) { p.Protocol.Sender = s p.mgr.start() - p.log.Debugw("discover started", - "addr", s.LocalAddr(), - ) + p.log.Debug("discover started") } // Close finalizes the protocol. @@ -66,14 +70,17 @@ func (p *Protocol) IsVerified(id peer.ID, addr string) bool { return time.Since(p.loc.Database().LastPong(id, addr)) < PingExpiration } -// EnsureVerified checks if the given peer has recently sent a ping; -// if not, we send a ping to trigger a verification. -func (p *Protocol) EnsureVerified(peer *peer.Peer) { +// EnsureVerified checks if the given peer has recently sent a Ping; +// if not, we send a Ping to trigger a verification. +func (p *Protocol) EnsureVerified(peer *peer.Peer) error { if !p.hasVerified(peer.ID(), peer.Address()) { - <-p.sendPing(peer.Address(), peer.ID()) - // Wait for them to ping back and process our pong + if err := p.Ping(peer); err != nil { + return err + } + // Wait for them to Ping back and process our pong time.Sleep(server.ResponseTimeout) } + return nil } // GetVerifiedPeer returns the verified peer with the given ID, or nil if no such peer exists. @@ -106,7 +113,7 @@ func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer. if err := proto.Unmarshal(data[1:], m); err != nil { return true, fmt.Errorf("invalid message: %w", err) } - if p.validatePing(s, fromAddr, m) { + if p.validatePing(fromAddr, m) { p.handlePing(s, fromAddr, fromID, fromKey, data) } @@ -126,7 +133,7 @@ func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer. if err := proto.Unmarshal(data[1:], m); err != nil { return true, fmt.Errorf("invalid message: %w", err) } - if p.validateDiscoveryRequest(s, fromAddr, fromID, m) { + if p.validateDiscoveryRequest(fromAddr, fromID, m) { p.handleDiscoveryRequest(s, fromAddr, data) } @@ -146,17 +153,33 @@ func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer. return true, nil } +// local returns the associated local peer of the neighbor selection. +func (p *Protocol) local() *peer.Local { + return p.loc +} + +// publicAddr returns the public address of the peering service in string representation. +func (p *Protocol) publicAddr() string { + return p.loc.Services().Get(service.PeeringKey).String() +} + // ------ message senders ------ -// ping sends a ping to the specified peer and blocks until a reply is received or timeout. +// Ping sends a Ping to the specified peer and blocks until a reply is received or timeout. func (p *Protocol) Ping(to *peer.Peer) error { - return <-p.sendPing(to.Address(), to.ID()) + return backoff.Retry(retryPolicy, func() error { + err := <-p.sendPing(to.Address(), to.ID()) + if err != nil && !errors.Is(err, server.ErrTimeout) { + return backoff.Permanent(err) + } + return err + }) } -// sendPing sends a ping to the specified address and expects a matching reply. +// sendPing sends a Ping to the specified address and expects a matching reply. // This method is non-blocking, but it returns a channel that can be used to query potential errors. func (p *Protocol) sendPing(toAddr string, toID peer.ID) <-chan error { - ping := newPing(p.LocalAddr(), toAddr) + ping := newPing(p.publicAddr(), toAddr) data := marshal(ping) // compute the message hash @@ -165,48 +188,48 @@ func (p *Protocol) sendPing(toAddr string, toID peer.ID) <-chan error { return bytes.Equal(m.(*pb.Pong).GetPingHash(), hash) } - // expect a pong referencing the ping we are about to send - p.log.Debugw("send message", "type", ping.Name(), "addr", toAddr) - errc := p.Protocol.SendExpectingReply(toAddr, toID, data, pb.MPong, hashEqual) - - return errc + p.logSend(toAddr, ping) + return p.Protocol.SendExpectingReply(toAddr, toID, data, pb.MPong, hashEqual) } -// discoveryRequest request known peers from the given target. This method blocks +// DiscoveryRequest request known peers from the given target. This method blocks // until a response is received and the provided peers are returned. -func (p *Protocol) discoveryRequest(to *peer.Peer) ([]*peer.Peer, error) { - p.EnsureVerified(to) +func (p *Protocol) DiscoveryRequest(to *peer.Peer) ([]*peer.Peer, error) { + if err := p.EnsureVerified(to); err != nil { + return nil, err + } - // create the request package - toAddr := to.Address() - req := newDiscoveryRequest(toAddr) + req := newDiscoveryRequest(to.Address()) data := marshal(req) // compute the message hash hash := server.PacketHash(data) - peers := make([]*peer.Peer, 0, MaxPeersInResponse) - p.log.Debugw("send message", "type", req.Name(), "addr", toAddr) - errc := p.Protocol.SendExpectingReply(toAddr, to.ID(), data, pb.MDiscoveryResponse, func(m interface{}) bool { + peers := make([]*peer.Peer, 0, MaxPeersInResponse) + callback := func(m interface{}) bool { res := m.(*pb.DiscoveryResponse) if !bytes.Equal(res.GetReqHash(), hash) { return false } - for _, rp := range res.GetPeers() { - peer, err := peer.FromProto(rp) - if err != nil { - p.log.Warnw("invalid peer received", "err", err) - continue + peers = peers[:0] + for _, protoPeer := range res.GetPeers() { + if p, _ := peer.FromProto(protoPeer); p != nil { + peers = append(peers, p) } - peers = append(peers, peer) } - return true - }) + } - // wait for the response and then return peers - return peers, <-errc + err := backoff.Retry(retryPolicy, func() error { + p.logSend(to.Address(), req) + err := <-p.Protocol.SendExpectingReply(to.Address(), to.ID(), data, pb.MDiscoveryResponse, callback) + if err != nil && !errors.Is(err, server.ErrTimeout) { + return backoff.Permanent(err) + } + return err + }) + return peers, err } // ------ helper functions ------ @@ -216,6 +239,12 @@ func (p *Protocol) hasVerified(id peer.ID, addr string) bool { return time.Since(p.loc.Database().LastPing(id, addr)) < PingExpiration } +func (p *Protocol) logSend(toAddr string, msg pb.Message) { + if logSends { + p.log.Debugw("send message", "type", msg.Name(), "addr", toAddr) + } +} + func marshal(msg pb.Message) []byte { mType := msg.Type() if mType > 0xFF { @@ -229,15 +258,15 @@ func marshal(msg pb.Message) []byte { return append([]byte{byte(mType)}, data...) } -// createDiscoverPeer creates a new peer that only has a peering service at the given address. -func createDiscoverPeer(key peer.PublicKey, network string, address string) *peer.Peer { +// newPeer creates a new peer that only has a peering service at the given address. +func newPeer(key peer.PublicKey, network string, address string) *peer.Peer { services := service.New() services.Update(service.PeeringKey, network, address) return peer.NewPeer(key, services) } -// ------ Packet Constructors ------ +// ------ Message Constructors ------ func newPing(fromAddr string, toAddr string) *pb.Ping { return &pb.Ping{ @@ -274,9 +303,9 @@ func newDiscoveryResponse(reqData []byte, list []*peer.Peer) *pb.DiscoveryRespon } } -// ------ Packet Handlers ------ +// ------ Message Handlers ------ -func (p *Protocol) validatePing(s *server.Server, fromAddr string, m *pb.Ping) bool { +func (p *Protocol) validatePing(fromAddr string, m *pb.Ping) bool { // check version number if m.GetVersion() != VersionNum { p.log.Debugw("invalid message", @@ -296,11 +325,11 @@ func (p *Protocol) validatePing(s *server.Server, fromAddr string, m *pb.Ping) b return false } // check that To matches the local address - if m.GetTo() != s.LocalAddr() { + if m.GetTo() != p.publicAddr() { p.log.Debugw("invalid message", "type", m.Name(), "to", m.GetTo(), - "want", s.LocalAddr(), + "want", p.publicAddr(), ) return false } @@ -322,36 +351,32 @@ func (p *Protocol) validatePing(s *server.Server, fromAddr string, m *pb.Ping) b func (p *Protocol) handlePing(s *server.Server, fromAddr string, fromID peer.ID, fromKey peer.PublicKey, rawData []byte) { // create and send the pong response - pong := newPong(fromAddr, rawData, s.Local().Services().CreateRecord()) + pong := newPong(fromAddr, rawData, p.loc.Services().CreateRecord()) - p.log.Debugw("send message", - "type", pong.Name(), - "addr", fromAddr, - ) + p.logSend(fromAddr, pong) s.Send(fromAddr, marshal(pong)) - // if the peer is new or expired, send a ping to verify + // if the peer is new or expired, send a Ping to verify if !p.IsVerified(fromID, fromAddr) { p.sendPing(fromAddr, fromID) } else if !p.mgr.isKnown(fromID) { // add a discovered peer to the manager if it is new - peer := createDiscoverPeer(fromKey, p.LocalNetwork(), fromAddr) - p.mgr.addDiscoveredPeer(peer) + p.mgr.addDiscoveredPeer(newPeer(fromKey, s.LocalAddr().Network(), fromAddr)) } - _ = p.local().Database().UpdateLastPing(fromID, fromAddr, time.Now()) + _ = p.loc.Database().UpdateLastPing(fromID, fromAddr, time.Now()) } func (p *Protocol) validatePong(s *server.Server, fromAddr string, fromID peer.ID, m *pb.Pong) bool { // check that To matches the local address - if m.GetTo() != s.LocalAddr() { + if m.GetTo() != p.publicAddr() { p.log.Debugw("invalid message", "type", m.Name(), "to", m.GetTo(), - "want", s.LocalAddr(), + "want", p.publicAddr(), ) return false } - // there must be a ping waiting for this pong as a reply + // there must be a Ping waiting for this pong as a reply if !s.IsExpectedReply(fromAddr, fromID, m.Type(), m) { p.log.Debugw("invalid message", "type", m.Name(), @@ -391,18 +416,18 @@ func (p *Protocol) handlePong(fromAddr string, fromID peer.ID, fromKey peer.Publ p.mgr.addVerifiedPeer(from) // update peer database - db := p.local().Database() + db := p.loc.Database() _ = db.UpdateLastPong(fromID, fromAddr, time.Now()) _ = db.UpdatePeer(from) } -func (p *Protocol) validateDiscoveryRequest(s *server.Server, fromAddr string, fromID peer.ID, m *pb.DiscoveryRequest) bool { +func (p *Protocol) validateDiscoveryRequest(fromAddr string, fromID peer.ID, m *pb.DiscoveryRequest) bool { // check that To matches the local address - if m.GetTo() != s.LocalAddr() { + if m.GetTo() != p.publicAddr() { p.log.Debugw("invalid message", "type", m.Name(), "to", m.GetTo(), - "want", s.LocalAddr(), + "want", p.publicAddr(), ) return false } @@ -435,10 +460,7 @@ func (p *Protocol) handleDiscoveryRequest(s *server.Server, fromAddr string, raw peers := p.mgr.getRandomPeers(MaxPeersInResponse, 1) res := newDiscoveryResponse(rawData, peers) - p.log.Debugw("send message", - "type", res.Name(), - "addr", fromAddr, - ) + p.logSend(fromAddr, res) s.Send(fromAddr, marshal(res)) } diff --git a/packages/autopeering/discover/protocol_test.go b/packages/autopeering/discover/protocol_test.go index 7a98bec242..fd294f7bca 100644 --- a/packages/autopeering/discover/protocol_test.go +++ b/packages/autopeering/discover/protocol_test.go @@ -87,11 +87,11 @@ func TestProtPingPong(t *testing.T) { peerA := getPeer(srvA) peerB := getPeer(srvB) - // send a ping from node A to B + // send a Ping from node A to B t.Run("A->B", func(t *testing.T) { assert.NoError(t, protA.Ping(peerB)) }) time.Sleep(graceTime) - // send a ping from node B to A + // send a Ping from node B to A t.Run("B->A", func(t *testing.T) { assert.NoError(t, protB.Ping(peerA)) }) time.Sleep(graceTime) } @@ -107,7 +107,7 @@ func TestProtPingTimeout(t *testing.T) { peerB := getPeer(srvB) - // send a ping from node A to B + // send a Ping from node A to B err := protA.Ping(peerB) assert.EqualError(t, err, server.ErrTimeout.Error()) } @@ -123,7 +123,7 @@ func TestProtVerifiedPeers(t *testing.T) { peerB := getPeer(srvB) - // send a ping from node A to B + // send a Ping from node A to B assert.NoError(t, protA.Ping(peerB)) time.Sleep(graceTime) @@ -146,7 +146,7 @@ func TestProtVerifiedPeer(t *testing.T) { peerA := getPeer(srvA) peerB := getPeer(srvB) - // send a ping from node A to B + // send a Ping from node A to B assert.NoError(t, protA.Ping(peerB)) time.Sleep(graceTime) @@ -172,13 +172,13 @@ func TestProtDiscoveryRequest(t *testing.T) { // request peers from node A t.Run("A->B", func(t *testing.T) { - if ps, err := protA.discoveryRequest(peerB); assert.NoError(t, err) { + if ps, err := protA.DiscoveryRequest(peerB); assert.NoError(t, err) { assert.ElementsMatch(t, []*peer.Peer{peerA}, ps) } }) // request peers from node B t.Run("B->A", func(t *testing.T) { - if ps, err := protB.discoveryRequest(peerA); assert.NoError(t, err) { + if ps, err := protB.DiscoveryRequest(peerA); assert.NoError(t, err) { assert.ElementsMatch(t, []*peer.Peer{peerB}, ps) } }) @@ -246,14 +246,14 @@ func BenchmarkPingPong(b *testing.B) { peerB := getPeer(srvB) - // send initial ping to ensure that every peer is verified + // send initial Ping to ensure that every peer is verified err := protA.Ping(peerB) require.NoError(b, err) time.Sleep(graceTime) b.ResetTimer() for n := 0; n < b.N; n++ { - // send a ping from node A to B + // send a Ping from node A to B _ = protA.Ping(peerB) } @@ -276,14 +276,14 @@ func BenchmarkDiscoveryRequest(b *testing.B) { peerB := getPeer(srvB) - // send initial request to ensure that every peer is verified - _, err := protA.discoveryRequest(peerB) + // send initial DiscoveryRequest to ensure that every peer is verified + _, err := protA.DiscoveryRequest(peerB) require.NoError(b, err) time.Sleep(graceTime) b.ResetTimer() for n := 0; n < b.N; n++ { - _, _ = protA.discoveryRequest(peerB) + _, _ = protA.DiscoveryRequest(peerB) } b.StopTimer() diff --git a/packages/autopeering/discover/query_strat.go b/packages/autopeering/discover/query_strat.go index 80247c54e4..0f70a6ba2a 100644 --- a/packages/autopeering/discover/query_strat.go +++ b/packages/autopeering/discover/query_strat.go @@ -5,10 +5,6 @@ import ( "math/rand" "sync" "time" - - "github.com/iotaledger/goshimmer/packages/autopeering/peer" - "github.com/iotaledger/goshimmer/packages/autopeering/server" - "github.com/iotaledger/hive.go/backoff" ) // doQuery is the main method of the query strategy. @@ -38,16 +34,7 @@ func (m *manager) doQuery(next chan<- time.Duration) { func (m *manager) requestWorker(p *mpeer, wg *sync.WaitGroup) { defer wg.Done() - var peers []*peer.Peer - err := backoff.Retry(networkRetryPolicy, func() error { - var err error - peers, err = m.net.discoveryRequest(unwrapPeer(p)) - if err != nil && err != server.ErrTimeout { - return backoff.Permanent(err) - } - return err - }) - + peers, err := m.net.DiscoveryRequest(unwrapPeer(p)) if err != nil || len(peers) == 0 { p.lastNewPeers = 0 diff --git a/packages/autopeering/selection/manager.go b/packages/autopeering/selection/manager.go index 0ac30f101d..ae58fd5359 100644 --- a/packages/autopeering/selection/manager.go +++ b/packages/autopeering/selection/manager.go @@ -22,8 +22,8 @@ const ( type network interface { local() *peer.Local - RequestPeering(*peer.Peer, *salt.Salt) (bool, error) - SendPeeringDrop(*peer.Peer) + PeeringRequest(*peer.Peer, *salt.Salt) (bool, error) + PeeringDrop(*peer.Peer) } type peeringRequest struct { @@ -230,8 +230,7 @@ func (m *manager) updateOutbound(resultChan chan<- peer.PeerDistance) { return } - // send peering request - status, err := m.net.RequestPeering(candidate.Remote, m.getPublicSalt()) + status, err := m.net.PeeringRequest(candidate.Remote, m.getPublicSalt()) if err != nil { m.rejectionFilter.AddPeer(candidate.Remote.ID()) m.log.Debugw("error requesting peering", @@ -317,7 +316,7 @@ func (m *manager) dropNeighborhood(nh *Neighborhood) { // dropPeering sends the peering drop over the network and triggers the corresponding event. func (m *manager) dropPeering(p *peer.Peer) { - m.net.SendPeeringDrop(p) + m.net.PeeringDrop(p) m.log.Debugw("peering dropped", "id", p.ID(), diff --git a/packages/autopeering/selection/manager_test.go b/packages/autopeering/selection/manager_test.go index 15e472a20c..af24ee4161 100644 --- a/packages/autopeering/selection/manager_test.go +++ b/packages/autopeering/selection/manager_test.go @@ -197,11 +197,11 @@ func (n *networkMock) local() *peer.Local { return n.loc } -func (n *networkMock) SendPeeringDrop(p *peer.Peer) { +func (n *networkMock) PeeringDrop(p *peer.Peer) { n.mgr[p.ID()].removeNeighbor(n.local().ID()) } -func (n *networkMock) RequestPeering(p *peer.Peer, s *salt.Salt) (bool, error) { +func (n *networkMock) PeeringRequest(p *peer.Peer, s *salt.Salt) (bool, error) { return n.mgr[p.ID()].requestPeering(&n.local().Peer, s), nil } diff --git a/packages/autopeering/selection/protocol.go b/packages/autopeering/selection/protocol.go index f82697afd8..61ad178d8b 100644 --- a/packages/autopeering/selection/protocol.go +++ b/packages/autopeering/selection/protocol.go @@ -2,22 +2,34 @@ package selection import ( "bytes" + "errors" "fmt" "sync" "time" "github.com/golang/protobuf/proto" "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/autopeering/salt" pb "github.com/iotaledger/goshimmer/packages/autopeering/selection/proto" "github.com/iotaledger/goshimmer/packages/autopeering/server" + "github.com/iotaledger/hive.go/backoff" "github.com/iotaledger/hive.go/logger" ) +const ( + maxRetries = 2 + logSends = true +) + +// policy for retrying failed network calls +var retryPolicy = backoff.ExponentialBackOff(500*time.Millisecond, 1.5).With( + backoff.Jitter(0.5), backoff.MaxRetries(maxRetries)) + // DiscoverProtocol specifies the methods from the peer discovery that are required. type DiscoverProtocol interface { IsVerified(id peer.ID, addr string) bool - EnsureVerified(*peer.Peer) + EnsureVerified(*peer.Peer) error GetVerifiedPeer(id peer.ID, addr string) *peer.Peer GetVerifiedPeers() []*peer.Peer @@ -49,19 +61,12 @@ func New(local *peer.Local, disc DiscoverProtocol, cfg Config) *Protocol { return p } -// Local returns the associated local peer of the neighbor selection. -func (p *Protocol) local() *peer.Local { - return p.loc -} - // Start starts the actual neighbor selection over the provided Sender. func (p *Protocol) Start(s server.Sender) { p.Protocol.Sender = s p.mgr.start() - p.log.Debugw("neighborhood started", - "addr", s.LocalAddr(), - ) + p.log.Debug("neighborhood started") } // Close finalizes the protocol. @@ -94,7 +99,7 @@ func (p *Protocol) RemoveNeighbor(id peer.ID) { } // HandleMessage responds to incoming neighbor selection messages. -func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer.ID, fromKey peer.PublicKey, data []byte) (bool, error) { +func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer.ID, _ peer.PublicKey, data []byte) (bool, error) { switch pb.MType(data[0]) { // PeeringRequest @@ -103,7 +108,7 @@ func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer. if err := proto.Unmarshal(data[1:], m); err != nil { return true, fmt.Errorf("invalid message: %w", err) } - if p.validatePeeringRequest(s, fromAddr, fromID, m) { + if p.validatePeeringRequest(fromAddr, fromID, m) { p.handlePeeringRequest(s, fromAddr, fromID, data, m) } @@ -122,7 +127,7 @@ func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer. if err := proto.Unmarshal(data[1:], m); err != nil { return true, fmt.Errorf("invalid message: %w", err) } - if p.validatePeeringDrop(s, fromAddr, m) { + if p.validatePeeringDrop(fromAddr, m) { p.handlePeeringDrop(fromID) } @@ -133,12 +138,24 @@ func (p *Protocol) HandleMessage(s *server.Server, fromAddr string, fromID peer. return true, nil } +// Local returns the associated local peer of the neighbor selection. +func (p *Protocol) local() *peer.Local { + return p.loc +} + +// publicAddr returns the public address of the peering service in string representation. +func (p *Protocol) publicAddr() string { + return p.loc.Services().Get(service.PeeringKey).String() +} + // ------ message senders ------ -// RequestPeering sends a peering request to the given peer. This method blocks +// PeeringRequest sends a PeeringRequest to the given peer. This method blocks // until a response is received and the status answer is returned. -func (p *Protocol) RequestPeering(to *peer.Peer, salt *salt.Salt) (bool, error) { - p.disc.EnsureVerified(to) +func (p *Protocol) PeeringRequest(to *peer.Peer, salt *salt.Salt) (bool, error) { + if err := p.disc.EnsureVerified(to); err != nil { + return false, err + } // create the request package toAddr := to.Address() @@ -158,29 +175,33 @@ func (p *Protocol) RequestPeering(to *peer.Peer, salt *salt.Salt) (bool, error) return true } - p.log.Debugw("send message", - "type", req.Name(), - "addr", toAddr, - ) - err := <-p.Protocol.SendExpectingReply(toAddr, to.ID(), data, pb.MPeeringResponse, callback) - + err := backoff.Retry(retryPolicy, func() error { + p.logSend(toAddr, req) + err := <-p.Protocol.SendExpectingReply(toAddr, to.ID(), data, pb.MPeeringResponse, callback) + if err != nil && !errors.Is(err, server.ErrTimeout) { + return backoff.Permanent(err) + } + return err + }) return status, err } -// SendPeeringDrop sends a peering drop to the given peer and does not wait for any responses. -func (p *Protocol) SendPeeringDrop(to *peer.Peer) { - toAddr := to.Address() - drop := newPeeringDrop(toAddr) +// PeeringDrop sends a peering drop message to the given peer, non-blocking and does not wait for any responses. +func (p *Protocol) PeeringDrop(to *peer.Peer) { + drop := newPeeringDrop(to.Address()) - p.log.Debugw("send message", - "type", drop.Name(), - "addr", toAddr, - ) + p.logSend(to.Address(), drop) p.Protocol.Send(to, marshal(drop)) } // ------ helper functions ------ +func (p *Protocol) logSend(toAddr string, msg pb.Message) { + if logSends { + p.log.Debugw("send message", "type", msg.Name(), "addr", toAddr) + } +} + func marshal(msg pb.Message) []byte { mType := msg.Type() if mType > 0xFF { @@ -194,7 +215,7 @@ func marshal(msg pb.Message) []byte { return append([]byte{byte(mType)}, data...) } -// ------ Packet Constructors ------ +// ------ Message Constructors ------ func newPeeringRequest(toAddr string, salt *salt.Salt) *pb.PeeringRequest { return &pb.PeeringRequest{ @@ -220,12 +241,13 @@ func newPeeringDrop(toAddr string) *pb.PeeringDrop { // ------ Packet Handlers ------ -func (p *Protocol) validatePeeringRequest(s *server.Server, fromAddr string, fromID peer.ID, m *pb.PeeringRequest) bool { +func (p *Protocol) validatePeeringRequest(fromAddr string, fromID peer.ID, m *pb.PeeringRequest) bool { // check that To matches the local address - if m.GetTo() != s.LocalAddr() { + if m.GetTo() != p.publicAddr() { p.log.Debugw("invalid message", "type", m.Name(), "to", m.GetTo(), + "want", p.publicAddr(), ) return false } @@ -246,7 +268,7 @@ func (p *Protocol) validatePeeringRequest(s *server.Server, fromAddr string, fro return false } // check Salt - salt, err := salt.FromProto(m.GetSalt()) + s, err := salt.FromProto(m.GetSalt()) if err != nil { p.log.Debugw("invalid message", "type", m.Name(), @@ -255,10 +277,10 @@ func (p *Protocol) validatePeeringRequest(s *server.Server, fromAddr string, fro return false } // check salt expiration - if salt.Expired() { + if s.Expired() { p.log.Debugw("invalid message", "type", m.Name(), - "salt.expiration", salt.GetExpiration(), + "salt.expiration", s.GetExpiration(), ) return false } @@ -289,10 +311,7 @@ func (p *Protocol) handlePeeringRequest(s *server.Server, fromAddr string, fromI res := newPeeringResponse(rawData, p.mgr.requestPeering(from, salt)) - p.log.Debugw("send message", - "type", res.Name(), - "addr", fromAddr, - ) + p.logSend(fromAddr, res) s.Send(fromAddr, marshal(res)) } @@ -313,12 +332,13 @@ func (p *Protocol) validatePeeringResponse(s *server.Server, fromAddr string, fr return true } -func (p *Protocol) validatePeeringDrop(s *server.Server, fromAddr string, m *pb.PeeringDrop) bool { +func (p *Protocol) validatePeeringDrop(fromAddr string, m *pb.PeeringDrop) bool { // check that To matches the local address - if m.GetTo() != s.LocalAddr() { + if m.GetTo() != p.publicAddr() { p.log.Debugw("invalid message", "type", m.Name(), "to", m.GetTo(), + "want", p.publicAddr(), ) return false } diff --git a/packages/autopeering/selection/protocol_test.go b/packages/autopeering/selection/protocol_test.go index d43820f87d..ce6e59e1ba 100644 --- a/packages/autopeering/selection/protocol_test.go +++ b/packages/autopeering/selection/protocol_test.go @@ -24,7 +24,7 @@ var peerMap = make(map[peer.ID]*peer.Peer) type dummyDiscovery struct{} func (d dummyDiscovery) IsVerified(peer.ID, string) bool { return true } -func (d dummyDiscovery) EnsureVerified(*peer.Peer) {} +func (d dummyDiscovery) EnsureVerified(*peer.Peer) error { return nil } func (d dummyDiscovery) GetVerifiedPeer(id peer.ID, _ string) *peer.Peer { return peerMap[id] } func (d dummyDiscovery) GetVerifiedPeers() []*peer.Peer { return []*peer.Peer{} } @@ -77,13 +77,13 @@ func TestProtocol(t *testing.T) { // request peering to peer B t.Run("A->B", func(t *testing.T) { - if services, err := protA.RequestPeering(peerB, saltA); assert.NoError(t, err) { + if services, err := protA.PeeringRequest(peerB, saltA); assert.NoError(t, err) { assert.NotEmpty(t, services) } }) // request peering to peer A t.Run("B->A", func(t *testing.T) { - if services, err := protB.RequestPeering(peerA, saltB); assert.NoError(t, err) { + if services, err := protB.PeeringRequest(peerA, saltB); assert.NoError(t, err) { assert.NotEmpty(t, services) } }) @@ -102,7 +102,7 @@ func TestProtocol(t *testing.T) { peerB := getPeer(srvB) // request peering to peer B - _, err := protA.RequestPeering(peerB, saltA) + _, err := protA.PeeringRequest(peerB, saltA) assert.EqualError(t, err, server.ErrTimeout.Error()) }) @@ -120,14 +120,14 @@ func TestProtocol(t *testing.T) { peerB := getPeer(srvB) // request peering to peer B - services, err := protA.RequestPeering(peerB, saltA) + services, err := protA.PeeringRequest(peerB, saltA) require.NoError(t, err) assert.NotEmpty(t, services) require.Contains(t, protB.GetNeighbors(), peerA) // drop peer A - protA.SendPeeringDrop(peerB) + protA.PeeringDrop(peerB) time.Sleep(graceTime) require.NotContains(t, protB.GetNeighbors(), peerA) }) diff --git a/packages/autopeering/selection/selection.go b/packages/autopeering/selection/selection.go index f97acbdbb3..66183f2461 100644 --- a/packages/autopeering/selection/selection.go +++ b/packages/autopeering/selection/selection.go @@ -24,9 +24,9 @@ func NewFilter() *Filter { func (f *Filter) Apply(list []peer.PeerDistance) (filteredList []peer.PeerDistance) { f.lock.RLock() defer f.lock.RUnlock() - for _, peer := range list { - if !f.internal[peer.Remote.ID()] { - filteredList = append(filteredList, peer) + for _, p := range list { + if !f.internal[p.Remote.ID()] { + filteredList = append(filteredList, p) } } return filteredList @@ -36,11 +36,11 @@ func (f *Filter) PushBack(list []peer.PeerDistance) (filteredList []peer.PeerDis var head, tail []peer.PeerDistance f.lock.RLock() defer f.lock.RUnlock() - for _, peer := range list { - if f.internal[peer.Remote.ID()] { - tail = append(tail, peer) + for _, p := range list { + if f.internal[p.Remote.ID()] { + tail = append(tail, p) } else { - head = append(head, peer) + head = append(head, p) } } return append(head, tail...) @@ -48,8 +48,8 @@ func (f *Filter) PushBack(list []peer.PeerDistance) (filteredList []peer.PeerDis func (f *Filter) AddPeers(n []*peer.Peer) { f.lock.Lock() - for _, peer := range n { - f.internal[peer.ID()] = true + for _, p := range n { + f.internal[p.ID()] = true } f.lock.Unlock() } diff --git a/packages/autopeering/server/common.go b/packages/autopeering/server/common.go index 4defddc2db..593d916b1f 100644 --- a/packages/autopeering/server/common.go +++ b/packages/autopeering/server/common.go @@ -11,9 +11,6 @@ type MType uint // The Sender interface specifies common method required to send requests. type Sender interface { - LocalAddr() string - LocalNetwork() string - Send(toAddr string, data []byte) SendExpectingReply(toAddr string, toID peer.ID, data []byte, replyType MType, callback func(interface{}) bool) <-chan error } diff --git a/packages/autopeering/server/protocol.go b/packages/autopeering/server/protocol.go index bab76b712f..e3ef6a622e 100644 --- a/packages/autopeering/server/protocol.go +++ b/packages/autopeering/server/protocol.go @@ -15,16 +15,6 @@ type Protocol struct { Sender Sender // interface to send own requests } -// LocalAddr returns the local network address in string form. -func (p *Protocol) LocalAddr() string { - return p.Sender.LocalAddr() -} - -// LocalNetwork returns the name of the local network (for example, "tcp", "udp"). -func (p *Protocol) LocalNetwork() string { - return p.Sender.LocalNetwork() -} - // Send sends the data to the given peer. func (p *Protocol) Send(to *peer.Peer, data []byte) { p.Sender.Send(to.Address(), data) diff --git a/packages/autopeering/server/server.go b/packages/autopeering/server/server.go index 74d1bfbda4..88ca6cc55d 100644 --- a/packages/autopeering/server/server.go +++ b/packages/autopeering/server/server.go @@ -4,6 +4,7 @@ import ( "container/list" "fmt" "io" + "net" "sync" "time" @@ -87,6 +88,8 @@ func Listen(local *peer.Local, t transport.Transport, log *logger.Logger, h ...H go srv.replyLoop() go srv.readLoop() + log.Debugw("server started", "addr", srv.LocalAddr(), "#handlers", len(h)) + return srv } @@ -104,14 +107,9 @@ func (s *Server) Local() *peer.Local { return s.local } -// LocalNetwork returns the network of the local peer. -func (s *Server) LocalNetwork() string { - return s.network -} - // LocalAddr returns the address of the local peer in string form. -func (s *Server) LocalAddr() string { - return s.address +func (s *Server) LocalAddr() net.Addr { + return s.trans.LocalAddr() } // Send sends a message to the given address diff --git a/packages/autopeering/server/server_test.go b/packages/autopeering/server/server_test.go index f3cff2c83e..58bc5a60e3 100644 --- a/packages/autopeering/server/server_test.go +++ b/packages/autopeering/server/server_test.go @@ -205,5 +205,5 @@ func TestUnexpectedPong(t *testing.T) { // there should never be a Ping.Handle // there should never be a Pong.Handle - srvA.Send(srvB.LocalAddr(), new(Pong).Marshal()) + srvA.Send(srvB.LocalAddr().String(), new(Pong).Marshal()) } diff --git a/packages/gossip/manager.go b/packages/gossip/manager.go index 683cd24c96..19933333c6 100644 --- a/packages/gossip/manager.go +++ b/packages/gossip/manager.go @@ -7,7 +7,6 @@ import ( "github.com/golang/protobuf/proto" "github.com/iotaledger/goshimmer/packages/autopeering/peer" - "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" pb "github.com/iotaledger/goshimmer/packages/gossip/proto" "github.com/iotaledger/goshimmer/packages/gossip/server" "github.com/iotaledger/hive.go/events" @@ -71,11 +70,6 @@ func (m *Manager) stop() { } } -// LocalAddr returns the public address of the gossip service. -func (m *Manager) LocalAddr() net.Addr { - return m.local.Services().Get(service.GossipKey) -} - // AddOutbound tries to add a neighbor by connecting to that peer. func (m *Manager) AddOutbound(p *peer.Peer) error { if p.ID() == m.local.ID() { diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 33fb047aa5..76c8122a6b 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -13,6 +13,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/selection" "github.com/iotaledger/goshimmer/packages/autopeering/server" "github.com/iotaledger/goshimmer/packages/autopeering/transport" + "github.com/iotaledger/goshimmer/packages/netutil" "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/cli" @@ -56,8 +57,9 @@ func configureAP() { func start(shutdownSignal <-chan struct{}) { defer log.Info("Stopping " + name + " ... done") - addr := local.GetInstance().Services().Get(service.PeeringKey) - udpAddr, err := net.ResolveUDPAddr(addr.Network(), addr.String()) + loc := local.GetInstance() + peeringAddr := loc.Services().Get(service.PeeringKey) + udpAddr, err := net.ResolveUDPAddr(peeringAddr.Network(), peeringAddr.String()) if err != nil { log.Fatalf("ResolveUDPAddr: %v", err) } @@ -71,7 +73,12 @@ func start(shutdownSignal <-chan struct{}) { } } - conn, err := net.ListenUDP(addr.Network(), udpAddr) + // check that discovery is working and the port is open + log.Info("Testing service ...") + checkConnection(udpAddr, &loc.Peer) + log.Info("Testing service ... done") + + conn, err := net.ListenUDP(peeringAddr.Network(), udpAddr) if err != nil { log.Fatalf("ListenUDP: %v", err) } @@ -86,26 +93,21 @@ func start(shutdownSignal <-chan struct{}) { } // start a server doing discovery and peering - srv := server.Listen(local.GetInstance(), trans, log.Named("srv"), handlers...) + srv := server.Listen(loc, trans, log.Named("srv"), handlers...) defer srv.Close() // start the discovery on that connection Discovery.Start(srv) defer Discovery.Close() - //check that discovery is working and the port is open - log.Info("Testing service ...") - checkConnection(srv, &local.GetInstance().Peer) - log.Info("Testing service ... done") - if Selection != nil { // start the peering on that connection Selection.Start(srv) defer Selection.Close() } - log.Infof(name+" started: address=%s/udp", srv.LocalAddr()) - log.Debugf(name+" server started: PubKey=%s", base64.StdEncoding.EncodeToString(local.GetInstance().PublicKey())) + log.Infof(name+" started: address=%s/%s", peeringAddr.String(), peeringAddr.Network()) + log.Debugf(name+" server started: PubKey=%s", base64.StdEncoding.EncodeToString(loc.PublicKey())) <-shutdownSignal log.Info("Stopping " + name + " ...") @@ -135,14 +137,18 @@ func parseEntryNodes() (result []*peer.Peer, err error) { return result, nil } -func checkConnection(srv *server.Server, self *peer.Peer) { - if err := Discovery.Ping(self); err != nil { - if err == server.ErrTimeout { - log.Errorf("Error testing service: %s", err) - addr := self.Services().Get(service.PeeringKey) - log.Panicf("Please check that %s is publicly reachable at %s/%s", - cli.AppName, addr.String(), addr.Network()) - } - log.Panicf("Error: %s", err) +func checkConnection(localAddr *net.UDPAddr, self *peer.Peer) { + peering := self.Services().Get(service.PeeringKey) + remoteAddr, err := net.ResolveUDPAddr(peering.Network(), peering.String()) + if err != nil { + panic(err) + } + + // do not check the address as a NAT may change them for local connections + err = netutil.CheckUDP(localAddr, remoteAddr, false, true) + if err != nil { + log.Errorf("Error testing service: %s", err) + log.Panicf("Please check that %s is publicly reachable at %s/%s", + cli.AppName, peering.String(), peering.Network()) } } diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index b6ea302a75..5a6904c5ac 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -44,7 +44,8 @@ func configureGossip() { func start(shutdownSignal <-chan struct{}) { defer log.Info("Stopping " + name + " ... done") - srv, err := server.ListenTCP(local.GetInstance(), log) + loc := local.GetInstance() + srv, err := server.ListenTCP(loc, log) if err != nil { log.Fatalf("ListenTCP: %v", err) } @@ -52,13 +53,14 @@ func start(shutdownSignal <-chan struct{}) { //check that the server is working and the port is open log.Info("Testing service ...") - checkConnection(srv, &local.GetInstance().Peer) + checkConnection(srv, &loc.Peer) log.Info("Testing service ... done") mgr.Start(srv) defer mgr.Close() - log.Infof(name+" started: address=%s/%s", mgr.LocalAddr().String(), mgr.LocalAddr().Network()) + gossipAddr := loc.Services().Get(service.GossipKey) + log.Infof(name+" started: address=%s/%s", gossipAddr.String(), gossipAddr.Network()) <-shutdownSignal log.Info("Stopping " + name + " ...") From 65a91713316286fd0a98cfe21c7eb93a4612e2f0 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Thu, 23 Jan 2020 13:37:50 +0100 Subject: [PATCH 136/184] removes sent counter as value from spammed transactions (#163) --- .../transactionspammer/transactionspammer.go | 33 ++++++++++++------- plugins/webapi/spammer/plugin.go | 2 +- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index dcfb1da1ed..67ba1fa87f 100644 --- a/packages/transactionspammer/transactionspammer.go +++ b/packages/transactionspammer/transactionspammer.go @@ -1,20 +1,22 @@ package transactionspammer import ( + "strings" "sync" "time" - "github.com/iotaledger/goshimmer/packages/shutdown" - "github.com/iotaledger/goshimmer/plugins/autopeering/local" - "github.com/iotaledger/goshimmer/packages/gossip" "github.com/iotaledger/goshimmer/packages/model/meta_transaction" "github.com/iotaledger/goshimmer/packages/model/value_transaction" + "github.com/iotaledger/goshimmer/packages/shutdown" + "github.com/iotaledger/goshimmer/plugins/autopeering/local" "github.com/iotaledger/goshimmer/plugins/tipselection" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/logger" ) +const logEveryNTransactions = 5000 + var log *logger.Logger var spamming = false @@ -23,14 +25,14 @@ var spammingMutex sync.Mutex var shutdownSignal chan struct{} var done chan struct{} -var sentCounter = uint(0) - func init() { shutdownSignal = make(chan struct{}) done = make(chan struct{}) } -func Start(tps uint) { +var targetAddress = strings.Repeat("SPAMMMMER", 9) + +func Start(tps uint64) { log = logger.NewLogger("Transaction Spammer") spammingMutex.Lock() spamming = true @@ -38,8 +40,11 @@ func Start(tps uint) { daemon.BackgroundWorker("Transaction Spammer", func(daemonShutdownSignal <-chan struct{}) { start := time.Now() - totalSentCounter := int64(0) + var totalSentCounter, currentSentCounter uint64 + + log.Infof("started spammer...will output sent count every %d transactions", logEveryNTransactions) + defer log.Infof("spammer stopped, spammed %d transactions", totalSentCounter) for { select { case <-daemonShutdownSignal: @@ -50,13 +55,13 @@ func Start(tps uint) { return default: - sentCounter++ + currentSentCounter++ totalSentCounter++ tx := value_transaction.New() tx.SetHead(true) tx.SetTail(true) - tx.SetValue(totalSentCounter) + tx.SetAddress(targetAddress) tx.SetBranchTransactionHash(tipselection.GetRandomTip()) tx.SetTrunkTransactionHash(tipselection.GetRandomTip()) tx.SetTimestamp(uint(time.Now().Unix())) @@ -67,7 +72,12 @@ func Start(tps uint) { gossip.Events.TransactionReceived.Trigger(&gossip.TransactionReceivedEvent{Data: tx.GetBytes(), Peer: &local.GetInstance().Peer}) - if sentCounter >= tps { + if totalSentCounter%logEveryNTransactions == 0 { + log.Infof("spammed %d transactions", totalSentCounter) + } + + // rate limit to the specified TPS + if currentSentCounter >= tps { duration := time.Since(start) if duration < time.Second { @@ -75,8 +85,7 @@ func Start(tps uint) { } start = time.Now() - - sentCounter = 0 + currentSentCounter = 0 } } } diff --git a/plugins/webapi/spammer/plugin.go b/plugins/webapi/spammer/plugin.go index 97b9056a44..fdc1aca338 100644 --- a/plugins/webapi/spammer/plugin.go +++ b/plugins/webapi/spammer/plugin.go @@ -61,5 +61,5 @@ type Response struct { type Request struct { Cmd string `json:"cmd"` - Tps uint `json:"tps"` + Tps uint64 `json:"tps"` } From 2b0e068960a15803074047fcca2b2363b206c0e6 Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 23 Jan 2020 12:58:24 +0000 Subject: [PATCH 137/184] :recycle: removes goshimmer error package --- tools/relay-checker/main.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/relay-checker/main.go b/tools/relay-checker/main.go index 189babf7ea..bde576c981 100644 --- a/tools/relay-checker/main.go +++ b/tools/relay-checker/main.go @@ -5,14 +5,13 @@ import ( "time" client "github.com/iotaledger/goshimmer/client" - "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/iota.go/trinary" ) func testBroadcastData(api *client.GoShimmerAPI) (trinary.Hash, error) { txnHash, err := api.BroadcastData(txnAddr, txnData) if err != nil { - return "", errors.Wrapf(err, "Broadcast failed") + return "", fmt.Errorf("%w: broadcast failed", err) } return txnHash, nil } @@ -21,7 +20,7 @@ func testTargetGetTransactions(api *client.GoShimmerAPI, txnHash trinary.Hash) e // query target node for broadcasted data _, err := api.GetTransactions([]trinary.Hash{txnHash}) if err != nil { - return errors.Wrapf(err, "Query target failed") + return fmt.Errorf("%w: query target failed", err) } return nil } @@ -32,7 +31,7 @@ func testNodesGetTransactions(txnHash trinary.Hash) error { nodesApi := client.NewGoShimmerAPI(n) _, err := nodesApi.GetTransactions([]trinary.Hash{txnHash}) if err != nil { - return errors.Wrapf(err, "Query %s failed", n) + return fmt.Errorf("%w: query %s failed", err, n) } fmt.Printf("txn found in %s\n", n) } From f1cb9270f625ec98bf5c013cf7356539e633a505 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Thu, 23 Jan 2020 14:08:46 +0100 Subject: [PATCH 138/184] renames webapi endpoints --- client/lib.go | 18 +++++++++--------- main.go | 12 ++++++------ .../plugin.go | 12 ++++++------ .../plugin.go | 12 ++++++------ .../plugin.go | 12 ++++++------ tools/relay-checker/main.go | 4 ++-- 6 files changed, 35 insertions(+), 35 deletions(-) rename plugins/webapi/{findTransactions => findTransactionHashes}/plugin.go (80%) rename plugins/webapi/{getTransactions => getTransactionObjectsByHash}/plugin.go (87%) rename plugins/webapi/{getTrytes => getTransactionTrytesByHash}/plugin.go (79%) diff --git a/client/lib.go b/client/lib.go index ed2884bab4..85084f5ae4 100644 --- a/client/lib.go +++ b/client/lib.go @@ -10,10 +10,10 @@ import ( "net/http" webapi_broadcastData "github.com/iotaledger/goshimmer/plugins/webapi/broadcastData" - webapi_findTransactions "github.com/iotaledger/goshimmer/plugins/webapi/findTransactions" + webapi_findTransactions "github.com/iotaledger/goshimmer/plugins/webapi/findTransactionHashes" webapi_getNeighbors "github.com/iotaledger/goshimmer/plugins/webapi/getNeighbors" - webapi_getTransactions "github.com/iotaledger/goshimmer/plugins/webapi/getTransactions" - webapi_getTrytes "github.com/iotaledger/goshimmer/plugins/webapi/getTrytes" + webapi_getTransactions "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionObjectsByHash" + webapi_getTrytes "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionTrytesByHash" webapi_gtta "github.com/iotaledger/goshimmer/plugins/webapi/gtta" webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi/spammer" "github.com/iotaledger/iota.go/consts" @@ -30,9 +30,9 @@ var ( const ( routeBroadcastData = "broadcastData" - routeGetTrytes = "getTrytes" - routeGetTransactions = "getTransactions" - routeFindTransactions = "findTransactions" + routeGetTrytes = "getTransactionTrytesByHash" + routeGetTransactions = "getTransactionObjectsByHash" + routeFindTransactions = "findTransactionHashes" routeGetNeighbors = "getNeighbors" routeGetTransactionsToApprove = "getTransactionsToApprove" routeSpammer = "spammer" @@ -107,7 +107,7 @@ func (api *GoShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data string return resObj.Hash, nil } -func (api *GoShimmerAPI) GetTrytes(txHashes trinary.Hashes) ([]trinary.Trytes, error) { +func (api *GoShimmerAPI) GetTransactionTrytesByHash(txHashes trinary.Hashes) ([]trinary.Trytes, error) { for _, hash := range txHashes { if !guards.IsTrytes(hash) { return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash) @@ -132,7 +132,7 @@ func (api *GoShimmerAPI) GetTrytes(txHashes trinary.Hashes) ([]trinary.Trytes, e return resObj.Trytes, nil } -func (api *GoShimmerAPI) GetTransactions(txHashes trinary.Hashes) ([]webapi_getTransactions.Transaction, error) { +func (api *GoShimmerAPI) GetTransactionObjectsByHash(txHashes trinary.Hashes) ([]webapi_getTransactions.Transaction, error) { for _, hash := range txHashes { if !guards.IsTrytes(hash) { return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash) @@ -157,7 +157,7 @@ func (api *GoShimmerAPI) GetTransactions(txHashes trinary.Hashes) ([]webapi_getT return resObj.Transactions, nil } -func (api *GoShimmerAPI) FindTransactions(query *webapi_findTransactions.Request) ([]trinary.Hashes, error) { +func (api *GoShimmerAPI) FindTransactionHashes(query *webapi_findTransactions.Request) ([]trinary.Hashes, error) { for _, hash := range query.Addresses { if !guards.IsTrytes(hash) { return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash) diff --git a/main.go b/main.go index f7d202d11a..319811df54 100644 --- a/main.go +++ b/main.go @@ -20,10 +20,10 @@ import ( "github.com/iotaledger/goshimmer/plugins/ui" "github.com/iotaledger/goshimmer/plugins/webapi" webapi_broadcastData "github.com/iotaledger/goshimmer/plugins/webapi/broadcastData" - webapi_findTransactions "github.com/iotaledger/goshimmer/plugins/webapi/findTransactions" + webapi_findTransactionHashes "github.com/iotaledger/goshimmer/plugins/webapi/findTransactionHashes" webapi_getNeighbors "github.com/iotaledger/goshimmer/plugins/webapi/getNeighbors" - webapi_getTransactions "github.com/iotaledger/goshimmer/plugins/webapi/getTransactions" - webapi_getTrytes "github.com/iotaledger/goshimmer/plugins/webapi/getTrytes" + webapi_getTransactionObjectsByHash "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionObjectsByHash" + webapi_getTransactionTrytesByHash "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionTrytesByHash" webapi_gtta "github.com/iotaledger/goshimmer/plugins/webapi/gtta" webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi/spammer" "github.com/iotaledger/goshimmer/plugins/webauth" @@ -57,9 +57,9 @@ func main() { webapi_gtta.PLUGIN, webapi_spammer.PLUGIN, webapi_broadcastData.PLUGIN, - webapi_getTrytes.PLUGIN, - webapi_getTransactions.PLUGIN, - webapi_findTransactions.PLUGIN, + webapi_getTransactionTrytesByHash.PLUGIN, + webapi_getTransactionObjectsByHash.PLUGIN, + webapi_findTransactionHashes.PLUGIN, webapi_getNeighbors.PLUGIN, webapi_spammer.PLUGIN, diff --git a/plugins/webapi/findTransactions/plugin.go b/plugins/webapi/findTransactionHashes/plugin.go similarity index 80% rename from plugins/webapi/findTransactions/plugin.go rename to plugins/webapi/findTransactionHashes/plugin.go index ff9b406ad2..07a626d9fc 100644 --- a/plugins/webapi/findTransactions/plugin.go +++ b/plugins/webapi/findTransactionHashes/plugin.go @@ -1,4 +1,4 @@ -package findTransactions +package findTransactionHashes import ( "net/http" @@ -11,19 +11,19 @@ import ( "github.com/labstack/echo" ) -var PLUGIN = node.NewPlugin("WebAPI findTransactions Endpoint", node.Enabled, configure) +var PLUGIN = node.NewPlugin("WebAPI findTransactionHashes Endpoint", node.Enabled, configure) var log *logger.Logger func configure(plugin *node.Plugin) { - log = logger.NewLogger("API-findTransactions") - webapi.Server.POST("findTransactions", findTransactions) + log = logger.NewLogger("API-findTransactionHashes") + webapi.Server.POST("findTransactionHashes", findTransactionHashes) } -// findTransactions returns the array of transaction hashes for the +// findTransactionHashes returns the array of transaction hashes for the // given addresses (in the same order as the parameters). // If a node doesn't have any transaction hash for a given address in its ledger, // the value at the index of that address is empty. -func findTransactions(c echo.Context) error { +func findTransactionHashes(c echo.Context) error { var request Request if err := c.Bind(&request); err != nil { diff --git a/plugins/webapi/getTransactions/plugin.go b/plugins/webapi/getTransactionObjectsByHash/plugin.go similarity index 87% rename from plugins/webapi/getTransactions/plugin.go rename to plugins/webapi/getTransactionObjectsByHash/plugin.go index 70c231328b..221def3cdb 100644 --- a/plugins/webapi/getTransactions/plugin.go +++ b/plugins/webapi/getTransactionObjectsByHash/plugin.go @@ -1,4 +1,4 @@ -package getTransactions +package getTransactionObjectsByHash import ( "net/http" @@ -11,19 +11,19 @@ import ( "github.com/labstack/echo" ) -var PLUGIN = node.NewPlugin("WebAPI getTransaction Endpoint", node.Enabled, configure) +var PLUGIN = node.NewPlugin("WebAPI getTransactionObjectsByHash Endpoint", node.Enabled, configure) var log *logger.Logger func configure(plugin *node.Plugin) { - log = logger.NewLogger("API-getTransactions") - webapi.Server.POST("getTransactions", getTransactions) + log = logger.NewLogger("API-getTransactionObjectsByHash") + webapi.Server.POST("getTransactionObjectsByHash", getTransactionObjectsByHash) } -// getTransactions returns the array of transactions for the +// getTransactionObjectsByHash returns the array of transactions for the // given transaction hashes (in the same order as the parameters). // If a node doesn't have the transaction for a given transaction hash in its ledger, // the value at the index of that transaction hash is empty. -func getTransactions(c echo.Context) error { +func getTransactionObjectsByHash(c echo.Context) error { var request Request result := []Transaction{} diff --git a/plugins/webapi/getTrytes/plugin.go b/plugins/webapi/getTransactionTrytesByHash/plugin.go similarity index 79% rename from plugins/webapi/getTrytes/plugin.go rename to plugins/webapi/getTransactionTrytesByHash/plugin.go index b29b83fa76..b4bb36136d 100644 --- a/plugins/webapi/getTrytes/plugin.go +++ b/plugins/webapi/getTransactionTrytesByHash/plugin.go @@ -1,4 +1,4 @@ -package getTrytes +package getTransactionTrytesByHash import ( "net/http" @@ -11,19 +11,19 @@ import ( "github.com/labstack/echo" ) -var PLUGIN = node.NewPlugin("WebAPI getTrytes Endpoint", node.Enabled, configure) +var PLUGIN = node.NewPlugin("WebAPI getTransactionTrytesByHash Endpoint", node.Enabled, configure) var log *logger.Logger func configure(plugin *node.Plugin) { - log = logger.NewLogger("API-getTrytes") - webapi.Server.GET("getTrytes", getTrytes) + log = logger.NewLogger("API-getTransactionTrytesByHash") + webapi.Server.GET("getTransactionTrytesByHash", getTransactionTrytesByHash) } -// getTrytes returns the array of transaction trytes for the +// getTransactionTrytesByHash returns the array of transaction trytes for the // given transaction hashes (in the same order as the parameters). // If a node doesn't have the trytes for a given transaction hash in its ledger, // the value at the index of that transaction hash is empty. -func getTrytes(c echo.Context) error { +func getTransactionTrytesByHash(c echo.Context) error { var request Request result := []trinary.Trytes{} diff --git a/tools/relay-checker/main.go b/tools/relay-checker/main.go index 189babf7ea..18c1d1d9b5 100644 --- a/tools/relay-checker/main.go +++ b/tools/relay-checker/main.go @@ -19,7 +19,7 @@ func testBroadcastData(api *client.GoShimmerAPI) (trinary.Hash, error) { func testTargetGetTransactions(api *client.GoShimmerAPI, txnHash trinary.Hash) error { // query target node for broadcasted data - _, err := api.GetTransactions([]trinary.Hash{txnHash}) + _, err := api.GetTransactionObjectsByHash([]trinary.Hash{txnHash}) if err != nil { return errors.Wrapf(err, "Query target failed") } @@ -30,7 +30,7 @@ func testNodesGetTransactions(txnHash trinary.Hash) error { // query nodes node for broadcasted data for _, n := range nodes { nodesApi := client.NewGoShimmerAPI(n) - _, err := nodesApi.GetTransactions([]trinary.Hash{txnHash}) + _, err := nodesApi.GetTransactionObjectsByHash([]trinary.Hash{txnHash}) if err != nil { return errors.Wrapf(err, "Query %s failed", n) } From d08572be91c311a24f7636ce29edab79dbfd0577 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Thu, 23 Jan 2020 14:12:42 +0100 Subject: [PATCH 139/184] adds bind address parameter for the web api --- config.json | 5 ++++- plugins/webapi/parameters.go | 13 +++++++++++++ plugins/webapi/plugin.go | 3 ++- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 plugins/webapi/parameters.go diff --git a/config.json b/config.json index e28d03a947..d5f7713c05 100644 --- a/config.json +++ b/config.json @@ -8,7 +8,7 @@ "entrynodes": [ "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626" ], - "port":14626 + "port": 14626 }, "database": { "directory": "mainnetdb" @@ -16,6 +16,9 @@ "gossip": { "port": 14666 }, + "webapi": { + "bindAddress": "0.0.0.0:8080" + }, "graph": { "webrootPath": "./IOTAtangle/webroot", "socketioPath": "./socket.io-client/dist/socket.io.js", diff --git a/plugins/webapi/parameters.go b/plugins/webapi/parameters.go new file mode 100644 index 0000000000..e5703ce31f --- /dev/null +++ b/plugins/webapi/parameters.go @@ -0,0 +1,13 @@ +package webapi + +import ( + flag "github.com/spf13/pflag" +) + +const ( + BIND_ADDRESS = "webapi.bindAddress" +) + +func init() { + flag.String(BIND_ADDRESS, "0.0.0.0:8080", "the bind address for the web API") +} diff --git a/plugins/webapi/plugin.go b/plugins/webapi/plugin.go index c7bd41f334..79365c8727 100644 --- a/plugins/webapi/plugin.go +++ b/plugins/webapi/plugin.go @@ -4,6 +4,7 @@ import ( "context" "time" + "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/logger" @@ -30,7 +31,7 @@ func run(plugin *node.Plugin) { log.Info("Starting Web Server ... done") go func() { - if err := Server.Start(":8080"); err != nil { + if err := Server.Start(parameter.NodeConfig.GetString(BIND_ADDRESS)); err != nil { log.Info("Stopping Web Server ... done") } }() From b19a815d86a06cc3dbc5afeeab21db0f086e3c9e Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Thu, 23 Jan 2020 14:16:52 +0100 Subject: [PATCH 140/184] fixes relay-chcker tool --- tools/relay-checker/main.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tools/relay-checker/main.go b/tools/relay-checker/main.go index 18c1d1d9b5..8048458299 100644 --- a/tools/relay-checker/main.go +++ b/tools/relay-checker/main.go @@ -5,23 +5,21 @@ import ( "time" client "github.com/iotaledger/goshimmer/client" - "github.com/iotaledger/goshimmer/packages/errors" "github.com/iotaledger/iota.go/trinary" ) func testBroadcastData(api *client.GoShimmerAPI) (trinary.Hash, error) { txnHash, err := api.BroadcastData(txnAddr, txnData) if err != nil { - return "", errors.Wrapf(err, "Broadcast failed") + return "", fmt.Errorf("broadcast failed: %w", err) } return txnHash, nil } func testTargetGetTransactions(api *client.GoShimmerAPI, txnHash trinary.Hash) error { // query target node for broadcasted data - _, err := api.GetTransactionObjectsByHash([]trinary.Hash{txnHash}) - if err != nil { - return errors.Wrapf(err, "Query target failed") + if _, err := api.GetTransactionObjectsByHash([]trinary.Hash{txnHash}); err != nil { + return fmt.Errorf("querying the target node failed: %w", err) } return nil } @@ -30,11 +28,10 @@ func testNodesGetTransactions(txnHash trinary.Hash) error { // query nodes node for broadcasted data for _, n := range nodes { nodesApi := client.NewGoShimmerAPI(n) - _, err := nodesApi.GetTransactionObjectsByHash([]trinary.Hash{txnHash}) - if err != nil { - return errors.Wrapf(err, "Query %s failed", n) + if _, err := nodesApi.GetTransactionObjectsByHash([]trinary.Hash{txnHash}); err != nil { + return fmt.Errorf("querying node %s failed: %w", n, err) } - fmt.Printf("txn found in %s\n", n) + fmt.Printf("txn found in node %s\n", n) } return nil } From 2a39284b6e85905a199e6c07ff141c5f428fe6f1 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Thu, 23 Jan 2020 15:36:09 +0100 Subject: [PATCH 141/184] refactors webauth plugin and client --- client/lib.go | 208 +++++++++++++++++++--------------- main.go | 4 +- plugins/webauth/parameters.go | 17 +++ plugins/webauth/webauth.go | 78 +++++++------ 4 files changed, 172 insertions(+), 135 deletions(-) create mode 100644 plugins/webauth/parameters.go diff --git a/client/lib.go b/client/lib.go index 85084f5ae4..a3d7a3c0ea 100644 --- a/client/lib.go +++ b/client/lib.go @@ -1,4 +1,4 @@ -// Implements a very simple wrapper for GoShimmer's HTTP API . +// Implements a very simple wrapper for GoShimmer's web API . package goshimmer import ( @@ -6,16 +6,18 @@ import ( "encoding/json" "errors" "fmt" + "io" "io/ioutil" "net/http" webapi_broadcastData "github.com/iotaledger/goshimmer/plugins/webapi/broadcastData" - webapi_findTransactions "github.com/iotaledger/goshimmer/plugins/webapi/findTransactionHashes" + webapi_findTransactionHashes "github.com/iotaledger/goshimmer/plugins/webapi/findTransactionHashes" webapi_getNeighbors "github.com/iotaledger/goshimmer/plugins/webapi/getNeighbors" - webapi_getTransactions "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionObjectsByHash" - webapi_getTrytes "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionTrytesByHash" + webapi_getTransactionObjectsByHash "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionObjectsByHash" + webapi_getTransactionTrytesByHash "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionTrytesByHash" webapi_gtta "github.com/iotaledger/goshimmer/plugins/webapi/gtta" webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi/spammer" + webapi_auth "github.com/iotaledger/goshimmer/plugins/webauth" "github.com/iotaledger/iota.go/consts" "github.com/iotaledger/iota.go/guards" "github.com/iotaledger/iota.go/trinary" @@ -25,17 +27,19 @@ var ( ErrBadRequest = errors.New("bad request") ErrInternalServerError = errors.New("internal server error") ErrNotFound = errors.New("not found") + ErrUnauthorized = errors.New("unauthorized") ErrUnknownError = errors.New("unknown error") ) const ( - routeBroadcastData = "broadcastData" - routeGetTrytes = "getTransactionTrytesByHash" - routeGetTransactions = "getTransactionObjectsByHash" - routeFindTransactions = "findTransactionHashes" - routeGetNeighbors = "getNeighbors" - routeGetTransactionsToApprove = "getTransactionsToApprove" - routeSpammer = "spammer" + routeBroadcastData = "broadcastData" + routeGetTransactionTrytesByHash = "getTransactionTrytesByHash" + routeGetTransactionObjectsByHash = "getTransactionObjectsByHash" + routeFindTransactionsHashes = "findTransactionHashes" + routeGetNeighbors = "getNeighbors" + routeGetTransactionsToApprove = "getTransactionsToApprove" + routeSpammer = "spammer" + routeLogin = "login" contentTypeJSON = "application/json" ) @@ -47,9 +51,11 @@ func NewGoShimmerAPI(node string, httpClient ...http.Client) *GoShimmerAPI { return &GoShimmerAPI{node: node} } +// GoShimmerAPI is an API wrapper over the web API of GoShimmer. type GoShimmerAPI struct { httpClient http.Client node string + jwt string } type errorresponse struct { @@ -79,34 +85,85 @@ func interpretBody(res *http.Response, decodeTo interface{}) error { return fmt.Errorf("%w: %s", ErrNotFound, errRes.Error) case http.StatusBadRequest: return fmt.Errorf("%w: %s", ErrBadRequest, errRes.Error) + case http.StatusUnauthorized: + return fmt.Errorf("%w: %s", ErrUnauthorized, errRes.Error) } return fmt.Errorf("%w: %s", ErrUnknownError, errRes.Error) } -func (api *GoShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data string) (trinary.Hash, error) { - if !guards.IsHash(targetAddress) { - return "", fmt.Errorf("%w: invalid address: %s", consts.ErrInvalidHash, targetAddress) +func (api *GoShimmerAPI) do(method string, route string, reqObj interface{}, resObj interface{}) error { + // marshal request object + var data []byte + if reqObj != nil { + var err error + data, err = json.Marshal(reqObj) + if err != nil { + return err + } } - reqBytes, err := json.Marshal(&webapi_broadcastData.Request{Address: targetAddress, Data: data}) + // construct request + req, err := http.NewRequest(method, fmt.Sprintf("%s/%s", api.node, route), func() io.Reader { + if data == nil { + return nil + } + return bytes.NewReader(data) + }()) if err != nil { - return "", err + return err + } + + // add authorization header with JWT + if len(api.jwt) > 0 { + req.Header.Set("Authorization", fmt.Sprintf("bearer %s", api.jwt)) } - res, err := api.httpClient.Post(fmt.Sprintf("%s/%s", api.node, routeBroadcastData), contentTypeJSON, bytes.NewReader(reqBytes)) + // make the request + res, err := api.httpClient.Do(req) if err != nil { - return "", err + return err } - resObj := &webapi_broadcastData.Response{} + if resObj == nil { + return nil + } + + // write response into response object if err := interpretBody(res, resObj); err != nil { + return err + } + return nil +} + +// Login authorizes this API instance against the web API. +// You must call this function before any before any other call, if the web-auth plugin is enabled. +func (api *GoShimmerAPI) Login(username string, password string) error { + res := &webapi_auth.Response{} + if err := api.do(http.MethodPost, routeLogin, + &webapi_auth.Request{Username: username, Password: password}, res); err != nil { + return err + } + api.jwt = res.Token + return nil +} + +// BroadcastData sends the given data by creating a zero value transaction in the backend targeting the given address. +func (api *GoShimmerAPI) BroadcastData(targetAddress trinary.Trytes, data string) (trinary.Hash, error) { + if !guards.IsHash(targetAddress) { + return "", fmt.Errorf("%w: invalid address: %s", consts.ErrInvalidHash, targetAddress) + } + + res := &webapi_broadcastData.Response{} + if err := api.do(http.MethodPost, routeBroadcastData, + &webapi_broadcastData.Request{Address: targetAddress, Data: data}, res); err != nil { return "", err } - return resObj.Hash, nil + return res.Hash, nil } +// GetTransactionTrytesByHash gets the corresponding transaction trytes given the transaction hashes. func (api *GoShimmerAPI) GetTransactionTrytesByHash(txHashes trinary.Hashes) ([]trinary.Trytes, error) { for _, hash := range txHashes { if !guards.IsTrytes(hash) { @@ -114,117 +171,82 @@ func (api *GoShimmerAPI) GetTransactionTrytesByHash(txHashes trinary.Hashes) ([] } } - reqBytes, err := json.Marshal(&webapi_getTrytes.Request{Hashes: txHashes}) - if err != nil { + res := &webapi_getTransactionTrytesByHash.Response{} + if err := api.do(http.MethodPost, routeGetTransactionTrytesByHash, + &webapi_getTransactionTrytesByHash.Request{Hashes: txHashes}, res); err != nil { return nil, err } - res, err := api.httpClient.Post(fmt.Sprintf("%s/%s", api.node, routeGetTrytes), contentTypeJSON, bytes.NewReader(reqBytes)) - if err != nil { - return nil, err - } - - resObj := &webapi_getTrytes.Response{} - if err := interpretBody(res, resObj); err != nil { - return nil, err - } - - return resObj.Trytes, nil + return res.Trytes, nil } -func (api *GoShimmerAPI) GetTransactionObjectsByHash(txHashes trinary.Hashes) ([]webapi_getTransactions.Transaction, error) { +// GetTransactionObjectsByHash gets the transaction objects given the transaction hashes. +func (api *GoShimmerAPI) GetTransactionObjectsByHash(txHashes trinary.Hashes) ([]webapi_getTransactionObjectsByHash.Transaction, error) { for _, hash := range txHashes { if !guards.IsTrytes(hash) { return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash) } } - reqBytes, err := json.Marshal(&webapi_getTransactions.Request{Hashes: txHashes}) - if err != nil { - return nil, err - } - - res, err := api.httpClient.Post(fmt.Sprintf("%s/%s", api.node, routeGetTransactions), contentTypeJSON, bytes.NewReader(reqBytes)) - if err != nil { + res := &webapi_getTransactionObjectsByHash.Response{} + if err := api.do(http.MethodPost, routeGetTransactionObjectsByHash, + &webapi_getTransactionObjectsByHash.Request{Hashes: txHashes}, res); err != nil { return nil, err } - resObj := &webapi_getTransactions.Response{} - if err := interpretBody(res, resObj); err != nil { - return nil, err - } - - return resObj.Transactions, nil + return res.Transactions, nil } -func (api *GoShimmerAPI) FindTransactionHashes(query *webapi_findTransactions.Request) ([]trinary.Hashes, error) { +// FindTransactionHashes finds the given transaction hashes given the query. +func (api *GoShimmerAPI) FindTransactionHashes(query *webapi_findTransactionHashes.Request) ([]trinary.Hashes, error) { for _, hash := range query.Addresses { if !guards.IsTrytes(hash) { return nil, fmt.Errorf("%w: invalid hash: %s", consts.ErrInvalidHash, hash) } } - reqBytes, err := json.Marshal(&query) - if err != nil { + res := &webapi_findTransactionHashes.Response{} + if err := api.do(http.MethodPost, routeFindTransactionsHashes, query, res); err != nil { return nil, err } - res, err := api.httpClient.Post(fmt.Sprintf("%s/%s", api.node, routeFindTransactions), contentTypeJSON, bytes.NewReader(reqBytes)) - if err != nil { - return nil, err - } - - resObj := &webapi_findTransactions.Response{} - if err := interpretBody(res, resObj); err != nil { - return nil, err - } - - return resObj.Transactions, nil + return res.Transactions, nil } -func (api *GoShimmerAPI) GetNeighbors() (*webapi_getNeighbors.Response, error) { - res, err := api.httpClient.Get(fmt.Sprintf("%s/%s", api.node, routeGetNeighbors)) - if err != nil { - return nil, err - } - - resObj := &webapi_getNeighbors.Response{} - if err := interpretBody(res, resObj); err != nil { +// GetNeighbors gets the chosen/accepted neighbors. +// If knownPeers is set, also all known peers to the node are returned additionally. +func (api *GoShimmerAPI) GetNeighbors(knownPeers bool) (*webapi_getNeighbors.Response, error) { + res := &webapi_getNeighbors.Response{} + if err := api.do(http.MethodGet, func() string { + if !knownPeers { + return routeGetNeighbors + } + return fmt.Sprintf("%s?known=1", routeGetNeighbors) + }(), nil, res); err != nil { return nil, err } - - return resObj, nil + return res, nil } -func (api *GoShimmerAPI) GetTips() (*webapi_gtta.Response, error) { - res, err := api.httpClient.Get(fmt.Sprintf("%s/%s", api.node, routeGetTransactionsToApprove)) - if err != nil { +// GetTips executes the tip-selection on the node to retrieve tips to approve. +func (api *GoShimmerAPI) GetTransactionsToApprove() (*webapi_gtta.Response, error) { + res := &webapi_gtta.Response{} + if err := api.do(http.MethodGet, routeGetTransactionsToApprove, nil, res); err != nil { return nil, err } - - resObj := &webapi_gtta.Response{} - if err := interpretBody(res, resObj); err != nil { - return nil, err - } - - return resObj, nil + return res, nil } +// ToggleSpammer toggles the node internal spammer. func (api *GoShimmerAPI) ToggleSpammer(enable bool) (*webapi_spammer.Response, error) { - res, err := api.httpClient.Get(fmt.Sprintf("%s/%s?cmd=%s", api.node, routeSpammer, func() string { + res := &webapi_spammer.Response{} + if err := api.do(http.MethodGet, func() string { if enable { - return "start" + return fmt.Sprintf("%s?cmd=start", routeSpammer) } - return "stop" - }())) - if err != nil { - return nil, err - } - - resObj := &webapi_spammer.Response{} - if err := interpretBody(res, resObj); err != nil { + return fmt.Sprintf("%s?cmd=stop", routeSpammer) + }(), nil, res); err != nil { return nil, err } - - return resObj, nil + return res, nil } diff --git a/main.go b/main.go index 319811df54..c3f4249478 100644 --- a/main.go +++ b/main.go @@ -26,7 +26,7 @@ import ( webapi_getTransactionTrytesByHash "github.com/iotaledger/goshimmer/plugins/webapi/getTransactionTrytesByHash" webapi_gtta "github.com/iotaledger/goshimmer/plugins/webapi/gtta" webapi_spammer "github.com/iotaledger/goshimmer/plugins/webapi/spammer" - "github.com/iotaledger/goshimmer/plugins/webauth" + webapi_auth "github.com/iotaledger/goshimmer/plugins/webauth" "github.com/iotaledger/goshimmer/plugins/zeromq" "github.com/iotaledger/hive.go/node" ) @@ -54,6 +54,7 @@ func main() { statusscreen_tps.PLUGIN, webapi.PLUGIN, + webapi_auth.PLUGIN, webapi_gtta.PLUGIN, webapi_spammer.PLUGIN, webapi_broadcastData.PLUGIN, @@ -64,7 +65,6 @@ func main() { webapi_spammer.PLUGIN, ui.PLUGIN, - webauth.PLUGIN, graph.PLUGIN, ), diff --git a/plugins/webauth/parameters.go b/plugins/webauth/parameters.go new file mode 100644 index 0000000000..2146da738a --- /dev/null +++ b/plugins/webauth/parameters.go @@ -0,0 +1,17 @@ +package webauth + +import ( + flag "github.com/spf13/pflag" +) + +const ( + WEBAPI_AUTH_USERNAME = "webapi.auth.username" + WEBAPI_AUTH_PASSWORD = "webapi.auth.password" + WEBAPI_AUTH_PRIVATE_KEY = "webapi.auth.private_key" +) + +func init() { + flag.String(WEBAPI_AUTH_USERNAME, "user", "username for the webapi") + flag.String(WEBAPI_AUTH_PASSWORD, "pass", "password for the webapi") + flag.String(WEBAPI_AUTH_PRIVATE_KEY, "", "private key used to sign the JWTs") +} diff --git a/plugins/webauth/webauth.go b/plugins/webauth/webauth.go index aa7ba5b340..ed8adfd320 100644 --- a/plugins/webauth/webauth.go +++ b/plugins/webauth/webauth.go @@ -2,13 +2,11 @@ package webauth import ( "net/http" - "os" "strings" "time" - "github.com/iotaledger/goshimmer/packages/shutdown" + "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/webapi" - "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/node" "github.com/labstack/echo" "github.com/labstack/echo/middleware" @@ -16,59 +14,59 @@ import ( "github.com/dgrijalva/jwt-go" ) -var secret = "secret" +var PLUGIN = node.NewPlugin("WebAPI JWT Auth", node.Disabled, configure) + +var privateKey string func configure(plugin *node.Plugin) { - jwtKey := os.Getenv("JWT_KEY") - if jwtKey != "" { - secret = jwtKey + privateKey = parameter.NodeConfig.GetString(WEBAPI_AUTH_PRIVATE_KEY) + if len(privateKey) == 0 { + panic("") } webapi.Server.Use(middleware.JWTWithConfig(middleware.JWTConfig{ - SigningKey: []byte(secret), - TokenLookup: "query:token", + SigningKey: []byte(privateKey), Skipper: func(c echo.Context) bool { - // if strings.HasPrefix(c.Request().Host, "localhost") { - // return true - // } if strings.HasPrefix(c.Path(), "/ui") || c.Path() == "/login" { return true } return false }, })) + + webapi.Server.POST("/login", Handler) } -func run(plugin *node.Plugin) { - daemon.BackgroundWorker("webauth", func(shutdownSignal <-chan struct{}) { - webapi.Server.GET("login", func(c echo.Context) error { - username := c.FormValue("username") - password := c.FormValue("password") - uiUser := os.Getenv("UI_USER") - uiPass := os.Getenv("UI_PASS") - - // Throws unauthorized error - if username != uiUser || password != uiPass { - return echo.ErrUnauthorized - } +type Request struct { + Username string `json:"username"` + Password string `json:"password"` +} - token := jwt.New(jwt.SigningMethodHS256) - claims := token.Claims.(jwt.MapClaims) - claims["name"] = username - claims["exp"] = time.Now().Add(time.Hour * 24 * 7).Unix() +type Response struct { + Token string `json:"token"` +} - t, err := token.SignedString([]byte(secret)) - if err != nil { - return err - } +func Handler(c echo.Context) error { + login := &Request{} + if err := c.Bind(login); err != nil { + return echo.ErrBadRequest + } - return c.JSON(http.StatusOK, map[string]string{ - "token": t, - }) - }) - }, shutdown.ShutdownPriorityWebAPI) -} + if login.Username != parameter.NodeConfig.GetString(WEBAPI_AUTH_USERNAME) || + login.Password != parameter.NodeConfig.GetString(WEBAPI_AUTH_PASSWORD) { + return echo.ErrUnauthorized + } + + token := jwt.New(jwt.SigningMethodHS256) + claims := token.Claims.(jwt.MapClaims) + claims["name"] = login.Username + claims["exp"] = time.Now().Add(time.Hour * 24 * 7).Unix() -// PLUGIN plugs the UI into the main program -var PLUGIN = node.NewPlugin("webauth", node.Disabled, configure, run) + t, err := token.SignedString([]byte(privateKey)) + if err != nil { + return err + } + + return c.JSON(http.StatusOK, &Response{Token: t}) +} From 506dee9dd3caaae76f35fdd0e48e70e60e1243a7 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Thu, 23 Jan 2020 15:53:32 +0100 Subject: [PATCH 142/184] fixes bearer format, adds logger to webauth --- client/lib.go | 2 +- config.json | 7 ++++++- plugins/webauth/parameters.go | 6 +++--- plugins/webauth/webauth.go | 8 +++++--- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/client/lib.go b/client/lib.go index a3d7a3c0ea..487f708307 100644 --- a/client/lib.go +++ b/client/lib.go @@ -116,7 +116,7 @@ func (api *GoShimmerAPI) do(method string, route string, reqObj interface{}, res // add authorization header with JWT if len(api.jwt) > 0 { - req.Header.Set("Authorization", fmt.Sprintf("bearer %s", api.jwt)) + req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", api.jwt)) } // make the request diff --git a/config.json b/config.json index d5f7713c05..9b8fe5db33 100644 --- a/config.json +++ b/config.json @@ -17,7 +17,12 @@ "port": 14666 }, "webapi": { - "bindAddress": "0.0.0.0:8080" + "bindAddress": "0.0.0.0:8080", + "auth": { + "username": "goshimmer", + "password": "goshimmer", + "privateKey": "uUUavNbdr32jE9CqnSMCKt4HMu9AZ2K4rKekUSPx9jk83eyeM7xewv5CqUKYMC9" + } }, "graph": { "webrootPath": "./IOTAtangle/webroot", diff --git a/plugins/webauth/parameters.go b/plugins/webauth/parameters.go index 2146da738a..5084ce5640 100644 --- a/plugins/webauth/parameters.go +++ b/plugins/webauth/parameters.go @@ -7,11 +7,11 @@ import ( const ( WEBAPI_AUTH_USERNAME = "webapi.auth.username" WEBAPI_AUTH_PASSWORD = "webapi.auth.password" - WEBAPI_AUTH_PRIVATE_KEY = "webapi.auth.private_key" + WEBAPI_AUTH_PRIVATE_KEY = "webapi.auth.privateKey" ) func init() { - flag.String(WEBAPI_AUTH_USERNAME, "user", "username for the webapi") - flag.String(WEBAPI_AUTH_PASSWORD, "pass", "password for the webapi") + flag.String(WEBAPI_AUTH_USERNAME, "goshimmer", "username for the webapi") + flag.String(WEBAPI_AUTH_PASSWORD, "goshimmer", "password for the webapi") flag.String(WEBAPI_AUTH_PRIVATE_KEY, "", "private key used to sign the JWTs") } diff --git a/plugins/webauth/webauth.go b/plugins/webauth/webauth.go index ed8adfd320..21e943fa9f 100644 --- a/plugins/webauth/webauth.go +++ b/plugins/webauth/webauth.go @@ -7,6 +7,7 @@ import ( "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/plugins/webapi" + "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/node" "github.com/labstack/echo" "github.com/labstack/echo/middleware" @@ -14,12 +15,12 @@ import ( "github.com/dgrijalva/jwt-go" ) -var PLUGIN = node.NewPlugin("WebAPI JWT Auth", node.Disabled, configure) - +var PLUGIN = node.NewPlugin("WebAPI Auth", node.Disabled, configure) +var log *logger.Logger var privateKey string func configure(plugin *node.Plugin) { - + log = logger.NewLogger("WebAPI Auth") privateKey = parameter.NodeConfig.GetString(WEBAPI_AUTH_PRIVATE_KEY) if len(privateKey) == 0 { panic("") @@ -36,6 +37,7 @@ func configure(plugin *node.Plugin) { })) webapi.Server.POST("/login", Handler) + log.Info("WebAPI is now secured through JWT authentication") } type Request struct { From d7962911065d196bc67973ed3eb8762118210433 Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 23 Jan 2020 15:11:49 +0000 Subject: [PATCH 143/184] :loud_sound: improves debug logs --- plugins/analysis/client/plugin.go | 9 +++++---- .../webinterface/recordedevents/recorded_events.go | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index df532eec75..f3ad4f700b 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -1,6 +1,7 @@ package client import ( + "encoding/hex" "net" "time" @@ -57,19 +58,19 @@ func Run(plugin *node.Plugin) { func getEventDispatchers(conn *network.ManagedConnection) *EventDispatchers { return &EventDispatchers{ AddNode: func(nodeId []byte) { - log.Debugw("AddNode", "nodeId", nodeId) + log.Debugw("AddNode", "nodeId", hex.EncodeToString(nodeId)) _, _ = conn.Write((&addnode.Packet{NodeId: nodeId}).Marshal()) }, RemoveNode: func(nodeId []byte) { - log.Debugw("RemoveNode", "nodeId", nodeId) + log.Debugw("RemoveNode", "nodeId", hex.EncodeToString(nodeId)) _, _ = conn.Write((&removenode.Packet{NodeId: nodeId}).Marshal()) }, ConnectNodes: func(sourceId []byte, targetId []byte) { - log.Debugw("ConnectNodes", "sourceId", sourceId, "targetId", targetId) + log.Debugw("ConnectNodes", "sourceId", hex.EncodeToString(sourceId), "targetId", hex.EncodeToString(targetId)) _, _ = conn.Write((&connectnodes.Packet{SourceId: sourceId, TargetId: targetId}).Marshal()) }, DisconnectNodes: func(sourceId []byte, targetId []byte) { - log.Debugw("DisconnectNodes", "sourceId", sourceId, "targetId", targetId) + log.Debugw("DisconnectNodes", "sourceId", hex.EncodeToString(sourceId), "targetId", hex.EncodeToString(targetId)) _, _ = conn.Write((&disconnectnodes.Packet{SourceId: sourceId, TargetId: targetId}).Marshal()) }, } diff --git a/plugins/analysis/webinterface/recordedevents/recorded_events.go b/plugins/analysis/webinterface/recordedevents/recorded_events.go index ae6a5597c0..398ca97082 100644 --- a/plugins/analysis/webinterface/recordedevents/recorded_events.go +++ b/plugins/analysis/webinterface/recordedevents/recorded_events.go @@ -16,6 +16,7 @@ var lock sync.Mutex func Configure(plugin *node.Plugin) { server.Events.AddNode.Attach(events.NewClosure(func(nodeId string) { + plugin.Node.Logger.Debugw("AddNode", "nodeID", nodeId) lock.Lock() defer lock.Unlock() @@ -25,6 +26,7 @@ func Configure(plugin *node.Plugin) { })) server.Events.RemoveNode.Attach(events.NewClosure(func(nodeId string) { + plugin.Node.Logger.Debugw("RemoveNode", "nodeID", nodeId) lock.Lock() defer lock.Unlock() @@ -32,6 +34,7 @@ func Configure(plugin *node.Plugin) { })) server.Events.NodeOnline.Attach(events.NewClosure(func(nodeId string) { + plugin.Node.Logger.Debugw("NodeOnline", "nodeID", nodeId) lock.Lock() defer lock.Unlock() @@ -39,6 +42,7 @@ func Configure(plugin *node.Plugin) { })) server.Events.NodeOffline.Attach(events.NewClosure(func(nodeId string) { + plugin.Node.Logger.Debugw("NodeOffline", "nodeID", nodeId) lock.Lock() defer lock.Unlock() @@ -46,6 +50,7 @@ func Configure(plugin *node.Plugin) { })) server.Events.ConnectNodes.Attach(events.NewClosure(func(sourceId string, targetId string) { + plugin.Node.Logger.Debugw("ConnectNodes", "sourceID", sourceId, "targetId", targetId) lock.Lock() defer lock.Unlock() @@ -59,6 +64,7 @@ func Configure(plugin *node.Plugin) { })) server.Events.DisconnectNodes.Attach(events.NewClosure(func(sourceId string, targetId string) { + plugin.Node.Logger.Debugw("DisconnectNodes", "sourceID", sourceId, "targetId", targetId) lock.Lock() defer lock.Unlock() From c507e9bbefe9fd2a08e0a3696ee544261ad0cb42 Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 23 Jan 2020 15:24:08 +0000 Subject: [PATCH 144/184] :children_crossing: disables node deletion from UI --- plugins/analysis/webinterface/httpserver/index.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/analysis/webinterface/httpserver/index.go b/plugins/analysis/webinterface/httpserver/index.go index 15fea5145b..c3cab773b3 100644 --- a/plugins/analysis/webinterface/httpserver/index.go +++ b/plugins/analysis/webinterface/httpserver/index.go @@ -78,7 +78,7 @@ func index(w http.ResponseWriter, r *http.Request) { const Graph = ForceGraph3D()(elem) .enableNodeDrag(false) .onNodeHover(node => elem.style.cursor = node ? 'pointer' : null) - .onNodeClick(removeNodeX) + .onNodeClick() .nodeColor(node => node.online ? 'rgba(0,255,0,1)' : 'rgba(255,255,255,1)') .graphData(data); From 7729f6a87c09ec4d5787293cd9e96d8ecc0d4981 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Thu, 23 Jan 2020 16:52:22 +0100 Subject: [PATCH 145/184] Use hive.go/network --- packages/network/events.go | 15 --- packages/network/managed_connection.go | 161 ------------------------- packages/network/parameters.go | 5 - packages/network/tcp/server.go | 74 ------------ packages/network/tcp/server_events.go | 17 --- packages/network/tcp/types.go | 9 -- packages/network/types.go | 7 -- plugins/analysis/client/plugin.go | 2 +- plugins/analysis/server/plugin.go | 8 +- 9 files changed, 5 insertions(+), 293 deletions(-) delete mode 100644 packages/network/events.go delete mode 100644 packages/network/managed_connection.go delete mode 100644 packages/network/parameters.go delete mode 100644 packages/network/tcp/server.go delete mode 100644 packages/network/tcp/server_events.go delete mode 100644 packages/network/tcp/types.go delete mode 100644 packages/network/types.go diff --git a/packages/network/events.go b/packages/network/events.go deleted file mode 100644 index 7903376b6b..0000000000 --- a/packages/network/events.go +++ /dev/null @@ -1,15 +0,0 @@ -package network - -import ( - "github.com/iotaledger/hive.go/events" -) - -type BufferedConnectionEvents struct { - ReceiveData *events.Event - Close *events.Event - Error *events.Event -} - -func dataCaller(handler interface{}, params ...interface{}) { - handler.(func([]byte))(params[0].([]byte)) -} diff --git a/packages/network/managed_connection.go b/packages/network/managed_connection.go deleted file mode 100644 index 012a59d8a7..0000000000 --- a/packages/network/managed_connection.go +++ /dev/null @@ -1,161 +0,0 @@ -package network - -import ( - "io" - "net" - "sync" - "time" - - "github.com/iotaledger/hive.go/events" -) - -type ManagedConnection struct { - Conn net.Conn - Events BufferedConnectionEvents - readTimeout time.Duration - writeTimeout time.Duration - closeOnce sync.Once -} - -func NewManagedConnection(conn net.Conn) *ManagedConnection { - bufferedConnection := &ManagedConnection{ - Conn: conn, - Events: BufferedConnectionEvents{ - ReceiveData: events.NewEvent(dataCaller), - Close: events.NewEvent(events.CallbackCaller), - Error: events.NewEvent(events.ErrorCaller), - }, - } - - return bufferedConnection -} - -func (this *ManagedConnection) Read(receiveBuffer []byte) (n int, err error) { - defer this.Close() - - totalReadBytes := 0 - for { - if err := this.setReadTimeoutBasedDeadline(); err != nil { - return totalReadBytes, err - } - - byteCount, err := this.Conn.Read(receiveBuffer) - if byteCount > 0 { - totalReadBytes += byteCount - - receivedData := make([]byte, byteCount) - copy(receivedData, receiveBuffer) - - this.Events.ReceiveData.Trigger(receivedData) - } - - if err != nil { - if err != io.EOF { - this.Events.Error.Trigger(err) - } - - return totalReadBytes, err - } - } -} - -func (this *ManagedConnection) Write(data []byte) (n int, err error) { - if err := this.setWriteTimeoutBasedDeadline(); err != nil { - return 0, err - } - - return this.Conn.Write(data) -} - -func (this *ManagedConnection) Close() error { - err := this.Conn.Close() - if err != nil { - this.Events.Error.Trigger(err) - } - - this.closeOnce.Do(func() { - this.Events.Close.Trigger() - }) - - return err -} - -func (this *ManagedConnection) LocalAddr() net.Addr { - return this.Conn.LocalAddr() -} - -func (this *ManagedConnection) RemoteAddr() net.Addr { - return this.Conn.RemoteAddr() -} - -func (this *ManagedConnection) SetDeadline(t time.Time) error { - return this.Conn.SetDeadline(t) -} - -func (this *ManagedConnection) SetReadDeadline(t time.Time) error { - return this.Conn.SetReadDeadline(t) -} - -func (this *ManagedConnection) SetWriteDeadline(t time.Time) error { - return this.Conn.SetWriteDeadline(t) -} - -func (this *ManagedConnection) SetTimeout(d time.Duration) error { - if err := this.SetReadTimeout(d); err != nil { - return err - } - - if err := this.SetWriteTimeout(d); err != nil { - return err - } - - return nil -} - -func (this *ManagedConnection) SetReadTimeout(d time.Duration) error { - this.readTimeout = d - - if err := this.setReadTimeoutBasedDeadline(); err != nil { - return err - } - - return nil -} - -func (this *ManagedConnection) SetWriteTimeout(d time.Duration) error { - this.writeTimeout = d - - if err := this.setWriteTimeoutBasedDeadline(); err != nil { - return err - } - - return nil -} - -func (this *ManagedConnection) setReadTimeoutBasedDeadline() error { - if this.readTimeout != 0 { - if err := this.Conn.SetReadDeadline(time.Now().Add(this.readTimeout)); err != nil { - return err - } - } else { - if err := this.Conn.SetReadDeadline(time.Time{}); err != nil { - return err - } - } - - return nil -} - -func (this *ManagedConnection) setWriteTimeoutBasedDeadline() error { - if this.writeTimeout != 0 { - if err := this.Conn.SetWriteDeadline(time.Now().Add(this.writeTimeout)); err != nil { - return err - } - } else { - if err := this.Conn.SetWriteDeadline(time.Time{}); err != nil { - return err - } - } - - return nil -} diff --git a/packages/network/parameters.go b/packages/network/parameters.go deleted file mode 100644 index bad4b1bab0..0000000000 --- a/packages/network/parameters.go +++ /dev/null @@ -1,5 +0,0 @@ -package network - -const ( - READ_BUFFER_SIZE = 81920 -) diff --git a/packages/network/tcp/server.go b/packages/network/tcp/server.go deleted file mode 100644 index 5d962043fd..0000000000 --- a/packages/network/tcp/server.go +++ /dev/null @@ -1,74 +0,0 @@ -package tcp - -import ( - "net" - "strconv" - "sync" - - "github.com/iotaledger/goshimmer/packages/network" - "github.com/iotaledger/hive.go/events" -) - -type Server struct { - socket net.Listener - socketMutex sync.RWMutex - Events serverEvents -} - -func (this *Server) GetSocket() net.Listener { - this.socketMutex.RLock() - defer this.socketMutex.RUnlock() - return this.socket -} - -func (this *Server) Shutdown() { - this.socketMutex.Lock() - defer this.socketMutex.Unlock() - if this.socket != nil { - socket := this.socket - this.socket = nil - - socket.Close() - } -} - -func (this *Server) Listen(port int) *Server { - socket, err := net.Listen("tcp4", "0.0.0.0:"+strconv.Itoa(port)) - if err != nil { - this.Events.Error.Trigger(err) - - return this - } else { - this.socketMutex.Lock() - this.socket = socket - this.socketMutex.Unlock() - } - - this.Events.Start.Trigger() - defer this.Events.Shutdown.Trigger() - - for this.GetSocket() != nil { - if socket, err := this.GetSocket().Accept(); err != nil { - if this.GetSocket() != nil { - this.Events.Error.Trigger(err) - } - } else { - peer := network.NewManagedConnection(socket) - - go this.Events.Connect.Trigger(peer) - } - } - - return this -} - -func NewServer() *Server { - return &Server{ - Events: serverEvents{ - Start: events.NewEvent(events.CallbackCaller), - Shutdown: events.NewEvent(events.CallbackCaller), - Connect: events.NewEvent(managedConnectionCaller), - Error: events.NewEvent(events.ErrorCaller), - }, - } -} diff --git a/packages/network/tcp/server_events.go b/packages/network/tcp/server_events.go deleted file mode 100644 index bf4e8aea24..0000000000 --- a/packages/network/tcp/server_events.go +++ /dev/null @@ -1,17 +0,0 @@ -package tcp - -import ( - "github.com/iotaledger/goshimmer/packages/network" - "github.com/iotaledger/hive.go/events" -) - -type serverEvents struct { - Start *events.Event - Shutdown *events.Event - Connect *events.Event - Error *events.Event -} - -func managedConnectionCaller(handler interface{}, params ...interface{}) { - handler.(func(*network.ManagedConnection))(params[0].(*network.ManagedConnection)) -} diff --git a/packages/network/tcp/types.go b/packages/network/tcp/types.go deleted file mode 100644 index 44856584f1..0000000000 --- a/packages/network/tcp/types.go +++ /dev/null @@ -1,9 +0,0 @@ -package tcp - -import "github.com/iotaledger/goshimmer/packages/network" - -type Callback = func() - -type ErrorConsumer = func(e error) - -type PeerConsumer = func(conn *network.ManagedConnection) diff --git a/packages/network/types.go b/packages/network/types.go deleted file mode 100644 index 1a31faf507..0000000000 --- a/packages/network/types.go +++ /dev/null @@ -1,7 +0,0 @@ -package network - -type Callback func() - -type ErrorConsumer func(err error) - -type DataConsumer func(data []byte) diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index b9179be123..6fd3f07c47 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -6,7 +6,6 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/discover" "github.com/iotaledger/goshimmer/packages/autopeering/selection" - "github.com/iotaledger/goshimmer/packages/network" "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/analysis/types/addnode" @@ -19,6 +18,7 @@ import ( "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/network" "github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/timeutil" ) diff --git a/plugins/analysis/server/plugin.go b/plugins/analysis/server/plugin.go index ab1b14453c..215eefa197 100644 --- a/plugins/analysis/server/plugin.go +++ b/plugins/analysis/server/plugin.go @@ -5,8 +5,6 @@ import ( "errors" "math" - "github.com/iotaledger/goshimmer/packages/network" - "github.com/iotaledger/goshimmer/packages/network/tcp" "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/analysis/types/addnode" @@ -17,13 +15,15 @@ import ( "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" + "github.com/iotaledger/hive.go/network" + "github.com/iotaledger/hive.go/network/tcp" "github.com/iotaledger/hive.go/node" ) var ( ErrInvalidPackageHeader = errors.New("invalid package header") ErrExpectedInitialAddNodePackage = errors.New("expected initial add node package") - server *tcp.Server + server *tcp.TCPServer log *logger.Logger ) @@ -46,7 +46,7 @@ func Configure(plugin *node.Plugin) { func Run(plugin *node.Plugin) { daemon.BackgroundWorker("Analysis Server", func(shutdownSignal <-chan struct{}) { log.Infof("Starting Server (port %d) ... done", parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) - go server.Listen(parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) + go server.Listen("0.0.0.0", parameter.NodeConfig.GetInt(CFG_SERVER_PORT)) <-shutdownSignal Shutdown() }, shutdown.ShutdownPriorityAnalysis) From aec6710ed539e422183de28c1e220364275da4c4 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Thu, 23 Jan 2020 17:08:19 +0100 Subject: [PATCH 146/184] Adds relay-checker tool readme (#171) * partial readme * adds readme to the relay-checker and refactors it a little bit --- tools/relay-checker/README.md | 15 +++++++++++++++ tools/relay-checker/config.go | 24 ++++++++++++------------ tools/relay-checker/config.json | 12 ++++++------ tools/relay-checker/main.go | 6 +++--- tools/relay-checker/parameters.go | 22 +++++++++++----------- 5 files changed, 47 insertions(+), 32 deletions(-) create mode 100644 tools/relay-checker/README.md diff --git a/tools/relay-checker/README.md b/tools/relay-checker/README.md new file mode 100644 index 0000000000..f3102cb446 --- /dev/null +++ b/tools/relay-checker/README.md @@ -0,0 +1,15 @@ +# Relay-Checker + +This tool checks whether a transaction which is created on a given node (via `broadcastData`), +is actually relayed/gossiped through the network by checking the transaction's existence on other +specified nodes after a cooldown. + +This program can be configured via CLI flags: +``` +--relayChecker.cooldownTime int the cooldown time after broadcasting the data on the specified target node (default 10) +--relayChecker.data string data to broadcast (default "TEST99BROADCAST99DATA") +--relayChecker.repeat int the amount of times to repeat the relay-checker queries (default 1) +--relayChecker.targetNode string the target node from the which transaction will be broadcasted from (default "http://127.0.0.1:8080") +--relayChecker.testNodes strings the list of nodes to check after the cooldown +--relayChecker.txAddress string the transaction address (default "SHIMMER99TEST99999999999999999999999999999999999999999999999999999999999999999999") +``` \ No newline at end of file diff --git a/tools/relay-checker/config.go b/tools/relay-checker/config.go index 9096faf6f2..6833f365dd 100644 --- a/tools/relay-checker/config.go +++ b/tools/relay-checker/config.go @@ -5,12 +5,12 @@ import ( ) var ( - nodes []string - target = "" - txnAddr = "GOSHIMMER99TEST999999999999999999999999999999999999999999999999999999999999999999" - txnData = "TEST99BROADCAST99DATA" - cooldown = 2 - maxQuery = 1 + nodes []string + target = "" + txnAddr = "GOSHIMMER99TEST999999999999999999999999999999999999999999999999999999999999999999" + txnData = "TEST99BROADCAST99DATA" + cooldownTime = 2 + repeat = 1 ) func LoadConfig() { @@ -31,16 +31,16 @@ func SetConfig() { nodes = append(nodes, parameter.NodeConfig.GetStringSlice(CFG_TEST_NODES)...) // optional settings - if parameter.NodeConfig.GetString(CFG_TXN_ADDRESS) != "" { - txnAddr = parameter.NodeConfig.GetString(CFG_TXN_ADDRESS) + if parameter.NodeConfig.GetString(CFG_TX_ADDRESS) != "" { + txnAddr = parameter.NodeConfig.GetString(CFG_TX_ADDRESS) } if parameter.NodeConfig.GetString(CFG_DATA) != "" { txnData = parameter.NodeConfig.GetString(CFG_DATA) } - if parameter.NodeConfig.GetInt(CFG_COOL_DOWN_TIME) > 0 { - cooldown = parameter.NodeConfig.GetInt(CFG_COOL_DOWN_TIME) + if parameter.NodeConfig.GetInt(CFG_COOLDOWN_TIME) > 0 { + cooldownTime = parameter.NodeConfig.GetInt(CFG_COOLDOWN_TIME) } - if parameter.NodeConfig.GetInt(CFG_MAX_QUERY) > 0 { - maxQuery = parameter.NodeConfig.GetInt(CFG_MAX_QUERY) + if parameter.NodeConfig.GetInt(CFG_REPEAT) > 0 { + repeat = parameter.NodeConfig.GetInt(CFG_REPEAT) } } diff --git a/tools/relay-checker/config.json b/tools/relay-checker/config.json index d7c0df5512..a830da125c 100644 --- a/tools/relay-checker/config.json +++ b/tools/relay-checker/config.json @@ -1,12 +1,12 @@ { - "relaycheck": { - "targetnode": "http://127.0.0.1:8080", - "nodes": [ + "relayChecker": { + "targetNode": "http://127.0.0.1:8080", + "testNodes": [ "http://127.0.0.1:8080" ], - "txnaddress": "SHIMMER99TEST99999999999999999999999999999999999999999999999999999999999999999999", + "txAddress": "SHIMMER99TEST99999999999999999999999999999999999999999999999999999999999999999999", "data": "TEST99BROADCAST99DATA", - "cooldowntime": 10, - "maxquery": 2 + "cooldownTime": 10, + "repeat": 2 } } diff --git a/tools/relay-checker/main.go b/tools/relay-checker/main.go index 8048458299..4bdc570883 100644 --- a/tools/relay-checker/main.go +++ b/tools/relay-checker/main.go @@ -41,7 +41,7 @@ func main() { SetConfig() api := client.NewGoShimmerAPI(target) - for i := 0; i < maxQuery; i++ { + for i := 0; i < repeat; i++ { txnHash, err := testBroadcastData(api) if err != nil { fmt.Printf("%s\n", err) @@ -50,7 +50,7 @@ func main() { fmt.Printf("txnHash: %s\n", txnHash) // cooldown time - time.Sleep(time.Duration(cooldown) * time.Second) + time.Sleep(time.Duration(cooldownTime) * time.Second) // query target node err = testTargetGetTransactions(api, txnHash) @@ -59,7 +59,7 @@ func main() { break } - // query nodes node + // query test nodes err = testNodesGetTransactions(txnHash) if err != nil { fmt.Printf("%s\n", err) diff --git a/tools/relay-checker/parameters.go b/tools/relay-checker/parameters.go index b1ee2b9b5a..ac64aaf770 100644 --- a/tools/relay-checker/parameters.go +++ b/tools/relay-checker/parameters.go @@ -5,19 +5,19 @@ import ( ) const ( - CFG_TARGET_NODE = "relaycheck.targetNode" - CFG_TEST_NODES = "relaycheck.nodes" - CFG_TXN_ADDRESS = "relaycheck.txnAddress" - CFG_DATA = "relaycheck.data" - CFG_COOL_DOWN_TIME = "relaycheck.cooldownTime" - CFG_MAX_QUERY = "relaycheck.maxQuery" + CFG_TARGET_NODE = "relayChecker.targetNode" + CFG_TEST_NODES = "relayChecker.testNodes" + CFG_TX_ADDRESS = "relayChecker.txAddress" + CFG_DATA = "relayChecker.data" + CFG_COOLDOWN_TIME = "relayChecker.cooldownTime" + CFG_REPEAT = "relayChecker.repeat" ) func init() { - flag.StringSlice(CFG_TEST_NODES, []string{""}, "list of trusted entry nodes for auto peering") - flag.String(CFG_TARGET_NODE, "http://127.0.0.1:8080", "target node to test") - flag.String(CFG_TXN_ADDRESS, "SHIMMER99TEST99999999999999999999999999999999999999999999999999999999999999999999", "transaction address") + flag.StringSlice(CFG_TEST_NODES, []string{""}, "the list of nodes to check after the cooldown") + flag.String(CFG_TARGET_NODE, "http://127.0.0.1:8080", "the target node from the which transaction will be broadcasted from") + flag.String(CFG_TX_ADDRESS, "SHIMMER99TEST99999999999999999999999999999999999999999999999999999999999999999999", "the transaction address") flag.String(CFG_DATA, "TEST99BROADCAST99DATA", "data to broadcast") - flag.Int(CFG_COOL_DOWN_TIME, 10, "cooldown time after broadcast data") - flag.Int(CFG_MAX_QUERY, 1, "the repeat times of relay-checker") + flag.Int(CFG_COOLDOWN_TIME, 10, "the cooldown time after broadcasting the data on the specified target node") + flag.Int(CFG_REPEAT, 1, "the amount of times to repeat the relay-checker queries") } From 501b06e7111a79e2496306272e6878cf6f4f17e1 Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 23 Jan 2020 20:13:01 +0000 Subject: [PATCH 147/184] :art: improves network stats --- .../analysis/webinterface/httpserver/index.go | 101 ++++++++++++++++-- 1 file changed, 91 insertions(+), 10 deletions(-) diff --git a/plugins/analysis/webinterface/httpserver/index.go b/plugins/analysis/webinterface/httpserver/index.go index c3cab773b3..f91ca4f6f5 100644 --- a/plugins/analysis/webinterface/httpserver/index.go +++ b/plugins/analysis/webinterface/httpserver/index.go @@ -7,15 +7,84 @@ import ( func index(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, ` - + -
- +
+
+

+

+
+
+

+

+
+ `) From 0c272d3c369c52d7ef6f1fbb3cddce53db6c932b Mon Sep 17 00:00:00 2001 From: capossele Date: Thu, 23 Jan 2020 20:46:31 +0000 Subject: [PATCH 148/184] :art: makes node IDs shorter --- plugins/analysis/webinterface/httpserver/index.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/analysis/webinterface/httpserver/index.go b/plugins/analysis/webinterface/httpserver/index.go index f91ca4f6f5..ddda52702d 100644 --- a/plugins/analysis/webinterface/httpserver/index.go +++ b/plugins/analysis/webinterface/httpserver/index.go @@ -113,13 +113,13 @@ func index(w http.ResponseWriter, r *http.Request) { break; case "C": - connectNodes(e.data.substr(1, 64), e.data.substr(65, 128)); - console.log("Connect nodes:",e.data.substr(1, 64), " - ", e.data.substr(65, 128)); + connectNodes(e.data.substr(1, 64), e.data.substr(65, 64)); + console.log("Connect nodes:",e.data.substr(1, 64), " - ", e.data.substr(65, 64)); break; case "c": - disconnectNodes(e.data.substr(1, 64), e.data.substr(65, 128)); - console.log("Disconnect nodes:",e.data.substr(1, 64), " - ", e.data.substr(65, 128)); + disconnectNodes(e.data.substr(1, 64), e.data.substr(65, 64)); + console.log("Disconnect nodes:",e.data.substr(1, 64), " - ", e.data.substr(65, 64)); break; case "O": @@ -230,18 +230,18 @@ func index(w http.ResponseWriter, r *http.Request) { } function showNodeID(node) { - document.getElementById("nodeId").innerHTML = "ID: " + node.id; + document.getElementById("nodeId").innerHTML = "ID: " + node.id.substr(0, 16); var incoming = data.links.filter(l => (l.target.id == node.id)); document.getElementById("in").innerHTML = "IN: " + incoming.length + "
"; incoming.forEach(function(link){ - document.getElementById("in").innerHTML += link.source.id + " → NODE
"; + document.getElementById("in").innerHTML += link.source.id.substr(0, 16) + " → NODE
"; }); var outgoing = data.links.filter(l => (l.source.id == node.id)); document.getElementById("out").innerHTML = "OUT: " + outgoing.length + "
"; outgoing.forEach(function(link){ - document.getElementById("out").innerHTML += "NODE → " + link.target.id + "
"; + document.getElementById("out").innerHTML += "NODE → " + link.target.id.substr(0, 16) + "
"; }); } From a436b66e37e3de4004dab605c65a6f8043f8c551 Mon Sep 17 00:00:00 2001 From: capossele Date: Fri, 24 Jan 2020 09:36:36 +0000 Subject: [PATCH 149/184] :art: highlights link direction --- .../analysis/webinterface/httpserver/index.go | 57 +++++++++++++++++-- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/plugins/analysis/webinterface/httpserver/index.go b/plugins/analysis/webinterface/httpserver/index.go index ddda52702d..e4009b1ded 100644 --- a/plugins/analysis/webinterface/httpserver/index.go +++ b/plugins/analysis/webinterface/httpserver/index.go @@ -143,14 +143,45 @@ func index(w http.ResponseWriter, r *http.Request) { var existingLinks = {}; + let highlightNodes = []; + let highlightLinks = []; + let highlightLink = null; + const elem = document.getElementById("graphc"); + //.onNodeHover(node => elem.style.cursor = node ? 'pointer' : null) + const Graph = ForceGraph3D()(elem) + .graphData(data) .enableNodeDrag(false) - .onNodeHover(node => elem.style.cursor = node ? 'pointer' : null) - .onNodeClick(showNodeID) - .nodeColor(node => node.online ? 'rgba(0,255,0,1)' : 'rgba(255,255,255,1)') - .graphData(data); + .onNodeClick(showNodeStat) + .nodeColor(node => highlightNodes.indexOf(node) === -1 ? 'rgba(0,255,255,0.6)' : 'rgb(255,0,0,1)') + .linkWidth(link => highlightLinks.indexOf(link) === -1 ? 1 : 4) + .linkDirectionalParticles(link => highlightLinks.indexOf(link) === -1 ? 0 : 4) + .linkDirectionalParticleWidth(4) + .onNodeHover(node => { + // no state change + if ((!node && !highlightNodes.length) || (highlightNodes.length === 1 && highlightNodes[0] === node)) return; + + highlightNodes = node ? [node] : []; + + highlightLinks = []; + clearNodeStat(); + if (node != null) { + highlightLinks = data.links.filter(l => (l.target.id == node.id) || (l.source.id == node.id)); + showNodeStat(node); + } + updateHighlight(); + }) + .onLinkHover(link => { + // no state change + if ((!link && !highlightLinks.length) || (highlightLinks.length === 1 && highlightLinks[0] === link)) return; + + highlightLinks = [link]; + highlightNodes = link ? [link.source, link.target] : []; + + updateHighlight(); + }); var updateRequired = true; @@ -162,6 +193,14 @@ func index(w http.ResponseWriter, r *http.Request) { } }, 500) + function updateHighlight() { + // trigger update of highlighted objects in scene + Graph + .nodeColor(Graph.nodeColor()) + .linkWidth(Graph.linkWidth()) + .linkDirectionalParticles(Graph.linkDirectionalParticles()); + } + updateGraph = function() { updateRequired = true; }; @@ -229,7 +268,13 @@ func index(w http.ResponseWriter, r *http.Request) { updateGraph(); } - function showNodeID(node) { + function clearNodeStat() { + document.getElementById("nodeId").innerHTML = "" + document.getElementById("in").innerHTML = "" + document.getElementById("out").innerHTML = "" + } + + function showNodeStat(node) { document.getElementById("nodeId").innerHTML = "ID: " + node.id.substr(0, 16); var incoming = data.links.filter(l => (l.target.id == node.id)); @@ -243,6 +288,8 @@ func index(w http.ResponseWriter, r *http.Request) { outgoing.forEach(function(link){ document.getElementById("out").innerHTML += "NODE → " + link.target.id.substr(0, 16) + "
"; }); + + nodesById[node.id].color = 'rgba(0,255,255,1)' } `) From d243f444d234a96462df766f6e5ef5eb4cbe51be Mon Sep 17 00:00:00 2001 From: capossele Date: Fri, 24 Jan 2020 10:21:13 +0000 Subject: [PATCH 150/184] :art: replaces IN and OUT with INBOUND and OUTBOUND --- plugins/analysis/webinterface/httpserver/index.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/analysis/webinterface/httpserver/index.go b/plugins/analysis/webinterface/httpserver/index.go index e4009b1ded..894e36b59e 100644 --- a/plugins/analysis/webinterface/httpserver/index.go +++ b/plugins/analysis/webinterface/httpserver/index.go @@ -156,9 +156,9 @@ func index(w http.ResponseWriter, r *http.Request) { .enableNodeDrag(false) .onNodeClick(showNodeStat) .nodeColor(node => highlightNodes.indexOf(node) === -1 ? 'rgba(0,255,255,0.6)' : 'rgb(255,0,0,1)') - .linkWidth(link => highlightLinks.indexOf(link) === -1 ? 1 : 4) - .linkDirectionalParticles(link => highlightLinks.indexOf(link) === -1 ? 0 : 4) - .linkDirectionalParticleWidth(4) + .linkWidth(link => highlightLinks.indexOf(link) === -1 ? 1 : 3) + .linkDirectionalParticles(link => highlightLinks.indexOf(link) === -1 ? 0 : 3) + .linkDirectionalParticleWidth(3) .onNodeHover(node => { // no state change if ((!node && !highlightNodes.length) || (highlightNodes.length === 1 && highlightNodes[0] === node)) return; @@ -278,13 +278,13 @@ func index(w http.ResponseWriter, r *http.Request) { document.getElementById("nodeId").innerHTML = "ID: " + node.id.substr(0, 16); var incoming = data.links.filter(l => (l.target.id == node.id)); - document.getElementById("in").innerHTML = "IN: " + incoming.length + "
"; + document.getElementById("in").innerHTML = "INBOUND (accepted): " + incoming.length + "
"; incoming.forEach(function(link){ document.getElementById("in").innerHTML += link.source.id.substr(0, 16) + " → NODE
"; }); var outgoing = data.links.filter(l => (l.source.id == node.id)); - document.getElementById("out").innerHTML = "OUT: " + outgoing.length + "
"; + document.getElementById("out").innerHTML = "OUTBOUND (chosen): " + outgoing.length + "
"; outgoing.forEach(function(link){ document.getElementById("out").innerHTML += "NODE → " + link.target.id.substr(0, 16) + "
"; }); From 6a408ad7fe901ec04c9aa092922eca15de7c9d86 Mon Sep 17 00:00:00 2001 From: Wolfgang Welz Date: Fri, 24 Jan 2020 11:55:59 +0100 Subject: [PATCH 151/184] Feat: Add config keys to make bind addresses configurable (#172) * configure bind and external address * Move bind and external to network * Ignore empty seed * Update default config * Add bind address config for analysis http server * Make graph config consistent * Add bind address to dashboard * Do not print config on startup * Apply suggestions from code review Co-Authored-By: Luca Moser * Apply suggestions from code review Co-Authored-By: Luca Moser Co-authored-by: Luca Moser --- config.json | 69 +++++++++------ packages/autopeering/discover/manager_test.go | 4 +- .../autopeering/discover/protocol_test.go | 7 +- packages/autopeering/peer/local.go | 6 +- packages/autopeering/peer/local_test.go | 39 +++++---- packages/autopeering/peer/mapdb_test.go | 7 +- .../autopeering/selection/manager_test.go | 5 +- .../autopeering/selection/protocol_test.go | 15 +++- packages/autopeering/server/server.go | 9 +- packages/autopeering/server/server_test.go | 13 ++- packages/gossip/manager_test.go | 72 +++++++--------- packages/gossip/server/server.go | 31 ++----- packages/gossip/server/server_test.go | 84 +++++++++---------- packages/parameter/parameter.go | 21 ++++- plugins/analysis/client/parameters.go | 2 +- plugins/analysis/server/parameters.go | 2 +- .../webinterface/httpserver/parameters.go | 13 +++ .../webinterface/httpserver/plugin.go | 36 +++++--- plugins/autopeering/autopeering.go | 35 ++++---- plugins/autopeering/local/local.go | 39 +++++---- plugins/autopeering/local/parameters.go | 12 +-- plugins/dashboard/parameters.go | 13 +++ plugins/dashboard/plugin.go | 66 ++++++++++----- plugins/gossip/gossip.go | 41 ++++++--- plugins/graph/graph.go | 2 +- plugins/graph/parameters.go | 34 ++++---- plugins/graph/plugin.go | 40 +++++---- 27 files changed, 420 insertions(+), 297 deletions(-) create mode 100644 plugins/analysis/webinterface/httpserver/parameters.go create mode 100644 plugins/dashboard/parameters.go diff --git a/config.json b/config.json index 9b8fe5db33..b702dcb030 100644 --- a/config.json +++ b/config.json @@ -1,49 +1,64 @@ { "analysis": { - "serveraddress": "ressims.iota.cafe:188", - "serverport": 0 + "client": { + "serverAddress": "ressims.iota.cafe:188" + }, + "server": { + "port": 0 + }, + "httpServer": { + "bindAddress": "0.0.0.0:80" + } }, "autopeering": { - "address": "0.0.0.0", - "entrynodes": [ + "entryNodes": [ "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq/Cx9ai6g=@116.202.49.178:14626" ], "port": 14626 }, + "dashboard": { + "bindAddress": "0.0.0.0:8081" + }, "database": { "directory": "mainnetdb" }, "gossip": { "port": 14666 }, - "webapi": { - "bindAddress": "0.0.0.0:8080", - "auth": { - "username": "goshimmer", - "password": "goshimmer", - "privateKey": "uUUavNbdr32jE9CqnSMCKt4HMu9AZ2K4rKekUSPx9jk83eyeM7xewv5CqUKYMC9" - } - }, "graph": { - "webrootPath": "./IOTAtangle/webroot", - "socketioPath": "./socket.io-client/dist/socket.io.js", + "bindAddress": "127.0.0.1:8083", "domain": "", - "host": "127.0.0.1", - "port": 8083, - "networkName": "GoShimmer" + "networkName": "GoShimmer", + "socketIOPath": "socket.io-client/dist/socket.io.js", + "webrootPath": "IOTAtangle/webroot" }, "logger": { - "Level": "info", - "DisableCaller": false, - "DisableStacktrace": false, - "Encoding": "console", - "OutputPaths": [ + "level": "info", + "disableCaller": false, + "disableStacktrace": false, + "encoding": "console", + "outputPaths": [ "goshimmer.log" - ] + ], + "disableEvents": false + }, + "network": { + "bindAddress": "0.0.0.0", + "externalAddress": "auto" }, "node": { - "disableplugins": "", - "enableplugins": [], - "loglevel": 0 + "disablePlugins": [], + "enablePlugins": [] + }, + "webapi": { + "auth": { + "password": "goshimmer", + "privateKey": "", + "username": "goshimmer" + }, + "bindAddress": "0.0.0.0:8080" + }, + "zeromq": { + "port": 5556 } -} \ No newline at end of file +} diff --git a/packages/autopeering/discover/manager_test.go b/packages/autopeering/discover/manager_test.go index afe6a3899c..fb0132a1b4 100644 --- a/packages/autopeering/discover/manager_test.go +++ b/packages/autopeering/discover/manager_test.go @@ -33,7 +33,9 @@ func (m *NetworkMock) DiscoveryRequest(p *peer.Peer) ([]*peer.Peer, error) { } func newNetworkMock() *NetworkMock { - local, _ := peer.NewLocal("mock", "0", peer.NewMemoryDB(log)) + services := service.New() + services.Update(service.PeeringKey, "mock", "local") + local, _ := peer.NewLocal(services, peer.NewMemoryDB(log)) return &NetworkMock{ // no database needed loc: local, diff --git a/packages/autopeering/discover/protocol_test.go b/packages/autopeering/discover/protocol_test.go index fd294f7bca..92a5740dd6 100644 --- a/packages/autopeering/discover/protocol_test.go +++ b/packages/autopeering/discover/protocol_test.go @@ -31,8 +31,11 @@ func init() { // newTest creates a new discovery server and also returns the teardown. func newTest(t require.TestingT, trans transport.Transport, logger *logger.Logger, masters ...*peer.Peer) (*server.Server, *Protocol, func()) { l := logger.Named(trans.LocalAddr().String()) + + services := service.New() + services.Update(service.PeeringKey, trans.LocalAddr().Network(), trans.LocalAddr().String()) db := peer.NewMemoryDB(l.Named("db")) - local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) + local, err := peer.NewLocal(services, db) require.NoError(t, err) cfg := Config{ @@ -40,7 +43,7 @@ func newTest(t require.TestingT, trans transport.Transport, logger *logger.Logge MasterPeers: masters, } prot := New(local, cfg) - srv := server.Listen(local, trans, l.Named("srv"), prot) + srv := server.Serve(local, trans, l.Named("srv"), prot) prot.Start(srv) teardown := func() { diff --git a/packages/autopeering/peer/local.go b/packages/autopeering/peer/local.go index 19595a32cc..989d0ff834 100644 --- a/packages/autopeering/peer/local.go +++ b/packages/autopeering/peer/local.go @@ -44,7 +44,7 @@ func newLocal(key PrivateKey, serviceRecord *service.Record, db DB) *Local { // NewLocal creates a new local peer linked to the provided db. // If an optional seed is provided, the seed is used to generate the private key. Without a seed, // the provided key is loaded from the provided database and generated if not stored there. -func NewLocal(network string, address string, db DB, seed ...[]byte) (*Local, error) { +func NewLocal(serviceRecord *service.Record, db DB, seed ...[]byte) (*Local, error) { var key PrivateKey if len(seed) > 0 { key = PrivateKey(ed25519.NewKeyFromSeed(seed[0])) @@ -62,10 +62,6 @@ func NewLocal(network string, address string, db DB, seed ...[]byte) (*Local, er if l := len(key); l != ed25519.PrivateKeySize { return nil, fmt.Errorf("invalid key length: %d, need %d", l, ed25519.PrivateKeySize) } - // update the external address used for the peering - serviceRecord := service.New() - serviceRecord.Update(service.PeeringKey, network, address) - return newLocal(key, serviceRecord, db), nil } diff --git a/packages/autopeering/peer/local_test.go b/packages/autopeering/peer/local_test.go index aa50862c1a..469ef80f7c 100644 --- a/packages/autopeering/peer/local_test.go +++ b/packages/autopeering/peer/local_test.go @@ -28,36 +28,45 @@ func TestPublicKey(t *testing.T) { assert.EqualValues(t, pub, local.PublicKey()) } -func newTestLocal(t require.TestingT) *Local { - priv, err := generatePrivateKey() - require.NoError(t, err) - return newLocal(priv, newTestServiceRecord(), nil) -} - func TestAddress(t *testing.T) { - local := newTestLocal(t) + local := newTestLocal(t, nil) address := local.Services().Get(service.PeeringKey).String() assert.EqualValues(t, address, local.Address()) } func TestPrivateSalt(t *testing.T) { - p := newTestLocal(t) + p := newTestLocal(t, nil) - salt, _ := salt.NewSalt(time.Second * 10) - p.SetPrivateSalt(salt) + s, _ := salt.NewSalt(time.Second * 10) + p.SetPrivateSalt(s) got := p.GetPrivateSalt() - assert.Equal(t, salt, got, "Private salt") + assert.Equal(t, s, got, "Private salt") } func TestPublicSalt(t *testing.T) { - p := newTestLocal(t) + p := newTestLocal(t, nil) - salt, _ := salt.NewSalt(time.Second * 10) - p.SetPublicSalt(salt) + s, _ := salt.NewSalt(time.Second * 10) + p.SetPublicSalt(s) got := p.GetPublicSalt() - assert.Equal(t, salt, got, "Public salt") + assert.Equal(t, s, got, "Public salt") +} + +func newTestLocal(t require.TestingT, db DB) *Local { + var priv PrivateKey + var err error + if db == nil { + priv, err = generatePrivateKey() + require.NoError(t, err) + } else { + priv, err = db.LocalPrivateKey() + require.NoError(t, err) + } + services := service.New() + services.Update(service.PeeringKey, testNetwork, testAddress) + return newLocal(priv, services, db) } diff --git a/packages/autopeering/peer/mapdb_test.go b/packages/autopeering/peer/mapdb_test.go index 5c7580b743..494f669181 100644 --- a/packages/autopeering/peer/mapdb_test.go +++ b/packages/autopeering/peer/mapdb_test.go @@ -58,12 +58,9 @@ func TestMapDBSeedPeers(t *testing.T) { func TestMapDBLocal(t *testing.T) { db := NewMemoryDB(log) - l1, err := NewLocal(testNetwork, testAddress, db) - require.NoError(t, err) + l1 := newTestLocal(t, db) assert.Equal(t, len(l1.PublicKey()), ed25519.PublicKeySize) - l2, err := NewLocal(testNetwork, testAddress, db) - require.NoError(t, err) - + l2 := newTestLocal(t, db) assert.Equal(t, l1, l2) } diff --git a/packages/autopeering/selection/manager_test.go b/packages/autopeering/selection/manager_test.go index af24ee4161..cf5a961f77 100644 --- a/packages/autopeering/selection/manager_test.go +++ b/packages/autopeering/selection/manager_test.go @@ -7,6 +7,7 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/autopeering/salt" "github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/logger" @@ -186,7 +187,9 @@ type networkMock struct { } func newNetworkMock(name string, mgrMap map[peer.ID]*manager, log *logger.Logger) *networkMock { - local, _ := peer.NewLocal("mock", name, peer.NewMemoryDB(log)) + services := service.New() + services.Update(service.PeeringKey, "mock", name) + local, _ := peer.NewLocal(services, peer.NewMemoryDB(log)) return &networkMock{ loc: local, mgr: mgrMap, diff --git a/packages/autopeering/selection/protocol_test.go b/packages/autopeering/selection/protocol_test.go index ce6e59e1ba..c2e9903560 100644 --- a/packages/autopeering/selection/protocol_test.go +++ b/packages/autopeering/selection/protocol_test.go @@ -6,6 +6,7 @@ import ( "github.com/iotaledger/goshimmer/packages/autopeering/discover" "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/autopeering/salt" "github.com/iotaledger/goshimmer/packages/autopeering/server" "github.com/iotaledger/goshimmer/packages/autopeering/transport" @@ -31,15 +32,18 @@ func (d dummyDiscovery) GetVerifiedPeers() []*peer.Peer { retur // newTest creates a new neighborhood server and also returns the teardown. func newTest(t require.TestingT, trans transport.Transport) (*server.Server, *Protocol, func()) { l := log.Named(trans.LocalAddr().String()) + + services := service.New() + services.Update(service.PeeringKey, trans.LocalAddr().Network(), trans.LocalAddr().String()) db := peer.NewMemoryDB(l.Named("db")) - local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) + local, err := peer.NewLocal(services, db) require.NoError(t, err) // add the new peer to the global map for dummyDiscovery peerMap[local.ID()] = &local.Peer prot := New(local, dummyDiscovery{}, Config{Log: l}) - srv := server.Listen(local, trans, l.Named("srv"), prot) + srv := server.Serve(local, trans, l.Named("srv"), prot) prot.Start(srv) teardown := func() { @@ -155,8 +159,11 @@ func TestProtocol(t *testing.T) { // newTest creates a new server handling discover as well as neighborhood and also returns the teardown. func newFullTest(t require.TestingT, trans transport.Transport, masterPeers ...*peer.Peer) (*server.Server, *Protocol, func()) { l := log.Named(trans.LocalAddr().String()) + + services := service.New() + services.Update(service.PeeringKey, trans.LocalAddr().Network(), trans.LocalAddr().String()) db := peer.NewMemoryDB(l.Named("db")) - local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) + local, err := peer.NewLocal(services, db) require.NoError(t, err) discovery := discover.New(local, discover.Config{ @@ -167,7 +174,7 @@ func newFullTest(t require.TestingT, trans transport.Transport, masterPeers ...* Log: l.Named("sel"), }) - srv := server.Listen(local, trans, l.Named("srv"), discovery, selection) + srv := server.Serve(local, trans, l.Named("srv"), discovery, selection) discovery.Start(srv) selection.Start(srv) diff --git a/packages/autopeering/server/server.go b/packages/autopeering/server/server.go index 88ca6cc55d..d1bca6aabd 100644 --- a/packages/autopeering/server/server.go +++ b/packages/autopeering/server/server.go @@ -68,10 +68,10 @@ type reply struct { matchedRequest chan<- bool // a matching request is indicated via this channel } -// Listen starts a new peer server using the given transport layer for communication. +// Serve starts a new peer server using the given transport layer for communication. // Sent data is signed using the identity of the local peer, // received data with a valid peer signature is handled according to the provided Handler. -func Listen(local *peer.Local, t transport.Transport, log *logger.Logger, h ...Handler) *Server { +func Serve(local *peer.Local, t transport.Transport, log *logger.Logger, h ...Handler) *Server { srv := &Server{ local: local, trans: t, @@ -88,7 +88,10 @@ func Listen(local *peer.Local, t transport.Transport, log *logger.Logger, h ...H go srv.replyLoop() go srv.readLoop() - log.Debugw("server started", "addr", srv.LocalAddr(), "#handlers", len(h)) + log.Debugw("server started", + "network", srv.LocalAddr().Network(), + "address", srv.LocalAddr().String(), + "#handlers", len(h)) return srv } diff --git a/packages/autopeering/server/server_test.go b/packages/autopeering/server/server_test.go index 58bc5a60e3..e6725fc0fa 100644 --- a/packages/autopeering/server/server_test.go +++ b/packages/autopeering/server/server_test.go @@ -5,6 +5,7 @@ import ( "time" "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/autopeering/salt" "github.com/iotaledger/goshimmer/packages/autopeering/transport" "github.com/iotaledger/hive.go/logger" @@ -96,8 +97,9 @@ func unmarshal(data []byte) (Message, error) { } func TestSrvEncodeDecodePing(t *testing.T) { - // create minimal server just containing the local peer - local, err := peer.NewLocal("dummy", "local", peer.NewMemoryDB(log)) + services := service.New() + services.Update(service.PeeringKey, "dummy", "local") + local, err := peer.NewLocal(services, peer.NewMemoryDB(log)) require.NoError(t, err) s := &Server{local: local} @@ -114,8 +116,11 @@ func TestSrvEncodeDecodePing(t *testing.T) { func newTestServer(t require.TestingT, name string, trans transport.Transport) (*Server, func()) { l := log.Named(name) + + services := service.New() + services.Update(service.PeeringKey, trans.LocalAddr().Network(), trans.LocalAddr().String()) db := peer.NewMemoryDB(l.Named("db")) - local, err := peer.NewLocal(trans.LocalAddr().Network(), trans.LocalAddr().String(), db) + local, err := peer.NewLocal(services, db) require.NoError(t, err) s, _ := salt.NewSalt(100 * time.Second) @@ -123,7 +128,7 @@ func newTestServer(t require.TestingT, name string, trans transport.Transport) ( s, _ = salt.NewSalt(100 * time.Second) local.SetPublicSalt(s) - srv := Listen(local, trans, l, HandlerFunc(handle)) + srv := Serve(local, trans, l, HandlerFunc(handle)) teardown := func() { srv.Close() diff --git a/packages/gossip/manager_test.go b/packages/gossip/manager_test.go index eb86bf01e7..ea19d48097 100644 --- a/packages/gossip/manager_test.go +++ b/packages/gossip/manager_test.go @@ -27,46 +27,6 @@ var ( func getTestTransaction([]byte) ([]byte, error) { return testTxData, nil } -func getTCPAddress(t require.TestingT) string { - tcpAddr, err := net.ResolveTCPAddr("tcp", "localhost:0") - require.NoError(t, err) - lis, err := net.ListenTCP("tcp", tcpAddr) - require.NoError(t, err) - - addr := lis.Addr().String() - require.NoError(t, lis.Close()) - - return addr -} - -func newTestManager(t require.TestingT, name string) (*Manager, func(), *peer.Peer) { - l := log.Named(name) - db := peer.NewMemoryDB(l.Named("db")) - local, err := peer.NewLocal("peering", name, db) - require.NoError(t, err) - - // enable TCP gossipping - require.NoError(t, local.UpdateService(service.GossipKey, "tcp", getTCPAddress(t))) - - mgr := NewManager(local, getTestTransaction, l) - - srv, err := server.ListenTCP(local, l) - require.NoError(t, err) - - // update the service with the actual address - require.NoError(t, local.UpdateService(service.GossipKey, srv.LocalAddr().Network(), srv.LocalAddr().String())) - - // start the actual gossipping - mgr.Start(srv) - - detach := func() { - mgr.Close() - srv.Close() - db.Close() - } - return mgr, detach, &local.Peer -} - func TestClose(t *testing.T) { _, detach := newEventMock(t) defer detach() @@ -409,6 +369,38 @@ func TestTxRequest(t *testing.T) { e.AssertExpectations(t) } +func newTestManager(t require.TestingT, name string) (*Manager, func(), *peer.Peer) { + l := log.Named(name) + + services := service.New() + services.Update(service.PeeringKey, "peering", name) + db := peer.NewMemoryDB(l.Named("db")) + local, err := peer.NewLocal(services, db) + require.NoError(t, err) + + laddr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:0") + require.NoError(t, err) + lis, err := net.ListenTCP("tcp", laddr) + require.NoError(t, err) + + // enable TCP gossipping + require.NoError(t, local.UpdateService(service.GossipKey, lis.Addr().Network(), lis.Addr().String())) + + srv := server.ServeTCP(local, lis, l) + + // start the actual gossipping + mgr := NewManager(local, getTestTransaction, l) + mgr.Start(srv) + + detach := func() { + mgr.Close() + srv.Close() + _ = lis.Close() + db.Close() + } + return mgr, detach, &local.Peer +} + func newEventMock(t mock.TestingT) (*eventMock, func()) { e := &eventMock{} e.Test(t) diff --git a/packages/gossip/server/server.go b/packages/gossip/server/server.go index bb52798c93..c3853ac049 100644 --- a/packages/gossip/server/server.go +++ b/packages/gossip/server/server.go @@ -77,39 +77,22 @@ type accept struct { conn net.Conn // the actual network connection } -// ListenTCP creates the object and starts listening for incoming connections. -func ListenTCP(local *peer.Local, log *zap.SugaredLogger) (*TCP, error) { +// ServeTCP creates the object and starts listening for incoming connections. +func ServeTCP(local *peer.Local, listener *net.TCPListener, log *zap.SugaredLogger) *TCP { t := &TCP{ local: local, + publicAddr: local.Services().Get(service.GossipKey), + listener: listener, log: log, addAcceptMatcher: make(chan *acceptMatcher), acceptReceived: make(chan accept), closing: make(chan struct{}), } - - t.publicAddr = local.Services().Get(service.GossipKey) if t.publicAddr == nil { - return nil, ErrNoGossip - } - tcpAddr, err := net.ResolveTCPAddr(t.publicAddr.Network(), t.publicAddr.String()) - if err != nil { - return nil, err - } - // if the ip is an external ip, set it to unspecified - if tcpAddr.IP.IsGlobalUnicast() { - if tcpAddr.IP.To4() != nil { - tcpAddr.IP = net.IPv4zero - } else { - tcpAddr.IP = net.IPv6unspecified - } + panic(ErrNoGossip) } - listener, err := net.ListenTCP(t.publicAddr.Network(), tcpAddr) - if err != nil { - return nil, err - } - t.listener = listener - t.log.Debugw("listening started", + t.log.Debugw("server started", "network", listener.Addr().Network(), "address", listener.Addr().String(), ) @@ -118,7 +101,7 @@ func ListenTCP(local *peer.Local, log *zap.SugaredLogger) (*TCP, error) { go t.run() go t.listenLoop() - return t, nil + return t } // Close stops listening on the gossip address. diff --git a/packages/gossip/server/server_test.go b/packages/gossip/server/server_test.go index 9aa398fb88..5f2778a10e 100644 --- a/packages/gossip/server/server_test.go +++ b/packages/gossip/server/server_test.go @@ -17,48 +17,17 @@ const graceTime = 5 * time.Millisecond var log = logger.NewExampleLogger("server") -func getTCPAddress(t require.TestingT) string { - laddr, err := net.ResolveTCPAddr("tcp", "localhost:0") - require.NoError(t, err) - lis, err := net.ListenTCP("tcp", laddr) - require.NoError(t, err) - - addr := lis.Addr().String() - require.NoError(t, lis.Close()) - - return addr -} - -func newTest(t require.TestingT, name string) (*TCP, func()) { - l := log.Named(name) - db := peer.NewMemoryDB(l.Named("db")) - local, err := peer.NewLocal("peering", name, db) - require.NoError(t, err) - - // enable TCP gossipping - require.NoError(t, local.UpdateService(service.GossipKey, "tcp", getTCPAddress(t))) - - trans, err := ListenTCP(local, l) - require.NoError(t, err) - - teardown := func() { - trans.Close() - db.Close() - } - return trans, teardown -} - func getPeer(t *TCP) *peer.Peer { return &t.local.Peer } func TestClose(t *testing.T) { - _, teardown := newTest(t, "A") + _, teardown := newTestServer(t, "A") teardown() } func TestUnansweredAccept(t *testing.T) { - transA, closeA := newTest(t, "A") + transA, closeA := newTestServer(t, "A") defer closeA() _, err := transA.AcceptPeer(getPeer(transA)) @@ -66,7 +35,7 @@ func TestUnansweredAccept(t *testing.T) { } func TestCloseWhileAccepting(t *testing.T) { - transA, closeA := newTest(t, "A") + transA, closeA := newTestServer(t, "A") var wg sync.WaitGroup wg.Add(1) @@ -82,7 +51,7 @@ func TestCloseWhileAccepting(t *testing.T) { } func TestUnansweredDial(t *testing.T) { - transA, closeA := newTest(t, "A") + transA, closeA := newTestServer(t, "A") defer closeA() // create peer with invalid gossip address @@ -95,7 +64,7 @@ func TestUnansweredDial(t *testing.T) { } func TestNoHandshakeResponse(t *testing.T) { - transA, closeA := newTest(t, "A") + transA, closeA := newTestServer(t, "A") defer closeA() // accept and read incoming connections @@ -119,7 +88,7 @@ func TestNoHandshakeResponse(t *testing.T) { } func TestNoHandshakeRequest(t *testing.T) { - transA, closeA := newTest(t, "A") + transA, closeA := newTestServer(t, "A") defer closeA() var wg sync.WaitGroup @@ -140,9 +109,9 @@ func TestNoHandshakeRequest(t *testing.T) { } func TestConnect(t *testing.T) { - transA, closeA := newTest(t, "A") + transA, closeA := newTestServer(t, "A") defer closeA() - transB, closeB := newTest(t, "B") + transB, closeB := newTestServer(t, "B") defer closeB() var wg sync.WaitGroup @@ -153,7 +122,7 @@ func TestConnect(t *testing.T) { c, err := transA.AcceptPeer(getPeer(transB)) assert.NoError(t, err) if assert.NotNil(t, c) { - c.Close() + _ = c.Close() } }() time.Sleep(graceTime) @@ -162,7 +131,7 @@ func TestConnect(t *testing.T) { c, err := transB.DialPeer(getPeer(transA)) assert.NoError(t, err) if assert.NotNil(t, c) { - c.Close() + _ = c.Close() } }() @@ -170,11 +139,11 @@ func TestConnect(t *testing.T) { } func TestWrongConnect(t *testing.T) { - transA, closeA := newTest(t, "A") + transA, closeA := newTestServer(t, "A") defer closeA() - transB, closeB := newTest(t, "B") + transB, closeB := newTestServer(t, "B") defer closeB() - transC, closeC := newTest(t, "C") + transC, closeC := newTestServer(t, "C") defer closeC() var wg sync.WaitGroup @@ -194,3 +163,30 @@ func TestWrongConnect(t *testing.T) { wg.Wait() } + +func newTestServer(t require.TestingT, name string) (*TCP, func()) { + l := log.Named(name) + + services := service.New() + services.Update(service.PeeringKey, "peering", name) + db := peer.NewMemoryDB(l.Named("db")) + local, err := peer.NewLocal(services, db) + require.NoError(t, err) + + laddr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:0") + require.NoError(t, err) + lis, err := net.ListenTCP("tcp", laddr) + require.NoError(t, err) + + // enable TCP gossipping + require.NoError(t, local.UpdateService(service.GossipKey, lis.Addr().Network(), lis.Addr().String())) + + srv := ServeTCP(local, lis, l) + + teardown := func() { + srv.Close() + _ = lis.Close() + db.Close() + } + return srv, teardown +} diff --git a/packages/parameter/parameter.go b/packages/parameter/parameter.go index fa1adfee75..7d390f1fb7 100644 --- a/packages/parameter/parameter.go +++ b/packages/parameter/parameter.go @@ -1,6 +1,7 @@ package parameter import ( + "github.com/iotaledger/hive.go/logger" "github.com/iotaledger/hive.go/parameter" flag "github.com/spf13/pflag" "github.com/spf13/viper" @@ -11,10 +12,26 @@ var ( configName = flag.StringP("config", "c", "config", "Filename of the config file without the file extension") configDirPath = flag.StringP("config-dir", "d", ".", "Path to the directory containing the config file") - // Viper - NodeConfig = viper.New() + // viper + NodeConfig *viper.Viper + + // logger + defaultLoggerConfig = logger.Config{ + Level: "info", + DisableCaller: false, + DisableStacktrace: false, + Encoding: "console", + OutputPaths: []string{"goshimmer.log"}, + DisableEvents: false, + } ) +func init() { + // set the default logger config + NodeConfig = viper.New() + NodeConfig.SetDefault(logger.ViperKey, defaultLoggerConfig) +} + // FetchConfig fetches config values from a dir defined via CLI flag --config-dir (or the current working dir if not set). // // It automatically reads in a single config file starting with "config" (can be changed via the --config CLI flag) diff --git a/plugins/analysis/client/parameters.go b/plugins/analysis/client/parameters.go index a60d143282..b875fadf36 100644 --- a/plugins/analysis/client/parameters.go +++ b/plugins/analysis/client/parameters.go @@ -5,7 +5,7 @@ import ( ) const ( - CFG_SERVER_ADDRESS = "analysis.serverAddress" + CFG_SERVER_ADDRESS = "analysis.client.serverAddress" ) func init() { diff --git a/plugins/analysis/server/parameters.go b/plugins/analysis/server/parameters.go index e27b4a9e2a..a8d66903b7 100644 --- a/plugins/analysis/server/parameters.go +++ b/plugins/analysis/server/parameters.go @@ -5,7 +5,7 @@ import ( ) const ( - CFG_SERVER_PORT = "analysis.serverPort" + CFG_SERVER_PORT = "analysis.server.port" ) func init() { diff --git a/plugins/analysis/webinterface/httpserver/parameters.go b/plugins/analysis/webinterface/httpserver/parameters.go new file mode 100644 index 0000000000..a32ab36fd8 --- /dev/null +++ b/plugins/analysis/webinterface/httpserver/parameters.go @@ -0,0 +1,13 @@ +package httpserver + +import ( + flag "github.com/spf13/pflag" +) + +const ( + CFG_BIND_ADDRESS = "analysis.httpServer.bindAddress" +) + +func init() { + flag.String(CFG_BIND_ADDRESS, "0.0.0.0:80", "the bind address for the web API") +} diff --git a/plugins/analysis/webinterface/httpserver/plugin.go b/plugins/analysis/webinterface/httpserver/plugin.go index d8330000f2..c84fabe599 100644 --- a/plugins/analysis/webinterface/httpserver/plugin.go +++ b/plugins/analysis/webinterface/httpserver/plugin.go @@ -3,9 +3,9 @@ package httpserver import ( "errors" "net/http" - "sync" "time" + "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/logger" @@ -25,36 +25,46 @@ func Configure() { log = logger.NewLogger(name) router = http.NewServeMux() - httpServer = &http.Server{Addr: ":80", Handler: router} + + httpServer = &http.Server{ + Addr: parameter.NodeConfig.GetString(CFG_BIND_ADDRESS), + Handler: router, + } router.Handle("/datastream", websocket.Handler(dataStream)) router.HandleFunc("/", index) } func Run() { + log.Infof("Starting %s ...", name) if err := daemon.BackgroundWorker(name, start, shutdown.ShutdownPriorityAnalysis); err != nil { log.Errorf("Error starting as daemon: %s", err) } } func start(shutdownSignal <-chan struct{}) { - var wg sync.WaitGroup - wg.Add(1) + stopped := make(chan struct{}) go func() { - defer wg.Done() - log.Infof(name+" started: address=%s", httpServer.Addr) - if err := httpServer.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { - log.Warnf("Error listening: %s", err) + log.Infof("Started %s: http://%s", name, httpServer.Addr) + if err := httpServer.ListenAndServe(); err != nil { + if !errors.Is(err, http.ErrServerClosed) { + log.Errorf("Error serving: %s", err) + } + close(stopped) } }() - <-shutdownSignal - log.Info("Stopping " + name + " ...") + + select { + case <-shutdownSignal: + case <-stopped: + } + + log.Infof("Stopping %s ...", name) ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() if err := httpServer.Shutdown(ctx); err != nil { - log.Errorf("Error closing: %s", err) + log.Errorf("Error stopping: %s", err) } - wg.Wait() - log.Info("Stopping " + name + " ... done") + log.Info("Stopping %s ... done", name) } diff --git a/plugins/autopeering/autopeering.go b/plugins/autopeering/autopeering.go index 76c8122a6b..18d04fc07d 100644 --- a/plugins/autopeering/autopeering.go +++ b/plugins/autopeering/autopeering.go @@ -57,31 +57,30 @@ func configureAP() { func start(shutdownSignal <-chan struct{}) { defer log.Info("Stopping " + name + " ... done") - loc := local.GetInstance() - peeringAddr := loc.Services().Get(service.PeeringKey) - udpAddr, err := net.ResolveUDPAddr(peeringAddr.Network(), peeringAddr.String()) + lPeer := local.GetInstance() + // use the port of the peering service + peeringAddr := lPeer.Services().Get(service.PeeringKey) + _, peeringPort, err := net.SplitHostPort(peeringAddr.String()) if err != nil { - log.Fatalf("ResolveUDPAddr: %v", err) + panic(err) } - - // if the ip is an external ip, set it to unspecified - if udpAddr.IP.IsGlobalUnicast() { - if udpAddr.IP.To4() != nil { - udpAddr.IP = net.IPv4zero - } else { - udpAddr.IP = net.IPv6unspecified - } + // resolve the bind address + address := net.JoinHostPort(parameter.NodeConfig.GetString(local.CFG_BIND), peeringPort) + localAddr, err := net.ResolveUDPAddr(peeringAddr.Network(), address) + if err != nil { + log.Fatalf("Error resolving %s: %v", local.CFG_BIND, err) } // check that discovery is working and the port is open log.Info("Testing service ...") - checkConnection(udpAddr, &loc.Peer) + checkConnection(localAddr, &lPeer.Peer) log.Info("Testing service ... done") - conn, err := net.ListenUDP(peeringAddr.Network(), udpAddr) + conn, err := net.ListenUDP(peeringAddr.Network(), localAddr) if err != nil { - log.Fatalf("ListenUDP: %v", err) + log.Fatalf("Error listening: %v", err) } + defer conn.Close() // use the UDP connection for transport trans := transport.Conn(conn, func(network, address string) (net.Addr, error) { return net.ResolveUDPAddr(network, address) }) @@ -93,7 +92,7 @@ func start(shutdownSignal <-chan struct{}) { } // start a server doing discovery and peering - srv := server.Listen(loc, trans, log.Named("srv"), handlers...) + srv := server.Serve(lPeer, trans, log.Named("srv"), handlers...) defer srv.Close() // start the discovery on that connection @@ -106,8 +105,8 @@ func start(shutdownSignal <-chan struct{}) { defer Selection.Close() } - log.Infof(name+" started: address=%s/%s", peeringAddr.String(), peeringAddr.Network()) - log.Debugf(name+" server started: PubKey=%s", base64.StdEncoding.EncodeToString(loc.PublicKey())) + log.Infof(name+" started: Address=%s/%s", peeringAddr.String(), peeringAddr.Network()) + log.Infof(name+" started: PubKey=%s", base64.StdEncoding.EncodeToString(lPeer.PublicKey())) <-shutdownSignal log.Info("Stopping " + name + " ...") diff --git a/plugins/autopeering/local/local.go b/plugins/autopeering/local/local.go index c5ca19a110..6b694b72c5 100644 --- a/plugins/autopeering/local/local.go +++ b/plugins/autopeering/local/local.go @@ -5,9 +5,11 @@ import ( "encoding/base64" "net" "strconv" + "strings" "sync" "github.com/iotaledger/goshimmer/packages/autopeering/peer" + "github.com/iotaledger/goshimmer/packages/autopeering/peer/service" "github.com/iotaledger/goshimmer/packages/netutil" "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/hive.go/logger" @@ -21,24 +23,30 @@ var ( func configureLocal() *peer.Local { log := logger.NewLogger("Local") - ip := net.ParseIP(parameter.NodeConfig.GetString(CFG_ADDRESS)) - if ip == nil { - log.Fatalf("Invalid %s address: %s", CFG_ADDRESS, parameter.NodeConfig.GetString(CFG_ADDRESS)) - } - if ip.IsUnspecified() { - log.Info("Querying public IP ...") - myIp, err := netutil.GetPublicIP(!netutil.IsIPv4(ip)) + var externalIP net.IP + if str := parameter.NodeConfig.GetString(CFG_EXTERNAL); strings.ToLower(str) == "auto" { + log.Info("Querying external IP ...") + ip, err := netutil.GetPublicIP(false) if err != nil { - log.Fatalf("Error querying public IP: %s", err) + log.Fatalf("Error querying external IP: %s", err) + } + log.Infof("External IP queried: address=%s", ip.String()) + externalIP = ip + } else { + externalIP = net.ParseIP(str) + if externalIP == nil { + log.Fatalf("Invalid IP address (%s): %s", CFG_EXTERNAL, str) } - ip = myIp - log.Infof("Public IP queried: address=%s", ip.String()) + } + if !externalIP.IsGlobalUnicast() { + log.Fatalf("IP is not a global unicast address: %s", externalIP.String()) } - port := strconv.Itoa(parameter.NodeConfig.GetInt(CFG_PORT)) + peeringPort := strconv.Itoa(parameter.NodeConfig.GetInt(CFG_PORT)) - // create a new local node - db := peer.NewPersistentDB(log) + // announce the peering service + services := service.New() + services.Update(service.PeeringKey, "udp", net.JoinHostPort(externalIP.String(), peeringPort)) // the private key seed of the current local can be returned the following way: // key, _ := db.LocalPrivateKey() @@ -46,8 +54,7 @@ func configureLocal() *peer.Local { // set the private key from the seed provided in the config var seed [][]byte - if parameter.NodeConfig.IsSet(CFG_SEED) { - str := parameter.NodeConfig.GetString(CFG_SEED) + if str := parameter.NodeConfig.GetString(CFG_SEED); str != "" { bytes, err := base64.StdEncoding.DecodeString(str) if err != nil { log.Fatalf("Invalid %s: %s", CFG_SEED, err) @@ -58,7 +65,7 @@ func configureLocal() *peer.Local { seed = append(seed, bytes) } - local, err := peer.NewLocal("udp", net.JoinHostPort(ip.String(), port), db, seed...) + local, err := peer.NewLocal(services, peer.NewPersistentDB(log), seed...) if err != nil { log.Fatalf("Error creating local: %s", err) } diff --git a/plugins/autopeering/local/parameters.go b/plugins/autopeering/local/parameters.go index ab7629e834..9ffa15c81f 100644 --- a/plugins/autopeering/local/parameters.go +++ b/plugins/autopeering/local/parameters.go @@ -5,13 +5,15 @@ import ( ) const ( - CFG_ADDRESS = "autopeering.address" - CFG_PORT = "autopeering.port" - CFG_SEED = "autopeering.seed" + CFG_BIND = "network.bindAddress" + CFG_EXTERNAL = "network.externalAddress" + CFG_PORT = "autopeering.port" + CFG_SEED = "autopeering.seed" ) func init() { - flag.String(CFG_ADDRESS, "0.0.0.0", "address to bind for incoming peering requests") - flag.Int(CFG_PORT, 14626, "udp port for incoming peering requests") + flag.String(CFG_BIND, "0.0.0.0", "bind address for global services such as autopeering and gossip") + flag.String(CFG_EXTERNAL, "auto", "external IP address under which the node is reachable; or 'auto' to determine it automatically") + flag.Int(CFG_PORT, 14626, "UDP port for incoming peering requests") flag.BytesBase64(CFG_SEED, nil, "private key seed used to derive the node identity; optional Base64 encoded 256-bit string") } diff --git a/plugins/dashboard/parameters.go b/plugins/dashboard/parameters.go new file mode 100644 index 0000000000..1031a27367 --- /dev/null +++ b/plugins/dashboard/parameters.go @@ -0,0 +1,13 @@ +package dashboard + +import ( + flag "github.com/spf13/pflag" +) + +const ( + CFG_BIND_ADDRESS = "dashboard.bindAddress" +) + +func init() { + flag.String(CFG_BIND_ADDRESS, "0.0.0.0:8081", "the bind address for the dashboard") +} diff --git a/plugins/dashboard/plugin.go b/plugins/dashboard/plugin.go index 5fa26f6982..bf820c5582 100644 --- a/plugins/dashboard/plugin.go +++ b/plugins/dashboard/plugin.go @@ -1,9 +1,11 @@ package dashboard import ( + "errors" "net/http" "time" + "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/goshimmer/plugins/metrics" "github.com/iotaledger/hive.go/daemon" @@ -13,17 +15,24 @@ import ( "golang.org/x/net/context" ) -var server *http.Server +var ( + log *logger.Logger + httpServer *http.Server +) + +const name = "Dashboard" -var router *http.ServeMux +var PLUGIN = node.NewPlugin(name, node.Disabled, configure, run) -var PLUGIN = node.NewPlugin("Dashboard", node.Disabled, configure, run) -var log *logger.Logger +func configure(*node.Plugin) { + log = logger.NewLogger(name) -func configure(plugin *node.Plugin) { - log = logger.NewLogger("Dashboard") - router = http.NewServeMux() - server = &http.Server{Addr: ":8081", Handler: router} + router := http.NewServeMux() + + httpServer = &http.Server{ + Addr: parameter.NodeConfig.GetString(CFG_BIND_ADDRESS), + Handler: router, + } router.HandleFunc("/dashboard", ServeHome) router.HandleFunc("/ws", ServeWs) @@ -37,17 +46,36 @@ func configure(plugin *node.Plugin) { })) } -func run(plugin *node.Plugin) { - daemon.BackgroundWorker("Dashboard Updater", func(shutdownSignal <-chan struct{}) { - go func() { - if err := server.ListenAndServe(); err != nil { - log.Error(err.Error()) +func run(*node.Plugin) { + log.Infof("Starting %s ...", name) + if err := daemon.BackgroundWorker(name, workerFunc, shutdown.ShutdownPriorityDashboard); err != nil { + log.Errorf("Error starting as daemon: %s", err) + } +} + +func workerFunc(shutdownSignal <-chan struct{}) { + stopped := make(chan struct{}) + go func() { + log.Infof("Started %s: http://%s/dashboard", name, httpServer.Addr) + if err := httpServer.ListenAndServe(); err != nil { + if !errors.Is(err, http.ErrServerClosed) { + log.Errorf("Error serving: %s", err) } - }() + close(stopped) + } + }() + + select { + case <-shutdownSignal: + case <-stopped: + } + + log.Infof("Stopping %s ...", name) + ctx, cancel := context.WithTimeout(context.Background(), time.Second) + defer cancel() - <-shutdownSignal - ctx, cancel := context.WithTimeout(context.Background(), 0*time.Second) - defer cancel() - _ = server.Shutdown(ctx) - }, shutdown.ShutdownPriorityDashboard) + if err := httpServer.Shutdown(ctx); err != nil { + log.Errorf("Error stopping: %s", err) + } + log.Infof("Stopping %s ... done", name) } diff --git a/plugins/gossip/gossip.go b/plugins/gossip/gossip.go index 5a6904c5ac..63536632bf 100644 --- a/plugins/gossip/gossip.go +++ b/plugins/gossip/gossip.go @@ -27,15 +27,17 @@ var ( func configureGossip() { lPeer := local.GetInstance() - port := strconv.Itoa(parameter.NodeConfig.GetInt(GOSSIP_PORT)) - - host, _, err := net.SplitHostPort(lPeer.Address()) + peeringAddr := lPeer.Services().Get(service.PeeringKey) + external, _, err := net.SplitHostPort(peeringAddr.String()) if err != nil { - log.Fatalf("invalid peering address: %v", err) + panic(err) } - err = lPeer.UpdateService(service.GossipKey, "tcp", net.JoinHostPort(host, port)) + + // announce the gossip service + gossipPort := strconv.Itoa(parameter.NodeConfig.GetInt(GOSSIP_PORT)) + err = lPeer.UpdateService(service.GossipKey, "tcp", net.JoinHostPort(external, gossipPort)) if err != nil { - log.Fatalf("could not update services: %v", err) + log.Fatalf("could not update services: %s", err) } mgr = gp.NewManager(lPeer, loadTransaction, log) @@ -44,23 +46,38 @@ func configureGossip() { func start(shutdownSignal <-chan struct{}) { defer log.Info("Stopping " + name + " ... done") - loc := local.GetInstance() - srv, err := server.ListenTCP(loc, log) + lPeer := local.GetInstance() + // use the port of the gossip service + gossipAddr := lPeer.Services().Get(service.GossipKey) + _, gossipPort, err := net.SplitHostPort(gossipAddr.String()) + if err != nil { + panic(err) + } + // resolve the bind address + address := net.JoinHostPort(parameter.NodeConfig.GetString(local.CFG_BIND), gossipPort) + localAddr, err := net.ResolveTCPAddr(gossipAddr.Network(), address) if err != nil { - log.Fatalf("ListenTCP: %v", err) + log.Fatalf("Error resolving %s: %v", local.CFG_BIND, err) } + + listener, err := net.ListenTCP(gossipAddr.Network(), localAddr) + if err != nil { + log.Fatalf("Error listening: %v", err) + } + defer listener.Close() + + srv := server.ServeTCP(lPeer, listener, log) defer srv.Close() //check that the server is working and the port is open log.Info("Testing service ...") - checkConnection(srv, &loc.Peer) + checkConnection(srv, &lPeer.Peer) log.Info("Testing service ... done") mgr.Start(srv) defer mgr.Close() - gossipAddr := loc.Services().Get(service.GossipKey) - log.Infof(name+" started: address=%s/%s", gossipAddr.String(), gossipAddr.Network()) + log.Infof("%s started: Address=%s/%s", name, gossipAddr.String(), gossipAddr.Network()) <-shutdownSignal log.Info("Stopping " + name + " ...") diff --git a/plugins/graph/graph.go b/plugins/graph/graph.go index 6b5442e80a..e0946cc3a2 100644 --- a/plugins/graph/graph.go +++ b/plugins/graph/graph.go @@ -66,7 +66,7 @@ func onConnectHandler(s socketio.Conn) error { log.Info(infoMsg) socketioServer.JoinRoom("broadcast", s) - config := &wsConfig{NetworkName: parameter.NodeConfig.GetString("graph.networkName")} + config := &wsConfig{NetworkName: parameter.NodeConfig.GetString(CFG_NETWORK)} var initTxs []*wsTransaction txRingBuffer.Do(func(tx interface{}) { diff --git a/plugins/graph/parameters.go b/plugins/graph/parameters.go index 5bc6386996..5fbef46f38 100644 --- a/plugins/graph/parameters.go +++ b/plugins/graph/parameters.go @@ -1,26 +1,22 @@ package graph import ( - "github.com/iotaledger/goshimmer/packages/parameter" + "github.com/iotaledger/goshimmer/plugins/cli" + flag "github.com/spf13/pflag" ) -func init() { - - // "Path to IOTA Tangle Visualiser webroot files" - parameter.NodeConfig.SetDefault("graph.webrootPath", "IOTAtangle/webroot") - - // "Path to socket.io.js" - parameter.NodeConfig.SetDefault("graph.socketioPath", "socket.io-client/dist/socket.io.js") - - // "Set the domain on which IOTA Tangle Visualiser is served" - parameter.NodeConfig.SetDefault("graph.domain", "") - - // "Set the host to which the IOTA Tangle Visualiser listens" - parameter.NodeConfig.SetDefault("graph.host", "127.0.0.1") - - // "IOTA Tangle Visualiser webserver port" - parameter.NodeConfig.SetDefault("graph.port", 8083) +const ( + CFG_WEBROOT = "graph.webrootPath" + CFG_SOCKET_IO = "graph.socketioPath" + CFG_DOMAIN = "graph.domain" + CFG_BIND_ADDRESS = "graph.bindAddress" + CFG_NETWORK = "graph.networkName" +) - // "Name of the network shown in IOTA Tangle Visualiser" - parameter.NodeConfig.SetDefault("graph.networkName", "meets HORNET") +func init() { + flag.String(CFG_WEBROOT, "IOTAtangle/webroot", "Path to IOTA Tangle Visualiser webroot files") + flag.String(CFG_SOCKET_IO, "socket.io-client/dist/socket.io.js", "Path to socket.io.js") + flag.String(CFG_DOMAIN, "", "Set the domain on which IOTA Tangle Visualiser is served") + flag.String(CFG_BIND_ADDRESS, "127.0.0.1:8083", "the bind address for the IOTA Tangle Visualizer") + flag.String(CFG_NETWORK, cli.AppName, "Name of the network shown in IOTA Tangle Visualiser") } diff --git a/plugins/graph/plugin.go b/plugins/graph/plugin.go index f6dcc3eea3..af58616543 100644 --- a/plugins/graph/plugin.go +++ b/plugins/graph/plugin.go @@ -1,7 +1,7 @@ package graph import ( - "fmt" + "errors" "net/http" "time" @@ -39,7 +39,7 @@ var ( ) func downloadSocketIOHandler(w http.ResponseWriter, r *http.Request) { - http.ServeFile(w, r, parameter.NodeConfig.GetString("graph.socketioPath")) + http.ServeFile(w, r, parameter.NodeConfig.GetString(CFG_SOCKET_IO)) } func configureSocketIOServer() error { @@ -72,11 +72,11 @@ func configure(plugin *node.Plugin) { // socket.io and web server server = &http.Server{ - Addr: fmt.Sprintf("%s:%d", parameter.NodeConfig.GetString("graph.host"), parameter.NodeConfig.GetInt("graph.port")), + Addr: parameter.NodeConfig.GetString(CFG_BIND_ADDRESS), Handler: router, } - fs := http.FileServer(http.Dir(parameter.NodeConfig.GetString("graph.webrootPath"))) + fs := http.FileServer(http.Dir(parameter.NodeConfig.GetString(CFG_WEBROOT))) if err := configureSocketIOServer(); err != nil { log.Panicf("Graph: %v", err.Error()) @@ -92,7 +92,7 @@ func configure(plugin *node.Plugin) { }, workerpool.WorkerCount(newTxWorkerCount), workerpool.QueueSize(newTxWorkerQueueSize)) } -func run(plugin *node.Plugin) { +func run(*node.Plugin) { notifyNewTx := events.NewClosure(func(transaction *value_transaction.ValueTransaction) { newTxWorkerPool.TrySubmit(transaction) @@ -111,23 +111,33 @@ func run(plugin *node.Plugin) { daemon.BackgroundWorker("Graph Webserver", func(shutdownSignal <-chan struct{}) { go socketioServer.Serve() + stopped := make(chan struct{}) go func() { + log.Infof("You can now access IOTA Tangle Visualiser using: http://%s", parameter.NodeConfig.GetString(CFG_BIND_ADDRESS)) if err := server.ListenAndServe(); err != nil { - log.Error(err.Error()) + if !errors.Is(err, http.ErrServerClosed) { + log.Errorf("Error serving: %s", err) + } } + close(stopped) }() - log.Infof("You can now access IOTA Tangle Visualiser using: http://%s:%d", parameter.NodeConfig.GetString("graph.host"), parameter.NodeConfig.GetInt("graph.port")) + select { + case <-shutdownSignal: + case <-stopped: + } - <-shutdownSignal - log.Info("Stopping Graph ...") - - socketioServer.Close() - - ctx, cancel := context.WithTimeout(context.Background(), 0*time.Second) + log.Info("Stopping Graph Webserver ...") + ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() - _ = server.Shutdown(ctx) - log.Info("Stopping Graph ... done") + if err := server.Shutdown(ctx); err != nil { + log.Errorf("Error stopping: %s", err) + } + + if err := socketioServer.Close(); err != nil { + log.Errorf("Error closing Socket.IO server: %s", err) + } + log.Info("Stopping Graph Webserver ... done") }, shutdown.ShutdownPriorityGraph) } From 30b0cb4f3c3276bddea05e17da16fb30fdcd2327 Mon Sep 17 00:00:00 2001 From: capossele Date: Fri, 24 Jan 2020 11:48:28 +0000 Subject: [PATCH 152/184] :bug: fixes correct inbound order --- plugins/analysis/client/plugin.go | 2 +- plugins/analysis/webinterface/httpserver/index.go | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/analysis/client/plugin.go b/plugins/analysis/client/plugin.go index 369702a4ba..c3d4abcf4c 100644 --- a/plugins/analysis/client/plugin.go +++ b/plugins/analysis/client/plugin.go @@ -157,7 +157,7 @@ func reportAcceptedNeighbors(dispatchers *EventDispatchers) { if autopeering.Selection != nil { for _, acceptedNeighbor := range autopeering.Selection.GetIncomingNeighbors() { //dispatchers.AddNode(acceptedNeighbor.ID().Bytes()) - dispatchers.ConnectNodes(local.GetInstance().ID().Bytes(), acceptedNeighbor.ID().Bytes()) + dispatchers.ConnectNodes(acceptedNeighbor.ID().Bytes(), local.GetInstance().ID().Bytes()) } } } diff --git a/plugins/analysis/webinterface/httpserver/index.go b/plugins/analysis/webinterface/httpserver/index.go index 894e36b59e..4da63b851f 100644 --- a/plugins/analysis/webinterface/httpserver/index.go +++ b/plugins/analysis/webinterface/httpserver/index.go @@ -144,6 +144,8 @@ func index(w http.ResponseWriter, r *http.Request) { var existingLinks = {}; let highlightNodes = []; + let highlightInbound = []; + let highlightOutbound = []; let highlightLinks = []; let highlightLink = null; @@ -244,7 +246,7 @@ func index(w http.ResponseWriter, r *http.Request) { } function connectNodes(sourceNodeId, targetNodeId) { - if(existingLinks[sourceNodeId + targetNodeId] == undefined && existingLinks[targetNodeId + sourceNodeId] == undefined) { + if(existingLinks[sourceNodeId + targetNodeId] == undefined) { if (!(sourceNodeId in nodesById)) { addNode(sourceNodeId); } @@ -261,9 +263,8 @@ func index(w http.ResponseWriter, r *http.Request) { } function disconnectNodes(sourceNodeId, targetNodeId) { - data.links = data.links.filter(l => !(l.source.id == sourceNodeId && l.target.id == targetNodeId) && !(l.source.id == targetNodeId && l.target.id == sourceNodeId)); + data.links = data.links.filter(l => !(l.source.id == sourceNodeId && l.target.id == targetNodeId)); delete existingLinks[sourceNodeId + targetNodeId]; - delete existingLinks[targetNodeId + sourceNodeId]; updateGraph(); } From 3a038049dc0490de057e2a9432afcd8d9c8affa4 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Fri, 24 Jan 2020 12:53:19 +0100 Subject: [PATCH 153/184] Fix: Add content-type header in client lib http reqs (#176) --- client/lib.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/lib.go b/client/lib.go index 487f708307..09a47878fd 100644 --- a/client/lib.go +++ b/client/lib.go @@ -114,6 +114,10 @@ func (api *GoShimmerAPI) do(method string, route string, reqObj interface{}, res return err } + if data != nil { + req.Header.Set("Content-Type", contentTypeJSON) + } + // add authorization header with JWT if len(api.jwt) > 0 { req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", api.jwt)) From 11d26b051e74b562266235b2d982ccf9fe7c4645 Mon Sep 17 00:00:00 2001 From: capossele Date: Fri, 24 Jan 2020 13:12:54 +0000 Subject: [PATCH 154/184] :art: changes inbound, outbound colors --- .../analysis/webinterface/httpserver/index.go | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/plugins/analysis/webinterface/httpserver/index.go b/plugins/analysis/webinterface/httpserver/index.go index 4da63b851f..574a252fb9 100644 --- a/plugins/analysis/webinterface/httpserver/index.go +++ b/plugins/analysis/webinterface/httpserver/index.go @@ -157,7 +157,20 @@ func index(w http.ResponseWriter, r *http.Request) { .graphData(data) .enableNodeDrag(false) .onNodeClick(showNodeStat) - .nodeColor(node => highlightNodes.indexOf(node) === -1 ? 'rgba(0,255,255,0.6)' : 'rgb(255,0,0,1)') + .nodeColor(node => { + if (highlightNodes.indexOf(node) != -1) { + return 'rgb(255,0,0,1)' + } + if (highlightInbound.indexOf(node) != -1) { + return 'rgba(0,255,100,0.6)' + } + if (highlightOutbound.indexOf(node) != -1) { + return 'rgba(0,100,255,0.6)' + } + else { + return 'rgba(0,255,255,0.6)' + } + }) .linkWidth(link => highlightLinks.indexOf(link) === -1 ? 1 : 3) .linkDirectionalParticles(link => highlightLinks.indexOf(link) === -1 ? 0 : 3) .linkDirectionalParticleWidth(3) @@ -168,9 +181,22 @@ func index(w http.ResponseWriter, r *http.Request) { highlightNodes = node ? [node] : []; highlightLinks = []; + highlightInbound = []; + highlightOutbound = []; clearNodeStat(); if (node != null) { highlightLinks = data.links.filter(l => (l.target.id == node.id) || (l.source.id == node.id)); + + highlightLinks.forEach(function(link){ + if (link.target.id == node.id) { + highlightInbound.push(link.source) + } + else { + highlightOutbound.push(link.target) + } + }); + + showNodeStat(node); } updateHighlight(); From 3a6445c0e906ab0eb99026a037a31e0d19c43554 Mon Sep 17 00:00:00 2001 From: capossele Date: Fri, 24 Jan 2020 14:17:42 +0000 Subject: [PATCH 155/184] :art: changes font --- plugins/analysis/webinterface/httpserver/index.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/analysis/webinterface/httpserver/index.go b/plugins/analysis/webinterface/httpserver/index.go index 574a252fb9..4f65bf2713 100644 --- a/plugins/analysis/webinterface/httpserver/index.go +++ b/plugins/analysis/webinterface/httpserver/index.go @@ -8,6 +8,11 @@ import ( func index(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, ` - - - - - - -
-
-

-

-
-
-

-

-
-
- -`) -} diff --git a/plugins/analysis/webinterface/httpserver/packrd/packed-packr.go b/plugins/analysis/webinterface/httpserver/packrd/packed-packr.go new file mode 100644 index 0000000000..4241a1363e --- /dev/null +++ b/plugins/analysis/webinterface/httpserver/packrd/packed-packr.go @@ -0,0 +1,38 @@ +// +build !skippackr +// Code generated by github.com/gobuffalo/packr/v2. DO NOT EDIT. + +// You can use the "packr2 clean" command to clean up this, +// and any other packr generated files. +package packrd + +import ( + "github.com/gobuffalo/packr/v2" + "github.com/gobuffalo/packr/v2/file/resolver" +) + +var _ = func() error { + const gk = "4c80c379ef2b80415266c114d9f8d6a8" + g := packr.New(gk, "") + hgr, err := resolver.NewHexGzip(map[string]string{ + "166310f2d73113b478111b0a976a0eea": "1f8b08000000000000ff9c57793494fbff7f701b528454f6a6414d0bb330c34c46b319141a63494a356661304b331343ca9232527675254b961a85b2e5226d52e426a25c1165c992352d971a7ec7fdd5fdfeceefdc73fff87ece79ce799ecf79bd5eefcffbf5bc9ef7394f1cd5c55e4d554f150000354707320d0000e6f2a5020200403090ee0e0080aed8ce4becc6678b43e842164060f27d5960472edd8f4563d199a1479b593600a0c4e6b87b89bd9c9db00c3ed79cbe8c31977005c0f2b2d92511d019812c31d897e5c7e1e120d375f720600e1307d98772863b0b482c7f8e439890e516e6e2ce080b646098905db6601b0956c2157059623a58c20de289b0121ce42f5d2c4f845dde8641c07f41c48138c8ff1ecacb990a26f1852c30cadcc28c014720c068b439c2128546237680917004120647c2e0683384251685c622adc03f16c4166c2364b2b13432e5472d21938d83f88bc5022c0c161212621e6261ce17fac110180c66590389341332d966a2509e982e31e3898c7f2a9059228690231073f83cf0f233dd977f4c8c83407eb6c015383bff2dcc13fd308ac1e7c22474010c610e8771b9b09f689198c662ff3b5ae41e2a60c1682c11ff9890c1a2b1d8c6ffa7d4bf539781026767ec5e21c78fc3a30791f98c635c164fec48c641245c813993c3c492e0d61696240286802212ed3008040665412158a348186b22dc9a6205ffa9f14f5c0ba2350a498193ec50966404c20e43b023910948b21d91444121d094bfb98e3c9198ce63b07e7239ffe112ff958b25095974315fe8cee707fd4c00d59f2fe68bfcf90230c90d0d86eee3f098fc10d1d6e5d7f3e3a42c212798c5a408f95cf05ffe6239ff509f648724a0911824c5924859eedbdadace92842120890822c20e4db484fce032ff1bcf60b6601bd8ff0bcbcf2d1a99b27cfb77f46dc1fff978583c260e2284ecb2456c7c1a0100aad71cc90477c9eb091f1f2783ae757d1972852f1b2fbcf94c73d3d5dbd2d4b6704d637f00637f952fd3f4d9814ec87ed4f5dac71f1999328f02879262cfaa8517b15f1acf2b30b679941ffeded95975c3ab64d89aaad963b6127de445658bf98e6f4b4b56f256f6556f2a42837d41579828c6357c6eed3d3e15f2bc6624fbf894615642f275697e0408045aece8eb9b82673ebb1a6e7b737bfaee4bb23b6095dadd857983d6a5bd9d9deec80ca733be653298b6eacbf09219aaf9c563eab1f96fe7e6074043f506f18dde5cf401739dd52e8f078faa3b71cee88ab3779348a7ba0667c56834baf5667171cc8b31cb9bebf0b2ecb7044047f9b28b9f85822f79f39a4b7afafac7dd185ae6e08cbadada430a16bb769b684d1fbc77527e1b84f268895bbbe5a4aa6d8206d820ec02909efe48fec8b3dfd2dafa37c6c1a400c38d1bf9163aab2903efde3e3815353535158707e7769c4d4b4c4878519818135d701a682760ad470f2fceddd1783ed90b3479c4e28df6b9dcecfa905b2b79f144676fc152c70baf56d20a9187c6fd18a3b0ae5c5643cce3b566fafb6411eb941463623d3e5a1ba83f47e48b4680a8b36a1448f25645135b14eab33c08fd6d73e045c3fc4f0db16b22d4a82e49976a37a89ede761176d8bc22b81b71c96573ea4646244c0b6cf7ca68a70b0b31761b97d4404c7d23cc53f0d62b48372a2eb229dc818cdb1097f86ca69c8b87375c4c5750fc7562f6a0f935e30d525a2455d7fd42bbbf89687f7282697d6aaf6b5a9349bf34c74c41f8fe775d25d53181b5812de09a96baf23a74b344f1bd8665c9af898dbe7b1c149d67864076e27d495e1278e2383943f1e9fba16db17d24eea9e6eb9ad33e4e85b4bd7442ba8a06c6342633236336d4263be7ca7d05787a5ef3af079da8ac76b71515dd0715ffe0e73fe853300e3565f7fed2f4e8510cb7ffee897e5243fde98f9fa039c64569f11b03f493d6599efd66456d7dcaceee51053fdeb2373b5c572dadf117b656d388abf4960fc804b7eab3fb2daf1d86b27065fcd1c1a75b0b7b62636343af758c9130874f55ee6c3f5ea4bcebf4183fa5a5e37cad9b6e74cfe4a24a0aad77e278b5a2038bc532958a1dcb5598b79113caea0692c691b9faf657af3c15496713defb838d1d37466ec8d583f9d4054f5ef8dd2e491a936c8b89580ce754f48d9400448de771631126b12257b1d6c995290f3b70f3e2f12301aa26a793b4de5c21c52ebe7cf912b5f59a1badbccfe19823c3dea77807e6727c4a40b46ae79ebb45619ac53bd41917930d5276634cabf35e856685490fafa2e21cb82e8e879e48151e4a151e02f44740f73a930fe525cce3a91bed2f4575c4f85764bb9450cd72aafa401849fa0a8d222dcb95014141c5afe75272b6673ef3ec601b047a839bf73819f90ea4ffa92df7bc2191dfc96d5254f1002c7a37bb4fd839691fbecfdcee57d12d39b894ec60b299f3a54e1fd8046f3aaf1e37ba028c7b5b455cf9953db378ff08dc29aaeb61b004d5b4c9b0a1a161a1afaf6fe4cb44f7dcfa6de1e55428d5cbef21af3a316db7a990eca9db8e75251dae0f7b193adeb97517b6e703bba21b7448ad92a75432b3b3b23171b6225aefb1c6e0c444d09ecda9f3403debc13bc104e9f45eb49555ddcad5351b2282b534a8fa05773b2683ad9415a30e5ca1fab7fa9669df39345d07402b7c9c6f71f1642bfbadebe39fe5e62d51606521c1c1775ff7f52da67846dfae1e6573f0f9736dc07e07f91fcf32adfaed959d6a0e96162e2e2e965bde9a96c5fc295fd4daa669d26ea8af2f72f32336fef686b9bfe4d2f6993bf83d5d381c4e4176ab3b2a4a212a32c9f8fe81f53e908cc8826c9971fbc0b9d2d6433d6199f59543abaa8aef09de45833f9ac587de8c11f657e16d48ac8a0cac280bee1b09c777b20e21f19d96d4dd9efaf37169de2f0a919d680e4ae68c241fb03daf1bd13e26f6243816d2ca63d25fb5ae15d618d48408037ab885b53e6efeb27064467833affa498967a081d6c711df329d8bc605eee268ac4b8eed09e4faf8132b724394d26c86e3dfd9af4e42dd0e5fa1969e919525bfdd321cb64e8b68d4cc07e392480b140ae59c7da2d1e4e7b0fafca473a0c8078d83b3d052c5d3c9d7e9dbab2e019a79eda34a0e8f8605d64179d6fd0909096bdef0be469fabafe68485d59a66b92c81c0969074c192f6f052fa78ee1953450f00a25e9cdcd8d8d8e3301dd75d5817326d9eb333a4146a3cda4d861cfdda9e6fffd5d4ec8cb6a19eded3cea9e1235ad18f67bec97565e79cb846a6b3a3abf7ebad6269cf66e327eb64169d81a2a4aba0635bd53d9b439b2b82f714b1a61ad8e341be4dcbe176bd78881d19aee050d47a55966eb7a5def14062f396aa8c26dbe6775b30f282b55d43e74ea6eda82db9e05a51262bcfb69379e3c9a0add2e2daf964452564c6395e7d56695e4f5ead0bb7ccebface0ac0b7900a756faa81da1fbcd8b9890a4a444aceda6a575f4e47303640c767748fe5f7bf40500db2d741035ce39a0b6891eed53af690645bf84cc3d5ab57b5819a158fd94bfda1d24f56c31be21b471e0c554f04d73d0b427f18c30c2d29ccb7f47cfe72f689c278db561bc97448f20ecf1b55e7cab5a0733087c4ae1bfa18f4ec84e8cf672d72b9fc5bfb832fa9e24d39fd2e7fc80622a510e777bb0ac910cdcb3939fd394e9b238605d690ca28a3f98a0f9f7bcbca102db3834f0ef7d4854cc3e25cc74b9af6becdd8e9d0221cfddedeeedaf1ae21f65e02f26402b2f81720ec7823bb62be7d70e3cd6ab470f8e9ba9632c6930425e9e1dc7ceb077ee67ae74f9e5dda56bcc52340b14011ce265e699b6694fd7a8c4ebf3231376f4b31762add5067821c528d6de09694940c1716161eff2de753587d84bd71382456e45a7c60b0b7f7f28af1e9eaa483abfa22548edc91524a836e69b03333329a2536d97ba8856a49a536f7bfabcc2fa56d37dae3884f696969f99a34fa9df23477a6b1a9ad8dca53cadaf380ad38293d4dae5f155773eece2dadd6c6b1b1b13582bdb16bbf038c275645bd6ad9f1574ed5c77eb27ae3a7ccdf6d333c6c64cf547e34fd75c4f5815d514aca92bf85ba0db6360af4bab5d5656aa0317e486e96b23ba9e5779311885e44f2ea187d2b9e25f1fc6bf4f81bc8de1aef6b439e92d7b3841375ea361c5cbde7e926ee544262e29c4e9b73e6093e2e2be57aa6ceaba3d5e9dbdea85c3f8fa597aea5acd6a0acd600a91883549462349562fe1eb1f4ca339db777916146330fbb9a9b9bda073664ed837ca54df080980b24681b5e4a8618707fdf273c1e29fe8db039f5cac76dc29bdf397a1a47cd0e78797b2fb40d0bb32abc4b4282d00708cd3ecec05d9dd5a0e9cacacaefcdbceafeab70d3dbbb982870cb6851c49d88a593aa69631f3edc80ca88bf44ca3950ed5acdf39441434343ccd572cf1b6b381996508582211de19789fd0b52fc25dae4751325a61ab46a95dbe7c5f204ef81a4aa85c9871efae1a3ab9407089c75b534f74dc97fbe5bff2c5ce6951ae9f04a036573a23b125bddccdc2655e6bf870614d6d4d42ce89ff58a7b3278f624766cd51a15b5bbfefe58c19ce262f84981809a78af4e5873d9d6407de997f9fea84f6d5dea46830bc1d8ac562db013513b2f3959f3446060e0f36463fb85f63f606d21e1636bfba2f060657ced79cae0beb14c1adc0f073cc9adeaa056e9f411b246a129f99ea92547951a93fbba4eaca7374935f37d48063dca3273dfa9907f723e7279862e8f511d043e5849be2f5201703603e3e232da84cbbf828e762ee452e291e8ff090000ffff241161e8770e0000", + "2f53e054245e3cec681be9135541dbcb": "1f8b08000000000000ff9c544f8f9b3e14bce753bc9f7fe7e06c0e55d5029736daaeaadd54bbabae7a74cc039cf89fec076dfae92b2024e44f2f3d016fc6e399b145fadfe7f5a7d71fdf565093d1f92c1d1f288a7c0600901a2401b216212265aca172fe9e013f80a448637eef5e6a650c0698c313d24f1776f05dc54668f51b43ca07d6b0422bbb83803a6391f61a638d480c68ef316384bf88cb1819d401cb8cf1488294ec46dcba607abda4231cc4a20ccad374f556b462983288419e34b691b7aa155510be9e2f92bb65b2488cb2c936b23ce5c3927f5235e24a25e5437fb374e38a3df44133b611725705d7d8e203fcbf5c2cef96ef3e8e410ad5822a32a65de50eb37eeefb69df1fcbefd72f5f1e1e1f57cfe926e44fabd7b7f5f3d794fb095d990aa416311e94cecd2a53f1cac5c4db8a81d094b1e3c18d3e78a1da7c76eea9af4c76f96e80ca96370c771b367d25fe0616509833c68932ca461441d66f41787f34774a697d4313daf4fa30f05a48ac9d2e308c04285d00eb0a4c92848168c84967bc46c28cb9b2bcad3f686e1a226759bf9bd428028356e806c7af1c4ee6877eaeb2741bc7b5d5cae231d02d706c78daf3b510098a9786fd117e282e4a9fe0cafe1d730d5d9ed629cde135e5dd6dee6e35efff127f020000ffffe59390183c040000", + "853579e9f8c28c5a0ea8a5ed642bbad0": "1f8b08000000000000ffecbded7adb38b230f87faf82d6798f06b04ab424dbe90e15c4eb244e4fce3a4e3671cf4c3f1a1d0f2d42123b14a006415b6a4917b03ff70af616f712f6c1074990a2ec74bfe73dbfb63b8f450085ef42a15055281c4d333691316788e24d3c452d7eff2b9dc8162172bda47cead1d5920b99b6dbad8c45741a331ab58ef2c4058fb28462f3e35b5042111ed224a59e2a2f2fbf2cd194d26e9b5f3f5c44d87ca2d118a8c9ba790885c7864d753ec62ce28f178c988fa0096696f0fb30b960c47c34c2a43499b6db8811f58181f97f8b1f42d5f6dd0e1583823782ca4c302f8ff128622041e04d11c35108991ebc23390ac7e68be92fd58b94348c81a0bf65b1a0edb6fd18aa3c59bb9d625b5f8a4238ea61151fe771b18d53a54e09a38fde95105ca0d6db90312ebd69cc223b25de5f5a9db0d3fa4b0b0fe55cf0476fea4f784449ebe3a7773f5f5fdddd7cbabd7bffe9e79b772d98ee547913a2da4e36760e83cd6e37547d18f5c6fe244c1234c9a7175c8c515925d180fdf1888e87b6a91cc90b1950bc830994392998b1db592855659eb89b72815471f1f78c1784a4370c5f093fa16c26e7c3b0d3c11c0935e845137668d30f46656b55e5a6c58250d46233112ee7be0859c4172d0c9c6c92f0f7f5d54a521605fb185066595031a32dec87cb65b246721ea7108a59b6a04ca67807a6c40f928a5072d15092f0ab20b620d150ca13b91b73d107f511946d35112dbc1b72ff271543360f54a431670ac83fb101ffd7b48541677132ebbf2d0c29157198c4bfd386de6c121e46ef055ffcc7d74f374edea9e08b5f53ce5476c905bde53500c94df26e0713caa4089358ae4da32e931917b19c2fd29332c934912fd598c59ca57ba06592ed0d6d1abf4dcc2415299d4855c0ac08b53014df5f6caa7ff2b38c93f4a492a00bdfede091decf1203f5777affd3f5898e3055ebcf0f6c99c9ab62422a604e5ade5876105f9c09c9a154134017126c1426a9af8f210b675498ba74cc492da9deb8861c7b89a6bba00722d844229cb148f065a5963cd294afc8d05542154a7ee6692c0b5c3383d9906cf2c97891b7c540ea887c78e4bb7841595a2bcc8db723499d113740f7e1e4db6328a2b77cb10c657c9f5067e477701daeb91ac7291713fa2e16742269e462b28a4f34500bc384b35486cce287c97b9247da12ff16d3c760734b573213d49d7b69a29c79b89449b88f1e3ad69dad4538a3373ca29f059f8970b18f4f350027ef75ccbe1dcae6a439399eaae8601db4a970b7a75f7fcb42b10f65a2eb7d6deea003a569593cb143a706fca4126f40ef749cc28260b30c454adff2840bb7f032d6ce5dfa306b28db8935250bca222a727cd53079940198a469518eb3a4cd6eececdd0e9c17a75e4497824e424923dffb9cd030a55e96528f2711159e25d61e9f7a0ff143a8d1d343afbc9eff03f6e2a9b7e699c7288dbc58daaea8e97a1f4e2417eb275b5105fdaf6ec8842f161953e4fdc991c8a19ea8beac4d5756ab0b3c2ebc7fcda55ca6c1c9c92c96f3ecde9ff0c549c81ec26fe1895dd069b20cff6519254dcaebf45ee4645e0da14a48e3c532a1e9c3ac85e18de08f29151fd89457884c196d3189150c31dfc1e6a96d2d387d014fed65c1e90ff0144d0f4e7f84666a1c9cbe84a7697b70d6836642169cf5e1bb686870368043e3109c9dc273a43f383b87c3143d387b018777e2e0ec07d89bb7e0ec25ecef22c1b9eee9de5a0dce0770609d07e7a77090bc04e76770808e04e7e7d044f483f317b0cf2f04e73fc001fa1f9cff0807086170feb229a946a08317bd3a5495f5085ef4a1996e072f06fb29df2a659fc293bb43f0e20c0e51fbe0851e2287ff0c5ebc80921f0b4ea1c6c3062fa1694b0efa7dd8633a837e99dd619a82fe195499dba0ff02aa7c7dd0ff016a8783e0b40735b63538ed43411582d3c16e0c83fdc346714614283ffb14074a32dd6e51c4279a77f7c328d273721da752b5f76213465110835804e12ed0814c05d21d86a9822e0adc3907d1ffd24ac4a2a18eb8ac83ee9587ead0a10b2de8823fd0a733646586788a04dedf24cc51374be9db70a996951733b5297db86ae121f54329c3c95cd7815a9cb53a6a1acae253b73d116d82154ded241cc45e6f897048bcc84fe55992ec60b31bc3e9f7a0037088418b0fb4a800a63081081258c203cc61060b58c30a1ee19e6c56410fd6416f979f6f5322ba0c2684762524441eb32e3d163023e931ef4c8ee34e020b921e879dc971d649a07744c8acdd563f8b767bf69af40859bc266717aac1019a92ac1b434478378425098fe32e3fcee0814c8f69273a669d25ccc9f45876a263d159eac21e4c61f376fb4117367f4d7ab6b035498fa3eef478023d42c8dac6aec8fa55efa2bb3e1904eb9301ac480f1ec9e478d98d8e13b8f757043dbeea5d3c7657c16367854fd6f048a6c749373d5ec2bdbfde4bbdc718ef9cf137837eb63fe8058c1fd199a094e84d3b15931313361b7d09754fe523a58cd1342d419dc83afc24e129ad42175175583ad11b7f3c89e5ba0477632defb069ae37d03473af8ae005ec7529f8010e141ffcb81bc3f973d8e98425a278331fd1f10919ec5c281debc7d198f42a54086f52a2e2214329861855e80756072d44150dbf0a2773b565a0100f27b928c7a46bf91f99f84bbe44182441fdcec3888df1c972c4c62048a47e38e90d792904ea74b859473111233e1e3e8ce271872c47f1f858eed8112169bb8de62336ee105dd6ae42a8f0e661bf3319aa0d0cdec44841e15a874d7b55ca50358d8cc690a8df6e1f548bdd3263059f8ce89810d2edb7db487f27a370dce9c3d45f66e91c518cc1829884761b2d475477271c4334a263031862bcdb1f4fae72cb31e9c152fd14c54a3c9c96e3acda1c92a99fcee3a9446a0a6c915094a6767c1a993902010cef769650a91e4ed49f887cd222637f2268282952ab1d43d218bb6c8c7d688c9d37c5e6c4afda5de1b438ef3fdb6e6dfe6f749da239ce0190c430dfa71c2ffee88298ee638bc68fd0a07eacc691a30a9e9821a7c46d588afd45b844ae503527f0233ade617f1a27928a26007aa410688741219e995590446db45136a1c8ed4e99a7c37678285ff72ea6a3704c10ebf6f1890c74a082a37b78ef60786a30fbf012d00016bbf577aa96621f328361ac11690586d4206d56606b56c5d6986405b636e1680cbcc0d11032859e6923724dbf1fb9641db90486e93efefcf087f087e5a273eacfa8543d4811536465988d98462b8124e818dd190159638be3296204b1edb675cfe5bc857dc9aff923156fc394220c269610a22062a6d86515c08284a5862666792437ba17ad06ca64eb48c5ee716057aba5969079e519d633db8ef72d669117a7811733f07826d571dcb46b2848bc3b34bc598d85cdc7a6a7b52234577fc861be3108d21b8a5739ce0f4587f4b1ec103a12635ff20f91eace453fe8e5132a6bfcebff5405ea8cf16415a1bb442ff24282de3ecefcf8df48737ac31ad5c9c961d1826258d48a1dd257b2dd469448ac0e038a3cd0ff9f3cfc79f2f0f2e9a9ce87e770b51bce4ae9993e39187d6da12b2b149b8da7a624b90f27dfbc38f568be7e25f7eea91716aacd96d12cc6848d64a1c88bb75b6462c8688c213643bfc90b0c044ce42ae03b0c74077c3aadb4d1f48a1347fd5a68f4a45a7b3c5f7a8d3d07ad165575e7d3dbd45ba3228d684225f574d33565cb9772a81b0f19e90db35761c92a66381c6546b7a93a420811ed76e8a7cb249e509441bfd052d21d4c63419d9ee55a445d9b222122ef07d543c887854ece56f85aa13a279742846b7f29b8e4aaf9b636a3602db2401fe361a90ded0d6397c58d73be4d8ce2f1302c3a60d581a13f912be04ee377b5756848de3e595747db78baf6ca13b6370d9374ed198b002f4c3d2388f1d2ccd80894ad6464a44ed0d05203d582169f4e5b63500456be6265db258ea788faf330fdf4c83e0bbea442aecd04ef37e8aba9256fcf3d35d5c7d39846e0a5319b502f965e98081a466b6f1ea6ded216e9fda5d551a56a05b8b3165d1e4a8dc5d0b45dadbf7271734698cf19509f4fa7ea733a552b3c169430fd037467d674bff7fc113f4795d6c80ea34681b1da712dc697d820f95729623633f820f5ee2e701513a48b0956e0338ac7b886f45ecc3c6ad3c37d1191c682bd8990b846528ac5aaa7c88cd050d382a2dba5ace981c791d73b22445c20aa60d47121505fbbdd3e3dec37a8e69db16b2090eef675d3bc7d5174a38e850cef6a32a87c1ad4889a761242241624377729c809bda081dea30a2b144e981a28b58de892f482cf09d75010eec751bedabe8dc4b822cc2a46e74631f38e1c0a6f1492a1d6641eb2198d5a30719a3c5519ef34b2a1562ac3fb84b6803a0013cd0cd8c936cb8cbacb2cb77250f4a915468aec12e19bba6ed74b7a8184cf7844dbedc47e294e13849fc4ec5bbbfd80cc17c641cb48c3ea05b4db45094bfb55669f17d9779f09530caeda18d3b73c63d2654e2284379f490f5865ff74176962cedaf0b943f439c7ddd3d1835354521aa3a891d6735492e9bc096a9d1b72bd476d6216cb373c5a23ec3d86a9a756208dbcc758cebd8c7d63fc9179aa935e1cd96d9213e12fad12c3a284dda46648e0212757aad637349537f451959c6b3c508c77925cf96114a9e84ba94eabd28f234241b59d4858208a618d046eb791f4e3f473cc188dc851cf15592cab4c15a89eb3f150716dea434b22c16e8b7a595c59c9a6eea6c4cee83da8a2168adfd2bc2d560dd08c744e216f4679da58d76352c7204c3fbe2e15d9d2c2dc1c0df1f057444160f86659565156372f27cba6aa016c9aaea241bc126b9a26daed05121a3fb8fae4fad3f6d8165c74da3651ba23382b47706450866abc2d8cb0d8b05c631f4339f717314316263f700f3098d3821c763a05c7638146620c31e1b61b4744cfd4c5cd288f1907ea5b8fe5306eb7638551ed36334c565c6ce2ac6cf3a26c738ee8cc5f84694aae15d2dc648b7b2afc38bd096f6c42c3d6aa86d153695e3ae75912193e90e9bc2d072fd6ee49469d060a5cdc6ea91f85326cb7cd6f91e0e45ed59a9a7766bb456ab98289c6e0f4eed1b1292b0fc6e5ee2c2ffa9d7c073c390dfa3b6d6ab7df41ada6f35229b289d611943c44c9891adcbe774cc196f3751a4f523f8d1759124a2e5a18aec8bd62f1afc9a35a590d5ba3d4c4ef6398a6ed36ba2665d0947fd3c8d87e239b1d28d2f72bb9f2532a65cc66a99f6a1cbd15214ba75c2cb65b3e8c10861499a22ec9511feec8269574e92ad2e32952dbd9678bb547bda139f15df90a12e1e19d9f84a9fcc81f28a1506e2b74d9cad7373df90c92b057c4eff5f3b1be3c224411934b2241ad4e0c7207760d16763d0d522935ed0a8f77903e016cea55b043a646a0d0071b3696c11eab7c8053862b3f660f611247a1a46fdef015c2ba995a5779b8e66ff9e2b1a3b6510b32607a5daad683e401f325d73dd1056a9cd29602fb165a86d6dbcaed1ea5c86c20601933350841551a67707c65b6b7a14be38fd80ee2548f9b8e3930c42a5f916b07519c2e794adda669ceb5c26014736fa1a396192addd24c7d192a1984502c81e0ca5a0532c891c8d141c5e80ec35d55dce0f27a8eeaa328f1e905678fa00d068cb0a9eb83fb03385c52d07fa9d8cc06a56c813ea3b3f1e8a5b670b5969c1553ca4d942d035dc67768f272fe9211b6dd729044aa1f415aa9e6e81d73ea8bfff8fae9c6d7e60288e2c01c1843c8488c70853d353c54badd3a318ab6a4fbe4cedaff263c8c3c631da318179e494f17e1852cd2dc4b6a8f6cb9f1ac8e2bf9c63037586696a54bb53dada2b169fdacd0528cd021c2ab392545c242e9c5a967d767e0dd180e4ac52de2345503838799e220f4c69e2a3626d5fb8911001546bece865bb6734aa46534cb764ef7da6936da16de6e1b12d5ce7bb81baae8fd6ef8de1b2ee79e29570fad2ac50b05cdad94a3bc579a4d9ddabd1ea67aa387a9eda05d4259ed785e9cdbebba65775158c35c674d14d60c0a611bb4a0eed9aa2e55d49ccf764b5ff5f647e283e9b4650e3c7516b488a4491808c290412a7b0ce9f6f5094414fd97203b7d0c6504ed48a09d5aa48e2af67907b8db87c131ed2ae09ad0f3cf379b11e93015aca8ac07baa23282e675b326218aaabbbf5ff7a5f4121aa6d2938fdc54ab91a390bb4db9f0267cb1d47caa9dc97c3415a35b1d4f3d9a2a2c88ecf48742c7082c8fb4c08a3b03281cd3f78abc5b16ed3d927abcb65bd9346806eba3c2fa4a37bbc0fa9bea506a094338997bcb50c8d89c6a0b6672a6991de1c979c8bc9eed9e367628ba6745ecba332acc091df257b423b51a372efa258017fd8a6b42f6ff1ac4150501ea6190a45f8cba839ddd3e38d859b557b1d294577d35ac0df870a0256a0067228e2a28508e513c457d42086db7fb46566187c06d6c7c60247b43fe4a96eaf090880e3fa643f1baa7ce1879a74210ddbe4ac0c0f7523a8877fbf89816742aae5ad1e4263a79b7b75bf127fa7e5ae9bcb58569eabef929c4ac993b0a99bba7e9eda11c05aa474185adf8ac94a0a6243ca6c712a68477e263da49877a141cc20dbcdb374918e2bdb40e8af508a9d4703f55e543a18638964dd47e6a31f88f60af1ab7fb3009d984469e149456d119b839a62ef9231a0035e8dd33c35862793fc7725eca8a6222212483e31832f557119aa23731842ea58e212bba236a22a943dda9d38e9252bc26057d68d84cca6568752d0d4b30324b704f7156958ee99278595287e1611348a90174a9ad43663b0c4487e19dc1fdef99b94912ff96512dfd52f36783b198246afae229fa4eaa61327e8d7fa70dc5e4edd6fb071864a71ad90592101f4b8bc2654fe2631ddfed97db86b311f2bad84eed82dc15b859eb3563a8f79ac806b674ce794abd7411260915debfbefdcbf73eb802fd2414b37c97a863fabfd8bf2c5e849041da7063cb7ea078bb3d1b609816c863488134a4a098f2b01ca4895926d3842bf2793250ac4844fac3e8d564d8e944b85e484650d409f1bf4b637a696964660a7c2a633c45a9cfe84abee3d97d42117e65497242c26151aaeee592184824313c90252124d96ea785e43981a5391eb4dbd352329260cb152b1ad9ede30967326619d50d1b3e0cf1f794aa6a9f133752f5cccacd74cc1c3b1d5779f2f53fdde597c0c228a22290903336012f3edfc48645a0410c39f17a13b35b416930856528e7410893584cb22414d7a620016a7b508752b54b042930ae7b1c4ce0319432fd2a059f85f2f720017721049151eef27d5e79e8f0d3da3ea838994ecda507ad99386c1c9c9b02f7cf1587fd8cf95c2e656859991a71d50b1db544de8592160c287df43862759332398f533fa534aa6adead425f553a8cb8c7c8e05843ba68a6d89503f194b063d691c772f8388f138ae86bd2df6ef5265172c4c77a7da4bf0989ba031348f80c517c422b9a95dcb8a0686aa14623b433e80f7e78d91f0cfa671d445fbdea0f70fb6cf0f2ece58b1f062fcf819232d046a7a767e7bd1f063ff47aff49ff93be7efdbaff12832ae4f487b31f5ef44f5f9eea32ce9f2882764ecfcf7b2f4ecffbfd17ff495fbdb2059c0dcefb2f5f9efef0f2075dc2e9538de89d0dce5f9e9dbf789937e205066716000d5efc78767a7e767edea6f8240fbc68d6f83824666f1e8e69dd28b97226b3e8a3982cbd924bfbae6e7fc85ef786dd2ec392c46669337d92d2ca1ed08a373a62ea8b8d8928e6c3c5ad5cfea408b8dd6d9df2a52e5f629197af4f6a5c1bbf80fae3d4c481218e8779ee769b213aea8d8dcd524cd8762b0c2fd7a0b837a537d82a64a9e48b2f7ab97911a7a9a7768b452827f3f20c75f9f943e0e9d6e1f26a7645ac908bf58c302ee090ceb3e934a181dc1d90509915de1095dfd32529704722a9aa27d95e94996312561232164fb958d462676196a671c8486c95a2cf18213a21869c002d2591bff9f77416b39f97512829794fbec16f3e65910dff443ec31b22e11311f09bd674432e71fdcd157e19eaa520861acc411f69b0f58b35044962f62da0506a0603e62a5f45155a6ded4f404f0cb42b056bb054283823234db23601a28587efada45c92a8a2344052cb5c08834f48422bd383d1c23840525fa3374661f0b5d331006114b530860f461bf713c2202bfc6631da1f2a5adda424fc51ae6acce5cb477da775cc48adacd6cb86b4c2ae6681e668fb055e203912e362efb58a2ed504f8daedc227c420d7d662dde8a35e455b68f0296f85d06ddc6e15df0e9c4488e90053cce3cf16381fc1db5c210521121063a04784b0763b448a01843728b663a6ab8d2b8a45d708c2503a77dbcb1aae98cc9b3201276febe23ba187986fb76b0d82377cbb456f1585eae572e4d6ffdeea789d8e8a1ceaa23a31b08ea3593bd086596d2a73f00b3b5981bee751d5cab9b684477d2b68e288c2adb1d37cd5abe002dce6c6460cfa0ede163a4f3d43b9aed3a2b27658a1ca94565309ec35e9b5db36e896884114d0a20a2d9aa0df20fa04feac1dbd85699955a56fb747a2a635cdf1d89cabf6c4b7325792e6c25b6344c54bcb4aaace29b921272e845a4ef9ae9651e3347c6c321cd8e98e34e81715f3d46cea42b1d9717b20c96dde68a6f9798629bad517078a02efabb89a0f8b28c6b8516758f4495e5ce7226c50e31b5c5582653d57c57690d3077bf981365c7ea0233e8690c4aea96aacc733c8e3742389441f46e118625ca80e1dedf8f51fad521be23975b6dbb68ad85a0bc4b8b1a21b843765e81bc29b771de2588f7e56315dd2d7b789deb5db5f729bba5ebb8d7eb32aad42cdf505430e407ace08fe5aee918e25d1c565e0a8af2e73273887d0a262a4a92d913ee043666ee8c3888de478ecf4b9a8e8eea98aacef1b8d86eaa4ffa128ce2d6b4709dd6e373b68654c1d80d4f1e843d48a8da67ec259ca13ea3f8682554f4281f755aae3189b6915467195bbe7f7cfbc7fb965fdab760ffb9fece7947aff5a64898c7551fff2f8d2305e2c95348cfec95ad0d27f6eb8a48127e75450554898a4dc3333a43a14d1699825d2bba7f3f021e622f0deab9630fee8f1472b55d615fc93c5a9a7ba1247541416ab8a1d0cbdb219defdba2812e9cc349ae97a4d6fb0dfc240fd3203d1fc58d14f0c25b7e140697b0727d39125d21f9afcd35494fc170d2aff60b3835b321ac35bb2d9c157d28377a4071fc9af08c3cf957a2fe6c1037c51a06fc80d7c2237f09edcc04fe4067e231b2bcc0826608fe3c112ca837ab0b0010d93e4dafa20828a30a74181fdb5d0991f04c989610919ccc031dc0a3ec29ec57570efc6058fe030a7c17b2818d3e02798243414c10aac142258abafb2f526ae503c4fd16f1818c2f0dbdedd0197ebeaf68d814ccc22bafa342d76a83c22b701d5a2c77c013b5bd75076481f5b2364cd8d165705f20af6ae16e8c39eb6e6d25f256f67c28611ad5d91c51b6b3074915b175943f8c086c9888d1b6fc9ea322dcdb535ea8d9339b549c8db24f64e9d85d96b6e7c8a70a7f5fffe3ffff7ffe5b53acc89dc53474ebf4f47af15e8df713746cf829a2cbadd224a363b0c4c935c2d33657a0e9aec557373abbd24885de35508c911df6e731a3b92e32342e26178a18fb10a22283d9f9158ad7d6dc2aa7fc05828ef9a54b3f6e0f61d3739f41c2c794a8cb84733b5264ed087cf0df1fa92bb8935110f34e1fae6a813a74dbffa7b8b80b6dbb9ecc9316d358288558358ca5f5d507f15f44ca1eb2688f505f5d7414f1d9a0e9572419f28815db0a0b77f93bc3630f6c678c3d05453cac1091b06276c1e9cbc88ff85c363207e6f82f8fd82fabfffcf0ee0c1f2e58554c35ba2e6c61a20fd8d4e24178328e0a0624ea320b671a75110ee40b84656a52116a91a2cb9d3e1af483e67fe2aa73a79daba4c5b13b6abc83b044da924ced66207c2f6b8b783f83b1a53e2cc1f6e4e35edf732ed772277107e7f53ed2cf4f29b004f5fef6992ee516064996f39da104d51bbb91fb3940af98647314dd1120f59b73bc494e86bcfaefda5b91d35b12d4518e6be916ba8497eaf52b411b18d44d4de2961e4a138d4a892173980b9115d78c7f34f92f8fec458246ae7780eb55f2d79aace88ae458af5890761c3b6306424460c36a6b46b731deeb40726fc96d3e934f89176cf6026c28758ae836edf1f809c531906fe8f1089d002f9bd81f612f655d26530e8edcce69d116659adff330ba35b41e9765b36e2b72c8ca4a0f45e3bb22b40dff08c45a906345dbdd7112dad47b230ef4438d323e98045795c0bc3a48034767375d8b48c6d618888623b249d6959a20346b3848a0f454a0b43e234335a3ba065640bc352f1880feacf9c6488619891142dd5f6b1205a90b3260aad60458e7af0487a704f36f71aaf8225fc66872a98db69488307c82d51030675235369c5469444aa0e3f9f86423431cb1149df04b3c6ed15e3c503178f149c62d61de3295be432bf0bef947829bfbbccdc3abf56b839c3258e546799735bc07650dac8d72b2a24424b977d542dd0b21d5c94e68855f499755988c767c56a552738284ce7832af128f4aada66a7c1bed91afc8551a4a5219e9942753ed234c1730d2af7363ad96e2349baf63813ea0d33774812bf26bd8b38e8f61dab9b87c22d40a879ff5b2ec3e4237fd07e9c1a0e0a8ff920eef5ad3a8c0fee30e69cf9eb6eff023d5486f0a8870373423386b80d772a9a8c6467cefd8be2ee05b516af6ff8aaa1e5ab761b3978bc52673e98f9f77cb583aa91b19b59adaf5d41bb1a5a52dc8ca21788f916905098fbe6fc9ca24d9e9bee0c7f838302706729e1b3056bb06ab126a75ba88ed9ed4a3fad0cee3184e81ec37d8dafad12c660a01d49d5a85030e8c31e650c06033840db82c12954f7966070060df432189c3fe1ffc96e4141bff784f32687f2078317bb310c1aeeeb355c0eacefdeb9929339bbb51e74d7c8c45ebcf878f98fbbbf5d5eff7c05623f8a17511f6e6c54b81735a46a5bded88d6d44c7c3acd8f52f5066b99cac647e20b3dc4d19b7c601722088cd050e848d5b639b7df5ca90051b2aa25f737d71b516bd7e25b474af56c8fa75d86ea3b088dec5feaa4f24c4fe6a4038c4feba4f84fa1990705f515fb7eb381b281663b3ea073d58ab3fab81fa1a94f6e79b7bbe0a62300b3610a0896be56a84aa5f57db338dd075f75c32f2c41d811804e9694fc3fab6a4bdd8544cbab9524cdd2bc5a243e8281bdbe10e9dd07a284e4a2f1d61f9bdd317370541cc5ff53bcc5f0df0c90042155eabf05a8587c6604dfa2e0b950fc22a101d6e54b529eea627035807613566a7fe2b0fe7a55b33b52abec349726e5ebf14f12296f183b6a36cbe57eb285684afaf9a51ecd6dd5054d0ff51b5a3c154bf6975169e33f6784fd1c0a40e19918af7ac3091bbfc0adfc6a28edb819caf5e7509f38b6cc7b43861fa2bc861d60761d6258d1588018751ab806b8d3170774c9e22676a649ebd80502a667ac015ae1bbc85ac40b3a1bd2594e56c4acf917365a5562635dafd296127e6fc3c4c9d8e77c8f438cdc7079c94b59bb21e1a232b3727446e700d09294d4c26c7934e741ce161a2afc9bbd9c8e424a9d443a29344cd343bae941e5723d6608f831d22ece7ba4362e01d536d789f2281d5022d82854e10f163de098f437c92ed0b7a064f9bd6175edd1cc15c2996cbcf9f563b61c5721385124498c0238d6773b97fbae7173ce83734a7c10ee9cfaf992602dc74f0cbd7947b7e1ba8f35be580f7637e3e8b1b97996d901e22558b2fb93a50dac179d5bb6015621794b4937033b75d996f6b36666d63d6903ad8151e879dec38c34385fea9de9f90a85a45f9e7f8e45cad9603094dc5e56ef8d36e0c13828ea899c8edd67e383d302364e3f1f1f4243da676a687325f4d1d32390e210fae5530035ed22295ca4bb23339ceaa5c5c0ca396535d0b5aeef02992137f2fc969707fa970ed3b3c64e5b445ab1ca9e6c07a41df09f58381131a04a74ee8b4a6542f7c15548a23b25a2091d5228934856af58d2e96c8461f108d4219321b2d8a9baaf402e5956af97d5ea31318b881d33c70cfa375fead6590e6e71ff6f717d2d3f7a4a7da59975ef00afd9744e594922f480f07c84837a7a05a4428864e6701b4e645ae3013d3d7069696e6f7604afa30213d6dd4aa8ddf47bd31590fa796b17c20f16832861979d04d1d4ebb0abe438cd1c282cc14773b9cb5db8b0b24c9cc2e376a979bb0316b1bb3cecdcef5fa90c7b2238e8539f972cd53d66c60f355250e253415878191e478a6c7efd80ce389a2d4c75c9371762c21533f02070b5de98319f213f3eb34de44fc524df86fea037a30f3dd7dd0d38f4ff8abf905523d7bf89e9ea107838eed368a47d198d8204c3ba40f5187f43198a87e15a2bf0f31a8420cf6214eab10a70e04c63b5ad2adb064873a24abfb54d418fae461a8888abfe77c0469c9d31881666a2499f64e201db19cff9e9481f5706a8f2c530cd3d7b1ea9bfa9cbc32e79b0986893dbc4c8c14342271574042c2aeb1918c5e271721e19d288889d0ce557bb0261261589ba52c606d17730c6bbd9c39acf3051d022369b76fed6fd0da9008d53c2be1cd90b6da5ce39a31a93e6c1452232b8a5903c5c3a3073f4eaf164bb9467858ca548cc3cc98307d831342c2cc1ad7c619ea2b3f5bc6b578eb30c21c3121547f713ea8a7c3886f72a6ce457748088a2d4ec706a78f27b024ba4cd5f36eac86021f4f86f9d1d5807592e2dcaa213a4b505468678c92a7af7bed76ad2939073bdd4b31e47a67072786ac18a81842bc2b3cb9cc4968316366bfd6c3d81068f3d309f50fc4965cdb5f1b7d3cb709bfd8845ff28499a59b3dc8bb078fc5b87456ea40776fba0957e5d074eed5c96efefab1dd460bb5b656e4111e89cd8661f6facaa4a8dc577045f28c86f5b82602c5b0c0c3eb0bdbdb6b087180ae35525e1ba45cc1b546c57bb8b6c8f908d739525ee9cf684d42e0aa28b8c678b7dbe93bcc9b1d94a2aa7d55549e74517c050abbad0caa015e275cd8dfc0ffd19e680f339ffd973f9e61981a5d8442652d70d721a322f92ac3c9372d573791e9d77051f81ab04274dbb65c54ae36d409cc896d06cc5474b19087c50331a50626086146e517ce9b049deb1dd4542e410c56f6d624aea317a8412d68dbd86ea38414210c0d90bad1ed369a13fb9d8bf50af161626585f3fcc05f1dac60a09d02d7862a18681ff37a8c83c1cb03dcdfd33afcfcb682aa460daa55ac2d3f44ab9a6fe04299a8eacbcf4686fe54ecb21db524d95842d73007da915359d90ed44a6874b6503670e464180fb57970de18db121c1c807695f49d4eb5625ef7cae124bfee15962365c1ddae5bf46e5f7c551d45ab6b1c34d81a348962ca9e17675c759060fe4a9dfa9cb87597f9ebd2c4f4559f767f6cb785fecdeb6cd06f36d4695b5cee263ae870d045b85f0b0f6ae15327ac0974affcfe871bf8250f6872d7cb8fdacbfc3367a84dc890c05c6b7bfa8cffb6efbbc503153571e1cf9055eebfb0bdfb2fecd0fd17f69fccde7f518538f75f58fdfe4bb508e6de7f61fafe8b2ac0bdffc2eaf75fd8a1fb2fb6112fb07be785b9775e726aa9b8812662e75e7f31175ea0641c1a16b244b8e6aab044e027ef91c8ffd67b2475998a3e79d96bd8ce251aa12fd108cc89691e129dbe56988ff818d41fe73a4d0c0cc54d97688a2b2bce68597eda5edc69bc1824f23ad9fec59dfc62101f3afe211d9b11fbea9ca83f62c7f325f3b4dbbec64594593f239a474911c5f58b6e996bf336ad0294c75cb28923ed9aaf107b94ea2feb8b0a3163f066c215af0da1538e31970b724b7bd096d1c6d2fe8f946dd8687da7250d466330170346e31da40a63639812b9dd86cfbb2cd7d72a3906ed19c6388c89a76b9435bc6f70faec2323f99ae156395dd8b6b22637c7ae2933cbef0d1ff2360a997ee971d8523d6d1142c20b73ef006538907e28a5d0d76277fb3e9179edf292a3c3dc6ed10389d1122bae5d9746312c6b178e543f6d8670ffd9912558d3b06583f4a8c8d6f4fe48534e47452d2a5602e1724959f4761e27913116a85f5cb2900335343507b017da0cf8881076b1f4532a2fa514f17d26e9cd57642445c070b0b48ddc4fc5b054c9b3a69cb8f972d27e13f66a4ea1b5d237b8e6824e5b876aa942d5bd2e36e8a297bea42bf99633499924d414ea44edcc8567edde77df43125edaa75dfde2e11aa371b64f47dd7c4559fe4eaca73573c5433c5537bc0fe5d41510e4a8074b8daa6402f99492292c35ea91084c4349024b9f3322d5cf744a382cf5baffca336d7708cb1ab33ae18b659cd0d274ca46141ead0a905bba5826a1dc07bd93362537a30aa3a8ab75dfddc4e26b0b43465a732997c1c9c9e3e3a3ff78ea73313b19f47abd93f461d682b429b9fff2e5cb133d85ad52af9f3730382d54f27b0d094ecfa0a919c140d1a267d4527823c5ba38fb688204218a8defabf7822fac6d3185961af293d52269e162ceed64e3dd44edd888150fc635f8332ed6eb5f568b84a5819ae7a746c9d3604f82fc45bfa4a0b90574f29faffef9d839c1152f9572d41b17fee1730a9f66f7a914a80702775a5eabc3f4df225ee0dd21531e3d285ecc9699f4d46804b9e31dd5d68b96755a1e1ba489f842c3dba70635b2f8fe49f592bb9e69ffa4159c6a6b8c4a9ee0f45c4de033caace79d92e74721730dd4e5021df2cdf0461bde54f79a7d07beb474ab4dc743e1bcd7b13bcc1a52cd5cdcae971404d1ae62b6db53f5639c271b59d730f776ac69b7be088170a1eff42745acde198d5e3f75f5fa1ca5a34c3b168ea7e8d438a43186fba0df9c32a4322d64904e9c53e4d42d32465355a4bee6b56bb08aae4e046bdc3342a0a3d45a6d7242fd8730c9a8f1ab6eef65718bc2997d49daeee6d44ff8244c6ec2058594c4a3fe18a6242decb15a7e0bbf328f234cf719eb82967a934c08ca64b22ef9eb345b2afcf3184d157f7d1fb32866b3dcedd284c8513a1e4e2eec53330207268a8cc478b7dbbb1551c52233d77f539d246c148f736bd532da99744e44a5efe590a8de8604c5b5eec2ffc6b423edf022ccdf1708425d0fd9f3616ded4e4f361be4772ef06e7762d9b3a7fd42e49b65933ffc779f3e7ed6ebf36253239001df05fab0994354fd2deecd4f01a70e32ce9ca8e9586bf983a7a8fb948b45f1b6265f5275ee4933eae94b5b87dfd0749ec2744704613b024f6b098b57989d87adde96af3f73302f893851719dde1b9a94b9ef74395c5a58f1a35179ed23b30f80552e218748e2da29c161535d06928ee4b84b2bf7703456da0e7da3eb80815e818186daeddf364414fb29172a9b7ef447627b8828c5a0e5a32afbd47c1f24385343fe9c68ceb630a22cad5a2842f5191ad7ddcfd095af5ddc843701bb28dfaab14027481e23d9ed631c0c8e9f486d72007ffa071f3fc9cd926267170e4bafd03f7fb0be5463c25188a1d1532f67faee63bb1de79fa8883c98e59d08672687fa4279d41355f0655e035fa23c0a83b09eb063ad914031b111b8dd46b12fa85e89a8f0609da75a2ab7298dde6216a916dcbc137c597367312c8ceafcdab3dc86f1ab3f0eab26e2fb9e26d15ae60cec1385a40709e9c1921cf5e181f4604ef6cde77afa666ce91066bbb56cbd662681facb7046ffb1dd9a8f5f2eb43443c769de4b47e200517f92c494490d693e7fc1fa667b91d2a99f17ee79b4f6d389e049724da7722fbdc6643aa0ba6a5bcb53c5def2e577967aabe67ec4408e7730ab5e64117823db6d85dc9b55c0ba11ac03d14d76faae00246aa52c48d5342d957cf959f06538d3af035fecc5201c507f12b2094dde64f7f709d5c6c9eb5a314ba1e7e09db935db6ed76314355f3599f569cff447fd1d3c564bdc9b5dc5d617f303e5c4ede09ed40dc2f7322f71b53aeb1c413b04f4ef3329396bb7ed79dacd68fd185910c7ff4754e20a24e504c384505f866246a542ae544cecd401d35238352d6a52d49470fd5cc38267a97191008f95b86cd9822b6c3cf7a77be757ce529ad0894c15a5816943ba5a9826f5c9bc640513179aace0a85f98c7c3d533b3c28d4fe8bd5e1491b61b4fb721adb5610a1323ae17edb6d026f6d715339be68bee19de684d63a5816c0f35eb310803f3cdcc1a4e30470f1044dfe1e044ede2da723810a3deb8cb47bdb15a59a3befaee8f77434998ff38a734794713ad952c0327a72f7a01d36fc3c6c949f72564fa598318ef767053e9d551d66eb38bd623bdff169b5ba3be7dfbfaa2e1655c33bcba9e165ceb496b827af7e9e34705f855938e1c326bb78f58bb8d0e54d624d86aacaf11b0b14a0c19613bf856d327590bc962317559fe858f1b633b45ec2f45ec2f0eac1bbb83cf75d26056bce4d9645e38aad62f55148eebf3c4516f3c5434a7a81a9c827349d1a0b138435cbe21b72c2803fdb179e141be7ab810a4db0fe4eb076d49d2c790210a425109376fd1827553f42f3b0c0fe51b1fda38fad74abff5a66a17a5ce6e56ea675c89a42c6ac1afd53843f775747d455eba3329cd18eaea2122d2a18df2cfd0c6e5768b96e4a86709e25ea3d97e9bd95e93f10eee9ab69c261cb8b8d4db4b39b88604364e70bb8dcace3e3c39cf18ef4a59ce81251cf147d6827b7df0df83d06569a2d8823b0c1bcb5b36e9c798d57defc0f0934d30d281513c64138c7061f4126e82ba519d376096d174954a4f9110a7bf8d40b52e7fef0ef33f8bdf37460ed5702ce7561a665eff2f78b2e2c17b7b6fb580b074f4039bf2aa38cd244f631659cc2fdea828f8e903650467a7f0541382b33378b686e0ec7c3786b367df182b153e4c1bc6ab651f93cd0ec2fd37c3a5afe7e01d7f64f5e7610985d05f91927e86feba08fd0236a77d741d89fc06456c1ff0c9e581ed362f8f59c5276210ea3b8fd814f373f5c15b999f7e3e56ebb0ddb1b4be56952243c5712bff426e2d1ff943fd15dc523e24493c126e798a132f8e7bf917629a352f76b6d05fc1ba08ffd20dfdf50e3f397047bddd0e43edd0566b943d183260dbad3dfdd9b827f0fbeff4fea7eb93477a3f4b3eb065e662b8c5cdc310c18bbec2ad6795b9f5970272d773233ade318571b05984ab7f04fddee00c16e1ea17f395521a05ad775452b188599cca78e2198532a369ea2dc2887a0bea455c4ba35abbdc235d8c9876b5a9b90fedf261cf46f46044611f5a8f50fcf86607d386bd4571885655eeab7e60c5263a11bfa8cd7952e381a8bf7ac5fc555fab84577d42fd95228eabd7cc5f0d4ce4208f5cbf62feda40ae15e45a47be66feda40ae073a7207d19f762a9454fa1559549a2a7a3f41360819dec1d23553319aed9acca7dd4699ead1de1867aaf50db1abc1be796ea63ab5175b557e276ab37fa8343cb50da7bb9a2ca174bbd51b32f7b65d29bbd2cf9ed9d7e850fedc9d749fbb4bac89170eecf28a46327ff66e8cad33bd43991f90492f32a7231361c433bb66057f5257f03fa888ca937f730c1b91556f1e5af330ba5447f0fa25fc5c9d69a8dc738f12658dcf0251f75920d586679f1b525535bf62b4ff1e94fc8ea797d2f23130f3ea925a6db9d343c975507b3ddc3df58454c5ed9e2e51bf49b8220c84bf2652617c124e68add985087e7fb9d10b342514d4e81ab3caa9e6ce9b0970ed1a557cd892b5c64f08b588f718883c36387bf9bdf771ce9e3105a9398b2ddc5156df3da97073e6e153b68ba78503b984cf50eb761ea7de82ca398f6a3ee172fd419652ef6ff14368ef6a239cfb846b61281fd8a65690e318d770963f706482d369253c8d052de5381bba9294450db84e15fb1ba8e220558cb22e6917e4195853eade05e4d25f49a3dcdd756975f6b4eedbc83c1ab43c46d8b1dd1e59a947fd4122163ec433e3b8217f98ccf29641ab05d6575fd0eab576d61b872da7c8e76729159733ca64ed2978464e90111fe091f7cf93311afdf3d11f77f00948728254fd214617817f6c2bc1173530414ed0228d29f6ca38aee2f8ef7192d8cc179e7808f2747c71a22f22d0159d685fb3b2fc14e5272d157113be588632be4f680bbfd2af151450a38266e403128ffae3edd6199678345011bdd6ae493375f6b4b6bb66c8428a29cbd9f78b30d8701670fdca75bcaf8f2e84657bc7c2aa2bcfb806de74aad239acaa56dbbf6749e2f077c37af7f64082b31f5597bfd34dbd91d46b25399f4e532a3f8782328923eeb10ec9238d78bc0cdff2a5f5216f45b188925a0139ad31e2ef3d1dd0d9b3feae1dff2e9b054dd3704683dc646246a5fb58119f968f3b7a13ce6418332aec422995057f8f233977a4fc7f35f7302d6e25742a831e2822d18347051a30986b909aa6c5f6e059d7765a6fa2dfb581b4c031639c469d94ed56fbe9ad40ab38a9e3582d8e69b3b53cae2464b398492a52f33877b5b1655270aa1afeb4faade0900b8ce78674f2dde1d7fe8a95f68c46a9e2bb5071d0db6deef5ac4f5811580d882c5306446cb7bdfd19386f3820a30396287513c4ca06c949e80bfa5b465379c9e285d6a6bc17e182aa7335458a7cb9ae845569a1d5b4d4e03906eede7a50c3c9b75b86ec4c151b30c2b0d1a32a41502d4309c46e573d7219ec45b9b539564cfb6dbc50243d7f94365ca11ef45f7411eb66581d9a433f35403c93c8e5fd10eb28c6a8f4ec9d11d691206a2af6d0d7de38f312a8f5e7af1f67ea414a46ad45da82d682ffde825c260d2dde1adbe7579c9defa8baf35d989fa009825ed06053363c10e0b622103b6b9e5a0af68e0ecc5869b83a25a97926bf118e84a369a7f5a529a93586e6d93579de36a4b4c6dbad9378a0d89d638fda00b0dda2438d95f84093749ec6b6f28a95aaa8ae5785ced8be353f8f53689a9359c2efc3e4c2fc34ce5a4a93e985fad3985a9df5cdce5288f3a7250f4fd9c9d8129fd98c2d5bf47d5bb105fe5fb8119f7f87d97693a465cf38f6b78bdf1caf59af492f68dd739ed0d0b910f1db76fb5b75d27f223f157ab68a321b3e914fdbad1a864dcd7703d49d3bec30bc27efb7db500117db6bf0937e96bdcec60aca222ab431480b6fb788f94e0c39ea61a3e83391c4f956f4fe6782defbda12f263c8c2998a4c31a2f0be62798c37efcd53175f7446ab162c2a69b7dfbb4184210f5bf33f78ef5316e599dd87128a5dfa1fe4933d8ab7db477f83441dbbff517b35fdcb768bbe38079a8ba94b70154bd5257da0af7a39253f2a1e5866bbf23cbf838feabcb9848fb8f21202defc7dbb45ff20477df8e2db3d02e1ca4305e6acb17fe3b21853ab433581d7bdc2913925bd217de5a40d6987f471de67f77583dc3bc227df9539e853c504fda4762244fdd5a043fd551f9f0c40a8f05a85d72a3cfcab650bff4198afb9aa934117c9e3bffae9244c685762c8217e21cc37fc96021105885013a6cf616fa96264de1a210a2a4a2e4bc0f00b39ead75e31b796ac7e4d60618d86de17af845509847ec2fc7d2e9d36008dcf0998925dc1875bb27d4b94551f0e704a3600557fffe60a216a99bbaf0efafcec5784c96a3deee999f04635c915ec208ae1936fe53888825a847f23473d982becabeba01ce1caa131fbe4a70df120fc5547faab133b7120fc7547faeb3c6c2b4d4ca555a516deb80d641ab4bfdbe1eaa30478b33f0046175440dd68ea10b3582ae4accae5d67b84a22aa67bc4d5b7088a39423f61f74d82f2729a16240e73d121734587487ba2be527f7e69b71708e3207f62630ff45a41add41f63c4b22f9cfd45514e1ce4efd7d44a68b79d228a7a2b2f20386e7792987dd3d72f6cb3a95312ae0dd02392e56d0ba7fd4fe5b9afe4295b5cc9a3cf752de302de53842bb758d536a66a97a291efdd7e7af729f03ee451de821eb56a6f36580b357b27ae2228668aa61921311899efc567247190cb7c7f550d9dbbe4ee0ee1cd0261a8d0c00f086fdeb4dbe88d63a8f786d4f0eeb62e5f8d5a70e9a4bf753dd4dba950f473c8c86615c89c34c23a900511dc59fbbfe261cfbe7f06f4a2eb0f027f50f0f1767591f7e61709b57cd486f51ff973ff2aba05c52ab41f65dbbe22bcc9b47c5ad034fe9d6a6dee0775ca40da73594b61e01b12a915f526d78e55c5c1ef7d29429626a1a45f688298bf02e6afabedd045294a8875c9c644ce94bddddaf24d0546998dea6cd35bc45ef540ea02aa2bfb0ac32dda13b2bbe3ff0ee1cdef6a2f5570aa6f99992ca7c7ffa163307cd18675a82ec4770f967b184ff1aede26175ed12e5819a84fbe15cd230cdfecb9f02339ed0dadf3052db4f819bec01bf844989f846b9e49786f5c1a2ce7f124859fd4eacff930f88d9417fdb49b61114e64fc40b7db4a1074f7152101cd54280a0b7f577ffe4a3676270d7a6077d2a0071a4b82fe0efe8370b4d915f761eb7a0b8b87bf6fb748f1623384e1066150ebe82bc2aada1e8607d70aa176d7fdbd7172f255a3afc99823757f07cb30abaa31feaeba904f922e2e5bd4012a3c938231f3d5203e4e50deaedf395f7cca9ad4296fd1510f1b800fac39bd6fbccbdeaa5530e562d100f5d71d28f279cb83fada798ab9e9d29c112ad99c2e3b2e56b3de4e73d62c9ea40d15bf37ef7668446a48fed4a82c7a67b6e9a0c90accfb0fdf46e4f627d3e941c0e9d4817c5aa5924be12b3a15ed5fc8ac82c242e3247d98e51d36961b5945d3620e3caee1476ad3b536fc245213599e320cc8b452848c1779c2a49230a3f25d217a340051b5f07de3eb27ea0d4e7f84037983d397f044bdc1d90b68686f70de83c323119c6bafbdb5f10bce4f9f70b9ebce40d0efab43ed733a9022408b0304472d7d75a43803a998590b9bcbc3adfb6c3aa582465db352d5d1175ad19a858b78a21ff1a95dc1a53bc7365d8ba672df679b1d44644f3d5e885f5b42cb486db57adf6d41bf974798cdd78d99c649d282d6bff57ae180fed8aaead3ad5d80815cb580f9abee799e73adc2ebeef99ecabb6c4c12335a342695827fa3aaae972f5faa8ae67baf1f1455f5755d454d3ab8ce83ab410ba493aa836b5cb542d7fe4ef5ce2ca8262691aa72519a0ec1daf95e39df8fa47ad065f91cb716a114f10ab53ad34e0bbc9efa67be5b9d4cff4d3b2ddc1a32db309993cb1650bcdb0d25a1d6d9fc3dd914d73b9a769bc9888e8be7889a41b4a90ab0ba12f8d0db5bf97e5018d5ed5d6c7c26e74391f329edb3b7ac825dd76bb160f302cc1175b8047a078510a31abdbf9bd468734628a484c1a322f1aeb42508c165e3dc6cc5d5badc0ce5ebdf7efacc63753cd18abe19956f6f3f2245a0f7217c8316c5e6a82fe03d50a178203ce4fae90eeeaf89006eae2d1e0406058cb8bfea86fe0a1fc77ea83322eeafbba1bf563111c43eed10eeaf20f6a7ea636defec95d819fba1839fb11f69dc54f9cceff41096667867f9a2ef1b1bdd39e1af4cf7b4afc1fd0e96a3e70e8bb9b2e814f9d1b41e97acb61a085532b6ac3f75d3ba2ab1ab52217426c83c37b64cd628c6c32909fd103212fa0a23427f6aaf6a96231556462ab42315da910aed48956605f5019b288650db54c0d4b27e5fabe3873753eb7db2a41f7d5ba3673f9eac8296559805a34eff35bfceeee621b1c2fca63b5cda645ae2064359aaafebd0763b3785cd8bda15afb139085108501ef24721731a21fcfc690a22edd39c84426eba2580991bc9d626549fff5ff72e58fe340c9d72a14f788a70a752370207acd23d8141143dd8a32ee6e4692b1cea47456b3d82c24eca5e4283fce5b9a61e26cff4d07ad79a383d3cd8d83d8a698fc9dfd1d849d15847d25bc1b15cf2e9c5cc9be0788a2675d1352d246d6a73192eb46567de197f050b6ddc5944ac6189182cc00881f02eafdabc8f77a8ea48551d1dae5adb33adab554f055ff82b5857ebd7b16b585561a55af5ab2aa4e4fe1ae688c11ad4b15c1bb4ed2a8786aa97bb272da5da6d242f28923810441de974395f1f66071ce5c9d2482ede7b69a23c0038578b2bcc7f7122089fe5dfbf8bd1dee3718b8a83d381626c9ff58b40c90451d85016de27f44d42f525f7e0a8074b45dcc4037d27c2c798cdde687e3638ea1b55e65b9ef05a48df610a3622e8c32ce8c37dd08730e8efac49ace16c234860090f308719e9597f85a33ef4ecff8d5f635891d1181ed59f7bc5085fa93fd72456077312225cb9db53da0ca2bd6b38362545a7bdfed98f2f7f7cf1e30fb87265056faeed9b29e56eb6c670d31059b9878237dfd18dcaa510bc61edb6a20011b1c2b25203ceecb9d8d877f4b1becb62f8f87d2063f4a1a0f44bbd0f317d54d888549d112418aedbedbc535fe3df298a4e06909c0c30dcb4db374d0978071f9e63ab87f269c736a83509d943983b4bb8d5dcef61d6f62ae77e0f33c8f77f8afbfdf6a7b9dfcfffa5dc6fc94b57f853fe0799e1c5eb9e9a4d91eb09672a7c53847770af359f31fb76cbdf0bcee4becdaa5a86e45ab14f1ac0bc1b8bf0f0dad7796d3e443188d76a0fb2d793e30824791c8931a83fe471c4cc977e8a13549048fda32218fe0eae7d3dea0fc664704c4fa26e1fd6a3fee998f4bb83637692c0afa899112944cd8b4e0704f9ec98800a55b1daa1f5f38b706df1518b3a058647fd06265c15fbb668e4038a0a66ba826f072a30fc002bf9811b5b5dee106d65aabb77ab3b7414c9c7a24306c7eb516fac46e464ad6f7aaa41e9eae8f3b11a9813f56146678f6b2f9a3e3866fe4a0faa3003eaaf4f92c2f2b44b746520f4c7a9ae44d52d8f51bf4bb1a9b3434411ec8d8f0905dd024255ddf0c172a72aed100f6cabbb44e6edf63b8455d69ca32da94e7057636f0be7269b9d31e36bdc87b49f81c614a392271c5495975a975e63960591faf4c099a42b895a74b5a42256542b4cbafa8a490b620c4722f7ccd07acbb32432da1c16cb384ce2dfa9a7afa4f8de574a17a997c4dfa827e7d4b3169dda8b0cfb4be94426967e6b68fc9be4061d0915d23c45a6fb59dd81b505f8bd0abccfd80409ffeb97b77797d79fff7a09c2ff747375f7f1c3cdcf5fef8a580cc2968084ffe6faeae69d562a94bb73ee2bdb8d338e66841383325f40e6cf20f3ef21f3ad5b5ed73aa1e221d4e444c27ffbe9fad397bb373fbf7f7ff5e5eecd875bbcdb5dfb090f35477c60fb29d21b77218d690d047ade6ecffff099264ebfe68e63ea1e28e9f76e64c0882ebb449d6aa811914ae9e0e1238c26ea68d125fdfc2ab0a552437b18b041b8f6cbf7b111b3cf3d13e6c7fa0d7cf96aa137b51e2164b1dd2e0821d26e66f64ed2e368311e5a4268a8d9eef059456f2d68e6b4eabeda2a1b841bbf7ca8bba955b3a255b3ed76b6dfaad568361eaedc56e922f5766a0f14314d1103519e490e1f871ca99ed19ecedcfb35ab111b0fa9bf22d23d08517fed46ac61d96e2f915407f19b225a870f1f8ae2293ad24b852f62e33ae64b2ef7c5cd8d2bbfcdcb458bf2e5223555720c9ce8cd469f8c86cc5f691910f3d7a4cbb5e4c5a44a0ed4a6d13ceda1dd7e50c76ad585ebb20b26e6bfe0a834b747a5dc6c42f09908177bcf598a769be21b424bff86564f7e53578c5b3be8f4315c7ae93c8ca8f038d304759aac7ddff77ea1d26fe90ab565ca53155eff575658c865de6a13eb5baec7ed2de7228a592869b377747fa5181bbb0bab5951fb3055fbb09e2bedbd5aefbbd86cf40a44bbafd6bb2f36dbbc82a4feea5891447dd98e507f7d8cba9a3a52a769ba49b7dcb4f03b9aa61a5629f4242fd4d6a8dad4316c425ead6a51c7300c790f3a7d7caca8b56e7cbf4bfd353e4e54b8e0e42fa569d3679ed6ef8936fa3f2efcbaeaabb2c6fff573e3af38b4f2ed42b590667a21c553c490222baabdaa8dc5aba62ad218ba38b5ed9cf7f86f31dc1ebcab6acee3e54dd48aca2ddebfd0eaa06bf54eb603e3aca1aaf6cf81f9fa5b160a5a55fe55aba18edaaf2e6e98ec5ff4aac8171afb139c19cd5b4335c18b414392dbd1e0c5691da2d6cde0c5591da2ec64f0e2a94733dd27e5cebff36648bf77d63f3b3d3d6ff6d4aa08473c4567daaea7f0b64009cdb722748246fff96f637c3283d6ffe8ff8f7e0b6378e9406346b4b3bb0feaf0947bc9ec63e8bf30c6430ae57f3872e03561fa8be6ba4a27de31f3e674e529840fa5f718cbb9b7147442154be8b5feade57b57feccf7feadd79b4e7b3ddffb894bcf386af3fed2a1c3c36d78f5eac7ede0fc5cfb0fd977026f0e790eb3b27f37e1d9fb2de60538cd2c7d374b65f248fb16b989aeb0548328878ad377b1906b72d40717d8884edc182b28a10d7d78e686cbbebfbcdc2ba3d559e87d02496c0e2666db306e748d9512cd1de35a4881e148b38826fc3914e1824a9500d47ffbe9e3e70fd757775f6f2f6f7ffe8a739d8b03ff814df9359f21819b4e0e1c03cfcd6e857bd342960a9cbce576d519dd96e264fcbf5d7db9bdfac7ddd7bf5ebebbfaa2352aba51efbf5cfef4f1eae6364f303d0da50c2773db29ae0e477b71a18a4b4a12a09a67fa6e23cace2b7ee5fac3cdff51ed79d6d473ded8f30c4396f79cbbe6e1764ee329d20ee38fe56b5a718d23f455fcf7090fe5e9e05288705dbc857a2c8f07ce513fa54604b22b2e6516d584f655ddc2f1f866079cf486fc952c6f7417a75839e2630849b76f2c14b5bfa3516fdc6eb7eecc777fac1b1c9aee1bbfa8d77c623ca03135d62121a4dbdf775e6a07b6386acec3075abc0eee156e5b03afd589f1508c623fd52f510ff09884bb9c26b5b2d69169d376dbba33dffd71c33bddea0cacaa99c6b34c508f67d25bf34c78b1f683ed7b9749e2652c56a42bf5d2b93e326b832543c6fe92ddfd45d1b269bc022f644e03530b10defda5a511ce8ec5cfa6b0ea60a8bd9a1012fed1e1b02d3b3018e53ab236619565134830976f35ca0402267cb9d6df9f4321030e8a8b2cc3b156e3db56a741081343cd025abfdc61ee8ee59864904868eca123d6d12f2bc80e1fefb9d43d94cbe29cc93cac9401e687c40d37ffce9ff15fd970fd9a6a9eebcaa5cac606ffb15c03143f8ee8d80169bc0eb61ed1f1d09891da3bfa7aa9d843a64a057534868536073432ef1cb237cc0d4f8b141064821678b8440264eed9653dba1f2dc6a567170b5c9407f7a3fc734c14a8b92051bbf766733fd67cacda68d5d2ca836796cd5d37e8c61852d0962fb0e7655a10b90f8b70464190c5503fa5a5764f9ea69f443c8b1969858cb3f58267690ba4cf59c2c3c815c9a8864f91be68897720fd544c888b7769f906387df462343f9ee1e1a3f112ec5aed4fab6e09268a1af2dcae32a0bba1d0cee533418d838cd7e4b1609b52946bfb1f4735b0f13056fbbd1f89f051f7539debfd094f8e67207cc11f8f6730831986fb111d13a69a0feb91fe1deb67b70b6cea81da02dd770b4a33f613faea550f0461ff4ed531f964ae823111ff5e3c345d69542041f0c780c38427951b5811c29b2bb7ca15e9c103a9beed99a8116db7919dbdca75c3070c2b3587260f86d5eb7eef22423878c85924e776630467bd5ee5fa8e23d47d1cd1da485a7e0704791cb1bd34b902aead6ad5c8c68499b11d0a67e4a5e657543a2d471e38c466061a6a7446a2a1ce32559bb23dc0dc7938926eb7fddee00cab999891392c481fd66aeb54436a557b234308b85a22e6d87e1b2734f5965478b6ae7c63b9a7de923faa43fbd4938fdc6f6984bb221bdb88423369420c8c8cca38f5b83565a58100cd6b9607e610d47a0ab2e2307855bb4eeab81246b44dbb7dec3ab3b78ddcbb4f676ed339a9c1f90b45779fbd5c5cdc5dbeb399831edcd935d88334fe9d068d2f3a9d0e201593803510fb17cfbe14e5107b6b0dc842193f50e3b5a7dd5ef88638db6144d5f45c00b8b0ac670e85870bdf186ee7318b51ebf6ea1fb73f7fb96a75d818c342df8529527d9b7837780752a54abad2883b78574decc1c2fff2d39bcbf2e7e79baf1f7ebab97a77f7e697db2ba076a5d8320a4634ae1653063e5efe74f7fec3f5edd51758284ef5eaf2cbf7e7fd7053cf7bf7f1c3e78f979fefd4f7d5d75b55d48c322a42493fc6cb45b8ac94a5922db3d28fd1e3a895868b6542851a2373c670479bc8ea35ee788ae6f942b4841e2499fb0ed623232f31dbb574b7eb23e9ecd7edb60eb9956db70ca948a07838f7cbe585dc6b4d42d1e10561b022196218e6d6fd15c53023abda79e457f8acfb9b16318af09095ef72506806a35678f740859a019eb6a015de9927b18a6704546476974e04a5ecabbe00d1caee1c9b2a9568c6b1e706fa6e60e0064e4d098afe7ca6c28e5d6beccece143dfa3500a00ac0e861fea6db6b5a68ce1a8f7ed187a7c1ea9dc3b02ed693d172b9f779d2aaf7f3383afe36bc1b49b57daebad4575402ee46b2d31f932ed34f1d17518331393ba6be25293aea54e7eb384067fbf9ce2bf93a7d1df962afc61f4c4eb7b01fab39073af2e57e5b7bfb59fbfda6bcfdc15e83fba7fb2dee9f3535b97fbe9ff94543cd3f54339fd65e58ba232bdf3921a03bb8846f182ef367a899598115a9a56269f0905d14a516dc6880cab81ecc8d9a4cc34341b83559ae67dce10a3f44f1e6522b712ebba4af08471cbdba6cb74d9c2eafdd9e5be58d6d0facfccad906dd814128b83cfe06df70f579268575ac6845d19edaa34a378a5db826748fb1b92714ae080305e05e45c69b3a45303b83c5fc857ff9e5cbe52f56d9086b9dac93de8532ac27dfc1c27ff7cbcde5c70f6fefde7db9fcbb367b4137eac052ac6463887a367d500b3aa71970d4876b67b90fd4722f090cdcc31556c90fcefad546b254b80b1d06b0f0df5f7fbabc55059e1ebbc2075f6d4f5fef3e5f7db9bbbabefa7875730bbdc345d68902f4ff50c93f62904895ae18400d94aa7de7cb87cb9b9faeafbe420f5e1c5f1a6e660e335868e3ba47d54db8861bf846fa3fc267c211865fb5e595f6c8ad5d245e921edced4b565e9c1537ac34532520d743052994d612c1144afd6130813dcd5f1041cdfa2a485c0382a555c9050f357f2ed65f4f6b29e8244ef5ed6f1ac5d962e94d553b872d683d84621db399f7402767de84275cd4624fbd074bdaf5e255a9161fbc7cd778e7957bcb33e9fd67d207cfa49fead6f138f21661ccf47b78d8dbb4a0e5795e3cf550a5adfeef1e215ecf2f203c6f96dcbd17e1ccc89c49ce530fdea1b20750edb0bf5ae3a1c9bef3ac52adb19efe1faba7ff67eb19fcb17a067fb69ed33f56cfe9b3f56ceaa5289c438549781f0fbd5d0b5abbd6d8ff95c70cb5fec95a15ff1e254217923355c6c0735823556599aad1dcdbe7955c2cd325b89c939bb808e599e7f0516e9a297c8f457a7efd1cc0df597297dfbef7885ba9776c86cae9e689dbe07cf85ad0326d9a70c1a81ae1058fd07eefc13bf31d68d5fe0f2ca22b9bc1bcf3ba9fcd3b51f960bfc7b5b254ca17fee8114f9f7b9f03573df0d4f23971325741def2245b30dbbca2b9e0d6562bd4d46f5faccd339cd4e1b56b4433548a4ef4f2a9a823b2c1d5012a86b958394efefef3f9fb4fe51f7c57fd3d37ffb3b5596885732e90774c8aa11fd613fd95d721eeb01f3f01bbce61d5803f05f87b311d4fa3d74933bad48882e3c4476b4d2f651256ae8d9ae8036288222d38d74fa8578b08ce7fdc8de1c533ee946b12e1554d24a6c5bb2b97e513cf59967cce459070597b31f7a95cdf9a7285cfe5ba69ca953d97ebba2957fa5caeaba65cd3e772dd37e59a3c97ebb12957e468c5b4fd9a3ad5949acd9c27034e4c52a9035b75f92bd66eb357c25f7578bb2dfc7597bf92edb67c25fc7527573ebacc7b52be22e6156e3f1c2b10c420aa4a38fffc4b40ce89c131c7b68ffa148973e7700c424b3e8c9548e1554376481fc75324081dc9b11f2e97c9da3e350c0ce3fd4ece9cf7971d1b2ef34805e9434cca07d5c38a21fd1cddc048021d6360dad4a67ce0635d3ee5b383cc95e8ef3f4310ee3f43a0eff155ef23e8f17fc3336d4e6a66c0783ada0d0fb9142bbc47a41852d4fc2e84d38ebaf5d50a6f44a7f3ef3f1042d41153952072f3410e3139ea0f2bddeeaef553f7d5de77d7bee44be024d12fe0b4dbf288107e8164bb3d47f73092630c92a8e2e2ed768e1e750c0eac5e30876fb7910528b218097cdc6e2fb52fe4277a67de89a85bce0bd38314d526efa95e0832d2dda06310a3def802c5648eae4034bcc114eebdc19461583cf3fcd2d38f1b3d802442bf2862b133effc137d5715eff79c9728fddd533834db94ee7f4642fd90a920a370bb95f978945a93033d5800efc6afce7abd763bbb98a3cf20703047dfd400c684c31c5d83c0a65378878d1d75fd9180c263f35e8a6ea13ee89ae129d41070a5fe5cab3f37eacf37f5e7b3faf3ab5956aef124c2c319fad560f925d9e851bc5267f660023a704dc30775cc2ddeab0852b04f47041914cf3b04214c9278f22d8821ba4fdeea4f01ee5315dab7e6dee3120173dcb6d7bb482ee172f75d4f8934bcb7fbc49b1f8a4778d66977ae4bd757c5b85e75ce9b7eda52491f860e302a5580e0fc5c55fa9ca30623f2aeb8aab5cffcbd80840c8ed1e0194149e7e7981d4ec5b0247f46a270f0cce39e080bf02abf070fe4fbcf7cbadef0ae28ea4f9ff3fe6847fef4e1cd57e70abf971f972776306c1ffcf07ed6342673d28399163ae999b2b2c1fe8be34451cd3d61d40cc35ac73ab3ab225735cf0f68dee9e3e3e4f5ccbf5f4b7aedd80ed1bdca06c71528600dd6457ae3a9554bf1506a03a3b56e2aac898419a18505aa119715ed0af186911084790c941251d3a13cc052ed488ec4543f1927aa3a14daa4435103fcb4e244732a871415b1abcf780a4c57a487a2aec4286582f5559d33a871049c88e368b818712dac87c58877faea730deb11ef0cc6849a1a74cae998480b74a63e0dd07901b483f26258c5407a8530cc3ba40fa1ae7507e5658b0adc5ccbcfe7a54c7ddefeffa83b831d3761200cdffb14cd1e10a65304c9de56ee6d0f95508ad4dea21c28260b6263455936218df2ee950788c70636d9b4aad4cb6ac1662e197d1eff33633bf86e6b69e787463b17907b4285bd3d19935a4df9248015cf8cde28b366ba3be622c57b30fb0740d93e20a96a2e4d59bcc261ad9a5bc34f202dd53c751c37e59350799aad9a17a66abe627ad274e51654357f8517a6868724eec250cde5fb54f331938d63dc83b492c293e02ac95c52b95c6242f73b0430f5720609cf3f876dcbe550bb65d2f64f6e7da33ecc5d777e91a05f40820e952887c2ca79d29739d051979c8c55f4da9dbe5a3b2fdd1a707ec85a18c60a86fb2f3cba8a86d19fd1b06430e7124a5e61b6e844cb10d851f00c7678e707a47c6721f0117e3210d4fd53061f367c673230bd998162146e1bcac0b7a6b50c7ce66234915bd989dc87f9a2f2ea867af86f97c36d9f107d98a52cf179a62967466258b2b3a6824c7b5e74ce33b58cc2c1d851a38212a35bc69a73b1e3e0bb9dc5b9b2f1e71a62af869a5149851d339741fc898766051a9542d8d1fee504059730c9f48cc31a5cd67004c202d7c1715cac4f147d706d4c70ad999e345db91b0aae1c9e981a1ea20cf1019881d0e0aaaf00d798c90e5ca20fae8b66c3a9b24bc825fcf8dbd7f90f85aeb8d10f537a144393ede3f7b0e797a0f87678ac764fff3a3a7eb4a3e3d9ff1c1dfbf5612cbbd1592a64d5660de877bf3e7ad4f422582e82e5fb62ea68289ede23966d94470cca1eca2306f1f99af4268a953ac0ab7af1cf96c63a054d03273441fc3a90137e39c73f37af8617da8648f1dd789d5d1840b7bb957f63773bd064a33fbc0bfc30f0c33bace3537f60112e991bb2137bf81d0000ffffce0c5d9bfc000100", + "f256e6f5a46e10e60db6a2444386dc4e": "1f8b08000000000000ffdc7d6b73db38b2e877ff8a8eb237a21c85923d4976d61e65af9f19573976ca76923b3737d7059190843545f000a06dedacfffb293c48822028c94eb2a7ced187a9986c34fadd0da0c18968ca05ec9ded9dfe717972797d7974f1f9e8e2fad3c5298ca0b3b5f536dc1e6e87afff166efdf5d70ebc84ce20460271c1309a777637f4e8b3f3c3a3eb93c3ebd3a3b3f757bfc308debededdd8180c604219703ac7c00543e91403c388d314229a5026dfce91e00a0ac753cc01a531a434c61c528c631014c6186232996086531186214488e1499e3c33331f1dbe3fba3e383f3dbfb83e3c3adefb747a25c97efe5afd4afa2ca8f34f57efcf4fcede2bb05f7e791b8fdff8c04ece0ece3f14605bd1aff15f2725d8e7a38baba3ffd39c7578ff56fdfc807b0757279f8f349c336f0deee0fcecece8e0eae85083fae7be3cf9bf12d59614739420cee198d154e034863f3700001434cb23415980b2ac671ecb9f98111ea22c8311a02cdb759e4782dce2331a631841b7ebbce518b1687685d9dc791bd3289f4b0da1383ebac5a938255ce014b3a01b2524bae9f621c03d18bdb3e8903f32816086f8816421c0a1406c8a451fba69b7d77340e52fc10266629e18fa8a01bb5e40694727318cca11214953cc7ebffa70babbd11841261521c5803e74b53cfcd4d8c20c19e658ec95d20b7a4da2e48f6191b3b4f9eea149d1600057e787e73b80e218341da0752dbd84e139bdc59051cec938c140c50c330e418a23cc39620bed7b4a6130c148e40cf79a9394f4d7a9d7b2eb83603976387928ff7ae8c304255c02d4cd84a4445caa990b3118f6ec1796404beb9962719460f9cffdc5491c7434f99d9ec7ac6ef022cfdacc4aaaff1625b96d24a17a100a46e6412f14f494de617680b85295639481193c1a41a7e353bd6253a9bccee72a553b6a6e3a959ab83ea6c119c33c4f048711a4f80e2eb170679f5016280f003aa9341cf35085d6f3342129f6714526411a728198e05f88986929b49abe2143ea26483dfc3fb4984d832732090a5c9cfc538a1db67c930e06901021120c3314ddc8e4802269ec80b5cdf8a3008c4a4a153f3ce88529be17412ff4081b96f8448b3b34351a139e2568715649bb60d01afc609b5dab07440946cce7001d15573b2d0eb0cc3e1fea3e59837a9453161ed6e9ac9b2656454b43129fd13b4dd131c149bc16595d3de91786b20cb36e2fe46291e030e2fc0adf0b49a5d1cace38a1d1cd6ea73621169702899c7f90b1738a83399fae270b35aad3ab520b8c60cea7bb0decb25e7aea1c72ec7a33cde89d94e729496fb80ae27d483199cec694f1b526d381df99463e94a51f907447d68025ca90a4da65e54b9a0be72dcd857a6d197a91c1a542481ad13949a7baf6db01cb8c060328de96cf6a51cd26a1077fd6038a9ae0e5085245d70b8618db0555bcca42f5b7317b674d55052619fe1a9c8d4630941314383b29853ae1cf3a168e56c192d411aa446809a6100acdc594b60aa578bb4a283417ad525142e8b8a251b25a4f34855abdb2a9d3bf9e6c682ebcc2a9fb90a73cc9b31809fc3be2b391ae441a65ae5dceea51bb3653150237e1cc0817942d4286b3044558ba2e0ed23c49faa0ffdb7dde7da931dab1b56ee9a5cc6054cfc3c5f3af1ac337378036fc58725b79723380dbb1d4e2643080286772ed942c8a1a5279f31d491248282f4b4a49ecbdac2d260cf3d99a8b82d542826e6f5752a18884844648109ac20cb97328808a670f8bd6cb2747323b55adefaa6b8d6a1a7131cc30e1a90a5aeab1c140c904e4739893e94cc86530820c33b5644e230c372449307b568eb150c108f618438b70c2e8bc3647c82913b57ad78ac75f2d2bac8795f6aa51c60519061c33f1556f729630cbf92ce8fec633946ac31b755263979d77dd320c0d24c0bb8e5b6a014e387e0cea35707a82dd52933282f0c4abf01f94a441a7539aee43b1363fd43b2679241761dfb940d7bb23ded2bf7a5fdac172a8c9641db043c2239aa63812385e026b60084d979267454409f301658eaf4f8b5aec4a15e975b740b7d322945af3a96cb4b90d03085c19bcdaeac10ebcda92468a53c1163afc0528b9430b2e7db2e4ad574ea4576ea0f50d5421da5159d2455f563f41fdad2db312a6a793ee2b3839e42ebaaa8c7a5566fe02c0e5d480a1dba9060a1e210ff5ead5564fae808fc93d8e83edbaf8511cab2c42e23d5bf664123cb3a89d21ae205c47b740e4b25082ec7a16486671e5ab8a3b288e717c45251119a589665123f2e2d1295c2309fca9b8dc4911789e51a63647c8bdda2099a03c110b40294a169c70e098dd6216424c21a542961d663f926a6709dd958e4a4b269c575496796b4e4d567e9a3c6594a0090e316394059d0a1f8c73a12824a92130215cec74fa1e51b91b119664c82468315a8ba236bb8e718285e1ba5e2bd65ddd83ab7ce5e0f013664c77b5d119401ba9df68a60c653303f7193381ef9f64ab963e64ae35a1a2cd6c2b11b5b0694c6c0d3e0de46a46d7a65c636c27dd4ff23a81e0c711992e89091ee12e0d11d5bac271e0ef76d21aca1fe4a7b28e9fe1e806c8a486cd4cc2b16821fab1ae53456dafa6b4dfa0386e771a492ac34860936f25a965d29fa3cc337fb91a22f1deb732bf2b2467c5bbf3f13f70d4d8e96c894c4fcd3d35d555565669c457813e0e2bf01b926538f661f7ebbbd4b529d71c65ffb0f8f114df8c8f199d9ffb62878fab751cb245ed162ba63a731622e94e5573f66baf682ebcef1e7c7140b3e206829f524014eefe83c28db18efff975c1b3efb1f8efac4ad736f57ac08e31106eedc4e83ae1bf65b1a33dde53e73cd9e1b5dda86d9120a2a9b254f99ffdef4fc536eea59ed1972357bac75262f67f1431fbeb11d3b01e7b0128499248bcd6b34cc93522dd54a5169eefcc5ffb76f1e5cb8b72b91ec72af256a449d35f48a718533133ac23865d8f80155e012f5e343da1d0837c29a97d3672ada8c535501c1fc553ec585fcbc1a02d66194db4ae1ab08381d99d86b8b6fba37306aff68621a1f426cffc93d54b23b5f3ae23582b79f688fd6f2149db429e21d2f411a8fadade0d5106d918f033f2c2bab8f7d7c2bd5fcf170d8daf63f8ab0dbe81b66d170296ed5b160122a1d336cfc344cc30d32944c60bed279d563375f733abbde79f19671df4ffe5a1f611f4fcf4686b031a2b6d4ee8cdd5de98e486d8a70799b60063bbd2f2013abeb42f22dc22880317244960866e71b5287483bed6f70c71a9bb7221b02ab89451ce892ccb102e8d28659cf5b6782c0b258ef5ad174d56ef67faa2482d82b856ffa420520b1b5e25582478cf38eb26b5ebaedb02cf21bbaf69a007ef60d833d4944729efa57f7ce711ca8c4c670999ce048ecf569ca658a0eae8b10e5a8755ae0b23f84c6e51a8e8d48f1a48d55312f13aec6782efc23b3c9e26efcdfbe6110b4aa23c4182b2fad008a782a184884593aa042d682eeaf0a7ea5938a12cc28784297b0f2ad2fa8e91f18c91747a8ad3a998edc02fc3bee7ed01c593c90e0cc3e170b855078819b25e6fd75f4e19ba2562b103afb6c2edca08fdc225110f1392de0481fcafa7edc9989857aaa7725ddf6c176eebc8aacf6a16d91f199d32340fc63949e203c2a244ed4e5ece508c59d06b1f2f5d2f5047b1ed544bc3fa82c7ef4f35e2c06af5ed7b7b8e9792ce701a638699c7c88a574b54aead66c736a186de14673b7546fb6e741288a498edb4b76da99151d7d9b3d1242a97db515d774b38252911aa37ce5d59ea482a15f4891cd08432d311a59acffbc0d12d1ea98e3e37a2c9112745382b7538d536f0e944ebd1ee2381c08c7936823c8df184a43876ab010d12ead6f791a6a2adc490b479ab093776e9eecb3a3d0f4d21484916422882fe6a414434ad49418a40620a7cf50899c85a454a20cd93c4255ea2934eeb97ab22ef448e0f49ec2446295d33729974d5240aac94708618c79a67f56879e7668bd47d925776592cfe9a14b7d4e00d4dec2fe41f27b1626fb536568a4f05c5ba59ae21b8f585f67813ad04e5d056df7bad753b719ca884e4f6911485772325bf8321fceb5f2deea1ca8b77aa4dad519a2618a5906745638ebf1c5bd2d7ef6e74691f19e329493f295d373a6d56f783d9dc7fdbaded2796bc151b892aa2d44968863c1b61df7723a5d7364bd9e568ad604ac865cd984d417a2271bfe5d68baf2c6ec6b0b40f75c63c57775a7b012a16692e1ecfa3eeadfc373059e730edfbae31ad34479cc69531d6de176540c8b0fea7e7b2469157ddd21aabe7f5da42555927699617a3ea9581455423856b74e19ce61c1fa502b3d65ac95e7c390da132102f2913ec394e31bac541e0bd90f423a30cac1169e011b7881e6afc81d320f991e15b4273aeacc7a3b4e5f1a97969c465f389566faad5eab290c7608bc913dfe44a014b26f7a6d4bee76ae052127e88cff87792fd8a40715c2ba6ec8da862dbae6d1fc8531aacacd43c24e8cd5f056825e88a17ebb4a89587b2bbc943f9caf14e839463d35ac0eec84a07791a349b2df7b22c21a6cdb8b94f90b3a4813067098c20678923a34971a5522ffa8b1b962a40b8f28c8bad815aafa717b4d82790d02a7216505e36e5ecca6a551b35e120661890c5234a1846f1020af8bf3b4c2494c667f80e463074f993afce9358bfaa55644febb6d73af535afbb322844db72edd06acb5fbbd5bd66559e68d842c08a9b482b2e0615e9a210be374ad9cc36b1edba4be67243affbbfa21af80e74e125ccf9b40f5d559befc865f8a2db5a57af75efe8092cf871ae60a431e8b1ecd437465dcd37646bdc3274fa899b37cdf4e9a13e17b1d1722c4e642d728b92a25468dc5b748553dc7b0b13b55bd65613f8af86b64bdd7375a060afd69c5f09ae0fbf0c878ef3c870e9240e59e311941ccb487045e6981de7690423f09746a69db80c29ef9c38f212b6865e7e2b0d79b6cbc3300486234c6e715c353d9793bc848e3412b7711f3c51ac3670dd33b8042356eab9dc50aa09a56d6a7555f642f90d49a74b8a35cf8e556d0218d5accdab953ebc29355ac3f4058f398d6eaaddebc2b61deaeafd4c3724baa19389491bf6953237fb089663efc666582f81a0d17bf9e3346e557bcd93119b2de32960b7eeabfbf2c54d788293b82d17b9d74e3db7b26ac1a26de5ac0e5a32c4398e81a4b2b2a8ef02141f26b823694cefc2e2565438437c16f27ccc85d2d8566d33a7c8a4bef0eccba26d61d43199461c55cf4d79f2058f2f355c6dce207029cf181534a289be323f1322e33b9d1efc1d3a779cef0c061dd891ff94ffea15fab6c56288f59112d29466386d094afed8df2909073916c7219c5214cb85beb43d379678227d8bc36b8ab8ac023bd78dbb447d19ff6c1f7d58ca963aac967cb52e749731a647d3b16a388c43f89860c431309c5014872e6dce01791b9a4e1fea17dc977330d764b5f1208d5d2c32fd15861809f475f86db701215f9410c6fc6bb65f0092780f4660430dfbcea767bca3f6eb0fdd1cfecc2d7feae1e8e5cbc60930bf23229a412079f3a5bb482aa273ddd969bc01152a746fe84c9ae32b2082c33f722e0041668761fb376618dd389aa84fb6d73259ed80d8acd6406d85f87b422b226142128119d05c009e67620124e65e5832918bb7a2e4198d5c9db47c3f02aab593671de9fe9afd4296605a8482d6118a75c9600db914047b17ae2dd441bbda0e5a2824f1be63ea7599aeb07b2fa3b5de009bd5beba4ed669eb7ab3d9ae35119178efa5dab758d232b79e18a27fa318dc2e89274ac2eda8fa71c2385fc76aeb770a1e61b86d37d61e4f277d0c9da63bfd09845a1df92b292d7ecd13b8878d8d0d990d543788a95e682a53a55358e8a61159fc581b4981e7f368861ab56b2b57566a8a8d8d499e46c51577f359ab04cffbfa4af2199a9709c39cfacbb7a17a794ab808cd91390f2af85d89b944db389f33e86e11d3efe203739237bc1f0eff86f1af938909906a01b7c8309d98efafc962adab8bcd2ebc78013584c508f5b00aee23782d53e46000cfd974ecd418d6c976f14d8060107cfdffcfbff5067299ff97adbf6c990f02c4b9962e068ca299ccd432d9e0fb08670226847101cfc38da642bd24fdad24894da7e3314235baea62517f9da4c26029eb8d3e6cbd6db65b79a7fbab998eb262c670c984c1d219e1b7dfe0d71efc0b86f75251cef46e4dc8e81d7435627c9fe9465d92c20cdf9b8fe9c11d1133c8e4ea4a95bb9de79d108ec26908cf87c3c964380ce13d351fc7d21b308d3e0487fba6c5a4f97c8c59d736943ac716ca72e34e19bb05a6ac7a63b0b9b9019bbaed05b8c82713d880cd8165ef76470c27ff2cda378ac9753daa3e4602fa533350355ed6a879d8180ce00cdf0b88e81ceb7dd41962b1244ac83a6c9ee9be14bdad4a27b0f7f1447552463917740e5c75f9482c996e03ea432e5778e305a8a3af620796ed54d4b7340a19e2070338969a940e90313227eafb1c77587ffcf03520211819e702f31db8efc3c2f0aed7b3e49fe62e91f4fcbdabab8b93fd4f574797d71f8f2eae3f5e9c7c38319f1b7c5d75d6a845f1f1258ce06bcdaebad25e089704cf714cf27906938422b1dbad77e5746f115b48abbac5d16b23d706082531cc114903f9af1efce902181f0ea6c9f5474a527140298bc37b7805c3f04d0f36a1edcd4bf7cda2754cf9e6371886db6ffc54004c93eb63d59c661b8a07b270c6759048d104c39e178dfbeca1fb4d7f34a2fbff52bb034ae9e9b3474fa541c869b6015ddfaa03968f94bbf30d06f01145378ec100490595630565211cab282b13502ad4fd24d38082239ac6f0ca32310beb2549230c4474b9b611690e9994bcb4db08990b1e39c7b0fd1ac64480a0909594f0306c6014b39c034ab219826886d21427929898d12cc3715fd14e2480fa6003e23c9f975f06dd0a57c847bbee5ee9470db5e429918153c3e7d73c6218a7973290b441ce91780df9b56028e5f2c1cf721265d19ca83032b227844d6d6496f60736e57d18f661cb6b8185975cea80d994cfd7ad6fb0694ff675f84d2eda3db894f621f2a3f10fd1f96f0c2398d33888fab0fde66d38eced2a2c72bdcd8268609eb50e9f7edf70b6d670e33783116cbf79130edbd12118c19607a0eedabb5589665247093d4daa7f8ff3c904b3eaef627bcd6aabcc0549b813298af349a9905fb6d5a77f82b7afdd787240f354c8b2b07a1ea1f416f12f2416b3bef9e3774ca633d187d2002a68c20f14c8216162b16ba7756b6359e6f3e2b7090728497c1952baafaabd6512d6795587a669a29a46f1bdb03c7b73604904c53b50a6d7609a1c68707793619ac008cab7f5d581a2e59314a4a781c542591f653407236bbcb9a45eb4059bb8dd2f12ad83619a84392f810d3e77c7aa50797d9e2916a7c59ba02c3fbe76ad18d0ed43b7e989f2a91d1cf4dfa576bbdf9a34e2148d137374af1169932a490bcb399f32d8a5d0c1a17d4029cf48775f3da935def59f6270e6a68cde9c2f222b49950d9a5991a4d5c267a3fedf1992ea378dbeaff4b6e59cc6385145a2c4521e9ae86f0c59a5ab9e47e658c471cf8336a31c5ec19fb2ca7b804816312445425d1b57a8558393d7250a566cb7d044f6e53bd731641022f1bdf91cdea79390c4750528dbfd2a41365bcbca6f721d457978fff8a1f012b6e4f05772fce249e3b7bf55d43bab974760f9c5c252ad1c969bd705fe8f1c73a16f4b362d0c45224749b28098a13ba039334b1a15dac40cdba8ac480757d2324c6b474419964a57a35564f4ab5dcf6b2bbd190257879b69128e491a1b179b26e1dec5c5de1fd7fb9f8e8f8f2efac62d3c63d4f3432450738c127f5f421dfe71b6f7e1e4e0faf062ef8ba7a9bb964fbc9f23b601ca36980698e453d7661f9060e4fef5e4d60a375522d3e3add4e6d94faa706d4f2c247671d59a345b8f7f0de25b2b28aa2a0c335f4cedc3b692def1e9f9de554974ab216fd6f27eb8ff470172747af4e1e8ecaa0fc3a6fe9693e246e81f4ed1366cc2eb2655d26bd4182eadeae3f9c9d9d5a52a66abfae5fb92c0dd0ca77269c2804728c17c90a1d4789dd2a3de3cd1374dbd4ea753c8556140b5908befcae78d33dab27457955a09e7f88463eefadcfd87b0cbb08c704f60559abcc3e5816dffe5dfc605dceb8915ac66dd1abceb81d4586c50fde4270b4aa8f3383291eb5610332474cac577e65ba9889bcfd2c445bda0fa1fbc7233dfafa1317613b2ef3e9053e6e17b81d358574c268e56b6dfee723d4f02d4e5fecb116cfd0cd1146231df04d10971b960aa13b3558229ee53191e740f95cdd52bc955e39e2f145de0f09b0dfce205349035e2fe600077b8f8660fc33a89ab165640e9421fd5963ceaec17fa909ca45c60144b64fc0e6506475c7c7357cc14824e82b8e898efc2a4f5caa0c255d4a4690c319666c531cc11bbc1ac280a2d3c21bc27b798434a220ce7c156cf87d1fa7e6c5fdd899fa31b5971c418b8ea5c49166a4b54ea7d86522002229a27318c71f3a8c75e05d16ca18cf62362c2365ca98cf622cc36eea5606bdafdc31a86ae4aad391633aa7695a2a5b153f23f43e91473b549ac8a7122b88d4f2b8987f0459a4fda156aeb8b0898616684acf6ca528c633dd1dec7130838c6a6da9bd7ffcf059b4584b10e987b86e05e8b5fa973968f8c66980982b9ed5ee665718504df995b5585841e76371e36fe330000ffff85c9196802680000", + "f3aa7c7c063ea75f55c6f07e3b99f877": "1f8b08000000000000ffcc595b8fdbb8f57fd7a738ff0cf2327fcb97997a67a1c13eb4db6c11a08b14cd027d580430251d59ec50a44052633bd97cf7821749d4cd49da9da26320b128f2dc2fbf436f6eff0fb8901561f423ae33a5e0f9fbf576bd83dfe0e7b7bfc05f69865c21fc0647aacb265d67a2da70cc04236a333c77bb89a2cd2dfc59644d855c4700f0c3eff6e7a9df46700bbb35fc28a4c44c832e1118e50825d263a98172208c412ac549a1546bb3fd6e0d7f93f88c5c03c9ffd9286da453200a2804d7a0e84704526894202445ae89a6824356127e446528d277ef0da14d1495ba62f029027b322e4845d925814a70a16a92e1aafffa089b5bd8994360058c9d8009ecd6bb7df8323e61fa4475acf1ac63234bec844c60b7ddbeb63befcccecfd6b8ef3133d2a99733eedfb112cf680d5b117934ea4f6dba89a254e4176b0ab72b81ed6304209e51164c9c1228699e237f74727bca3c4769291f2a42f90190a1f10564822baa3472cd2e86dddb379e89d96699e454d58c5c124899c89e42aa612404fee4792bbee07028771d330527aa4bcae1a09c2d0f66b3a1742052d38ce1c1c863dc619dff632945852bf8894a2cc4796549bf270591b40d8a5d1f1286790277583d8696597ff78095319073e25fa4686aca8f8ecf0b67ca1ff3dcda26f3764ac5d998c8b0a7bcd5aacd93f7a538d9ddad1fcd9e37f9d119b4734b29adc6a938c78e54d2aa12a7e21c46771bf5db70b10f9267aa68ca7014e573494e7989926ac233278bca08333a0cb27821fb433a22cfe180d5a13be50d3113e1b5c46fcff5200a76588dd3f71793e40c9f9181c28a704db3ff4e2a1f25b9404ab2a7a3140dcf4d52904cd3675b3d9f944b3ad86dbdeac4f9b7db1f67820999809684ab9a48e4fa71e8ab80572ab41615a4429a74ef5208f60fb177c838264db2418e9990aef6066967826f056fdface05d8d92cca41f4953f9aba69ae1071f95866feca448800b3e7090adb33daf041a53954c89ee9d756d17e4426bcce74276ac960db153d798862a4df4485791d252f0631f74279f3da96039cac7ffa9ecc8448eabe829cd57912255fd3b67cab23d9754d94491aacce2a8167fbf7d1d1aae450207d5a4b6f29b6f75d01d0a292a2045619a033fce000c43658e79631cd8d463fe0ffbd78f630c605b652d1475b1259111938b66f5194d13222c268c1e790229516883d3e8a09ad487b88bed78bbbedb9b5e63df39d65ad4f645bbbeb98537558a798ef9cbf79b4115b0e96fb2b9220e48299a2fd41b5a1dc3dc55fac2d0a7aed7e12721ab172c95269f2ce00b708411422d65cd2c4cf2dd7426b71bad055f4594d78d5e45a2d6a6aed6ab4821c34caf22536f8844f29fa5510b18bf0677f6b06d26f36671806bffc6548b30614e5df874b5f50f006267d3b0a089c23508db7c0a21ab96db0894f5f27d0ba1000105923bbf0c44b72da13b3a88ce0910a59ca494517d012d5c2041c668f6445286a02f7537572c87caaf66db0fafdce3ab0fdd8244853a78564d5a51fdcaf5be769820758d441aa513701416edcc51b6b96a64a9499e4fb161275792c495f81817226b546c0f4f24bdb2c5cb7e6547abcd74cb627d8056e6a443d85e4ba5856c133a6b549bd10d57a821bdd837b5c4672a1a05b261c3f00d2490941fa77a2ebc6f955c78dd69387c6fd5138d36399bc0ae3e7b9c017fb2ec0c705c0ab645971514596e74fd3430d2fa7e6fa691f583fbefbbbbbe55cc610b9b322749eada3319cd03630c61a1e220ef6c4b3db4d204bdb62f2af783a46d355202720396458d520191085c68c848633ab168349c4ae4e6c4053ea21466c9100358e236d3b7191e91e79379a643918371c6c360af5c0818bb01559376a0e90aed393ed15c97d3021d04ae59bd77aba7926a8c6da14ffcd54c7f68191db5c8012c72b073f5d2f86aa17437e588a344a5ac05aea28f69f5c8b1200d0b58ab4c0ac65222bb06ffff9ecda0c1f55d80345a8c62effac0daa18651130e922004163ee9b212b3a7549cc33a4a722a5e7df84ac78f3c356a9783f06fa412d2177d5100e59974b71cc6f239b64fae8c04570c43897953a5286d21f435dd56c158d594c7a31e31dd2b1a3ddc6bd56ca1c08cd1c74340df4082016ed8ab26b3832b5e5e73ca876dadad7e4864565ee956264e6cee0e2e0c1ce9581485429d407c579fe7fc30696c41544c7430d0b4225977b73792b037a65b09a6c145e1c7906032a5fd7ba8c05adaa1538b4c6b690aa2a6a80ca183af468789cd7b150aca306e6a26481e06c415b83042983335cfe1f2b75ca37457092f82cee72a9dafb53d0c7495c6d5b6610bcc5113cad4f21de217e8cf0e7a5545e465489251a563aafb99eb67aab2971b57ae483caaba55cd88c6a1b0e330fd12b53641dc95ee87456271ff274e3c788acdf11b268ec29e0d665f922ac11a6d611c00c3a29d8ebb0165b7adcf6ea19b64b6dd52df57cdcae7285a074cc6feee89c68e91ab83c1b20ceb63407fefef106eec359327efb1c051e2c56db603826f9c199abc70ebe184f68756f2f07e27152c1fe8dc9ac097afee2e6befb5bca1bcf882296570d3d0b72f67cc9154bbbb56a840037bde31539ae8468dd98597169de0dbb1c6f30a43afb1b3e20d21c43d7f8c29cff16c7cda729748aa6f9001eeea336ccd27e4e0dc6409da72fe0f0368fd543189e62f333186842ddc9b7f9704b77cc60c28b79d2c08c9fe967574bf6a5f5a3432ce89b15bdb671fae77dbdecd57a33474b2953671839293b99b467aa3786ace5de658c6904c8cf8a23a3a7c95402da84bb1a99a9d60d7d4e93795068e0e93ba8fc7c945b0554d975234c7d252896eb8c851bdb34afbb01ac5290c63a82d64df7775ac05c4f125f1187a2ead3a53ec5dd8cd3b78128881785ff6d4e676e0ac9491ece9d1b7fb012555137ea5d00e64ddb77a8eeee6ed984b548939dc3c64e6b3e0e339e66bff03c6d071f7f7dfe5e97efe445250a9749c9594e5fe9817c85e9ace49d392799b87bf756ec35b877d5b03662bdc959f1ba241f5835e644df45796ba87c55207be4face0c60cca9fae8593af62e6c05192baccc6cc61d85bc26976dc995fcf056e1f928fd1e77f050000ffff222970aa71200000", + }) + if err != nil { + panic(err) + } + g.DefaultResolver = hgr + + func() { + b := packr.New("Assets", "./static") + b.SetResolver("css/normalize.css", packr.Pointer{ForwardBox: gk, ForwardPath: "f3aa7c7c063ea75f55c6f07e3b99f877"}) + b.SetResolver("img/gos.png", packr.Pointer{ForwardBox: gk, ForwardPath: "166310f2d73113b478111b0a976a0eea"}) + b.SetResolver("index.html", packr.Pointer{ForwardBox: gk, ForwardPath: "2f53e054245e3cec681be9135541dbcb"}) + b.SetResolver("js/main.js", packr.Pointer{ForwardBox: gk, ForwardPath: "f256e6f5a46e10e60db6a2444386dc4e"}) + b.SetResolver("js/vivagraph-0.12.0.min.js", packr.Pointer{ForwardBox: gk, ForwardPath: "853579e9f8c28c5a0ea8a5ed642bbad0"}) + }() + + return nil +}() diff --git a/plugins/analysis/webinterface/httpserver/parameters.go b/plugins/analysis/webinterface/httpserver/parameters.go index a32ab36fd8..0bee3d52e7 100644 --- a/plugins/analysis/webinterface/httpserver/parameters.go +++ b/plugins/analysis/webinterface/httpserver/parameters.go @@ -6,8 +6,10 @@ import ( const ( CFG_BIND_ADDRESS = "analysis.httpServer.bindAddress" + CFG_DEV = "analysis.httpServer.dev" ) func init() { flag.String(CFG_BIND_ADDRESS, "0.0.0.0:80", "the bind address for the web API") + flag.Bool(CFG_DEV, false, "whether the analysis server visualizer is running dev mode") } diff --git a/plugins/analysis/webinterface/httpserver/plugin.go b/plugins/analysis/webinterface/httpserver/plugin.go index c84fabe599..dfc752a3ec 100644 --- a/plugins/analysis/webinterface/httpserver/plugin.go +++ b/plugins/analysis/webinterface/httpserver/plugin.go @@ -5,34 +5,41 @@ import ( "net/http" "time" + "github.com/gobuffalo/packr/v2" "github.com/iotaledger/goshimmer/packages/parameter" "github.com/iotaledger/goshimmer/packages/shutdown" "github.com/iotaledger/hive.go/daemon" "github.com/iotaledger/hive.go/logger" + "github.com/labstack/echo" "golang.org/x/net/context" "golang.org/x/net/websocket" ) var ( - log *logger.Logger - httpServer *http.Server - router *http.ServeMux + log *logger.Logger + engine *echo.Echo ) const name = "Analysis HTTP Server" +var assetsBox = packr.New("Assets", "./static") + func Configure() { log = logger.NewLogger(name) - router = http.NewServeMux() + engine = echo.New() + engine.HideBanner = true - httpServer = &http.Server{ - Addr: parameter.NodeConfig.GetString(CFG_BIND_ADDRESS), - Handler: router, + // we only need this special flag, because we always keep a packed box in the same directory + if parameter.NodeConfig.GetBool(CFG_DEV) { + engine.Static("/static", "./plugins/analysis/webinterface/httpserver/static") + engine.File("/", "./plugins/analysis/webinterface/httpserver/static/index.html") + } else { + engine.GET("/static/*", echo.WrapHandler(http.StripPrefix("/static", http.FileServer(assetsBox)))) + engine.GET("/", index) } - router.Handle("/datastream", websocket.Handler(dataStream)) - router.HandleFunc("/", index) + engine.GET("/datastream", echo.WrapHandler(websocket.Handler(dataStream))) } func Run() { @@ -44,9 +51,10 @@ func Run() { func start(shutdownSignal <-chan struct{}) { stopped := make(chan struct{}) + bindAddr := parameter.NodeConfig.GetString(CFG_BIND_ADDRESS) go func() { - log.Infof("Started %s: http://%s", name, httpServer.Addr) - if err := httpServer.ListenAndServe(); err != nil { + log.Infof("Started %s: http://%s", name, bindAddr) + if err := engine.Start(bindAddr); err != nil { if !errors.Is(err, http.ErrServerClosed) { log.Errorf("Error serving: %s", err) } @@ -63,8 +71,16 @@ func start(shutdownSignal <-chan struct{}) { ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() - if err := httpServer.Shutdown(ctx); err != nil { + if err := engine.Shutdown(ctx); err != nil { log.Errorf("Error stopping: %s", err) } log.Info("Stopping %s ... done", name) } + +func index(e echo.Context) error { + indexHTML, err := assetsBox.Find("index.html") + if err != nil { + return err + } + return e.HTMLBlob(http.StatusOK, indexHTML) +} diff --git a/plugins/analysis/webinterface/httpserver/static/index.html b/plugins/analysis/webinterface/httpserver/static/index.html index 98e675e7ae..211feba0c7 100644 --- a/plugins/analysis/webinterface/httpserver/static/index.html +++ b/plugins/analysis/webinterface/httpserver/static/index.html @@ -3,15 +3,15 @@ GoShimmer - Network Visualizer - - - + + +
From 4be465ea32203495e5e7d2aaa740d5bec400697f Mon Sep 17 00:00:00 2001 From: capossele Date: Fri, 31 Jan 2020 11:45:21 +0000 Subject: [PATCH 179/184] :rewind: reverts server event RemoveNode --- .../analysis/webinterface/recordedevents/recorded_events.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/analysis/webinterface/recordedevents/recorded_events.go b/plugins/analysis/webinterface/recordedevents/recorded_events.go index 723eef7740..31dba5c72f 100644 --- a/plugins/analysis/webinterface/recordedevents/recorded_events.go +++ b/plugins/analysis/webinterface/recordedevents/recorded_events.go @@ -30,8 +30,8 @@ func Configure(plugin *node.Plugin) { lock.Lock() defer lock.Unlock() - //delete(nodes, nodeId) - nodes[nodeId] = false + delete(nodes, nodeId) + //nodes[nodeId] = false })) server.Events.NodeOnline.Attach(events.NewClosure(func(nodeId string) { From 358d1ec28a5129b8b239ba5e97ce37b9553a270d Mon Sep 17 00:00:00 2001 From: capossele Date: Fri, 31 Jan 2020 12:18:29 +0000 Subject: [PATCH 180/184] :heavy_minus_sign: mod tidy --- go.sum | 5 ----- 1 file changed, 5 deletions(-) diff --git a/go.sum b/go.sum index fb6165532b..769edd98ff 100644 --- a/go.sum +++ b/go.sum @@ -75,7 +75,6 @@ github.com/gobuffalo/logger v1.0.3 h1:YaXOTHNPCvkqqA7w05A4v0k2tCdpr+sgFlgINbQ6gq github.com/gobuffalo/logger v1.0.3/go.mod h1:SoeejUwldiS7ZsyCBphOGURmWdwUFXs0J7TCjEhjKxM= github.com/gobuffalo/packd v0.3.0 h1:eMwymTkA1uXsqxS0Tpoop3Lc0u3kTfiMBE6nKtQU4g4= github.com/gobuffalo/packd v0.3.0/go.mod h1:zC7QkmNkYVGKPw4tHpBQ+ml7W/3tIebgeo1b36chA3Q= -github.com/gobuffalo/packr v1.30.1 h1:hu1fuVR3fXEZR7rXNW3h8rqSML8EVAf6KNm0NKO/wKg= github.com/gobuffalo/packr/v2 v2.7.1 h1:n3CIW5T17T8v4GGK5sWXLVWJhCz7b5aNLSxW6gYim4o= github.com/gobuffalo/packr/v2 v2.7.1/go.mod h1:qYEvAazPaVxy7Y7KR0W8qYEE+RymX74kETFqjFoFlOc= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -336,8 +335,6 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191122220453-ac88ee75c92c/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876 h1:sKJQZMuxjOAR/Uo2LBfU90onWEf1dF4C+0hPJCc9Mpc= -golang.org/x/crypto v0.0.0-20191227163750-53104e6ec876/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d h1:9FCpayM9Egr1baVnV1SX0H87m+XB0B8S0hAMi99X/3U= golang.org/x/crypto v0.0.0-20200128174031-69ecbb4d6d5d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -391,8 +388,6 @@ golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191018095205-727590c5006e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 h1:JA8d3MPx/IToSyXZG/RhwYEtfrKO1Fxrqe8KrkiLXKM= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 h1:1/DFK4b7JH8DmkqhUk48onnSfrPzImPoVxuomtbT2nk= golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 5f56391c3565393d3e39c93663a6e10110396d25 Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Tue, 28 Jan 2020 11:11:50 +0100 Subject: [PATCH 181/184] adds changelog entry for v0.1.0 --- CHANGELOG.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000..b10d7fa5d2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,52 @@ +# v0.1.0 - 2020-01-31 + +> Note that this release is a complete breaking change, therefore node operators are instructed to upgrade. + +This release mainly integrates the shared codebase between Hornet and GoShimmer called [hive.go](https://github.com/iotaledger/hive.go), +to foster improvements in both projects simultaneously. Additionally, the autopeering code from [autopeering-sim](https://github.com/iotaledger/autopeering-sim) +has been integrated into the codebase. For developers a Go client library is now available to communicate +with a GoShimmer node in order to issue, get and search zero value transactions and retrieve neighbor information. + +A detailed list about the changes in v0.1.0 can be seen under the given [milestone](https://github.com/iotaledger/goshimmer/milestone/1?closed=1). + +* Adds config keys to make bind addresses configurable +* Adds a `relay-checker` tool to check transaction propagation +* Adds database versioning +* Adds concrete shutdown order for plugins +* Adds BadgerDB garbage collection routine +* Adds SPA dashboard with TPS and memory chart, neighbors and Tangle explorer (`spa` plugin) +* Adds option to manually define autopeering seed/private keys +* Adds Golang CI and GitHub workflows as part of the continuous integration pipeline +* Adds back off policies when doing network operations +* Adds an open port check which checks whether NATs are configured properly +* Adds `netutil` package +* Adds the glumb visualizer backend as a plugin called `graph` (has to be manually enabled, check the readme) +* Adds rudimentary PoW as a rate control mechanism +* Adds the autopeering code from autopeering-sim +* Adds association between transactions and their address +* Adds the possibility to allow a node to function/start with gossiping disabled +* Adds buffered connections for gossip messages +* Adds an OAS/Swagger specification file for the web API +* Adds web API and refactors endpoints: `broadcastData`, `findTransactionHashes`, +`getNeighbors`, `getTransactionObjectsByHash`, `getTransactionTrytesByHash`, `getTransactionsToApprove`, `spammer` +* Adds a Go client library over the web API +* Adds a complete rewrite of the gossiping layer +* Fixes the autopeering visualizer to conform to the newest autopeering changes. + The visualizer can be accessed [here](http://ressims.iota.cafe/). +* Fixes parallel connections by improving the peer selection mechanism +* Fixes that LRU caches are not flushed correctly up on shutdown +* Fixes consistent application naming (removes instances of sole "Shimmer" in favor of "GoShimmer") +* Fixes several analysis server related issues +* Fixes race condition in the PoW code +* Fixes race condition in the `daemon` package +* Fixes several race conditions in the `analysis` package +* Fixes the database not being closed when the node shuts down +* Fixes `webauth` plugin to function properly with the web API +* Fixes solidification related issues +* Fixes several instances of overused goroutine spawning +* Upgrades to [BadgerDB](https://github.com/dgraph-io/badger) v2.0.1 +* Upgrades to latest [iota.go](https://github.com/iotaledger/iota.go) library +* Removes sent count from spammed transactions +* Removes usage of `errors.Identifiable` and `github.com/pkg/errors` in favor of standard lib `errors` package +* Use `network`, `parameter`, `events`, `database`, `logger`, `daemon`, `workerpool` and `node` packages from hive.go +* Removes unused plugins (`zmq`, `dashboard`, `ui`) \ No newline at end of file From 1a354538e52f90efafaffb98fd3718afef5972a6 Mon Sep 17 00:00:00 2001 From: Jake Cahill <45230295+JakeSCahill@users.noreply.github.com> Date: Fri, 31 Jan 2020 16:50:52 +0000 Subject: [PATCH 182/184] Improve API docs and add to separate folder (#198) * Improve API docs and add to separate folder * Fix table format * Update api-reference.md --- plugins/webapi/docs/api-reference.md | 1053 ++++++++++++++++++++++++++ plugins/webapi/{ => docs}/api.yaml | 25 +- plugins/webapi/docs/env.json | 5 + 3 files changed, 1078 insertions(+), 5 deletions(-) create mode 100644 plugins/webapi/docs/api-reference.md rename plugins/webapi/{ => docs}/api.yaml (87%) create mode 100644 plugins/webapi/docs/env.json diff --git a/plugins/webapi/docs/api-reference.md b/plugins/webapi/docs/api-reference.md new file mode 100644 index 0000000000..455e8bbcd4 --- /dev/null +++ b/plugins/webapi/docs/api-reference.md @@ -0,0 +1,1053 @@ +--- +title: GoShimmer API +language_tabs: + - go: Go + - shell: Shell + - javascript--nodejs: Node.JS + - python: Python +toc_footers: [] +includes: [] +search: true +highlight_theme: darkula +headingLevel: 2 + +--- + +

GoShimmer API v0.1.0

+ +The GoShimmer API provides a simple and consistent way to get transactions from the Tangle, get a node's neighbors, or send new transactions.

This API accepts HTTP requests and responds with JSON data. + +## Base URLs + +All requests to this API should be prefixed with the following URL: + +``` +
http://localhost:8080 +``` + +

+ +## POST /broadcastData + +Creates a zero-value transaction and attaches it to the Tangle. + +Creates a zero-value transaction that includes the given data in the `signatureMessageFragment` field and the given address in the `address` field.

This endpoint also does tip selection and proof of work before attaching the transaction to the Tangle. + +### Body parameters + +```json +{ + "address": "string", + "data": "string" +} +``` + +

Body parameters

+ +|**Name**|**Type**|**Required**|**Description**| +|---|---|---|---| +|body|object|true|Request object| +|» address|string|true|Address to add to the transaction's `address` field.| +|» data|string|false|Data to add to the transaction's `signatureMessageFragment` field.

The data must be no larger than 2187 bytes, and the address must contain only trytes and be either 81 trytes long or 90 trytes long, including a checksum.| + +### Examples + +-------------------- +### Go +```go +package main + +import ( + "bytes" + "net/http" +) + +func main() { + + headers := map[string][]string{ + "Content-Type": []string{"application/json"}, + "Accept": []string{"application/json"}, + + } + + data := bytes.NewBuffer([]byte{jsonReq}) + req, err := http.NewRequest("POST", "http://localhost:8080/broadcastData", data) + req.Header = headers + + client := &http.Client{} + resp, err := client.Do(req) + // ... +} + +``` +--- +### cURL +```bash +# You can also use wget +curl -X POST http://localhost:8080/broadcastData \ + -H 'Content-Type: application/json' \ + -H 'Accept: application/json' + +``` +--- +### Node.js +```js +const fetch = require('node-fetch'); +const inputBody = '{ + "address": "string", + "data": "string" +}'; +const headers = { + 'Content-Type':'application/json', + 'Accept':'application/json' + +}; + +fetch('http://localhost:8080/broadcastData', +{ + method: 'POST', + body: inputBody, + headers: headers +}) +.then(function(res) { + return res.json(); +}).then(function(body) { + console.log(body); +}); + +``` +--- +### Python +```python +import requests +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json' +} + +r = requests.post('http://localhost:8080/broadcastData', params={ + +}, headers = headers) + +print r.json() + +``` +-------------------- + +### Response examples + +> 200 Response + +```json +{ + "hash": "99IJMBGYVUAYAFAZFGAIVCFWMXP9WTDPX9JDFJLFKNUBLGRRHBERVTTJUZPRRTKKKNMMVX9PYGBKA9999" +} +``` + +

Response examples

+ +|**Status**|**Meaning**|**Description**|**Schema**| +|---|---|---|---| +|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful response|Inline| +|400|[Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)|Error response|Inline| + +

Response examples

+ +Status Code **200** + +|**Field**|**Type**|**Description**| +|---|---|---| +|» hash|string|The transaction's hash on the Tangle.| + +Status Code **400** + +|**Field**|**Type**|**Description**| +|---|---|---| +|» message|string|The error message.| + + + +## POST /findTransactionHashes + +Gets any transaction hashes that were sent to the given addresses. + +Searches the Tangle for transactions that contain the given addresses and returns an array of the transactions hashes that were found. The transaction hashes are returned in the same order as the given addresses. For example, if the node doesn't have any transaction hashes for a given address, the value at that index in the returned array is empty. + +### Body parameters + +```json +{ + "addresses": [ + "string" + ] +} +``` + +

Body parameters

+ +|**Name**|**Type**|**Required**|**Description**| +|---|---|---|---| +|body|object|true|Request object| +|» addresses|[string]|true|Addresses to search for in transactions.

Addresses must contain only trytes and be either 81 trytes long or 90 trytes long, including a checksum.| + +### Examples + +-------------------- +### Go +```go +package main + +import ( + "bytes" + "net/http" +) + +func main() { + + headers := map[string][]string{ + "Content-Type": []string{"application/json"}, + "Accept": []string{"application/json"}, + + } + + data := bytes.NewBuffer([]byte{jsonReq}) + req, err := http.NewRequest("POST", "http://localhost:8080/findTransactionHashes", data) + req.Header = headers + + client := &http.Client{} + resp, err := client.Do(req) + // ... +} + +``` +--- +### cURL +```bash +# You can also use wget +curl -X POST http://localhost:8080/findTransactionHashes \ + -H 'Content-Type: application/json' \ + -H 'Accept: application/json' + +``` +--- +### Node.js +```js +const fetch = require('node-fetch'); +const inputBody = '{ + "addresses": [ + "string" + ] +}'; +const headers = { + 'Content-Type':'application/json', + 'Accept':'application/json' + +}; + +fetch('http://localhost:8080/findTransactionHashes', +{ + method: 'POST', + body: inputBody, + headers: headers +}) +.then(function(res) { + return res.json(); +}).then(function(body) { + console.log(body); +}); + +``` +--- +### Python +```python +import requests +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json' +} + +r = requests.post('http://localhost:8080/findTransactionHashes', params={ + +}, headers = headers) + +print r.json() + +``` +-------------------- + +### Response examples + +> 200 Response + +```json +{ + "transactions": [ + [ + "string" + ] + ] +} +``` + +

Response examples

+ +|**Status**|**Meaning**|**Description**|**Schema**| +|---|---|---|---| +|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful response|Inline| + +

Response examples

+ +Status Code **200** + +|**Field**|**Type**|**Description**| +|---|---|---| +|» transactions|[array]| + + + +## POST /getTransactionObjectsByHash + +Gets transactions objects for the given transaction hashes + +Searches the Tangle for transactions with the given hashes and returns their contents as objects. The transaction objects are returned in the same order as the given hashes. If any of the given hashes is not found, an error is returned. + +### Body parameters + +```json +{ + "hashes": [ + "string" + ] +} +``` + +

Body parameters

+ +|**Name**|**Type**|**Required**|**Description**| +|---|---|---|---| +|body|object|true|Request object| +|» hashes|[string]|true|Transaction hashes to search for in the Tangle.

Transaction hashes must contain only 81 trytes.| + +### Examples + +-------------------- +### Go +```go +package main + +import ( + "bytes" + "net/http" +) + +func main() { + + headers := map[string][]string{ + "Content-Type": []string{"application/json"}, + "Accept": []string{"application/json"}, + + } + + data := bytes.NewBuffer([]byte{jsonReq}) + req, err := http.NewRequest("POST", "http://localhost:8080/getTransactionObjectsByHash", data) + req.Header = headers + + client := &http.Client{} + resp, err := client.Do(req) + // ... +} + +``` +--- +### cURL +```bash +# You can also use wget +curl -X POST http://localhost:8080/getTransactionObjectsByHash \ + -H 'Content-Type: application/json' \ + -H 'Accept: application/json' + +``` +--- +### Node.js +```js +const fetch = require('node-fetch'); +const inputBody = '{ + "hashes": [ + "string" + ] +}'; +const headers = { + 'Content-Type':'application/json', + 'Accept':'application/json' + +}; + +fetch('http://localhost:8080/getTransactionObjectsByHash', +{ + method: 'POST', + body: inputBody, + headers: headers +}) +.then(function(res) { + return res.json(); +}).then(function(body) { + console.log(body); +}); + +``` +--- +### Python +```python +import requests +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json' +} + +r = requests.post('http://localhost:8080/getTransactionObjectsByHash', params={ + +}, headers = headers) + +print r.json() + +``` +-------------------- + +### Response examples + +> 200 Response + +```json +{ + "transaction": [ + { + "hash": "string", + "weightMagnitude": 0, + "trunkTransactionHash": "string", + "branchTransactionHash": "string", + "head": true, + "tail": true, + "nonce": "string", + "address": "string", + "timestamp": 0, + "signatureMessageFragment": "string" + } + ] +} +``` + +

Response examples

+ +|**Status**|**Meaning**|**Description**|**Schema**| +|---|---|---|---| +|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful response|Inline| +|404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Transaction(s) not found|None| + +

Response examples

+ +Status Code **200** + +|**Field**|**Type**|**Description**| +|---|---|---| +|» transaction|[[Transaction](#schematransaction)]| +|»» hash|string| +|»» weightMagnitude|integer| +|»» trunkTransactionHash|string| +|»» branchTransactionHash|string| +|»» head|boolean| +|»» tail|boolean| +|»» nonce|string| +|»» address|string| +|»» timestamp|integer| +|»» signatureMessageFragment|string| + + + +## POST /getTransactionTrytesByHash + +Gets the transaction trytes of given transaction hashes. + +Searches the Tangle for transactions with the given hashes and returns their contents in trytes. The transaction trytes are returned in the same order as the given hashes. If any of the given hashes is not found, an error is returned. + +### Body parameters + +```json +{ + "hashes": [ + "string" + ] +} +``` + +

Body parameters

+ +|**Name**|**Type**|**Required**|**Description**| +|---|---|---|---| +|body|object|true|Request object| +|» hashes|[string]|true|Transaction hashes to search for in the Tangle.

Transaction hashes must contain only 81 trytes.| + +### Examples + +-------------------- +### Go +```go +package main + +import ( + "bytes" + "net/http" +) + +func main() { + + headers := map[string][]string{ + "Content-Type": []string{"application/json"}, + "Accept": []string{"application/json"}, + + } + + data := bytes.NewBuffer([]byte{jsonReq}) + req, err := http.NewRequest("POST", "http://localhost:8080/getTransactionTrytesByHash", data) + req.Header = headers + + client := &http.Client{} + resp, err := client.Do(req) + // ... +} + +``` +--- +### cURL +```bash +# You can also use wget +curl -X POST http://localhost:8080/getTransactionTrytesByHash \ + -H 'Content-Type: application/json' \ + -H 'Accept: application/json' + +``` +--- +### Node.js +```js +const fetch = require('node-fetch'); +const inputBody = '{ + "hashes": [ + "string" + ] +}'; +const headers = { + 'Content-Type':'application/json', + 'Accept':'application/json' + +}; + +fetch('http://localhost:8080/getTransactionTrytesByHash', +{ + method: 'POST', + body: inputBody, + headers: headers +}) +.then(function(res) { + return res.json(); +}).then(function(body) { + console.log(body); +}); + +``` +--- +### Python +```python +import requests +headers = { + 'Content-Type': 'application/json', + 'Accept': 'application/json' +} + +r = requests.post('http://localhost:8080/getTransactionTrytesByHash', params={ + +}, headers = headers) + +print r.json() + +``` +-------------------- + +### Response examples + +> 200 Response + +```json +{ + "trytes": [ + "string" + ] +} +``` + +

Response examples

+ +|**Status**|**Meaning**|**Description**|**Schema**| +|---|---|---|---| +|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful response|Inline| +|404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|Transactions not found|None| + +

Response examples

+ +Status Code **200** + +|**Field**|**Type**|**Description**| +|---|---|---| +|» trytes|[string]| + + + +## GET /getTransactionsToApprove + +Gets two tip transactions from the Tangle. + +Runs the tip selection algorithm and returns two tip transactions hashes.

You can use these hashes in the branch and trunk transaction fields of a new transaction. + +### Examples + +-------------------- +### Go +```go +package main + +import ( + "bytes" + "net/http" +) + +func main() { + + headers := map[string][]string{ + "Accept": []string{"application/json"}, + + } + + data := bytes.NewBuffer([]byte{jsonReq}) + req, err := http.NewRequest("GET", "http://localhost:8080/getTransactionsToApprove", data) + req.Header = headers + + client := &http.Client{} + resp, err := client.Do(req) + // ... +} + +``` +--- +### cURL +```bash +# You can also use wget +curl -X GET http://localhost:8080/getTransactionsToApprove \ + -H 'Accept: application/json' + +``` +--- +### Node.js +```js +const fetch = require('node-fetch'); + +const headers = { + 'Accept':'application/json' + +}; + +fetch('http://localhost:8080/getTransactionsToApprove', +{ + method: 'GET', + + headers: headers +}) +.then(function(res) { + return res.json(); +}).then(function(body) { + console.log(body); +}); + +``` +--- +### Python +```python +import requests +headers = { + 'Accept': 'application/json' +} + +r = requests.get('http://localhost:8080/getTransactionsToApprove', params={ + +}, headers = headers) + +print r.json() + +``` +-------------------- + +### Response examples + +> 200 Response + +```json +{ + "branchTransaction": "string", + "trunkTransaction": "string" +} +``` + +

Response examples

+ +|**Status**|**Meaning**|**Description**|**Schema**| +|---|---|---|---| +|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful response|Inline| + +

Response examples

+ +Status Code **200** + +|**Field**|**Type**|**Description**| +|---|---|---| +|» branchTransaction|string| +|» trunkTransaction|string| + + + +## GET /spammer + +Sends spam transactions. + +Sends zero-value transactions at the given rate per second.

You can start the spammer, using the `cmd=start` command and stop it, using the `cmd=stop` command. Optionally, a parameter `tps` can be provided (i.e., `tps=10`) to change the default rate (`tps=1`). + +

Body parameters

+ +|**Name**|**Type**|**Required**|**Description**| +|---|---|---|---| +|cmd|string|true|Command to either `start` or `stop` spamming.| +|tps|integer|false|Change the sending rate.| + +#### Enumerated Values + +|Parameter|Value| +|---|---| +|cmd|start| +|cmd|stop| + +### Examples + +-------------------- +### Go +```go +package main + +import ( + "bytes" + "net/http" +) + +func main() { + + data := bytes.NewBuffer([]byte{jsonReq}) + req, err := http.NewRequest("GET", "http://localhost:8080/spammer", data) + req.Header = headers + + client := &http.Client{} + resp, err := client.Do(req) + // ... +} + +``` +--- +### cURL +```bash +# You can also use wget +curl -X GET http://localhost:8080/spammer?cmd=start + +``` +--- +### Node.js +```js +const fetch = require('node-fetch'); + +fetch('http://localhost:8080/spammer?cmd=start', +{ + method: 'GET' + +}) +.then(function(res) { + return res.json(); +}).then(function(body) { + console.log(body); +}); + +``` +--- +### Python +```python +import requests + +r = requests.get('http://localhost:8080/spammer', params={ + 'cmd': 'start' +) + +print r.json() + +``` +-------------------- + +

Response examples

+ +|**Status**|**Meaning**|**Description**|**Schema**| +|---|---|---|---| +|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful Response|None| +|404|[Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)|invalid command in request|None| + + + +

+ +## GET /getNeighbors + +Gets the node's chosen and accepted neighbors. + +Returns the node's chosen and accepted neighbors. Optionally, you can pass the `known=1` query parameter to return all known peers. + +

Body parameters

+ +|**Name**|**Type**|**Required**|**Description**| +|---|---|---|---| +|known|integer|false|Returns all known peers when set to 1.| + +### Examples + +-------------------- +### Go +```go +package main + +import ( + "bytes" + "net/http" +) + +func main() { + + headers := map[string][]string{ + "Accept": []string{"application/json"}, + + } + + data := bytes.NewBuffer([]byte{jsonReq}) + req, err := http.NewRequest("GET", "http://localhost:8080/getNeighbors", data) + req.Header = headers + + client := &http.Client{} + resp, err := client.Do(req) + // ... +} + +``` +--- +### cURL +```bash +# You can also use wget +curl -X GET http://localhost:8080/getNeighbors \ + -H 'Accept: application/json' + +``` +--- +### Node.js +```js +const fetch = require('node-fetch'); + +const headers = { + 'Accept':'application/json' + +}; + +fetch('http://localhost:8080/getNeighbors', +{ + method: 'GET', + + headers: headers +}) +.then(function(res) { + return res.json(); +}).then(function(body) { + console.log(body); +}); + +``` +--- +### Python +```python +import requests +headers = { + 'Accept': 'application/json' +} + +r = requests.get('http://localhost:8080/getNeighbors', params={ + +}, headers = headers) + +print r.json() + +``` +-------------------- + +### Response examples + +> 200 Response + +```json +{ + "chosen": [ + { + "id": "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq", + "publicKey": "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq", + "services": [ + { + "id": "peering", + "address": "198.51.100.1:80" + } + ] + } + ], + "accepted": [ + { + "id": "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq", + "publicKey": "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq", + "services": [ + { + "id": "peering", + "address": "198.51.100.1:80" + } + ] + } + ], + "known": [ + { + "id": "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq", + "publicKey": "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq", + "services": [ + { + "id": "peering", + "address": "198.51.100.1:80" + } + ] + } + ] +} +``` + +

Response examples

+ +|**Status**|**Meaning**|**Description**|**Schema**| +|---|---|---|---| +|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|Successful response|Inline| +|501|[Not Implemented](https://tools.ietf.org/html/rfc7231#section-6.6.2)|Neighbor Selection/Discovery is not enabled|None| + +

Response examples

+ +Status Code **200** + +|**Field**|**Type**|**Description**| +|---|---|---| +|» chosen|[[Peer](#schemapeer)]| +|»» id|string| +|»» publicKey|string| +|»» services|[[PeerService](#schemapeerservice)]| +|»»» id|string| +|»»» address|string| +|»» accepted|[[Peer](#schemapeer)]| +|»» known|[[Peer](#schemapeer)]| + + + +# Schemas + +

Peer

+ + + +```json +{ + "id": "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq", + "publicKey": "V8LYtWWcPYYDTTXLeIEFjJEuWlsjDiI0+Pq", + "services": [ + { + "id": "peering", + "address": "198.51.100.1:80" + } + ] +} + +``` + +### Properties + +|**Name**|**Type**|**Required**|**Description**| +|---|---|---|---| +|id|string|false|ID of the peer node.| +|publicKey|string|false|Public key of the peer node.| +|services|[[PeerService](#schemapeerservice)]|false|Services that the peer node is running.| + +

PeerService

+ + + +```json +{ + "id": "peering", + "address": "198.51.100.1:80" +} + +``` + +### Properties + +|**Name**|**Type**|**Required**|**Description**| +|---|---|---|---| +|id|string|false|ID of the service. Can be "peering", "gossip", or "fpc".| +|address|string|false|The IP address and port that the service is using.| + +

Transaction

+ + + +```json +{ + "hash": "string", + "weightMagnitude": 0, + "trunkTransactionHash": "string", + "branchTransactionHash": "string", + "head": true, + "tail": true, + "nonce": "string", + "address": "string", + "timestamp": 0, + "signatureMessageFragment": "string" +} + +``` + +### Properties + +|**Name**|**Type**|**Required**|**Description**| +|---|---|---|---| +|hash|string|false|Transaction hash.| +|weightMagnitude|integer|false|The weight magnitude of the transaction hash.| +|trunkTransactionHash|string|false|The transaction's trunk transaction hash.| +|branchTransactionHash|string|false|The transaction's branch transaction hash.| +|head|boolean|false|Whether this transaction is the head transaction in its bundle.| +|tail|boolean|false|Whether this transaction is the tail transaction in its bundle.| +|nonce|string|false|The transaction's nonce, which is used to validate the proof of work.| +|address|string|false|The address of the transaction.| +|timestamp|integer|false|The Unix epoch at which the transaction was created.| +|signatureMessageFragment|string|false|The transaction's signature or message.| + diff --git a/plugins/webapi/api.yaml b/plugins/webapi/docs/api.yaml similarity index 87% rename from plugins/webapi/api.yaml rename to plugins/webapi/docs/api.yaml index 67d8307731..c41d9d87f0 100644 --- a/plugins/webapi/api.yaml +++ b/plugins/webapi/docs/api.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: title: GoShimmer API - description: "Get transactions from the Tangle, get a node's neighbors, or send new transactions." + description: "The GoShimmer API provides a simple and consistent way to get transactions from the Tangle, get a node's neighbors, or send new transactions.

This API accepts HTTP requests and responds with JSON data." version: 0.1.0 servers: - url: http://localhost:8080 @@ -17,17 +17,21 @@ paths: summary: Creates a zero-value transaction and attaches it to the Tangle. description: Creates a zero-value transaction that includes the given data in the `signatureMessageFragment` field and the given address in the `address` field.

This endpoint also does tip selection and proof of work before attaching the transaction to the Tangle. requestBody: - description: Data and address to add to the transaction.

The data must be no larger than 2187 bytes, and the address must contain only trytes and be either 81 trytes long or 90 trytes long, including a checksum. required: true + description: Request object content: application/json: schema: + required: + - address type: object properties: address: type: string + description: Address to add to the transaction's `address` field. data: type: string + description: Data to add to the transaction's `signatureMessageFragment` field.

The data must be no larger than 2187 bytes, and the address must contain only trytes and be either 81 trytes long or 90 trytes long, including a checksum. responses: 200: description: Successful response @@ -58,17 +62,20 @@ paths: summary: Gets any transaction hashes that were sent to the given addresses. description: Searches the Tangle for transactions that contain the given addresses and returns an array of the transactions hashes that were found. The transaction hashes are returned in the same order as the given addresses. For example, if the node doesn't have any transaction hashes for a given address, the value at that index in the returned array is empty. requestBody: - description: Addresses to search for in transactions.

Addresses must contain only trytes and be either 81 trytes long or 90 trytes long, including a checksum. + description: Request object required: true content: application/json: schema: + required: + - addresses type: object properties: addresses: type: array items: type: string + description: Addresses to search for in transactions.

Addresses must contain only trytes and be either 81 trytes long or 90 trytes long, including a checksum. responses: '200': description: Successful response @@ -130,16 +137,21 @@ paths: summary: Gets transactions objects for the given transaction hashes description: Searches the Tangle for transactions with the given hashes and returns their contents as objects. The transaction objects are returned in the same order as the given hashes. If any of the given hashes is not found, an error is returned. requestBody: + description: Request object required: true content: application/json: schema: + required: + - hashes type: object properties: hashes: type: array items: type: string + description: Transaction hashes to search for in the Tangle.

Transaction hashes must contain only 81 trytes. + responses: '200': description: Successful response @@ -162,17 +174,20 @@ paths: summary: Gets the transaction trytes of given transaction hashes. description: Searches the Tangle for transactions with the given hashes and returns their contents in trytes. The transaction trytes are returned in the same order as the given hashes. If any of the given hashes is not found, an error is returned. requestBody: - description: Transaction hashes to search for in the Tangle.

Transaction hashes must contain only 81 trytes. + description: Request object required: true content: application/json: schema: + required: + - hashes type: object properties: hashes: type: array items: type: string + description: Transaction hashes to search for in the Tangle.

Transaction hashes must contain only 81 trytes. responses: '200': description: Successful response @@ -186,7 +201,7 @@ paths: items: type: string '404': - description: Transaction(s) not found + description: Transactions not found /getTransactionsToApprove: get: diff --git a/plugins/webapi/docs/env.json b/plugins/webapi/docs/env.json new file mode 100644 index 0000000000..e1b99eef90 --- /dev/null +++ b/plugins/webapi/docs/env.json @@ -0,0 +1,5 @@ +{ + "language_tabs": [{ "go": "Go" }, { "shell": "Shell" }, { "javascript--nodejs": "Node.JS" }, { "python": "Python" }], + "summary": true, + "expandBody": true +} \ No newline at end of file From 3787f7c54f609526eaa6550f32e4aa1f92cabe3a Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Fri, 31 Jan 2020 17:51:47 +0100 Subject: [PATCH 183/184] Adjusts readme for v0.1.0 release (#124) * :construction: WIP * :pencil: adds modules description * :pencil: adds more details about the design * :pencil: adds ToC * :pencil: fixes typos * :pencil: moves glumb into Prerequisites section * :pencil: fixes ToC anchors * :pencil: improves modules overview * fixes spaceing in readme, fixes some typos, adds visualizer install instr. * :art: changes code-block to note * :art: updates building-blocks image * more fixes * remove testnet mention from readme * :pencil: improves autopeering module * Tidy build instructions * Review README * Readd link to autopeering simulator * :pencil: adds Adaptive proof of work simulator link * Fix spacing after link * Remove no longer included plugins * rewrites client lib http ref section * try to make readme more uniform * ay caramba * Update README.md (#196) Added the web address to visit to view the visualizer. * :pencil: adds Dashboard section * updates dashboard screenshot * use other screenshot Co-authored-by: Angelo Capossele Co-authored-by: Jake Cahill <45230295+JakeSCahill@users.noreply.github.com> Co-authored-by: Wolfgang Welz --- README.md | 268 +++++++++++++++++++++++++++++-------- images/GoShimmer.png | Bin 0 -> 278918 bytes images/autopeering.png | Bin 0 -> 27513 bytes images/building-blocks.png | Bin 0 -> 29920 bytes images/dashboard.png | Bin 0 -> 76629 bytes images/outputs.png | Bin 0 -> 87175 bytes 6 files changed, 215 insertions(+), 53 deletions(-) create mode 100644 images/GoShimmer.png create mode 100644 images/autopeering.png create mode 100644 images/building-blocks.png create mode 100644 images/dashboard.png create mode 100644 images/outputs.png diff --git a/README.md b/README.md index d85f7d547b..09934711ba 100644 --- a/README.md +++ b/README.md @@ -1,82 +1,244 @@ -# goshimmer +

+
+ +

-[![Build Status](https://travis-ci.org/iotaledger/goshimmer.svg?branch=master)](https://travis-ci.org/iotaledger/goshimmer) +

Prototype node software for an IOTA network without the Coordinator

-## Run Shimmer +

+ + Developer documentation portal +

+

+ Discord + StackExchange + Apache 2.0 license + Go version + Build status + Latest release +

+ +

+ About ◈ + Design ◈ + Implemented Coordicide modules ◈ + Work-in-progress modules ◈ + Installation ◈ + Getting started ◈ + Client-Library and HTTP API reference ◈ + Supporting the project ◈ + Joining the discussion +

-First, you need to [install Go](https://golang.org/doc/install) if it is not already installed on your machine. It is recommended that you use the most recent version of Go. +--- -### Requirements +## About -- gcc: Some packages in this repo might require to be compiled by gcc. Windows users can install [MinGW-gcc](http://tdm-gcc.tdragon.net/download). +This repository is where the IOTA Foundation's Research Department runs simulations of the Coordicide modules to study and evaluate their performance. +The aim of this open repository is to give the community the opportunity to follow developments, take part in testing, and learn more about [Coordicide](https://coordicide.iota.org/). -## Build +**Note:** You can find details about future development plans in our [roadmap](https://roadmap.iota.org). -If you need to develop locally and be able to build by using your local code, i.e., without waiting for pushing your commits on the repo, clone the repository directly inside the `src/github.com/iotaledger/` folder of your `$GOPATH` with the command: +## Design -``` -git clone git@github.com:iotaledger/goshimmer.git -``` +The code in GoShimmer is modular, where each module represents either one of the [Coordicide components](https://coordicide.iota.org/) or a basic node function such as the gossip layer, ledger state, and API. -or if you prefer https over ssh +![Coordicide blueprint](images/building-blocks.png) -``` -git clone https://github.com/iotaledger/goshimmer.git -``` +This approach allows us to develop each module in parallel and to test GoShimmer with one or more different versions. + +Each module is defined in the `packages` directory and can be enabled, using the `plugins` directory. + +**Note:** See the `main.go` file to see which plugins are currently supported. + +## Implemented Coordicide modules + +The `master` branch is the stable version of the GoShimmer software, which includes a minimal set of modules to allow you to send and gossip zero-value transactions. + +The `master` branch includes the following Coordicide modules: + +- [Node identities](https://coordicide.iota.org/module1) + +- [Autopeering](https://coordicide.iota.org/module2) + + +The autopeering module is divided into two submodules: + +- **Peer discovery:** Responsible for operations such as discovering new peers and verifying their online status + +- **Neighbor selection:** Responsible for finding and managing neighbors + +![Autopeering design](images/autopeering.png) + +We also have a standalone autopeering simulator in this [repository](https://github.com/iotaledger/autopeering-sim). + +## Work-in-progress modules + +Work-in-progress modules are typically kept on a different branch such as `mana`, and are not compatible with the `master` branch. Therefore, nodes that run these branches cannot join the current network because the code either is still too experimental or it includes breaking changes. + +The following Coordicide modules are a work in progress: + +- [Mana](https://coordicide.iota.org/module1): The `mana` branch contains a first implementation of the mana module in the `packages` directory. + +- [Cellular Consensus](https://coordicide.iota.org/module5.1.1): The `ca` branch contains a first implementation of the Cellular Consensus module in the `packages` directory. -Verify that you have installed the minimal required go version (1.12.7): +- [Fast Probabilistic Consensus](https://coordicide.iota.org/module5.1.2): The `fpc` branch contains a first implementation of the Fast Probabilistic Consensus module in the `packages` directory. We also have a standalone FPC simulator in this [repository](https://github.com/iotaledger/fpc-sim). + +- [Spam Protection](https://coordicide.iota.org/module3): You can find the initial simulation source code of the rate control in this [repository](https://github.com/andypandypi/IOTARateControl) and the source code of the Adaptive Proof of Work simulator [here](https://github.com/iotaledger/adaptive-pow-sim). + +As well as these modules, we are working on the following node functions: + +- Ledger State: The `ledger_state` branch implements a version of the [parallel-reality-based ledger state](https://iota.cafe/t/parallel-reality-based-ledger-state-using-utxo/261) (using the UTXO model). + + ![parallel_reality](images/outputs.png "Ledger State") + +## Client-Library and HTTP API reference + +You can use the Go client-library to interact with GoShimmer (located under `github.com/iotaledger/goshimmer/client`). + +Alternatively, you can check out the [API docs](https://docs.iota.org/docs/node-software/0.1/goshimmer/references/api-reference) +to implement your own client or inspect the available HTTP API endpoints. + +For code generation, you might want to use the [OAS/Swagger specification file](https://github.com/iotaledger/goshimmer/blob/master/plugins/webapi/api.yaml) directly. + +## Installation + +You have two options to install and run GoShimmer: + +- Use the precompiled executable file +- Compile the code from source + +### Execute the precompiled executable file + +This repository includes a `goshimmer` file (for Linux and macOS) and a `goshimmer.exe` file (for Windows), which are precompiled executables. + +To run the node, all you need to do is execute one of these files, depending on your operating system. + +```bash +# Linux and macOS +./goshimmer +# Windows +goshimmer.exe ``` + +### Compile the code from source + +If you want to build your own executable file, you need to follow these steps. + +#### Prerequisites + +To complete this guide, you need to have at least [version 1.13 of Go installed](https://golang.org/doc/install) on your device. + +To check if you have Go installed, run the following command: + +```bash go version ``` -You can build your executable (as well as cross compiling for other architectures) by running the `go build` tool inside the just cloned folder `goshimmer`: +If Go is installed, you should see the version that's installed. -``` -go build -o shimmer -``` +--- -On Windows: -``` -ren shimmer shimmer.exe -``` +1. Clone the repository -You can then run by: + ```bash + git clone https://github.com/iotaledger/goshimmer.git + ``` -Linux -``` -./shimmer -``` +2. Change into the `goshimmer` directory -Windows -``` -shimmer -``` +3. Use one of the following commands to build your executable file, depending on your operating system -## Docker + ```bash + # Linux and macOS + go build -o goshimmer + # Windows + go build -o goshimmer.exe + ``` -To run Shimmer on docker, you must first build the image with -``` -docker build -t iotaledger/goshimmer . -``` -and then run it with -``` -docker run --rm -it -v "$(pwd)/mainnetdb:/app/mainnetdb" iotaledger/goshimmer -``` -You may replace `$(pwd)/mainnetdb` with a custom path to the database folder. + **Note:** If you're using Windows PowerShell, enclose `goshimmer.exe` in single quotation marks. For example: go build -o 'goshimmer.exe'. -To start Shimmer in the background, you can also simply use [Docker Compose](https://docs.docker.com/compose/) by running -``` -docker-compose up -d +## Getting started + +When you first run GoShimmer, the node starts running and tries to connects to neighbors, using the autopeering module. + +To run other modules such as the `spammer` or the Glumb visualizer `graph`, you can configure GoShimmer to enable them through plugins. + +**Note:** For a list of all the available configuration parameters, you can run the following command: + +```bash +# Linux and macOS +./goshimmer -help +# Windows +goshimmer.exe -help ``` -### Install Glumb visualizer +You can configure GoShimmer in the following ways: + +* Use a configuration file called `config.json` +* Use command-line options + +The repository includes a `config.json` file, which the executable file will find and use when you execute it. + +To use the command line, execute the file with one of the following commands, depending on your operating system -Install both the Glumb visualizer and socket.io client lib within the root folder/where the binary is located: ```bash -git clone https://github.com/glumb/IOTAtangle.git -// only this version seems to be stable -cd IOTAtangle && git reset --hard 07bba77a296a2d06277cdae56aa963abeeb5f66e -cd ../ -git clone https://github.com/socketio/socket.io-client.git +# Linux and macOS +./goshimmer --node.enablePlugins "spammer" +# Windows +goshimmer.exe --node.enablePlugins "spammer" ``` + +Here, we use the command-line flags to enable the spammer plugin. This plugin allows you to send spam transactions to your node. + +### Dashboard + +GoShimmer provides access to a SPA dashboard showing TPS, memory chart, neighbors and a Tangle explorer. + +You can change its configuration (e.g, bind address, port) under the section `dashboard` of the `config.json` file, for example by changing the bind address to `0.0.0.0:8081` to enable the access from remote and/or by enabling the authentication. + +To access the dashboard, you can use your browser (the default address is `http://127.0.0.1:8081`). + + ![dashboard](images/dashboard.png "Dashboard") + +### Installing the Glumb visualizer + +The Glumb visualizer allows you to view the transactions in the network, using a web browser. + +1. Enable the `graph` plugin either in your `config.json` file or in the command line (`--node.enablePlugins=["graph"]`) + +2. If you're running GoShimmer with the precompiled executable file, do the following in the `goshimmer` directory: + + ```bash + git clone https://github.com/glumb/IOTAtangle.git + // only this version seems to be stable + cd IOTAtangle && git reset --hard 07bba77a296a2d06277cdae56aa963abeeb5f66e + cd ../ + git clone https://github.com/socketio/socket.io-client.git + ``` + +3. If you built the code from source, do the following in the `goshimmer` directory: + + ```bash + git submodule init + git submodule update + ``` + +To open the visualizer, run GoShimmer, and go to `127.0.0.1:8083` in a web browser. + +## Supporting the project + +If you want to contribute to the code, consider posting a [bug report](https://github.com/iotaledger/goshimmer/issues/new-issue), feature request or a [pull request](https://github.com/iotaledger/goshimmer/pulls/). + +When creating a pull request, we recommend that you do the following: + +1. Clone the repository +2. Create a new branch for your fix or feature. For example, `git checkout -b fix/my-fix` or ` git checkout -b feat/my-feature`. +3. Run the `go fmt` command to make sure your code is well formatted +4. Document any exported packages +5. Target your pull request to be merged with `dev` + +## Joining the discussion + +If you want to get involved in the community, need help getting started, have any issues related to the repository or just want to discuss blockchain, distributed ledgers, and IoT with other people, feel free to join our [Discord](https://discord.iota.org/). diff --git a/images/GoShimmer.png b/images/GoShimmer.png new file mode 100644 index 0000000000000000000000000000000000000000..8aa6b1afcd756d3fa634ded5ed482f7b7787d9e4 GIT binary patch literal 278918 zcmV(+K;6HIP)2US=95{~m$lCj(0i}%?Mqfx-m5CRs#^c;|MtHzRS`86 z`}j{y>hbaHSe16nw19JQLZbszt19}i!z zz(|Ta z^s?f-Fei|w1YSMp*m*D;wlPSCfL^=8KCWLWcgx?+XQ*${EPuL*u5BIQlJNz%P=Lu~5u+7)F z0UNaBtofe=F93>D;0)P~`-i{mdJVleE+d&~KIGT}xK#`b-Gq##$iBzKh?8!60-JR_ zzyA6~e*E^{IG&Hgw>cInMM=whBMuD@hQHzYkcG)#`n}&HVqFJ_jhc2BbxDh3bPs%) z)1l2KS*9R2Zy4cJ;rLJCQrI%sCtgvf7Mg<>A=?r7zce^t?)7JEk%*a=JZq&T;lU;u zw6Q-A8$Cia89mA#E8A8suV5uwRwpgkS1r5Zv`2)>@DNM6M3rID#|0YJZ z!~OW>k3Y%}U%!%0vuyIilGP;-2Q6kr#)YYcec&hHDS8&#x%B015nPMCvZzm@)`IL`l(N^14fjykzOxIh`LYF6GO@JpbD?jaV^a^b| zA-r07vt_}kOS5{ykr9qd&i$M#;`Gc&XIS|1BY1Y=qSyua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qoM6N<$g5{-X#{d8T literal 0 HcmV?d00001 diff --git a/images/autopeering.png b/images/autopeering.png new file mode 100644 index 0000000000000000000000000000000000000000..abbe28a3663f83182813c5eb9dd70c1ef994394a GIT binary patch literal 27513 zcmeEuWmJ`I)aDT>X{AF_q)WPy5CaM677*!{<`5#?N+}J}-Cfe%At`m}=FlPp$-9suSFEikJvACsNXi< zGoT{#NI&S047rg{C{Jei-LX*bq`I58Q}=W0N|Pl-$7y#4KE8l^bur=aof-n6ao*2} zkiVFOn~?`RdKBCV_+{+D11Ypyfug%Vt$9|u;F~XMNHP#e z+HuR}+amEBrnMMkE)_X5u);4HF~SvB5i6)wc&tbg8==|g5Ne)Ys)9KIo)eQho6mTQ z89d-;zvvBaYtqEE<8H(;nys(yZf~5U(I5g55)UDg@7ETsT%XcBzh-?NDE<0A1VY`g zDys3B@83$ydg!fuD zw+JDB;+F*RzlqD?8DeDKgFx_Hr6hH3^jEI-KgffV2L*y5ki_EwekKL{r$`WpG_I@7 zsfpKXSHG_ii0rl+#2cSdqqzq@kn&YL^9gwB^dYLdshC`}d@t9SuMqE%i~w4Qz-ofc z*ZoZ3V@Ueg`QbMz@UevyIT-RMGA->3VKlg|L^Pjg*IULc@I{(X3@rqbjWv*sg*aiH zUy2>$9whO3DmnzmfQtyMfw4)QoB^HSUJDJl#y^K8og(r-pWc)EfYbjTv*0)Xe42g% z&i;F}@FBeN_o#Zv2=0tHO2U9q{~q2}|9wfz1cWv4C_CQ3g2wmd4(sQ&_iyD-&b)S~ zkBfBFR^c`b3U_*mR|T_^o@ML(j|9tgW4*SwsR(2jZd&%m-hIWF`Hf5D*H9qdc;IJx zTLK-w>iNF%u6Wk54{Pbi_owf^K9aGwPv6+5B8Y3QV|Ht5csesv-`+E}o4%f(AO5&` zdyozf!a@KJP(@{q^1^Tecflp;Wtk{8F;|QAXbw{T?o3+3rL%@+tJbv8mAl*b< zxV!!W+J9S=u(F>*B&x4lURhl4Rq`^a?c>q4sCBu{PITB9T;pdE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tpLX+E0RA2%>{{ zzVFbz?-evtt+T`!Jn~8Rj9r#E-tTvN^IW#_OHjLYpGkp2vD~H1mQolyq+%pv@-S&p zHD|jf9Rf+Tjq99UbuqV2a|mVw5N#JC?}FWn=;+wY&_vQh68%4Cxuaez`|?q>a-k4o z^w$fJ@kN)Q!`B3B#m|HyO>Kp2CRP@?6SprH@XWd5cifpO4iGxRykpV)%U QPE18zP5V)?>Z^bL7ZGDwk^lez literal 0 HcmV?d00001 diff --git a/images/building-blocks.png b/images/building-blocks.png new file mode 100644 index 0000000000000000000000000000000000000000..2099b05c261c1975311306d0380df298918cbf0e GIT binary patch literal 29920 zcmZ6y1zeMF7dH+lAqSupd% zg?J!6uli0}vq1DDxUm2}kAnE7GAXD53{8{m(kjg_P8?N4B64_9a43S2~t2f`yD zCMd)sDhgcJwy?GEu>T(^w}bPs@$j^Fb@_K}eEd8@Jc9p@!p6(O?%%7TDkwb%XSj}^ zyqAiu3%@1WLeKi&HeP;iHvhJrz@OKW?5v@=xO$rYub?xboVppNpz2nZnz1+>+zt#p;u zbX+x@kaAX@mKYBQ1$}*p9-7Y*j#l-w5#+bQz(h6q-8B{XT~Q*=YU-9Yo-Rlyq`QZr zlAQ)d&qr0kOIuw;TgegbVyEC_sC_Vme`_H_04RrRqHg^R%W+#Ou33^Bf{9=>)iiefhMa*lFZB0gTu z@(5ue4Vaw{)YlQorzFR(r0uN?x6pS-qt&4T);=gXxQ06lDKD&TBZ%?Uve1X35q8eX zE`E-x?s}?7d#Jy^u&AN1g}=Oxvb6=o8>wKg0YQto>biM3pwt|kkSf+nn$C*ufT_s= zHY6wN19j3A*0`M=K2a}yM*}Y>U9_E$KA)zyi@mLlo)%ol&D)z#P0vHj*WF29NW>Q9 zqhzNis>`R3bcf2j>B60roecTaZ}l9muH+|(uuyVWm4~5hbPYxIfd^QNKx}>aLxBvQoEM#w@>OAsUG9vW^n&nvYY7UtTA;<0 zy!AbFw2*q12oJcOo|u)AudaoIwWa|a4Rl0U-N)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d00001 diff --git a/images/dashboard.png b/images/dashboard.png new file mode 100644 index 0000000000000000000000000000000000000000..c2165951aa52d90f2f21d888a2a5cb86992f54ef GIT binary patch literal 76629 zcmeFYXH=72*e(c)C@SJBDgp`?ihxK7MM}U5QUcN?RK*Y=6zLF}Snw4Dlum%qJ0#K} zl&HLdl!OuzYADhP5NV+Vl8O3$-#I_NnKfr-otZgn&BJ1mXS1`P``P>6d*AnUUHjc5 z18wf(0>|0d*tm5b-Zy4r<8WkSJAC^XC#%F+5N6K$!|rXYeU}Y|zqrV{;eg%&-C<*^ zh&{3Y-j@VZ#K45|NQ!8Pn0?($SSBu%cjn55H@*Pd0ACi zIaPq%WjSS41!Yw^CA+B3t88q{0G<1HOap9}$y~vvv(3ykk7L7E%ECW!9dh99C3sQSc`W^l!0=ZdRFMolm4Z%ZCBJ0>Ys`9}Ko zW!BI6%QIm}05lE|uaj~+PUq|V3T!5Q{)TsLs>*!w{4Vgx?0K`?%>_B=F_yiotLCqB z{8J~*&~G+m{uBsYP-OK48(UVY)J+Lu%ga})UU`qjOTsuf5Y6YGJc*2oGJ5Ohc9!?j zYyv6M-lh9=3OlRz3&(B_NbT&LM1{AuuahA9=W_vr$!;@qzq|BPXC*zhZ8M0#it$$f z1<0XawE^kH5)LorGgPZZufGBycTcADyxi4K>CtldTzKZ!(-Crn;EsU=_D3DTV%^YO zxy!PLe--0WIwbCa_&+D_>MJA#>jkU+dNv!|-PfN_{{C?L??2|Su^s#C5a4$a+m*Za zzXp|!?ehI&-G7Q+9}DOI{prPNm5oDy)SeQHo*+fd9)5J6G9sk?8)pCGb|N+5PvwEc z2=4B)?t|j!{p2>XXHCmQRUtfe@I%^Gyf%`!-wnj;7owh%>F~vhAm6UjP%@2jbdRWA zSifpq{15;AYtW-(NTLf=ArETR#`XbD4`Xcrt!d|47mLMXi}Qo z0~3H(hTOnNOqlahLRhh<@Rv!{FK3(7C)$Unt_XvOhA2k3vE44%?dJZ+(6!|oIJjSA zs9M=uKba6?UU&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RbCP4FZTXSx2^R>_YrCn<_>)G0@ zf8O^QYi-uo+AHV2e)0O2-7n3V*C&&;2KTTk{e7b6b1 z+6Reem}7u+LOJ@nLs%nLV$abe!PrCR46di1fi#1F%1hKCBO`DV97bXfD(xa@VDv!5 z--r6^mnR4R??WuYU?_n^u&&SY%U}L<=Pv;sAZhmh0 zu$Vos2RL*B2YoG>;HnTV0K7Ct57LN22vMhvO+<$o+KOs>@O1xQYha=90=Vk6?3#9c zz3wj1niMc-0@o-TKHF8EUisyp($XpSI`vo?64GlQJqvz$%J?%#4+L;1fKtzabGsiN z+gozD7pc(%6!n`0ZEeF;GaPsaDb3&l3<^XznL2&^&3fYg%Qt_y_F8|*|9$_Q;=dvs z0b&^_O-`17QT8`!W5kxd760#=U$)NwyA^hg159nthSv$)g~wB?*37?Tz~gD z|Cp)IuE$(m3YkHMsbna-VFKy!z(p9!rVqCPjWa=B_C0#A_BF((4RgQj{?Dl7xlXhC R=J~ZCF;7=Nmvv4FO#r5aew_dS literal 0 HcmV?d00001 From 0753dc73122527a8d3705cd81492b8a72d8c1fbe Mon Sep 17 00:00:00 2001 From: Luca Moser Date: Mon, 3 Feb 2020 12:29:19 +0100 Subject: [PATCH 184/184] disable analysis server per default (#217) --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 26d204de9d..eff648254f 100644 --- a/config.json +++ b/config.json @@ -4,7 +4,7 @@ "serverAddress": "ressims.iota.cafe:188" }, "server": { - "port": 9191 + "port": 0 }, "httpServer": { "bindAddress": "0.0.0.0:80"