diff --git a/packages/transactionspammer/transactionspammer.go b/packages/transactionspammer/transactionspammer.go index e9fd616c3c31d932f229c88c771a4d41041b215c..00866b8ab9d8e72e451d0b236452ee4603f1b5fd 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 6fda90857c431e4dfc41cf8f69b453b05ddb61d1..93ea4dcdcf66528743c3c8fd17c55cd2ecef6388 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 00598e5fc4d7be1f7ace2b8a73c15952325cf6bb..1f58e107f132c1449c6a8db8744b265686d6ce04 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 3cfadd2416c3af6bce48797069c374cba6746f3d..5bf6cfca6e3b40a2d30b44bbe7f0c50da67ad96b 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 b9c0acf5a9ca4d9a84ccc4a291ea978de1222b44..3cc90ba43176512d4db1aa835bb180b921d35844 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 6e7b19912cff4b8197d599dad358241b026a773e..addd5ee1130f26847fd0058dce105079905c59ad 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 9062eda476bf5b79ad16bec8d3cc7ddfd6fc217b..692e5ccdccb943fba5271dbdaf1e03f5368095b4 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()