Go vet fixed.

pull/4134/head
Konstantin 3 years ago committed by Leo Chen
parent c9ec957b4f
commit 97eb8d972f
  1. 3
      .travis.yml
  2. 6
      Makefile
  3. 1
      accounts/keystore/watch.go
  4. 1
      accounts/keystore/watch_fallback.go
  5. 3
      api/proto/message/gen.sh
  6. 2
      api/proto/message/message.go
  7. 84
      api/proto/message/message.pb.go
  8. 101
      api/proto/message/message_grpc.pb.go
  9. 1
      api/proto/message/server.go
  10. 2
      block/factory/factory.go
  11. 2
      block/v3/header.go
  12. 1
      cmd/harmony/config.go
  13. 2
      cmd/harmony/main.go
  14. 1
      common/fdlimit/fdlimit_unix.go
  15. 1
      consensus/consensus_v2.go
  16. 12
      consensus/construct_test.go
  17. 12
      consensus/double_sign.go
  18. 6
      consensus/quorum/one-node-staked-vote_test.go
  19. 6
      consensus/quorum/quorom_test.go
  20. 4
      consensus/votepower/roster_test.go
  21. 20
      core/blockchain.go
  22. 15
      core/evm_test.go
  23. 1
      core/gen_genesis.go
  24. 2
      core/rawdb/accessors_offchain.go
  25. 2
      core/state/statedb_test.go
  26. 2
      core/state_processor.go
  27. 2
      core/types/block_test.go
  28. 1
      core/vm/int_pool_verifier.go
  29. 1
      core/vm/int_pool_verifier_empty.go
  30. 1
      core/vm/runtime/fuzz.go
  31. 1
      eth/rpc/constants_unix.go
  32. 1
      eth/rpc/constants_unix_nocgo.go
  33. 1
      eth/rpc/ipc_js.go
  34. 1
      eth/rpc/ipc_unix.go
  35. 1
      eth/rpc/ipc_windows.go
  36. 8
      go.mod
  37. 5
      go.sum
  38. 8
      hmy/downloader/longrange_test.go
  39. 1
      hmy/downloader/shortrange.go
  40. 2
      hmy/transaction.go
  41. 2
      internal/chain/reward.go
  42. 15
      node/node.go
  43. 2
      node/node_genesis.go
  44. 7
      node/node_handler_test.go
  45. 1
      p2p/discovery/discovery.go
  46. 3
      p2p/host.go
  47. 21
      p2p/stream/common/requestmanager/requestmanager_test.go
  48. 8
      p2p/stream/common/streammanager/streammanager.go
  49. 8
      rosetta/services/construction_create.go
  50. 8
      rosetta/services/construction_create_test.go
  51. 8
      rosetta/services/tx_construction.go
  52. 2
      rpc/common/types.go
  53. 3
      rpc/tracer.go
  54. 3
      scripts/golint.sh
  55. 29
      shard/committee/assignment.go
  56. 2
      shard/shard_state.go
  57. 2
      staking/slash/double-sign.go
  58. 4
      staking/types/validator.go
  59. 6
      test/chain/reward/main.go
  60. 4
      test/chain/vrf/main.go
  61. 4
      tools/tools.go

@ -22,7 +22,10 @@ install:
- (cd $HOME/gopath/src/github.com/harmony-one/bls; make BLS_SWAP_G=1 -j4)
- go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
- go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.41.1
- make go-get
- go install golang.org/x/tools/cmd/goimports@latest
- go install github.com/harmony-ek/gencodec@latest
- scripts/install_build_tools.sh
script:
- ${TEST}

@ -151,3 +151,9 @@ rpmpub_dev: rpm
rpmpub_prod: rpm
./scripts/package/publish-repo.sh -p prod -n rpm -s $(RPMBUILD)
go-vet:
go vet ./...
go-test:
go test ./...

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//go:build (darwin && !ios) || freebsd || (linux && !arm64) || netbsd || solaris
// +build darwin,!ios freebsd linux,!arm64 netbsd solaris
package keystore

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//go:build ios || (linux && arm64) || windows || (!darwin && !freebsd && !linux && !netbsd && !solaris)
// +build ios linux,arm64 windows !darwin,!freebsd,!linux,!netbsd,!solaris
// This is the fallback implementation of directory watching.

@ -1,2 +1 @@
protoc -I ./ message.proto --go_out=plugins=grpc:./
# protoc -I ./ message.proto --go_out=./
protoc -I ./ message.proto --go_out=. --go-grpc_out=.

@ -1,3 +1,3 @@
package message
//go:generate protoc message.proto --go_out=plugins=grpc:.
//go:generate protoc message.proto --go_out=. --go-grpc_out=.

