diff --git a/.github/workflows/automated-tests.yml b/.github/workflows/automated-tests.yml index 175bec9545..13b4d5cbc4 100644 --- a/.github/workflows/automated-tests.yml +++ b/.github/workflows/automated-tests.yml @@ -23,7 +23,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v4 with: - go-version: "1.19" # The Go version to download (if necessary) and use. + go-version: "1.20" # The Go version to download (if necessary) and use. # - name: Proto Check # run: make proto-check - name: Unit, integration and difference tests diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ab15d52ae0..ec188dd429 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v4 with: - go-version: "1.19" # The Go version to download (if necessary) and use. + go-version: "1.20" # The Go version to download (if necessary) and use. - name: Test with coverage run: go test -coverpkg=./x/... -coverprofile=coverage.out ./... - name: SonarCloud Scan diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 28eba10b41..11e422b923 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: "1.19" + go-version: "1.20" - uses: actions/checkout@v3 - name: golangci-lint uses: golangci/golangci-lint-action@v3 diff --git a/.github/workflows/manual-e2e.yml b/.github/workflows/manual-e2e.yml index 400e2a81ab..899e4ba230 100644 --- a/.github/workflows/manual-e2e.yml +++ b/.github/workflows/manual-e2e.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: "1.19" + go-version: "1.20" - uses: actions/checkout@v3 - name: Checkout LFS objects @@ -20,7 +20,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v4 with: - go-version: "1.19" # The Go version to download (if necessary) and use. + go-version: "1.20" # The Go version to download (if necessary) and use. - name: E2E tests run: make test-e2e diff --git a/.github/workflows/nightly-e2e.yml b/.github/workflows/nightly-e2e.yml index 0fe0e48d81..f69125e6b8 100644 --- a/.github/workflows/nightly-e2e.yml +++ b/.github/workflows/nightly-e2e.yml @@ -24,7 +24,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: "1.19" + go-version: "1.20" - uses: actions/checkout@v3 diff --git a/README.md b/README.md index df86648ea4..bb6da8be76 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,8 @@ For more details on the Replicated Security protocol, take a look at the [docs]( ```bash ## For OSX or Linux -# go 1.18 (https://formulae.brew.sh/formula/go) -brew install go@1.19 +# go 1.20 (https://formulae.brew.sh/formula/go) +brew install go@1.20 # jq (optional, for testnet) (https://formulae.brew.sh/formula/jq) brew install jq # docker (optional, for integration tests, testnet) (https://docs.docker.com/get-docker/) diff --git a/x/ccv/provider/keeper/key_assignment_test.go b/x/ccv/provider/keeper/key_assignment_test.go index c06099ca60..49ef8698cb 100644 --- a/x/ccv/provider/keeper/key_assignment_test.go +++ b/x/ccv/provider/keeper/key_assignment_test.go @@ -47,7 +47,9 @@ func TestGetAllValidatorConsumerPubKey(t *testing.T) { pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - rand.Seed(time.Now().Unix()) + seed := time.Now().UnixNano() + rng := rand.New(rand.NewSource(seed)) + chainIDs := []string{"consumer-1", "consumer-2", "consumer-3"} numAssignments := 10 testAssignments := []types.ValidatorConsumerPubKey{} @@ -56,7 +58,7 @@ func TestGetAllValidatorConsumerPubKey(t *testing.T) { providerAddr := cryptotestutil.NewCryptoIdentityFromIntSeed(numAssignments + i).ProviderConsAddress() testAssignments = append(testAssignments, types.ValidatorConsumerPubKey{ - ChainId: chainIDs[rand.Intn(len(chainIDs))], + ChainId: chainIDs[rng.Intn(len(chainIDs))], ProviderAddr: providerAddr.ToSdkConsAddr(), ConsumerKey: &consumerKey, }, @@ -125,7 +127,9 @@ func TestGetAllValidatorsByConsumerAddr(t *testing.T) { pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - rand.Seed(time.Now().Unix()) + seed := time.Now().UnixNano() + rng := rand.New(rand.NewSource(seed)) + chainIDs := []string{"consumer-1", "consumer-2", "consumer-3"} numAssignments := 10 testAssignments := []types.ValidatorByConsumerAddr{} @@ -134,7 +138,7 @@ func TestGetAllValidatorsByConsumerAddr(t *testing.T) { providerAddr := cryptotestutil.NewCryptoIdentityFromIntSeed(numAssignments + i).ProviderConsAddress() testAssignments = append(testAssignments, types.ValidatorByConsumerAddr{ - ChainId: chainIDs[rand.Intn(len(chainIDs))], + ChainId: chainIDs[rng.Intn(len(chainIDs))], ConsumerAddr: consumerAddr.ToSdkConsAddr(), ProviderAddr: providerAddr.ToSdkConsAddr(), }, @@ -205,7 +209,9 @@ func TestGetAllKeyAssignmentReplacements(t *testing.T) { chainID := "consumer-1" - rand.Seed(time.Now().Unix()) + seed := time.Now().UnixNano() + rng := rand.New(rand.NewSource(seed)) + numAssignments := 10 testAssignments := []types.KeyAssignmentReplacement{} for i := 0; i < numAssignments; i++ { @@ -215,7 +221,7 @@ func TestGetAllKeyAssignmentReplacements(t *testing.T) { types.KeyAssignmentReplacement{ ProviderAddr: providerAddr.ToSdkConsAddr(), PrevCKey: &consumerKey, - Power: rand.Int63(), + Power: rng.Int63(), }, ) } @@ -264,7 +270,9 @@ func TestGetAllConsumerAddrsToPrune(t *testing.T) { pk, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - rand.Seed(time.Now().Unix()) + seed := time.Now().UnixNano() + rng := rand.New(rand.NewSource(seed)) + chainIDs := []string{"consumer-1", "consumer-2", "consumer-3"} numAssignments := 10 testAssignments := []types.ConsumerAddrsToPrune{} @@ -276,8 +284,8 @@ func TestGetAllConsumerAddrsToPrune(t *testing.T) { } testAssignments = append(testAssignments, types.ConsumerAddrsToPrune{ - ChainId: chainIDs[rand.Intn(len(chainIDs))], - VscId: rand.Uint64(), + ChainId: chainIDs[rng.Intn(len(chainIDs))], + VscId: rng.Uint64(), ConsumerAddrs: &consumerAddresses, }, ) @@ -705,14 +713,17 @@ func TestSimulatedAssignmentsAndUpdateApplication(t *testing.T) { assignableIDS = append(assignableIDS, cryptotestutil.NewCryptoIdentityFromIntSeed(i)) } + seed := time.Now().UnixNano() + rng := rand.New(rand.NewSource(seed)) + // Helper: simulates creation of staking module EndBlock updates. getStakingUpdates := func() (ret []abci.ValidatorUpdate) { // Get a random set of validators to update. It is important to test subsets of all validators. - validators := rand.Perm(len(providerIDS))[0:rand.Intn(len(providerIDS)+1)] + validators := rng.Perm(len(providerIDS))[0:rng.Intn(len(providerIDS)+1)] for _, i := range validators { // Power 0, 1, or 2 represents // deletion, update (from 0 or 2), update (from 0 or 1) - power := rand.Intn(3) + power := rng.Intn(3) ret = append(ret, abci.ValidatorUpdate{ PubKey: providerIDS[i].TMProtoCryptoPublicKey(), Power: int64(power), @@ -723,9 +734,9 @@ func TestSimulatedAssignmentsAndUpdateApplication(t *testing.T) { // Helper: simulates creation of assignment tx's to be done. getAssignments := func() (ret []Assignment) { - for i, numAssignments := 0, rand.Intn(NUM_ASSIGNMENTS_PER_BLOCK_MAX); i < numAssignments; i++ { - randomIxP := rand.Intn(len(providerIDS)) - randomIxC := rand.Intn(len(assignableIDS)) + for i, numAssignments := 0, rng.Intn(NUM_ASSIGNMENTS_PER_BLOCK_MAX); i < numAssignments; i++ { + randomIxP := rng.Intn(len(providerIDS)) + randomIxC := rng.Intn(len(assignableIDS)) ret = append(ret, Assignment{ val: providerIDS[randomIxP].SDKStakingValidator(), ck: assignableIDS[randomIxC].TMProtoCryptoPublicKey(), @@ -832,7 +843,7 @@ func TestSimulatedAssignmentsAndUpdateApplication(t *testing.T) { // delivery of maturity packets from the consumer chain. prunedVscid := greatestPrunedVSCID + // +1 and -1 because id was incremented (-1), (+1) to make upper bound inclusive - rand.Intn(int(k.GetValidatorSetUpdateId(ctx))+1-1-greatestPrunedVSCID) + rng.Intn(int(k.GetValidatorSetUpdateId(ctx))+1-1-greatestPrunedVSCID) k.PruneKeyAssignments(ctx, CHAINID, uint64(prunedVscid)) greatestPrunedVSCID = prunedVscid diff --git a/x/ccv/provider/keeper/throttle_test.go b/x/ccv/provider/keeper/throttle_test.go index 7cd39a8382..f923c53e98 100644 --- a/x/ccv/provider/keeper/throttle_test.go +++ b/x/ccv/provider/keeper/throttle_test.go @@ -784,8 +784,9 @@ func TestGlobalSlashEntryDeletion(t *testing.T) { // Instantiate shuffled copy of above slice shuffledEntries := append([]providertypes.GlobalSlashEntry{}, entries...) - rand.Seed(now.UnixNano()) - rand.Shuffle(len(shuffledEntries), func(i, j int) { + seed := time.Now().UnixNano() + rng := rand.New(rand.NewSource(seed)) + rng.Shuffle(len(shuffledEntries), func(i, j int) { shuffledEntries[i], shuffledEntries[j] = shuffledEntries[j], shuffledEntries[i] }) @@ -1192,7 +1193,8 @@ func TestPanicIfTooMuchThrottledPacketData(t *testing.T) { defaultParams.MaxThrottledPackets = tc.max providerKeeper.SetParams(ctx, defaultParams) - rand.Seed(time.Now().UnixNano()) + seed := time.Now().UnixNano() + rng := rand.New(rand.NewSource(seed)) // Queuing up a couple data instances for another chain shouldn't matter err := providerKeeper.QueueThrottledPacketData(ctx, "chain-17", 0, testkeeper.GetNewSlashPacketData()) @@ -1203,7 +1205,7 @@ func TestPanicIfTooMuchThrottledPacketData(t *testing.T) { // Queue packet data instances until we reach the max (some slash packets, some VSC matured packets) reachedMax := false for i := 0; i < int(tc.max); i++ { - randBool := rand.Intn(2) == 0 + randBool := rng.Intn(2) == 0 var data interface{} if randBool { data = testkeeper.GetNewSlashPacketData()