diff --git a/api/service/syncing/syncing.go b/api/service/syncing/syncing.go index 8827fb851..53a094a69 100644 --- a/api/service/syncing/syncing.go +++ b/api/service/syncing/syncing.go @@ -544,7 +544,7 @@ func (ss *StateSync) updateBlockAndStatus(block *types.Block, bc *core.BlockChai _, err := bc.InsertChain([]*types.Block{block}) if err != nil { - utils.Logger().Error().Err(err).Msgf("[SYNC] Error adding new block to blockchain %d %d %s", block.NumberU64(), block.ShardID(), block.IncomingReceipts()) + utils.Logger().Error().Err(err).Msgf("[SYNC] Error adding new block to blockchain %d %d", block.NumberU64(), block.ShardID()) utils.Logger().Debug().Interface("block", bc.CurrentBlock()).Msg("[SYNC] Rolling back current block!") bc.Rollback([]common.Hash{bc.CurrentBlock().Hash()}) @@ -567,7 +567,6 @@ func (ss *StateSync) generateNewState(bc *core.BlockChain, worker *worker.Worker // update blocks created before node start sync parentHash := bc.CurrentBlock().Hash() for { - utils.Logger().Warn().Msg("[SYNC] 111") block := ss.getBlockFromOldBlocksByParentHash(parentHash) if block == nil { break @@ -585,7 +584,6 @@ func (ss *StateSync) generateNewState(bc *core.BlockChain, worker *worker.Worker // update blocks after node start sync parentHash = bc.CurrentBlock().Hash() for { - utils.Logger().Warn().Msg("[SYNC] 222") block := ss.getMaxConsensusBlockFromParentHash(parentHash) if block == nil { break @@ -608,7 +606,6 @@ func (ss *StateSync) generateNewState(bc *core.BlockChain, worker *worker.Worker // update last mile blocks if any parentHash = bc.CurrentBlock().Hash() for { - utils.Logger().Warn().Msg("[SYNC] 333") block := ss.getBlockFromLastMileBlocksByParentHash(parentHash) if block == nil { break diff --git a/core/rawdb/accessors_chain.go b/core/rawdb/accessors_chain.go index 3c8c5503d..cadea09ef 100644 --- a/core/rawdb/accessors_chain.go +++ b/core/rawdb/accessors_chain.go @@ -339,7 +339,7 @@ func ReadBlock(db DatabaseReader, hash common.Hash, number uint64) *types.Block if body == nil { return nil } - return types.NewBlockWithHeader(header).WithBody(body.Transactions, body.Uncles) + return types.NewBlockWithHeader(header).WithBody(body.Transactions, body.Uncles, body.IncomingReceipts) } // WriteBlock serializes a block into the database, header and body separately. diff --git a/core/types/block.go b/core/types/block.go index bc1adc942..07759cd93 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -154,8 +154,9 @@ func rlpHash(x interface{}) (h common.Hash) { // Body is a simple (mutable, non-safe) data container for storing and moving // a block's data contents (transactions and uncles) together. type Body struct { - Transactions []*Transaction - Uncles []*Header + Transactions []*Transaction + Uncles []*Header + IncomingReceipts CXReceiptsProofs } // Block represents an entire block in the Ethereum blockchain. @@ -419,7 +420,7 @@ func (b *Block) Extra() []byte { return common.CopyBytes(b.header.Extra) } func (b *Block) Header() *Header { return CopyHeader(b.header) } // Body returns the non-header content of the block. -func (b *Block) Body() *Body { return &Body{b.transactions, b.uncles} } +func (b *Block) Body() *Body { return &Body{b.transactions, b.uncles, b.incomingReceipts} } // Vdf returns header Vdf. func (b *Block) Vdf() []byte { return common.CopyBytes(b.header.Vdf) } @@ -464,11 +465,12 @@ func (b *Block) WithSeal(header *Header) *Block { } // WithBody returns a new block with the given transaction and uncle contents. -func (b *Block) WithBody(transactions []*Transaction, uncles []*Header) *Block { +func (b *Block) WithBody(transactions []*Transaction, uncles []*Header, incomingReceipts CXReceiptsProofs) *Block { block := &Block{ - header: CopyHeader(b.header), - transactions: make([]*Transaction, len(transactions)), - uncles: make([]*Header, len(uncles)), + header: CopyHeader(b.header), + transactions: make([]*Transaction, len(transactions)), + uncles: make([]*Header, len(uncles)), + incomingReceipts: incomingReceipts, } copy(block.transactions, transactions) for i := range uncles { diff --git a/hmyclient/hmyclient.go b/hmyclient/hmyclient.go index 73f20075b..7e000a8f4 100644 --- a/hmyclient/hmyclient.go +++ b/hmyclient/hmyclient.go @@ -119,7 +119,7 @@ func (c *Client) getBlock(ctx context.Context, method string, args ...interface{ } txs[i] = tx.tx } - return types.NewBlockWithHeader(head).WithBody(txs, []*types.Header{}), nil + return types.NewBlockWithHeader(head).WithBody(txs, []*types.Header{}, nil), nil } func toBlockNumArg(number *big.Int) string { diff --git a/node/node_error.go b/node/node_error.go index 21b9df96e..ac0074555 100644 --- a/node/node_error.go +++ b/node/node_error.go @@ -5,5 +5,6 @@ import ( ) var ( + // ErrCrosslinkVerificationFail ... ErrCrosslinkVerificationFail = errors.New("Crosslink Verification Failed") ) diff --git a/node/node_handler.go b/node/node_handler.go index 07df5720c..e34d4fdb7 100644 --- a/node/node_handler.go +++ b/node/node_handler.go @@ -179,7 +179,7 @@ func (node *Node) messageHandler(content []byte, sender libp2p_peer.ID) { if block.ShardID() == 0 { utils.Logger().Info(). Uint64("block", blocks[0].NumberU64()). - Msgf("Block being handled by block channel %d %d %s", block.NumberU64(), block.ShardID(), block.IncomingReceipts()) + Msgf("Block being handled by block channel %d %d", block.NumberU64(), block.ShardID()) node.BeaconBlockChannel <- block } } @@ -281,7 +281,7 @@ func (node *Node) transactionMessageHandler(msgPayload []byte) { // NOTE: For now, just send to the client (basically not broadcasting) // TODO (lc): broadcast the new blocks to new nodes doing state sync func (node *Node) BroadcastNewBlock(newBlock *types.Block) { - utils.Logger().Info().Msgf("broadcasting new block %d %s", newBlock.NumberU64(), newBlock.IncomingReceipts()) + utils.Logger().Info().Msgf("broadcasting new block %d", newBlock.NumberU64()) groups := []p2p.GroupID{node.NodeConfig.GetClientGroupID()} msg := host.ConstructP2pMessage(byte(0), proto_node.ConstructBlocksSyncMessage([]*types.Block{newBlock})) if err := node.host.SendMessageToGroups(groups, msg); err != nil { diff --git a/node/node_syncing.go b/node/node_syncing.go index 89f0b0e77..ba23a96ec 100644 --- a/node/node_syncing.go +++ b/node/node_syncing.go @@ -360,6 +360,7 @@ func (node *Node) CalculateResponse(request *downloader_pb.DownloaderRequest, in continue } encodedBlock, err := rlp.EncodeToBytes(block) + if err == nil { response.Payload = append(response.Payload, encodedBlock) } diff --git a/test/chain/main.go b/test/chain/main.go index 6221ded26..12ce317a6 100644 --- a/test/chain/main.go +++ b/test/chain/main.go @@ -13,7 +13,6 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/params" - "github.com/harmony-one/harmony/consensus" "github.com/harmony-one/harmony/core" core_state "github.com/harmony-one/harmony/core/state" "github.com/harmony-one/harmony/core/types" @@ -105,7 +104,7 @@ func fundFaucetContract(chain *core.BlockChain) { fmt.Println("--------- Funding addresses for Faucet Contract Call ---------") fmt.Println() - contractworker = pkgworker.New(params.TestChainConfig, chain, consensus.NewFaker(), 0) + contractworker = pkgworker.New(params.TestChainConfig, chain, chain.Engine(), 0) nonce = contractworker.GetCurrentState().GetNonce(crypto.PubkeyToAddress(FaucetPriKey.PublicKey)) dataEnc = common.FromHex(FaucetContractBinary) ftx, _ := types.SignTx(types.NewContractCreation(nonce, 0, big.NewInt(7000000000000000000), params.TxGasContractCreation*10, nil, dataEnc), types.HomesteadSigner{}, FaucetPriKey) @@ -331,7 +330,7 @@ func playStakingContract(chain *core.BlockChain) { func main() { genesis := gspec.MustCommit(database) - chain, _ := core.NewBlockChain(database, nil, gspec.Config, consensus.NewFaker(), vm.Config{}, nil) + chain, _ := core.NewBlockChain(database, nil, gspec.Config, chain.Engine(), vm.Config{}, nil) txpool := core.NewTxPool(core.DefaultTxPoolConfig, chainConfig, chain) @@ -345,7 +344,7 @@ func main() { //// Generate a small n-block chain and an uncle block for it n := 3 if n > 0 { - blocks, _ := core.GenerateChain(chainConfig, genesis, consensus.NewFaker(), database, n, func(i int, gen *core.BlockGen) { + blocks, _ := core.GenerateChain(chainConfig, genesis, chain.Engine(), database, n, func(i int, gen *core.BlockGen) { gen.SetCoinbase(FaucetAddress) gen.SetShardID(0) gen.AddTx(pendingTxs[i])