@ -7,10 +7,6 @@
package message
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
@ -1296,83 +1292,3 @@ func file_message_proto_init() {
file_message_proto_goTypes = nil
file_message_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// ClientServiceClient is the client API for ClientService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type ClientServiceClient interface {
Process(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Response, error)
}
type clientServiceClient struct {
cc grpc.ClientConnInterface
}
func NewClientServiceClient(cc grpc.ClientConnInterface) ClientServiceClient {
return &clientServiceClient{cc}
}
func (c *clientServiceClient) Process(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Response, error) {
out := new(Response)
err := c.cc.Invoke(ctx, "/message.ClientService/Process", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ClientServiceServer is the server API for ClientService service.
type ClientServiceServer interface {
Process(context.Context, *Message) (*Response, error)
}
// UnimplementedClientServiceServer can be embedded to have forward compatible implementations.
type UnimplementedClientServiceServer struct {
}
func (*UnimplementedClientServiceServer) Process(context.Context, *Message) (*Response, error) {
return nil, status.Errorf(codes.Unimplemented, "method Process not implemented")
}
func RegisterClientServiceServer(s *grpc.Server, srv ClientServiceServer) {
s.RegisterService(&_ClientService_serviceDesc, srv)
}
func _ClientService_Process_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Message)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ClientServiceServer).Process(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/message.ClientService/Process",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ClientServiceServer).Process(ctx, req.(*Message))
}
return interceptor(ctx, in, info, handler)
}
var _ClientService_serviceDesc = grpc.ServiceDesc{
ServiceName: "message.ClientService",
HandlerType: (*ClientServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Process",
Handler: _ClientService_Process_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "message.proto",
}

@ -0,0 +1,101 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
package message
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// ClientServiceClient is the client API for ClientService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type ClientServiceClient interface {
Process(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Response, error)
}
type clientServiceClient struct {
cc grpc.ClientConnInterface
}
func NewClientServiceClient(cc grpc.ClientConnInterface) ClientServiceClient {
return &clientServiceClient{cc}
}
func (c *clientServiceClient) Process(ctx context.Context, in *Message, opts ...grpc.CallOption) (*Response, error) {
out := new(Response)
err := c.cc.Invoke(ctx, "/message.ClientService/Process", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// ClientServiceServer is the server API for ClientService service.
// All implementations must embed UnimplementedClientServiceServer
// for forward compatibility
type ClientServiceServer interface {
Process(context.Context, *Message) (*Response, error)
mustEmbedUnimplementedClientServiceServer()
}
// UnimplementedClientServiceServer must be embedded to have forward compatible implementations.
type UnimplementedClientServiceServer struct {
}
func (UnimplementedClientServiceServer) Process(context.Context, *Message) (*Response, error) {
return nil, status.Errorf(codes.Unimplemented, "method Process not implemented")
}
func (UnimplementedClientServiceServer) mustEmbedUnimplementedClientServiceServer() {}
// UnsafeClientServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to ClientServiceServer will
// result in compilation errors.
type UnsafeClientServiceServer interface {
mustEmbedUnimplementedClientServiceServer()
}
func RegisterClientServiceServer(s grpc.ServiceRegistrar, srv ClientServiceServer) {
s.RegisterService(&ClientService_ServiceDesc, srv)
}
func _ClientService_Process_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(Message)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ClientServiceServer).Process(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/message.ClientService/Process",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ClientServiceServer).Process(ctx, req.(*Message))
}
return interceptor(ctx, in, info, handler)
}
// ClientService_ServiceDesc is the grpc.ServiceDesc for ClientService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var ClientService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "message.ClientService",
HandlerType: (*ClientServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Process",
Handler: _ClientService_Process_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "message.proto",
}

