Rename getter functions to be idiomatic (#8320)

* Rename getter functions

* Rename new

* Radek's feedback

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
terence tsao
2021-01-25 13:27:30 -08:00
committed by GitHub
parent b2d6012371
commit d5ec248691
59 changed files with 143 additions and 143 deletions

View File

@@ -118,7 +118,7 @@ func (s *Service) processAttestationsRoutine(subscribedToStateEvents chan struct
log.Warn("Genesis time received, now available to process attestations")
}
st := slotutil.GetSlotTicker(s.genesisTime, params.BeaconConfig().SecondsPerSlot)
st := slotutil.NewSlotTicker(s.genesisTime, params.BeaconConfig().SecondsPerSlot)
for {
select {
case <-s.ctx.Done():

View File

@@ -15,7 +15,7 @@ import (
)
// retrieves the signature set from the raw data, public key,signature and domain provided.
func retrieveSignatureSet(signedData, pub, signature, domain []byte) (*bls.SignatureSet, error) {
func signatureSet(signedData, pub, signature, domain []byte) (*bls.SignatureSet, error) {
publicKey, err := bls.PublicKeyFromBytes(pub)
if err != nil {
return nil, errors.Wrap(err, "could not convert bytes to public key")
@@ -37,7 +37,7 @@ func retrieveSignatureSet(signedData, pub, signature, domain []byte) (*bls.Signa
// verifies the signature from the raw data, public key and domain provided.
func verifySignature(signedData, pub, signature, domain []byte) error {
set, err := retrieveSignatureSet(signedData, pub, signature, domain)
set, err := signatureSet(signedData, pub, signature, domain)
if err != nil {
return err
}
@@ -85,7 +85,7 @@ func BlockSignatureSet(beaconState *stateTrie.BeaconState, block *ethpb.SignedBe
return nil, err
}
proposerPubKey := proposer.PublicKey
return helpers.RetrieveBlockSignatureSet(block.Block, proposerPubKey, block.Signature, domain)
return helpers.BlockSignatureSet(block.Block, proposerPubKey, block.Signature, domain)
}
// RandaoSignatureSet retrieves the relevant randao specific signature set object
@@ -97,7 +97,7 @@ func RandaoSignatureSet(beaconState *stateTrie.BeaconState,
if err != nil {
return nil, err
}
set, err := retrieveSignatureSet(buf, proposerPub, body.RandaoReveal, domain)
set, err := signatureSet(buf, proposerPub, body.RandaoReveal, domain)
if err != nil {
return nil, err
}

View File

@@ -98,7 +98,7 @@ func VerifySigningRoot(obj fssz.HashRoot, pub, signature, domain []byte) error {
// VerifyBlockSigningRoot verifies the signing root of a block given it's public key, signature and domain.
func VerifyBlockSigningRoot(blk *ethpb.BeaconBlock, pub, signature, domain []byte) error {
set, err := RetrieveBlockSignatureSet(blk, pub, signature, domain)
set, err := BlockSignatureSet(blk, pub, signature, domain)
if err != nil {
return err
}
@@ -117,9 +117,9 @@ func VerifyBlockSigningRoot(blk *ethpb.BeaconBlock, pub, signature, domain []byt
return nil
}
// RetrieveBlockSignatureSet retrieves the relevant signature, message and pubkey data from a block and collating it
// BlockSignatureSet retrieves the relevant signature, message and pubkey data from a block and collating it
// into a signature set object.
func RetrieveBlockSignatureSet(blk *ethpb.BeaconBlock, pub, signature, domain []byte) (*bls.SignatureSet, error) {
func BlockSignatureSet(blk *ethpb.BeaconBlock, pub, signature, domain []byte) (*bls.SignatureSet, error) {
publicKey, err := bls.PublicKeyFromBytes(pub)
if err != nil {
return nil, errors.Wrap(err, "could not convert bytes to public key")

View File

@@ -71,7 +71,7 @@ func (s *Store) Blocks(ctx context.Context, f *filters.QueryFilter) ([]*ethpb.Si
err := s.db.View(func(tx *bolt.Tx) error {
bkt := tx.Bucket(blocksBucket)
keys, err := getBlockRootsByFilter(ctx, tx, f)
keys, err := blockRootsByFilter(ctx, tx, f)
if err != nil {
return err
}
@@ -100,7 +100,7 @@ func (s *Store) BlockRoots(ctx context.Context, f *filters.QueryFilter) ([][32]b
defer span.End()
blockRoots := make([][32]byte, 0)
err := s.db.View(func(tx *bolt.Tx) error {
keys, err := getBlockRootsByFilter(ctx, tx, f)
keys, err := blockRootsByFilter(ctx, tx, f)
if err != nil {
return err
}
@@ -143,7 +143,7 @@ func (s *Store) BlocksBySlot(ctx context.Context, slot uint64) (bool, []*ethpb.S
err := s.db.View(func(tx *bolt.Tx) error {
bkt := tx.Bucket(blocksBucket)
keys, err := getBlockRootsBySlot(ctx, tx, slot)
keys, err := blockRootsBySlot(ctx, tx, slot)
if err != nil {
return err
}
@@ -167,7 +167,7 @@ func (s *Store) BlockRootsBySlot(ctx context.Context, slot uint64) (bool, [][32]
defer span.End()
blockRoots := make([][32]byte, 0)
err := s.db.View(func(tx *bolt.Tx) error {
keys, err := getBlockRootsBySlot(ctx, tx, slot)
keys, err := blockRootsBySlot(ctx, tx, slot)
if err != nil {
return err
}
@@ -374,9 +374,9 @@ func (s *Store) HighestSlotBlocksBelow(ctx context.Context, slot uint64) ([]*eth
return []*ethpb.SignedBeaconBlock{blk}, nil
}
// getBlockRootsByFilter retrieves the block roots given the filter criteria.
func getBlockRootsByFilter(ctx context.Context, tx *bolt.Tx, f *filters.QueryFilter) ([][]byte, error) {
ctx, span := trace.StartSpan(ctx, "BeaconDB.getBlockRootsByFilter")
// blockRootsByFilter retrieves the block roots given the filter criteria.
func blockRootsByFilter(ctx context.Context, tx *bolt.Tx, f *filters.QueryFilter) ([][]byte, error) {
ctx, span := trace.StartSpan(ctx, "BeaconDB.blockRootsByFilter")
defer span.End()
// If no filter criteria are specified, return an error.
@@ -394,7 +394,7 @@ func getBlockRootsByFilter(ctx context.Context, tx *bolt.Tx, f *filters.QueryFil
// We retrieve block roots that match a filter criteria of slot ranges, if specified.
filtersMap := f.Filters()
rootsBySlotRange, err := fetchBlockRootsBySlotRange(
rootsBySlotRange, err := blockRootsBySlotRange(
ctx,
tx.Bucket(blockSlotIndicesBucket),
filtersMap[filters.StartSlot],
@@ -431,15 +431,15 @@ func getBlockRootsByFilter(ctx context.Context, tx *bolt.Tx, f *filters.QueryFil
return keys, nil
}
// fetchBlockRootsBySlotRange looks into a boltDB bucket and performs a binary search
// blockRootsBySlotRange looks into a boltDB bucket and performs a binary search
// range scan using sorted left-padded byte keys using a start slot and an end slot.
// However, if step is one, the implemented logic wont skip half of the slots in the range.
func fetchBlockRootsBySlotRange(
func blockRootsBySlotRange(
ctx context.Context,
bkt *bolt.Bucket,
startSlotEncoded, endSlotEncoded, startEpochEncoded, endEpochEncoded, slotStepEncoded interface{},
) ([][]byte, error) {
ctx, span := trace.StartSpan(ctx, "BeaconDB.fetchBlockRootsBySlotRange")
ctx, span := trace.StartSpan(ctx, "BeaconDB.blockRootsBySlotRange")
defer span.End()
// Return nothing when all slot parameters are missing
@@ -501,9 +501,9 @@ func fetchBlockRootsBySlotRange(
return roots, nil
}
// getBlockRootsByFilter retrieves the block roots by slot
func getBlockRootsBySlot(ctx context.Context, tx *bolt.Tx, slot uint64) ([][]byte, error) {
ctx, span := trace.StartSpan(ctx, "BeaconDB.getBlockRootsBySlot")
// blockRootsBySlot retrieves the block roots by slot
func blockRootsBySlot(ctx context.Context, tx *bolt.Tx, slot uint64) ([][]byte, error) {
ctx, span := trace.StartSpan(ctx, "BeaconDB.blockRootsBySlot")
defer span.End()
roots := make([][]byte, 0)

View File

@@ -117,7 +117,7 @@ func main() {
app.Name = "beacon-chain"
app.Usage = "this is a beacon chain implementation for Ethereum 2.0"
app.Action = startNode
app.Version = version.GetVersion()
app.Version = version.Version()
app.Commands = []*cli.Command{
db.DatabaseCommands,
}

View File

@@ -242,7 +242,7 @@ func (b *BeaconNode) Start() {
b.lock.Lock()
log.WithFields(logrus.Fields{
"version": version.GetVersion(),
"version": version.Version(),
}).Info("Starting beacon node")
b.services.StartAll()

View File

@@ -44,7 +44,7 @@ func (s *Service) RefreshENR() {
for _, idx := range committees {
bitV.SetBitAt(idx, true)
}
currentBitV, err := retrieveBitvector(s.dv5Listener.Self().Record())
currentBitV, err := bitvector(s.dv5Listener.Self().Record())
if err != nil {
log.Errorf("Could not retrieve bitfield: %v", err)
return

View File

@@ -36,11 +36,11 @@ func (s *Service) forkDigest() ([4]byte, error) {
// local record values for current and next fork version/epoch.
func (s *Service) compareForkENR(record *enr.Record) error {
currentRecord := s.dv5Listener.LocalNode().Node().Record()
peerForkENR, err := retrieveForkEntry(record)
peerForkENR, err := forkEntry(record)
if err != nil {
return err
}
currentForkENR, err := retrieveForkEntry(currentRecord)
currentForkENR, err := forkEntry(currentRecord)
if err != nil {
return err
}
@@ -124,7 +124,7 @@ func addForkEntry(
// Retrieves an enrForkID from an ENR record by key lookup
// under the eth2EnrKey.
func retrieveForkEntry(record *enr.Record) (*pb.ENRForkID, error) {
func forkEntry(record *enr.Record) (*pb.ENRForkID, error) {
sszEncodedForkEntry := make([]byte, 16)
entry := enr.WithEntry(eth2ENRKey, &sszEncodedForkEntry)
err := record.Load(entry)

View File

@@ -229,7 +229,7 @@ func TestDiscv5_AddRetrieveForkEntryENR(t *testing.T) {
}
enc, err := enrForkID.MarshalSSZ()
require.NoError(t, err)
forkEntry := enr.WithEntry(eth2ENRKey, enc)
entry := enr.WithEntry(eth2ENRKey, enc)
// In epoch 1 of current time, the fork version should be
// {0, 0, 0, 1} according to the configuration override above.
temp := t.TempDir()
@@ -241,12 +241,12 @@ func TestDiscv5_AddRetrieveForkEntryENR(t *testing.T) {
db, err := enode.OpenDB("")
require.NoError(t, err)
localNode := enode.NewLocalNode(db, pkey)
localNode.Set(forkEntry)
localNode.Set(entry)
want, err := helpers.ComputeForkDigest([]byte{0, 0, 0, 0}, genesisValidatorsRoot)
require.NoError(t, err)
resp, err := retrieveForkEntry(localNode.Node().Record())
resp, err := forkEntry(localNode.Node().Record())
require.NoError(t, err)
assert.DeepEqual(t, want[:], resp.CurrentForkDigest)
assert.DeepEqual(t, nextForkVersion, resp.NextForkVersion)
@@ -266,7 +266,7 @@ func TestAddForkEntry_Genesis(t *testing.T) {
localNode := enode.NewLocalNode(db, pkey)
localNode, err = addForkEntry(localNode, time.Now().Add(10*time.Second), bytesutil.PadTo([]byte{'A', 'B', 'C', 'D'}, 32))
require.NoError(t, err)
forkEntry, err := retrieveForkEntry(localNode.Node().Record())
forkEntry, err := forkEntry(localNode.Node().Record())
require.NoError(t, err)
assert.DeepEqual(t,
params.BeaconConfig().GenesisForkVersion, forkEntry.NextForkVersion,

View File

@@ -32,7 +32,7 @@ func (s *Service) buildOptions(ip net.IP, priKey *ecdsa.PrivateKey) []libp2p.Opt
options := []libp2p.Option{
privKeyOption(priKey),
libp2p.ListenAddrs(listen),
libp2p.UserAgent(version.GetBuildData()),
libp2p.UserAgent(version.BuildData()),
libp2p.ConnectionGater(s),
}

View File

@@ -13,6 +13,6 @@ func Benchmark_retrieveIndicesFromBitfield(b *testing.B) {
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
retrieveIndicesFromBitfield(bv)
indicesFromBitfield(bv)
}
}

View File

@@ -237,7 +237,7 @@ func (p *Status) CommitteeIndices(pid peer.ID) ([]uint64, error) {
if peerData.Enr == nil || peerData.MetaData == nil {
return []uint64{}, nil
}
return retrieveIndicesFromBitfield(peerData.MetaData.Attnets), nil
return indicesFromBitfield(peerData.MetaData.Attnets), nil
}
return nil, peerdata.ErrPeerUnknown
}
@@ -253,7 +253,7 @@ func (p *Status) SubscribedToSubnet(index uint64) []peer.ID {
// look at active peers
connectedStatus := peerData.ConnState == PeerConnecting || peerData.ConnState == PeerConnected
if connectedStatus && peerData.MetaData != nil && peerData.MetaData.Attnets != nil {
indices := retrieveIndicesFromBitfield(peerData.MetaData.Attnets)
indices := indicesFromBitfield(peerData.MetaData.Attnets)
for _, idx := range indices {
if idx == index {
peers = append(peers, pid)
@@ -796,7 +796,7 @@ func sameIP(firstAddr, secondAddr ma.Multiaddr) bool {
return firstIP.Equal(secondIP)
}
func retrieveIndicesFromBitfield(bitV bitfield.Bitvector64) []uint64 {
func indicesFromBitfield(bitV bitfield.Bitvector64) []uint64 {
committeeIdxs := make([]uint64, 0, bitV.Count())
for i := uint64(0); i < 64; i++ {
if bitV.BitAt(i) {

View File

@@ -73,7 +73,7 @@ func (s *Service) filterPeerForSubnet(index uint64) func(node *enode.Node) bool
if !s.filterPeer(node) {
return false
}
subnets, err := retrieveAttSubnets(node.Record())
subnets, err := attSubnets(node.Record())
if err != nil {
return false
}
@@ -119,8 +119,8 @@ func intializeAttSubnets(node *enode.LocalNode) *enode.LocalNode {
// Reads the attestation subnets entry from a node's ENR and determines
// the committee indices of the attestation subnets the node is subscribed to.
func retrieveAttSubnets(record *enr.Record) ([]uint64, error) {
bitV, err := retrieveBitvector(record)
func attSubnets(record *enr.Record) ([]uint64, error) {
bitV, err := bitvector(record)
if err != nil {
return nil, err
}
@@ -135,7 +135,7 @@ func retrieveAttSubnets(record *enr.Record) ([]uint64, error) {
// Parses the attestation subnets ENR entry in a node and extracts its value
// as a bitvector for further manipulation.
func retrieveBitvector(record *enr.Record) (bitfield.Bitvector64, error) {
func bitvector(record *enr.Record) (bitfield.Bitvector64, error) {
bitV := bitfield.NewBitvector64()
entry := enr.WithEntry(attSubnetEnrKey, &bitV)
err := record.Load(entry)

View File

@@ -87,11 +87,11 @@ func privKey(cfg *Config) (*ecdsa.PrivateKey, error) {
if defaultKeysExist && privateKeyPath == "" {
privateKeyPath = defaultKeyPath
}
return retrievePrivKeyFromFile(privateKeyPath)
return privKeyFromFile(privateKeyPath)
}
// Retrieves a p2p networking private key from a file path.
func retrievePrivKeyFromFile(path string) (*ecdsa.PrivateKey, error) {
func privKeyFromFile(path string) (*ecdsa.PrivateKey, error) {
src, err := ioutil.ReadFile(path)
if err != nil {
log.WithError(err).Error("Error reading private key from file")

View File

@@ -334,7 +334,7 @@ func (bs *Server) StreamIndexedAttestations(
func (bs *Server) collectReceivedAttestations(ctx context.Context) {
attsByRoot := make(map[[32]byte][]*ethpb.Attestation)
twoThirdsASlot := 2 * slotutil.DivideSlotBy(3) /* 2/3 slot duration */
ticker := slotutil.GetSlotTickerWithOffset(bs.GenesisTimeFetcher.GenesisTime(), twoThirdsASlot, params.BeaconConfig().SecondsPerSlot)
ticker := slotutil.NewSlotTickerWithOffset(bs.GenesisTimeFetcher.GenesisTime(), twoThirdsASlot, params.BeaconConfig().SecondsPerSlot)
for {
select {
case <-ticker.C():

View File

@@ -79,7 +79,7 @@ func (ns *Server) GetGenesis(ctx context.Context, _ *ptypes.Empty) (*ethpb.Genes
// GetVersion checks the version information of the beacon node.
func (ns *Server) GetVersion(_ context.Context, _ *ptypes.Empty) (*ethpb.Version, error) {
return &ethpb.Version{
Version: version.GetVersion(),
Version: version.Version(),
}, nil
}

View File

@@ -71,7 +71,7 @@ func TestNodeServer_GetGenesis(t *testing.T) {
}
func TestNodeServer_GetVersion(t *testing.T) {
v := version.GetVersion()
v := version.Version()
ns := &Server{}
res, err := ns.GetVersion(context.Background(), &ptypes.Empty{})
require.NoError(t, err)

View File

@@ -226,10 +226,10 @@ func (ns *Server) PeerCount(ctx context.Context, _ *ptypes.Empty) (*ethpb.PeerCo
// GetVersion requests that the beacon node identify information about its implementation in a
// format similar to a HTTP User-Agent field.
func (ns *Server) GetVersion(ctx context.Context, _ *ptypes.Empty) (*ethpb.VersionResponse, error) {
ctx, span := trace.StartSpan(ctx, "nodev1.GetVersion")
ctx, span := trace.StartSpan(ctx, "nodev1.Version")
defer span.End()
v := fmt.Sprintf("Prysm/%s (%s %s)", version.GetSemanticVersion(), runtime.GOOS, runtime.GOARCH)
v := fmt.Sprintf("Prysm/%s (%s %s)", version.SemanticVersion(), runtime.GOOS, runtime.GOARCH)
return &ethpb.VersionResponse{
Data: &ethpb.Version{
Version: v,

View File

@@ -35,7 +35,7 @@ func (id dummyIdentity) Verify(_ *enr.Record, _ []byte) error { return nil }
func (id dummyIdentity) NodeAddr(_ *enr.Record) []byte { return id[:] }
func TestGetVersion(t *testing.T) {
semVer := version.GetSemanticVersion()
semVer := version.SemanticVersion()
os := runtime.GOOS
arch := runtime.GOARCH
res, err := (&Server{}).GetVersion(context.Background(), &ptypes.Empty{})

View File

@@ -61,7 +61,7 @@ func (vs *Server) StreamDuties(req *ethpb.DutiesRequest, stream ethpb.BeaconNode
defer stateSub.Unsubscribe()
secondsPerEpoch := params.BeaconConfig().SecondsPerSlot * params.BeaconConfig().SlotsPerEpoch
epochTicker := slotutil.GetSlotTicker(vs.TimeFetcher.GenesisTime(), secondsPerEpoch)
epochTicker := slotutil.NewSlotTicker(vs.TimeFetcher.GenesisTime(), secondsPerEpoch)
for {
select {
// Ticks every epoch to submit assignments to connected validator clients.

View File

@@ -135,7 +135,7 @@ func (vs *Server) validatorStatus(
Status: ethpb.ValidatorStatus_UNKNOWN_STATUS,
ActivationEpoch: params.BeaconConfig().FarFutureEpoch,
}
vStatus, idx, err := retrieveStatusForPubKey(headState, pubKey)
vStatus, idx, err := statusForPubKey(headState, pubKey)
if err != nil && err != errPubkeyDoesNotExist {
traceutil.AnnotateError(span, err)
return resp, nonExistentIndex
@@ -217,7 +217,7 @@ func (vs *Server) validatorStatus(
}
}
func retrieveStatusForPubKey(headState *stateTrie.BeaconState, pubKey []byte) (ethpb.ValidatorStatus, uint64, error) {
func statusForPubKey(headState *stateTrie.BeaconState, pubKey []byte) (ethpb.ValidatorStatus, uint64, error) {
if headState == nil {
return ethpb.ValidatorStatus_UNKNOWN_STATUS, 0, errors.New("head state does not exist")
}

View File

@@ -228,7 +228,7 @@ func (b *BeaconState) FieldReferencesCount() map[string]uint64 {
// pads the leaves to a length of 32.
func merkleize(leaves [][]byte) [][][]byte {
hashFunc := hashutil.CustomSHA256Hasher()
layers := make([][][]byte, htrutils.GetDepth(uint64(len(leaves)))+1)
layers := make([][][]byte, htrutils.Depth(uint64(len(leaves)))+1)
for len(leaves) != 32 {
leaves = append(leaves, make([]byte, 32))
}

View File

@@ -33,7 +33,7 @@ func (h *stateRootHasher) arraysRoot(input [][]byte, length uint64, fieldName st
defer lock.Unlock()
hashFunc := hashutil.CustomSHA256Hasher()
if _, ok := layersCache[fieldName]; !ok && h.rootsCache != nil {
depth := htrutils.GetDepth(length)
depth := htrutils.Depth(length)
layersCache[fieldName] = make([][][32]byte, depth+1)
}
@@ -93,7 +93,7 @@ func (h *stateRootHasher) merkleizeWithCache(leaves [][32]byte, length uint64,
return leaves[0]
}
hashLayer := leaves
layers := make([][][32]byte, htrutils.GetDepth(length)+1)
layers := make([][][32]byte, htrutils.Depth(length)+1)
if items, ok := layersCache[fieldName]; ok && h.rootsCache != nil {
if len(items[0]) == len(leaves) {
layers = items

View File

@@ -19,7 +19,7 @@ func ReturnTrieLayer(elements [][32]byte, length uint64) [][]*[32]byte {
return [][]*[32]byte{{&leaves[0]}}
}
hashLayer := leaves
layers := make([][][32]byte, htrutils.GetDepth(length)+1)
layers := make([][][32]byte, htrutils.Depth(length)+1)
layers[0] = hashLayer
layers, _ = merkleizeTrieLeaves(layers, hashLayer, hasher)
refLayers := make([][]*[32]byte, len(layers))
@@ -38,7 +38,7 @@ func ReturnTrieLayer(elements [][32]byte, length uint64) [][]*[32]byte {
// it.
func ReturnTrieLayerVariable(elements [][32]byte, length uint64) [][]*[32]byte {
hasher := hashutil.CustomSHA256Hasher()
depth := htrutils.GetDepth(length)
depth := htrutils.Depth(length)
layers := make([][]*[32]byte, depth+1)
// Return zerohash at depth
if len(elements) == 0 {

View File

@@ -304,7 +304,7 @@ func (f *blocksFetcher) requestBlocks(
if ctx.Err() != nil {
return nil, ctx.Err()
}
l := f.getPeerLock(pid)
l := f.peerLock(pid)
l.Lock()
log.WithFields(logrus.Fields{
"peer": pid,
@@ -334,7 +334,7 @@ func (f *blocksFetcher) requestBlocksByRoot(
if ctx.Err() != nil {
return nil, ctx.Err()
}
l := f.getPeerLock(pid)
l := f.peerLock(pid)
l.Lock()
log.WithFields(logrus.Fields{
"peer": pid,

View File

@@ -17,8 +17,8 @@ import (
"go.opencensus.io/trace"
)
// getPeerLock returns peer lock for a given peer. If lock is not found, it is created.
func (f *blocksFetcher) getPeerLock(pid peer.ID) *peerLock {
// peerLock returns peer lock for a given peer. If lock is not found, it is created.
func (f *blocksFetcher) peerLock(pid peer.ID) *peerLock {
f.Lock()
defer f.Unlock()
if lock, ok := f.peerLocks[pid]; ok && lock != nil {

View File

@@ -205,7 +205,7 @@ func (s *Service) subscribeStaticWithSubnets(topic string, validator pubsub.Vali
s.subscribeWithBase(s.addDigestAndIndexToTopic(topic, i), validator, handle)
}
genesis := s.chain.GenesisTime()
ticker := slotutil.GetSlotTicker(genesis, params.BeaconConfig().SecondsPerSlot)
ticker := slotutil.NewSlotTicker(genesis, params.BeaconConfig().SecondsPerSlot)
go func() {
for {
@@ -252,7 +252,7 @@ func (s *Service) subscribeDynamicWithSubnets(
}
subscriptions := make(map[uint64]*pubsub.Subscription, params.BeaconConfig().MaxCommitteesPerSlot)
genesis := s.chain.GenesisTime()
ticker := slotutil.GetSlotTicker(genesis, params.BeaconConfig().SecondsPerSlot)
ticker := slotutil.NewSlotTicker(genesis, params.BeaconConfig().SecondsPerSlot)
go func() {
for {

View File

@@ -105,7 +105,7 @@ func StartBootnode(t *testing.T) string {
t.Fatalf("could not find enr for bootnode, this means the bootnode had issues starting: %v", err)
}
enr, err := getENRFromLogFile(stdOutFile.Name())
enr, err := enrFromLogFile(stdOutFile.Name())
if err != nil {
t.Fatalf("could not get enr for bootnode: %v", err)
}
@@ -113,7 +113,7 @@ func StartBootnode(t *testing.T) string {
return enr
}
func getENRFromLogFile(name string) (string, error) {
func enrFromLogFile(name string) (string, error) {
byteContent, err := ioutil.ReadFile(name)
if err != nil {
return "", err

View File

@@ -97,7 +97,7 @@ func runEndToEndTest(t *testing.T, config *types.E2EConfig) {
// Offsetting the ticker from genesis so it ticks in the middle of an epoch, in order to keep results consistent.
tickingStartTime := genesisTime.Add(middleOfEpoch)
ticker := helpers.GetEpochTicker(tickingStartTime, epochSeconds)
ticker := helpers.NewEpochTicker(tickingStartTime, epochSeconds)
for currentEpoch := range ticker.C() {
for _, evaluator := range config.Evaluators {
// Only run if the policy says so.

View File

@@ -113,7 +113,7 @@ func metricsTest(conns ...*grpc.ClientConn) error {
if err != nil {
return err
}
timeSlot, err := getValueOfTopic(pageContent, "beacon_clock_time_slot")
timeSlot, err := valueOfTopic(pageContent, "beacon_clock_time_slot")
if err != nil {
return err
}
@@ -148,7 +148,7 @@ func metricsTest(conns ...*grpc.ClientConn) error {
}
func metricCheckLessThan(pageContent, topic string, value int) error {
topicValue, err := getValueOfTopic(pageContent, topic)
topicValue, err := valueOfTopic(pageContent, topic)
if err != nil {
return err
}
@@ -164,7 +164,7 @@ func metricCheckLessThan(pageContent, topic string, value int) error {
}
func metricCheckComparison(pageContent, topic1, topic2 string, comparison float64) error {
topic2Value, err := getValueOfTopic(pageContent, topic2)
topic2Value, err := valueOfTopic(pageContent, topic2)
// If we can't find the first topic (error metrics), then assume the test passes.
if topic2Value != -1 {
return nil
@@ -172,7 +172,7 @@ func metricCheckComparison(pageContent, topic1, topic2 string, comparison float6
if err != nil {
return err
}
topic1Value, err := getValueOfTopic(pageContent, topic1)
topic1Value, err := valueOfTopic(pageContent, topic1)
if topic1Value != -1 {
return nil
}
@@ -192,7 +192,7 @@ func metricCheckComparison(pageContent, topic1, topic2 string, comparison float6
return nil
}
func getValueOfTopic(pageContent, topic string) (int, error) {
func valueOfTopic(pageContent, topic string) (int, error) {
regexExp, err := regexp.Compile(topic + " ")
if err != nil {
return -1, errors.Wrap(err, "could not create regex expression")

View File

@@ -30,8 +30,8 @@ func (s *EpochTicker) Done() {
}()
}
// GetEpochTicker is the constructor for EpochTicker.
func GetEpochTicker(genesisTime time.Time, secondsPerEpoch uint64) *EpochTicker {
// NewEpochTicker starts the EpochTicker.
func NewEpochTicker(genesisTime time.Time, secondsPerEpoch uint64) *EpochTicker {
ticker := &EpochTicker{
c: make(chan uint64),
done: make(chan struct{}),

View File

@@ -12,8 +12,8 @@ import (
const fileBase = "0-11-0/mainnet/beaconstate"
const fileBaseENV = "BEACONSTATES_PATH"
// GetBeaconFuzzState returns a beacon state by ID using the beacon-fuzz corpora.
func GetBeaconFuzzState(ID uint64) (*pb.BeaconState, error) {
// BeaconFuzzState returns a beacon state by ID using the beacon-fuzz corpora.
func BeaconFuzzState(ID uint64) (*pb.BeaconState, error) {
base := fileBase
// Using an environment variable allows a host image to specify the path when only the binary
// executable was uploaded (without the runfiles). i.e. fuzzit's platform.

View File

@@ -7,6 +7,6 @@ import (
)
func TestGetBeaconFuzzState(t *testing.T) {
_, err := GetBeaconFuzzState(1)
_, err := BeaconFuzzState(1)
require.NoError(t, err)
}

View File

@@ -29,8 +29,8 @@ const (
bit5
)
// GetDepth retrieves the appropriate depth for the provided trie size.
func GetDepth(v uint64) (out uint8) {
// Depth retrieves the appropriate depth for the provided trie size.
func Depth(v uint64) (out uint8) {
// bitmagic: binary search through a uint32, offset down by 1 to not round powers of 2 up.
// Then adding 1 to it to not get the index of the first bit, but the length of the bits (depth of tree)
// Zero is a special case, it has a 0 depth.
@@ -81,8 +81,8 @@ func Merkleize(hasher Hasher, count, limit uint64, leaf func(i uint64) []byte) (
}
return
}
depth := GetDepth(count)
limitDepth := GetDepth(limit)
depth := Depth(count)
limitDepth := Depth(limit)
tmp := make([][32]byte, limitDepth+1)
j := uint8(0)
@@ -144,8 +144,8 @@ func ConstructProof(hasher Hasher, count, limit uint64, leaf func(i uint64) []by
if limit <= 1 {
return
}
depth := GetDepth(count)
limitDepth := GetDepth(limit)
depth := Depth(count)
limitDepth := Depth(limit)
branch = append(branch, trieutil.ZeroHashes[:limitDepth]...)
tmp := make([][32]byte, limitDepth+1)

View File

@@ -12,7 +12,7 @@ func TestGetDepth(t *testing.T) {
trieSize := uint64(896745231)
expected := uint8(30)
result := htrutils.GetDepth(trieSize)
result := htrutils.Depth(trieSize)
assert.Equal(t, expected, result)
}

View File

@@ -8,7 +8,7 @@ import (
// ExternalIPv4 returns the first IPv4 available.
func ExternalIPv4() (string, error) {
ips, err := retrieveIPAddrs()
ips, err := ipAddrs()
if err != nil {
return "", err
}
@@ -28,7 +28,7 @@ func ExternalIPv4() (string, error) {
// ExternalIPv6 retrieves any allocated IPv6 addresses
// from the accessible network interfaces.
func ExternalIPv6() (string, error) {
ips, err := retrieveIPAddrs()
ips, err := ipAddrs()
if err != nil {
return "", err
}
@@ -49,7 +49,7 @@ func ExternalIPv6() (string, error) {
// ExternalIP returns the first IPv4/IPv6 available.
func ExternalIP() (string, error) {
ips, err := retrieveIPAddrs()
ips, err := ipAddrs()
if err != nil {
return "", err
}
@@ -59,8 +59,8 @@ func ExternalIP() (string, error) {
return ips[0].String(), nil
}
// retrieveIP returns all the valid IPs available.
func retrieveIPAddrs() ([]net.IP, error) {
// ipAddrs returns all the valid IPs available.
func ipAddrs() ([]net.IP, error) {
ifaces, err := net.Interfaces()
if err != nil {
return nil, err

View File

@@ -237,7 +237,7 @@ func decryptKeyJSON(keyProtected *encryptedKeyJSON, auth string) (keyBytes, keyI
return nil, nil, err
}
derivedKey, err := getKDFKey(keyProtected.Crypto, auth)
derivedKey, err := kdfKey(keyProtected.Crypto, auth)
if err != nil {
return nil, nil, err
}
@@ -254,7 +254,7 @@ func decryptKeyJSON(keyProtected *encryptedKeyJSON, auth string) (keyBytes, keyI
return plainText, keyID, nil
}
func getKDFKey(cryptoJSON cryptoJSON, auth string) ([]byte, error) {
func kdfKey(cryptoJSON cryptoJSON, auth string) ([]byte, error) {
authArray := []byte(auth)
salt, err := hex.DecodeString(cryptoJSON.KDFParams["salt"].(string))
if err != nil {

View File

@@ -34,7 +34,7 @@ func execShellOutputFunc(ctx context.Context, command string, args ...string) (s
return string(result), nil
}
func getSupportedPlatforms() []platform {
func supportedPlatforms() []platform {
return []platform{
{os: "linux", arch: "amd64"},
{os: "linux", arch: "arm64"},
@@ -66,7 +66,7 @@ func parseVersion(input string, num int, sep string) ([]int, error) {
// meetsMinPlatformReqs returns true if the runtime matches any on the list of supported platforms
func meetsMinPlatformReqs(ctx context.Context) (bool, error) {
okPlatforms := getSupportedPlatforms()
okPlatforms := supportedPlatforms()
for _, platform := range okPlatforms {
if runtimeOS == platform.os && runtimeArch == platform.arch {
// If MacOS we make sure it meets the minimum version cutoff

View File

@@ -61,8 +61,8 @@ func TestLogrusCollector(t *testing.T) {
logExampleMessage(log.StandardLogger(), tt.level)
}
time.Sleep(time.Millisecond)
metrics := getMetrics(t)
count := getValueFor(t, metrics, prefix, tt.level)
metrics := metrics(t)
count := valueFor(t, metrics, prefix, tt.level)
if count != tt.want {
t.Errorf("Expecting %d and receive %d", tt.want, count)
}
@@ -70,7 +70,7 @@ func TestLogrusCollector(t *testing.T) {
}
}
func getMetrics(t *testing.T) []string {
func metrics(t *testing.T) []string {
resp, err := http.Get(fmt.Sprintf("http://%s/metrics", addr))
require.NoError(t, err)
body, err := ioutil.ReadAll(resp.Body)
@@ -78,7 +78,7 @@ func getMetrics(t *testing.T) []string {
return strings.Split(string(body), "\n")
}
func getValueFor(t *testing.T, metrics []string, prefix string, level log.Level) int {
func valueFor(t *testing.T, metrics []string, prefix string, level log.Level) int {
// Expect line with this pattern:
// # HELP log_entries_total Total number of log messages.
// # TYPE log_entries_total counter

View File

@@ -38,8 +38,8 @@ func (s *SlotTicker) Done() {
}()
}
// GetSlotTicker is the constructor for SlotTicker.
func GetSlotTicker(genesisTime time.Time, secondsPerSlot uint64) *SlotTicker {
// NewSlotTicker starts and returns a new SlotTicker instance.
func NewSlotTicker(genesisTime time.Time, secondsPerSlot uint64) *SlotTicker {
if genesisTime.IsZero() {
panic("zero genesis time")
}
@@ -51,9 +51,9 @@ func GetSlotTicker(genesisTime time.Time, secondsPerSlot uint64) *SlotTicker {
return ticker
}
// GetSlotTickerWithOffset is a constructor for SlotTicker that allows a offset of time from genesis,
// NewSlotTickerWithOffset starts and returns a SlotTicker instance that allows a offset of time from genesis,
// entering a offset greater than secondsPerSlot is not allowed.
func GetSlotTickerWithOffset(genesisTime time.Time, offset time.Duration, secondsPerSlot uint64) *SlotTicker {
func NewSlotTickerWithOffset(genesisTime time.Time, offset time.Duration, secondsPerSlot uint64) *SlotTicker {
if genesisTime.Unix() == 0 {
panic("zero genesis time")
}

View File

@@ -115,8 +115,8 @@ func TestGetSlotTickerWithOffset_OK(t *testing.T) {
secondsPerSlot := uint64(4)
offset := time.Duration(secondsPerSlot/2) * time.Second
offsetTicker := GetSlotTickerWithOffset(genesisTime, offset, secondsPerSlot)
normalTicker := GetSlotTicker(genesisTime, secondsPerSlot)
offsetTicker := NewSlotTickerWithOffset(genesisTime, offset, secondsPerSlot)
normalTicker := NewSlotTicker(genesisTime, secondsPerSlot)
firstTicked := 0
for {

View File

@@ -36,7 +36,7 @@ func Setup(serviceName, processName, endpoint string, sampleFraction float64, en
ServiceName: serviceName,
Tags: []jaeger.Tag{
jaeger.StringTag("process_name", processName),
jaeger.StringTag("version", version.GetVersion()),
jaeger.StringTag("version", version.Version()),
},
},
BufferMaxCount: 10000,

View File

@@ -15,22 +15,22 @@ var gitCommit = "Local build"
var buildDate = "Moments ago"
var gitTag = "Unknown"
// GetVersion returns the version string of this build.
func GetVersion() string {
// Version returns the version string of this build.
func Version() string {
if buildDate == "{DATE}" {
now := time.Now().Format(time.RFC3339)
buildDate = now
}
return fmt.Sprintf("%s. Built at: %s", GetBuildData(), buildDate)
return fmt.Sprintf("%s. Built at: %s", BuildData(), buildDate)
}
// GetSemanticVersion returns the Major.Minor.Patch version of this build.
func GetSemanticVersion() string {
// SemanticVersion returns the Major.Minor.Patch version of this build.
func SemanticVersion() string {
return gitTag
}
// GetBuildData returns the git tag and commit of the current build.
func GetBuildData() string {
// BuildData returns the git tag and commit of the current build.
func BuildData() string {
// if doing a local build, these values are not interpolated
if gitCommit == "{STABLE_GIT_COMMIT}" {
commit, err := exec.Command("git", "rev-parse", "HEAD").Output()

View File

@@ -90,7 +90,7 @@ func main() {
app := cli.App{}
app.Name = "hash slinging slasher"
app.Usage = `launches an Ethereum Serenity slasher server that interacts with a beacon chain.`
app.Version = version.GetVersion()
app.Version = version.Version()
app.Commands = []*cli.Command{
db.DatabaseCommands,
}

View File

@@ -119,7 +119,7 @@ func (n *SlasherNode) Start() {
n.lock.Unlock()
log.WithFields(logrus.Fields{
"version": version.GetVersion(),
"version": version.Version(),
}).Info("Starting slasher client")
stop := n.stop

View File

@@ -341,7 +341,7 @@ func walkThroughEmbeddedInterfaces(sel *types.Selection) ([]types.Type, bool) {
// index because it would give the method itself.
indexes := sel.Index()
for _, fieldIndex := range indexes[:len(indexes)-1] {
currentT = getTypeAtFieldIndex(currentT, fieldIndex)
currentT = typeAtFieldIndex(currentT, fieldIndex)
}
// Now currentT is either a type implementing the actual function,
@@ -366,7 +366,7 @@ func walkThroughEmbeddedInterfaces(sel *types.Selection) ([]types.Type, bool) {
for !explicitlyDefinesMethod(interfaceT, fn) {
// Otherwise, we find which of the embedded interfaces _does_
// define the method, add it to our list, and loop.
namedInterfaceT, ok := getEmbeddedInterfaceDefiningMethod(interfaceT, fn)
namedInterfaceT, ok := embeddedInterfaceDefiningMethod(interfaceT, fn)
if !ok {
// This should be impossible as long as we type-checked: either the
// interface or one of its embedded ones must implement the method...
@@ -382,7 +382,7 @@ func walkThroughEmbeddedInterfaces(sel *types.Selection) ([]types.Type, bool) {
return result, true
}
func getTypeAtFieldIndex(startingAt types.Type, fieldIndex int) types.Type {
func typeAtFieldIndex(startingAt types.Type, fieldIndex int) types.Type {
t := maybeUnname(maybeDereference(startingAt))
s, ok := t.(*types.Struct)
if !ok {
@@ -392,12 +392,12 @@ func getTypeAtFieldIndex(startingAt types.Type, fieldIndex int) types.Type {
return s.Field(fieldIndex).Type()
}
// getEmbeddedInterfaceDefiningMethod searches through any embedded interfaces of the
// embeddedInterfaceDefiningMethod searches through any embedded interfaces of the
// passed interface searching for one that defines the given function. If found, the
// types.Named wrapping that interface will be returned along with true in the second value.
//
// If no such embedded interface is found, nil and false are returned.
func getEmbeddedInterfaceDefiningMethod(interfaceT *types.Interface, fn *types.Func) (*types.Named, bool) {
func embeddedInterfaceDefiningMethod(interfaceT *types.Interface, fn *types.Func) (*types.Named, bool) {
for i := 0; i < interfaceT.NumEmbeddeds(); i++ {
embedded := interfaceT.Embedded(i)
if definesMethod(embedded.Underlying().(*types.Interface), fn) {

View File

@@ -36,11 +36,11 @@ func StringSlice() {
}
func SliceFromFunction() {
x := getSlice()[:] // want "Expression is already a slice."
x := slice()[:] // want "Expression is already a slice."
if len(x) == 3 {
}
}
func getSlice() []string {
func slice() []string {
return []string{"bar"}
}

View File

@@ -74,7 +74,7 @@ func main() {
}
}
fmt.Printf("Starting bootnode. Version: %s\n", version.GetVersion())
fmt.Printf("Starting bootnode. Version: %s\n", version.Version())
if *debug {
logrus.SetLevel(logrus.DebugLevel)

View File

@@ -43,7 +43,7 @@ func main() {
app := cli.App{}
app.Name = "deployDepositContract"
app.Usage = "this is a util to deploy deposit contract"
app.Version = version.GetVersion()
app.Version = version.Version()
app.Flags = []cli.Flag{
&cli.StringFlag{
Name: "keystoreUTCPath",

View File

@@ -39,7 +39,7 @@ func main() {
app := cli.App{}
app.Name = "drainContracts"
app.Usage = "this is a util to drain all (testing) deposit contracts of their ETH."
app.Version = version.GetVersion()
app.Version = version.Version()
app.Flags = []cli.Flag{
&cli.StringFlag{
Name: "keystoreUTCPath",

View File

@@ -60,7 +60,7 @@ func main() {
t1 := time.Now()
fmt.Printf("Checking %v wallets...\n", len(allWatching))
for _, v := range allWatching {
v.Balance = GetEthBalance(v.Address).String()
v.Balance = EthBalance(v.Address).String()
totalLoaded++
}
t2 := time.Now()
@@ -93,8 +93,8 @@ func ConnectionToGeth(url string) error {
return err
}
// GetEthBalance from remote server.
func GetEthBalance(address string) *big.Float {
// EthBalance from remote server.
func EthBalance(address string) *big.Float {
balance, err := eth.BalanceAt(context.TODO(), common.HexToAddress(address), nil)
if err != nil {
fmt.Printf("Error fetching ETH Balance for address: %v\n", address)

View File

@@ -37,7 +37,7 @@ func main() {
app := cli.App{}
app.Name = "pcli"
app.Usage = "A command line utility to run eth2 specific commands"
app.Version = version.GetVersion()
app.Version = version.Version()
app.Commands = []*cli.Command{
{
Name: "pretty",

View File

@@ -173,7 +173,7 @@ func (v *validator) WaitForChainStart(ctx context.Context) error {
// Once the ChainStart log is received, we update the genesis time of the validator client
// and begin a slot ticker used to track the current slot the beacon node is in.
v.ticker = slotutil.GetSlotTicker(time.Unix(int64(v.genesisTime), 0), params.BeaconConfig().SecondsPerSlot)
v.ticker = slotutil.NewSlotTicker(time.Unix(int64(v.genesisTime), 0), params.BeaconConfig().SecondsPerSlot)
log.WithField("genesisTime", time.Unix(int64(v.genesisTime), 0)).Info("Beacon chain started")
return nil
}

View File

@@ -58,7 +58,7 @@ func (v *validator) WaitForActivation(ctx context.Context, accountsChangedChan c
stream, err := v.validatorClient.WaitForActivation(ctx, req)
if err != nil {
traceutil.AnnotateError(span, err)
attempts := getStreamAttempts(ctx)
attempts := streamAttempts(ctx)
log.WithError(err).WithField("attempts", attempts).
Error("Stream broken while waiting for activation. Reconnecting...")
// Reconnection attempt backoff, up to 60s.
@@ -82,7 +82,7 @@ func (v *validator) WaitForActivation(ctx context.Context, accountsChangedChan c
}
if err != nil {
traceutil.AnnotateError(span, err)
attempts := getStreamAttempts(ctx)
attempts := streamAttempts(ctx)
log.WithError(err).WithField("attempts", attempts).
Error("Stream broken while waiting for activation. Reconnecting...")
// Reconnection attempt backoff, up to 60s.
@@ -108,7 +108,7 @@ func (v *validator) WaitForActivation(ctx context.Context, accountsChangedChan c
break
}
v.ticker = slotutil.GetSlotTicker(time.Unix(int64(v.genesisTime), 0), params.BeaconConfig().SecondsPerSlot)
v.ticker = slotutil.NewSlotTicker(time.Unix(int64(v.genesisTime), 0), params.BeaconConfig().SecondsPerSlot)
return nil
}
@@ -117,7 +117,7 @@ type waitForActivationContextKey string
const waitForActivationAttemptsContextKey = waitForActivationContextKey("WaitForActivation-attempts")
func getStreamAttempts(ctx context.Context) int {
func streamAttempts(ctx context.Context) int {
attempts, ok := ctx.Value(waitForActivationAttemptsContextKey).(int)
if !ok {
return 1
@@ -126,6 +126,6 @@ func getStreamAttempts(ctx context.Context) int {
}
func incrementRetries(ctx context.Context) context.Context {
attempts := getStreamAttempts(ctx)
attempts := streamAttempts(ctx)
return context.WithValue(ctx, waitForActivationAttemptsContextKey, attempts+1)
}

View File

@@ -106,7 +106,7 @@ func main() {
app := cli.App{}
app.Name = "validator"
app.Usage = `launches an Ethereum 2.0 validator client that interacts with a beacon chain, starts proposer and attester services, p2p connections, and more`
app.Version = version.GetVersion()
app.Version = version.Version()
app.Action = startNode
app.Commands = []*cli.Command{
accounts.WalletCommands,

View File

@@ -123,7 +123,7 @@ func (c *ValidatorClient) Start() {
c.lock.Lock()
log.WithFields(logrus.Fields{
"version": version.GetVersion(),
"version": version.Version(),
}).Info("Starting validator node")
c.services.StartAll()

View File

@@ -51,7 +51,7 @@ func (s *Server) GetVersion(ctx context.Context, _ *ptypes.Empty) (*pb.VersionRe
return &pb.VersionResponse{
Beacon: beacon.Version,
Validator: version.GetVersion(),
Validator: version.Version(),
}, nil
}

View File

@@ -45,7 +45,7 @@ func ExportStandardProtectionJSON(ctx context.Context, validatorDB db.Database)
if err != nil {
return nil, err
}
signedBlocks, err := getSignedBlocksByPubKey(ctx, validatorDB, pubKey)
signedBlocks, err := signedBlocksByPubKey(ctx, validatorDB, pubKey)
if err != nil {
return nil, err
}
@@ -62,7 +62,7 @@ func ExportStandardProtectionJSON(ctx context.Context, validatorDB db.Database)
if err != nil {
return nil, err
}
signedAttestations, err := getSignedAttestationsByPubKey(ctx, validatorDB, pubKey)
signedAttestations, err := signedAttestationsByPubKey(ctx, validatorDB, pubKey)
if err != nil {
return nil, err
}
@@ -95,7 +95,7 @@ func ExportStandardProtectionJSON(ctx context.Context, validatorDB db.Database)
return interchangeJSON, nil
}
func getSignedAttestationsByPubKey(ctx context.Context, validatorDB db.Database, pubKey [48]byte) ([]*format.SignedAttestation, error) {
func signedAttestationsByPubKey(ctx context.Context, validatorDB db.Database, pubKey [48]byte) ([]*format.SignedAttestation, error) {
// If a key does not have an attestation history in our database, we return nil.
// This way, a user will be able to export their slashing protection history
// even if one of their keys does not have a history of signed attestations.
@@ -124,7 +124,7 @@ func getSignedAttestationsByPubKey(ctx context.Context, validatorDB db.Database,
return signedAttestations, nil
}
func getSignedBlocksByPubKey(ctx context.Context, validatorDB db.Database, pubKey [48]byte) ([]*format.SignedBlock, error) {
func signedBlocksByPubKey(ctx context.Context, validatorDB db.Database, pubKey [48]byte) ([]*format.SignedBlock, error) {
// If a key does not have a lowest or highest signed proposal history
// in our database, we return nil. This way, a user will be able to export their
// slashing protection history even if one of their keys does not have a history

View File

@@ -19,7 +19,7 @@ func Test_getSignedAttestationsByPubKey(t *testing.T) {
validatorDB := dbtest.SetupDB(t, pubKeys)
// No attestation history stored should return empty.
signedAttestations, err := getSignedAttestationsByPubKey(ctx, validatorDB, pubKeys[0])
signedAttestations, err := signedAttestationsByPubKey(ctx, validatorDB, pubKeys[0])
require.NoError(t, err)
assert.Equal(t, 0, len(signedAttestations))
@@ -37,7 +37,7 @@ func Test_getSignedAttestationsByPubKey(t *testing.T) {
)))
// We then retrieve the signed attestations and expect a correct result.
signedAttestations, err = getSignedAttestationsByPubKey(ctx, validatorDB, pubKeys[0])
signedAttestations, err = signedAttestationsByPubKey(ctx, validatorDB, pubKeys[0])
require.NoError(t, err)
wanted := []*format.SignedAttestation{
@@ -63,7 +63,7 @@ func Test_getSignedBlocksByPubKey(t *testing.T) {
validatorDB := dbtest.SetupDB(t, pubKeys)
// No highest and/or lowest signed blocks will return empty.
signedBlocks, err := getSignedBlocksByPubKey(ctx, validatorDB, pubKeys[0])
signedBlocks, err := signedBlocksByPubKey(ctx, validatorDB, pubKeys[0])
require.NoError(t, err)
assert.Equal(t, 0, len(signedBlocks))
@@ -83,7 +83,7 @@ func Test_getSignedBlocksByPubKey(t *testing.T) {
// We expect a valid proposal history containing slot 1 and slot 5 only
// when we attempt to retrieve it from disk.
signedBlocks, err = getSignedBlocksByPubKey(ctx, validatorDB, pubKeys[0])
signedBlocks, err = signedBlocksByPubKey(ctx, validatorDB, pubKeys[0])
require.NoError(t, err)
wanted := []*format.SignedBlock{
{