From 1dbc15d7fb811931ee57da00e8074d87004c242e Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Tue, 30 Apr 2019 16:57:27 -0700 Subject: [PATCH 1/2] Display pingpong message's effect --- node/node.go | 10 +++++----- node/node_handler.go | 27 ++++++++++++++------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/node/node.go b/node/node.go index e400f4a2d..b2ce4b5ef 100644 --- a/node/node.go +++ b/node/node.go @@ -374,11 +374,11 @@ func (node *Node) AddPeers(peers []*p2p.Peer) int { // Only leader needs to add the peer info into consensus // Validators will receive the updated peer info from Leader via pong message // TODO: remove this after fully migrating to beacon chain-based committee membership - if count > 0 && node.NodeConfig.IsLeader() { - node.Consensus.AddPeers(peers) - // TODO: make peers into a context object shared by consensus and drand - node.DRand.AddPeers(peers) - } + //if count > 0 && node.NodeConfig.IsLeader() { + // node.Consensus.AddPeers(peers) + // // TODO: make peers into a context object shared by consensus and drand + // node.DRand.AddPeers(peers) + //} return count } diff --git a/node/node_handler.go b/node/node_handler.go index c8044daef..217989f3b 100644 --- a/node/node_handler.go +++ b/node/node_handler.go @@ -501,18 +501,18 @@ func (node *Node) pongMessageHandler(msgPayload []byte) int { // otherwise, we may not be able to validate the consensus messages received // which will result in first consensus timeout // TODO: remove this after fully migrating to beacon chain-based committee membership - err = node.Consensus.SetLeaderPubKey(pong.LeaderPubKey) - if err != nil { - utils.GetLogInstance().Error("Unmarshal Consensus Leader PubKey Failed", "error", err) - } else { - utils.GetLogInstance().Info("Set Consensus Leader PubKey", "key", node.Consensus.GetLeaderPubKey()) - } - err = node.DRand.SetLeaderPubKey(pong.LeaderPubKey) - if err != nil { - utils.GetLogInstance().Error("Unmarshal DRand Leader PubKey Failed", "error", err) - } else { - utils.GetLogInstance().Info("Set DRand Leader PubKey", "key", node.Consensus.GetLeaderPubKey()) - } + //err = node.Consensus.SetLeaderPubKey(pong.LeaderPubKey) + //if err != nil { + // utils.GetLogInstance().Error("Unmarshal Consensus Leader PubKey Failed", "error", err) + //} else { + // utils.GetLogInstance().Info("Set Consensus Leader PubKey", "key", node.Consensus.GetLeaderPubKey()) + //} + //err = node.DRand.SetLeaderPubKey(pong.LeaderPubKey) + //if err != nil { + // utils.GetLogInstance().Error("Unmarshal DRand Leader PubKey Failed", "error", err) + //} else { + // utils.GetLogInstance().Info("Set DRand Leader PubKey", "key", node.Consensus.GetLeaderPubKey()) + //} peers := make([]*p2p.Peer, 0) @@ -564,7 +564,8 @@ func (node *Node) pongMessageHandler(msgPayload []byte) int { node.serviceManager.TakeAction(&service.Action{Action: service.Notify, ServiceType: service.PeerDiscovery, Params: data}) // TODO: remove this after fully migrating to beacon chain-based committee membership - return node.Consensus.UpdatePublicKeys(publicKeys) + node.DRand.UpdatePublicKeys(publicKeys) + // return node.Consensus.UpdatePublicKeys(publicKeys) + node.DRand.UpdatePublicKeys(publicKeys) + return 0 } func (node *Node) epochShardStateMessageHandler(msgPayload []byte) int { From e611f97328e5d0a5a148fd6f825f11876e059855 Mon Sep 17 00:00:00 2001 From: Rongjian Lan Date: Wed, 1 May 2019 01:32:03 -0700 Subject: [PATCH 2/2] Support multi-shard for contracts calls --- node/contract.go | 2 +- node/demo_contract.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/node/contract.go b/node/contract.go index beba54919..4de1d430f 100644 --- a/node/contract.go +++ b/node/contract.go @@ -96,7 +96,7 @@ func (node *Node) QueryStakeInfo() *structs.StakeInfoReturnValue { tx := types.NewTransaction( state.GetNonce(deployerAddress), stakingContractAddress, - 0, + node.NodeConfig.ShardID, nil, math.MaxUint64, nil, diff --git a/node/demo_contract.go b/node/demo_contract.go index 3e7b4542b..c627a8fad 100644 --- a/node/demo_contract.go +++ b/node/demo_contract.go @@ -73,7 +73,7 @@ func (node *Node) CreateTransactionForEnterMethod(amount int64, priKey string) e tx := types.NewTransaction( nonce, toAddress, - 0, + node.NodeConfig.ShardID, Amount, params.TxGas*10, nil, @@ -141,7 +141,7 @@ func (node *Node) GetResult(priKey string) (players []string, balances []*big.In tx := types.NewTransaction( nonce, demoContractAddress, - 0, + node.NodeConfig.ShardID, nil, math.MaxUint64, nil, @@ -192,7 +192,7 @@ func (node *Node) CreateTransactionForPickWinner() error { tx := types.NewTransaction( nonce, toAddress, - 0, + node.NodeConfig.ShardID, Amount, params.TxGas*1000, nil,