Fix view id copy

pull/1133/head
Rongjian Lan 5 years ago
parent d2e9862b91
commit b409058a2c
  1. 3
      core/state_processor.go
  2. 3
      core/types/block.go
  3. 5
      internal/shardchain/shardchains.go
  4. 2
      node/node_genesis.go
  5. 3
      node/worker/worker.go

@ -59,6 +59,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.DB, cfg vm.C
receipts types.Receipts
usedGas = new(uint64)
header = block.Header()
coinbase = block.Header().Coinbase
allLogs []*types.Log
gp = new(GasPool).AddGas(block.GasLimit())
)
@ -69,7 +70,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.DB, cfg vm.C
// Iterate over and process the individual transactions
for i, tx := range block.Transactions() {
statedb.Prepare(tx.Hash(), block.Hash(), i)
receipt, _, err := ApplyTransaction(p.config, p.bc, &block.Header().Coinbase, gp, statedb, header, tx, usedGas, cfg)
receipt, _, err := ApplyTransaction(p.config, p.bc, &coinbase, gp, statedb, header, tx, usedGas, cfg)
if err != nil {
return nil, nil, 0, err
}

@ -265,6 +265,9 @@ func CopyHeader(h *Header) *Header {
if cpy.Number = new(big.Int); h.Number != nil {
cpy.Number.Set(h.Number)
}
if cpy.ViewID = new(big.Int); h.ViewID != nil {
cpy.ViewID.Set(h.ViewID)
}
if cpy.Epoch = new(big.Int); h.Epoch != nil {
cpy.Epoch.Set(h.Epoch)
}

@ -1,10 +1,9 @@
package shardchain
import (
"math/big"
"sync"
nodeconfig "github.com/harmony-one/harmony/internal/configs/node"
"github.com/harmony-one/harmony/internal/configs/node"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethdb"
@ -103,7 +102,7 @@ func (sc *CollectionImpl) ShardChain(shardID uint32, networkType nodeconfig.Netw
chainConfig = *params.TestnetChainConfig
}
chainConfig.ChainID = big.NewInt(int64(shardID))
//chainConfig.ChainID = big.NewInt(int64(shardID))
bc, err := core.NewBlockChain(
db, cacheConfig, &chainConfig, sc.engine, vm.Config{}, nil,

@ -93,7 +93,7 @@ func (node *Node) SetupGenesisBlock(db ethdb.Database, shardID uint32, myShardSt
// Initialize shard state
// TODO: add ShardID into chainconfig and change ChainID to NetworkID
chainConfig.ChainID = big.NewInt(int64(shardID)) // Use ChainID as piggybacked ShardID
//chainConfig.ChainID = big.NewInt(int64(shardID)) // Use ChainID as piggybacked ShardID
gspec := core.Genesis{
Config: &chainConfig,

@ -167,7 +167,8 @@ func (w *Worker) Commit(sig []byte, signers []byte, viewID uint64, coinbase comm
s := w.current.state.Copy()
block, err := w.engine.Finalize(w.chain, w.current.header, s, w.current.txs, w.current.receipts)
copyHeader := types.CopyHeader(w.current.header)
block, err := w.engine.Finalize(w.chain, copyHeader, s, w.current.txs, w.current.receipts)
if err != nil {
return nil, ctxerror.New("cannot finalize block").WithCause(err)
}

Loading…
Cancel
Save