From b1fcaa03ae22e429c58cdce7695ddbdaf12a83ef Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Sat, 3 Aug 2019 19:17:46 +0530 Subject: [PATCH] Remove Statistical Package (#3129) --- WORKSPACE | 6 ---- .../sendDepositTx/BUILD.bazel | 2 -- .../sendDepositTx/sendDeposits.go | 36 ------------------- 3 files changed, 44 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index 7aa418645..b57b35575 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -977,12 +977,6 @@ go_repository( importpath = "gopkg.in/natefinch/npipe.v2", ) -go_repository( - name = "org_gonum_v1_gonum", - commit = "70a1e933af10e87000d2ccabdd509b87d8626153", - importpath = "gonum.org/v1/gonum", -) - go_repository( name = "org_golang_x_exp", commit = "438050ddec5e7f808979ed57d041cebbc8e2d8a9", diff --git a/contracts/deposit-contract/sendDepositTx/BUILD.bazel b/contracts/deposit-contract/sendDepositTx/BUILD.bazel index b911ec10e..2550a8760 100644 --- a/contracts/deposit-contract/sendDepositTx/BUILD.bazel +++ b/contracts/deposit-contract/sendDepositTx/BUILD.bazel @@ -19,8 +19,6 @@ go_library( "@com_github_sirupsen_logrus//:go_default_library", "@com_github_urfave_cli//:go_default_library", "@com_github_x_cray_logrus_prefixed_formatter//:go_default_library", - "@org_golang_x_exp//rand:go_default_library", - "@org_gonum_v1_gonum//stat/distuv:go_default_library", ], ) diff --git a/contracts/deposit-contract/sendDepositTx/sendDeposits.go b/contracts/deposit-contract/sendDepositTx/sendDeposits.go index 57fb000b1..d0709bd62 100644 --- a/contracts/deposit-contract/sendDepositTx/sendDeposits.go +++ b/contracts/deposit-contract/sendDepositTx/sendDeposits.go @@ -6,7 +6,6 @@ import ( "encoding/hex" "fmt" "io/ioutil" - "math" "math/big" "os" "time" @@ -24,8 +23,6 @@ import ( "github.com/sirupsen/logrus" "github.com/urfave/cli" prefixed "github.com/x-cray/logrus-prefixed-formatter" - rand2 "golang.org/x/exp/rand" - "gonum.org/v1/gonum/stat/distuv" ) var ( @@ -43,8 +40,6 @@ func main() { var numberOfDeposits int64 var depositAmount int64 var depositDelay int64 - var variableTx bool - var txDeviation int64 var randomKey bool customFormatter := new(prefixed.TextFormatter) @@ -112,17 +107,6 @@ func main() { Usage: "The time delay between sending the deposits to the contract(in seconds)", Destination: &depositDelay, }, - cli.BoolFlag{ - Name: "variableTx", - Usage: "This enables variable transaction latencies to simulate real-world transactions", - Destination: &variableTx, - }, - cli.Int64Flag{ - Name: "txDeviation", - Usage: "The standard deviation between transaction times", - Value: 2, - Destination: &txDeviation, - }, cli.BoolFlag{ Name: "random-key", Usage: "Use a randomly generated keystore key", @@ -183,8 +167,6 @@ func main() { log.Fatal(err) } - statDist := buildStatisticalDist(depositDelay, numberOfDeposits, txDeviation) - validatorKeys := make(map[string]*prysmKeyStore.Key) if randomKey { validatorKey, err := prysmKeyStore.NewKey(rand.Reader) @@ -221,12 +203,6 @@ func main() { "Transaction Hash": fmt.Sprintf("%#x", tx.Hash()), }).Infof("Deposit %d sent to contract address %v for validator with a public key %#x", i, depositContractAddr, validatorKey.PublicKey.Marshal()) - // If flag is enabled make transaction times variable - if variableTx { - time.Sleep(time.Duration(math.Abs(statDist.Rand())) * time.Second) - continue - } - time.Sleep(time.Duration(depositDelay) * time.Second) } } @@ -238,18 +214,6 @@ func main() { } } -func buildStatisticalDist(depositDelay int64, numberOfDeposits int64, txDeviation int64) *distuv.StudentsT { - src := rand2.NewSource(uint64(time.Now().Unix())) - dist := &distuv.StudentsT{ - Mu: float64(depositDelay), - Sigma: float64(txDeviation), - Nu: float64(numberOfDeposits - 1), - Src: src, - } - - return dist -} - func loadTextFromFile(filepath string) string { // #nosec - Inclusion of file via variable is OK for this tool. file, err := os.Open(filepath)