mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 03:30:35 +00:00
Fix typos and inconsistencies (#4453)
* Fix typos and inconsistencies * igoimports * Gazelle
This commit is contained in:
parent
0d400faea2
commit
b30a7d1e19
@ -23,7 +23,7 @@ Participation is now open to the public for our Ethereum 2.0 phase 0 testnet rel
|
||||
- [Running via Docker](#running-via-docker)
|
||||
- [Running via Bazel](#running-via-bazel)
|
||||
- [Staking ETH: running a validator client](#staking-eth-running-a-validator-client)
|
||||
- [Activating your validator: depositing 3.2 Goerli ETH](#activating-your-validator-depositing-32-göerli-eth)
|
||||
- [Activating your validator: depositing 3.2 Goerli ETH](#activating-your-validator-depositing-32-gerli-eth)
|
||||
- [Starting the validator with Bazel](#starting-the-validator-with-bazel)
|
||||
- [Setting up a local ETH2 development chain](#setting-up-a-local-eth2-development-chain)
|
||||
- [Installation and dependencies](#installation-and-dependencies)
|
||||
|
@ -329,7 +329,7 @@ func TestStore_GetHead(t *testing.T) {
|
||||
// 18 validators switches vote to B1 to gain 51%, enough to switch head
|
||||
for i := 0; i < 18; i++ {
|
||||
idx := 50 + uint64(i)
|
||||
store.latestVoteMap[uint64(idx)] = &pb.ValidatorLatestVote{Root: roots[1]}
|
||||
store.latestVoteMap[idx] = &pb.ValidatorLatestVote{Root: roots[1]}
|
||||
}
|
||||
head, err = store.Head(ctx)
|
||||
if err != nil {
|
||||
|
2
beacon-chain/cache/eth1_data_test.go
vendored
2
beacon-chain/cache/eth1_data_test.go
vendored
@ -91,7 +91,7 @@ func TestEth1Data_MaxSize(t *testing.T) {
|
||||
|
||||
for i := 0; i < maxEth1DataVoteSize+1; i++ {
|
||||
var hash [32]byte
|
||||
copy(hash[:], []byte(strconv.Itoa(i)))
|
||||
copy(hash[:], strconv.Itoa(i))
|
||||
eInfo := &Eth1DataVote{
|
||||
Eth1DataHash: hash,
|
||||
}
|
||||
|
@ -323,8 +323,8 @@ func TestProcessRegistryUpdates_NoRotation(t *testing.T) {
|
||||
state := &pb.BeaconState{
|
||||
Slot: 5 * params.BeaconConfig().SlotsPerEpoch,
|
||||
Validators: []*ethpb.Validator{
|
||||
{ExitEpoch: params.BeaconConfig().MaxSeedLookhead},
|
||||
{ExitEpoch: params.BeaconConfig().MaxSeedLookhead},
|
||||
{ExitEpoch: params.BeaconConfig().MaxSeedLookahead},
|
||||
{ExitEpoch: params.BeaconConfig().MaxSeedLookahead},
|
||||
},
|
||||
Balances: []uint64{
|
||||
params.BeaconConfig().MaxEffectiveBalance,
|
||||
@ -337,9 +337,9 @@ func TestProcessRegistryUpdates_NoRotation(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for i, validator := range newState.Validators {
|
||||
if validator.ExitEpoch != params.BeaconConfig().MaxSeedLookhead {
|
||||
if validator.ExitEpoch != params.BeaconConfig().MaxSeedLookahead {
|
||||
t.Errorf("Could not update registry %d, wanted exit slot %d got %d",
|
||||
i, params.BeaconConfig().MaxSeedLookhead, validator.ExitEpoch)
|
||||
i, params.BeaconConfig().MaxSeedLookahead, validator.ExitEpoch)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -385,10 +385,10 @@ func TestProcessRegistryUpdates_ActivationCompletes(t *testing.T) {
|
||||
state := &pb.BeaconState{
|
||||
Slot: 5 * params.BeaconConfig().SlotsPerEpoch,
|
||||
Validators: []*ethpb.Validator{
|
||||
{ExitEpoch: params.BeaconConfig().MaxSeedLookhead,
|
||||
ActivationEpoch: 5 + params.BeaconConfig().MaxSeedLookhead + 1},
|
||||
{ExitEpoch: params.BeaconConfig().MaxSeedLookhead,
|
||||
ActivationEpoch: 5 + params.BeaconConfig().MaxSeedLookhead + 1},
|
||||
{ExitEpoch: params.BeaconConfig().MaxSeedLookahead,
|
||||
ActivationEpoch: 5 + params.BeaconConfig().MaxSeedLookahead + 1},
|
||||
{ExitEpoch: params.BeaconConfig().MaxSeedLookahead,
|
||||
ActivationEpoch: 5 + params.BeaconConfig().MaxSeedLookahead + 1},
|
||||
},
|
||||
FinalizedCheckpoint: ðpb.Checkpoint{},
|
||||
}
|
||||
@ -397,9 +397,9 @@ func TestProcessRegistryUpdates_ActivationCompletes(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
for i, validator := range newState.Validators {
|
||||
if validator.ExitEpoch != params.BeaconConfig().MaxSeedLookhead {
|
||||
if validator.ExitEpoch != params.BeaconConfig().MaxSeedLookahead {
|
||||
t.Errorf("Could not update registry %d, wanted exit slot %d got %d",
|
||||
i, params.BeaconConfig().MaxSeedLookhead, validator.ExitEpoch)
|
||||
i, params.BeaconConfig().MaxSeedLookahead, validator.ExitEpoch)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -424,9 +424,9 @@ func TestProcessRegistryUpdates_ValidatorsEjected(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
for i, validator := range newState.Validators {
|
||||
if validator.ExitEpoch != params.BeaconConfig().MaxSeedLookhead+1 {
|
||||
if validator.ExitEpoch != params.BeaconConfig().MaxSeedLookahead+1 {
|
||||
t.Errorf("Could not update registry %d, wanted exit slot %d got %d",
|
||||
i, params.BeaconConfig().MaxSeedLookhead+1, validator.ExitEpoch)
|
||||
i, params.BeaconConfig().MaxSeedLookahead+1, validator.ExitEpoch)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,12 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
)
|
||||
|
||||
// ErrInvalidStateLatestActiveIndexRoots is returned when the state active
|
||||
// index root count does not match the expected EpochsPerHistoricalVector.
|
||||
var ErrInvalidStateLatestActiveIndexRoots = errors.New("state does not have correct number of latest active index roots")
|
||||
|
||||
// Seed returns the randao seed used for shuffling of a given epoch.
|
||||
//
|
||||
// Spec pseudocode definition:
|
||||
|
@ -110,7 +110,7 @@ func ActiveValidatorCount(state *pb.BeaconState, epoch uint64) (uint64, error) {
|
||||
// """
|
||||
// return Epoch(epoch + 1 + ACTIVATION_EXIT_DELAY)
|
||||
func DelayedActivationExitEpoch(epoch uint64) uint64 {
|
||||
return epoch + 1 + params.BeaconConfig().MaxSeedLookhead
|
||||
return epoch + 1 + params.BeaconConfig().MaxSeedLookahead
|
||||
}
|
||||
|
||||
// ValidatorChurnLimit returns the number of validators that are allowed to
|
||||
|
@ -178,7 +178,7 @@ func TestBeaconProposerIndex_OK(t *testing.T) {
|
||||
func TestDelayedActivationExitEpoch_OK(t *testing.T) {
|
||||
epoch := uint64(9999)
|
||||
got := DelayedActivationExitEpoch(epoch)
|
||||
wanted := epoch + 1 + params.BeaconConfig().MaxSeedLookhead
|
||||
wanted := epoch + 1 + params.BeaconConfig().MaxSeedLookahead
|
||||
if wanted != got {
|
||||
t.Errorf("Wanted: %d, received: %d", wanted, got)
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ var containerFinalizedButNotCanonical = []byte("recent block needs reindexing to
|
||||
//
|
||||
// This method ensures that all blocks from the current finalized epoch are considered "final" while
|
||||
// maintaining only canonical and finalized blocks older than the current finalized epoch.
|
||||
func (kv *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, checkpoint *ethpb.Checkpoint) error {
|
||||
func (k *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, checkpoint *ethpb.Checkpoint) error {
|
||||
ctx, span := trace.StartSpan(ctx, "BeaconDB.updateFinalizedBlockRoots")
|
||||
defer span.End()
|
||||
|
||||
@ -48,15 +48,15 @@ func (kv *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, che
|
||||
genesisRoot := tx.Bucket(blocksBucket).Get(genesisBlockRootKey)
|
||||
|
||||
// De-index recent finalized block roots, to be re-indexed.
|
||||
prevousFinalizedCheckpoint := ðpb.Checkpoint{}
|
||||
previousFinalizedCheckpoint := ðpb.Checkpoint{}
|
||||
if b := bkt.Get(previousFinalizedCheckpointKey); b != nil {
|
||||
if err := decode(b, prevousFinalizedCheckpoint); err != nil {
|
||||
if err := decode(b, previousFinalizedCheckpoint); err != nil {
|
||||
traceutil.AnnotateError(span, err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
blockRoots, err := kv.BlockRoots(ctx, filters.NewFilter().
|
||||
SetStartEpoch(prevousFinalizedCheckpoint.Epoch).
|
||||
blockRoots, err := k.BlockRoots(ctx, filters.NewFilter().
|
||||
SetStartEpoch(previousFinalizedCheckpoint.Epoch).
|
||||
SetEndEpoch(checkpoint.Epoch+1),
|
||||
)
|
||||
if err != nil {
|
||||
@ -77,7 +77,7 @@ func (kv *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, che
|
||||
break
|
||||
}
|
||||
|
||||
signedBlock, err := kv.Block(ctx, bytesutil.ToBytes32(root))
|
||||
signedBlock, err := k.Block(ctx, bytesutil.ToBytes32(root))
|
||||
if err != nil {
|
||||
traceutil.AnnotateError(span, err)
|
||||
return err
|
||||
@ -128,7 +128,7 @@ func (kv *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, che
|
||||
}
|
||||
|
||||
// Upsert blocks from the current finalized epoch.
|
||||
roots, err := kv.BlockRoots(ctx, filters.NewFilter().SetStartEpoch(checkpoint.Epoch).SetEndEpoch(checkpoint.Epoch+1))
|
||||
roots, err := k.BlockRoots(ctx, filters.NewFilter().SetStartEpoch(checkpoint.Epoch).SetEndEpoch(checkpoint.Epoch+1))
|
||||
if err != nil {
|
||||
traceutil.AnnotateError(span, err)
|
||||
return err
|
||||
@ -158,12 +158,12 @@ func (kv *Store) updateFinalizedBlockRoots(ctx context.Context, tx *bolt.Tx, che
|
||||
// A beacon block root contained exists in this index if it is considered finalized and canonical.
|
||||
// Note: beacon blocks from the latest finalized epoch return true, whether or not they are
|
||||
// considered canonical in the "head view" of the beacon node.
|
||||
func (kv *Store) IsFinalizedBlock(ctx context.Context, blockRoot [32]byte) bool {
|
||||
func (k *Store) IsFinalizedBlock(ctx context.Context, blockRoot [32]byte) bool {
|
||||
ctx, span := trace.StartSpan(ctx, "BeaconDB.IsFinalizedBlock")
|
||||
defer span.End()
|
||||
|
||||
var exists bool
|
||||
err := kv.db.View(func(tx *bolt.Tx) error {
|
||||
err := k.db.View(func(tx *bolt.Tx) error {
|
||||
exists = tx.Bucket(finalizedBlockRootsIndexBucket).Get(blockRoot[:]) != nil
|
||||
return nil
|
||||
})
|
||||
|
@ -12,10 +12,10 @@ import (
|
||||
|
||||
var pruneStatesKey = []byte("prune-states")
|
||||
|
||||
func (kv *Store) pruneStates(ctx context.Context) error {
|
||||
func (k *Store) pruneStates(ctx context.Context) error {
|
||||
var pruned bool
|
||||
|
||||
kv.db.View(func(tx *bolt.Tx) error {
|
||||
k.db.View(func(tx *bolt.Tx) error {
|
||||
bkt := tx.Bucket(migrationBucket)
|
||||
v := bkt.Get(pruneStatesKey)
|
||||
pruned = len(v) == 1 && v[0] == 0x01
|
||||
@ -29,16 +29,16 @@ func (kv *Store) pruneStates(ctx context.Context) error {
|
||||
log := logrus.WithField("prefix", "kv")
|
||||
log.Info("Pruning states before last finalized check point. This might take a while...")
|
||||
|
||||
roots, err := kv.rootsToPrune(ctx)
|
||||
roots, err := k.rootsToPrune(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := kv.DeleteStates(ctx, roots); err != nil {
|
||||
if err := k.DeleteStates(ctx, roots); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return kv.db.Update(func(tx *bolt.Tx) error {
|
||||
return k.db.Update(func(tx *bolt.Tx) error {
|
||||
bkt := tx.Bucket(migrationBucket)
|
||||
return bkt.Put(pruneStatesKey, []byte{0x01})
|
||||
})
|
||||
@ -48,13 +48,13 @@ func (kv *Store) pruneStates(ctx context.Context) error {
|
||||
// * Get last finalized check point
|
||||
// * Rewind end slot until it's not finalized root
|
||||
// * return roots between slot 1 and end slot
|
||||
func (kv *Store) rootsToPrune(ctx context.Context) ([][32]byte, error) {
|
||||
cp, err := kv.FinalizedCheckpoint(ctx)
|
||||
func (k *Store) rootsToPrune(ctx context.Context) ([][32]byte, error) {
|
||||
cp, err := k.FinalizedCheckpoint(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
f := filters.NewFilter().SetStartSlot(1).SetEndSlot(helpers.StartSlot(cp.Epoch))
|
||||
roots, err := kv.BlockRoots(ctx, f)
|
||||
roots, err := k.BlockRoots(ctx, f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ type segment struct {
|
||||
type segments [256]*segment
|
||||
|
||||
func (ss *segments) get(p peer.ID) *segment {
|
||||
return ss[byte(p[len(p)-1])]
|
||||
return ss[p[len(p)-1]]
|
||||
}
|
||||
|
||||
func (ss *segments) countPeers() (count int) {
|
||||
|
@ -103,7 +103,7 @@ func TestConnsToClose(t *testing.T) {
|
||||
t.Fatal("expected no connections")
|
||||
}
|
||||
|
||||
cm = NewConnManager(1, 1, time.Duration(10*time.Minute))
|
||||
cm = NewConnManager(1, 1, 10*time.Minute)
|
||||
not := cm.Notifee()
|
||||
for i := 0; i < 5; i++ {
|
||||
conn := randConn(t, nil)
|
||||
@ -117,7 +117,7 @@ func TestConnsToClose(t *testing.T) {
|
||||
|
||||
func TestGetTagInfo(t *testing.T) {
|
||||
start := time.Now()
|
||||
cm := NewConnManager(1, 1, time.Duration(10*time.Minute))
|
||||
cm := NewConnManager(1, 1, 10*time.Minute)
|
||||
not := cm.Notifee()
|
||||
conn := randConn(t, nil)
|
||||
not.Connected(nil, conn)
|
||||
@ -187,7 +187,7 @@ func TestGetTagInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestTagPeerNonExistant(t *testing.T) {
|
||||
cm := NewConnManager(1, 1, time.Duration(10*time.Minute))
|
||||
cm := NewConnManager(1, 1, 10*time.Minute)
|
||||
|
||||
id := tu.RandPeerIDFatal(t)
|
||||
cm.TagPeer(id, "test", 1)
|
||||
@ -198,7 +198,7 @@ func TestTagPeerNonExistant(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUntagPeer(t *testing.T) {
|
||||
cm := NewConnManager(1, 1, time.Duration(10*time.Minute))
|
||||
cm := NewConnManager(1, 1, 10*time.Minute)
|
||||
not := cm.Notifee()
|
||||
conn := randConn(t, nil)
|
||||
not.Connected(nil, conn)
|
||||
@ -228,7 +228,7 @@ func TestUntagPeer(t *testing.T) {
|
||||
|
||||
func TestGetInfo(t *testing.T) {
|
||||
start := time.Now()
|
||||
gp := time.Duration(10 * time.Minute)
|
||||
gp := 10 * time.Minute
|
||||
cm := NewConnManager(1, 5, gp)
|
||||
not := cm.Notifee()
|
||||
conn := randConn(t, nil)
|
||||
@ -255,7 +255,7 @@ func TestGetInfo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDoubleConnection(t *testing.T) {
|
||||
gp := time.Duration(10 * time.Minute)
|
||||
gp := 10 * time.Minute
|
||||
cm := NewConnManager(1, 5, gp)
|
||||
not := cm.Notifee()
|
||||
conn := randConn(t, nil)
|
||||
@ -271,7 +271,7 @@ func TestDoubleConnection(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDisconnected(t *testing.T) {
|
||||
gp := time.Duration(10 * time.Minute)
|
||||
gp := 10 * time.Minute
|
||||
cm := NewConnManager(1, 5, gp)
|
||||
not := cm.Notifee()
|
||||
conn := randConn(t, nil)
|
||||
@ -605,7 +605,7 @@ func TestPeerProtectionIdempotent(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpsertTag(t *testing.T) {
|
||||
cm := NewConnManager(1, 1, time.Duration(10*time.Minute))
|
||||
cm := NewConnManager(1, 1, 10*time.Minute)
|
||||
not := cm.Notifee()
|
||||
conn := randConn(t, nil)
|
||||
rp := conn.RemotePeer()
|
||||
|
@ -55,7 +55,7 @@ func TestCreateListener(t *testing.T) {
|
||||
t.Errorf("Ip address is not the expected type, wanted %s but got %s", ipAddr.String(), listener.Self().IP().String())
|
||||
}
|
||||
|
||||
if port != int(listener.Self().UDP()) {
|
||||
if port != listener.Self().UDP() {
|
||||
t.Errorf("In correct port number, wanted %d but got %d", port, listener.Self().UDP())
|
||||
}
|
||||
pubkey := listener.Self().Pubkey()
|
||||
|
@ -30,7 +30,6 @@ import (
|
||||
var _ = shared.Service(&Service{})
|
||||
|
||||
var pollingPeriod = 1 * time.Second
|
||||
var ttl = 1 * time.Hour
|
||||
|
||||
const prysmProtocolPrefix = "/prysm/0.0.0"
|
||||
|
||||
@ -94,7 +93,7 @@ func NewService(cfg *Config) (*Service, error) {
|
||||
dopts := []dhtopts.Option{
|
||||
dhtopts.Datastore(dsync.MutexWrap(ds.NewMapDatastore())),
|
||||
dhtopts.Protocols(
|
||||
protocol.ID(prysmProtocolPrefix + "/dht"),
|
||||
prysmProtocolPrefix + "/dht",
|
||||
),
|
||||
}
|
||||
|
||||
@ -189,7 +188,7 @@ func (s *Service) Start() {
|
||||
s.host.ConnManager().Protect(peer.ID, "bootnode")
|
||||
}
|
||||
bcfg := kaddht.DefaultBootstrapConfig
|
||||
bcfg.Period = time.Duration(30 * time.Second)
|
||||
bcfg.Period = 30 * time.Second
|
||||
if err := s.dht.BootstrapWithConfig(s.ctx, bcfg); err != nil {
|
||||
log.WithError(err).Error("Failed to bootstrap DHT")
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ func TestProcessDeposit_InvalidPublicKey(t *testing.T) {
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
}
|
||||
deposits[0].Proof, err = trie.MerkleProof((0))
|
||||
deposits[0].Proof, err = trie.MerkleProof(0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -591,6 +591,6 @@ func (bs *Server) GetValidatorPerformance(
|
||||
AverageActiveValidatorBalance: avgBalance,
|
||||
MissingValidators: missingValidators,
|
||||
TotalValidators: uint64(len(headState.Validators)),
|
||||
TotalActiveValidators: uint64(activeCount),
|
||||
TotalActiveValidators: activeCount,
|
||||
}, nil
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func (vs *Server) GetBlock(ctx context.Context, req *ethpb.BlockRequest) (*ethpb
|
||||
// Use zero hash as stub for state root to compute later.
|
||||
stateRoot := params.BeaconConfig().ZeroHash[:]
|
||||
|
||||
graffiti := bytesutil.ToBytes32([]byte(req.Graffiti))
|
||||
graffiti := bytesutil.ToBytes32(req.Graffiti)
|
||||
|
||||
blk := ðpb.BeaconBlock{
|
||||
Slot: req.Slot,
|
||||
|
@ -117,7 +117,6 @@ go_test(
|
||||
"@com_github_gogo_protobuf//proto:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_core//: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//protocol:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_pubsub//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_pubsub//pb:go_default_library",
|
||||
|
@ -43,5 +43,5 @@ func ReadStatusCode(stream io.Reader, encoding encoder.NetworkEncoding) (uint8,
|
||||
return 0, "", err
|
||||
}
|
||||
|
||||
return uint8(b[0]), string(msg), nil
|
||||
return b[0], string(msg), nil
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/libp2p/go-libp2p-core/peer"
|
||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||
pubsubpb "github.com/libp2p/go-libp2p-pubsub/pb"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
@ -104,7 +103,7 @@ func TestValidateAttesterSlashing_ValidSlashing(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
valid := r.validateAttesterSlashing(ctx, peer.ID("foobar"), msg)
|
||||
valid := r.validateAttesterSlashing(ctx, "foobar", msg)
|
||||
|
||||
if !valid {
|
||||
t.Error("Failed Validation")
|
||||
|
@ -109,7 +109,7 @@ func TestDepositTrieRoot_Fail(t *testing.T) {
|
||||
}
|
||||
|
||||
// Change an element in the data when storing locally
|
||||
copy(data.PublicKey, []byte(strconv.Itoa(i+10)))
|
||||
copy(data.PublicKey, strconv.Itoa(i+10))
|
||||
|
||||
testAcc.Backend.Commit()
|
||||
item, err := ssz.HashTreeRoot(data)
|
||||
|
@ -40,7 +40,7 @@ func Setup() (*TestAccount, error) {
|
||||
// strip off the 0x and the first 2 characters 04 which is always the EC prefix and is not required.
|
||||
publicKeyBytes := crypto.FromECDSAPub(pubKeyECDSA)[4:]
|
||||
var pubKey = make([]byte, 48)
|
||||
copy(pubKey[:], []byte(publicKeyBytes))
|
||||
copy(pubKey[:], publicKeyBytes)
|
||||
|
||||
addr := crypto.PubkeyToAddress(privKey.PublicKey)
|
||||
txOpts := bind.NewKeyedTransactor(privKey)
|
||||
@ -63,12 +63,6 @@ func Amount32Eth() *big.Int {
|
||||
return amount
|
||||
}
|
||||
|
||||
// Amount33Eth returns 33Eth(in wei) in terms of the big.Int type.
|
||||
func Amount33Eth() *big.Int {
|
||||
amount, _ := new(big.Int).SetString(amount33Eth, 10)
|
||||
return amount
|
||||
}
|
||||
|
||||
// LessThan1Eth returns less than 1 Eth(in wei) in terms of the big.Int type.
|
||||
func LessThan1Eth() *big.Int {
|
||||
amount, _ := new(big.Int).SetString(amountLessThan1Eth, 10)
|
||||
|
@ -5,25 +5,6 @@ import (
|
||||
"github.com/prysmaticlabs/go-bitfield"
|
||||
)
|
||||
|
||||
// NewContainerFromAttestations creates a new attestation contain with signature pairs from the
|
||||
// given list of attestations.
|
||||
func NewContainerFromAttestations(atts []*ethpb.Attestation) *AttestationContainer {
|
||||
if len(atts) == 0 {
|
||||
panic("no attestations provided")
|
||||
}
|
||||
var sp []*AttestationContainer_SignaturePair
|
||||
for _, att := range atts {
|
||||
sp = append(sp, &AttestationContainer_SignaturePair{
|
||||
AggregationBits: att.AggregationBits,
|
||||
Signature: att.Signature,
|
||||
})
|
||||
}
|
||||
return &AttestationContainer{
|
||||
Data: atts[0].Data,
|
||||
SignaturePairs: sp,
|
||||
}
|
||||
}
|
||||
|
||||
// Contains returns true if the attestation bits are fully contained in some attestations.
|
||||
func (ac *AttestationContainer) Contains(att *ethpb.Attestation) bool {
|
||||
all := bitfield.NewBitlist(att.AggregationBits.Len())
|
||||
|
@ -11,22 +11,6 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/shared/bls"
|
||||
)
|
||||
|
||||
func TestNewContainerFromAttestations(t *testing.T) {
|
||||
atts := []*ethpb.Attestation{
|
||||
{
|
||||
AggregationBits: bitfield.Bitlist{0b00000001, 0b1},
|
||||
Signature: bls.NewAggregateSignature().Marshal(),
|
||||
Data: ðpb.AttestationData{},
|
||||
},
|
||||
}
|
||||
|
||||
ac := dbpb.NewContainerFromAttestations(atts)
|
||||
|
||||
if len(ac.SignaturePairs) != 1 {
|
||||
t.Errorf("wrong length of pairs. wanted 1 got %d", len(ac.SignaturePairs))
|
||||
}
|
||||
}
|
||||
|
||||
func TestAttestationContainer_Contains(t *testing.T) {
|
||||
tests := []struct {
|
||||
input []bitfield.Bitlist
|
||||
|
@ -6,7 +6,6 @@ package bls
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/dgraph-io/ristretto"
|
||||
bls12 "github.com/herumi/bls-eth-go-binary/bls"
|
||||
@ -38,8 +37,6 @@ const CurveOrder = "524358751751261904794477405081859658376905525005276378226036
|
||||
// The size would be a combination of both the message(32 bytes) and domain(8 bytes) size.
|
||||
const concatMsgDomainSize = 40
|
||||
|
||||
var curveOrder, _ = new(big.Int).SetString(CurveOrder, 10)
|
||||
|
||||
// Signature used in the BLS signature scheme.
|
||||
type Signature struct {
|
||||
s *bls12.Sign
|
||||
@ -64,8 +61,8 @@ func RandKey() *SecretKey {
|
||||
|
||||
// SecretKeyFromBytes creates a BLS private key from a BigEndian byte slice.
|
||||
func SecretKeyFromBytes(priv []byte) (*SecretKey, error) {
|
||||
if len(priv) != params.BeaconConfig().BLSSecretkeyLength {
|
||||
return nil, fmt.Errorf("secret key must be %d bytes", params.BeaconConfig().BLSSecretkeyLength)
|
||||
if len(priv) != params.BeaconConfig().BLSSecretKeyLength {
|
||||
return nil, fmt.Errorf("secret key must be %d bytes", params.BeaconConfig().BLSSecretKeyLength)
|
||||
}
|
||||
secKey := &bls12.SecretKey{}
|
||||
err := secKey.Deserialize(priv)
|
||||
@ -141,8 +138,8 @@ func (s *SecretKey) Sign(msg []byte, domain uint64) *Signature {
|
||||
// Marshal a secret key into a LittleEndian byte slice.
|
||||
func (s *SecretKey) Marshal() []byte {
|
||||
keyBytes := s.p.Serialize()
|
||||
if len(keyBytes) < params.BeaconConfig().BLSSecretkeyLength {
|
||||
emptyBytes := make([]byte, params.BeaconConfig().BLSSecretkeyLength-len(keyBytes))
|
||||
if len(keyBytes) < params.BeaconConfig().BLSSecretKeyLength {
|
||||
emptyBytes := make([]byte, params.BeaconConfig().BLSSecretKeyLength-len(keyBytes))
|
||||
keyBytes = append(emptyBytes, keyBytes...)
|
||||
}
|
||||
return keyBytes
|
||||
|
@ -27,8 +27,8 @@ import (
|
||||
func TestFeedPanics(t *testing.T) {
|
||||
{
|
||||
var f Feed
|
||||
f.Send(int(2))
|
||||
want := feedTypeError{op: "Send", got: reflect.TypeOf(uint64(0)), want: reflect.TypeOf(int(0))}
|
||||
f.Send(2)
|
||||
want := feedTypeError{op: "Send", got: reflect.TypeOf(uint64(0)), want: reflect.TypeOf(0)}
|
||||
if err := checkPanic(want, func() { f.Send(uint64(2)) }); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@ -37,14 +37,14 @@ func TestFeedPanics(t *testing.T) {
|
||||
var f Feed
|
||||
ch := make(chan int)
|
||||
f.Subscribe(ch)
|
||||
want := feedTypeError{op: "Send", got: reflect.TypeOf(uint64(0)), want: reflect.TypeOf(int(0))}
|
||||
want := feedTypeError{op: "Send", got: reflect.TypeOf(uint64(0)), want: reflect.TypeOf(0)}
|
||||
if err := checkPanic(want, func() { f.Send(uint64(2)) }); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
{
|
||||
var f Feed
|
||||
f.Send(int(2))
|
||||
f.Send(2)
|
||||
want := feedTypeError{op: "Subscribe", got: reflect.TypeOf(make(chan uint64)), want: reflect.TypeOf(make(chan<- int))}
|
||||
if err := checkPanic(want, func() { f.Subscribe(make(chan uint64)) }); err != nil {
|
||||
t.Error(err)
|
||||
@ -58,7 +58,7 @@ func TestFeedPanics(t *testing.T) {
|
||||
}
|
||||
{
|
||||
var f Feed
|
||||
if err := checkPanic(errBadChannel, func() { f.Subscribe(int(0)) }); err != nil {
|
||||
if err := checkPanic(errBadChannel, func() { f.Subscribe(0) }); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ func TestMarshalAndUnmarshal(t *testing.T) {
|
||||
t.Fatalf("unable to unmarshal object %v", err)
|
||||
}
|
||||
|
||||
if !bytes.Equal([]byte(newKey.ID), []byte(testID)) {
|
||||
if !bytes.Equal(newKey.ID, testID) {
|
||||
t.Fatalf("retrieved id not the same as pre serialized id: %v ", newKey.ID)
|
||||
}
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ func DecryptKey(keyjson []byte, password string) (*Key, error) {
|
||||
}
|
||||
|
||||
return &Key{
|
||||
ID: uuid.UUID(keyID),
|
||||
ID: keyID,
|
||||
PublicKey: secretKey.PublicKey(),
|
||||
SecretKey: secretKey,
|
||||
}, nil
|
||||
|
@ -5,8 +5,6 @@ package logutil
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"reflect"
|
||||
"runtime"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
@ -25,8 +23,3 @@ func ConfigurePersistentLogging(logFileName string) error {
|
||||
logrus.Info("File logging initialized")
|
||||
return nil
|
||||
}
|
||||
|
||||
// FunctionName returns the string representation of the function name for some interface.
|
||||
func FunctionName(i interface{}) string {
|
||||
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ func TestError(t *testing.T) {
|
||||
val++
|
||||
if val == 1011 {
|
||||
mu.Unlock()
|
||||
return nil, errors.New("Bad number!")
|
||||
return nil, errors.New("bad number")
|
||||
}
|
||||
mu.Unlock()
|
||||
}
|
||||
|
@ -42,11 +42,11 @@ type BeaconChainConfig struct {
|
||||
SecondsPerSlot uint64 `yaml:"SECONDS_PER_SLOT"` // SecondsPerSlot is how many seconds are in a single slot.
|
||||
SlotsPerEpoch uint64 `yaml:"SLOTS_PER_EPOCH"` // SlotsPerEpoch is the number of slots in an epoch.
|
||||
MinSeedLookahead uint64 `yaml:"MIN_SEED_LOOKAHEAD"` // SeedLookahead is the duration of randao look ahead seed.
|
||||
MaxSeedLookhead uint64 `yaml:"ACTIVATION_EXIT_DELAY"` // MaxSeedLookhead is the duration a validator has to wait for entry and exit in epoch.
|
||||
MaxSeedLookahead uint64 `yaml:"MIN_SEED_LOOKAHEAD"` // MaxSeedLookahead is the duration a validator has to wait for entry and exit in epoch.
|
||||
SlotsPerEth1VotingPeriod uint64 `yaml:"SLOTS_PER_ETH1_VOTING_PERIOD"` // SlotsPerEth1VotingPeriod defines how often the merkle root of deposit receipts get updated in beacon node.
|
||||
SlotsPerHistoricalRoot uint64 `yaml:"SLOTS_PER_HISTORICAL_ROOT"` // SlotsPerHistoricalRoot defines how often the historical root is saved.
|
||||
MinValidatorWithdrawabilityDelay uint64 `yaml:"MIN_VALIDATOR_WITHDRAWABILITY_DELAY"` // MinValidatorWithdrawabilityDelay is the shortest amount of time a validator has to wait to withdraw.
|
||||
PersistentCommitteePeriod uint64 `yaml:"PERSISTENT_COMMITTEE_PERIOD"` // PersistentCommitteePeriod is the minimum amount of epochs a validator must participate before exitting.
|
||||
PersistentCommitteePeriod uint64 `yaml:"PERSISTENT_COMMITTEE_PERIOD"` // PersistentCommitteePeriod is the minimum amount of epochs a validator must participate before exiting.
|
||||
MinEpochsToInactivityPenalty uint64 `yaml:"MIN_EPOCHS_TO_INACTIVITY_PENALTY"` // MinEpochsToInactivityPenalty defines the minimum amount of epochs since finality to begin penalizing inactivity.
|
||||
Eth1FollowDistance uint64 // Eth1FollowDistance is the number of eth1.0 blocks to wait before considering a new deposit for voting. This only applies after the chain as been started.
|
||||
SafeSlotsToUpdateJustified uint64 // SafeSlotsToUpdateJustified is the minimal slots needed to update justified check point.
|
||||
@ -82,7 +82,7 @@ type BeaconChainConfig struct {
|
||||
// Prysm constants.
|
||||
GweiPerEth uint64 // GweiPerEth is the amount of gwei corresponding to 1 eth.
|
||||
LogBlockDelay int64 // Number of blocks to wait from the current head before processing logs from the deposit contract.
|
||||
BLSSecretkeyLength int // BLSSecretkeyLength defines the expected length of BLS secret keys in bytes.
|
||||
BLSSecretKeyLength int // BLSSecretKeyLength defines the expected length of BLS secret keys in bytes.
|
||||
BLSPubkeyLength int // BLSPubkeyLength defines the expected length of BLS public keys in bytes.
|
||||
BLSSignatureLength int // BLSSignatureLength defines the expected length of BLS signatures in bytes.
|
||||
DefaultBufferSize int // DefaultBufferSize for channels across the Prysm repository.
|
||||
@ -135,7 +135,7 @@ var defaultBeaconConfig = &BeaconChainConfig{
|
||||
SecondsPerSlot: 12,
|
||||
SlotsPerEpoch: 32,
|
||||
MinSeedLookahead: 1,
|
||||
MaxSeedLookhead: 4,
|
||||
MaxSeedLookahead: 4,
|
||||
SlotsPerEth1VotingPeriod: 1024,
|
||||
SlotsPerHistoricalRoot: 8192,
|
||||
MinValidatorWithdrawabilityDelay: 256,
|
||||
@ -175,7 +175,7 @@ var defaultBeaconConfig = &BeaconChainConfig{
|
||||
// Prysm constants.
|
||||
GweiPerEth: 1000000000,
|
||||
LogBlockDelay: 2,
|
||||
BLSSecretkeyLength: 32,
|
||||
BLSSecretKeyLength: 32,
|
||||
BLSPubkeyLength: 48,
|
||||
BLSSignatureLength: 96,
|
||||
DefaultBufferSize: 10000,
|
||||
@ -257,7 +257,7 @@ func MinimalSpecConfig() *BeaconChainConfig {
|
||||
minimalConfig.MinAttestationInclusionDelay = 1
|
||||
minimalConfig.SlotsPerEpoch = 8
|
||||
minimalConfig.MinSeedLookahead = 1
|
||||
minimalConfig.MaxSeedLookhead = 4
|
||||
minimalConfig.MaxSeedLookahead = 4
|
||||
minimalConfig.SlotsPerEth1VotingPeriod = 16
|
||||
minimalConfig.SlotsPerHistoricalRoot = 64
|
||||
minimalConfig.MinValidatorWithdrawabilityDelay = 256
|
||||
|
@ -12,12 +12,12 @@ func TestEveryRuns(t *testing.T) {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
|
||||
i := 0
|
||||
runutil.RunEvery(ctx, time.Duration(100*time.Millisecond), func() {
|
||||
runutil.RunEvery(ctx, 100*time.Millisecond, func() {
|
||||
i++
|
||||
})
|
||||
|
||||
// Sleep for a bit and ensure the value has increased.
|
||||
time.Sleep(time.Duration(200 * time.Millisecond))
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
||||
if i == 0 {
|
||||
t.Error("Counter failed to increment with ticker")
|
||||
@ -26,12 +26,12 @@ func TestEveryRuns(t *testing.T) {
|
||||
cancel()
|
||||
|
||||
// Sleep for a bit to let the cancel take place.
|
||||
time.Sleep(time.Duration(100 * time.Millisecond))
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
||||
last := i
|
||||
|
||||
// Sleep for a bit and ensure the value has not increased.
|
||||
time.Sleep(time.Duration(200 * time.Millisecond))
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
||||
if i != last {
|
||||
t.Error("Counter incremented after stop")
|
||||
|
@ -91,7 +91,7 @@ func DeterministicDepositsAndKeys(numDeposits uint64) ([]*ethpb.Deposit, []*bls.
|
||||
}
|
||||
requestedDeposits := cachedDeposits[:numDeposits]
|
||||
for i := range requestedDeposits {
|
||||
proof, err := depositTrie.MerkleProof(int(i))
|
||||
proof, err := depositTrie.MerkleProof(i)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "could not create merkle proof")
|
||||
}
|
||||
@ -256,7 +256,7 @@ func DeterministicDepositsAndKeysSameValidator(numDeposits uint64) ([]*ethpb.Dep
|
||||
}
|
||||
requestedDeposits := cachedDeposits[:numDeposits]
|
||||
for i := range requestedDeposits {
|
||||
proof, err := depositTrie.MerkleProof(int(i))
|
||||
proof, err := depositTrie.MerkleProof(i)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrap(err, "could not create merkle proof")
|
||||
}
|
||||
|
@ -100,7 +100,6 @@ func waitForStarted(rpcService *Service, t *testing.T) {
|
||||
s, err := rpcService.Status()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
break
|
||||
}
|
||||
if s {
|
||||
break
|
||||
|
@ -20,7 +20,6 @@ go_library(
|
||||
"@com_github_ipfs_go_log//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_core//crypto:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_core//protocol:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_kad_dht//:go_default_library",
|
||||
"@com_github_libp2p_go_libp2p_kad_dht//opts:go_default_library",
|
||||
"@com_github_multiformats_go_multiaddr//:go_default_library",
|
||||
|
@ -30,7 +30,6 @@ import (
|
||||
logging "github.com/ipfs/go-log"
|
||||
libp2p "github.com/libp2p/go-libp2p"
|
||||
"github.com/libp2p/go-libp2p-core/crypto"
|
||||
"github.com/libp2p/go-libp2p-core/protocol"
|
||||
kaddht "github.com/libp2p/go-libp2p-kad-dht"
|
||||
dhtopts "github.com/libp2p/go-libp2p-kad-dht/opts"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
@ -120,7 +119,7 @@ func startKademliaDHT(privKey crypto.PrivKey) {
|
||||
dopts := []dhtopts.Option{
|
||||
dhtopts.Datastore(dsync.MutexWrap(ds.NewMapDatastore())),
|
||||
dhtopts.Protocols(
|
||||
protocol.ID(dhtProtocol),
|
||||
dhtProtocol,
|
||||
),
|
||||
}
|
||||
|
||||
|
@ -12,10 +12,6 @@ import (
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
)
|
||||
|
||||
const (
|
||||
blsWithdrawalPrefixByte = byte(0)
|
||||
)
|
||||
|
||||
var (
|
||||
numValidators = flag.Int("num-validators", 0, "Number of validators to deterministically include in the generated genesis state")
|
||||
useMainnetConfig = flag.Bool("mainnet-config", false, "Select whether genesis state should be generated with mainnet or minimal (default) params")
|
||||
|
@ -101,7 +101,7 @@ func TestEndtoEndDeposits(t *testing.T) {
|
||||
t.Fatal("no logs")
|
||||
}
|
||||
|
||||
if len(logs) != int((numberOfDeposits * numberOfValidators)) {
|
||||
if len(logs) != int(numberOfDeposits*numberOfValidators) {
|
||||
t.Fatal("No sufficient number of logs")
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ func CreateValidatorAccount(path string, passphrase string) (string, string, err
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
log.Info("Create a new validator account for eth2")
|
||||
log.Info("Enter a password:")
|
||||
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
|
||||
bytePassword, err := terminal.ReadPassword(syscall.Stdin)
|
||||
if err != nil {
|
||||
log.Fatalf("Could not read account password: %v", err)
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ func TestAttests_NextSlot(t *testing.T) {
|
||||
|
||||
cancel()
|
||||
}()
|
||||
timer := time.NewTimer(time.Duration(200 * time.Millisecond))
|
||||
timer := time.NewTimer(200 * time.Millisecond)
|
||||
run(ctx, v)
|
||||
<-timer.C
|
||||
if !v.AttestToBlockHeadCalled {
|
||||
@ -144,7 +144,7 @@ func TestProposes_NextSlot(t *testing.T) {
|
||||
|
||||
cancel()
|
||||
}()
|
||||
timer := time.NewTimer(time.Duration(200 * time.Millisecond))
|
||||
timer := time.NewTimer(200 * time.Millisecond)
|
||||
run(ctx, v)
|
||||
<-timer.C
|
||||
if !v.ProposeBlockCalled {
|
||||
@ -168,7 +168,7 @@ func TestBothProposesAndAttests_NextSlot(t *testing.T) {
|
||||
|
||||
cancel()
|
||||
}()
|
||||
timer := time.NewTimer(time.Duration(200 * time.Millisecond))
|
||||
timer := time.NewTimer(200 * time.Millisecond)
|
||||
run(ctx, v)
|
||||
<-timer.C
|
||||
if !v.AttestToBlockHeadCalled {
|
||||
|
@ -30,7 +30,7 @@ func NewKeystore(path string, passphrase string) (KeyManager, error) {
|
||||
} else {
|
||||
if passphrase == "" {
|
||||
log.Info("Enter your validator account password:")
|
||||
bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
|
||||
bytePassword, err := terminal.ReadPassword(syscall.Stdin)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user