@@ -469,6 +469,12 @@ func (ws *workingSet) process(ctx context.Context, actions []*action.SealedEnvel
469
469
if err := ws .validate (ctx ); err != nil {
470
470
return err
471
471
}
472
+ userActions , systemActions := ws .splitActions (actions )
473
+ if protocol .MustGetFeatureCtx (ctx ).PreStateSystemAction {
474
+ if err := ws .validatePostSystemActions (ctx , systemActions ); err != nil {
475
+ return err
476
+ }
477
+ }
472
478
reg := protocol .MustGetRegistry (ctx )
473
479
for _ , p := range reg .All () {
474
480
if pp , ok := p .(protocol.PreStatesCreator ); ok {
@@ -478,11 +484,10 @@ func (ws *workingSet) process(ctx context.Context, actions []*action.SealedEnvel
478
484
}
479
485
}
480
486
var (
481
- receipts = make ([]* action.Receipt , 0 )
482
- ctxWithBlockContext = ctx
483
- blkCtx = protocol .MustGetBlockCtx (ctx )
484
- fCtx = protocol .MustGetFeatureCtx (ctx )
485
- userActions , systemActions = ws .splitActions (actions )
487
+ receipts = make ([]* action.Receipt , 0 )
488
+ ctxWithBlockContext = ctx
489
+ blkCtx = protocol .MustGetBlockCtx (ctx )
490
+ fCtx = protocol .MustGetFeatureCtx (ctx )
486
491
)
487
492
for _ , act := range userActions {
488
493
if err := ws .txValidator .ValidateWithState (ctxWithBlockContext , act ); err != nil {
@@ -513,8 +518,10 @@ func (ws *workingSet) process(ctx context.Context, actions []*action.SealedEnvel
513
518
}
514
519
}
515
520
// Handle post system actions
516
- if err := ws .validatePostSystemActions (ctxWithBlockContext , systemActions ); err != nil {
517
- return err
521
+ if ! protocol .MustGetFeatureCtx (ctx ).PreStateSystemAction {
522
+ if err := ws .validatePostSystemActions (ctxWithBlockContext , systemActions ); err != nil {
523
+ return err
524
+ }
518
525
}
519
526
for _ , act := range systemActions {
520
527
actionCtx , err := withActionCtx (ctxWithBlockContext , act )
@@ -682,6 +689,16 @@ func (ws *workingSet) pickAndRunActions(
682
689
executedActions := make ([]* action.SealedEnvelope , 0 )
683
690
reg := protocol .MustGetRegistry (ctx )
684
691
692
+ var (
693
+ systemActions []* action.SealedEnvelope
694
+ )
695
+ if protocol .MustGetFeatureCtx (ctx ).PreStateSystemAction {
696
+ systemActions , err = ws .generateSignedSystemActions (ctx , sign )
697
+ if err != nil {
698
+ return nil , err
699
+ }
700
+ }
701
+
685
702
for _ , p := range reg .All () {
686
703
if pp , ok := p .(protocol.PreStatesCreator ); ok {
687
704
if err := pp .CreatePreStates (ctx , ws ); err != nil {
@@ -800,19 +817,14 @@ func (ws *workingSet) pickAndRunActions(
800
817
}
801
818
}
802
819
803
- unsignedSystemActions , err := ws .generateSystemActions (ctxWithBlockContext )
804
- if err != nil {
805
- return nil , err
806
- }
807
- postSystemActions := make ([]* action.SealedEnvelope , len (unsignedSystemActions ))
808
- for i , elp := range unsignedSystemActions {
809
- selp , err := sign (elp )
820
+ if ! fCtx .PreStateSystemAction {
821
+ systemActions , err = ws .generateSignedSystemActions (ctx , sign )
810
822
if err != nil {
811
- return nil , errors . Wrapf ( err , "failed to sign %+v" , elp . Action ())
823
+ return nil , err
812
824
}
813
- postSystemActions [i ] = selp
814
825
}
815
- for _ , selp := range postSystemActions {
826
+
827
+ for _ , selp := range systemActions {
816
828
actionCtx , err := withActionCtx (ctxWithBlockContext , selp )
817
829
if err != nil {
818
830
return nil , err
@@ -832,6 +844,22 @@ func (ws *workingSet) pickAndRunActions(
832
844
return executedActions , ws .finalize ()
833
845
}
834
846
847
+ func (ws * workingSet ) generateSignedSystemActions (ctx context.Context , sign func (elp action.Envelope ) (* action.SealedEnvelope , error )) ([]* action.SealedEnvelope , error ) {
848
+ unsignedSystemActions , err := ws .generateSystemActions (ctx )
849
+ if err != nil {
850
+ return nil , err
851
+ }
852
+ postSystemActions := make ([]* action.SealedEnvelope , len (unsignedSystemActions ))
853
+ for i , elp := range unsignedSystemActions {
854
+ selp , err := sign (elp )
855
+ if err != nil {
856
+ return nil , errors .Wrapf (err , "failed to sign %+v" , elp .Action ())
857
+ }
858
+ postSystemActions [i ] = selp
859
+ }
860
+ return postSystemActions , nil
861
+ }
862
+
835
863
func updateReceiptIndex (receipts []* action.Receipt ) {
836
864
var txIndex , logIndex uint32
837
865
for _ , r := range receipts {
0 commit comments