forked from cerc-io/laconicd-deprecated
app, ante, evm: Keeper StateDB refactor (#30)
* evm: keeper statedb refactor * keeper: implement stateDB account, balance, nonce and suicide functions * keeper: implement stateDB code and iterator functions * keeper: implement stateDB log and preimage functions * update code to use CommitStateDB * tests updates * journal changes (wip) * cache fields * journal and logs * minor cleanup * evm: remove journal related changes * evm: delete empty account code and storage state * app, evm: transient store * ante, evm: refund gas transient * evm: remove transient keeper state fields * address comments from review * evm: undo revision change
This commit is contained in:
+1
-1
@@ -67,7 +67,7 @@ func NewAnteHandler(
|
||||
// handle as *evmtypes.MsgEthereumTx
|
||||
|
||||
anteHandler = sdk.ChainAnteDecorators(
|
||||
NewEthSetupContextDecorator(), // outermost AnteDecorator. EthSetUpContext must be called first
|
||||
NewEthSetupContextDecorator(evmKeeper), // outermost AnteDecorator. EthSetUpContext must be called first
|
||||
NewEthMempoolFeeDecorator(evmKeeper),
|
||||
NewEthValidateBasicDecorator(),
|
||||
authante.TxTimeoutHeightDecorator{},
|
||||
|
||||
+14
-3
@@ -22,6 +22,8 @@ import (
|
||||
type EVMKeeper interface {
|
||||
GetParams(ctx sdk.Context) evmtypes.Params
|
||||
GetChainConfig(ctx sdk.Context) (evmtypes.ChainConfig, bool)
|
||||
WithContext(ctx sdk.Context)
|
||||
ResetRefundTransient(ctx sdk.Context)
|
||||
}
|
||||
|
||||
// EthSetupContextDecorator sets the infinite GasMeter in the Context and wraps
|
||||
@@ -30,11 +32,15 @@ type EVMKeeper interface {
|
||||
// on gas provided and gas used.
|
||||
// CONTRACT: Must be first decorator in the chain
|
||||
// CONTRACT: Tx must implement GasTx interface
|
||||
type EthSetupContextDecorator struct{}
|
||||
type EthSetupContextDecorator struct {
|
||||
evmKeeper EVMKeeper
|
||||
}
|
||||
|
||||
// NewEthSetupContextDecorator creates a new EthSetupContextDecorator
|
||||
func NewEthSetupContextDecorator() EthSetupContextDecorator {
|
||||
return EthSetupContextDecorator{}
|
||||
func NewEthSetupContextDecorator(ek EVMKeeper) EthSetupContextDecorator {
|
||||
return EthSetupContextDecorator{
|
||||
evmKeeper: ek,
|
||||
}
|
||||
}
|
||||
|
||||
// AnteHandle sets the infinite gas meter to done to ignore costs in AnteHandler checks.
|
||||
@@ -43,6 +49,9 @@ func NewEthSetupContextDecorator() EthSetupContextDecorator {
|
||||
func (escd EthSetupContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {
|
||||
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
|
||||
|
||||
// reset the refund gas value for the current transaction
|
||||
escd.evmKeeper.ResetRefundTransient(ctx)
|
||||
|
||||
// all transactions must implement GasTx
|
||||
gasTx, ok := tx.(authante.GasTx)
|
||||
if !ok {
|
||||
@@ -431,6 +440,8 @@ func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula
|
||||
|
||||
// Set gas meter after ante handler to ignore gaskv costs
|
||||
newCtx = authante.SetGasMeter(simulate, ctx, gasLimit)
|
||||
egcd.evmKeeper.WithContext(newCtx)
|
||||
|
||||
return next(newCtx, tx, simulate)
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -252,7 +252,8 @@ func NewEthermintApp(
|
||||
evmtypes.StoreKey,
|
||||
)
|
||||
|
||||
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
|
||||
// Add the EVM transient store key
|
||||
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey)
|
||||
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
|
||||
|
||||
app := &EthermintApp{
|
||||
@@ -310,7 +311,7 @@ func NewEthermintApp(
|
||||
|
||||
// Create Ethermint keepers
|
||||
app.EvmKeeper = evmkeeper.NewKeeper(
|
||||
appCodec, keys[evmtypes.StoreKey], app.GetSubspace(evmtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
|
||||
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey], app.GetSubspace(evmtypes.ModuleName), app.AccountKeeper, app.BankKeeper,
|
||||
)
|
||||
|
||||
// Create IBC Keeper
|
||||
|
||||
Reference in New Issue
Block a user