Skip to content

Commit

Permalink
Merge PR: Revert "Merge PR: Dynamic GP compatible with Tx parallel (#…
Browse files Browse the repository at this point in the history
…2795)" (#2836)

This reverts commit 082ebe8.
  • Loading branch information
KamiD authored Dec 2, 2022
1 parent 082ebe8 commit e18eb77
Show file tree
Hide file tree
Showing 16 changed files with 454 additions and 383 deletions.
10 changes: 5 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,6 @@ func NewOKExChainApp(
app.SetEvmSysContractAddressHandler(NewEvmSysContractAddressHandler(app.EvmKeeper))
app.SetEvmWatcherCollector(app.EvmKeeper.Watcher.Collect)

gpoConfig := gasprice.NewGPOConfig(appconfig.GetOecConfig().GetDynamicGpWeight(), appconfig.GetOecConfig().GetDynamicGpCheckBlocks())
app.gpo = gasprice.NewOracle(gpoConfig)
app.SetUpdateGPOHandler(updateGPOHandler(app.gpo))

if loadLatest {
err := app.LoadLatestVersion(app.keys[bam.MainStoreKey])
if err != nil {
Expand All @@ -673,6 +669,10 @@ func NewOKExChainApp(
enableAnalyzer := sm.DeliverTxsExecMode(viper.GetInt(sm.FlagDeliverTxsExecMode)) == sm.DeliverTxsExecModeSerial
trace.EnableAnalyzer(enableAnalyzer)

if appconfig.GetOecConfig().GetDynamicGpMode() != types.CloseMode {
gpoConfig := gasprice.NewGPOConfig(appconfig.GetOecConfig().GetDynamicGpWeight(), appconfig.GetOecConfig().GetDynamicGpCheckBlocks())
app.gpo = gasprice.NewOracle(gpoConfig)
}
return app
}

Expand Down Expand Up @@ -705,7 +705,7 @@ func (app *OKExChainApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBloc

// EndBlocker updates every end block
func (app *OKExChainApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
if appconfig.GetOecConfig().GetDynamicGpMode() != types.MinimalGpMode {
if appconfig.GetOecConfig().GetDynamicGpMode() != types.CloseMode {
currentBlockGPsCopy := app.gpo.CurrentBlockGPs.Copy()
_ = app.gpo.BlockGPQueue.Push(currentBlockGPsCopy)
GlobalGp = app.gpo.RecommendGP()
Expand Down
23 changes: 23 additions & 0 deletions app/app_abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import (
"time"

appconfig "github.com/okex/exchain/app/config"
"github.com/okex/exchain/app/types"
sdk "github.com/okex/exchain/libs/cosmos-sdk/types"
"github.com/okex/exchain/libs/system/trace"
abci "github.com/okex/exchain/libs/tendermint/abci/types"
"github.com/okex/exchain/x/evm"
"github.com/okex/exchain/x/wasm/watcher"
)

Expand All @@ -23,6 +26,14 @@ func (app *OKExChainApp) DeliverTx(req abci.RequestDeliverTx) (res abci.Response

resp := app.BaseApp.DeliverTx(req)

if appconfig.GetOecConfig().GetDynamicGpMode() != types.CloseMode {
tx, err := evm.TxDecoder(app.marshal)(req.Tx)
if err == nil {
//optimize get tx gas price can not get value from verifySign method
app.gpo.CurrentBlockGPs.Update(tx.GetGasPrice(), uint64(resp.GasUsed))
}
}

return resp
}

Expand All @@ -35,6 +46,18 @@ func (app *OKExChainApp) DeliverRealTx(req abci.TxEssentials) (res abci.Response
resp := app.BaseApp.DeliverRealTx(req)
app.EvmKeeper.Watcher.RecordTxAndFailedReceipt(req, &resp, app.GetTxDecoder())

var err error
if appconfig.GetOecConfig().GetDynamicGpMode() != types.CloseMode {
tx, _ := req.(sdk.Tx)
if tx == nil {
tx, err = evm.TxDecoder(app.Codec())(req.GetRaw())
}
if err == nil {
//optimize get tx gas price can not get value from verifySign method
app.gpo.CurrentBlockGPs.Update(tx.GetGasPrice(), uint64(resp.GasUsed))
}
}

return resp
}

Expand Down
12 changes: 0 additions & 12 deletions app/app_parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"sort"
"strings"

appconfig "github.com/okex/exchain/app/config"
"github.com/okex/exchain/app/gasprice"
ethermint "github.com/okex/exchain/app/types"
sdk "github.com/okex/exchain/libs/cosmos-sdk/types"
"github.com/okex/exchain/libs/cosmos-sdk/x/auth"
Expand Down Expand Up @@ -147,13 +145,3 @@ func groupByAddrAndSortFeeSplits(txFeesplit []*sdk.FeeSplitInfo) (feesplits map[

return
}

func updateGPOHandler(gpo *gasprice.Oracle) sdk.UpdateGPOHandler {
return func(dynamicGpInfos []sdk.DynamicGasInfo) {
if appconfig.GetOecConfig().GetDynamicGpMode() != ethermint.MinimalGpMode {
for _, dgi := range dynamicGpInfos {
gpo.CurrentBlockGPs.Update(dgi.GetGP(), dgi.GetGU())
}
}
}
}
10 changes: 4 additions & 6 deletions app/app_test.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package app

import (
"math/big"
"os"
"testing"

ethcommon "github.com/ethereum/go-ethereum/common"
ethcrypto "github.com/ethereum/go-ethereum/crypto"
"github.com/stretchr/testify/suite"

"github.com/okex/exchain/app/crypto/ethsecp256k1"
cosmossdk "github.com/okex/exchain/libs/cosmos-sdk/types"
authclient "github.com/okex/exchain/libs/cosmos-sdk/x/auth/client/utils"
"github.com/okex/exchain/libs/tendermint/global"
tendertypes "github.com/okex/exchain/libs/tendermint/types"
"github.com/okex/exchain/x/distribution/keeper"
evmtypes "github.com/okex/exchain/x/evm/types"
"github.com/stretchr/testify/suite"
"math/big"
"os"
"testing"

"github.com/okex/exchain/libs/cosmos-sdk/x/upgrade"
"github.com/okex/exchain/x/dex"
Expand Down
Loading

0 comments on commit e18eb77

Please sign in to comment.