@ -18,6 +18,7 @@ const (
// Server is the Server struct for client service package.
type Server struct {
UnimplementedClientServiceServer
server *grpc.Server
CreateTransactionForEnterMethod func(int64, string) error
GetResult func(string) ([]string, []*big.Int)

@ -40,7 +40,7 @@ func (f *factory) NewHeader(epoch *big.Int) *block.Header {
impl = v0.NewHeader()
}
impl.SetEpoch(epoch)
return &block.Header{impl}
return &block.Header{Header: impl}
}
// Factories corresponding to well-known chain configurations.

@ -70,7 +70,7 @@ type headerFields struct {
Vdf []byte `json:"vdf"`
ShardState []byte `json:"shardState"`
CrossLinks []byte `json:"crossLink"`
Slashes []byte `json:slashes`
Slashes []byte `json:"slashes"`
}
// ParentHash is the header hash of the parent block. For the genesis block

@ -194,7 +194,6 @@ var dumpConfigLegacyCmd = &cobra.Command{
func registerDumpConfigFlags() error {
return cli.RegisterFlags(dumpConfigCmd, []cli.Flag{networkTypeFlag})
return cli.RegisterFlags(dumpConfigLegacyCmd, []cli.Flag{networkTypeFlag})
}
func promptConfigUpdate() bool {

@ -840,7 +840,7 @@ func setupBlacklist(hc harmonyconfig.HarmonyConfig) (map[ethCommon.Address]struc
func listenOSSigAndShutDown(node *node.Node) {
// Prepare for graceful shutdown from os signals
osSignal := make(chan os.Signal)
osSignal := make(chan os.Signal, 1)
signal.Notify(osSignal, syscall.SIGINT, syscall.SIGTERM)
sig := <-osSignal
utils.Logger().Warn().Str("signal", sig.String()).Msg("Gracefully shutting down...")

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//go:build linux || netbsd || openbsd || solaris
// +build linux netbsd openbsd solaris
package fdlimit

@ -424,7 +424,6 @@ func (consensus *Consensus) Start(
return
}
}
consensus.getLogger().Info().Msg("[ConsensusMainLoop] Ended.")
}()
if consensus.dHelper != nil {

@ -39,7 +39,7 @@ func TestConstructAnnounceMessage(test *testing.T) {
consensus.blockHash = [32]byte{}
pubKeyWrapper := bls.PublicKeyWrapper{Object: blsPriKey.GetPublicKey()}
pubKeyWrapper.Bytes.FromLibBLSPublicKey(pubKeyWrapper.Object)
priKeyWrapper := bls.PrivateKeyWrapper{blsPriKey, &pubKeyWrapper}
priKeyWrapper := bls.PrivateKeyWrapper{Pri: blsPriKey, Pub: &pubKeyWrapper}
if _, err = consensus.construct(msg_pb.MessageType_ANNOUNCE, nil, []*bls.PrivateKeyWrapper{&priKeyWrapper}); err != nil {
test.Fatalf("could not construct announce: %v", err)
}
@ -110,7 +110,7 @@ func TestConstructPreparedMessage(test *testing.T) {
pubKeyWrapper := bls.PublicKeyWrapper{Object: blsPriKey.GetPublicKey()}
pubKeyWrapper.Bytes.FromLibBLSPublicKey(pubKeyWrapper.Object)
priKeyWrapper := bls.PrivateKeyWrapper{blsPriKey, &pubKeyWrapper}
priKeyWrapper := bls.PrivateKeyWrapper{Pri: blsPriKey, Pub: &pubKeyWrapper}
network, err := consensus.construct(msg_pb.MessageType_PREPARED, nil, []*bls.PrivateKeyWrapper{&priKeyWrapper})
if err != nil {
test.Errorf("Error when creating prepared message")
@ -134,12 +134,12 @@ func TestConstructPrepareMessage(test *testing.T) {
blsPriKey1 := bls.RandPrivateKey()
pubKeyWrapper1 := bls.PublicKeyWrapper{Object: blsPriKey1.GetPublicKey()}
pubKeyWrapper1.Bytes.FromLibBLSPublicKey(pubKeyWrapper1.Object)
priKeyWrapper1 := bls.PrivateKeyWrapper{blsPriKey1, &pubKeyWrapper1}
priKeyWrapper1 := bls.PrivateKeyWrapper{Pri: blsPriKey1, Pub: &pubKeyWrapper1}
blsPriKey2 := bls.RandPrivateKey()
pubKeyWrapper2 := bls.PublicKeyWrapper{Object: blsPriKey2.GetPublicKey()}
pubKeyWrapper2.Bytes.FromLibBLSPublicKey(pubKeyWrapper2.Object)
priKeyWrapper2 := bls.PrivateKeyWrapper{blsPriKey2, &pubKeyWrapper2}
priKeyWrapper2 := bls.PrivateKeyWrapper{Pri: blsPriKey2, Pub: &pubKeyWrapper2}
decider := quorum.NewDecider(
quorum.SuperMajorityStake, shard.BeaconChainShardID,
@ -226,12 +226,12 @@ func TestConstructCommitMessage(test *testing.T) {
blsPriKey1 := bls.RandPrivateKey()
pubKeyWrapper1 := bls.PublicKeyWrapper{Object: blsPriKey1.GetPublicKey()}
pubKeyWrapper1.Bytes.FromLibBLSPublicKey(pubKeyWrapper1.Object)
priKeyWrapper1 := bls.PrivateKeyWrapper{blsPriKey1, &pubKeyWrapper1}
priKeyWrapper1 := bls.PrivateKeyWrapper{Pri: blsPriKey1, Pub: &pubKeyWrapper1}
blsPriKey2 := bls.RandPrivateKey()
pubKeyWrapper2 := bls.PublicKeyWrapper{Object: blsPriKey2.GetPublicKey()}
pubKeyWrapper2.Bytes.FromLibBLSPublicKey(pubKeyWrapper2.Object)
priKeyWrapper2 := bls.PrivateKeyWrapper{blsPriKey2, &pubKeyWrapper2}
priKeyWrapper2 := bls.PrivateKeyWrapper{Pri: blsPriKey2, Pub: &pubKeyWrapper2}
decider := quorum.NewDecider(
quorum.SuperMajorityStake, shard.BeaconChainShardID,

@ -86,14 +86,14 @@ func (consensus *Consensus) checkDoubleSign(recvMsg *FBFTMessage) bool {
evid := slash.Evidence{
ConflictingVotes: slash.ConflictingVotes{
FirstVote: slash.Vote{
alreadyCastBallot.SignerPubKeys,
alreadyCastBallot.BlockHeaderHash,
alreadyCastBallot.Signature,
SignerPubKeys: alreadyCastBallot.SignerPubKeys,
BlockHeaderHash: alreadyCastBallot.BlockHeaderHash,
Signature: alreadyCastBallot.Signature,
},
SecondVote: slash.Vote{
secondKeys,
recvMsg.BlockHash,
common.Hex2Bytes(doubleSign.SerializeToHexStr()),
SignerPubKeys: secondKeys,
BlockHeaderHash: recvMsg.BlockHash,
Signature: common.Hex2Bytes(doubleSign.SerializeToHexStr()),
}},
Moment: slash.Moment{
Epoch: curHeader.Epoch(),

@ -45,7 +45,7 @@ func generateRandomSlot() (shard.Slot, bls_core.SecretKey) {
key := bls.SerializedPublicKey{}
key.FromLibBLSPublicKey(secretKey.GetPublicKey())
stake := numeric.NewDecFromBigInt(big.NewInt(int64(stakeGen.Int63n(maxStakeGen))))
return shard.Slot{addr, key, &stake}, secretKey
return shard.Slot{EcdsaAddress: addr, BLSPublicKey: key, EffectiveStake: &stake}, secretKey
}
// 50 Harmony Nodes, 50 Staked Nodes
@ -73,7 +73,7 @@ func setupBaseCase() (Decider, *TallyResult, shard.SlotList, map[string]secretKe
decider := NewDecider(SuperMajorityStake, shard.BeaconChainShardID)
decider.UpdateParticipants(pubKeys)
tally, err := decider.SetVoters(&shard.Committee{
shard.BeaconChainShardID, slotList,
ShardID: shard.BeaconChainShardID, Slots: slotList,
}, big.NewInt(3))
if err != nil {
panic("Unable to SetVoters for Base Case")
@ -102,7 +102,7 @@ func setupEdgeCase() (Decider, *TallyResult, shard.SlotList, secretKeyMap) {
decider := NewDecider(SuperMajorityStake, shard.BeaconChainShardID)
decider.UpdateParticipants(pubKeys)
tally, err := decider.SetVoters(&shard.Committee{
shard.BeaconChainShardID, slotList,
ShardID: shard.BeaconChainShardID, Slots: slotList,
}, big.NewInt(3))
if err != nil {
panic("Unable to SetVoters for Edge Case")

@ -223,7 +223,7 @@ func TestAddNewVote(test *testing.T) {
decider.UpdateParticipants(pubKeys)
decider.SetVoters(&shard.Committee{
shard.BeaconChainShardID, slotList,
ShardID: shard.BeaconChainShardID, Slots: slotList,
}, big.NewInt(3))
aggSig := &bls_core.Sign{}
@ -328,7 +328,7 @@ func TestAddNewVoteAggregateSig(test *testing.T) {
decider.UpdateParticipants(pubKeys)
decider.SetVoters(&shard.Committee{
shard.BeaconChainShardID, slotList,
ShardID: shard.BeaconChainShardID, Slots: slotList,
}, big.NewInt(3))
aggSig := &bls_core.Sign{}
@ -412,7 +412,7 @@ func TestAddNewVoteInvalidAggregateSig(test *testing.T) {
decider.UpdateParticipants(pubKeys)
decider.SetVoters(&shard.Committee{
shard.BeaconChainShardID, slotList,
ShardID: shard.BeaconChainShardID, Slots: slotList,
}, big.NewInt(3))
aggSig := &bls_core.Sign{}

@ -52,7 +52,7 @@ func generateRandomSlot() shard.Slot {
key := bls.SerializedPublicKey{}
key.FromLibBLSPublicKey(secretKey.GetPublicKey())
stake := numeric.NewDecFromBigInt(big.NewInt(int64(stakeGen.Int63n(maxStakeGen))))
return shard.Slot{addr, key, &stake}
return shard.Slot{EcdsaAddress: addr, BLSPublicKey: key, EffectiveStake: &stake}
}
func TestCompute(t *testing.T) {
@ -100,7 +100,7 @@ func TestCompute(t *testing.T) {
expectedRoster.TheirVotingPowerTotalPercentage = theirPercentage
computedRoster, err := Compute(&shard.Committee{
shard.BeaconChainShardID, slotList,
ShardID: shard.BeaconChainShardID, Slots: slotList,
}, big.NewInt(3))
if err != nil {
t.Error("Computed Roster failed on vote summation to one")

@ -2590,7 +2590,7 @@ func (bc *BlockChain) ComputeAndUpdateAPR(
}
} else {
// only insert if APR for current epoch does not exists
aprEntry := staking.APREntry{now, *aprComputed}
aprEntry := staking.APREntry{Epoch: now, Value: *aprComputed}
l := len(stats.APRs)
// first time inserting apr for validator or
// apr for current epoch does not exists
@ -2628,7 +2628,7 @@ func (bc *BlockChain) UpdateValidatorSnapshots(
return err
}
snapshot := &staking.ValidatorSnapshot{validator, epoch}
snapshot := &staking.ValidatorSnapshot{Validator: validator, Epoch: epoch}
if err := bc.WriteValidatorSnapshot(batch, snapshot); err != nil {
return err
}
@ -2775,13 +2775,13 @@ func (bc *BlockChain) UpdateStakingMetaData(
return newValidators, err
}
if err := bc.WriteValidatorSnapshot(batch, &staking.ValidatorSnapshot{validator, epoch}); err != nil {
if err := bc.WriteValidatorSnapshot(batch, &staking.ValidatorSnapshot{Validator: validator, Epoch: epoch}); err != nil {
return newValidators, err
}
// For validator created at exactly the last block of an epoch, we should create the snapshot
// for next epoch too.
if newEpoch.Cmp(epoch) > 0 {
if err := bc.WriteValidatorSnapshot(batch, &staking.ValidatorSnapshot{validator, newEpoch}); err != nil {
if err := bc.WriteValidatorSnapshot(batch, &staking.ValidatorSnapshot{Validator: validator, Epoch: newEpoch}); err != nil {
return newValidators, err
}
}
@ -2854,9 +2854,9 @@ func (bc *BlockChain) prepareStakingMetaData(
// Add self delegation into the index
selfIndex := staking.DelegationIndex{
createValidator.ValidatorAddress,
uint64(0),
blockNum,
ValidatorAddress: createValidator.ValidatorAddress,
Index: uint64(0),
BlockNum: blockNum,
}
delegations, ok := newDelegations[createValidator.ValidatorAddress]
if !ok {
@ -2974,9 +2974,9 @@ func (bc *BlockChain) addDelegationIndex(
) {
// TODO(audit): change the way of indexing if we allow delegation deletion.
delegations = append(delegations, staking.DelegationIndex{
validatorAddress,
uint64(i),
blockNum,
ValidatorAddress: validatorAddress,
Index: uint64(i),
BlockNum: blockNum,
})
}
}

@ -77,12 +77,12 @@ func TestEVMStaking(t *testing.T) {
// write it to snapshot so that we can use it in edit
// use a copy because we are editing below (wrapper.Delegations)
wrapper, err := db.ValidatorWrapper(createValidator.ValidatorAddress, false, true)
err = chain.WriteValidatorSnapshot(batch, &staking.ValidatorSnapshot{wrapper, header.Epoch()})
err = chain.WriteValidatorSnapshot(batch, &staking.ValidatorSnapshot{Validator: wrapper, Epoch: header.Epoch()})
// also write the delegation so we can use it in CollectRewards
selfIndex := staking.DelegationIndex{
createValidator.ValidatorAddress,
uint64(0),
common.Big0, // block number at which delegation starts
ValidatorAddress: createValidator.ValidatorAddress,
Index: uint64(0),
BlockNum: common.Big0, // block number at which delegation starts
}
err = chain.writeDelegationsByDelegator(batch, createValidator.ValidatorAddress, []staking.DelegationIndex{selfIndex})
@ -98,10 +98,9 @@ func TestEVMStaking(t *testing.T) {
delegate := sampleDelegate(*key)
// add undelegations in epoch0
wrapper.Delegations[0].Undelegations = []staking.Undelegation{
staking.Undelegation{
new(big.Int).Mul(big.NewInt(denominations.One),
big.NewInt(10000)),
common.Big0,
{
Amount: new(big.Int).Mul(big.NewInt(denominations.One), big.NewInt(10000)),
Epoch: common.Big0,
},
}
// redelegate using epoch1, so that we can cover the locked tokens use case as well

@ -5,6 +5,7 @@ package core
import (
"encoding/json"
"errors"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/common/math"

@ -159,7 +159,7 @@ func ReadValidatorSnapshot(
Msg("Unable to decode validator snapshot from database")
return nil, err
}
s := staking.ValidatorSnapshot{&v, epoch}
s := staking.ValidatorSnapshot{Validator: &v, Epoch: epoch}
return &s, nil
}

@ -926,7 +926,7 @@ func makeValidValidatorWrapper(addr common.Address) stk.ValidatorWrapper {
MaxRate: numeric.ZeroDec(),
MaxChangeRate: numeric.ZeroDec(),
}
c := stk.Commission{cr, big.NewInt(300)}
c := stk.Commission{CommissionRates: cr, UpdateHeight: big.NewInt(300)}
d := stk.Description{
Name: "Wayne",
Identity: "wen",

@ -299,7 +299,7 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo
var cxReceipt *types.CXReceipt
// Do not create cxReceipt if EVM call failed
if txType == types.SubtractionOnly && !failedExe {
cxReceipt = &types.CXReceipt{tx.Hash(), msg.From(), msg.To(), tx.ShardID(), tx.ToShardID(), msg.Value()}
cxReceipt = &types.CXReceipt{TxHash: tx.Hash(), From: msg.From(), To: msg.To(), ShardID: tx.ShardID(), ToShardID: tx.ToShardID(), Amount: msg.Value()}
} else {
cxReceipt = nil
}

@ -927,7 +927,7 @@ func TestBlock_EncodeRLP(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
b := &Block{header: &block.Header{tt.header}}
b := &Block{header: &block.Header{Header: tt.header}}
w := &bytes.Buffer{}
err := b.EncodeRLP(w)
if (err != nil) != tt.wantErr {

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//go:build VERIFY_EVM_INTEGER_POOL
// +build VERIFY_EVM_INTEGER_POOL
package vm

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//go:build !VERIFY_EVM_INTEGER_POOL
// +build !VERIFY_EVM_INTEGER_POOL
package vm

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//go:build gofuzz
// +build gofuzz
package runtime

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//go:build darwin || dragonfly || freebsd || linux || nacl || netbsd || openbsd || solaris
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
package rpc

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//go:build !cgo && !windows
// +build !cgo,!windows
package rpc

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//go:build js
// +build js
package rpc

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//go:build darwin || dragonfly || freebsd || linux || nacl || netbsd || openbsd || solaris
// +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris
package rpc

@ -14,6 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
//go:build windows
// +build windows
package rpc

@ -16,13 +16,11 @@ require (
github.com/deckarep/golang-set v1.7.1
github.com/ethereum/go-ethereum v1.9.25
github.com/fjl/memsize v0.0.0-20180929194037-2a09253e352a // indirect
github.com/garslo/gogen v0.0.0-20170307003452-d6ebae628c7c // indirect
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.2
github.com/golangci/golangci-lint v1.22.2
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.4.2
github.com/harmony-ek/gencodec v0.0.0-20190215044613-e6740dbdd846
github.com/harmony-one/abool v1.0.1
github.com/harmony-one/bls v0.0.6
github.com/harmony-one/taggedrlp v0.1.4
@ -53,14 +51,14 @@ require (
github.com/spf13/viper v1.6.1
github.com/stretchr/testify v1.7.0
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee // indirect
github.com/whyrusleeping/timecache v0.0.0-20160911033111-cfcb2f1abfee
go.uber.org/ratelimit v0.1.0
go.uber.org/zap v1.16.0
golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
golang.org/x/tools v0.1.7
golang.org/x/tools v0.1.7 // indirect
google.golang.org/grpc v1.33.2
google.golang.org/protobuf v1.26.0
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c

@ -209,8 +209,6 @@ github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/garslo/gogen v0.0.0-20170307003452-d6ebae628c7c h1:uYNKzPntb8c6DKvP9EfrBjkLkU7pM4lM+uuHSIa8UtU=
github.com/garslo/gogen v0.0.0-20170307003452-d6ebae628c7c/go.mod h1:Q0X6pkwTILDlzrGEckF6HKjXe48EgsY/l7K7vhY4MW8=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
@ -389,8 +387,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t
github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/gxed/hashland/keccakpg v0.0.1/go.mod h1:kRzw3HkwxFU1mpmPP8v1WyQzwdGfmKFJ6tItnhQ67kU=
github.com/gxed/hashland/murmur3 v0.0.1/go.mod h1:KjXop02n4/ckmZSnY2+HKcLud/tcmvhST0bie/0lS48=
github.com/harmony-ek/gencodec v0.0.0-20190215044613-e6740dbdd846 h1:mYQ5htv2sj7m/mwlonteCTD80ODMlPUQTwbKJk+hi3Q=
github.com/harmony-ek/gencodec v0.0.0-20190215044613-e6740dbdd846/go.mod h1:YZcPnufUw70msUSudLvxcQOSpnZJgaMS9WIU8IGEtBg=
github.com/harmony-one/abool v1.0.1 h1:SjXLmrr3W8h6lY37gRuWtLiRknUOchnUnsXJWK6Gbm4=
github.com/harmony-one/abool v1.0.1/go.mod h1:9sq0PJzb1SqRpKrpEV4Ttvm9WV5uud8sfrsPw3AIBJA=
github.com/harmony-one/bls v0.0.6 h1:KG4q4JwdkPf3DtFvJmAgMRWT6QdY1A/wqN/Qt+S4VaQ=
@ -553,7 +549,6 @@ github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/libp2p/go-addr-util v0.0.1/go.mod h1:4ac6O7n9rIAKB1dnd+s8IbbMXkt+oBpzX4/+RACcnlQ=

@ -123,7 +123,7 @@ func TestLrSyncIter_FetchAndInsertBlocks(t *testing.T) {
targetBN := uint64(1000)
chain := newTestBlockChain(0, nil)
protocol := newTestSyncProtocol(targetBN, 32, nil)
ctx, _ := context.WithCancel(context.Background())
ctx := context.Background()
lsi := &lrSyncIter{
bc: chain,
@ -155,7 +155,7 @@ func TestLrSyncIter_FetchAndInsertBlocks_ErrRequest(t *testing.T) {
}
chain := newTestBlockChain(0, nil)
protocol := newTestSyncProtocol(targetBN, 32, errHook)
ctx, _ := context.WithCancel(context.Background())
ctx := context.Background()
lsi := &lrSyncIter{
bc: chain,
@ -187,7 +187,7 @@ func TestLrSyncIter_FetchAndInsertBlocks_ErrInsert(t *testing.T) {
}
chain := newTestBlockChain(0, errHook)
protocol := newTestSyncProtocol(targetBN, 32, nil)
ctx, _ := context.WithCancel(context.Background())
ctx := context.Background()
lsi := &lrSyncIter{
bc: chain,
@ -219,7 +219,7 @@ func TestLrSyncIter_FetchAndInsertBlocks_RandomErr(t *testing.T) {
}
chain := newTestBlockChain(0, errHook)
protocol := newTestSyncProtocol(targetBN, 32, errHook)
ctx, _ := context.WithCancel(context.Background())
ctx := context.Background()
lsi := &lrSyncIter{
bc: chain,

@ -122,6 +122,7 @@ func (sh *srHelper) getHashChain(curBN uint64) ([]common.Hash, []sttypes.StreamI
func (sh *srHelper) getBlocksByHashes(hashes []common.Hash, whitelist []sttypes.StreamID) ([]*types.Block, []sttypes.StreamID, error) {
ctx, cancel := context.WithCancel(sh.ctx)
defer cancel()
m := newGetBlocksByHashManager(hashes, whitelist)
var (

@ -44,7 +44,7 @@ func (hmy *Harmony) ResendCx(ctx context.Context, txID common.Hash) (uint64, boo
if tx.ShardID() == tx.ToShardID() || blk.Header().ShardID() != tx.ShardID() {
return 0, false
}
entry := core.CxEntry{blockHash, tx.ToShardID()}
entry := core.CxEntry{BlockHash: blockHash, ToShardID: tx.ToShardID()}
success := hmy.CxPool.Add(entry)
return blockNum, success
}

@ -498,7 +498,7 @@ func distributeRewardBeforeAggregateEpoch(bc engine.ChainReader, state *state.DB
if err != nil {
return network.EmptyPayout, errors.Wrapf(err, "shard 0 block %d reward error with bitmap %x", header.Number(), header.LastCommitBitmap())
}
subComm := shard.Committee{shard.BeaconChainShardID, members}
subComm := shard.Committee{ShardID: shard.BeaconChainShardID, Slots: members}
if err := availability.IncrementValidatorSigningCounts(
beaconChain,

@ -649,7 +649,7 @@ func (node *Node) StartPubSub() error {
}
allTopics = append(
allTopics, u{
NamedTopic: p2p.NamedTopic{string(key), topicHandle},
NamedTopic: p2p.NamedTopic{Name: string(key), Topic: topicHandle},
consensusBound: isCon,
},
)
@ -787,19 +787,6 @@ func (node *Node) StartPubSub() error {
nodeP2PMessageCounterVec.With(prometheus.Labels{"type": "ignored"}).Inc()
return libp2p_pubsub.ValidationReject
}
select {
case <-ctx.Done():
if errors.Is(ctx.Err(), context.DeadlineExceeded) ||
errors.Is(ctx.Err(), context.Canceled) {
utils.Logger().Warn().
Str("topic", topicNamed).Msg("[context] exceeded validation deadline")
}
errChan <- withError{errors.WithStack(ctx.Err()), nil}
default:
return libp2p_pubsub.ValidationAccept
}
return libp2p_pubsub.ValidationReject
},
// WithValidatorTimeout is an option that sets a timeout for an (asynchronous) topic validator. By default there is no timeout in asynchronous validators.
// TODO: Currently this timeout is useless. Verify me.

@ -30,7 +30,7 @@ func (gi *genesisInitializer) InitChainDB(db ethdb.Database, shardID uint32) err
if err != nil {
return errors.New("cannot find local shard in genesis")
}
shardState = &shard.State{nil, []shard.Committee{*subComm}}
shardState = &shard.State{Shards: []shard.Committee{*subComm}}
}
gi.node.SetupGenesisBlock(db, shardID, shardState)
return nil

@ -155,15 +155,14 @@ func TestVerifyVRF(t *testing.T) {
spKey := bls.SerializedPublicKey{}
spKey.FromLibBLSPublicKey(pubKey)
curNodeID := shard.Slot{
ecdsaAddr,
spKey,
nil,
EcdsaAddress: ecdsaAddr,
BLSPublicKey: spKey,
}
com.Slots = append(com.Slots, curNodeID)
shardState.Epoch = big.NewInt(1)
shardState.Shards = append(shardState.Shards, com)
node.Consensus.LeaderPubKey = &bls.PublicKeyWrapper{spKey, pubKey}
node.Consensus.LeaderPubKey = &bls.PublicKeyWrapper{Bytes: spKey, Object: pubKey}
node.Worker.GetCurrentHeader().SetEpoch(big.NewInt(1))
node.Consensus.GenerateVrfAndProof(node.Worker.GetCurrentHeader())
block, _ := node.Worker.FinalizeNewBlock(

@ -45,6 +45,7 @@ func NewDHTDiscovery(host libp2p_host.Host, opt DHTConfig) (Discovery, error) {
ctx, cancel := context.WithCancel(context.Background())
dht, err := libp2p_dht.New(ctx, host, opts...)
if err != nil {
cancel()
return nil, err
}
d := libp2p_dis.NewRoutingDiscovery(dht)

@ -109,6 +109,7 @@ func NewHost(cfg HostConfig) (Host, error) {
libp2p.BandwidthReporter(newCounter()),
)
if err != nil {
cancel()
return nil, errors.Wrapf(err, "cannot initialize libp2p host")
}
@ -118,6 +119,7 @@ func NewHost(cfg HostConfig) (Host, error) {
DiscConcurrency: cfg.DiscConcurrency,
})
if err != nil {
cancel()
return nil, errors.Wrap(err, "cannot create DHT discovery")
}
@ -169,6 +171,7 @@ func NewHost(cfg HostConfig) (Host, error) {
pubsub, err := libp2p_pubsub.NewGossipSub(ctx, p2pHost, options...)
if err != nil {
cancel()
return nil, errors.Wrapf(err, "cannot initialize libp2p pub-sub")
}

@ -25,7 +25,8 @@ func TestRequestManager_Request_Normal(t *testing.T) {
defer ts.Close()
req := makeTestRequest(100)
ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
res := <-ts.rm.doRequestAsync(ctx, req)
if res.err != nil {
@ -92,7 +93,8 @@ func TestRequestManager_RemoveStream(t *testing.T) {
defer ts.Close()
req := makeTestRequest(100)
ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
resC := ts.rm.doRequestAsync(ctx, req)
time.Sleep(defTestSleep)
@ -153,7 +155,8 @@ func TestRequestManager_StaleDelivery(t *testing.T) {
defer ts.Close()
req := makeTestRequest(100)
ctx, _ := context.WithTimeout(context.Background(), 100*time.Millisecond)
ctx, cancel := context.WithTimeout(context.Background(), 100*time.Millisecond)
defer cancel()
resC := ts.rm.doRequestAsync(ctx, req)
time.Sleep(2 * time.Second)
@ -192,7 +195,8 @@ func TestRequestManager_cancelWaitings(t *testing.T) {
ts.Start()
defer ts.Close()
ctx1, _ := context.WithTimeout(context.Background(), 1*time.Second)
ctx1, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
ctx2, cancel2 := context.WithTimeout(context.Background(), 1*time.Second)
resC1 := ts.rm.doRequestAsync(ctx1, req1)
resC2 := ts.rm.doRequestAsync(ctx2, req2)
@ -245,7 +249,8 @@ func TestRequestManager_Close(t *testing.T) {
ts := newTestSuite(delayF, respF, 3)
ts.Start()
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
resC := ts.rm.doRequestAsync(ctx, makeTestRequest(0))
time.Sleep(100 * time.Millisecond)
ts.Close()
@ -266,7 +271,8 @@ func TestRequestManager_Request_Blacklist(t *testing.T) {
defer ts.Close()
req := makeTestRequest(100)
ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
res := <-ts.rm.doRequestAsync(ctx, req, WithBlacklist([]sttypes.StreamID{
makeStreamID(0),
makeStreamID(1),
@ -293,7 +299,8 @@ func TestRequestManager_Request_Whitelist(t *testing.T) {
defer ts.Close()
req := makeTestRequest(100)
ctx, _ := context.WithTimeout(context.Background(), 1*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
res := <-ts.rm.doRequestAsync(ctx, req, WithWhitelist([]sttypes.StreamID{
makeStreamID(3),
}))

@ -332,8 +332,12 @@ func (sm *streamManager) discover(ctx context.Context) (<-chan libp2p_peer.AddrI
return nil, nil
}
ctx, _ = context.WithTimeout(ctx, discTimeout)
return sm.pf.FindPeers(ctx, protoID, discBatch)
ctx2, cancel := context.WithTimeout(ctx, discTimeout)
go func() { // avoid context leak
<-time.After(discTimeout)
cancel()
}()
return sm.pf.FindPeers(ctx2, protoID, discBatch)
}
func (sm *streamManager) setupStreamWithPeer(ctx context.Context, pid libp2p_peer.ID) error {

@ -112,9 +112,9 @@ func unpackWrappedTransactionFromString(
Details: createValidatorMsg.Details,
},
CommissionRates: stakingTypes.CommissionRates{
Rate: numeric.Dec{createValidatorMsg.CommissionRate},
MaxRate: numeric.Dec{createValidatorMsg.MaxCommissionRate},
MaxChangeRate: numeric.Dec{createValidatorMsg.MaxChangeRate},
Rate: numeric.Dec{Int: createValidatorMsg.CommissionRate},
MaxRate: numeric.Dec{Int: createValidatorMsg.MaxCommissionRate},
MaxChangeRate: numeric.Dec{Int: createValidatorMsg.MaxChangeRate},
},
MinSelfDelegation: createValidatorMsg.MinSelfDelegation,
MaxTotalDelegation: createValidatorMsg.MaxTotalDelegation,
@ -156,7 +156,7 @@ func unpackWrappedTransactionFromString(
SecurityContact: editValidatorMsg.SecurityContact,
Details: editValidatorMsg.Details,
},
CommissionRate: &numeric.Dec{editValidatorMsg.CommissionRate},
CommissionRate: &numeric.Dec{Int: editValidatorMsg.CommissionRate},
MinSelfDelegation: editValidatorMsg.MinSelfDelegation,
MaxTotalDelegation: editValidatorMsg.MaxTotalDelegation,
SlotKeyToAdd: slotKeyToAdd.(*bls.SerializedPublicKey),

@ -480,9 +480,9 @@ func stakingCreateValidatorTransaction(key *ecdsa.PrivateKey) (*stakingTypes.Sta
Details: "Don't mess with me!!!",
},
CommissionRates: stakingTypes.CommissionRates{
Rate: numeric.Dec{new(big.Int).SetUint64(100000000000000000)},
MaxRate: numeric.Dec{new(big.Int).SetUint64(900000000000000000)},
MaxChangeRate: numeric.Dec{new(big.Int).SetUint64(50000000000000000)},
Rate: numeric.Dec{Int: new(big.Int).SetUint64(100000000000000000)},
MaxRate: numeric.Dec{Int: new(big.Int).SetUint64(900000000000000000)},
MaxChangeRate: numeric.Dec{Int: new(big.Int).SetUint64(50000000000000000)},
},
MinSelfDelegation: new(big.Int).Mul(new(big.Int).SetInt64(10), big.NewInt(1e18)),
MaxTotalDelegation: new(big.Int).Mul(new(big.Int).SetInt64(3000), big.NewInt(1e18)),
@ -531,7 +531,7 @@ func stakingEditValidatorTransaction(key *ecdsa.PrivateKey) (*stakingTypes.Staki
SecurityContact: "Bob",
Details: "Don't mess with me!!!",
},
CommissionRate: &numeric.Dec{new(big.Int).SetUint64(100000000000000000)},
CommissionRate: &numeric.Dec{Int: new(big.Int).SetUint64(100000000000000000)},
MinSelfDelegation: new(big.Int).Mul(new(big.Int).SetInt64(10), big.NewInt(1e18)),
MaxTotalDelegation: new(big.Int).Mul(new(big.Int).SetInt64(3000), big.NewInt(1e18)),
SlotKeyToRemove: &slotKeyToRemove,

@ -215,9 +215,9 @@ func constructCreateValidatorTransaction(
Details: createValidatorMsg.Details,
},
CommissionRates: types2.CommissionRates{
Rate: numeric.Dec{createValidatorMsg.CommissionRate},
MaxRate: numeric.Dec{createValidatorMsg.MaxCommissionRate},
MaxChangeRate: numeric.Dec{createValidatorMsg.MaxChangeRate},
Rate: numeric.Dec{Int: createValidatorMsg.CommissionRate},
MaxRate: numeric.Dec{Int: createValidatorMsg.MaxCommissionRate},
MaxChangeRate: numeric.Dec{Int: createValidatorMsg.MaxChangeRate},
},
MinSelfDelegation: new(big.Int).Mul(createValidatorMsg.MinSelfDelegation, big.NewInt(1e18)),
MaxTotalDelegation: new(big.Int).Mul(createValidatorMsg.MaxTotalDelegation, big.NewInt(1e18)),
@ -286,7 +286,7 @@ func constructEditValidatorTransaction(
SecurityContact: editValidatorMsg.SecurityContact,
Details: editValidatorMsg.Details,
},
CommissionRate: &numeric.Dec{editValidatorMsg.CommissionRate},
CommissionRate: &numeric.Dec{Int: editValidatorMsg.CommissionRate},
MinSelfDelegation: new(big.Int).Mul(editValidatorMsg.MinSelfDelegation, big.NewInt(1e18)),
MaxTotalDelegation: new(big.Int).Mul(editValidatorMsg.MaxTotalDelegation, big.NewInt(1e18)),
SlotKeyToAdd: &slotKeyToAdd,

@ -68,7 +68,7 @@ type NodeMetadata struct {
PeerID peer.ID `json:"peerid"`
Consensus ConsensusInternal `json:"consensus"`
C C `json:"p2p-connectivity"`
SyncPeers map[string]int `json:"sync-peers",omitempty`
SyncPeers map[string]int `json:"sync-peers,omitempty"`
}
// P captures the connected peers per topic

@ -77,6 +77,7 @@ func (s *PublicTracerService) TraceChain(ctx context.Context, start, end rpc.Blo
// TODO (JL): Make API available after DoS testing
return nil, ErrNotAvailable
/*
if uint64(start) >= uint64(end) {
return nil, fmt.Errorf("start block can not be equal or greater than the end block")
}
@ -96,6 +97,8 @@ func (s *PublicTracerService) TraceChain(ctx context.Context, start, end rpc.Blo
}
return s.hmy.TraceChain(ctx, from, to, config)
*/
}
// TraceBlockByNumber returns the structured logs created during the execution of

@ -4,5 +4,4 @@ case "${0}" in
*/*) progdir="${0%/*}";;
*) progdir=.;;
esac
"${progdir}/list_harmony_go_files.sh" | "${progdir}/dirnames.sh" | \
sort -u -t/ | xargs golint "$@"
go vet ./...

@ -197,9 +197,9 @@ func prepareOrders(
totalStaked.Add(totalStaked, validatorStake)
essentials[validator.Address] = &effective.SlotOrder{
validatorStake,
validator.SlotPubKeys,
tempZero,
Stake: validatorStake,
SpreadAmong: validator.SlotPubKeys,
Percentage: tempZero,
}
}
totalStakedDec := numeric.NewDecFromBigInt(totalStaked)
@ -291,9 +291,8 @@ func preStakingEnabledCommittee(s shardingconfig.Instance) (*shard.State, error)
return nil, err
}
curNodeID := shard.Slot{
addr,
pubKey,
nil,
EcdsaAddress: addr,
BLSPublicKey: pubKey,
}
com.Slots = append(com.Slots, curNodeID)
}
@ -310,9 +309,8 @@ func preStakingEnabledCommittee(s shardingconfig.Instance) (*shard.State, error)
return nil, err
}
curNodeID := shard.Slot{
addr,
pubKey,
nil,
EcdsaAddress: addr,
BLSPublicKey: pubKey,
}
com.Slots = append(com.Slots, curNodeID)
}
@ -331,7 +329,7 @@ func eposStakedCommittee(
shardHarmonyNodes := s.NumHarmonyOperatedNodesPerShard()
for i := 0; i < shardCount; i++ {
shardState.Shards[i] = shard.Committee{uint32(i), shard.SlotList{}}
shardState.Shards[i] = shard.Committee{ShardID: uint32(i), Slots: shard.SlotList{}}
for j := 0; j < shardHarmonyNodes; j++ {
index := i + j*shardCount
pub := &bls_core.PublicKey{}
@ -348,9 +346,8 @@ func eposStakedCommittee(
return nil, err
}
shardState.Shards[i].Slots = append(shardState.Shards[i].Slots, shard.Slot{
addr,
pubKey,
nil,
EcdsaAddress: addr,
BLSPublicKey: pubKey,
})
}
}
@ -368,9 +365,9 @@ func eposStakedCommittee(
shardID := int(new(big.Int).Mod(purchasedSlot.Key.Big(), shardBig).Int64())
shardState.Shards[shardID].Slots = append(
shardState.Shards[shardID].Slots, shard.Slot{
purchasedSlot.Addr,
purchasedSlot.Key,
&purchasedSlot.EPoSStake,
EcdsaAddress: purchasedSlot.Addr,
BLSPublicKey: purchasedSlot.Key,
EffectiveStake: &purchasedSlot.EPoSStake,
},
)
}

@ -339,7 +339,7 @@ func (c *Committee) BLSPublicKeys() ([]bls.PublicKeyWrapper, error) {
return nil, err
}
slice[j] = bls.PublicKeyWrapper{c.Slots[j].BLSPublicKey, pubKey}
slice[j] = bls.PublicKeyWrapper{Bytes: c.Slots[j].BLSPublicKey, Object: pubKey}
}
return slice, nil

@ -130,7 +130,7 @@ func (r Record) MarshalJSON() ([]byte, error) {
common2.MustAddressToBech32(r.Evidence.Offender)
return json.Marshal(struct {
Evidence Evidence `json:"evidence"`
Reporter string `json:"reporter"`
Beneficiary string `json:"beneficiary"`
AddressForBLSKey string `json:"offender"`
}{r.Evidence, reporter, offender})
}

@ -79,9 +79,9 @@ type ValidatorSnapshotReader interface {
type counters struct {
// The number of blocks the validator
// should've signed when in active mode (selected in committee)
NumBlocksToSign *big.Int `json:"to-sign",rlp:"nil"`
NumBlocksToSign *big.Int `json:"to-sign" rlp:"nil"`
// The number of blocks the validator actually signed
NumBlocksSigned *big.Int `json:"signed",rlp:"nil"`
NumBlocksSigned *big.Int `json:"signed" rlp:"nil"`
}
// ValidatorWrapper contains validator,

@ -121,10 +121,8 @@ func main() {
}
for i := 0; i < 100000; i++ {
validator.Delegations = append(validator.Delegations, staking.Delegation{
common2.Address{},
big.NewInt(int64(rand.Intn(100))),
big.NewInt(0),
nil,
Amount: big.NewInt(int64(rand.Intn(100))),
Reward: big.NewInt(0),
})
}

@ -36,7 +36,7 @@ func main() {
startTime = time.Now()
for i := 0; i < size; i++ {
if !sig.VerifyHash(pubKeyWrapper.Object, blockHash[:]) {
fmt.Errorf("failed to verify sig")
fmt.Println("failed to verify sig")
}
}
endTime = time.Now()
@ -99,7 +99,7 @@ func main() {
startTime = time.Now()
if !aggSig.VerifyHash(aggPub, blockHash[:]) {
fmt.Errorf("failed to verify sig")
fmt.Println("failed to verify sig")
}
endTime = time.Now()

@ -2,6 +2,7 @@
// builds, which would fail because the imports are programs – package main –
// and not really importable packages.
//
//go:build tools
// +build tools
// Package tools provides build tools necessary for Harmony.
@ -13,7 +14,4 @@ import (
_ "github.com/golang/mock/mockgen"
_ "github.com/golang/protobuf/protoc-gen-go"
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
_ "github.com/harmony-ek/gencodec"
_ "golang.org/x/lint/golint"
_ "golang.org/x/tools/cmd/goimports"
)

Loading…
Cancel
Save