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

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

@ -127,9 +127,7 @@ type (
hash common.Hash hash common.Hash
} }
touchChange struct { touchChange struct {
account *common.Address 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 // IsValidator checks whether it is a validator object
func (so *Object) IsValidator(db Database) bool { func (so *Object) IsValidator(db Database) bool {
value := so.GetState(db, staking.IsValidatorKey) value := so.GetState(db, staking.IsValidatorKey)
if value == (common.Hash{}) { return value != (common.Hash{})
return false
}
return true
} }

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

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

@ -1,9 +1,6 @@
package genesis package genesis
import ( import (
"bufio"
"fmt"
"os"
"strconv" "strconv"
"strings" "strings"
"testing" "testing"
@ -11,7 +8,6 @@ import (
"github.com/btcsuite/btcutil/bech32" "github.com/btcsuite/btcutil/bech32"
ethCommon "github.com/ethereum/go-ethereum/common" ethCommon "github.com/ethereum/go-ethereum/common"
"github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/bls/ffi/go/bls"
"github.com/harmony-one/harmony/internal/common" "github.com/harmony-one/harmony/internal/common"
) )
@ -19,39 +15,6 @@ func TestString(t *testing.T) {
_ = BeaconAccountPriKey() _ = 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) { func TestCommitteeAccounts(test *testing.T) {
testAccounts(test, FoundationalNodeAccounts) testAccounts(test, FoundationalNodeAccounts)
testAccounts(test, FoundationalNodeAccountsV1) testAccounts(test, FoundationalNodeAccountsV1)

Loading…
Cancel
Save