[project] Dead fields, staticcheck, update deprecated libp2p usages (#2825)

* [project] Dead fields, staticcheck, update deprecated libp2p usages

* [project] Dead gas fild in test
pull/2829/head
Edgar Aroutiounian 5 years ago committed by GitHub
parent 89fe991d59
commit b8798c3ff5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      api/proto/node/node.go
  2. 6
      api/service/networkinfo/service.go
  3. 2
      core/state/journal.go
  4. 5
      core/state/state_object.go
  5. 1
      core/vm/contracts_test.go
  6. 3
      core/vm/jump_table.go
  7. 37
      internal/genesis/genesis_test.go

@ -15,7 +15,7 @@ import (
"github.com/harmony-one/harmony/internal/utils"
"github.com/harmony-one/harmony/staking/slash"
staking "github.com/harmony-one/harmony/staking/types"
peer "github.com/libp2p/go-libp2p-peer"
libp2p_peer "github.com/libp2p/go-libp2p-core/peer"
)
// MessageType is to indicate the specific type of message under Node category
@ -84,7 +84,7 @@ type Info struct {
Port string
PubKey []byte
Role RoleType
PeerID peer.ID // Peerstore ID
PeerID libp2p_peer.ID // Peerstore ID
}
func (info Info) String() string {

@ -14,10 +14,10 @@ import (
"github.com/harmony-one/harmony/p2p"
badger "github.com/ipfs/go-ds-badger"
coredis "github.com/libp2p/go-libp2p-core/discovery"
libp2p_peer "github.com/libp2p/go-libp2p-core/peer"
libp2pdis "github.com/libp2p/go-libp2p-discovery"
libp2pdht "github.com/libp2p/go-libp2p-kad-dht"
libp2pdhtopts "github.com/libp2p/go-libp2p-kad-dht/opts"
peerstore "github.com/libp2p/go-libp2p-peerstore"
manet "github.com/multiformats/go-multiaddr-net"
"github.com/pkg/errors"
)
@ -32,7 +32,7 @@ type Service struct {
stopChan chan struct{}
stoppedChan chan struct{}
peerChan chan p2p.Peer
peerInfo <-chan peerstore.PeerInfo
peerInfo <-chan libp2p_peer.AddrInfo
discovery *libp2pdis.RoutingDiscovery
messageChan chan *msg_pb.Message
started bool
@ -138,7 +138,7 @@ func (s *Service) Init() error {
connected := false
for _, peerAddr := range s.bootnodes {
peerinfo, _ := peerstore.InfoFromP2pAddr(peerAddr)
peerinfo, _ := libp2p_peer.AddrInfoFromP2pAddr(peerAddr)
wg.Add(1)
go func() {
defer wg.Done()

@ -128,8 +128,6 @@ type (
}
touchChange struct {
account *common.Address
prev bool
prevDirty bool
}
)

@ -397,8 +397,5 @@ func (so *Object) Value() *big.Int {
// IsValidator checks whether it is a validator object
func (so *Object) IsValidator(db Database) bool {
value := so.GetState(db, staking.IsValidatorKey)
if value == (common.Hash{}) {
return false
}
return true
return value != (common.Hash{})
}

@ -27,7 +27,6 @@ import (
// precompiledTest defines the input/output pairs for precompiled contract tests.
type precompiledTest struct {
input, expected string
gas uint64
name string
noBenchmark bool // Benchmark primarily the worst-cases
}

@ -51,9 +51,6 @@ type operation struct {
}
var (
frontierInstructionSet = newFrontierInstructionSet()
homesteadInstructionSet = newHomesteadInstructionSet()
byzantiumInstructionSet = newByzantiumInstructionSet()
constantinopleInstructionSet = newConstantinopleInstructionSet()
)

@ -1,9 +1,6 @@
package genesis
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
"testing"
@ -11,7 +8,6 @@ import (
"github.com/btcsuite/btcutil/bech32"
ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/harmony-one/bls/ffi/go/bls"
"github.com/harmony-one/harmony/internal/common"
)
@ -19,39 +15,6 @@ func TestString(t *testing.T) {
_ = BeaconAccountPriKey()
}
func fileToLines(filePath string) (lines []string, err error) {
f, err := os.Open(filePath)
if err != nil {
return
}
defer f.Close()
scanner := bufio.NewScanner(f)
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
err = scanner.Err()
return
}
func testGenesisccounts(t *testing.T) {
ones, err := fileToLines("one-acc.txt")
if err != nil {
t.Fatal("ReadFile failed", err)
}
bls, err := fileToLines("bls-pub.txt")
if err != nil {
t.Fatal("ReadFile failed", err)
}
index := 404
for i, one := range ones {
fmt.Printf(" {Index: \" %v \", Address: \"%v\", BLSPublicKey: \"%v\"},\n", index, one, bls[i])
index++
}
}
func TestCommitteeAccounts(test *testing.T) {
testAccounts(test, FoundationalNodeAccounts)
testAccounts(test, FoundationalNodeAccountsV1)

Loading…
Cancel
Save