@@ -613,8 +613,8 @@ func (app *BaseApp) preparePrepareProposalState() {
613
613
}
614
614
}
615
615
616
- func (app * BaseApp ) prepareProcessProposalState (gasMeter sdk. GasMeter , headerHash []byte ) {
617
- app .processProposalState .SetContext (app .processProposalState .Context ().WithBlockGasMeter ( gasMeter ).
616
+ func (app * BaseApp ) prepareProcessProposalState (headerHash []byte ) {
617
+ app .processProposalState .SetContext (app .processProposalState .Context ().
618
618
WithHeaderHash (headerHash ).
619
619
WithConsensusParams (app .GetConsensusParams (app .processProposalState .Context ())))
620
620
@@ -623,9 +623,8 @@ func (app *BaseApp) prepareProcessProposalState(gasMeter sdk.GasMeter, headerHas
623
623
}
624
624
}
625
625
626
- func (app * BaseApp ) prepareDeliverState (gasMeter sdk. GasMeter , headerHash []byte ) {
626
+ func (app * BaseApp ) prepareDeliverState (headerHash []byte ) {
627
627
app .deliverState .SetContext (app .deliverState .Context ().
628
- WithBlockGasMeter (gasMeter ).
629
628
WithHeaderHash (headerHash ).
630
629
WithConsensusParams (app .GetConsensusParams (app .deliverState .Context ())))
631
630
}
@@ -724,27 +723,6 @@ func (app *BaseApp) StoreConsensusParams(ctx sdk.Context, cp *tmproto.ConsensusP
724
723
app .paramStore .Set (ctx , ParamStoreKeyABCIParams , cp .Abci )
725
724
}
726
725
727
- // getMaximumBlockGas gets the maximum gas from the consensus params. It panics
728
- // if maximum block gas is less than negative one and returns zero if negative
729
- // one.
730
- func (app * BaseApp ) getMaximumBlockGas (ctx sdk.Context ) uint64 {
731
- cp := app .GetConsensusParams (ctx )
732
- if cp == nil || cp .Block == nil {
733
- return 0
734
- }
735
-
736
- maxGas := cp .Block .MaxGas
737
-
738
- // TODO::: This is a temporary fix, max gas causes non-deterministic behavior
739
- // with parallel TX
740
- switch {
741
- case maxGas < - 1 :
742
- panic (fmt .Sprintf ("invalid maximum block gas: %d" , maxGas ))
743
- default :
744
- return 0
745
- }
746
- }
747
-
748
726
func (app * BaseApp ) validateHeight (req abci.RequestBeginBlock ) error {
749
727
if req .Header .Height < 1 {
750
728
return fmt .Errorf ("invalid height: %d" , req .Header .Height )
@@ -879,11 +857,6 @@ func (app *BaseApp) runTx(ctx sdk.Context, mode runTxMode, txBytes []byte) (gInf
879
857
880
858
ms := ctx .MultiStore ()
881
859
882
- // only run the tx if there is block gas remaining
883
- if mode == runTxModeDeliver && ctx .BlockGasMeter ().IsOutOfGas () {
884
- return gInfo , nil , nil , - 1 , sdkerrors .Wrap (sdkerrors .ErrOutOfGas , "no block gas left to run tx" )
885
- }
886
-
887
860
defer func () {
888
861
if r := recover (); r != nil {
889
862
acltypes .SendAllSignalsForTx (ctx .TxCompletionChannels ())
@@ -896,27 +869,6 @@ func (app *BaseApp) runTx(ctx sdk.Context, mode runTxMode, txBytes []byte) (gInf
896
869
gInfo = sdk.GasInfo {GasWanted : gasWanted , GasUsed : ctx .GasMeter ().GasConsumed ()}
897
870
}()
898
871
899
- blockGasConsumed := false
900
- // consumeBlockGas makes sure block gas is consumed at most once. It must happen after
901
- // tx processing, and must be execute even if tx processing fails. Hence we use trick with `defer`
902
- consumeBlockGas := func () {
903
- if ! blockGasConsumed {
904
- blockGasConsumed = true
905
- ctx .BlockGasMeter ().ConsumeGas (
906
- ctx .GasMeter ().GasConsumedToLimit (), "block gas meter" ,
907
- )
908
- }
909
- }
910
-
911
- // If BlockGasMeter() panics it will be caught by the above recover and will
912
- // return an error - in any case BlockGasMeter will consume gas past the limit.
913
- //
914
- // NOTE: This must exist in a separate defer function for the above recovery
915
- // to recover from this one.
916
- if mode == runTxModeDeliver {
917
- defer consumeBlockGas ()
918
- }
919
-
920
872
tx , err := app .txDecoder (txBytes )
921
873
if err != nil {
922
874
return sdk.GasInfo {}, nil , nil , 0 , err
@@ -1004,9 +956,6 @@ func (app *BaseApp) runTx(ctx sdk.Context, mode runTxMode, txBytes []byte) (gInf
1004
956
result , err = app .runMsgs (runMsgCtx , msgs , mode )
1005
957
1006
958
if err == nil && mode == runTxModeDeliver {
1007
- // When block gas exceeds, it'll panic and won't commit the cached store.
1008
- consumeBlockGas ()
1009
-
1010
959
msCache .Write ()
1011
960
}
1012
961
// we do this since we will only be looking at result in DeliverTx
0 commit comments