|
|
@ -9,8 +9,10 @@ import ( |
|
|
|
"harmony-benchmark/log" |
|
|
|
"harmony-benchmark/log" |
|
|
|
"harmony-benchmark/node" |
|
|
|
"harmony-benchmark/node" |
|
|
|
"harmony-benchmark/p2p" |
|
|
|
"harmony-benchmark/p2p" |
|
|
|
|
|
|
|
"harmony-benchmark/utils" |
|
|
|
"math/rand" |
|
|
|
"math/rand" |
|
|
|
"os" |
|
|
|
"os" |
|
|
|
|
|
|
|
"runtime" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
|
"time" |
|
|
|
"time" |
|
|
|
) |
|
|
|
) |
|
|
@ -90,6 +92,16 @@ func attackDetermination(attackedMode int) bool { |
|
|
|
return false |
|
|
|
return false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func logMemUsage(consensus *consensus.Consensus) { |
|
|
|
|
|
|
|
for { |
|
|
|
|
|
|
|
var m runtime.MemStats |
|
|
|
|
|
|
|
runtime.ReadMemStats(&m) |
|
|
|
|
|
|
|
log.Info("Mem Report", "Alloc", utils.BToMb(m.Alloc), "TotalAlloc", utils.BToMb(m.TotalAlloc), |
|
|
|
|
|
|
|
"Sys", utils.BToMb(m.Sys), "NumGC", m.NumGC, "consensus", consensus) |
|
|
|
|
|
|
|
time.Sleep(10 * time.Second) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
func main() { |
|
|
|
ip := flag.String("ip", "127.0.0.1", "IP of the node") |
|
|
|
ip := flag.String("ip", "127.0.0.1", "IP of the node") |
|
|
|
port := flag.String("port", "9000", "port of the node.") |
|
|
|
port := flag.String("port", "9000", "port of the node.") |
|
|
@ -120,6 +132,8 @@ func main() { |
|
|
|
|
|
|
|
|
|
|
|
consensus := consensus.NewConsensus(*ip, *port, shardId, peers, leader) |
|
|
|
consensus := consensus.NewConsensus(*ip, *port, shardId, peers, leader) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
go logMemUsage(&consensus) |
|
|
|
|
|
|
|
|
|
|
|
node := node.NewNode(&consensus) |
|
|
|
node := node.NewNode(&consensus) |
|
|
|
// Set logger to attack model.
|
|
|
|
// Set logger to attack model.
|
|
|
|
attack.GetInstance().SetLogger(consensus.Log) |
|
|
|
attack.GetInstance().SetLogger(consensus.Log) |
|
|
|