mirror of https://github.com/poanetwork/quorum.git
Merge remote-tracking branch 'remotes/goeth/release/1.8' into geth-upgrade-1.8.15_new
fix compilation issues on programs impcted by this merge
This commit is contained in:
parent
47571689ee
commit
2c4081d89f
|
@ -70,4 +70,6 @@ type Backend interface {
|
|||
|
||||
// HasBadBlock returns whether the block with the hash is a bad block
|
||||
HasBadProposal(hash common.Hash) bool
|
||||
|
||||
Close() error
|
||||
}
|
||||
|
|
|
@ -315,3 +315,9 @@ func (sb *backend) HasBadProposal(hash common.Hash) bool {
|
|||
}
|
||||
return sb.hasBadBlock(hash)
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (sb *backend) Close() error {
|
||||
return nil
|
||||
}
|
|
@ -392,7 +392,8 @@ func (sb *backend) Finalize(chain consensus.ChainReader, header *types.Header, s
|
|||
|
||||
// Seal generates a new block for the given input block with the local miner's
|
||||
// seal place on top.
|
||||
func (sb *backend) Seal(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error) {
|
||||
func (sb *backend) Seal(chain consensus.ChainReader, block *types.Block, results chan<- *types.Block, stop <-chan struct{}) error {
|
||||
|
||||
// update the block header timestamp and signature and propose the block to core engine
|
||||
header := block.Header()
|
||||
number := header.Number.Uint64()
|
||||
|
@ -400,19 +401,19 @@ func (sb *backend) Seal(chain consensus.ChainReader, block *types.Block, stop <-
|
|||
// Bail out if we're unauthorized to sign a block
|
||||
snap, err := sb.snapshot(chain, number-1, header.ParentHash, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
if _, v := snap.ValSet.GetByAddress(sb.address); v == nil {
|
||||
return nil, errUnauthorized
|
||||
return errUnauthorized
|
||||
}
|
||||
|
||||
parent := chain.GetHeader(header.ParentHash, number-1)
|
||||
if parent == nil {
|
||||
return nil, consensus.ErrUnknownAncestor
|
||||
return consensus.ErrUnknownAncestor
|
||||
}
|
||||
block, err = sb.updateBlock(parent, block)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
|
||||
// wait for the timestamp of header, use this to adjust the block period
|
||||
|
@ -420,35 +421,39 @@ func (sb *backend) Seal(chain consensus.ChainReader, block *types.Block, stop <-
|
|||
select {
|
||||
case <-time.After(delay):
|
||||
case <-stop:
|
||||
return nil, nil
|
||||
results <- nil
|
||||
return nil
|
||||
}
|
||||
|
||||
// get the proposed block hash and clear it if the seal() is completed.
|
||||
sb.sealMu.Lock()
|
||||
sb.proposedBlockHash = block.Hash()
|
||||
clear := func() {
|
||||
sb.proposedBlockHash = common.Hash{}
|
||||
sb.sealMu.Unlock()
|
||||
}
|
||||
defer clear()
|
||||
|
||||
// post block into Istanbul engine
|
||||
go sb.EventMux().Post(istanbul.RequestEvent{
|
||||
Proposal: block,
|
||||
})
|
||||
|
||||
for {
|
||||
select {
|
||||
case result := <-sb.commitCh:
|
||||
// if the block hash and the hash from channel are the same,
|
||||
// return the result. Otherwise, keep waiting the next hash.
|
||||
if block.Hash() == result.Hash() {
|
||||
return result, nil
|
||||
}
|
||||
case <-stop:
|
||||
return nil, nil
|
||||
go func() {
|
||||
// get the proposed block hash and clear it if the seal() is completed.
|
||||
sb.sealMu.Lock()
|
||||
sb.proposedBlockHash = block.Hash()
|
||||
clear := func() {
|
||||
sb.proposedBlockHash = common.Hash{}
|
||||
sb.sealMu.Unlock()
|
||||
}
|
||||
}
|
||||
defer clear()
|
||||
|
||||
// post block into Istanbul engine
|
||||
go sb.EventMux().Post(istanbul.RequestEvent{
|
||||
Proposal: block,
|
||||
})
|
||||
for {
|
||||
select {
|
||||
case result := <-sb.commitCh:
|
||||
// if the block hash and the hash from channel are the same,
|
||||
// return the result. Otherwise, keep waiting the next hash.
|
||||
if block.Hash() == result.Hash() {
|
||||
results <- result
|
||||
return
|
||||
}
|
||||
case <-stop:
|
||||
results <- nil
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
// update timestamp and signature of the block based on its number of transactions
|
||||
|
@ -613,6 +618,12 @@ func sigHash(header *types.Header) (hash common.Hash) {
|
|||
return hash
|
||||
}
|
||||
|
||||
|
||||
// SealHash returns the hash of a block prior to it being sealed.
|
||||
func (sb *backend) SealHash(header *types.Header) common.Hash {
|
||||
return sigHash(header)
|
||||
}
|
||||
|
||||
// ecrecover extracts the Ethereum account address from a signed header.
|
||||
func ecrecover(header *types.Header) (common.Address, error) {
|
||||
hash := header.Hash()
|
||||
|
|
|
@ -65,7 +65,7 @@ func (cg *callHelper) MakeCall(private bool, key *ecdsa.PrivateKey, to common.Ad
|
|||
}
|
||||
|
||||
// TODO(joel): can we just pass nil instead of bc?
|
||||
bc, _ := NewBlockChain(cg.db, nil, params.QuorumTestChainConfig, ethash.NewFaker(), vm.Config{})
|
||||
bc, _ := NewBlockChain(cg.db, nil, params.QuorumTestChainConfig, ethash.NewFaker(), vm.Config{}, nil)
|
||||
context := NewEVMContext(msg, &cg.header, bc, &from)
|
||||
vmenv := vm.NewEVM(context, publicState, privateState, params.QuorumTestChainConfig, vm.Config{})
|
||||
_, _, _, err = ApplyMessage(vmenv, msg, cg.gp)
|
||||
|
|
|
@ -29,6 +29,9 @@ type PendingLogsEvent struct {
|
|||
Logs []*types.Log
|
||||
}
|
||||
|
||||
// PendingStateEvent is posted pre mining and notifies of pending state changes.
|
||||
type PendingStateEvent struct{}
|
||||
|
||||
// NewMinedBlockEvent is posted when a block has been imported.
|
||||
type NewMinedBlockEvent struct{ Block *types.Block }
|
||||
|
||||
|
|
|
@ -439,9 +439,9 @@ func (evm *EVM) create(caller ContractRef, code []byte, gas uint64, value *big.I
|
|||
}
|
||||
// Create a new account on the state
|
||||
snapshot := evm.StateDB.Snapshot()
|
||||
evm.StateDB.CreateAccount(address)
|
||||
evm.StateDB.CreateAccount(contractAddr)
|
||||
if evm.ChainConfig().IsEIP158(evm.BlockNumber) {
|
||||
evm.StateDB.SetNonce(address, 1)
|
||||
evm.StateDB.SetNonce(contractAddr, 1)
|
||||
}
|
||||
if evm.ChainConfig().IsQuorum {
|
||||
// skip transfer if value /= 0 (see note: Quorum, States, and Value Transfer)
|
||||
|
@ -458,15 +458,15 @@ func (evm *EVM) create(caller ContractRef, code []byte, gas uint64, value *big.I
|
|||
// initialise a new contract and set the code that is to be used by the
|
||||
// EVM. The contract is a scoped environment for this execution context
|
||||
// only.
|
||||
contract := NewContract(caller, AccountRef(address), value, gas)
|
||||
contract.SetCallCode(&address, crypto.Keccak256Hash(code), code)
|
||||
contract := NewContract(caller, AccountRef(contractAddr), value, gas)
|
||||
contract.SetCallCode(&contractAddr, crypto.Keccak256Hash(code), code)
|
||||
|
||||
if evm.vmConfig.NoRecursion && evm.depth > 0 {
|
||||
return nil, address, gas, nil
|
||||
return nil, contractAddr, gas, nil
|
||||
}
|
||||
|
||||
if evm.vmConfig.Debug && evm.depth == 0 {
|
||||
evm.vmConfig.Tracer.CaptureStart(caller.Address(), address, true, code, gas, value)
|
||||
evm.vmConfig.Tracer.CaptureStart(caller.Address(), contractAddr, true, code, gas, value)
|
||||
}
|
||||
start := time.Now()
|
||||
|
||||
|
@ -481,7 +481,7 @@ func (evm *EVM) create(caller ContractRef, code []byte, gas uint64, value *big.I
|
|||
if err == nil && !maxCodeSizeExceeded {
|
||||
createDataGas := uint64(len(ret)) * params.CreateDataGas
|
||||
if contract.UseGas(createDataGas) {
|
||||
evm.StateDB.SetCode(address, ret)
|
||||
evm.StateDB.SetCode(contractAddr, ret)
|
||||
} else {
|
||||
err = ErrCodeStoreOutOfGas
|
||||
}
|
||||
|
@ -503,7 +503,7 @@ func (evm *EVM) create(caller ContractRef, code []byte, gas uint64, value *big.I
|
|||
if evm.vmConfig.Debug && evm.depth == 0 {
|
||||
evm.vmConfig.Tracer.CaptureEnd(ret, gas-contract.Gas, time.Since(start), err)
|
||||
}
|
||||
return ret, address, contract.Gas, err
|
||||
return ret, contractAddr, contract.Gas, err
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
chainConfig: chainConfig,
|
||||
eventMux: ctx.EventMux,
|
||||
accountManager: ctx.AccountManager,
|
||||
engine: CreateConsensusEngine(ctx, config, chainConfig, config.MinerNotify, config.MinerNoverify, chainDb),
|
||||
engine: CreateConsensusEngine(ctx, chainConfig, config, config.MinerNotify, config.MinerNoverify, chainDb),
|
||||
shutdownChan: make(chan bool),
|
||||
networkID: config.NetworkId,
|
||||
gasPrice: config.MinerGasPrice,
|
||||
|
@ -246,7 +246,7 @@ func CreateDB(ctx *node.ServiceContext, config *Config, name string) (ethdb.Data
|
|||
}
|
||||
|
||||
// CreateConsensusEngine creates the required type of consensus engine instance for an Ethereum service
|
||||
func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainConfig, config *ethash.Config, notify []string, noverify bool, db ethdb.Database) consensus.Engine {
|
||||
func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainConfig, config *Config, notify []string, noverify bool, db ethdb.Database) consensus.Engine {
|
||||
// If proof-of-authority is requested, set it up
|
||||
if chainConfig.Clique != nil {
|
||||
return clique.New(chainConfig.Clique, db)
|
||||
|
@ -261,11 +261,11 @@ func CreateConsensusEngine(ctx *node.ServiceContext, chainConfig *params.ChainCo
|
|||
}
|
||||
|
||||
// Otherwise assume proof-of-work
|
||||
switch config.PowMode {
|
||||
case ModeFake:
|
||||
switch config.Ethash.PowMode {
|
||||
case ethash.ModeFake:
|
||||
log.Warn("Ethash used in fake mode")
|
||||
return ethash.NewFaker()
|
||||
case ModeTest:
|
||||
case ethash.ModeTest:
|
||||
log.Warn("Ethash used in test mode")
|
||||
return ethash.NewTester(nil, noverify)
|
||||
case ethash.ModeShared:
|
||||
|
|
|
@ -28,9 +28,7 @@ import (
|
|||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/ethereum/go-ethereum/accounts"
|
||||
"github.com/ethereum/go-ethereum/accounts/keystore"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
|
|
@ -102,7 +102,7 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) {
|
|||
peers: peers,
|
||||
reqDist: newRequestDistributor(peers, quitSync),
|
||||
accountManager: ctx.AccountManager,
|
||||
engine: eth.CreateConsensusEngine(ctx, chainConfig, &config.Ethash, nil, false, chainDb),
|
||||
engine: eth.CreateConsensusEngine(ctx, chainConfig, config, nil, false, chainDb),
|
||||
shutdownChan: make(chan bool),
|
||||
networkId: config.NetworkId,
|
||||
bloomRequests: make(chan chan *bloombits.Retrieval),
|
||||
|
|
|
@ -31,12 +31,14 @@ import (
|
|||
"github.com/ethereum/go-ethereum/event"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
)
|
||||
|
||||
// Backend wraps all methods required for mining.
|
||||
type Backend interface {
|
||||
BlockChain() *core.BlockChain
|
||||
TxPool() *core.TxPool
|
||||
ChainDb() ethdb.Database
|
||||
}
|
||||
|
||||
// Miner creates blocks and searches for proof-of-work values.
|
||||
|
|
|
@ -544,7 +544,6 @@ func (w *worker) taskLoop() {
|
|||
w.pendingMu.Lock()
|
||||
w.pendingTasks[w.engine.SealHash(task.block.Header())] = task
|
||||
w.pendingMu.Unlock()
|
||||
|
||||
if err := w.engine.Seal(w.chain, task.block, w.resultCh, stopCh); err != nil {
|
||||
log.Warn("Block sealing failed", "err", err)
|
||||
}
|
||||
|
@ -597,7 +596,7 @@ func (w *worker) resultLoop() {
|
|||
|
||||
// write private transacions
|
||||
privateStateRoot, _ := task.privateState.Commit(w.config.IsEIP158(block.Number()))
|
||||
core.WritePrivateStateRoot(w.chainDb, block.Root(), privateStateRoot)
|
||||
core.WritePrivateStateRoot(w.eth.ChainDb(), block.Root(), privateStateRoot)
|
||||
allReceipts := mergeReceipts(task.receipts, task.privateReceipts)
|
||||
|
||||
|
||||
|
@ -1014,7 +1013,15 @@ func (w *worker) commit(uncles []*types.Header, interval func(), update bool, st
|
|||
receipts[i] = new(types.Receipt)
|
||||
*receipts[i] = *l
|
||||
}
|
||||
|
||||
privateReceipts := make([]*types.Receipt, len(w.current.privateReceipts))
|
||||
for i, l := range w.current.privateReceipts {
|
||||
receipts[i] = new(types.Receipt)
|
||||
*receipts[i] = *l
|
||||
}
|
||||
|
||||
s := w.current.state.Copy()
|
||||
ps := w.current.privateState.Copy()
|
||||
block, err := w.engine.Finalize(w.chain, w.current.header, s, w.current.txs, uncles, w.current.receipts)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -1024,7 +1031,7 @@ func (w *worker) commit(uncles []*types.Header, interval func(), update bool, st
|
|||
interval()
|
||||
}
|
||||
select {
|
||||
case w.taskCh <- &task{receipts: receipts, state: s, block: block, createdAt: time.Now()}:
|
||||
case w.taskCh <- &task{receipts: receipts, privateReceipts: privateReceipts, state: s, privateState: ps, block: block, createdAt: time.Now()}:
|
||||
w.unconfirmed.Shift(block.NumberU64() - 1)
|
||||
|
||||
feesWei := new(big.Int)
|
||||
|
|
|
@ -143,7 +143,7 @@ var (
|
|||
TestChainConfig = &ChainConfig{big.NewInt(1), big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, nil, new(EthashConfig), nil, nil, false}
|
||||
TestRules = TestChainConfig.Rules(new(big.Int))
|
||||
|
||||
QuorumTestChainConfig = &ChainConfig{big.NewInt(10), big.NewInt(0), nil, false, nil, common.Hash{}, nil, nil, nil, nil, new(EthashConfig), nil, nil, nil, true}
|
||||
QuorumTestChainConfig = &ChainConfig{big.NewInt(10), big.NewInt(0), nil, false, nil, common.Hash{}, nil, nil, nil, nil, nil, new(EthashConfig), nil, nil, true}
|
||||
)
|
||||
|
||||
// TrustedCheckpoint represents a set of post-processed trie roots (CHT and
|
||||
|
|
|
@ -104,7 +104,7 @@ func NewProtocolManager(raftId uint16, raftPort uint16, blockchain *core.BlockCh
|
|||
bootstrapNodes: bootstrapNodes,
|
||||
peers: make(map[uint16]*Peer),
|
||||
leader: uint16(etcdRaft.None),
|
||||
removedPeers: set.New(),
|
||||
removedPeers: set.New(set.ThreadSafe).(*set.Set),
|
||||
joinExisting: joinExisting,
|
||||
blockchain: blockchain,
|
||||
eventMux: mux,
|
||||
|
|
|
@ -251,7 +251,7 @@ func (minter *minter) createWork() *work {
|
|||
ParentHash: parent.Hash(),
|
||||
Number: parentNumber.Add(parentNumber, common.Big1),
|
||||
Difficulty: ethash.CalcDifficulty(minter.config, uint64(tstamp), parent.Header()),
|
||||
GasLimit: core.CalcGasLimit(parent),
|
||||
GasLimit: core.CalcGasLimit(parent, parent.GasLimit(), parent.GasLimit()),
|
||||
GasUsed: 0,
|
||||
Coinbase: minter.coinbase,
|
||||
Time: big.NewInt(tstamp),
|
||||
|
|
|
@ -100,7 +100,7 @@ func (pm *ProtocolManager) triggerSnapshot(index uint64) {
|
|||
}
|
||||
|
||||
func confStateIdSet(confState raftpb.ConfState) *set.Set {
|
||||
set := set.New()
|
||||
set := set.New(set.ThreadSafe).(*set.Set)
|
||||
for _, rawRaftId := range confState.Nodes {
|
||||
set.Add(uint16(rawRaftId))
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ func (pm *ProtocolManager) updateClusterMembership(newConfState raftpb.ConfState
|
|||
// Update tombstones for permanently removed peers. For simplicity we do not
|
||||
// allow the re-use of peer IDs once a peer is removed.
|
||||
|
||||
removedPeers := set.New()
|
||||
removedPeers := set.New(set.ThreadSafe).(*set.Set)
|
||||
for _, removedRaftId := range removedRaftIds {
|
||||
removedPeers.Add(removedRaftId)
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ func newSpeculativeChain() *speculativeChain {
|
|||
return &speculativeChain{
|
||||
head: nil,
|
||||
unappliedBlocks: lane.NewDeque(),
|
||||
expectedInvalidBlockHashes: set.New(),
|
||||
proposedTxes: set.New(),
|
||||
expectedInvalidBlockHashes: set.New(set.ThreadSafe).(*set.Set),
|
||||
proposedTxes: set.New(set.ThreadSafe).(*set.Set),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue