func (s *ShardRPCServer) GenerateBlockTemplate(ctx context.Context, req *pb.BlockGenerationRequest) (*pb.ShardBlock, error) {
	finalizedBeaconHash, err := chainhash.NewHash(req.FinalizedBeaconHash)
	if err != nil {
		return nil, err
	}

	manager, err := s.sm.GetManager(req.Shard)
	if err != nil {
		return nil, err
	}

	tipNode, err := manager.Chain.Tip()
	if err != nil {
		return nil, err
	}

	proposalInfo := manager.SyncManager.GetProposalInformation(req.Slot)

	txPackage := proposalInfo.TransactionPackage

	transactionRoot, _ := ssz.HashTreeRoot(txPackage.Transactions)

	// for now, block is empty, but we'll fill this in eventually
	block := &primitives.ShardBlock{
		Header: primitives.ShardBlockHeader{
			PreviousBlockHash:   tipNode.BlockHash,
			Slot:                req.Slot,
			Signature:           [48]byte{},
			StateRoot:           txPackage.EndRoot,
			TransactionRoot:     transactionRoot,
			FinalizedBeaconHash: *finalizedBeaconHash,
		},
		Body: primitives.ShardBlockBody{
			Transactions: txPackage.Transactions,
		},
	}

	return block.ToProto(), nil
}
// GenerateBlockTemplate generates a block template using transactions and witnesses for a certain shard at a certain
// slot.
GenerateBlockTemplate generates a block template using transactions and witnesses for a certain shard at a certain
slot.
// GenerateBlockTemplate generates a block template using transactions and witnesses for a certain shard at a certain // slot .
func (s *ShardRPCServer) GenerateBlockTemplate(ctx context.Context, req *pb.BlockGenerationRequest) (*pb.ShardBlock, error) {
	finalizedBeaconHash, err := chainhash.NewHash(req.FinalizedBeaconHash)
	if err != nil {
		return nil, err
	}
	manager, err := s.sm.GetManager(req.Shard)
	if err != nil {
		return nil, err
	}
	tipNode, err := manager.Chain.Tip()
	if err != nil {
		return nil, err
	}
	proposalInfo := manager.SyncManager.GetProposalInformation(req.Slot)
	txPackage := proposalInfo.TransactionPackage
	transactionRoot, _ := ssz.HashTreeRoot(txPackage.Transactions)
	block := &primitives.ShardBlock{
		Header: primitives.ShardBlockHeader{
			PreviousBlockHash:   tipNode.BlockHash,
			Slot:                req.Slot,
			Signature:           [48]byte{},
			StateRoot:           txPackage.EndRoot,
			TransactionRoot:     transactionRoot,
			FinalizedBeaconHash: *finalizedBeaconHash,
		},
		Body: primitives.ShardBlockBody{
			Transactions: txPackage.Transactions,
		},
	}
	return block.ToProto(), nil
}
func ( s * ShardRPCServer ) GenerateBlockTemplate ( ctx context . Context , req * pb . BlockGenerationRequest ) ( * pb . ShardBlock , error ) { finalizedBeaconHash , err := chainhash . NewHash ( req . FinalizedBeaconHash ) if err != nil { return nil , err } manager , err := s . sm . GetManager ( req . Shard ) if err != nil { return nil , err } tipNode , err := manager . Chain . Tip ( ) if err != nil { return nil , err } proposalInfo := manager . SyncManager . GetProposalInformation ( req . Slot ) txPackage := proposalInfo . TransactionPackage transactionRoot , _ := ssz . HashTreeRoot ( txPackage . Transactions ) block := & primitives . ShardBlock { Header : primitives . ShardBlockHeader { PreviousBlockHash : tipNode . BlockHash , Slot : req . Slot , Signature : [ 48 ] byte { } , StateRoot : txPackage . EndRoot , TransactionRoot : transactionRoot , FinalizedBeaconHash : * finalizedBeaconHash , } , Body : primitives . ShardBlockBody { Transactions : txPackage . Transactions , } , } return block . ToProto ( ) , nil }
GenerateBlockTemplate generates a block template using transactions and witnesses for a certain shard at a certain
slot.
GenerateBlockTemplate generates a block template using transactions and witnesses for a certain shard at a certain slot .
// for now, block is empty, but we'll fill this in eventually