@@ -508,10 +508,8 @@ func (bc *blockchain) MintNewBlock(
508
508
509
509
sk := bc .config .ProducerPrivateKey ()
510
510
ra := block .NewRunnableActionsBuilder ().
511
- SetHeight (newblockHeight ).
512
- SetTimeStamp (timestamp ).
513
511
AddActions (actions ... ).
514
- Build (sk . PublicKey () )
512
+ Build ()
515
513
516
514
prevBlkHash := bc .tipHash
517
515
// The first block's previous block hash is pointing to the digest of genesis config. This is to guarantee all nodes
@@ -520,6 +518,8 @@ func (bc *blockchain) MintNewBlock(
520
518
prevBlkHash = bc .config .Genesis .Hash ()
521
519
}
522
520
blk , err := block .NewBuilder (ra ).
521
+ SetHeight (newblockHeight ).
522
+ SetTimestamp (timestamp ).
523
523
SetPrevBlockHash (prevBlkHash ).
524
524
SetDeltaStateDigest (ws .Digest ()).
525
525
SetReceipts (rc ).
@@ -652,7 +652,7 @@ func (bc *blockchain) startExistingBlockchain() error {
652
652
if err != nil {
653
653
return errors .Wrap (err , "failed to obtain working set from state factory" )
654
654
}
655
- if _ , err := bc .runActions (blk . RunnableActions () , ws ); err != nil {
655
+ if _ , err := bc .runActions (blk , ws ); err != nil {
656
656
return err
657
657
}
658
658
@@ -718,7 +718,7 @@ func (bc *blockchain) validateBlock(blk *block.Block) error {
718
718
return errors .Wrap (err , "Failed to obtain working set from state factory" )
719
719
}
720
720
runTimer := bc .timerFactory .NewTimer ("runActions" )
721
- receipts , err := bc .runActions (blk . RunnableActions () , ws )
721
+ receipts , err := bc .runActions (blk , ws )
722
722
runTimer .End ()
723
723
if err != nil {
724
724
log .L ().Panic ("Failed to update state." , zap .Uint64 ("tipHeight" , bc .tipHeight ), zap .Error (err ))
@@ -782,27 +782,27 @@ func (bc *blockchain) commitBlock(blk *block.Block) error {
782
782
}
783
783
784
784
func (bc * blockchain ) runActions (
785
- acts block.RunnableActions ,
785
+ blk * block.Block ,
786
786
ws factory.WorkingSet ,
787
787
) ([]* action.Receipt , error ) {
788
788
if bc .sf == nil {
789
789
return nil , errors .New ("statefactory cannot be nil" )
790
790
}
791
791
792
- producer , err := address .FromBytes (acts . BlockProducerPubKey ().Hash ())
792
+ producer , err := address .FromBytes (blk . PublicKey ().Hash ())
793
793
if err != nil {
794
794
return nil , err
795
795
}
796
796
797
- ctx , err := bc .context (context .Background (), producer , acts . BlockHeight (), acts . BlockTimeStamp ())
797
+ ctx , err := bc .context (context .Background (), producer , blk . Height (), blk . Timestamp ())
798
798
if err != nil {
799
799
return nil , err
800
800
}
801
801
802
802
raCtx := protocol .MustGetRunActionsCtx (ctx )
803
803
raCtx .History = ws .History ()
804
+ registry := raCtx .Registry
804
805
ctx = protocol .WithRunActionsCtx (ctx , raCtx )
805
- registry := protocol .MustGetRunActionsCtx (ctx ).Registry
806
806
for _ , p := range registry .All () {
807
807
if pp , ok := p .(protocol.PreStatesCreator ); ok {
808
808
if err := pp .CreatePreStates (ctx , ws ); err != nil {
@@ -812,7 +812,7 @@ func (bc *blockchain) runActions(
812
812
}
813
813
// TODO: verify whether the post system actions are appended tail
814
814
815
- return ws .RunActions (ctx , acts . BlockHeight (), acts .Actions ())
815
+ return ws .RunActions (ctx , blk . Height (), blk . RunnableActions () .Actions ())
816
816
}
817
817
818
818
func (bc * blockchain ) pickAndRunActions (ctx context.Context , actionMap map [string ][]action.SealedEnvelope ,
0 commit comments