From d53fdcf7811b27463065e47c60b11edb46f95df2 Mon Sep 17 00:00:00 2001 From: Victor Farazdagi Date: Mon, 1 Feb 2021 07:14:36 -0800 Subject: [PATCH] Simplify expressions (#8370) * Simplify expressions * avoid escaping Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> --- beacon-chain/core/epoch/precompute/reward_penalty_test.go | 2 +- beacon-chain/core/helpers/slot_epoch.go | 2 +- beacon-chain/powchain/log_processing.go | 4 ++-- beacon-chain/rpc/validator/attester_test.go | 2 +- shared/params/loader.go | 2 +- validator/accounts/accounts_import.go | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/beacon-chain/core/epoch/precompute/reward_penalty_test.go b/beacon-chain/core/epoch/precompute/reward_penalty_test.go index cf90206783..31e265f129 100644 --- a/beacon-chain/core/epoch/precompute/reward_penalty_test.go +++ b/beacon-chain/core/epoch/precompute/reward_penalty_test.go @@ -91,7 +91,7 @@ func TestAttestationDeltaPrecompute(t *testing.T) { // Add some variances to target and head balances. // See: https://github.com/prysmaticlabs/prysm/issues/5593 - bp.PrevEpochTargetAttested = bp.PrevEpochTargetAttested / 2 + bp.PrevEpochTargetAttested /= 2 bp.PrevEpochHeadAttested = bp.PrevEpochHeadAttested * 2 / 3 rewards, penalties, err := AttestationsDelta(beaconState, bp, vp) require.NoError(t, err) diff --git a/beacon-chain/core/helpers/slot_epoch.go b/beacon-chain/core/helpers/slot_epoch.go index 9b8dfe94cb..a02000419d 100644 --- a/beacon-chain/core/helpers/slot_epoch.go +++ b/beacon-chain/core/helpers/slot_epoch.go @@ -213,7 +213,7 @@ func WeakSubjectivityCheckptEpoch(valCount uint64) (uint64, error) { if err != nil { return 0, err } - v = v / (2 * 100 * m) + v /= 2 * 100 * m wsp += v } return wsp, nil diff --git a/beacon-chain/powchain/log_processing.go b/beacon-chain/powchain/log_processing.go index b71a8af12d..7757f59b28 100644 --- a/beacon-chain/powchain/log_processing.go +++ b/beacon-chain/powchain/log_processing.go @@ -318,7 +318,7 @@ func (s *Service) processPastLogs(ctx context.Context) error { } // multiplicative decrease - batchSize = batchSize / multiplicativeDecreaseDivisor + batchSize /= multiplicativeDecreaseDivisor continue } return err @@ -351,7 +351,7 @@ func (s *Service) processPastLogs(ctx context.Context) error { if batchSize < s.eth1HeaderReqLimit { // update the batchSize with additive increase - batchSize = batchSize + additiveFactor + batchSize += additiveFactor if batchSize > s.eth1HeaderReqLimit { batchSize = s.eth1HeaderReqLimit } diff --git a/beacon-chain/rpc/validator/attester_test.go b/beacon-chain/rpc/validator/attester_test.go index 0041558204..ce2e30dfa5 100644 --- a/beacon-chain/rpc/validator/attester_test.go +++ b/beacon-chain/rpc/validator/attester_test.go @@ -208,7 +208,7 @@ func TestAttestationDataAtSlot_HandlesFarAwayJustifiedEpoch(t *testing.T) { justifiedBlock := testutil.NewBeaconBlock() justifiedBlock.Block.Slot, err = helpers.StartSlot(helpers.SlotToEpoch(1500)) require.NoError(t, err) - justifiedBlock.Block.Slot = justifiedBlock.Block.Slot - 2 // Imagine two skip block + justifiedBlock.Block.Slot -= 2 // Imagine two skip block blockRoot, err := block.Block.HashTreeRoot() require.NoError(t, err, "Could not hash beacon block") justifiedBlockRoot, err := justifiedBlock.Block.HashTreeRoot() diff --git a/shared/params/loader.go b/shared/params/loader.go index 707ca6ec5b..cf4e987b89 100644 --- a/shared/params/loader.go +++ b/shared/params/loader.go @@ -51,7 +51,7 @@ func replaceHexStringWithYAMLFormat(line string) []string { if err != nil { log.WithError(err).Error("Failed to marshal config file.") } - parts[0] = parts[0] + string(fixedByte) + parts[0] += string(fixedByte) parts = parts[:1] case l > 1 && l <= 4: var arr [4]byte diff --git a/validator/accounts/accounts_import.go b/validator/accounts/accounts_import.go index 24bc2314a9..3b27396571 100644 --- a/validator/accounts/accounts_import.go +++ b/validator/accounts/accounts_import.go @@ -27,7 +27,7 @@ import ( keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4" ) -var derivationPathRegex = regexp.MustCompile("m_12381_3600_([0-9]+)_([0-9]+)_([0-9]+)") +var derivationPathRegex = regexp.MustCompile(`m_12381_3600_(\d+)_(\d+)_(\d+)`) // byDerivationPath implements sort.Interface based on a // derivation path present in a keystore filename, if any. This