mirror of https://github.com/poanetwork/quorum.git
Merge remote-tracking branch 'quorum/master' into geth-upgrade-1.8.16
This commit is contained in:
parent
519337a9d0
commit
13a9f26f9a
|
@ -34,7 +34,7 @@ import (
|
|||
const (
|
||||
ipcAPIs = "admin:1.0 debug:1.0 eth:1.0 istanbul:1.0 miner:1.0 net:1.0 personal:1.0 rpc:1.0 shh:1.0 txpool:1.0 web3:1.0"
|
||||
httpAPIs = "eth:1.0 net:1.0 rpc:1.0 web3:1.0"
|
||||
nodeKey = "b68c0338aa4b266bf38ebe84c6199ae9fac8b29f32998b3ed2fbeafebe8d65c9"
|
||||
nodeKey = "b68c0338aa4b266bf38ebe84c6199ae9fac8b29f32998b3ed2fbeafebe8d65c9"
|
||||
)
|
||||
|
||||
var genesis = `{
|
||||
|
|
|
@ -152,20 +152,20 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
|
|||
badBlocks, _ := lru.New(badBlockLimit)
|
||||
|
||||
bc := &BlockChain{
|
||||
chainConfig: chainConfig,
|
||||
cacheConfig: cacheConfig,
|
||||
db: db,
|
||||
triegc: prque.New(nil),
|
||||
stateCache: state.NewDatabase(db),
|
||||
quit: make(chan struct{}),
|
||||
shouldPreserve: shouldPreserve,
|
||||
bodyCache: bodyCache,
|
||||
bodyRLPCache: bodyRLPCache,
|
||||
blockCache: blockCache,
|
||||
futureBlocks: futureBlocks,
|
||||
engine: engine,
|
||||
vmConfig: vmConfig,
|
||||
badBlocks: badBlocks,
|
||||
chainConfig: chainConfig,
|
||||
cacheConfig: cacheConfig,
|
||||
db: db,
|
||||
triegc: prque.New(nil),
|
||||
stateCache: state.NewDatabase(db),
|
||||
quit: make(chan struct{}),
|
||||
shouldPreserve: shouldPreserve,
|
||||
bodyCache: bodyCache,
|
||||
bodyRLPCache: bodyRLPCache,
|
||||
blockCache: blockCache,
|
||||
futureBlocks: futureBlocks,
|
||||
engine: engine,
|
||||
vmConfig: vmConfig,
|
||||
badBlocks: badBlocks,
|
||||
privateStateCache: state.NewDatabase(db),
|
||||
}
|
||||
bc.SetValidator(NewBlockValidator(chainConfig, bc, engine))
|
||||
|
@ -911,7 +911,7 @@ func (bc *BlockChain) WriteBlockWithoutState(block *types.Block, td *big.Int) (e
|
|||
}
|
||||
|
||||
// WriteBlockWithState writes the block and all associated state to the database.
|
||||
func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types.Receipt, state , privateState *state.StateDB) (status WriteStatus, err error) {
|
||||
func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types.Receipt, state, privateState *state.StateDB) (status WriteStatus, err error) {
|
||||
bc.wg.Add(1)
|
||||
defer bc.wg.Done()
|
||||
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"math/big"
|
||||
"testing"
|
||||
"bytes"
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto/sha3"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto/sha3"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
)
|
||||
|
||||
// Tests block header storage and retrieval operations.
|
||||
|
|
|
@ -317,5 +317,3 @@ func TestBlockReceiptStorage(t *testing.T) {
|
|||
t.Fatalf("deleted receipts returned: %v", rs)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -745,7 +745,6 @@ func (pool *TxPool) journalTx(from common.Address, tx *types.Transaction) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// promoteTx adds a transaction to the pending (processable) list of transactions
|
||||
// and returns whether it was inserted or an older was better.
|
||||
//
|
||||
|
@ -1244,7 +1243,6 @@ func newTxLookup() *txLookup {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Range calls f on each key and value present in the map.
|
||||
func (t *txLookup) Range(f func(hash common.Hash, tx *types.Transaction) bool) {
|
||||
t.lock.RLock()
|
||||
|
|
|
@ -1168,9 +1168,9 @@ type SendTxArgs struct {
|
|||
Input *hexutil.Bytes `json:"input"`
|
||||
|
||||
//Quorum
|
||||
PrivateFrom string `json:"privateFrom"`
|
||||
PrivateFor []string `json:"privateFor"`
|
||||
PrivateTxType string `json:"restriction"`
|
||||
PrivateFrom string `json:"privateFrom"`
|
||||
PrivateFor []string `json:"privateFor"`
|
||||
PrivateTxType string `json:"restriction"`
|
||||
//End-Quorum
|
||||
}
|
||||
|
||||
|
@ -1583,13 +1583,13 @@ type AsyncSendTxArgs struct {
|
|||
}
|
||||
|
||||
type AsyncResultSuccess struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Id string `json:"id,omitempty"`
|
||||
TxHash common.Hash `json:"txHash"`
|
||||
}
|
||||
|
||||
type AsyncResultFailure struct {
|
||||
Id string `json:"id,omitempty"`
|
||||
Error string `json:"error"`
|
||||
Id string `json:"id,omitempty"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
type Async struct {
|
||||
|
@ -1650,7 +1650,7 @@ var async = newAsync(100)
|
|||
// Please note: This is a temporary integration to improve performance in high-latency
|
||||
// environments when sending many private transactions. It will be removed at a later
|
||||
// date when account management is handled outside Ethereum.
|
||||
func (s *PublicTransactionPoolAPI) SendTransactionAsync(ctx context.Context, args AsyncSendTxArgs) (common.Hash, error){
|
||||
func (s *PublicTransactionPoolAPI) SendTransactionAsync(ctx context.Context, args AsyncSendTxArgs) (common.Hash, error) {
|
||||
|
||||
select {
|
||||
case async.sem <- struct{}{}:
|
||||
|
@ -1688,4 +1688,5 @@ func (s *PublicBlockChainAPI) GetQuorumPayload(digestHex string) (string, error)
|
|||
}
|
||||
return fmt.Sprintf("0x%x", data), nil
|
||||
}
|
||||
|
||||
//End-Quorum
|
||||
|
|
|
@ -104,7 +104,7 @@ type task struct {
|
|||
block *types.Block
|
||||
createdAt time.Time
|
||||
|
||||
privateReceipts []*types.Receipt
|
||||
privateReceipts []*types.Receipt
|
||||
// Leave this publicState named state, add privateState which most code paths can just ignore
|
||||
privateState *state.StateDB
|
||||
}
|
||||
|
@ -584,7 +584,7 @@ func (w *worker) resultLoop() {
|
|||
continue
|
||||
}
|
||||
// Different block could share same sealhash, deep copy here to prevent write-write conflict.
|
||||
var logs []*types.Log
|
||||
var logs []*types.Log
|
||||
work := w.current
|
||||
|
||||
for _, receipt := range append(work.receipts, work.privateReceipts...) {
|
||||
|
@ -604,7 +604,6 @@ func (w *worker) resultLoop() {
|
|||
core.WritePrivateStateRoot(w.eth.ChainDb(), block.Root(), privateStateRoot)
|
||||
allReceipts := mergeReceipts(work.receipts, work.privateReceipts)
|
||||
|
||||
|
||||
// Commit block and state to database.
|
||||
stat, err := w.chain.WriteBlockWithState(block, allReceipts, work.state, nil)
|
||||
if err != nil {
|
||||
|
@ -624,7 +623,7 @@ func (w *worker) resultLoop() {
|
|||
w.mux.Post(core.NewMinedBlockEvent{Block: block})
|
||||
|
||||
var events []interface{}
|
||||
logs = append(work.state.Logs(), work.privateState.Logs()...)
|
||||
logs = append(work.state.Logs(), work.privateState.Logs()...)
|
||||
|
||||
switch stat {
|
||||
case core.CanonStatTy:
|
||||
|
@ -644,7 +643,6 @@ func (w *worker) resultLoop() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Given a slice of public receipts and an overlapping (smaller) slice of
|
||||
// private receipts, return a new slice where the default for each location is
|
||||
// the public receipt but we take the private receipt in each place we have
|
||||
|
@ -666,9 +664,6 @@ func mergeReceipts(pub, priv types.Receipts) types.Receipts {
|
|||
return ret
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// makeCurrent creates a new environment for the current cycle.
|
||||
func (w *worker) makeCurrent(parent *types.Block, header *types.Header) error {
|
||||
publicState, privateState, err := w.chain.StateAt(parent.Root())
|
||||
|
@ -752,12 +747,11 @@ func (w *worker) updateSnapshot() {
|
|||
w.snapshotState = w.current.state.Copy()
|
||||
}
|
||||
|
||||
|
||||
func (w *worker) commitTransaction(tx *types.Transaction, coinbase common.Address) ([]*types.Log, error) {
|
||||
snap := w.current.state.Snapshot()
|
||||
privateSnap := w.current.privateState.Snapshot()
|
||||
|
||||
receipt, privateReceipt, _, err := core.ApplyTransaction(w.config, w.chain, &coinbase, w.current.gasPool, w.current.state,w.current.privateState, w.current.header, tx, &w.current.header.GasUsed, vm.Config{})
|
||||
receipt, privateReceipt, _, err := core.ApplyTransaction(w.config, w.chain, &coinbase, w.current.gasPool, w.current.state, w.current.privateState, w.current.header, tx, &w.current.header.GasUsed, vm.Config{})
|
||||
if err != nil {
|
||||
w.current.state.RevertToSnapshot(snap)
|
||||
w.current.privateState.RevertToSnapshot(privateSnap)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package raft
|
||||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"sync"
|
||||
"time"
|
||||
"crypto/ecdsa"
|
||||
|
||||
"github.com/ethereum/go-ethereum/accounts"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
package raft
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"math/big"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
"github.com/ethereum/go-ethereum/rlp"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
)
|
||||
|
||||
func TestSignHeader(t *testing.T){
|
||||
func TestSignHeader(t *testing.T) {
|
||||
//create only what we need to test the seal
|
||||
var testRaftId uint16 = 5
|
||||
config := &node.Config{Name: "unit-test", DataDir: ""}
|
||||
|
||||
nodeKey := config.NodeKey()
|
||||
|
||||
raftProtocolManager := &ProtocolManager{raftId:testRaftId}
|
||||
raftProtocolManager := &ProtocolManager{raftId: testRaftId}
|
||||
raftService := &RaftService{nodeKey: nodeKey, raftProtocolManager: raftProtocolManager}
|
||||
minter := minter{eth: raftService,}
|
||||
minter := minter{eth: raftService}
|
||||
|
||||
//create some fake header to sign
|
||||
fakeParentHash := common.HexToHash("0xc2c1dc1be8054808c69e06137429899d")
|
||||
|
@ -46,16 +46,16 @@ func TestSignHeader(t *testing.T){
|
|||
}
|
||||
|
||||
// Check raftId
|
||||
sealRaftId, err := hexutil.DecodeUint64("0x"+ string(seal.RaftId)) //add the 0x prefix
|
||||
sealRaftId, err := hexutil.DecodeUint64("0x" + string(seal.RaftId)) //add the 0x prefix
|
||||
if err != nil {
|
||||
t.Errorf("Unable to get RaftId: %s", err.Error())
|
||||
}
|
||||
if sealRaftId != uint64(testRaftId) {
|
||||
if sealRaftId != uint64(testRaftId) {
|
||||
t.Errorf("RaftID does not match. Expected: %d, Actual: %d", testRaftId, sealRaftId)
|
||||
}
|
||||
|
||||
//Identify who signed it
|
||||
sig:= seal.Signature
|
||||
sig := seal.Signature
|
||||
pubKey, err := crypto.SigToPub(headerHash.Bytes(), sig)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to get public key from signature: %s", err.Error())
|
||||
|
|
|
@ -126,7 +126,6 @@ func BenchmarkDiscovery_64_4(b *testing.B) { benchmarkDiscovery(b, 64, 4) }
|
|||
func BenchmarkDiscovery_128_4(b *testing.B) { benchmarkDiscovery(b, 128, 4) }
|
||||
func BenchmarkDiscovery_256_4(b *testing.B) { benchmarkDiscovery(b, 256, 4) }
|
||||
|
||||
|
||||
func testDiscoverySimulationDockerAdapter(t *testing.T, nodes, conns int) {
|
||||
adapter, err := adapters.NewDockerAdapter()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue