Merge branch 'master' of github.com:harmony-one/harmony into pTXGen

pull/917/head
ak 6 years ago
commit 7e7ffd257e
  1. 30
      hmy/api_backend.go
  2. 4
      hmy/backend.go
  3. 3
      internal/hmyapi/backend.go
  4. 7
      internal/hmyapi/blockchain.go
  5. 4
      internal/utils/contract/constants.go
  6. 8
      scripts/node.sh
  7. 21
      test/consensus_testplan.md

@ -5,6 +5,7 @@ import (
"errors"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/core/bloombits"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
@ -111,9 +112,11 @@ func (b *APIBackend) GetReceipts(ctx context.Context, hash common.Hash) (types.R
}
// EventMux ...
// TODO: this is not implemented or verified yet for harmony.
func (b *APIBackend) EventMux() *event.TypeMux { return b.hmy.eventMux }
// BloomStatus ...
// TODO: this is not implemented or verified yet for harmony.
func (b *APIBackend) BloomStatus() (uint64, uint64) {
sections, _, _ := b.hmy.bloomIndexer.Sections()
return params.BloomBitsBlocks, sections
@ -143,37 +146,44 @@ func (b *APIBackend) ServiceFilter(ctx context.Context, session *bloombits.Match
// TODO(ricl): implement
}
// SubscribeNewTxsEvent ...
// SubscribeNewTxsEvent subcribes new tx event.
// TODO: this is not implemented or verified yet for harmony.
func (b *APIBackend) SubscribeNewTxsEvent(ch chan<- core.NewTxsEvent) event.Subscription {
return b.hmy.TxPool().SubscribeNewTxsEvent(ch)
}
// SubscribeChainEvent ...
// SubscribeChainEvent subcribes chain event.
// TODO: this is not implemented or verified yet for harmony.
func (b *APIBackend) SubscribeChainEvent(ch chan<- core.ChainEvent) event.Subscription {
return b.hmy.BlockChain().SubscribeChainEvent(ch)
}
// SubscribeChainHeadEvent ...
// SubscribeChainHeadEvent subcribes chain head event.
// TODO: this is not implemented or verified yet for harmony.
func (b *APIBackend) SubscribeChainHeadEvent(ch chan<- core.ChainHeadEvent) event.Subscription {
return b.hmy.BlockChain().SubscribeChainHeadEvent(ch)
}
// SubscribeChainSideEvent ...
// SubscribeChainSideEvent subcribes chain side event.
// TODO: this is not implemented or verified yet for harmony.
func (b *APIBackend) SubscribeChainSideEvent(ch chan<- core.ChainSideEvent) event.Subscription {
return b.hmy.BlockChain().SubscribeChainSideEvent(ch)
}
// SubscribeRemovedLogsEvent ...
// SubscribeRemovedLogsEvent subcribes removed logs event.
// TODO: this is not implemented or verified yet for harmony.
func (b *APIBackend) SubscribeRemovedLogsEvent(ch chan<- core.RemovedLogsEvent) event.Subscription {
return b.hmy.BlockChain().SubscribeRemovedLogsEvent(ch)
}
// SubscribeLogsEvent ...
// SubscribeLogsEvent subcribes log event.
// TODO: this is not implemented or verified yet for harmony.
func (b *APIBackend) SubscribeLogsEvent(ch chan<- []*types.Log) event.Subscription {
return b.hmy.BlockChain().SubscribeLogsEvent(ch)
}
// GetPoolTransactions ...
// GetPoolTransactions returns pool transactions.
// TODO: this is not implemented or verified yet for harmony.
func (b *APIBackend) GetPoolTransactions() (types.Transactions, error) {
pending, err := b.hmy.txPool.Pending()
if err != nil {
@ -185,3 +195,9 @@ func (b *APIBackend) GetPoolTransactions() (types.Transactions, error) {
}
return txs, nil
}
// GetBalance returns balance of an given address.
func (b *APIBackend) GetBalance(address common.Address) (*hexutil.Big, error) {
balance, err := b.hmy.nodeAPI.GetBalanceOfAddress(address)
return (*hexutil.Big)(balance), err
}

@ -1,6 +1,9 @@
package hmy
import (
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/bloombits"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
@ -34,6 +37,7 @@ type NodeAPI interface {
AddPendingTransaction(newTx *types.Transaction)
Blockchain() *core.BlockChain
AccountManager() *accounts.Manager
GetBalanceOfAddress(address common.Address) (*big.Int, error)
}
// New creates a new Harmony object (including the

@ -4,6 +4,7 @@ import (
"context"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/params"
@ -54,6 +55,8 @@ type Backend interface {
ChainConfig() *params.ChainConfig
CurrentBlock() *types.Block
// Get balance
GetBalance(address common.Address) (*hexutil.Big, error)
}
// GetAPIs returns all the APIs.

@ -72,11 +72,8 @@ func (s *PublicBlockChainAPI) GetStorageAt(ctx context.Context, address common.A
// given block number. The rpc.LatestBlockNumber and rpc.PendingBlockNumber meta
// block numbers are also allowed.
func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.Address, blockNr rpc.BlockNumber) (*hexutil.Big, error) {
state, _, err := s.b.StateAndHeaderByNumber(ctx, blockNr)
if state == nil || err != nil {
return nil, err
}
return (*hexutil.Big)(state.GetBalance(address)), state.Error()
// TODO: currently only get latest balance. Will add complete logic later.
return s.b.GetBalance(address)
}
// BlockNumber returns the block number of the chain head.

@ -270,8 +270,8 @@ var GenesisAccounts = [...]DeployAccount{
// 190-199
{Address: "0x1a4d5957Af59aE2E5ED0e4FAB42f14D1177d1F79", Private: "", Public: "0x1a4d5957Af59aE2E5ED0e4FAB42f14D1177d1F79"},
{Address: "0x87a157db95dc3517Eb578d4cedee92a5ab275BD5", Private: "", Public: "0x87a157db95dc3517Eb578d4cedee92a5ab275BD5"},
{Address: "0x804a1CE2387874E311e966c63A02C67dB15f2A87", Private: "", Public: "0x804a1CE2387874E311e966c63A02C67dB15f2A87"},
{Address: "0x8080ca14e1b3466b3b13441cDfd0f413E0BEb67a", Private: "", Public: "0x8080ca14e1b3466b3b13441cDfd0f413E0BEb67a"},
{Address: "0x25347d09373B2644191f1DC4beDEFEBE26a5b2d1", Private: "", Public: "0x25347d09373B2644191f1DC4beDEFEBE26a5b2d1"},
{Address: "0x7f42f7a4d66f0387AE77A219d0742E8a706231CA", Private: "", Public: "0x7f42f7a4d66f0387AE77A219d0742E8a706231CA"},
{Address: "0x80FBE7a01D593aC28CA1fE12E9CE62d6E2a08e5C", Private: "", Public: "0x80FBE7a01D593aC28CA1fE12E9CE62d6E2a08e5C"},
{Address: "0x81237F5d14F5db4d6370D353e3F5952e7aaae0cd", Private: "", Public: "0x81237F5d14F5db4d6370D353e3F5952e7aaae0cd"},
{Address: "0x822D6E108e434A3C2B27E0890C5DC3936D009560", Private: "", Public: "0x822D6E108e434A3C2B27E0890C5DC3936D009560"},

@ -141,17 +141,17 @@ BN_MA=/ip4/100.26.90.187/tcp/9874/p2p/Qmdfjtk6hPoyrH1zVD9PEH4zfWLo38dP2mDvvKXfh3
echo "############### Running Harmony Process ###############"
if [ "$OS" == "Linux" ]; then
# Run Harmony Node
LD_LIBRARY_PATH=$(pwd) ./harmony -bootnodes $BN_MA -ip $PUB_IP -port $NODE_PORT -is_genesis -account_index $IDX
LD_LIBRARY_PATH=$(pwd) ./harmony -bootnodes $BN_MA -ip $PUB_IP -port $NODE_PORT -is_genesis -is_archival -account_index $IDX
else
DYLD_FALLBACK_LIBRARY_PATH=$(pwd) ./harmony -bootnodes $BN_MA -ip $PUB_IP -port $NODE_PORT -is_genesis -account_index $IDX > harmony-${PUB_IP}.log 2>&1 &
DYLD_FALLBACK_LIBRARY_PATH=$(pwd) ./harmony -bootnodes $BN_MA -ip $PUB_IP -port $NODE_PORT -is_genesis -is_archival -account_index $IDX
fi
find_harmony_process
echo
echo
echo Please run the following command to inspect the log
echo "tail -f harmony-${PUB_IP}.log"
# echo Please run the following command to inspect the log
# echo "tail -f harmony-${PUB_IP}.log"
echo
echo You may use \"sudo pkill harmony\" to terminate running harmony node program.

@ -0,0 +1,21 @@
## testplan for consensus
### incorrect data
- wrong signature
- construct incorrect consensus messages
### timeout
- leader timeout in normal phase
- new leader timeout in viewchange phase
- multiple new leaders timeout in a row (m < n/3)
- two newview messages arrive at similar time
- a single node stucked at viewchange mode. e.g. new node stucked in view change while others move on
### malicious
- leader broadcasts different blocks in announce phase
- leader send different subsets of prepared signature in prepare phase
- new leader doesn't send prepared message from previous view
- new leader 't send inconsistent announce message from previous view
Loading…
Cancel
Save