Remove unused code (#6065)

* Ran code cleanup from goland

* Typo

* Remove unused code

* Gazelle

* Delete comments
This commit is contained in:
terence tsao 2020-05-31 15:47:15 -07:00 committed by GitHub
parent 6e3b78b99e
commit 6e514b96fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 5 additions and 177 deletions

View File

@ -27,10 +27,7 @@ var (
Name: "beacon_clock_time_slot",
Help: "The current slot based on the genesis time and current clock",
})
competingBlks = promauto.NewCounter(prometheus.CounterOpts{
Name: "competing_blocks",
Help: "The # of blocks received and processed from a competing chain",
})
headFinalizedEpoch = promauto.NewGauge(prometheus.GaugeOpts{
Name: "head_finalized_epoch",
Help: "Last finalized epoch of the head state",

View File

@ -43,42 +43,6 @@ func init() {
logrus.SetOutput(ioutil.Discard)
}
type store struct {
headRoot []byte
}
func (s *store) OnBlock(ctx context.Context, b *ethpb.SignedBeaconBlock) (*beaconstate.BeaconState, error) {
return nil, nil
}
func (s *store) OnBlockCacheFilteredTree(ctx context.Context, b *ethpb.SignedBeaconBlock) (*beaconstate.BeaconState, error) {
return nil, nil
}
func (s *store) OnBlockInitialSyncStateTransition(ctx context.Context, b *ethpb.SignedBeaconBlock) (*beaconstate.BeaconState, error) {
return nil, nil
}
func (s *store) OnAttestation(ctx context.Context, a *ethpb.Attestation) ([]uint64, error) {
return nil, nil
}
func (s *store) GenesisStore(ctx context.Context, justifiedCheckpoint *ethpb.Checkpoint, finalizedCheckpoint *ethpb.Checkpoint) error {
return nil
}
func (s *store) FinalizedCheckpt() *ethpb.Checkpoint {
return nil
}
func (s *store) JustifiedCheckpt() *ethpb.Checkpoint {
return nil
}
func (s *store) Head(ctx context.Context) ([]byte, error) {
return s.headRoot, nil
}
type mockBeaconNode struct {
stateFeed *event.Feed
}

View File

@ -1,9 +1,5 @@
package p2p
import (
p2ppb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
)
const (
// RPCStatusTopic defines the topic for the status rpc method.
RPCStatusTopic = "/eth2/beacon_chain/req/status/1"
@ -18,15 +14,3 @@ const (
// RPCMetaDataTopic defines the topic for the metadata rpc method.
RPCMetaDataTopic = "/eth2/beacon_chain/req/metadata/1"
)
// RPCTopicMappings represent the protocol ID to protobuf message type map for easy
// lookup. These mappings should be used for outbound sending only. Peers may respond
// with a different message type as defined by the p2p protocol.
var RPCTopicMappings = map[string]interface{}{
RPCStatusTopic: &p2ppb.Status{},
RPCGoodByeTopic: new(uint64),
RPCBlocksByRangeTopic: &p2ppb.BeaconBlocksByRangeRequest{},
RPCBlocksByRootTopic: [][32]byte{},
RPCPingTopic: new(uint64),
RPCMetaDataTopic: new(interface{}),
}

View File

@ -6,7 +6,6 @@ import (
"bytes"
"context"
"fmt"
"reflect"
"testing"
"time"
@ -26,15 +25,6 @@ import (
"github.com/sirupsen/logrus"
)
// TopicMappings are the protocol ids for the different types of requests.
var TopicMappings = map[reflect.Type]string{
reflect.TypeOf(&pb.Status{}): "/eth2/beacon_chain/req/status/1",
reflect.TypeOf(new(uint64)): "/eth2/beacon_chain/req/goodbye/1",
reflect.TypeOf(&pb.BeaconBlocksByRangeRequest{}): "/eth2/beacon_chain/req/beacon_blocks_by_range/1",
reflect.TypeOf([][32]byte{}): "/eth2/beacon_chain/req/beacon_blocks_by_root/1",
reflect.TypeOf(new(uint64)): "/eth2/beacon_chain/req/ping/1/",
}
// TestP2P represents a p2p implementation that can be used for testing.
type TestP2P struct {
t *testing.T

View File

@ -5,7 +5,5 @@ import "errors"
var errUnknownStateSummary = errors.New("unknown state summary")
var errUnknownArchivedState = errors.New("unknown archived state")
var errUnknownBoundaryState = errors.New("unknown boundary state")
var errUnknownBoundaryRoot = errors.New("unknown boundary root")
var errUnknownState = errors.New("unknown state")
var errUnknownBlock = errors.New("unknown block")
var errSlotNonArchivedPoint = errors.New("slot is not an archived point index")

View File

@ -13,7 +13,6 @@ import (
)
var (
amount33Eth = "33000000000000000000"
amount32Eth = "32000000000000000000"
amountLessThan1Eth = "500000000000000000"
)

View File

@ -76,18 +76,6 @@ func FromBytes8(x []byte) uint64 {
return binary.LittleEndian.Uint64(x)
}
// LowerThan returns true if byte slice x is lower than byte slice y. (little-endian format)
// This is used in spec to compare winning block root hash.
// Mentioned in spec as "ties broken by favoring lower `shard_block_root` values".
func LowerThan(x []byte, y []byte) bool {
for i, b := range x {
if b > y[i] {
return false
}
}
return true
}
// ToBytes4 is a convenience method for converting a byte slice to a fix
// sized 4 byte array. This method will truncate the input if it is larger
// than 4 bytes.
@ -185,19 +173,6 @@ func FromBytes48Array(x [][48]byte) [][]byte {
return y
}
// Xor xors the bytes in x and y and returns the result.
func Xor(x []byte, y []byte) []byte {
n := len(x)
if len(y) < n {
n = len(y)
}
var result []byte
for i := 0; i < n; i++ {
result = append(result, x[i]^y[i])
}
return result
}
// Trunc truncates the byte slices to 6 bytes.
func Trunc(x []byte) []byte {
if len(x) > 6 {

View File

@ -102,15 +102,6 @@ func HashKeccak256(data []byte) [32]byte {
return b
}
// RepeatHash applies the sha256 hash function repeatedly
// numTimes on a [32]byte array.
func RepeatHash(data [32]byte, numTimes uint64) [32]byte {
if numTimes == 0 {
return data
}
return RepeatHash(Hash(data[:]), numTimes-1)
}
// HashProto hashes a protocol buffer message using sha256.
func HashProto(msg proto.Message) (result [32]byte, err error) {
// Hashing a proto with nil pointers will cause a panic in the unsafe

View File

@ -4,7 +4,6 @@ package testutil
import (
"strings"
"testing"
"time"
"github.com/sirupsen/logrus/hooks/test"
)
@ -41,29 +40,3 @@ func assertLogs(t *testing.T, hook *test.Hook, want string, flag bool) {
t.Fatalf("unwanted log found: %s", want)
}
}
// WaitForLog waits for the desired string to appear the logs within a
// time period. If it does not appear within the limit, the function
// will throw an error.
func WaitForLog(t *testing.T, hook *test.Hook, want string) {
t.Logf("waiting for: %s", want)
match := false
timer := time.After(1 * time.Second)
for {
select {
case <-timer:
t.Fatalf("log not found in time period: %s", want)
default:
if match {
return
}
entries := hook.AllEntries()
for _, e := range entries {
if strings.Contains(e.Message, want) {
match = true
}
}
}
}
}

View File

@ -6,9 +6,9 @@ import (
)
const (
latestEpochKey = "LATEST_EPOCH_DETECTED"
chainHeadKey = "CHAIN_HEAD"
cachedSpanerEpochs = 256
latestEpochKey = "LATEST_EPOCH_DETECTED"
chainHeadKey = "CHAIN_HEAD"
spannerEncodedLength = 7
)

View File

@ -6,10 +6,6 @@ import (
)
var (
doubleProposalsDetected = promauto.NewCounter(prometheus.CounterOpts{
Name: "double_proposals_detected_total",
Help: "The # of double propose slashable events detected",
})
doubleVotesDetected = promauto.NewCounter(prometheus.CounterOpts{
Name: "double_votes_detected_total",
Help: "The # of double vote slashable events detected",

View File

@ -15,8 +15,6 @@ import (
"strings"
)
var fset = token.NewFileSet()
func malign(pos token.Pos, str *types.Struct) error {
wordSize := int64(8)
maxAlign := int64(8)

View File

@ -20,7 +20,6 @@ go_library(
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_pkg_errors//:go_default_library",
"@com_github_prysmaticlabs_go_bitfield//:go_default_library",
"@com_github_sirupsen_logrus//:go_default_library",
"@com_github_wealdtech_go_bytesutil//:go_default_library",
"@io_etcd_go_bbolt//:go_default_library",
"@io_opencensus_go//trace:go_default_library",

View File

@ -8,12 +8,9 @@ import (
"github.com/pkg/errors"
"github.com/prysmaticlabs/prysm/validator/db/iface"
"github.com/sirupsen/logrus"
bolt "go.etcd.io/bbolt"
)
var log = logrus.WithField("prefix", "db")
var _ = iface.ValidatorDB(&Store{})
var databaseFileName = "validator.db"

View File

@ -91,11 +91,7 @@ var (
Usage: "Port used to listening and respond metrics for prometheus.",
Value: 8081,
}
// NoCustomConfigFlag determines whether to launch a beacon chain using real parameters or demo parameters.
NoCustomConfigFlag = &cli.BoolFlag{
Name: "no-custom-config",
Usage: "Run the beacon chain with the real parameters from phase 0.",
}
// PasswordFlag defines the password value for storing and retrieving validator private keys from the keystore.
PasswordFlag = &cli.StringFlag{
Name: "password",

View File

@ -63,35 +63,6 @@ EOG+nLBh0o/dF8ND1LpbdXvQXRyVwRYaofI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l5TcsJtl84GPWILzVowIDAQABo0UwQzAOBgNVHQ8BAf8E
BAMCAQYwEgYDVR0TAQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQUnCGGWuHUASFv4FcE
dHLRgrh4XvYwDQYJKoZIhvcNAQELBQADggIBADXJjjhLrOrdsQLNQgHGL1cXtvmO
uZGbxZXAUPw/rFoL73gPhPm9+c9XSpQETYxNKJk6m4sZSMNNZ3vlrr9TlaIGev3r
06u0/suIj01YM6NAIlHPpflOONQscpEJDvCJEQg5kw/V5AT0OCqsnNholAyhlsjI
4nTAFmR3LY2oMPxgwZY+PrCskvgcNhtR5zh+WxB17TnnKz7yhphWlJHwLfJro928
nB4thhwYNt3C5Z7tGiX/rA3MW7Sh/H34xC9ISs8ybkwVj+EKjf20FADzjRDF49++
hqVDxOJw+W0ahQYHBQ/sTkn9S+Cp6PaAw9+efbPG1YuAkCFOWMDKM/yG5tLIpft+
zASk+VL2WO9oNiJN0rtVwNU//TtENYLS+9p4XTpwEuEIH4ZZApVlEXf0GHKF1x+n
MVH80sXFC9siv5xW76FzvxKv/RZ6fKm8T+uizt8U+jwhL1flS4Ahj7zWUV6cwdWH
57O6FnN+VVNYbV4Ze8SzHS09eS1gBtityJVJttUJk70J/LtMPkaun/+VuMvAha7T
0tPn7P3RbGj8QYVUm+c8Z3arWaJ4K20n3v3rSYtLwV1PpI2T8nL8is7P1AUI4da+
JW5Xg09Yct1izRb64SylduQC9a1bbjoMU0iABaDzCl7AHzK0RlkjALQ4sIt24nKL
Geq0WUbSP2OuDkAf
-----END CERTIFICATE-----`
func TestNewRemoteWallet(t *testing.T) {
tests := []struct {