mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Move Shared Packages into Math/ and IO/ (#9622)
* amend * building * build * userprompt * imports * build val * gaz * io file Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
d2f74615ab
commit
7dadc780b8
2
beacon-chain/cache/BUILD.bazel
vendored
2
beacon-chain/cache/BUILD.bazel
vendored
@ -44,9 +44,9 @@ go_library(
|
|||||||
"//container/slice:go_default_library",
|
"//container/slice:go_default_library",
|
||||||
"//crypto/hash:go_default_library",
|
"//crypto/hash:go_default_library",
|
||||||
"//crypto/rand:go_default_library",
|
"//crypto/rand:go_default_library",
|
||||||
|
"//math:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/mathutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"@com_github_hashicorp_golang_lru//:go_default_library",
|
"@com_github_hashicorp_golang_lru//:go_default_library",
|
||||||
"@com_github_patrickmn_go_cache//:go_default_library",
|
"@com_github_patrickmn_go_cache//:go_default_library",
|
||||||
|
4
beacon-chain/cache/committee.go
vendored
4
beacon-chain/cache/committee.go
vendored
@ -12,7 +12,7 @@ import (
|
|||||||
types "github.com/prysmaticlabs/eth2-types"
|
types "github.com/prysmaticlabs/eth2-types"
|
||||||
lruwrpr "github.com/prysmaticlabs/prysm/cache/lru"
|
lruwrpr "github.com/prysmaticlabs/prysm/cache/lru"
|
||||||
"github.com/prysmaticlabs/prysm/container/slice"
|
"github.com/prysmaticlabs/prysm/container/slice"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ func (c *CommitteeCache) Committee(slot types.Slot, seed [32]byte, index types.C
|
|||||||
committeeCountPerSlot = item.CommitteeCount / uint64(params.BeaconConfig().SlotsPerEpoch)
|
committeeCountPerSlot = item.CommitteeCount / uint64(params.BeaconConfig().SlotsPerEpoch)
|
||||||
}
|
}
|
||||||
|
|
||||||
indexOffSet, err := mathutil.Add64(uint64(index), uint64(slot.ModSlot(params.BeaconConfig().SlotsPerEpoch).Mul(committeeCountPerSlot)))
|
indexOffSet, err := math.Add64(uint64(index), uint64(slot.ModSlot(params.BeaconConfig().SlotsPerEpoch).Mul(committeeCountPerSlot)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,11 @@ go_library(
|
|||||||
"//beacon-chain/state/v2:go_default_library",
|
"//beacon-chain/state/v2:go_default_library",
|
||||||
"//crypto/bls:go_default_library",
|
"//crypto/bls:go_default_library",
|
||||||
"//crypto/hash:go_default_library",
|
"//crypto/hash:go_default_library",
|
||||||
|
"//math:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//proto/prysm/v1alpha1/block:go_default_library",
|
"//proto/prysm/v1alpha1/block:go_default_library",
|
||||||
"//shared/attestationutil:go_default_library",
|
"//shared/attestationutil:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/mathutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"@com_github_pkg_errors//:go_default_library",
|
"@com_github_pkg_errors//:go_default_library",
|
||||||
"@com_github_prysmaticlabs_eth2_types//:go_default_library",
|
"@com_github_prysmaticlabs_eth2_types//:go_default_library",
|
||||||
@ -68,11 +68,11 @@ go_test(
|
|||||||
"//beacon-chain/state/v2:go_default_library",
|
"//beacon-chain/state/v2:go_default_library",
|
||||||
"//container/trie:go_default_library",
|
"//container/trie:go_default_library",
|
||||||
"//crypto/bls:go_default_library",
|
"//crypto/bls:go_default_library",
|
||||||
|
"//math:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//proto/prysm/v1alpha1/wrapper:go_default_library",
|
"//proto/prysm/v1alpha1/wrapper:go_default_library",
|
||||||
"//shared/attestationutil:go_default_library",
|
"//shared/attestationutil:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/mathutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"//shared/testutil:go_default_library",
|
"//shared/testutil:go_default_library",
|
||||||
"//shared/testutil/assert:go_default_library",
|
"//shared/testutil/assert:go_default_library",
|
||||||
|
@ -14,10 +14,10 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||||
stateAltair "github.com/prysmaticlabs/prysm/beacon-chain/state/v2"
|
stateAltair "github.com/prysmaticlabs/prysm/beacon-chain/state/v2"
|
||||||
"github.com/prysmaticlabs/prysm/crypto/bls"
|
"github.com/prysmaticlabs/prysm/crypto/bls"
|
||||||
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||||
@ -631,7 +631,7 @@ func TestAttestationParticipationFlagIndices(t *testing.T) {
|
|||||||
Source: ðpb.Checkpoint{Root: params.BeaconConfig().ZeroHash[:]},
|
Source: ðpb.Checkpoint{Root: params.BeaconConfig().ZeroHash[:]},
|
||||||
Target: ðpb.Checkpoint{},
|
Target: ðpb.Checkpoint{},
|
||||||
},
|
},
|
||||||
inputDelay: types.Slot(mathutil.IntegerSquareRoot(uint64(cfg.SlotsPerEpoch)) - 1),
|
inputDelay: types.Slot(math.IntegerSquareRoot(uint64(cfg.SlotsPerEpoch)) - 1),
|
||||||
participationIndices: map[uint8]bool{
|
participationIndices: map[uint8]bool{
|
||||||
sourceFlagIndex: true,
|
sourceFlagIndex: true,
|
||||||
},
|
},
|
||||||
@ -645,7 +645,7 @@ func TestAttestationParticipationFlagIndices(t *testing.T) {
|
|||||||
Source: ðpb.Checkpoint{Root: params.BeaconConfig().ZeroHash[:]},
|
Source: ðpb.Checkpoint{Root: params.BeaconConfig().ZeroHash[:]},
|
||||||
Target: ðpb.Checkpoint{Root: params.BeaconConfig().ZeroHash[:]},
|
Target: ðpb.Checkpoint{Root: params.BeaconConfig().ZeroHash[:]},
|
||||||
},
|
},
|
||||||
inputDelay: types.Slot(mathutil.IntegerSquareRoot(uint64(cfg.SlotsPerEpoch)) - 1),
|
inputDelay: types.Slot(math.IntegerSquareRoot(uint64(cfg.SlotsPerEpoch)) - 1),
|
||||||
participationIndices: map[uint8]bool{
|
participationIndices: map[uint8]bool{
|
||||||
sourceFlagIndex: true,
|
sourceFlagIndex: true,
|
||||||
targetFlagIndex: true,
|
targetFlagIndex: true,
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
"go.opencensus.io/trace"
|
"go.opencensus.io/trace"
|
||||||
)
|
)
|
||||||
@ -228,7 +228,7 @@ func AttestationsDelta(state state.BeaconStateAltair, bal *precompute.Balance, v
|
|||||||
cfg := params.BeaconConfig()
|
cfg := params.BeaconConfig()
|
||||||
increment := cfg.EffectiveBalanceIncrement
|
increment := cfg.EffectiveBalanceIncrement
|
||||||
factor := cfg.BaseRewardFactor
|
factor := cfg.BaseRewardFactor
|
||||||
baseRewardMultiplier := increment * factor / mathutil.IntegerSquareRoot(bal.ActiveCurrentEpoch)
|
baseRewardMultiplier := increment * factor / math.IntegerSquareRoot(bal.ActiveCurrentEpoch)
|
||||||
leak := helpers.IsInInactivityLeak(prevEpoch, finalizedEpoch)
|
leak := helpers.IsInInactivityLeak(prevEpoch, finalizedEpoch)
|
||||||
inactivityDenominator := cfg.InactivityScoreBias * cfg.InactivityPenaltyQuotientAltair
|
inactivityDenominator := cfg.InactivityScoreBias * cfg.InactivityPenaltyQuotientAltair
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
types "github.com/prysmaticlabs/eth2-types"
|
types "github.com/prysmaticlabs/eth2-types"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -56,5 +56,5 @@ func BaseRewardPerIncrement(activeBalance uint64) (uint64, error) {
|
|||||||
return 0, errors.New("active balance can't be 0")
|
return 0, errors.New("active balance can't be 0")
|
||||||
}
|
}
|
||||||
cfg := params.BeaconConfig()
|
cfg := params.BeaconConfig()
|
||||||
return cfg.EffectiveBalanceIncrement * cfg.BaseRewardFactor / mathutil.IntegerSquareRoot(activeBalance), nil
|
return cfg.EffectiveBalanceIncrement * cfg.BaseRewardFactor / math.IntegerSquareRoot(activeBalance), nil
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,9 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||||
"github.com/prysmaticlabs/prysm/crypto/bls"
|
"github.com/prysmaticlabs/prysm/crypto/bls"
|
||||||
"github.com/prysmaticlabs/prysm/crypto/hash"
|
"github.com/prysmaticlabs/prysm/crypto/hash"
|
||||||
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ func IsSyncCommitteeAggregator(sig []byte) (bool, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cfg := params.BeaconConfig()
|
cfg := params.BeaconConfig()
|
||||||
modulo := mathutil.Max(1, cfg.SyncCommitteeSize/cfg.SyncCommitteeSubnetCount/cfg.TargetAggregatorsPerSyncSubcommittee)
|
modulo := math.Max(1, cfg.SyncCommitteeSize/cfg.SyncCommitteeSubnetCount/cfg.TargetAggregatorsPerSyncSubcommittee)
|
||||||
hashedSig := hash.Hash(sig)
|
hashedSig := hash.Hash(sig)
|
||||||
return bytesutil.FromBytes8(hashedSig[:8])%modulo == 0, nil
|
return bytesutil.FromBytes8(hashedSig[:8])%modulo == 0, nil
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ go_library(
|
|||||||
"//container/trie:go_default_library",
|
"//container/trie:go_default_library",
|
||||||
"//crypto/bls:go_default_library",
|
"//crypto/bls:go_default_library",
|
||||||
"//crypto/hash:go_default_library",
|
"//crypto/hash:go_default_library",
|
||||||
|
"//math:go_default_library",
|
||||||
"//network/forks:go_default_library",
|
"//network/forks:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//proto/prysm/v1alpha1/block:go_default_library",
|
"//proto/prysm/v1alpha1/block:go_default_library",
|
||||||
@ -39,7 +40,6 @@ go_library(
|
|||||||
"//shared/attestationutil:go_default_library",
|
"//shared/attestationutil:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/depositutil:go_default_library",
|
"//shared/depositutil:go_default_library",
|
||||||
"//shared/mathutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"//shared/slashutil:go_default_library",
|
"//shared/slashutil:go_default_library",
|
||||||
"@com_github_pkg_errors//:go_default_library",
|
"@com_github_pkg_errors//:go_default_library",
|
||||||
|
@ -9,10 +9,10 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||||
"github.com/prysmaticlabs/prysm/container/trie"
|
"github.com/prysmaticlabs/prysm/container/trie"
|
||||||
"github.com/prysmaticlabs/prysm/crypto/bls"
|
"github.com/prysmaticlabs/prysm/crypto/bls"
|
||||||
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/shared/depositutil"
|
"github.com/prysmaticlabs/prysm/shared/depositutil"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ func ActivateValidatorWithEffectiveBalance(beaconState state.BeaconState, deposi
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
validator.EffectiveBalance = mathutil.Min(balance-balance%params.BeaconConfig().EffectiveBalanceIncrement, params.BeaconConfig().MaxEffectiveBalance)
|
validator.EffectiveBalance = math.Min(balance-balance%params.BeaconConfig().EffectiveBalanceIncrement, params.BeaconConfig().MaxEffectiveBalance)
|
||||||
if validator.EffectiveBalance ==
|
if validator.EffectiveBalance ==
|
||||||
params.BeaconConfig().MaxEffectiveBalance {
|
params.BeaconConfig().MaxEffectiveBalance {
|
||||||
validator.ActivationEligibilityEpoch = 0
|
validator.ActivationEligibilityEpoch = 0
|
||||||
|
@ -14,9 +14,9 @@ go_library(
|
|||||||
"//beacon-chain/core/validators:go_default_library",
|
"//beacon-chain/core/validators:go_default_library",
|
||||||
"//beacon-chain/state:go_default_library",
|
"//beacon-chain/state:go_default_library",
|
||||||
"//config/features:go_default_library",
|
"//config/features:go_default_library",
|
||||||
|
"//math:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//shared/attestationutil:go_default_library",
|
"//shared/attestationutil:go_default_library",
|
||||||
"//shared/mathutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"@com_github_pkg_errors//:go_default_library",
|
"@com_github_pkg_errors//:go_default_library",
|
||||||
"@com_github_prysmaticlabs_eth2_types//:go_default_library",
|
"@com_github_prysmaticlabs_eth2_types//:go_default_library",
|
||||||
|
@ -15,9 +15,9 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/validators"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/validators"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||||
"github.com/prysmaticlabs/prysm/config/features"
|
"github.com/prysmaticlabs/prysm/config/features"
|
||||||
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
"github.com/prysmaticlabs/prysm/shared/attestationutil"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ func ProcessSlashings(state state.BeaconState, slashingMultiplier uint64) (state
|
|||||||
// a callback is used here to apply the following actions to all validators
|
// a callback is used here to apply the following actions to all validators
|
||||||
// below equally.
|
// below equally.
|
||||||
increment := params.BeaconConfig().EffectiveBalanceIncrement
|
increment := params.BeaconConfig().EffectiveBalanceIncrement
|
||||||
minSlashing := mathutil.Min(totalSlashing*slashingMultiplier, totalBalance)
|
minSlashing := math.Min(totalSlashing*slashingMultiplier, totalBalance)
|
||||||
err = state.ApplyToEveryValidator(func(idx int, val *ethpb.Validator) (bool, *ethpb.Validator, error) {
|
err = state.ApplyToEveryValidator(func(idx int, val *ethpb.Validator) (bool, *ethpb.Validator, error) {
|
||||||
correctEpoch := (currentEpoch + exitLength/2) == val.WithdrawableEpoch
|
correctEpoch := (currentEpoch + exitLength/2) == val.WithdrawableEpoch
|
||||||
if val.Slashed && correctEpoch {
|
if val.Slashed && correctEpoch {
|
||||||
|
@ -19,10 +19,10 @@ go_library(
|
|||||||
"//beacon-chain/core:go_default_library",
|
"//beacon-chain/core:go_default_library",
|
||||||
"//beacon-chain/core/helpers:go_default_library",
|
"//beacon-chain/core/helpers:go_default_library",
|
||||||
"//beacon-chain/state:go_default_library",
|
"//beacon-chain/state:go_default_library",
|
||||||
|
"//math:go_default_library",
|
||||||
"//monitoring/tracing:go_default_library",
|
"//monitoring/tracing:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//shared/attestationutil:go_default_library",
|
"//shared/attestationutil:go_default_library",
|
||||||
"//shared/mathutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"@com_github_pkg_errors//:go_default_library",
|
"@com_github_pkg_errors//:go_default_library",
|
||||||
"@com_github_prysmaticlabs_eth2_types//:go_default_library",
|
"@com_github_prysmaticlabs_eth2_types//:go_default_library",
|
||||||
@ -46,9 +46,9 @@ go_test(
|
|||||||
"//beacon-chain/core/helpers:go_default_library",
|
"//beacon-chain/core/helpers:go_default_library",
|
||||||
"//beacon-chain/state:go_default_library",
|
"//beacon-chain/state:go_default_library",
|
||||||
"//beacon-chain/state/v1:go_default_library",
|
"//beacon-chain/state/v1:go_default_library",
|
||||||
|
"//math:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//shared/attestationutil:go_default_library",
|
"//shared/attestationutil:go_default_library",
|
||||||
"//shared/mathutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"//shared/testutil:go_default_library",
|
"//shared/testutil:go_default_library",
|
||||||
"//shared/testutil/assert:go_default_library",
|
"//shared/testutil/assert:go_default_library",
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ func AttestationsDelta(state state.ReadOnlyBeaconState, pBal *Balance, vp []*Val
|
|||||||
prevEpoch := core.PrevEpoch(state)
|
prevEpoch := core.PrevEpoch(state)
|
||||||
finalizedEpoch := state.FinalizedCheckpointEpoch()
|
finalizedEpoch := state.FinalizedCheckpointEpoch()
|
||||||
|
|
||||||
sqrtActiveCurrentEpoch := mathutil.IntegerSquareRoot(pBal.ActiveCurrentEpoch)
|
sqrtActiveCurrentEpoch := math.IntegerSquareRoot(pBal.ActiveCurrentEpoch)
|
||||||
for i, v := range vp {
|
for i, v := range vp {
|
||||||
rewards[i], penalties[i] = attestationDelta(pBal, sqrtActiveCurrentEpoch, v, prevEpoch, finalizedEpoch)
|
rewards[i], penalties[i] = attestationDelta(pBal, sqrtActiveCurrentEpoch, v, prevEpoch, finalizedEpoch)
|
||||||
}
|
}
|
||||||
@ -158,7 +158,7 @@ func ProposersDelta(state state.ReadOnlyBeaconState, pBal *Balance, vp []*Valida
|
|||||||
rewards := make([]uint64, numofVals)
|
rewards := make([]uint64, numofVals)
|
||||||
|
|
||||||
totalBalance := pBal.ActiveCurrentEpoch
|
totalBalance := pBal.ActiveCurrentEpoch
|
||||||
balanceSqrt := mathutil.IntegerSquareRoot(totalBalance)
|
balanceSqrt := math.IntegerSquareRoot(totalBalance)
|
||||||
// Balance square root cannot be 0, this prevents division by 0.
|
// Balance square root cannot be 0, this prevents division by 0.
|
||||||
if balanceSqrt == 0 {
|
if balanceSqrt == 0 {
|
||||||
balanceSqrt = 1
|
balanceSqrt = 1
|
||||||
|
@ -12,8 +12,8 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||||
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||||
@ -314,7 +314,7 @@ func TestProposerDeltaPrecompute_HappyCase(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
baseReward := v[0].CurrentEpochEffectiveBalance * params.BeaconConfig().BaseRewardFactor /
|
baseReward := v[0].CurrentEpochEffectiveBalance * params.BeaconConfig().BaseRewardFactor /
|
||||||
mathutil.IntegerSquareRoot(b.ActiveCurrentEpoch) / params.BeaconConfig().BaseRewardsPerEpoch
|
math.IntegerSquareRoot(b.ActiveCurrentEpoch) / params.BeaconConfig().BaseRewardsPerEpoch
|
||||||
proposerReward := baseReward / params.BeaconConfig().ProposerRewardQuotient
|
proposerReward := baseReward / params.BeaconConfig().ProposerRewardQuotient
|
||||||
|
|
||||||
assert.Equal(t, proposerReward, r[proposerIndex], "Unexpected proposer reward")
|
assert.Equal(t, proposerReward, r[proposerIndex], "Unexpected proposer reward")
|
||||||
@ -372,6 +372,6 @@ func baseReward(state state.ReadOnlyBeaconState, index types.ValidatorIndex) (ui
|
|||||||
}
|
}
|
||||||
effectiveBalance := val.EffectiveBalance()
|
effectiveBalance := val.EffectiveBalance()
|
||||||
baseReward := effectiveBalance * params.BeaconConfig().BaseRewardFactor /
|
baseReward := effectiveBalance * params.BeaconConfig().BaseRewardFactor /
|
||||||
mathutil.IntegerSquareRoot(totalBalance) / params.BeaconConfig().BaseRewardsPerEpoch
|
math.IntegerSquareRoot(totalBalance) / params.BeaconConfig().BaseRewardsPerEpoch
|
||||||
return baseReward, nil
|
return baseReward, nil
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||||
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ func ProcessSlashingsPrecompute(s state.BeaconState, pBal *Balance) error {
|
|||||||
totalSlashing += slashing
|
totalSlashing += slashing
|
||||||
}
|
}
|
||||||
|
|
||||||
minSlashing := mathutil.Min(totalSlashing*params.BeaconConfig().ProportionalSlashingMultiplier, pBal.ActiveCurrentEpoch)
|
minSlashing := math.Min(totalSlashing*params.BeaconConfig().ProportionalSlashingMultiplier, pBal.ActiveCurrentEpoch)
|
||||||
epochToWithdraw := currentEpoch + exitLength/2
|
epochToWithdraw := currentEpoch + exitLength/2
|
||||||
|
|
||||||
var hasSlashing bool
|
var hasSlashing bool
|
||||||
|
@ -41,10 +41,10 @@ go_library(
|
|||||||
"//container/trie:go_default_library",
|
"//container/trie:go_default_library",
|
||||||
"//crypto/bls:go_default_library",
|
"//crypto/bls:go_default_library",
|
||||||
"//crypto/hash:go_default_library",
|
"//crypto/hash:go_default_library",
|
||||||
|
"//math:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//proto/prysm/v1alpha1/block:go_default_library",
|
"//proto/prysm/v1alpha1/block:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/mathutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"//time:go_default_library",
|
"//time:go_default_library",
|
||||||
"@com_github_ferranbt_fastssz//:go_default_library",
|
"@com_github_ferranbt_fastssz//:go_default_library",
|
||||||
|
@ -15,9 +15,9 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||||
"github.com/prysmaticlabs/prysm/container/slice"
|
"github.com/prysmaticlabs/prysm/container/slice"
|
||||||
"github.com/prysmaticlabs/prysm/crypto/hash"
|
"github.com/prysmaticlabs/prysm/crypto/hash"
|
||||||
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ func BeaconCommittee(
|
|||||||
|
|
||||||
committeesPerSlot := SlotCommitteeCount(uint64(len(validatorIndices)))
|
committeesPerSlot := SlotCommitteeCount(uint64(len(validatorIndices)))
|
||||||
|
|
||||||
indexOffset, err := mathutil.Add64(uint64(committeeIndex), uint64(slot.ModSlot(params.BeaconConfig().SlotsPerEpoch).Mul(committeesPerSlot)))
|
indexOffset, err := math.Add64(uint64(committeeIndex), uint64(slot.ModSlot(params.BeaconConfig().SlotsPerEpoch).Mul(committeesPerSlot)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "could not add calculate index offset")
|
return nil, errors.Wrap(err, "could not add calculate index offset")
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
types "github.com/prysmaticlabs/eth2-types"
|
types "github.com/prysmaticlabs/eth2-types"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||||
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ func ComputeWeakSubjectivityPeriod(st state.ReadOnlyBeaconState) (types.Epoch, e
|
|||||||
if T*(200+3*D) < t*(200+12*D) {
|
if T*(200+3*D) < t*(200+12*D) {
|
||||||
epochsForValidatorSetChurn := N * (t*(200+12*D) - T*(200+3*D)) / (600 * delta * (2*t + T))
|
epochsForValidatorSetChurn := N * (t*(200+12*D) - T*(200+3*D)) / (600 * delta * (2*t + T))
|
||||||
epochsForBalanceTopUps := N * (200 + 3*D) / (600 * Delta)
|
epochsForBalanceTopUps := N * (200 + 3*D) / (600 * Delta)
|
||||||
wsp += mathutil.Max(epochsForValidatorSetChurn, epochsForBalanceTopUps)
|
wsp += math.Max(epochsForValidatorSetChurn, epochsForBalanceTopUps)
|
||||||
} else {
|
} else {
|
||||||
wsp += 3 * N * D * t / (200 * Delta * (T - t))
|
wsp += 3 * N * D * t / (200 * Delta * (T - t))
|
||||||
}
|
}
|
||||||
|
@ -39,12 +39,12 @@ go_library(
|
|||||||
"//config/features:go_default_library",
|
"//config/features:go_default_library",
|
||||||
"//crypto/bls:go_default_library",
|
"//crypto/bls:go_default_library",
|
||||||
"//crypto/hash:go_default_library",
|
"//crypto/hash:go_default_library",
|
||||||
|
"//math:go_default_library",
|
||||||
"//monitoring/tracing:go_default_library",
|
"//monitoring/tracing:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//proto/prysm/v1alpha1/block:go_default_library",
|
"//proto/prysm/v1alpha1/block:go_default_library",
|
||||||
"//runtime/version:go_default_library",
|
"//runtime/version:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/mathutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"@com_github_pkg_errors//:go_default_library",
|
"@com_github_pkg_errors//:go_default_library",
|
||||||
"@com_github_prometheus_client_golang//prometheus:go_default_library",
|
"@com_github_prometheus_client_golang//prometheus:go_default_library",
|
||||||
|
@ -15,8 +15,8 @@ go_library(
|
|||||||
deps = [
|
deps = [
|
||||||
"//beacon-chain/state:go_default_library",
|
"//beacon-chain/state:go_default_library",
|
||||||
"//config/features:go_default_library",
|
"//config/features:go_default_library",
|
||||||
|
"//io/file:go_default_library",
|
||||||
"//proto/prysm/v1alpha1/block:go_default_library",
|
"//proto/prysm/v1alpha1/block:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
|
||||||
"@com_github_sirupsen_logrus//:go_default_library",
|
"@com_github_sirupsen_logrus//:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -6,8 +6,8 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/config/features"
|
"github.com/prysmaticlabs/prysm/config/features"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
|
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// WriteBlockToDisk as a block ssz. Writes to temp directory. Debug!
|
// WriteBlockToDisk as a block ssz. Writes to temp directory. Debug!
|
||||||
@ -27,7 +27,7 @@ func WriteBlockToDisk(block block.SignedBeaconBlock, failed bool) {
|
|||||||
log.WithError(err).Error("Failed to ssz encode block")
|
log.WithError(err).Error("Failed to ssz encode block")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := fileutil.WriteFile(fp, enc); err != nil {
|
if err := file.WriteFile(fp, enc); err != nil {
|
||||||
log.WithError(err).Error("Failed to write to disk")
|
log.WithError(err).Error("Failed to write to disk")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||||
"github.com/prysmaticlabs/prysm/config/features"
|
"github.com/prysmaticlabs/prysm/config/features"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
)
|
)
|
||||||
|
|
||||||
// WriteStateToDisk as a state ssz. Writes to temp directory. Debug!
|
// WriteStateToDisk as a state ssz. Writes to temp directory. Debug!
|
||||||
@ -22,7 +22,7 @@ func WriteStateToDisk(state state.ReadOnlyBeaconState) {
|
|||||||
log.WithError(err).Error("Failed to ssz encode state")
|
log.WithError(err).Error("Failed to ssz encode state")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := fileutil.WriteFile(fp, enc); err != nil {
|
if err := file.WriteFile(fp, enc); err != nil {
|
||||||
log.WithError(err).Error("Failed to write to disk")
|
log.WithError(err).Error("Failed to write to disk")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,10 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/epoch/precompute"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||||
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
"github.com/prysmaticlabs/prysm/monitoring/tracing"
|
"github.com/prysmaticlabs/prysm/monitoring/tracing"
|
||||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
|
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/block"
|
||||||
"github.com/prysmaticlabs/prysm/runtime/version"
|
"github.com/prysmaticlabs/prysm/runtime/version"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
"go.opencensus.io/trace"
|
"go.opencensus.io/trace"
|
||||||
)
|
)
|
||||||
@ -332,7 +332,7 @@ func VerifyOperationLengths(_ context.Context, state state.BeaconState, b block.
|
|||||||
if state.Eth1DepositIndex() > eth1Data.DepositCount {
|
if state.Eth1DepositIndex() > eth1Data.DepositCount {
|
||||||
return nil, fmt.Errorf("expected state.deposit_index %d <= eth1data.deposit_count %d", state.Eth1DepositIndex(), eth1Data.DepositCount)
|
return nil, fmt.Errorf("expected state.deposit_index %d <= eth1data.deposit_count %d", state.Eth1DepositIndex(), eth1Data.DepositCount)
|
||||||
}
|
}
|
||||||
maxDeposits := mathutil.Min(params.BeaconConfig().MaxDeposits, eth1Data.DepositCount-state.Eth1DepositIndex())
|
maxDeposits := math.Min(params.BeaconConfig().MaxDeposits, eth1Data.DepositCount-state.Eth1DepositIndex())
|
||||||
// Verify outstanding deposits are processed up to max number of deposits
|
// Verify outstanding deposits are processed up to max number of deposits
|
||||||
if uint64(len(body.Deposits())) != maxDeposits {
|
if uint64(len(body.Deposits())) != maxDeposits {
|
||||||
return nil, fmt.Errorf("incorrect outstanding deposits in block body, wanted: %d, got: %d",
|
return nil, fmt.Errorf("incorrect outstanding deposits in block body, wanted: %d, got: %d",
|
||||||
|
@ -18,9 +18,9 @@ go_library(
|
|||||||
deps = [
|
deps = [
|
||||||
"//beacon-chain/db/iface:go_default_library",
|
"//beacon-chain/db/iface:go_default_library",
|
||||||
"//beacon-chain/db/kv:go_default_library",
|
"//beacon-chain/db/kv:go_default_library",
|
||||||
|
"//io/file:go_default_library",
|
||||||
|
"//io/prompt:go_default_library",
|
||||||
"//shared/cmd:go_default_library",
|
"//shared/cmd:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
|
||||||
"//shared/promptutil:go_default_library",
|
|
||||||
"@com_github_pkg_errors//:go_default_library",
|
"@com_github_pkg_errors//:go_default_library",
|
||||||
"@com_github_sirupsen_logrus//:go_default_library",
|
"@com_github_sirupsen_logrus//:go_default_library",
|
||||||
"@com_github_urfave_cli_v2//:go_default_library",
|
"@com_github_urfave_cli_v2//:go_default_library",
|
||||||
|
@ -45,6 +45,7 @@ go_library(
|
|||||||
"//beacon-chain/state/v2:go_default_library",
|
"//beacon-chain/state/v2:go_default_library",
|
||||||
"//config/features:go_default_library",
|
"//config/features:go_default_library",
|
||||||
"//container/slice:go_default_library",
|
"//container/slice:go_default_library",
|
||||||
|
"//io/file:go_default_library",
|
||||||
"//monitoring/progress:go_default_library",
|
"//monitoring/progress:go_default_library",
|
||||||
"//monitoring/tracing:go_default_library",
|
"//monitoring/tracing:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
@ -52,7 +53,6 @@ go_library(
|
|||||||
"//proto/prysm/v1alpha1/wrapper:go_default_library",
|
"//proto/prysm/v1alpha1/wrapper:go_default_library",
|
||||||
"//runtime/version:go_default_library",
|
"//runtime/version:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"@com_github_dgraph_io_ristretto//:go_default_library",
|
"@com_github_dgraph_io_ristretto//:go_default_library",
|
||||||
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
"@com_github_ethereum_go_ethereum//common:go_default_library",
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
bolt "go.etcd.io/bbolt"
|
bolt "go.etcd.io/bbolt"
|
||||||
"go.opencensus.io/trace"
|
"go.opencensus.io/trace"
|
||||||
@ -23,7 +23,7 @@ func (s *Store) Backup(ctx context.Context, outputDir string, permissionOverride
|
|||||||
var backupsDir string
|
var backupsDir string
|
||||||
var err error
|
var err error
|
||||||
if outputDir != "" {
|
if outputDir != "" {
|
||||||
backupsDir, err = fileutil.ExpandPath(outputDir)
|
backupsDir, err = file.ExpandPath(outputDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ func (s *Store) Backup(ctx context.Context, outputDir string, permissionOverride
|
|||||||
return errors.New("no head block")
|
return errors.New("no head block")
|
||||||
}
|
}
|
||||||
// Ensure the backups directory exists.
|
// Ensure the backups directory exists.
|
||||||
if err := fileutil.HandleBackupDir(backupsDir, permissionOverride); err != nil {
|
if err := file.HandleBackupDir(backupsDir, permissionOverride); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
backupPath := path.Join(backupsDir, fmt.Sprintf("prysm_beacondb_at_slot_%07d.backup", head.Block().Slot()))
|
backupPath := path.Join(backupsDir, fmt.Sprintf("prysm_beacondb_at_slot_%07d.backup", head.Block().Slot()))
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
prombolt "github.com/prysmaticlabs/prombbolt"
|
prombolt "github.com/prysmaticlabs/prombbolt"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/db/iface"
|
"github.com/prysmaticlabs/prysm/beacon-chain/db/iface"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
bolt "go.etcd.io/bbolt"
|
bolt "go.etcd.io/bbolt"
|
||||||
)
|
)
|
||||||
@ -95,12 +95,12 @@ func KVStoreDatafilePath(dirPath string) string {
|
|||||||
// path specified, creates the kv-buckets based on the schema, and stores
|
// path specified, creates the kv-buckets based on the schema, and stores
|
||||||
// an open connection db object as a property of the Store struct.
|
// an open connection db object as a property of the Store struct.
|
||||||
func NewKVStore(ctx context.Context, dirPath string, config *Config) (*Store, error) {
|
func NewKVStore(ctx context.Context, dirPath string, config *Config) (*Store, error) {
|
||||||
hasDir, err := fileutil.HasDir(dirPath)
|
hasDir, err := file.HasDir(dirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !hasDir {
|
if !hasDir {
|
||||||
if err := fileutil.MkdirAll(dirPath); err != nil {
|
if err := file.MkdirAll(dirPath); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/db/kv"
|
"github.com/prysmaticlabs/prysm/beacon-chain/db/kv"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/prompt"
|
||||||
"github.com/prysmaticlabs/prysm/shared/cmd"
|
"github.com/prysmaticlabs/prysm/shared/cmd"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/promptutil"
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,9 +22,9 @@ func Restore(cliCtx *cli.Context) error {
|
|||||||
targetDir := cliCtx.String(cmd.RestoreTargetDirFlag.Name)
|
targetDir := cliCtx.String(cmd.RestoreTargetDirFlag.Name)
|
||||||
|
|
||||||
restoreDir := path.Join(targetDir, kv.BeaconNodeDbDirName)
|
restoreDir := path.Join(targetDir, kv.BeaconNodeDbDirName)
|
||||||
if fileutil.FileExists(path.Join(restoreDir, kv.DatabaseFileName)) {
|
if file.FileExists(path.Join(restoreDir, kv.DatabaseFileName)) {
|
||||||
resp, err := promptutil.ValidatePrompt(
|
resp, err := prompt.ValidatePrompt(
|
||||||
os.Stdin, dbExistsYesNoPrompt, promptutil.ValidateYesOrNo,
|
os.Stdin, dbExistsYesNoPrompt, prompt.ValidateYesOrNo,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "could not validate choice")
|
return errors.Wrap(err, "could not validate choice")
|
||||||
@ -34,10 +34,10 @@ func Restore(cliCtx *cli.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := fileutil.MkdirAll(restoreDir); err != nil {
|
if err := file.MkdirAll(restoreDir); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := fileutil.CopyFile(sourceFile, path.Join(restoreDir, kv.DatabaseFileName)); err != nil {
|
if err := file.CopyFile(sourceFile, path.Join(restoreDir, kv.DatabaseFileName)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,9 +16,9 @@ go_library(
|
|||||||
"//beacon-chain/core:go_default_library",
|
"//beacon-chain/core:go_default_library",
|
||||||
"//beacon-chain/db/iface:go_default_library",
|
"//beacon-chain/db/iface:go_default_library",
|
||||||
"//beacon-chain/slasher/types:go_default_library",
|
"//beacon-chain/slasher/types:go_default_library",
|
||||||
|
"//io/file:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"@com_github_ferranbt_fastssz//:go_default_library",
|
"@com_github_ferranbt_fastssz//:go_default_library",
|
||||||
"@com_github_golang_snappy//:go_default_library",
|
"@com_github_golang_snappy//:go_default_library",
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/db/iface"
|
"github.com/prysmaticlabs/prysm/beacon-chain/db/iface"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
bolt "go.etcd.io/bbolt"
|
bolt "go.etcd.io/bbolt"
|
||||||
)
|
)
|
||||||
@ -40,12 +40,12 @@ type Store struct {
|
|||||||
// path specified, creates the kv-buckets based on the schema, and stores
|
// path specified, creates the kv-buckets based on the schema, and stores
|
||||||
// an open connection db object as a property of the Store struct.
|
// an open connection db object as a property of the Store struct.
|
||||||
func NewKVStore(ctx context.Context, dirPath string, config *Config) (*Store, error) {
|
func NewKVStore(ctx context.Context, dirPath string, config *Config) (*Store, error) {
|
||||||
hasDir, err := fileutil.HasDir(dirPath)
|
hasDir, err := file.HasDir(dirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !hasDir {
|
if !hasDir {
|
||||||
if err := fileutil.MkdirAll(dirPath); err != nil {
|
if err := file.MkdirAll(dirPath); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ go_library(
|
|||||||
"//cmd/beacon-chain/flags:go_default_library",
|
"//cmd/beacon-chain/flags:go_default_library",
|
||||||
"//config/features:go_default_library",
|
"//config/features:go_default_library",
|
||||||
"//crypto/hash:go_default_library",
|
"//crypto/hash:go_default_library",
|
||||||
|
"//io/file:go_default_library",
|
||||||
"//monitoring/tracing:go_default_library",
|
"//monitoring/tracing:go_default_library",
|
||||||
"//network:go_default_library",
|
"//network:go_default_library",
|
||||||
"//network/forks:go_default_library",
|
"//network/forks:go_default_library",
|
||||||
@ -64,7 +65,6 @@ go_library(
|
|||||||
"//runtime:go_default_library",
|
"//runtime:go_default_library",
|
||||||
"//runtime/version:go_default_library",
|
"//runtime/version:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"//shared/runutil:go_default_library",
|
"//shared/runutil:go_default_library",
|
||||||
"//time:go_default_library",
|
"//time:go_default_library",
|
||||||
|
@ -18,11 +18,11 @@ import (
|
|||||||
"github.com/libp2p/go-libp2p-core/crypto"
|
"github.com/libp2p/go-libp2p-core/crypto"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prysmaticlabs/go-bitfield"
|
"github.com/prysmaticlabs/go-bitfield"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
"github.com/prysmaticlabs/prysm/network"
|
"github.com/prysmaticlabs/prysm/network"
|
||||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/metadata"
|
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/metadata"
|
||||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -127,7 +127,7 @@ func metaDataFromConfig(cfg *Config) (metadata.Metadata, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err := fileutil.WriteFile(defaultKeyPath, dst); err != nil {
|
if err := file.WriteFile(defaultKeyPath, dst); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return wrapper.WrappedMetadataV0(metaData), nil
|
return wrapper.WrappedMetadataV0(metaData), nil
|
||||||
|
@ -33,13 +33,13 @@ go_library(
|
|||||||
"//container/trie:go_default_library",
|
"//container/trie:go_default_library",
|
||||||
"//contracts/deposit-contract:go_default_library",
|
"//contracts/deposit-contract:go_default_library",
|
||||||
"//crypto/hash:go_default_library",
|
"//crypto/hash:go_default_library",
|
||||||
|
"//io/logs:go_default_library",
|
||||||
"//monitoring/clientstats:go_default_library",
|
"//monitoring/clientstats:go_default_library",
|
||||||
"//monitoring/tracing:go_default_library",
|
"//monitoring/tracing:go_default_library",
|
||||||
"//network:go_default_library",
|
"//network:go_default_library",
|
||||||
"//network/authorization:go_default_library",
|
"//network/authorization:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/logutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"//time:go_default_library",
|
"//time:go_default_library",
|
||||||
"@com_github_ethereum_go_ethereum//:go_default_library",
|
"@com_github_ethereum_go_ethereum//:go_default_library",
|
||||||
|
@ -34,13 +34,13 @@ import (
|
|||||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||||
"github.com/prysmaticlabs/prysm/container/trie"
|
"github.com/prysmaticlabs/prysm/container/trie"
|
||||||
contracts "github.com/prysmaticlabs/prysm/contracts/deposit-contract"
|
contracts "github.com/prysmaticlabs/prysm/contracts/deposit-contract"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/logs"
|
||||||
"github.com/prysmaticlabs/prysm/monitoring/clientstats"
|
"github.com/prysmaticlabs/prysm/monitoring/clientstats"
|
||||||
"github.com/prysmaticlabs/prysm/network"
|
"github.com/prysmaticlabs/prysm/network"
|
||||||
"github.com/prysmaticlabs/prysm/network/authorization"
|
"github.com/prysmaticlabs/prysm/network/authorization"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
protodb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
protodb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/shared/logutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
prysmTime "github.com/prysmaticlabs/prysm/time"
|
prysmTime "github.com/prysmaticlabs/prysm/time"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -493,7 +493,7 @@ func (s *Service) waitForConnection() {
|
|||||||
s.updateConnectedETH1(true)
|
s.updateConnectedETH1(true)
|
||||||
s.runError = nil
|
s.runError = nil
|
||||||
log.WithFields(logrus.Fields{
|
log.WithFields(logrus.Fields{
|
||||||
"endpoint": logutil.MaskCredentialsLogging(s.currHttpEndpoint.Url),
|
"endpoint": logs.MaskCredentialsLogging(s.currHttpEndpoint.Url),
|
||||||
}).Info("Connected to eth1 proof-of-work chain")
|
}).Info("Connected to eth1 proof-of-work chain")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -522,7 +522,7 @@ func (s *Service) waitForConnection() {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
log.Debugf("Trying to dial endpoint: %s", logutil.MaskCredentialsLogging(s.currHttpEndpoint.Url))
|
log.Debugf("Trying to dial endpoint: %s", logs.MaskCredentialsLogging(s.currHttpEndpoint.Url))
|
||||||
errConnect := s.connectToPowChain()
|
errConnect := s.connectToPowChain()
|
||||||
if errConnect != nil {
|
if errConnect != nil {
|
||||||
errorLogger(errConnect, "Could not connect to powchain endpoint")
|
errorLogger(errConnect, "Could not connect to powchain endpoint")
|
||||||
@ -541,7 +541,7 @@ func (s *Service) waitForConnection() {
|
|||||||
s.updateConnectedETH1(true)
|
s.updateConnectedETH1(true)
|
||||||
s.runError = nil
|
s.runError = nil
|
||||||
log.WithFields(logrus.Fields{
|
log.WithFields(logrus.Fields{
|
||||||
"endpoint": logutil.MaskCredentialsLogging(s.currHttpEndpoint.Url),
|
"endpoint": logs.MaskCredentialsLogging(s.currHttpEndpoint.Url),
|
||||||
}).Info("Connected to eth1 proof-of-work chain")
|
}).Info("Connected to eth1 proof-of-work chain")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -953,7 +953,7 @@ func (s *Service) fallbackToNextEndpoint() {
|
|||||||
}
|
}
|
||||||
s.updateCurrHttpEndpoint(s.httpEndpoints[nextIndex])
|
s.updateCurrHttpEndpoint(s.httpEndpoints[nextIndex])
|
||||||
if nextIndex != currIndex {
|
if nextIndex != currIndex {
|
||||||
log.Infof("Falling back to alternative endpoint: %s", logutil.MaskCredentialsLogging(s.currHttpEndpoint.Url))
|
log.Infof("Falling back to alternative endpoint: %s", logs.MaskCredentialsLogging(s.currHttpEndpoint.Url))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,10 +35,10 @@ go_library(
|
|||||||
"//beacon-chain/state/stategen:go_default_library",
|
"//beacon-chain/state/stategen:go_default_library",
|
||||||
"//beacon-chain/sync:go_default_library",
|
"//beacon-chain/sync:go_default_library",
|
||||||
"//config/features:go_default_library",
|
"//config/features:go_default_library",
|
||||||
|
"//io/logs:go_default_library",
|
||||||
"//monitoring/tracing:go_default_library",
|
"//monitoring/tracing:go_default_library",
|
||||||
"//proto/eth/service:go_default_library",
|
"//proto/eth/service:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//shared/logutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"@com_github_grpc_ecosystem_go_grpc_middleware//:go_default_library",
|
"@com_github_grpc_ecosystem_go_grpc_middleware//:go_default_library",
|
||||||
"@com_github_grpc_ecosystem_go_grpc_middleware//recovery:go_default_library",
|
"@com_github_grpc_ecosystem_go_grpc_middleware//recovery:go_default_library",
|
||||||
|
@ -10,9 +10,9 @@ go_library(
|
|||||||
"//beacon-chain/db:go_default_library",
|
"//beacon-chain/db:go_default_library",
|
||||||
"//beacon-chain/p2p:go_default_library",
|
"//beacon-chain/p2p:go_default_library",
|
||||||
"//beacon-chain/sync:go_default_library",
|
"//beacon-chain/sync:go_default_library",
|
||||||
|
"//io/logs:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//runtime/version:go_default_library",
|
"//runtime/version:go_default_library",
|
||||||
"//shared/logutil:go_default_library",
|
|
||||||
"@com_github_libp2p_go_libp2p_core//network:go_default_library",
|
"@com_github_libp2p_go_libp2p_core//network:go_default_library",
|
||||||
"@com_github_libp2p_go_libp2p_core//peer:go_default_library",
|
"@com_github_libp2p_go_libp2p_core//peer:go_default_library",
|
||||||
"@io_bazel_rules_go//proto/wkt:empty_go_proto",
|
"@io_bazel_rules_go//proto/wkt:empty_go_proto",
|
||||||
|
@ -17,10 +17,10 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
|
"github.com/prysmaticlabs/prysm/beacon-chain/p2p"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/sync"
|
"github.com/prysmaticlabs/prysm/beacon-chain/sync"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/logs"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/runtime/version"
|
"github.com/prysmaticlabs/prysm/runtime/version"
|
||||||
"github.com/prysmaticlabs/prysm/shared/logutil"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
@ -31,7 +31,7 @@ import (
|
|||||||
// providing RPC endpoints for verifying a beacon node's sync status, genesis and
|
// providing RPC endpoints for verifying a beacon node's sync status, genesis and
|
||||||
// version information, and services the node implements and runs.
|
// version information, and services the node implements and runs.
|
||||||
type Server struct {
|
type Server struct {
|
||||||
LogsStreamer logutil.Streamer
|
LogsStreamer logs.Streamer
|
||||||
StreamLogsBufferSize int
|
StreamLogsBufferSize int
|
||||||
SyncChecker sync.Checker
|
SyncChecker sync.Checker
|
||||||
Server *grpc.Server
|
Server *grpc.Server
|
||||||
|
@ -39,10 +39,10 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state/stategen"
|
||||||
chainSync "github.com/prysmaticlabs/prysm/beacon-chain/sync"
|
chainSync "github.com/prysmaticlabs/prysm/beacon-chain/sync"
|
||||||
"github.com/prysmaticlabs/prysm/config/features"
|
"github.com/prysmaticlabs/prysm/config/features"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/logs"
|
||||||
"github.com/prysmaticlabs/prysm/monitoring/tracing"
|
"github.com/prysmaticlabs/prysm/monitoring/tracing"
|
||||||
ethpbservice "github.com/prysmaticlabs/prysm/proto/eth/service"
|
ethpbservice "github.com/prysmaticlabs/prysm/proto/eth/service"
|
||||||
ethpbv1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
ethpbv1alpha1 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/shared/logutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"go.opencensus.io/plugin/ocgrpc"
|
"go.opencensus.io/plugin/ocgrpc"
|
||||||
@ -211,7 +211,7 @@ func (s *Service) Start() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nodeServer := &nodev1alpha1.Server{
|
nodeServer := &nodev1alpha1.Server{
|
||||||
LogsStreamer: logutil.NewStreamServer(),
|
LogsStreamer: logs.NewStreamServer(),
|
||||||
StreamLogsBufferSize: 1000, // Enough to handle bursts of beacon node logs for gRPC streaming.
|
StreamLogsBufferSize: 1000, // Enough to handle bursts of beacon node logs for gRPC streaming.
|
||||||
BeaconDB: s.cfg.BeaconDB,
|
BeaconDB: s.cfg.BeaconDB,
|
||||||
Server: s.grpcServer,
|
Server: s.grpcServer,
|
||||||
|
@ -29,12 +29,12 @@ go_library(
|
|||||||
"//beacon-chain/sync:go_default_library",
|
"//beacon-chain/sync:go_default_library",
|
||||||
"//cmd/beacon-chain/flags:go_default_library",
|
"//cmd/beacon-chain/flags:go_default_library",
|
||||||
"//crypto/rand:go_default_library",
|
"//crypto/rand:go_default_library",
|
||||||
|
"//math:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//proto/prysm/v1alpha1/block:go_default_library",
|
"//proto/prysm/v1alpha1/block:go_default_library",
|
||||||
"//runtime:go_default_library",
|
"//runtime:go_default_library",
|
||||||
"//shared/abool:go_default_library",
|
"//shared/abool:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/mathutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"//time:go_default_library",
|
"//time:go_default_library",
|
||||||
"@com_github_kevinms_leakybucket_go//:go_default_library",
|
"@com_github_kevinms_leakybucket_go//:go_default_library",
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers"
|
"github.com/prysmaticlabs/prysm/beacon-chain/p2p/peers/scorers"
|
||||||
"github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags"
|
"github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
mathutil "github.com/prysmaticlabs/prysm/math"
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
prysmTime "github.com/prysmaticlabs/prysm/time"
|
prysmTime "github.com/prysmaticlabs/prysm/time"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -19,14 +19,14 @@ go_library(
|
|||||||
"//cmd/beacon-chain/db:go_default_library",
|
"//cmd/beacon-chain/db:go_default_library",
|
||||||
"//cmd/beacon-chain/flags:go_default_library",
|
"//cmd/beacon-chain/flags:go_default_library",
|
||||||
"//config/features:go_default_library",
|
"//config/features:go_default_library",
|
||||||
|
"//io/file:go_default_library",
|
||||||
|
"//io/logs:go_default_library",
|
||||||
"//monitoring/journald:go_default_library",
|
"//monitoring/journald:go_default_library",
|
||||||
"//runtime/debug:go_default_library",
|
"//runtime/debug:go_default_library",
|
||||||
"//runtime/maxprocs:go_default_library",
|
"//runtime/maxprocs:go_default_library",
|
||||||
"//runtime/tos:go_default_library",
|
"//runtime/tos:go_default_library",
|
||||||
"//runtime/version:go_default_library",
|
"//runtime/version:go_default_library",
|
||||||
"//shared/cmd:go_default_library",
|
"//shared/cmd:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
|
||||||
"//shared/logutil:go_default_library",
|
|
||||||
"@com_github_ethereum_go_ethereum//log:go_default_library",
|
"@com_github_ethereum_go_ethereum//log:go_default_library",
|
||||||
"@com_github_ipfs_go_log_v2//:go_default_library",
|
"@com_github_ipfs_go_log_v2//:go_default_library",
|
||||||
"@com_github_joonix_log//:go_default_library",
|
"@com_github_joonix_log//:go_default_library",
|
||||||
|
@ -15,14 +15,14 @@ import (
|
|||||||
dbcommands "github.com/prysmaticlabs/prysm/cmd/beacon-chain/db"
|
dbcommands "github.com/prysmaticlabs/prysm/cmd/beacon-chain/db"
|
||||||
"github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags"
|
"github.com/prysmaticlabs/prysm/cmd/beacon-chain/flags"
|
||||||
"github.com/prysmaticlabs/prysm/config/features"
|
"github.com/prysmaticlabs/prysm/config/features"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/logs"
|
||||||
"github.com/prysmaticlabs/prysm/monitoring/journald"
|
"github.com/prysmaticlabs/prysm/monitoring/journald"
|
||||||
"github.com/prysmaticlabs/prysm/runtime/debug"
|
"github.com/prysmaticlabs/prysm/runtime/debug"
|
||||||
_ "github.com/prysmaticlabs/prysm/runtime/maxprocs"
|
_ "github.com/prysmaticlabs/prysm/runtime/maxprocs"
|
||||||
"github.com/prysmaticlabs/prysm/runtime/tos"
|
"github.com/prysmaticlabs/prysm/runtime/tos"
|
||||||
"github.com/prysmaticlabs/prysm/runtime/version"
|
"github.com/prysmaticlabs/prysm/runtime/version"
|
||||||
"github.com/prysmaticlabs/prysm/shared/cmd"
|
"github.com/prysmaticlabs/prysm/shared/cmd"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/logutil"
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
prefixed "github.com/x-cray/logrus-prefixed-formatter"
|
prefixed "github.com/x-cray/logrus-prefixed-formatter"
|
||||||
@ -163,7 +163,7 @@ func main() {
|
|||||||
|
|
||||||
logFileName := ctx.String(cmd.LogFileName.Name)
|
logFileName := ctx.String(cmd.LogFileName.Name)
|
||||||
if logFileName != "" {
|
if logFileName != "" {
|
||||||
if err := logutil.ConfigurePersistentLogging(logFileName); err != nil {
|
if err := logs.ConfigurePersistentLogging(logFileName); err != nil {
|
||||||
log.WithError(err).Error("Failed to configuring logging to disk.")
|
log.WithError(err).Error("Failed to configuring logging to disk.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ func main() {
|
|||||||
|
|
||||||
func startNode(ctx *cli.Context) error {
|
func startNode(ctx *cli.Context) error {
|
||||||
// Fix data dir for Windows users.
|
// Fix data dir for Windows users.
|
||||||
outdatedDataDir := filepath.Join(fileutil.HomeDir(), "AppData", "Roaming", "Eth2")
|
outdatedDataDir := filepath.Join(file.HomeDir(), "AppData", "Roaming", "Eth2")
|
||||||
currentDataDir := ctx.String(cmd.DataDirFlag.Name)
|
currentDataDir := ctx.String(cmd.DataDirFlag.Name)
|
||||||
if err := cmd.FixDefaultDataDir(outdatedDataDir, currentDataDir); err != nil {
|
if err := cmd.FixDefaultDataDir(outdatedDataDir, currentDataDir); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -12,11 +12,11 @@ go_library(
|
|||||||
visibility = ["//visibility:private"],
|
visibility = ["//visibility:private"],
|
||||||
deps = [
|
deps = [
|
||||||
"//cmd/client-stats/flags:go_default_library",
|
"//cmd/client-stats/flags:go_default_library",
|
||||||
|
"//io/logs:go_default_library",
|
||||||
"//monitoring/clientstats:go_default_library",
|
"//monitoring/clientstats:go_default_library",
|
||||||
"//monitoring/journald:go_default_library",
|
"//monitoring/journald:go_default_library",
|
||||||
"//runtime/version:go_default_library",
|
"//runtime/version:go_default_library",
|
||||||
"//shared/cmd:go_default_library",
|
"//shared/cmd:go_default_library",
|
||||||
"//shared/logutil:go_default_library",
|
|
||||||
"@com_github_joonix_log//:go_default_library",
|
"@com_github_joonix_log//:go_default_library",
|
||||||
"@com_github_sirupsen_logrus//:go_default_library",
|
"@com_github_sirupsen_logrus//:go_default_library",
|
||||||
"@com_github_urfave_cli_v2//:go_default_library",
|
"@com_github_urfave_cli_v2//:go_default_library",
|
||||||
|
@ -8,11 +8,11 @@ import (
|
|||||||
|
|
||||||
joonix "github.com/joonix/log"
|
joonix "github.com/joonix/log"
|
||||||
"github.com/prysmaticlabs/prysm/cmd/client-stats/flags"
|
"github.com/prysmaticlabs/prysm/cmd/client-stats/flags"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/logs"
|
||||||
"github.com/prysmaticlabs/prysm/monitoring/clientstats"
|
"github.com/prysmaticlabs/prysm/monitoring/clientstats"
|
||||||
"github.com/prysmaticlabs/prysm/monitoring/journald"
|
"github.com/prysmaticlabs/prysm/monitoring/journald"
|
||||||
"github.com/prysmaticlabs/prysm/runtime/version"
|
"github.com/prysmaticlabs/prysm/runtime/version"
|
||||||
"github.com/prysmaticlabs/prysm/shared/cmd"
|
"github.com/prysmaticlabs/prysm/shared/cmd"
|
||||||
"github.com/prysmaticlabs/prysm/shared/logutil"
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
prefixed "github.com/x-cray/logrus-prefixed-formatter"
|
prefixed "github.com/x-cray/logrus-prefixed-formatter"
|
||||||
@ -80,7 +80,7 @@ func main() {
|
|||||||
|
|
||||||
logFileName := ctx.String(cmd.LogFileName.Name)
|
logFileName := ctx.String(cmd.LogFileName.Name)
|
||||||
if logFileName != "" {
|
if logFileName != "" {
|
||||||
if err := logutil.ConfigurePersistentLogging(logFileName); err != nil {
|
if err := logs.ConfigurePersistentLogging(logFileName); err != nil {
|
||||||
log.WithError(err).Error("Failed to configuring logging to disk.")
|
log.WithError(err).Error("Failed to configuring logging to disk.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,14 +21,14 @@ go_library(
|
|||||||
"//cmd/validator/slashing-protection:go_default_library",
|
"//cmd/validator/slashing-protection:go_default_library",
|
||||||
"//cmd/validator/wallet:go_default_library",
|
"//cmd/validator/wallet:go_default_library",
|
||||||
"//config/features:go_default_library",
|
"//config/features:go_default_library",
|
||||||
|
"//io/file:go_default_library",
|
||||||
|
"//io/logs:go_default_library",
|
||||||
"//monitoring/journald:go_default_library",
|
"//monitoring/journald:go_default_library",
|
||||||
"//runtime/debug:go_default_library",
|
"//runtime/debug:go_default_library",
|
||||||
"//runtime/maxprocs:go_default_library",
|
"//runtime/maxprocs:go_default_library",
|
||||||
"//runtime/tos:go_default_library",
|
"//runtime/tos:go_default_library",
|
||||||
"//runtime/version:go_default_library",
|
"//runtime/version:go_default_library",
|
||||||
"//shared/cmd:go_default_library",
|
"//shared/cmd:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
|
||||||
"//shared/logutil:go_default_library",
|
|
||||||
"//validator/node:go_default_library",
|
"//validator/node:go_default_library",
|
||||||
"@com_github_joonix_log//:go_default_library",
|
"@com_github_joonix_log//:go_default_library",
|
||||||
"@com_github_sirupsen_logrus//:go_default_library",
|
"@com_github_sirupsen_logrus//:go_default_library",
|
||||||
|
@ -13,7 +13,7 @@ go_library(
|
|||||||
"//validator:__subpackages__",
|
"//validator:__subpackages__",
|
||||||
],
|
],
|
||||||
deps = [
|
deps = [
|
||||||
"//shared/fileutil:go_default_library",
|
"//io/file:go_default_library",
|
||||||
"@com_github_urfave_cli_v2//:go_default_library",
|
"@com_github_urfave_cli_v2//:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -207,10 +207,10 @@ var (
|
|||||||
Value: "",
|
Value: "",
|
||||||
}
|
}
|
||||||
// ExitAllFlag allows stakers to select all validating keys for exit. This will still require the staker
|
// ExitAllFlag allows stakers to select all validating keys for exit. This will still require the staker
|
||||||
// to confirm a prompt for this action given it is a dangerous one.
|
// to confirm a userprompt for this action given it is a dangerous one.
|
||||||
ExitAllFlag = &cli.BoolFlag{
|
ExitAllFlag = &cli.BoolFlag{
|
||||||
Name: "exit-all",
|
Name: "exit-all",
|
||||||
Usage: "Exit all validators. This will still require the staker to confirm a prompt for the action",
|
Usage: "Exit all validators. This will still require the staker to confirm a userprompt for the action",
|
||||||
}
|
}
|
||||||
// BackupPasswordFile for encrypting accounts a user wishes to back up.
|
// BackupPasswordFile for encrypting accounts a user wishes to back up.
|
||||||
BackupPasswordFile = &cli.StringFlag{
|
BackupPasswordFile = &cli.StringFlag{
|
||||||
@ -273,10 +273,10 @@ var (
|
|||||||
Usage: "Kind of keymanager, either imported, derived, or remote, specified during wallet creation",
|
Usage: "Kind of keymanager, either imported, derived, or remote, specified during wallet creation",
|
||||||
Value: "",
|
Value: "",
|
||||||
}
|
}
|
||||||
// SkipDepositConfirmationFlag skips the y/n confirmation prompt for sending a deposit to the deposit contract.
|
// SkipDepositConfirmationFlag skips the y/n confirmation userprompt for sending a deposit to the deposit contract.
|
||||||
SkipDepositConfirmationFlag = &cli.BoolFlag{
|
SkipDepositConfirmationFlag = &cli.BoolFlag{
|
||||||
Name: "skip-deposit-confirmation",
|
Name: "skip-deposit-confirmation",
|
||||||
Usage: "Skips the y/n confirmation prompt for sending a deposit to the deposit contract",
|
Usage: "Skips the y/n confirmation userprompt for sending a deposit to the deposit contract",
|
||||||
Value: false,
|
Value: false,
|
||||||
}
|
}
|
||||||
// EnableWebFlag enables controlling the validator client via the Prysm web ui. This is a work in progress.
|
// EnableWebFlag enables controlling the validator client via the Prysm web ui. This is a work in progress.
|
||||||
@ -308,7 +308,7 @@ var (
|
|||||||
// DefaultValidatorDir returns OS-specific default validator directory.
|
// DefaultValidatorDir returns OS-specific default validator directory.
|
||||||
func DefaultValidatorDir() string {
|
func DefaultValidatorDir() string {
|
||||||
// Try to place the data folder in the user's home dir
|
// Try to place the data folder in the user's home dir
|
||||||
home := fileutil.HomeDir()
|
home := file.HomeDir()
|
||||||
if home != "" {
|
if home != "" {
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
return filepath.Join(home, "Library", "Eth2Validators")
|
return filepath.Join(home, "Library", "Eth2Validators")
|
||||||
|
@ -17,14 +17,14 @@ import (
|
|||||||
slashingprotectioncommands "github.com/prysmaticlabs/prysm/cmd/validator/slashing-protection"
|
slashingprotectioncommands "github.com/prysmaticlabs/prysm/cmd/validator/slashing-protection"
|
||||||
walletcommands "github.com/prysmaticlabs/prysm/cmd/validator/wallet"
|
walletcommands "github.com/prysmaticlabs/prysm/cmd/validator/wallet"
|
||||||
"github.com/prysmaticlabs/prysm/config/features"
|
"github.com/prysmaticlabs/prysm/config/features"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/logs"
|
||||||
"github.com/prysmaticlabs/prysm/monitoring/journald"
|
"github.com/prysmaticlabs/prysm/monitoring/journald"
|
||||||
"github.com/prysmaticlabs/prysm/runtime/debug"
|
"github.com/prysmaticlabs/prysm/runtime/debug"
|
||||||
_ "github.com/prysmaticlabs/prysm/runtime/maxprocs"
|
_ "github.com/prysmaticlabs/prysm/runtime/maxprocs"
|
||||||
"github.com/prysmaticlabs/prysm/runtime/tos"
|
"github.com/prysmaticlabs/prysm/runtime/tos"
|
||||||
"github.com/prysmaticlabs/prysm/runtime/version"
|
"github.com/prysmaticlabs/prysm/runtime/version"
|
||||||
"github.com/prysmaticlabs/prysm/shared/cmd"
|
"github.com/prysmaticlabs/prysm/shared/cmd"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/logutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/validator/node"
|
"github.com/prysmaticlabs/prysm/validator/node"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
@ -155,13 +155,13 @@ func main() {
|
|||||||
|
|
||||||
logFileName := ctx.String(cmd.LogFileName.Name)
|
logFileName := ctx.String(cmd.LogFileName.Name)
|
||||||
if logFileName != "" {
|
if logFileName != "" {
|
||||||
if err := logutil.ConfigurePersistentLogging(logFileName); err != nil {
|
if err := logs.ConfigurePersistentLogging(logFileName); err != nil {
|
||||||
log.WithError(err).Error("Failed to configuring logging to disk.")
|
log.WithError(err).Error("Failed to configuring logging to disk.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix data dir for Windows users.
|
// Fix data dir for Windows users.
|
||||||
outdatedDataDir := filepath.Join(fileutil.HomeDir(), "AppData", "Roaming", "Eth2Validators")
|
outdatedDataDir := filepath.Join(file.HomeDir(), "AppData", "Roaming", "Eth2Validators")
|
||||||
currentDataDir := flags.DefaultValidatorDir()
|
currentDataDir := flags.DefaultValidatorDir()
|
||||||
if err := cmd.FixDefaultDataDir(outdatedDataDir, currentDataDir); err != nil {
|
if err := cmd.FixDefaultDataDir(outdatedDataDir, currentDataDir); err != nil {
|
||||||
log.WithError(err).Error("Cannot update data directory")
|
log.WithError(err).Error("Cannot update data directory")
|
||||||
|
@ -10,9 +10,9 @@ go_library(
|
|||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//crypto/hash:go_default_library",
|
"//crypto/hash:go_default_library",
|
||||||
|
"//math:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/mathutil:go_default_library",
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/crypto/hash"
|
"github.com/prysmaticlabs/prysm/crypto/hash"
|
||||||
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
protodb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
protodb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// SparseMerkleTrie implements a sparse, general purpose Merkle trie to be used
|
// SparseMerkleTrie implements a sparse, general purpose Merkle trie to be used
|
||||||
@ -180,7 +180,7 @@ func VerifyMerkleBranch(root, item []byte, merkleIndex int, proof [][]byte, dept
|
|||||||
}
|
}
|
||||||
node := bytesutil.ToBytes32(item)
|
node := bytesutil.ToBytes32(item)
|
||||||
for i := 0; i <= int(depth); i++ {
|
for i := 0; i <= int(depth); i++ {
|
||||||
if (uint64(merkleIndex) / mathutil.PowerOf2(uint64(i)) % 2) != 0 {
|
if (uint64(merkleIndex) / math.PowerOf2(uint64(i)) % 2) != 0 {
|
||||||
node = hash.Hash(append(proof[i], node[:]...))
|
node = hash.Hash(append(proof[i], node[:]...))
|
||||||
} else {
|
} else {
|
||||||
node = hash.Hash(append(node[:], proof[i]...))
|
node = hash.Hash(append(node[:], proof[i]...))
|
||||||
|
@ -12,7 +12,7 @@ go_library(
|
|||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//crypto/bls:go_default_library",
|
"//crypto/bls:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
"//io/file:go_default_library",
|
||||||
"//time:go_default_library",
|
"//time:go_default_library",
|
||||||
"@com_github_minio_sha256_simd//:go_default_library",
|
"@com_github_minio_sha256_simd//:go_default_library",
|
||||||
"@com_github_pborman_uuid//:go_default_library",
|
"@com_github_pborman_uuid//:go_default_library",
|
||||||
|
@ -27,7 +27,7 @@ import (
|
|||||||
|
|
||||||
"github.com/pborman/uuid"
|
"github.com/pborman/uuid"
|
||||||
"github.com/prysmaticlabs/prysm/crypto/bls"
|
"github.com/prysmaticlabs/prysm/crypto/bls"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -159,15 +159,15 @@ func storeNewRandomKey(ks keyStore, password string) error {
|
|||||||
return ks.StoreKey(ks.JoinPath(keyFileName(key.PublicKey)), key, password)
|
return ks.StoreKey(ks.JoinPath(keyFileName(key.PublicKey)), key, password)
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeKeyFile(file string, content []byte) error {
|
func writeKeyFile(fname string, content []byte) error {
|
||||||
// Create the keystore directory with appropriate permissions
|
// Create the keystore directory with appropriate permissions
|
||||||
// in case it is not present yet.
|
// in case it is not present yet.
|
||||||
if err := fileutil.MkdirAll(filepath.Dir(file)); err != nil {
|
if err := file.MkdirAll(filepath.Dir(fname)); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Atomic write: create a temporary hidden file first
|
// Atomic write: create a temporary hidden file first
|
||||||
// then move it into place. TempFile assigns mode 0600.
|
// then move it into place. TempFile assigns mode 0600.
|
||||||
f, err := ioutil.TempFile(filepath.Dir(file), "."+filepath.Base(file)+".tmp")
|
f, err := ioutil.TempFile(filepath.Dir(fname), "."+filepath.Base(fname)+".tmp")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -185,5 +185,5 @@ func writeKeyFile(file string, content []byte) error {
|
|||||||
if err := f.Close(); err != nil {
|
if err := f.Close(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return os.Rename(f.Name(), file)
|
return os.Rename(f.Name(), fname)
|
||||||
}
|
}
|
||||||
|
2
deps.bzl
2
deps.bzl
@ -433,7 +433,7 @@ def prysm_deps():
|
|||||||
|
|
||||||
go_repository(
|
go_repository(
|
||||||
name = "com_github_c_bata_go_prompt",
|
name = "com_github_c_bata_go_prompt",
|
||||||
importpath = "github.com/c-bata/go-prompt",
|
importpath = "github.com/c-bata/go-userprompt",
|
||||||
sum = "h1:uyKRz6Z6DUyj49QVijyM339UJV9yhbr70gESwbNU3e0=",
|
sum = "h1:uyKRz6Z6DUyj49QVijyM339UJV9yhbr70gESwbNU3e0=",
|
||||||
version = "v0.2.2",
|
version = "v0.2.2",
|
||||||
)
|
)
|
||||||
|
@ -3,7 +3,7 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test")
|
|||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = ["fileutil.go"],
|
srcs = ["fileutil.go"],
|
||||||
importpath = "github.com/prysmaticlabs/prysm/shared/fileutil",
|
importpath = "github.com/prysmaticlabs/prysm/io/file",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
@ -1,4 +1,4 @@
|
|||||||
package fileutil
|
package file
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
@ -13,7 +13,7 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
package fileutil_test
|
package file_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
@ -25,7 +25,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||||
@ -42,7 +42,7 @@ func TestPathExpansion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
require.NoError(t, os.Setenv("DDDXXX", "/tmp"))
|
require.NoError(t, os.Setenv("DDDXXX", "/tmp"))
|
||||||
for test, expected := range tests {
|
for test, expected := range tests {
|
||||||
expanded, err := fileutil.ExpandPath(test)
|
expanded, err := file.ExpandPath(test)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, expected, expanded)
|
assert.Equal(t, expected, expanded)
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ func TestMkdirAll_AlreadyExists_WrongPermissions(t *testing.T) {
|
|||||||
dirName := t.TempDir() + "somedir"
|
dirName := t.TempDir() + "somedir"
|
||||||
err := os.MkdirAll(dirName, os.ModePerm)
|
err := os.MkdirAll(dirName, os.ModePerm)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
err = fileutil.MkdirAll(dirName)
|
err = file.MkdirAll(dirName)
|
||||||
assert.ErrorContains(t, "already exists without proper 0700 permissions", err)
|
assert.ErrorContains(t, "already exists without proper 0700 permissions", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ func TestMkdirAll_AlreadyExists_Override(t *testing.T) {
|
|||||||
dirName := t.TempDir() + "somedir"
|
dirName := t.TempDir() + "somedir"
|
||||||
err := os.MkdirAll(dirName, params.BeaconIoConfig().ReadWriteExecutePermissions)
|
err := os.MkdirAll(dirName, params.BeaconIoConfig().ReadWriteExecutePermissions)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.NoError(t, fileutil.MkdirAll(dirName))
|
assert.NoError(t, file.MkdirAll(dirName))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHandleBackupDir_AlreadyExists_Override(t *testing.T) {
|
func TestHandleBackupDir_AlreadyExists_Override(t *testing.T) {
|
||||||
@ -70,7 +70,7 @@ func TestHandleBackupDir_AlreadyExists_Override(t *testing.T) {
|
|||||||
info, err := os.Stat(dirName)
|
info, err := os.Stat(dirName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, "drwxr-xr-x", info.Mode().String())
|
assert.Equal(t, "drwxr-xr-x", info.Mode().String())
|
||||||
assert.NoError(t, fileutil.HandleBackupDir(dirName, true))
|
assert.NoError(t, file.HandleBackupDir(dirName, true))
|
||||||
info, err = os.Stat(dirName)
|
info, err = os.Stat(dirName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, "drwx------", info.Mode().String())
|
assert.Equal(t, "drwx------", info.Mode().String())
|
||||||
@ -83,7 +83,7 @@ func TestHandleBackupDir_AlreadyExists_No_Override(t *testing.T) {
|
|||||||
info, err := os.Stat(dirName)
|
info, err := os.Stat(dirName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, "drwxr-xr-x", info.Mode().String())
|
assert.Equal(t, "drwxr-xr-x", info.Mode().String())
|
||||||
err = fileutil.HandleBackupDir(dirName, false)
|
err = file.HandleBackupDir(dirName, false)
|
||||||
assert.ErrorContains(t, "dir already exists without proper 0700 permissions", err)
|
assert.ErrorContains(t, "dir already exists without proper 0700 permissions", err)
|
||||||
info, err = os.Stat(dirName)
|
info, err = os.Stat(dirName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -92,7 +92,7 @@ func TestHandleBackupDir_AlreadyExists_No_Override(t *testing.T) {
|
|||||||
|
|
||||||
func TestHandleBackupDir_NewDir(t *testing.T) {
|
func TestHandleBackupDir_NewDir(t *testing.T) {
|
||||||
dirName := t.TempDir() + "somedir"
|
dirName := t.TempDir() + "somedir"
|
||||||
require.NoError(t, fileutil.HandleBackupDir(dirName, true))
|
require.NoError(t, file.HandleBackupDir(dirName, true))
|
||||||
info, err := os.Stat(dirName)
|
info, err := os.Stat(dirName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, "drwx------", info.Mode().String())
|
assert.Equal(t, "drwx------", info.Mode().String())
|
||||||
@ -100,9 +100,9 @@ func TestHandleBackupDir_NewDir(t *testing.T) {
|
|||||||
|
|
||||||
func TestMkdirAll_OK(t *testing.T) {
|
func TestMkdirAll_OK(t *testing.T) {
|
||||||
dirName := t.TempDir() + "somedir"
|
dirName := t.TempDir() + "somedir"
|
||||||
err := fileutil.MkdirAll(dirName)
|
err := file.MkdirAll(dirName)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
exists, err := fileutil.HasDir(dirName)
|
exists, err := file.HasDir(dirName)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, true, exists)
|
assert.Equal(t, true, exists)
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ func TestWriteFile_AlreadyExists_WrongPermissions(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
someFileName := filepath.Join(dirName, "somefile.txt")
|
someFileName := filepath.Join(dirName, "somefile.txt")
|
||||||
require.NoError(t, ioutil.WriteFile(someFileName, []byte("hi"), os.ModePerm))
|
require.NoError(t, ioutil.WriteFile(someFileName, []byte("hi"), os.ModePerm))
|
||||||
err = fileutil.WriteFile(someFileName, []byte("hi"))
|
err = file.WriteFile(someFileName, []byte("hi"))
|
||||||
assert.ErrorContains(t, "already exists without proper 0600 permissions", err)
|
assert.ErrorContains(t, "already exists without proper 0600 permissions", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ func TestWriteFile_AlreadyExists_OK(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
someFileName := filepath.Join(dirName, "somefile.txt")
|
someFileName := filepath.Join(dirName, "somefile.txt")
|
||||||
require.NoError(t, ioutil.WriteFile(someFileName, []byte("hi"), params.BeaconIoConfig().ReadWritePermissions))
|
require.NoError(t, ioutil.WriteFile(someFileName, []byte("hi"), params.BeaconIoConfig().ReadWritePermissions))
|
||||||
assert.NoError(t, fileutil.WriteFile(someFileName, []byte("hi")))
|
assert.NoError(t, file.WriteFile(someFileName, []byte("hi")))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestWriteFile_OK(t *testing.T) {
|
func TestWriteFile_OK(t *testing.T) {
|
||||||
@ -131,8 +131,8 @@ func TestWriteFile_OK(t *testing.T) {
|
|||||||
err := os.MkdirAll(dirName, os.ModePerm)
|
err := os.MkdirAll(dirName, os.ModePerm)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
someFileName := filepath.Join(dirName, "somefile.txt")
|
someFileName := filepath.Join(dirName, "somefile.txt")
|
||||||
require.NoError(t, fileutil.WriteFile(someFileName, []byte("hi")))
|
require.NoError(t, file.WriteFile(someFileName, []byte("hi")))
|
||||||
exists := fileutil.FileExists(someFileName)
|
exists := file.FileExists(someFileName)
|
||||||
assert.Equal(t, true, exists)
|
assert.Equal(t, true, exists)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ func TestCopyFile(t *testing.T) {
|
|||||||
err := ioutil.WriteFile(fName, []byte{1, 2, 3}, params.BeaconIoConfig().ReadWritePermissions)
|
err := ioutil.WriteFile(fName, []byte{1, 2, 3}, params.BeaconIoConfig().ReadWritePermissions)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
err = fileutil.CopyFile(fName, fName+"copy")
|
err = file.CopyFile(fName, fName+"copy")
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
defer func() {
|
defer func() {
|
||||||
assert.NoError(t, os.Remove(fName+"copy"))
|
assert.NoError(t, os.Remove(fName+"copy"))
|
||||||
@ -182,64 +182,64 @@ func TestCopyDir(t *testing.T) {
|
|||||||
require.NoError(t, os.MkdirAll(filepath.Join(tmpDir1, "subfolder1"), 0777))
|
require.NoError(t, os.MkdirAll(filepath.Join(tmpDir1, "subfolder1"), 0777))
|
||||||
require.NoError(t, os.MkdirAll(filepath.Join(tmpDir1, "subfolder2"), 0777))
|
require.NoError(t, os.MkdirAll(filepath.Join(tmpDir1, "subfolder2"), 0777))
|
||||||
for _, fd := range fds {
|
for _, fd := range fds {
|
||||||
require.NoError(t, fileutil.WriteFile(filepath.Join(tmpDir1, fd.path), fd.content))
|
require.NoError(t, file.WriteFile(filepath.Join(tmpDir1, fd.path), fd.content))
|
||||||
assert.Equal(t, true, fileutil.FileExists(filepath.Join(tmpDir1, fd.path)))
|
assert.Equal(t, true, file.FileExists(filepath.Join(tmpDir1, fd.path)))
|
||||||
assert.Equal(t, false, fileutil.FileExists(filepath.Join(tmpDir2, fd.path)))
|
assert.Equal(t, false, file.FileExists(filepath.Join(tmpDir2, fd.path)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure that files are copied into non-existent directory only. If directory exists function exits.
|
// Make sure that files are copied into non-existent directory only. If directory exists function exits.
|
||||||
assert.ErrorContains(t, "destination directory already exists", fileutil.CopyDir(tmpDir1, t.TempDir()))
|
assert.ErrorContains(t, "destination directory already exists", file.CopyDir(tmpDir1, t.TempDir()))
|
||||||
require.NoError(t, fileutil.CopyDir(tmpDir1, tmpDir2))
|
require.NoError(t, file.CopyDir(tmpDir1, tmpDir2))
|
||||||
|
|
||||||
// Now, all files should have been copied.
|
// Now, all files should have been copied.
|
||||||
for _, fd := range fds {
|
for _, fd := range fds {
|
||||||
assert.Equal(t, true, fileutil.FileExists(filepath.Join(tmpDir2, fd.path)))
|
assert.Equal(t, true, file.FileExists(filepath.Join(tmpDir2, fd.path)))
|
||||||
assert.Equal(t, true, deepCompare(t, filepath.Join(tmpDir1, fd.path), filepath.Join(tmpDir2, fd.path)))
|
assert.Equal(t, true, deepCompare(t, filepath.Join(tmpDir1, fd.path), filepath.Join(tmpDir2, fd.path)))
|
||||||
}
|
}
|
||||||
assert.Equal(t, true, fileutil.DirsEqual(tmpDir1, tmpDir2))
|
assert.Equal(t, true, file.DirsEqual(tmpDir1, tmpDir2))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDirsEqual(t *testing.T) {
|
func TestDirsEqual(t *testing.T) {
|
||||||
t.Run("non-existent source directory", func(t *testing.T) {
|
t.Run("non-existent source directory", func(t *testing.T) {
|
||||||
assert.Equal(t, false, fileutil.DirsEqual(filepath.Join(t.TempDir(), "nonexistent"), t.TempDir()))
|
assert.Equal(t, false, file.DirsEqual(filepath.Join(t.TempDir(), "nonexistent"), t.TempDir()))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("non-existent dest directory", func(t *testing.T) {
|
t.Run("non-existent dest directory", func(t *testing.T) {
|
||||||
assert.Equal(t, false, fileutil.DirsEqual(t.TempDir(), filepath.Join(t.TempDir(), "nonexistent")))
|
assert.Equal(t, false, file.DirsEqual(t.TempDir(), filepath.Join(t.TempDir(), "nonexistent")))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("non-empty directory", func(t *testing.T) {
|
t.Run("non-empty directory", func(t *testing.T) {
|
||||||
// Start with directories that do not have the same contents.
|
// Start with directories that do not have the same contents.
|
||||||
tmpDir1, tmpFileNames := tmpDirWithContents(t)
|
tmpDir1, tmpFileNames := tmpDirWithContents(t)
|
||||||
tmpDir2 := filepath.Join(t.TempDir(), "newfolder")
|
tmpDir2 := filepath.Join(t.TempDir(), "newfolder")
|
||||||
assert.Equal(t, false, fileutil.DirsEqual(tmpDir1, tmpDir2))
|
assert.Equal(t, false, file.DirsEqual(tmpDir1, tmpDir2))
|
||||||
|
|
||||||
// Copy dir, and retest (hashes should match now).
|
// Copy dir, and retest (hashes should match now).
|
||||||
require.NoError(t, fileutil.CopyDir(tmpDir1, tmpDir2))
|
require.NoError(t, file.CopyDir(tmpDir1, tmpDir2))
|
||||||
assert.Equal(t, true, fileutil.DirsEqual(tmpDir1, tmpDir2))
|
assert.Equal(t, true, file.DirsEqual(tmpDir1, tmpDir2))
|
||||||
|
|
||||||
// Tamper the data, make sure that hashes do not match anymore.
|
// Tamper the data, make sure that hashes do not match anymore.
|
||||||
require.NoError(t, os.Remove(filepath.Join(tmpDir1, tmpFileNames[2])))
|
require.NoError(t, os.Remove(filepath.Join(tmpDir1, tmpFileNames[2])))
|
||||||
assert.Equal(t, false, fileutil.DirsEqual(tmpDir1, tmpDir2))
|
assert.Equal(t, false, file.DirsEqual(tmpDir1, tmpDir2))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHashDir(t *testing.T) {
|
func TestHashDir(t *testing.T) {
|
||||||
t.Run("non-existent directory", func(t *testing.T) {
|
t.Run("non-existent directory", func(t *testing.T) {
|
||||||
hash, err := fileutil.HashDir(filepath.Join(t.TempDir(), "nonexistent"))
|
hash, err := file.HashDir(filepath.Join(t.TempDir(), "nonexistent"))
|
||||||
assert.ErrorContains(t, "no such file or directory", err)
|
assert.ErrorContains(t, "no such file or directory", err)
|
||||||
assert.Equal(t, "", hash)
|
assert.Equal(t, "", hash)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("empty directory", func(t *testing.T) {
|
t.Run("empty directory", func(t *testing.T) {
|
||||||
hash, err := fileutil.HashDir(t.TempDir())
|
hash, err := file.HashDir(t.TempDir())
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, "hashdir:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=", hash)
|
assert.Equal(t, "hashdir:47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=", hash)
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("non-empty directory", func(t *testing.T) {
|
t.Run("non-empty directory", func(t *testing.T) {
|
||||||
tmpDir, _ := tmpDirWithContents(t)
|
tmpDir, _ := tmpDirWithContents(t)
|
||||||
hash, err := fileutil.HashDir(tmpDir)
|
hash, err := file.HashDir(tmpDir)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, "hashdir:oSp9wRacwTIrnbgJWcwTvihHfv4B2zRbLYa0GZ7DDk0=", hash)
|
assert.Equal(t, "hashdir:oSp9wRacwTIrnbgJWcwTvihHfv4B2zRbLYa0GZ7DDk0=", hash)
|
||||||
})
|
})
|
||||||
@ -266,7 +266,7 @@ func TestDirFiles(t *testing.T) {
|
|||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
outFiles, err := fileutil.DirFiles(tt.path)
|
outFiles, err := file.DirFiles(tt.path)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
sort.Strings(outFiles)
|
sort.Strings(outFiles)
|
||||||
@ -317,7 +317,7 @@ func TestRecursiveFileFind(t *testing.T) {
|
|||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
found, _, err := fileutil.RecursiveFileFind(tt.name, tt.root)
|
found, _, err := file.RecursiveFileFind(tt.name, tt.root)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
assert.DeepEqual(t, tt.found, found)
|
assert.DeepEqual(t, tt.found, found)
|
||||||
@ -421,7 +421,7 @@ func TestHasReadWritePermissions(t *testing.T) {
|
|||||||
t.Fatalf("Could not delete temp dir: %v", err)
|
t.Fatalf("Could not delete temp dir: %v", err)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
got, err := fileutil.HasReadWritePermissions(fullPath)
|
got, err := file.HasReadWritePermissions(fullPath)
|
||||||
if (err != nil) != tt.wantErr {
|
if (err != nil) != tt.wantErr {
|
||||||
t.Errorf("HasReadWritePermissions() error = %v, wantErr %v", err, tt.wantErr)
|
t.Errorf("HasReadWritePermissions() error = %v, wantErr %v", err, tt.wantErr)
|
||||||
return
|
return
|
@ -6,7 +6,7 @@ go_library(
|
|||||||
"logutil.go",
|
"logutil.go",
|
||||||
"stream.go",
|
"stream.go",
|
||||||
],
|
],
|
||||||
importpath = "github.com/prysmaticlabs/prysm/shared/logutil",
|
importpath = "github.com/prysmaticlabs/prysm/io/logs",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//cache/lru:go_default_library",
|
"//cache/lru:go_default_library",
|
@ -1,6 +1,6 @@
|
|||||||
// Package logutil creates a Multi writer instance that
|
// Package logs creates a Multi writer instance that
|
||||||
// write all logs that are written to stdout.
|
// write all logs that are written to stdout.
|
||||||
package logutil
|
package logs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
@ -1,4 +1,4 @@
|
|||||||
package logutil
|
package logs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
@ -1,4 +1,4 @@
|
|||||||
package logutil
|
package logs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
@ -1,4 +1,4 @@
|
|||||||
package logutil
|
package logs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
@ -6,10 +6,10 @@ go_library(
|
|||||||
"prompt.go",
|
"prompt.go",
|
||||||
"validate.go",
|
"validate.go",
|
||||||
],
|
],
|
||||||
importpath = "github.com/prysmaticlabs/prysm/shared/promptutil",
|
importpath = "github.com/prysmaticlabs/prysm/io/prompt",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//shared/fileutil:go_default_library",
|
"//io/file:go_default_library",
|
||||||
"@com_github_logrusorgru_aurora//:go_default_library",
|
"@com_github_logrusorgru_aurora//:go_default_library",
|
||||||
"@com_github_nbutton23_zxcvbn_go//:go_default_library",
|
"@com_github_nbutton23_zxcvbn_go//:go_default_library",
|
||||||
"@com_github_pkg_errors//:go_default_library",
|
"@com_github_pkg_errors//:go_default_library",
|
@ -1,4 +1,4 @@
|
|||||||
package promptutil
|
package prompt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/logrusorgru/aurora"
|
"github.com/logrusorgru/aurora"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
@ -128,7 +128,7 @@ func InputPassword(
|
|||||||
) (string, error) {
|
) (string, error) {
|
||||||
if cliCtx.IsSet(passwordFileFlag.Name) {
|
if cliCtx.IsSet(passwordFileFlag.Name) {
|
||||||
passwordFilePathInput := cliCtx.String(passwordFileFlag.Name)
|
passwordFilePathInput := cliCtx.String(passwordFileFlag.Name)
|
||||||
passwordFilePath, err := fileutil.ExpandPath(passwordFilePathInput)
|
passwordFilePath, err := file.ExpandPath(passwordFilePathInput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errors.Wrap(err, "could not determine absolute path of password file")
|
return "", errors.Wrap(err, "could not determine absolute path of password file")
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package promptutil
|
package prompt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
@ -1,4 +1,4 @@
|
|||||||
package promptutil
|
package prompt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
@ -3,7 +3,7 @@ load("@prysm//tools/go:def.bzl", "go_library", "go_test")
|
|||||||
go_library(
|
go_library(
|
||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = ["math_helper.go"],
|
srcs = ["math_helper.go"],
|
||||||
importpath = "github.com/prysmaticlabs/prysm/shared/mathutil",
|
importpath = "github.com/prysmaticlabs/prysm/math",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = ["@com_github_thomaso_mirodin_intmath//u64:go_default_library"],
|
deps = ["@com_github_thomaso_mirodin_intmath//u64:go_default_library"],
|
||||||
)
|
)
|
@ -1,9 +1,9 @@
|
|||||||
// Package mathutil includes important helpers for Ethereum such as fast integer square roots.
|
// Package math includes important helpers for Ethereum such as fast integer square roots.
|
||||||
package mathutil
|
package math
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"math"
|
stdmath "math"
|
||||||
"math/bits"
|
"math/bits"
|
||||||
|
|
||||||
"github.com/thomaso-mirodin/intmath/u64"
|
"github.com/thomaso-mirodin/intmath/u64"
|
||||||
@ -37,7 +37,7 @@ func IntegerSquareRoot(n uint64) uint64 {
|
|||||||
return u64.Sqrt(n)
|
return u64.Sqrt(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
return uint64(math.Sqrt(float64(n)))
|
return uint64(stdmath.Sqrt(float64(n)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// CeilDiv8 divides the input number by 8
|
// CeilDiv8 divides the input number by 8
|
@ -1,10 +1,10 @@
|
|||||||
package mathutil_test
|
package math_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math"
|
stdmath "math"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -80,28 +80,28 @@ func TestIntegerSquareRoot(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, testVals := range tt {
|
for _, testVals := range tt {
|
||||||
require.Equal(t, testVals.root, mathutil.IntegerSquareRoot(testVals.number))
|
require.Equal(t, testVals.root, math.IntegerSquareRoot(testVals.number))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkIntegerSquareRootBelow52Bits(b *testing.B) {
|
func BenchmarkIntegerSquareRootBelow52Bits(b *testing.B) {
|
||||||
val := uint64(1 << 33)
|
val := uint64(1 << 33)
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
require.Equal(b, uint64(92681), mathutil.IntegerSquareRoot(val))
|
require.Equal(b, uint64(92681), math.IntegerSquareRoot(val))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkIntegerSquareRootAbove52Bits(b *testing.B) {
|
func BenchmarkIntegerSquareRootAbove52Bits(b *testing.B) {
|
||||||
val := uint64(1 << 62)
|
val := uint64(1 << 62)
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
require.Equal(b, uint64(1<<31), mathutil.IntegerSquareRoot(val))
|
require.Equal(b, uint64(1<<31), math.IntegerSquareRoot(val))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkIntegerSquareRoot_WithDatatable(b *testing.B) {
|
func BenchmarkIntegerSquareRoot_WithDatatable(b *testing.B) {
|
||||||
val := uint64(1024)
|
val := uint64(1024)
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
require.Equal(b, uint64(32), mathutil.IntegerSquareRoot(val))
|
require.Equal(b, uint64(32), math.IntegerSquareRoot(val))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ func TestCeilDiv8(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
require.Equal(t, tt.div8, mathutil.CeilDiv8(tt.number))
|
require.Equal(t, tt.div8, math.CeilDiv8(tt.number))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ func TestIsPowerOf2(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
require.Equal(t, tt.b, mathutil.IsPowerOf2(tt.a))
|
require.Equal(t, tt.b, math.IsPowerOf2(tt.a))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ func TestPowerOf2(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
require.Equal(t, tt.b, mathutil.PowerOf2(tt.a))
|
require.Equal(t, tt.b, math.PowerOf2(tt.a))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ func TestMaxValue(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
require.Equal(t, tt.result, mathutil.Max(tt.a, tt.b))
|
require.Equal(t, tt.result, math.Max(tt.a, tt.b))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,7 +265,7 @@ func TestMinValue(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
require.Equal(t, tt.result, mathutil.Min(tt.a, tt.b))
|
require.Equal(t, tt.result, math.Min(tt.a, tt.b))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ func TestMul64(t *testing.T) {
|
|||||||
{args: args{1 << 63, 2}, res: 0, err: true},
|
{args: args{1 << 63, 2}, res: 0, err: true},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
got, err := mathutil.Mul64(tt.args.a, tt.args.b)
|
got, err := math.Mul64(tt.args.a, tt.args.b)
|
||||||
if tt.err && err == nil {
|
if tt.err && err == nil {
|
||||||
t.Errorf("Mul64() Expected Error = %v, want error", tt.err)
|
t.Errorf("Mul64() Expected Error = %v, want error", tt.err)
|
||||||
continue
|
continue
|
||||||
@ -317,12 +317,12 @@ func TestAdd64(t *testing.T) {
|
|||||||
{args: args{1 << 31, 1 << 31}, res: 4294967296, err: false},
|
{args: args{1 << 31, 1 << 31}, res: 4294967296, err: false},
|
||||||
{args: args{1 << 63, 1 << 63}, res: 0, err: true},
|
{args: args{1 << 63, 1 << 63}, res: 0, err: true},
|
||||||
{args: args{1 << 63, 1}, res: 9223372036854775809, err: false},
|
{args: args{1 << 63, 1}, res: 9223372036854775809, err: false},
|
||||||
{args: args{math.MaxUint64, 1}, res: 0, err: true},
|
{args: args{stdmath.MaxUint64, 1}, res: 0, err: true},
|
||||||
{args: args{math.MaxUint64, 0}, res: math.MaxUint64, err: false},
|
{args: args{stdmath.MaxUint64, 0}, res: stdmath.MaxUint64, err: false},
|
||||||
{args: args{1 << 63, 2}, res: 9223372036854775810, err: false},
|
{args: args{1 << 63, 2}, res: 9223372036854775810, err: false},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
got, err := mathutil.Add64(tt.args.a, tt.args.b)
|
got, err := math.Add64(tt.args.a, tt.args.b)
|
||||||
if tt.err && err == nil {
|
if tt.err && err == nil {
|
||||||
t.Errorf("Add64() Expected Error = %v, want error", tt.err)
|
t.Errorf("Add64() Expected Error = %v, want error", tt.err)
|
||||||
continue
|
continue
|
@ -151,7 +151,7 @@
|
|||||||
},
|
},
|
||||||
"exclude_files": {
|
"exclude_files": {
|
||||||
".*_test\\.go": "Tests are ok",
|
".*_test\\.go": "Tests are ok",
|
||||||
"shared/fileutil/fileutil.go": "Package which defines the proper rules"
|
"io/file/fileutil.go": "Package which defines the proper rules"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,9 @@ go_library(
|
|||||||
importpath = "github.com/prysmaticlabs/prysm/runtime/tos",
|
importpath = "github.com/prysmaticlabs/prysm/runtime/tos",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
|
"//io/file:go_default_library",
|
||||||
|
"//io/prompt:go_default_library",
|
||||||
"//shared/cmd:go_default_library",
|
"//shared/cmd:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
|
||||||
"//shared/promptutil:go_default_library",
|
|
||||||
"@com_github_logrusorgru_aurora//:go_default_library",
|
"@com_github_logrusorgru_aurora//:go_default_library",
|
||||||
"@com_github_sirupsen_logrus//:go_default_library",
|
"@com_github_sirupsen_logrus//:go_default_library",
|
||||||
"@com_github_urfave_cli_v2//:go_default_library",
|
"@com_github_urfave_cli_v2//:go_default_library",
|
||||||
|
@ -6,9 +6,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/logrusorgru/aurora"
|
"github.com/logrusorgru/aurora"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/prompt"
|
||||||
"github.com/prysmaticlabs/prysm/shared/cmd"
|
"github.com/prysmaticlabs/prysm/shared/cmd"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/promptutil"
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
@ -41,7 +41,7 @@ func VerifyTosAcceptedOrPrompt(ctx *cli.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if fileutil.FileExists(filepath.Join(ctx.String(cmd.DataDirFlag.Name), acceptTosFilename)) {
|
if file.FileExists(filepath.Join(ctx.String(cmd.DataDirFlag.Name), acceptTosFilename)) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if ctx.Bool(cmd.AcceptTosFlag.Name) {
|
if ctx.Bool(cmd.AcceptTosFlag.Name) {
|
||||||
@ -49,7 +49,7 @@ func VerifyTosAcceptedOrPrompt(ctx *cli.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
input, err := promptutil.DefaultPrompt(au.Bold(acceptTosPromptText).String(), "decline")
|
input, err := prompt.DefaultPrompt(au.Bold(acceptTosPromptText).String(), "decline")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New(acceptTosPromptErrText)
|
return errors.New(acceptTosPromptErrText)
|
||||||
}
|
}
|
||||||
@ -64,16 +64,16 @@ func VerifyTosAcceptedOrPrompt(ctx *cli.Context) error {
|
|||||||
// saveTosAccepted creates a file when Tos accepted.
|
// saveTosAccepted creates a file when Tos accepted.
|
||||||
func saveTosAccepted(ctx *cli.Context) {
|
func saveTosAccepted(ctx *cli.Context) {
|
||||||
dataDir := ctx.String(cmd.DataDirFlag.Name)
|
dataDir := ctx.String(cmd.DataDirFlag.Name)
|
||||||
dataDirExists, err := fileutil.HasDir(dataDir)
|
dataDirExists, err := file.HasDir(dataDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Warnf("error checking directory: %s", dataDir)
|
log.WithError(err).Warnf("error checking directory: %s", dataDir)
|
||||||
}
|
}
|
||||||
if !dataDirExists {
|
if !dataDirExists {
|
||||||
if err := fileutil.MkdirAll(dataDir); err != nil {
|
if err := file.MkdirAll(dataDir); err != nil {
|
||||||
log.WithError(err).Warnf("error creating directory: %s", dataDir)
|
log.WithError(err).Warnf("error creating directory: %s", dataDir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := fileutil.WriteFile(filepath.Join(dataDir, acceptTosFilename), []byte("")); err != nil {
|
if err := file.WriteFile(filepath.Join(dataDir, acceptTosFilename), []byte("")); err != nil {
|
||||||
log.WithError(err).Warnf("error writing %s to file: %s", cmd.AcceptTosFlag.Name,
|
log.WithError(err).Warnf("error writing %s to file: %s", cmd.AcceptTosFlag.Name,
|
||||||
filepath.Join(dataDir, acceptTosFilename))
|
filepath.Join(dataDir, acceptTosFilename))
|
||||||
}
|
}
|
||||||
|
@ -25,14 +25,14 @@ func TestVerifyTosAcceptedOrPrompt(t *testing.T) {
|
|||||||
os.Stdin = tmpfile
|
os.Stdin = tmpfile
|
||||||
defer func() { os.Stdin = origStdin }()
|
defer func() { os.Stdin = origStdin }()
|
||||||
|
|
||||||
// prompt decline
|
// userprompt decline
|
||||||
_, err = tmpfile.Write([]byte("decline"))
|
_, err = tmpfile.Write([]byte("decline"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, err = tmpfile.Seek(0, 0)
|
_, err = tmpfile.Seek(0, 0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.ErrorContains(t, "you have to accept Terms and Conditions", VerifyTosAcceptedOrPrompt(context))
|
require.ErrorContains(t, "you have to accept Terms and Conditions", VerifyTosAcceptedOrPrompt(context))
|
||||||
|
|
||||||
// prompt accept
|
// userprompt accept
|
||||||
err = tmpfile.Truncate(0)
|
err = tmpfile.Truncate(0)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, err = tmpfile.Seek(0, 0)
|
_, err = tmpfile.Seek(0, 0)
|
||||||
|
@ -14,7 +14,7 @@ go_library(
|
|||||||
importpath = "github.com/prysmaticlabs/prysm/shared/cmd",
|
importpath = "github.com/prysmaticlabs/prysm/shared/cmd",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"//shared/fileutil:go_default_library",
|
"//io/file:go_default_library",
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"@com_github_golang_mock//gomock:go_default_library",
|
"@com_github_golang_mock//gomock:go_default_library",
|
||||||
"@com_github_pkg_errors//:go_default_library",
|
"@com_github_pkg_errors//:go_default_library",
|
||||||
|
@ -22,14 +22,14 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultDataDir is the default data directory to use for the databases and other
|
// DefaultDataDir is the default data directory to use for the databases and other
|
||||||
// persistence requirements.
|
// persistence requirements.
|
||||||
func DefaultDataDir() string {
|
func DefaultDataDir() string {
|
||||||
// Try to place the data folder in the user's home dir
|
// Try to place the data folder in the user's home dir
|
||||||
home := fileutil.HomeDir()
|
home := file.HomeDir()
|
||||||
if home != "" {
|
if home != "" {
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
return filepath.Join(home, "Library", "Eth2")
|
return filepath.Join(home, "Library", "Eth2")
|
||||||
@ -52,17 +52,17 @@ func FixDefaultDataDir(prevDataDir, curDataDir string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clean paths.
|
// Clean paths.
|
||||||
prevDataDir, err := fileutil.ExpandPath(prevDataDir)
|
prevDataDir, err := file.ExpandPath(prevDataDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
curDataDir, err = fileutil.ExpandPath(curDataDir)
|
curDataDir, err = file.ExpandPath(curDataDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if shared directory is found (if it is -- we need to move it to non-shared destination).
|
// See if shared directory is found (if it is -- we need to move it to non-shared destination).
|
||||||
prevDataDirExists, err := fileutil.HasDir(prevDataDir)
|
prevDataDirExists, err := file.HasDir(prevDataDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ func FixDefaultDataDir(prevDataDir, curDataDir string) error {
|
|||||||
if curDataDir == "" {
|
if curDataDir == "" {
|
||||||
curDataDir = DefaultDataDir()
|
curDataDir = DefaultDataDir()
|
||||||
}
|
}
|
||||||
selectedDirExists, err := fileutil.HasDir(curDataDir)
|
selectedDirExists, err := file.HasDir(curDataDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ func FixDefaultDataDir(prevDataDir, curDataDir string) error {
|
|||||||
|
|
||||||
log.Warnf("Outdated data directory is found: %s. "+
|
log.Warnf("Outdated data directory is found: %s. "+
|
||||||
"Copying its contents to the new data folder: %s", prevDataDir, curDataDir)
|
"Copying its contents to the new data folder: %s", prevDataDir, curDataDir)
|
||||||
if err := fileutil.CopyDir(prevDataDir, curDataDir); err != nil {
|
if err := file.CopyDir(prevDataDir, curDataDir); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Infof("All files from the outdated data directory %s have been moved to %s.", prevDataDir, curDataDir)
|
log.Infof("All files from the outdated data directory %s have been moved to %s.", prevDataDir, curDataDir)
|
||||||
@ -107,7 +107,7 @@ func FixDefaultDataDir(prevDataDir, curDataDir string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if removeConfirmed && fileutil.DirsEqual(prevDataDir, curDataDir) {
|
if removeConfirmed && file.DirsEqual(prevDataDir, curDataDir) {
|
||||||
if err := os.RemoveAll(prevDataDir); err != nil {
|
if err := os.RemoveAll(prevDataDir); err != nil {
|
||||||
return fmt.Errorf("cannot remove outdated directory or one of its files: %w", err)
|
return fmt.Errorf("cannot remove outdated directory or one of its files: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
@ -86,7 +86,7 @@ func ExpandSingleEndpointIfFile(ctx *cli.Context, flag *cli.StringFlag) error {
|
|||||||
case strings.HasPrefix(web3endpoint, "ws://"):
|
case strings.HasPrefix(web3endpoint, "ws://"):
|
||||||
case strings.HasPrefix(web3endpoint, "wss://"):
|
case strings.HasPrefix(web3endpoint, "wss://"):
|
||||||
default:
|
default:
|
||||||
web3endpoint, err := fileutil.ExpandPath(ctx.String(flag.Name))
|
web3endpoint, err := file.ExpandPath(ctx.String(flag.Name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "could not expand path for %s", web3endpoint)
|
return errors.Wrapf(err, "could not expand path for %s", web3endpoint)
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ func ExpandWeb3EndpointsIfFile(ctx *cli.Context, flags *cli.StringSliceFlag) err
|
|||||||
case strings.HasPrefix(rawValue, "ws://"):
|
case strings.HasPrefix(rawValue, "ws://"):
|
||||||
case strings.HasPrefix(rawValue, "wss://"):
|
case strings.HasPrefix(rawValue, "wss://"):
|
||||||
default:
|
default:
|
||||||
web3endpoint, err := fileutil.ExpandPath(rawValue)
|
web3endpoint, err := file.ExpandPath(rawValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "could not expand path for %s", rawValue)
|
return errors.Wrapf(err, "could not expand path for %s", rawValue)
|
||||||
}
|
}
|
||||||
|
@ -20,8 +20,8 @@ go_library(
|
|||||||
importpath = "github.com/prysmaticlabs/prysm/shared/params",
|
importpath = "github.com/prysmaticlabs/prysm/shared/params",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
|
"//math:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/mathutil:go_default_library",
|
|
||||||
"@com_github_ethereum_go_ethereum//params:go_default_library",
|
"@com_github_ethereum_go_ethereum//params:go_default_library",
|
||||||
"@com_github_mohae_deepcopy//:go_default_library",
|
"@com_github_mohae_deepcopy//:go_default_library",
|
||||||
"@com_github_prysmaticlabs_eth2_types//:go_default_library",
|
"@com_github_prysmaticlabs_eth2_types//:go_default_library",
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
types "github.com/prysmaticlabs/eth2-types"
|
types "github.com/prysmaticlabs/eth2-types"
|
||||||
"github.com/prysmaticlabs/prysm/shared/mathutil"
|
"github.com/prysmaticlabs/prysm/math"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
@ -45,7 +45,7 @@ func LoadChainConfigFile(chainConfigFileName string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// recompute SqrRootSlotsPerEpoch constant to handle non-standard values of SlotsPerEpoch
|
// recompute SqrRootSlotsPerEpoch constant to handle non-standard values of SlotsPerEpoch
|
||||||
conf.SqrRootSlotsPerEpoch = types.Slot(mathutil.IntegerSquareRoot(uint64(conf.SlotsPerEpoch)))
|
conf.SqrRootSlotsPerEpoch = types.Slot(math.IntegerSquareRoot(uint64(conf.SlotsPerEpoch)))
|
||||||
log.Debugf("Config file values: %+v", conf)
|
log.Debugf("Config file values: %+v", conf)
|
||||||
OverrideBeaconConfig(conf)
|
OverrideBeaconConfig(conf)
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
adjectives = []string{"able", "above", "absolute", "accepted", "accurate", "ace", "active", "actual", "adapted", "adapting", "adequate", "adjusted", "advanced", "alert", "alive", "allowed", "allowing", "amazed", "amazing", "ample", "amused", "amusing", "apparent", "apt", "arriving", "artistic", "assured", "assuring", "awaited", "awake", "aware", "balanced", "becoming", "beloved", "better", "big", "blessed", "bold", "boss", "brave", "brief", "bright", "bursting", "busy", "calm", "capable", "capital", "careful", "caring", "casual", "causal", "central", "certain", "champion", "charmed", "charming", "cheerful", "chief", "choice", "civil", "classic", "clean", "clear", "clever", "climbing", "close", "closing", "coherent", "comic", "communal", "complete", "composed", "concise", "concrete", "content", "cool", "correct", "cosmic", "crack", "creative", "credible", "crisp", "crucial", "cuddly", "cunning", "curious", "current", "cute", "daring", "darling", "dashing", "dear", "decent", "deciding", "deep", "definite", "delicate", "desired", "destined", "devoted", "direct", "discrete", "distinct", "diverse", "divine", "dominant", "driven", "driving", "dynamic", "eager", "easy", "electric", "elegant", "emerging", "eminent", "enabled", "enabling", "endless", "engaged", "engaging", "enhanced", "enjoyed", "enormous", "enough", "epic", "equal", "equipped", "eternal", "ethical", "evident", "evolved", "evolving", "exact", "excited", "exciting", "exotic", "expert", "factual", "fair", "faithful", "famous", "fancy", "fast", "feasible", "fine", "finer", "firm", "first", "fit", "fitting", "fleet", "flexible", "flowing", "fluent", "flying", "fond", "frank", "free", "fresh", "full", "fun", "funky", "funny", "game", "generous", "gentle", "genuine", "giving", "glad", "glorious", "glowing", "golden", "good", "gorgeous", "grand", "grateful", "great", "growing", "grown", "guided", "guiding", "handy", "happy", "hardy", "harmless", "healthy", "helped", "helpful", "helping", "heroic", "hip", "holy", "honest", "hopeful", "hot", "huge", "humane", "humble", "humorous", "ideal", "immense", "immortal", "immune", "improved", "in", "included", "infinite", "informed", "innocent", "inspired", "integral", "intense", "intent", "internal", "intimate", "inviting", "joint", "just", "keen", "key", "kind", "knowing", "known", "large", "lasting", "leading", "learning", "legal", "legible", "lenient", "liberal", "light", "liked", "literate", "live", "living", "logical", "loved", "loving", "loyal", "lucky", "magical", "magnetic", "main", "major", "many", "massive", "master", "mature", "maximum", "measured", "meet", "merry", "mighty", "mint", "model", "modern", "modest", "moral", "more", "moved", "moving", "musical", "mutual", "national", "native", "natural", "nearby", "neat", "needed", "neutral", "new", "next", "nice", "noble", "normal", "notable", "noted", "novel", "obliging", "on", "one", "open", "optimal", "optimum", "organic", "oriented", "outgoing", "patient", "peaceful", "perfect", "pet", "picked", "pleasant", "pleased", "pleasing", "poetic", "polished", "polite", "popular", "positive", "possible", "powerful", "precious", "precise", "premium", "prepared", "present", "pretty", "primary", "prime", "pro", "probable", "profound", "promoted", "prompt", "proper", "proud", "proven", "pumped", "pure", "quality", "quick", "quiet", "rapid", "rare", "rational", "ready", "real", "refined", "regular", "related", "relative", "relaxed", "relaxing", "relevant", "relieved", "renewed", "renewing", "resolved", "rested", "rich", "right", "robust", "romantic", "ruling", "sacred", "safe", "saved", "saving", "secure", "select", "selected", "sensible", "set", "settled", "settling", "sharing", "sharp", "shining", "simple", "sincere", "singular", "skilled", "smart", "smashing", "smiling", "smooth", "social", "solid", "sought", "sound", "special", "splendid", "square", "stable", "star", "steady", "sterling", "still", "stirred", "stirring", "striking", "strong", "stunning", "subtle", "suitable", "suited", "summary", "sunny", "super", "superb", "supreme", "sure", "sweeping", "sweet", "talented", "teaching", "tender", "thankful", "thorough", "tidy", "tight", "together", "tolerant", "top", "topical", "tops", "touched", "touching", "tough", "true", "trusted", "trusting", "trusty", "ultimate", "unbiased", "uncommon", "unified", "unique", "united", "up", "upright", "upward", "usable", "useful", "valid", "valued", "vast", "verified", "viable", "vital", "vocal", "wanted", "warm", "wealthy", "welcome", "welcomed", "well", "whole", "willing", "winning", "wired", "wise", "witty", "wondrous", "workable", "working", "worthy"}
|
adjectives = []string{"able", "above", "absolute", "accepted", "accurate", "ace", "active", "actual", "adapted", "adapting", "adequate", "adjusted", "advanced", "alert", "alive", "allowed", "allowing", "amazed", "amazing", "ample", "amused", "amusing", "apparent", "apt", "arriving", "artistic", "assured", "assuring", "awaited", "awake", "aware", "balanced", "becoming", "beloved", "better", "big", "blessed", "bold", "boss", "brave", "brief", "bright", "bursting", "busy", "calm", "capable", "capital", "careful", "caring", "casual", "causal", "central", "certain", "champion", "charmed", "charming", "cheerful", "chief", "choice", "civil", "classic", "clean", "clear", "clever", "climbing", "close", "closing", "coherent", "comic", "communal", "complete", "composed", "concise", "concrete", "content", "cool", "correct", "cosmic", "crack", "creative", "credible", "crisp", "crucial", "cuddly", "cunning", "curious", "current", "cute", "daring", "darling", "dashing", "dear", "decent", "deciding", "deep", "definite", "delicate", "desired", "destined", "devoted", "direct", "discrete", "distinct", "diverse", "divine", "dominant", "driven", "driving", "dynamic", "eager", "easy", "electric", "elegant", "emerging", "eminent", "enabled", "enabling", "endless", "engaged", "engaging", "enhanced", "enjoyed", "enormous", "enough", "epic", "equal", "equipped", "eternal", "ethical", "evident", "evolved", "evolving", "exact", "excited", "exciting", "exotic", "expert", "factual", "fair", "faithful", "famous", "fancy", "fast", "feasible", "fine", "finer", "firm", "first", "fit", "fitting", "fleet", "flexible", "flowing", "fluent", "flying", "fond", "frank", "free", "fresh", "full", "fun", "funky", "funny", "game", "generous", "gentle", "genuine", "giving", "glad", "glorious", "glowing", "golden", "good", "gorgeous", "grand", "grateful", "great", "growing", "grown", "guided", "guiding", "handy", "happy", "hardy", "harmless", "healthy", "helped", "helpful", "helping", "heroic", "hip", "holy", "honest", "hopeful", "hot", "huge", "humane", "humble", "humorous", "ideal", "immense", "immortal", "immune", "improved", "in", "included", "infinite", "informed", "innocent", "inspired", "integral", "intense", "intent", "internal", "intimate", "inviting", "joint", "just", "keen", "key", "kind", "knowing", "known", "large", "lasting", "leading", "learning", "legal", "legible", "lenient", "liberal", "light", "liked", "literate", "live", "living", "logical", "loved", "loving", "loyal", "lucky", "magical", "magnetic", "main", "major", "many", "massive", "master", "mature", "maximum", "measured", "meet", "merry", "mighty", "mint", "model", "modern", "modest", "moral", "more", "moved", "moving", "musical", "mutual", "national", "native", "natural", "nearby", "neat", "needed", "neutral", "new", "next", "nice", "noble", "normal", "notable", "noted", "novel", "obliging", "on", "one", "open", "optimal", "optimum", "organic", "oriented", "outgoing", "patient", "peaceful", "perfect", "pet", "picked", "pleasant", "pleased", "pleasing", "poetic", "polished", "polite", "popular", "positive", "possible", "powerful", "precious", "precise", "premium", "prepared", "present", "pretty", "primary", "prime", "pro", "probable", "profound", "promoted", "userprompt", "proper", "proud", "proven", "pumped", "pure", "quality", "quick", "quiet", "rapid", "rare", "rational", "ready", "real", "refined", "regular", "related", "relative", "relaxed", "relaxing", "relevant", "relieved", "renewed", "renewing", "resolved", "rested", "rich", "right", "robust", "romantic", "ruling", "sacred", "safe", "saved", "saving", "secure", "select", "selected", "sensible", "set", "settled", "settling", "sharing", "sharp", "shining", "simple", "sincere", "singular", "skilled", "smart", "smashing", "smiling", "smooth", "social", "solid", "sought", "sound", "special", "splendid", "square", "stable", "star", "steady", "sterling", "still", "stirred", "stirring", "striking", "strong", "stunning", "subtle", "suitable", "suited", "summary", "sunny", "super", "superb", "supreme", "sure", "sweeping", "sweet", "talented", "teaching", "tender", "thankful", "thorough", "tidy", "tight", "together", "tolerant", "top", "topical", "tops", "touched", "touching", "tough", "true", "trusted", "trusting", "trusty", "ultimate", "unbiased", "uncommon", "unified", "unique", "united", "up", "upright", "upward", "usable", "useful", "valid", "valued", "vast", "verified", "viable", "vital", "vocal", "wanted", "warm", "wealthy", "welcome", "welcomed", "well", "whole", "willing", "winning", "wired", "wise", "witty", "wondrous", "workable", "working", "worthy"}
|
||||||
adverbs = []string{"abnormally", "absolutely", "accurately", "actively", "actually", "adequately", "admittedly", "adversely", "allegedly", "amazingly", "annually", "apparently", "arguably", "awfully", "badly", "barely", "basically", "blatantly", "blindly", "briefly", "brightly", "broadly", "carefully", "centrally", "certainly", "cheaply", "cleanly", "clearly", "closely", "commonly", "completely", "constantly", "conversely", "correctly", "curiously", "currently", "daily", "deadly", "deeply", "definitely", "directly", "distinctly", "duly", "eagerly", "early", "easily", "eminently", "endlessly", "enormously", "entirely", "equally", "especially", "evenly", "evidently", "exactly", "explicitly", "externally", "extremely", "factually", "fairly", "finally", "firmly", "firstly", "forcibly", "formally", "formerly", "frankly", "freely", "frequently", "friendly", "fully", "generally", "gently", "genuinely", "ghastly", "gladly", "globally", "gradually", "gratefully", "greatly", "grossly", "happily", "hardly", "heartily", "heavily", "hideously", "highly", "honestly", "hopefully", "hopelessly", "horribly", "hugely", "humbly", "ideally", "illegally", "immensely", "implicitly", "incredibly", "indirectly", "infinitely", "informally", "inherently", "initially", "instantly", "intensely", "internally", "jointly", "jolly", "kindly", "largely", "lately", "legally", "lightly", "likely", "literally", "lively", "locally", "logically", "loosely", "loudly", "lovely", "luckily", "mainly", "manually", "marginally", "mentally", "merely", "mildly", "miserably", "mistakenly", "moderately", "monthly", "morally", "mostly", "multiply", "mutually", "namely", "nationally", "naturally", "nearly", "neatly", "needlessly", "newly", "nicely", "nominally", "normally", "notably", "noticeably", "obviously", "oddly", "officially", "only", "openly", "optionally", "overly", "painfully", "partially", "partly", "perfectly", "personally", "physically", "plainly", "pleasantly", "poorly", "positively", "possibly", "precisely", "preferably", "presently", "presumably", "previously", "primarily", "privately", "probably", "promptly", "properly", "publicly", "purely", "quickly", "quietly", "radically", "randomly", "rapidly", "rarely", "rationally", "readily", "really", "reasonably", "recently", "regularly", "reliably", "remarkably", "remotely", "repeatedly", "rightly", "roughly", "routinely", "sadly", "safely", "scarcely", "secondly", "secretly", "seemingly", "sensibly", "separately", "seriously", "severely", "sharply", "shortly", "similarly", "simply", "sincerely", "singularly", "slightly", "slowly", "smoothly", "socially", "solely", "specially", "steadily", "strangely", "strictly", "strongly", "subtly", "suddenly", "suitably", "supposedly", "surely", "terminally", "terribly", "thankfully", "thoroughly", "tightly", "totally", "trivially", "truly", "typically", "ultimately", "unduly", "uniformly", "uniquely", "unlikely", "urgently", "usefully", "usually", "utterly", "vaguely", "vastly", "verbally", "vertically", "vigorously", "violently", "virtually", "visually", "weekly", "wholly", "widely", "wildly", "willingly", "wrongly", "yearly"}
|
adverbs = []string{"abnormally", "absolutely", "accurately", "actively", "actually", "adequately", "admittedly", "adversely", "allegedly", "amazingly", "annually", "apparently", "arguably", "awfully", "badly", "barely", "basically", "blatantly", "blindly", "briefly", "brightly", "broadly", "carefully", "centrally", "certainly", "cheaply", "cleanly", "clearly", "closely", "commonly", "completely", "constantly", "conversely", "correctly", "curiously", "currently", "daily", "deadly", "deeply", "definitely", "directly", "distinctly", "duly", "eagerly", "early", "easily", "eminently", "endlessly", "enormously", "entirely", "equally", "especially", "evenly", "evidently", "exactly", "explicitly", "externally", "extremely", "factually", "fairly", "finally", "firmly", "firstly", "forcibly", "formally", "formerly", "frankly", "freely", "frequently", "friendly", "fully", "generally", "gently", "genuinely", "ghastly", "gladly", "globally", "gradually", "gratefully", "greatly", "grossly", "happily", "hardly", "heartily", "heavily", "hideously", "highly", "honestly", "hopefully", "hopelessly", "horribly", "hugely", "humbly", "ideally", "illegally", "immensely", "implicitly", "incredibly", "indirectly", "infinitely", "informally", "inherently", "initially", "instantly", "intensely", "internally", "jointly", "jolly", "kindly", "largely", "lately", "legally", "lightly", "likely", "literally", "lively", "locally", "logically", "loosely", "loudly", "lovely", "luckily", "mainly", "manually", "marginally", "mentally", "merely", "mildly", "miserably", "mistakenly", "moderately", "monthly", "morally", "mostly", "multiply", "mutually", "namely", "nationally", "naturally", "nearly", "neatly", "needlessly", "newly", "nicely", "nominally", "normally", "notably", "noticeably", "obviously", "oddly", "officially", "only", "openly", "optionally", "overly", "painfully", "partially", "partly", "perfectly", "personally", "physically", "plainly", "pleasantly", "poorly", "positively", "possibly", "precisely", "preferably", "presently", "presumably", "previously", "primarily", "privately", "probably", "promptly", "properly", "publicly", "purely", "quickly", "quietly", "radically", "randomly", "rapidly", "rarely", "rationally", "readily", "really", "reasonably", "recently", "regularly", "reliably", "remarkably", "remotely", "repeatedly", "rightly", "roughly", "routinely", "sadly", "safely", "scarcely", "secondly", "secretly", "seemingly", "sensibly", "separately", "seriously", "severely", "sharply", "shortly", "similarly", "simply", "sincerely", "singularly", "slightly", "slowly", "smoothly", "socially", "solely", "specially", "steadily", "strangely", "strictly", "strongly", "subtly", "suddenly", "suitably", "supposedly", "surely", "terminally", "terribly", "thankfully", "thoroughly", "tightly", "totally", "trivially", "truly", "typically", "ultimately", "unduly", "uniformly", "uniquely", "unlikely", "urgently", "usefully", "usually", "utterly", "vaguely", "vastly", "verbally", "vertically", "vigorously", "violently", "virtually", "visually", "weekly", "wholly", "widely", "wildly", "willingly", "wrongly", "yearly"}
|
||||||
names = []string{"ox", "ant", "ape", "asp", "bat", "bee", "boa", "bug", "cat", "cod", "cow", "cub", "doe", "dog", "eel", "eft", "elf", "elk", "emu", "ewe", "fly", "fox", "gar", "gnu", "hen", "hog", "imp", "jay", "kid", "kit", "koi", "lab", "man", "owl", "pig", "pug", "pup", "ram", "rat", "ray", "yak", "bass", "bear", "bird", "boar", "buck", "bull", "calf", "chow", "clam", "colt", "crab", "crow", "dane", "deer", "dodo", "dory", "dove", "drum", "duck", "fawn", "fish", "flea", "foal", "fowl", "frog", "gnat", "goat", "grub", "gull", "hare", "hawk", "ibex", "joey", "kite", "kiwi", "lamb", "lark", "lion", "loon", "lynx", "mako", "mink", "mite", "mole", "moth", "mule", "mutt", "newt", "orca", "oryx", "pika", "pony", "puma", "seal", "shad", "slug", "sole", "stag", "stud", "swan", "tahr", "teal", "tick", "toad", "tuna", "wasp", "wolf", "worm", "wren", "yeti", "adder", "akita", "alien", "aphid", "bison", "boxer", "bream", "bunny", "burro", "camel", "chimp", "civet", "cobra", "coral", "corgi", "crane", "dingo", "drake", "eagle", "egret", "filly", "finch", "gator", "gecko", "ghost", "ghoul", "goose", "guppy", "heron", "hippo", "horse", "hound", "husky", "hyena", "koala", "krill", "leech", "lemur", "liger", "llama", "louse", "macaw", "midge", "molly", "moose", "moray", "mouse", "panda", "perch", "prawn", "quail", "racer", "raven", "rhino", "robin", "satyr", "shark", "sheep", "shrew", "skink", "skunk", "sloth", "snail", "snake", "snipe", "squid", "stork", "swift", "swine", "tapir", "tetra", "tiger", "troll", "trout", "viper", "wahoo", "whale", "zebra", "alpaca", "amoeba", "baboon", "badger", "beagle", "bedbug", "beetle", "bengal", "bobcat", "caiman", "cattle", "cicada", "collie", "condor", "cougar", "coyote", "dassie", "donkey", "dragon", "earwig", "falcon", "feline", "ferret", "gannet", "gibbon", "glider", "goblin", "gopher", "grouse", "guinea", "hermit", "hornet", "iguana", "impala", "insect", "jackal", "jaguar", "jennet", "kitten", "kodiak", "lizard", "locust", "maggot", "magpie", "mammal", "mantis", "marlin", "marmot", "marten", "martin", "mayfly", "minnow", "monkey", "mullet", "muskox", "ocelot", "oriole", "osprey", "oyster", "parrot", "pigeon", "piglet", "poodle", "possum", "python", "quagga", "rabbit", "raptor", "rodent", "roughy", "salmon", "sawfly", "serval", "shiner", "shrimp", "spider", "sponge", "tarpon", "thrush", "tomcat", "toucan", "turkey", "turtle", "urchin", "vervet", "walrus", "weasel", "weevil", "wombat", "anchovy", "anemone", "bluejay", "buffalo", "bulldog", "buzzard", "caribou", "catfish", "chamois", "cheetah", "chicken", "chigger", "cowbird", "crappie", "crawdad", "cricket", "dogfish", "dolphin", "firefly", "garfish", "gazelle", "gelding", "giraffe", "gobbler", "gorilla", "goshawk", "grackle", "griffon", "grizzly", "grouper", "haddock", "hagfish", "halibut", "hamster", "herring", "jackass", "javelin", "jawfish", "jaybird", "katydid", "ladybug", "lamprey", "lemming", "leopard", "lioness", "lobster", "macaque", "mallard", "mammoth", "manatee", "mastiff", "meerkat", "mollusk", "monarch", "mongrel", "monitor", "monster", "mudfish", "muskrat", "mustang", "narwhal", "oarfish", "octopus", "opossum", "ostrich", "panther", "peacock", "pegasus", "pelican", "penguin", "phoenix", "piranha", "polecat", "primate", "quetzal", "raccoon", "rattler", "redbird", "redfish", "reptile", "rooster", "sawfish", "sculpin", "seagull", "skylark", "snapper", "spaniel", "sparrow", "sunbeam", "sunbird", "sunfish", "tadpole", "termite", "terrier", "unicorn", "vulture", "wallaby", "walleye", "warthog", "whippet", "wildcat", "aardvark", "airedale", "albacore", "anteater", "antelope", "arachnid", "barnacle", "basilisk", "blowfish", "bluebird", "bluegill", "bonefish", "bullfrog", "cardinal", "chipmunk", "cockatoo", "crayfish", "dinosaur", "doberman", "duckling", "elephant", "escargot", "flamingo", "flounder", "foxhound", "glowworm", "goldfish", "grubworm", "hedgehog", "honeybee", "hookworm", "humpback", "kangaroo", "killdeer", "kingfish", "labrador", "lacewing", "ladybird", "lionfish", "longhorn", "mackerel", "malamute", "marmoset", "mamoswine", "moccasin", "mongoose", "monkfish", "mosquito", "pangolin", "parakeet", "pheasant", "pipefish", "platypus", "polliwog", "porpoise", "reindeer", "ringtail", "sailfish", "scorpion", "seahorse", "seasnail", "sheepdog", "shepherd", "silkworm", "squirrel", "stallion", "starfish", "starling", "stingray", "stinkbug", "sturgeon", "terrapin", "titmouse", "tortoise", "treefrog", "werewolf", "woodcock"}
|
names = []string{"ox", "ant", "ape", "asp", "bat", "bee", "boa", "bug", "cat", "cod", "cow", "cub", "doe", "dog", "eel", "eft", "elf", "elk", "emu", "ewe", "fly", "fox", "gar", "gnu", "hen", "hog", "imp", "jay", "kid", "kit", "koi", "lab", "man", "owl", "pig", "pug", "pup", "ram", "rat", "ray", "yak", "bass", "bear", "bird", "boar", "buck", "bull", "calf", "chow", "clam", "colt", "crab", "crow", "dane", "deer", "dodo", "dory", "dove", "drum", "duck", "fawn", "fish", "flea", "foal", "fowl", "frog", "gnat", "goat", "grub", "gull", "hare", "hawk", "ibex", "joey", "kite", "kiwi", "lamb", "lark", "lion", "loon", "lynx", "mako", "mink", "mite", "mole", "moth", "mule", "mutt", "newt", "orca", "oryx", "pika", "pony", "puma", "seal", "shad", "slug", "sole", "stag", "stud", "swan", "tahr", "teal", "tick", "toad", "tuna", "wasp", "wolf", "worm", "wren", "yeti", "adder", "akita", "alien", "aphid", "bison", "boxer", "bream", "bunny", "burro", "camel", "chimp", "civet", "cobra", "coral", "corgi", "crane", "dingo", "drake", "eagle", "egret", "filly", "finch", "gator", "gecko", "ghost", "ghoul", "goose", "guppy", "heron", "hippo", "horse", "hound", "husky", "hyena", "koala", "krill", "leech", "lemur", "liger", "llama", "louse", "macaw", "midge", "molly", "moose", "moray", "mouse", "panda", "perch", "prawn", "quail", "racer", "raven", "rhino", "robin", "satyr", "shark", "sheep", "shrew", "skink", "skunk", "sloth", "snail", "snake", "snipe", "squid", "stork", "swift", "swine", "tapir", "tetra", "tiger", "troll", "trout", "viper", "wahoo", "whale", "zebra", "alpaca", "amoeba", "baboon", "badger", "beagle", "bedbug", "beetle", "bengal", "bobcat", "caiman", "cattle", "cicada", "collie", "condor", "cougar", "coyote", "dassie", "donkey", "dragon", "earwig", "falcon", "feline", "ferret", "gannet", "gibbon", "glider", "goblin", "gopher", "grouse", "guinea", "hermit", "hornet", "iguana", "impala", "insect", "jackal", "jaguar", "jennet", "kitten", "kodiak", "lizard", "locust", "maggot", "magpie", "mammal", "mantis", "marlin", "marmot", "marten", "martin", "mayfly", "minnow", "monkey", "mullet", "muskox", "ocelot", "oriole", "osprey", "oyster", "parrot", "pigeon", "piglet", "poodle", "possum", "python", "quagga", "rabbit", "raptor", "rodent", "roughy", "salmon", "sawfly", "serval", "shiner", "shrimp", "spider", "sponge", "tarpon", "thrush", "tomcat", "toucan", "turkey", "turtle", "urchin", "vervet", "walrus", "weasel", "weevil", "wombat", "anchovy", "anemone", "bluejay", "buffalo", "bulldog", "buzzard", "caribou", "catfish", "chamois", "cheetah", "chicken", "chigger", "cowbird", "crappie", "crawdad", "cricket", "dogfish", "dolphin", "firefly", "garfish", "gazelle", "gelding", "giraffe", "gobbler", "gorilla", "goshawk", "grackle", "griffon", "grizzly", "grouper", "haddock", "hagfish", "halibut", "hamster", "herring", "jackass", "javelin", "jawfish", "jaybird", "katydid", "ladybug", "lamprey", "lemming", "leopard", "lioness", "lobster", "macaque", "mallard", "mammoth", "manatee", "mastiff", "meerkat", "mollusk", "monarch", "mongrel", "monitor", "monster", "mudfish", "muskrat", "mustang", "narwhal", "oarfish", "octopus", "opossum", "ostrich", "panther", "peacock", "pegasus", "pelican", "penguin", "phoenix", "piranha", "polecat", "primate", "quetzal", "raccoon", "rattler", "redbird", "redfish", "reptile", "rooster", "sawfish", "sculpin", "seagull", "skylark", "snapper", "spaniel", "sparrow", "sunbeam", "sunbird", "sunfish", "tadpole", "termite", "terrier", "unicorn", "vulture", "wallaby", "walleye", "warthog", "whippet", "wildcat", "aardvark", "airedale", "albacore", "anteater", "antelope", "arachnid", "barnacle", "basilisk", "blowfish", "bluebird", "bluegill", "bonefish", "bullfrog", "cardinal", "chipmunk", "cockatoo", "crayfish", "dinosaur", "doberman", "duckling", "elephant", "escargot", "flamingo", "flounder", "foxhound", "glowworm", "goldfish", "grubworm", "hedgehog", "honeybee", "hookworm", "humpback", "kangaroo", "killdeer", "kingfish", "labrador", "lacewing", "ladybird", "lionfish", "longhorn", "mackerel", "malamute", "marmoset", "mamoswine", "moccasin", "mongoose", "monkfish", "mosquito", "pangolin", "parakeet", "pheasant", "pipefish", "platypus", "polliwog", "porpoise", "reindeer", "ringtail", "sailfish", "scorpion", "seahorse", "seasnail", "sheepdog", "shepherd", "silkworm", "squirrel", "stallion", "starfish", "starling", "stingray", "stinkbug", "sturgeon", "terrapin", "titmouse", "tortoise", "treefrog", "werewolf", "woodcock"}
|
||||||
)
|
)
|
||||||
|
@ -7,7 +7,7 @@ go_library(
|
|||||||
importpath = "github.com/prysmaticlabs/prysm/testing/bls/utils",
|
importpath = "github.com/prysmaticlabs/prysm/testing/bls/utils",
|
||||||
visibility = ["//testing/bls:__subpackages__"],
|
visibility = ["//testing/bls:__subpackages__"],
|
||||||
deps = [
|
deps = [
|
||||||
"//shared/fileutil:go_default_library",
|
"//io/file:go_default_library",
|
||||||
"//shared/testutil/require:go_default_library",
|
"//shared/testutil/require:go_default_library",
|
||||||
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
|
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
|
||||||
],
|
],
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/bazelbuild/rules_go/go/tools/bazel"
|
"github.com/bazelbuild/rules_go/go/tools/bazel"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ func RetrieveFiles(name string, t *testing.T) ([]string, [][]byte) {
|
|||||||
// Remove .yml suffix
|
// Remove .yml suffix
|
||||||
fName := strings.TrimSuffix(f.Name(), ".yaml")
|
fName := strings.TrimSuffix(f.Name(), ".yaml")
|
||||||
fileNames = append(fileNames, fName)
|
fileNames = append(fileNames, fName)
|
||||||
data, err := fileutil.ReadFileAsBytes(path.Join(filepath, f.Name()))
|
data, err := file.ReadFileAsBytes(path.Join(filepath, f.Name()))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
fileContent = append(fileContent, data)
|
fileContent = append(fileContent, data)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Package properpermissions implements a static analyzer to ensure that Prysm does not
|
// Package properpermissions implements a static analyzer to ensure that Prysm does not
|
||||||
// use ioutil.MkdirAll or os.WriteFile as they are unsafe when it comes to guaranteeing
|
// use ioutil.MkdirAll or os.WriteFile as they are unsafe when it comes to guaranteeing
|
||||||
// file permissions and not overriding existing permissions. Instead, users are warned
|
// file permissions and not overriding existing permissions. Instead, users are warned
|
||||||
// to utilize shared/fileutil as the canonical solution.
|
// to utilize shared/file as the canonical solution.
|
||||||
package properpermissions
|
package properpermissions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -19,7 +19,7 @@ const Doc = "Tool to enforce usage of Prysm's internal file-writing utils instea
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
errUnsafePackage = errors.New(
|
errUnsafePackage = errors.New(
|
||||||
"os and ioutil dir and file writing functions are not permissions-safe, use shared/fileutil",
|
"os and ioutil dir and file writing functions are not permissions-safe, use shared/file",
|
||||||
)
|
)
|
||||||
disallowedFns = []string{"MkdirAll", "WriteFile"}
|
disallowedFns = []string{"MkdirAll", "WriteFile"}
|
||||||
)
|
)
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
func UseAliasedPackages() {
|
func UseAliasedPackages() {
|
||||||
randPath, _ := rand.Int(rand.Reader, big.NewInt(1000000))
|
randPath, _ := rand.Int(rand.Reader, big.NewInt(1000000))
|
||||||
p := filepath.Join(tempDir(), fmt.Sprintf("/%d", randPath))
|
p := filepath.Join(tempDir(), fmt.Sprintf("/%d", randPath))
|
||||||
_ = osAlias.MkdirAll(p, osAlias.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/fileutil"
|
_ = osAlias.MkdirAll(p, osAlias.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/file"
|
||||||
someFile := filepath.Join(p, "some.txt")
|
someFile := filepath.Join(p, "some.txt")
|
||||||
_ = ioAlias.WriteFile(someFile, []byte("hello"), osAlias.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/fileutil"
|
_ = ioAlias.WriteFile(someFile, []byte("hello"), osAlias.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/file"
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ func tempDir() string {
|
|||||||
func UseOsMkdirAllAndWriteFile() {
|
func UseOsMkdirAllAndWriteFile() {
|
||||||
randPath, _ := rand.Int(rand.Reader, big.NewInt(1000000))
|
randPath, _ := rand.Int(rand.Reader, big.NewInt(1000000))
|
||||||
p := filepath.Join(tempDir(), fmt.Sprintf("/%d", randPath))
|
p := filepath.Join(tempDir(), fmt.Sprintf("/%d", randPath))
|
||||||
_ = os.MkdirAll(p, os.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/fileutil"
|
_ = os.MkdirAll(p, os.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/file"
|
||||||
someFile := filepath.Join(p, "some.txt")
|
someFile := filepath.Join(p, "some.txt")
|
||||||
_ = ioutil.WriteFile(someFile, []byte("hello"), os.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/fileutil"
|
_ = ioutil.WriteFile(someFile, []byte("hello"), os.ModePerm) // want "os and ioutil dir and file writing functions are not permissions-safe, use shared/file"
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ go_library(
|
|||||||
name = "go_default_library",
|
name = "go_default_library",
|
||||||
srcs = ["main.go"],
|
srcs = ["main.go"],
|
||||||
deps = [
|
deps = [
|
||||||
"//shared/fileutil:go_default_library",
|
"//io/file:go_default_library",
|
||||||
],
|
],
|
||||||
importpath = "github.com/prysmaticlabs/prysm/tools/beacon-fuzz",
|
importpath = "github.com/prysmaticlabs/prysm/tools/beacon-fuzz",
|
||||||
visibility = ["//visibility:private"],
|
visibility = ["//visibility:private"],
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -56,7 +56,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
res := execTmpl(tpl, input{Package: "testing", MapStr: sszBytesToMapStr(m)})
|
res := execTmpl(tpl, input{Package: "testing", MapStr: sszBytesToMapStr(m)})
|
||||||
if err := fileutil.WriteFile(*output, res.Bytes()); err != nil {
|
if err := file.WriteFile(*output, res.Bytes()); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,9 @@ go_library(
|
|||||||
"//beacon-chain/core/transition:go_default_library",
|
"//beacon-chain/core/transition:go_default_library",
|
||||||
"//beacon-chain/state:go_default_library",
|
"//beacon-chain/state:go_default_library",
|
||||||
"//beacon-chain/state/v1:go_default_library",
|
"//beacon-chain/state/v1:go_default_library",
|
||||||
|
"//io/file:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//proto/prysm/v1alpha1/wrapper:go_default_library",
|
"//proto/prysm/v1alpha1/wrapper:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
|
||||||
"//shared/interop:go_default_library",
|
"//shared/interop:go_default_library",
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"//shared/testutil:go_default_library",
|
"//shared/testutil:go_default_library",
|
||||||
|
@ -15,9 +15,9 @@ import (
|
|||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/transition"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/transition"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
"github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||||
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
v1 "github.com/prysmaticlabs/prysm/beacon-chain/state/v1"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/interop"
|
"github.com/prysmaticlabs/prysm/shared/interop"
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
"github.com/prysmaticlabs/prysm/shared/testutil"
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||||||
@ -47,7 +47,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := fileutil.MkdirAll(*outputDir); err != nil {
|
if err := file.MkdirAll(*outputDir); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ func generateGenesisBeaconState() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return fileutil.WriteFile(path.Join(*outputDir, benchmark.GenesisFileName), beaconBytes)
|
return file.WriteFile(path.Join(*outputDir, benchmark.GenesisFileName), beaconBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateMarshalledFullStateAndBlock() error {
|
func generateMarshalledFullStateAndBlock() error {
|
||||||
@ -153,7 +153,7 @@ func generateMarshalledFullStateAndBlock() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := fileutil.WriteFile(path.Join(*outputDir, benchmark.BState1EpochFileName), beaconBytes); err != nil {
|
if err := file.WriteFile(path.Join(*outputDir, benchmark.BState1EpochFileName), beaconBytes); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ func generateMarshalledFullStateAndBlock() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return fileutil.WriteFile(path.Join(*outputDir, benchmark.FullBlockFileName), blockBytes)
|
return file.WriteFile(path.Join(*outputDir, benchmark.FullBlockFileName), blockBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func generate2FullEpochState() error {
|
func generate2FullEpochState() error {
|
||||||
@ -203,7 +203,7 @@ func generate2FullEpochState() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return fileutil.WriteFile(path.Join(*outputDir, benchmark.BstateEpochFileName), beaconBytes)
|
return file.WriteFile(path.Join(*outputDir, benchmark.BstateEpochFileName), beaconBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func genesisBeaconState() (state.BeaconState, error) {
|
func genesisBeaconState() (state.BeaconState, error) {
|
||||||
|
@ -11,12 +11,12 @@ go_library(
|
|||||||
visibility = ["//visibility:private"],
|
visibility = ["//visibility:private"],
|
||||||
deps = [
|
deps = [
|
||||||
"//beacon-chain/core/helpers:go_default_library",
|
"//beacon-chain/core/helpers:go_default_library",
|
||||||
|
"//io/logs:go_default_library",
|
||||||
"//network:go_default_library",
|
"//network:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//runtime/maxprocs:go_default_library",
|
"//runtime/maxprocs:go_default_library",
|
||||||
"//runtime/version:go_default_library",
|
"//runtime/version:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/logutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"//shared/runutil:go_default_library",
|
"//shared/runutil:go_default_library",
|
||||||
"@com_github_ethereum_go_ethereum//crypto:go_default_library",
|
"@com_github_ethereum_go_ethereum//crypto:go_default_library",
|
||||||
|
@ -33,12 +33,12 @@ import (
|
|||||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||||
"github.com/prysmaticlabs/go-bitfield"
|
"github.com/prysmaticlabs/go-bitfield"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/logs"
|
||||||
"github.com/prysmaticlabs/prysm/network"
|
"github.com/prysmaticlabs/prysm/network"
|
||||||
pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
pb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
_ "github.com/prysmaticlabs/prysm/runtime/maxprocs"
|
_ "github.com/prysmaticlabs/prysm/runtime/maxprocs"
|
||||||
"github.com/prysmaticlabs/prysm/runtime/version"
|
"github.com/prysmaticlabs/prysm/runtime/version"
|
||||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||||
"github.com/prysmaticlabs/prysm/shared/logutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
"github.com/prysmaticlabs/prysm/shared/runutil"
|
"github.com/prysmaticlabs/prysm/shared/runutil"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -69,7 +69,7 @@ func main() {
|
|||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *logFileName != "" {
|
if *logFileName != "" {
|
||||||
if err := logutil.ConfigurePersistentLogging(*logFileName); err != nil {
|
if err := logs.ConfigurePersistentLogging(*logFileName); err != nil {
|
||||||
log.WithError(err).Error("Failed to configuring logging to disk.")
|
log.WithError(err).Error("Failed to configuring logging to disk.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ go_library(
|
|||||||
importpath = "github.com/prysmaticlabs/prysm/tools/enr-calculator",
|
importpath = "github.com/prysmaticlabs/prysm/tools/enr-calculator",
|
||||||
visibility = ["//visibility:private"],
|
visibility = ["//visibility:private"],
|
||||||
deps = [
|
deps = [
|
||||||
|
"//io/file:go_default_library",
|
||||||
"//runtime/maxprocs:go_default_library",
|
"//runtime/maxprocs:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
|
||||||
"@com_github_ethereum_go_ethereum//p2p/enode:go_default_library",
|
"@com_github_ethereum_go_ethereum//p2p/enode:go_default_library",
|
||||||
"@com_github_ethereum_go_ethereum//p2p/enr:go_default_library",
|
"@com_github_ethereum_go_ethereum//p2p/enr:go_default_library",
|
||||||
"@com_github_libp2p_go_libp2p_core//crypto:go_default_library",
|
"@com_github_libp2p_go_libp2p_core//crypto:go_default_library",
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/p2p/enode"
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
"github.com/ethereum/go-ethereum/p2p/enr"
|
"github.com/ethereum/go-ethereum/p2p/enr"
|
||||||
"github.com/libp2p/go-libp2p-core/crypto"
|
"github.com/libp2p/go-libp2p-core/crypto"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
_ "github.com/prysmaticlabs/prysm/runtime/maxprocs"
|
_ "github.com/prysmaticlabs/prysm/runtime/maxprocs"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ func main() {
|
|||||||
log.Info(localNode.Node().String())
|
log.Info(localNode.Node().String())
|
||||||
|
|
||||||
if *outfile != "" {
|
if *outfile != "" {
|
||||||
err := fileutil.WriteFile(*outfile, []byte(localNode.Node().String()))
|
err := file.WriteFile(*outfile, []byte(localNode.Node().String()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ go_library(
|
|||||||
importpath = "github.com/prysmaticlabs/prysm/tools/genesis-state-gen",
|
importpath = "github.com/prysmaticlabs/prysm/tools/genesis-state-gen",
|
||||||
visibility = ["//visibility:private"],
|
visibility = ["//visibility:private"],
|
||||||
deps = [
|
deps = [
|
||||||
|
"//io/file:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
|
||||||
"//shared/interop:go_default_library",
|
"//shared/interop:go_default_library",
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"@com_github_ghodss_yaml//:go_default_library",
|
"@com_github_ghodss_yaml//:go_default_library",
|
||||||
|
@ -12,8 +12,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ghodss/yaml"
|
"github.com/ghodss/yaml"
|
||||||
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/interop"
|
"github.com/prysmaticlabs/prysm/shared/interop"
|
||||||
"github.com/prysmaticlabs/prysm/shared/params"
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||||||
)
|
)
|
||||||
@ -58,7 +58,7 @@ func main() {
|
|||||||
var err error
|
var err error
|
||||||
if *depositJSONFile != "" {
|
if *depositJSONFile != "" {
|
||||||
inputFile := *depositJSONFile
|
inputFile := *depositJSONFile
|
||||||
expanded, err := fileutil.ExpandPath(inputFile)
|
expanded, err := file.ExpandPath(inputFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Could not expand file path %s: %v", inputFile, err)
|
log.Printf("Could not expand file path %s: %v", inputFile, err)
|
||||||
return
|
return
|
||||||
@ -98,7 +98,7 @@ func main() {
|
|||||||
log.Printf("Could not ssz marshal the genesis beacon state: %v", err)
|
log.Printf("Could not ssz marshal the genesis beacon state: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := fileutil.WriteFile(*sszOutputFile, encodedState); err != nil {
|
if err := file.WriteFile(*sszOutputFile, encodedState); err != nil {
|
||||||
log.Printf("Could not write encoded genesis beacon state to file: %v", err)
|
log.Printf("Could not write encoded genesis beacon state to file: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ func main() {
|
|||||||
log.Printf("Could not yaml marshal the genesis beacon state: %v", err)
|
log.Printf("Could not yaml marshal the genesis beacon state: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := fileutil.WriteFile(*yamlOutputFile, encodedState); err != nil {
|
if err := file.WriteFile(*yamlOutputFile, encodedState); err != nil {
|
||||||
log.Printf("Could not write encoded genesis beacon state to file: %v", err)
|
log.Printf("Could not write encoded genesis beacon state to file: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ func main() {
|
|||||||
log.Printf("Could not json marshal the genesis beacon state: %v", err)
|
log.Printf("Could not json marshal the genesis beacon state: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := fileutil.WriteFile(*jsonOutputFile, encodedState); err != nil {
|
if err := file.WriteFile(*jsonOutputFile, encodedState); err != nil {
|
||||||
log.Printf("Could not write encoded genesis beacon state to file: %v", err)
|
log.Printf("Could not write encoded genesis beacon state to file: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ go_library(
|
|||||||
deps = [
|
deps = [
|
||||||
"//beacon-chain/db:go_default_library",
|
"//beacon-chain/db:go_default_library",
|
||||||
"//beacon-chain/db/kv:go_default_library",
|
"//beacon-chain/db/kv:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
"//io/file:go_default_library",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
"github.com/prysmaticlabs/prysm/beacon-chain/db"
|
||||||
"github.com/prysmaticlabs/prysm/beacon-chain/db/kv"
|
"github.com/prysmaticlabs/prysm/beacon-chain/db/kv"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A basic tool to extract genesis.ssz from existing beaconchain.db.
|
// A basic tool to extract genesis.ssz from existing beaconchain.db.
|
||||||
@ -41,7 +41,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if err := fileutil.WriteFile(os.Args[2], b); err != nil {
|
if err := file.WriteFile(os.Args[2], b); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
fmt.Println("done")
|
fmt.Println("done")
|
||||||
|
@ -7,7 +7,7 @@ go_library(
|
|||||||
importpath = "github.com/prysmaticlabs/prysm/tools/interop/split-keys",
|
importpath = "github.com/prysmaticlabs/prysm/tools/interop/split-keys",
|
||||||
visibility = ["//visibility:private"],
|
visibility = ["//visibility:private"],
|
||||||
deps = [
|
deps = [
|
||||||
"//shared/fileutil:go_default_library",
|
"//io/file:go_default_library",
|
||||||
"//validator/accounts/wallet:go_default_library",
|
"//validator/accounts/wallet:go_default_library",
|
||||||
"//validator/keymanager:go_default_library",
|
"//validator/keymanager:go_default_library",
|
||||||
"//validator/keymanager/derived:go_default_library",
|
"//validator/keymanager/derived:go_default_library",
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
"github.com/prysmaticlabs/prysm/validator/accounts/wallet"
|
"github.com/prysmaticlabs/prysm/validator/accounts/wallet"
|
||||||
"github.com/prysmaticlabs/prysm/validator/keymanager"
|
"github.com/prysmaticlabs/prysm/validator/keymanager"
|
||||||
"github.com/prysmaticlabs/prysm/validator/keymanager/derived"
|
"github.com/prysmaticlabs/prysm/validator/keymanager/derived"
|
||||||
@ -56,7 +56,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Splitting %d keys across %d wallets\n", len(privKeys), *numberOfWalletsFlag)
|
log.Printf("Splitting %d keys across %d wallets\n", len(privKeys), *numberOfWalletsFlag)
|
||||||
wPass, err := fileutil.ReadFileAsBytes(*walletPasswordFileFlag)
|
wPass, err := file.ReadFileAsBytes(*walletPasswordFileFlag)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,8 @@ go_library(
|
|||||||
visibility = ["//visibility:private"],
|
visibility = ["//visibility:private"],
|
||||||
deps = [
|
deps = [
|
||||||
"//crypto/bls:go_default_library",
|
"//crypto/bls:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
"//io/file:go_default_library",
|
||||||
"//shared/promptutil:go_default_library",
|
"//io/prompt:go_default_library",
|
||||||
"//validator/keymanager:go_default_library",
|
"//validator/keymanager:go_default_library",
|
||||||
"@com_github_google_uuid//:go_default_library",
|
"@com_github_google_uuid//:go_default_library",
|
||||||
"@com_github_logrusorgru_aurora//:go_default_library",
|
"@com_github_logrusorgru_aurora//:go_default_library",
|
||||||
|
@ -18,8 +18,8 @@ import (
|
|||||||
"github.com/logrusorgru/aurora"
|
"github.com/logrusorgru/aurora"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prysmaticlabs/prysm/crypto/bls"
|
"github.com/prysmaticlabs/prysm/crypto/bls"
|
||||||
"github.com/prysmaticlabs/prysm/shared/fileutil"
|
"github.com/prysmaticlabs/prysm/io/file"
|
||||||
"github.com/prysmaticlabs/prysm/shared/promptutil"
|
"github.com/prysmaticlabs/prysm/io/prompt"
|
||||||
"github.com/prysmaticlabs/prysm/validator/keymanager"
|
"github.com/prysmaticlabs/prysm/validator/keymanager"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4"
|
keystorev4 "github.com/wealdtech/go-eth2-wallet-encryptor-keystorev4"
|
||||||
@ -90,14 +90,14 @@ func decrypt(cliCtx *cli.Context) error {
|
|||||||
if keystorePath == "" {
|
if keystorePath == "" {
|
||||||
return errors.New("--keystore must be set")
|
return errors.New("--keystore must be set")
|
||||||
}
|
}
|
||||||
fullPath, err := fileutil.ExpandPath(keystorePath)
|
fullPath, err := file.ExpandPath(keystorePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "could not expand path: %s", keystorePath)
|
return errors.Wrapf(err, "could not expand path: %s", keystorePath)
|
||||||
}
|
}
|
||||||
password := cliCtx.String(passwordFlag.Name)
|
password := cliCtx.String(passwordFlag.Name)
|
||||||
isPasswordSet := cliCtx.IsSet(passwordFlag.Name)
|
isPasswordSet := cliCtx.IsSet(passwordFlag.Name)
|
||||||
if !isPasswordSet {
|
if !isPasswordSet {
|
||||||
password, err = promptutil.PasswordPrompt("Input the keystore(s) password", func(s string) error {
|
password, err = prompt.PasswordPrompt("Input the keystore(s) password", func(s string) error {
|
||||||
// Any password is valid.
|
// Any password is valid.
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -105,7 +105,7 @@ func decrypt(cliCtx *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isDir, err := fileutil.HasDir(fullPath)
|
isDir, err := file.HasDir(fullPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "could not check if path exists: %s", fullPath)
|
return errors.Wrapf(err, "could not check if path exists: %s", fullPath)
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ func encrypt(cliCtx *cli.Context) error {
|
|||||||
password := cliCtx.String(passwordFlag.Name)
|
password := cliCtx.String(passwordFlag.Name)
|
||||||
isPasswordSet := cliCtx.IsSet(passwordFlag.Name)
|
isPasswordSet := cliCtx.IsSet(passwordFlag.Name)
|
||||||
if !isPasswordSet {
|
if !isPasswordSet {
|
||||||
password, err = promptutil.PasswordPrompt("Input the keystore(s) password", func(s string) error {
|
password, err = prompt.PasswordPrompt("Input the keystore(s) password", func(s string) error {
|
||||||
// Any password is valid.
|
// Any password is valid.
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -153,12 +153,12 @@ func encrypt(cliCtx *cli.Context) error {
|
|||||||
if outputPath == "" {
|
if outputPath == "" {
|
||||||
return errors.New("--output-path must be set")
|
return errors.New("--output-path must be set")
|
||||||
}
|
}
|
||||||
fullPath, err := fileutil.ExpandPath(outputPath)
|
fullPath, err := file.ExpandPath(outputPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "could not expand path: %s", outputPath)
|
return errors.Wrapf(err, "could not expand path: %s", outputPath)
|
||||||
}
|
}
|
||||||
if fileutil.FileExists(fullPath) {
|
if file.FileExists(fullPath) {
|
||||||
response, err := promptutil.ValidatePrompt(
|
response, err := prompt.ValidatePrompt(
|
||||||
os.Stdin,
|
os.Stdin,
|
||||||
fmt.Sprintf("file at path %s already exists, are you sure you want to overwrite it? [y/n]", fullPath),
|
fmt.Sprintf("file at path %s already exists, are you sure you want to overwrite it? [y/n]", fullPath),
|
||||||
func(s string) error {
|
func(s string) error {
|
||||||
@ -170,7 +170,7 @@ func encrypt(cliCtx *cli.Context) error {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "could not validate prompt confirmation")
|
return errors.Wrap(err, "could not validate userprompt confirmation")
|
||||||
}
|
}
|
||||||
if response == "n" {
|
if response == "n" {
|
||||||
return nil
|
return nil
|
||||||
@ -208,7 +208,7 @@ func encrypt(cliCtx *cli.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "could not json marshal keystore")
|
return errors.Wrap(err, "could not json marshal keystore")
|
||||||
}
|
}
|
||||||
if err := fileutil.WriteFile(fullPath, encodedFile); err != nil {
|
if err := file.WriteFile(fullPath, encodedFile); err != nil {
|
||||||
return errors.Wrapf(err, "could not write file at path: %s", fullPath)
|
return errors.Wrapf(err, "could not write file at path: %s", fullPath)
|
||||||
}
|
}
|
||||||
fmt.Printf(
|
fmt.Printf(
|
||||||
|
@ -27,15 +27,15 @@ go_library(
|
|||||||
"//beacon-chain/core/blocks:go_default_library",
|
"//beacon-chain/core/blocks:go_default_library",
|
||||||
"//cmd/validator/flags:go_default_library",
|
"//cmd/validator/flags:go_default_library",
|
||||||
"//crypto/bls:go_default_library",
|
"//crypto/bls:go_default_library",
|
||||||
|
"//io/file:go_default_library",
|
||||||
|
"//io/prompt:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/cmd:go_default_library",
|
"//shared/cmd:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"//shared/petnames:go_default_library",
|
"//shared/petnames:go_default_library",
|
||||||
"//shared/promptutil:go_default_library",
|
|
||||||
"//validator/accounts/iface:go_default_library",
|
"//validator/accounts/iface:go_default_library",
|
||||||
"//validator/accounts/prompt:go_default_library",
|
"//validator/accounts/userprompt:go_default_library",
|
||||||
"//validator/accounts/wallet:go_default_library",
|
"//validator/accounts/wallet:go_default_library",
|
||||||
"//validator/client:go_default_library",
|
"//validator/client:go_default_library",
|
||||||
"//validator/keymanager:go_default_library",
|
"//validator/keymanager:go_default_library",
|
||||||
@ -72,11 +72,11 @@ go_test(
|
|||||||
deps = [
|
deps = [
|
||||||
"//cmd/validator/flags:go_default_library",
|
"//cmd/validator/flags:go_default_library",
|
||||||
"//crypto/bls:go_default_library",
|
"//crypto/bls:go_default_library",
|
||||||
|
"//io/file:go_default_library",
|
||||||
"//proto/prysm/v1alpha1:go_default_library",
|
"//proto/prysm/v1alpha1:go_default_library",
|
||||||
"//proto/prysm/v1alpha1/validator-client:go_default_library",
|
"//proto/prysm/v1alpha1/validator-client:go_default_library",
|
||||||
"//shared/bytesutil:go_default_library",
|
"//shared/bytesutil:go_default_library",
|
||||||
"//shared/event:go_default_library",
|
"//shared/event:go_default_library",
|
||||||
"//shared/fileutil:go_default_library",
|
|
||||||
"//shared/params:go_default_library",
|
"//shared/params:go_default_library",
|
||||||
"//shared/petnames:go_default_library",
|
"//shared/petnames:go_default_library",
|
||||||
"//shared/testutil/assert:go_default_library",
|
"//shared/testutil/assert:go_default_library",
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user