forked from cerc-io/laconicd-deprecated
		
	evm: decouple tracer from evm creation (#459)
This commit is contained in:
		
							parent
							
								
									83c838330f
								
							
						
					
					
						commit
						fc46430e0f
					
				| @ -27,7 +27,7 @@ type EVMKeeper interface { | ||||
| 	WithContext(ctx sdk.Context) | ||||
| 	ResetRefundTransient(ctx sdk.Context) | ||||
| 	GetCoinbaseAddress() (common.Address, error) | ||||
| 	NewEVM(msg core.Message, config *params.ChainConfig, params evmtypes.Params, coinbase common.Address, tracer string) *vm.EVM | ||||
| 	NewEVM(msg core.Message, config *params.ChainConfig, params evmtypes.Params, coinbase common.Address, tracer vm.Tracer) *vm.EVM | ||||
| 	GetCodeHash(addr common.Address) common.Hash | ||||
| } | ||||
| 
 | ||||
| @ -389,8 +389,8 @@ func (ctd CanTransferDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate | ||||
| 			) | ||||
| 		} | ||||
| 
 | ||||
| 		// NOTE: pass in an empty coinbase address and tracer as we don't need them for the check below
 | ||||
| 		evm := ctd.evmKeeper.NewEVM(coreMsg, ethCfg, params, common.Address{}, "") | ||||
| 		// NOTE: pass in an empty coinbase address and nil tracer as we don't need them for the check below
 | ||||
| 		evm := ctd.evmKeeper.NewEVM(coreMsg, ethCfg, params, common.Address{}, nil) | ||||
| 
 | ||||
| 		// check that caller has enough balance to cover asset transfer for **topmost** call
 | ||||
| 		// NOTE: here the gas consumed is from the context with the infinite gas meter
 | ||||
|  | ||||
| @ -378,7 +378,8 @@ func (k Keeper) EthCall(c context.Context, req *types.EthCallRequest) (*types.Ms | ||||
| 		return nil, status.Error(codes.Internal, err.Error()) | ||||
| 	} | ||||
| 
 | ||||
| 	evm := k.NewEVM(msg, ethCfg, params, coinbase, k.tracer) | ||||
| 	tracer := types.NewTracer(k.tracer, msg, ethCfg, k.Ctx().BlockHeight(), k.debug) | ||||
| 	evm := k.NewEVM(msg, ethCfg, params, coinbase, tracer) | ||||
| 
 | ||||
| 	// pass true means execute in query mode, which don't do actual gas refund.
 | ||||
| 	res, err := k.ApplyMessage(evm, msg, ethCfg, true) | ||||
| @ -449,7 +450,9 @@ func (k Keeper) EstimateGas(c context.Context, req *types.EthCallRequest) (*type | ||||
| 		k.WithContext(ctx) | ||||
| 
 | ||||
| 		msg := args.ToMessage(req.GasCap) | ||||
| 		evm := k.NewEVM(msg, ethCfg, params, coinbase, k.tracer) | ||||
| 
 | ||||
| 		tracer := types.NewTracer(k.tracer, msg, ethCfg, k.Ctx().BlockHeight(), k.debug) | ||||
| 		evm := k.NewEVM(msg, ethCfg, params, coinbase, tracer) | ||||
| 		// pass true means execute in query mode, which don't do actual gas refund.
 | ||||
| 		rsp, err := k.ApplyMessage(evm, msg, ethCfg, true) | ||||
| 
 | ||||
|  | ||||
| @ -32,7 +32,7 @@ func (k *Keeper) NewEVM( | ||||
| 	config *params.ChainConfig, | ||||
| 	params types.Params, | ||||
| 	coinbase common.Address, | ||||
| 	tracer string, | ||||
| 	tracer vm.Tracer, | ||||
| ) *vm.EVM { | ||||
| 	blockCtx := vm.BlockContext{ | ||||
| 		CanTransfer: core.CanTransfer, | ||||
| @ -53,12 +53,10 @@ func (k *Keeper) NewEVM( | ||||
| 
 | ||||
| // VMConfig creates an EVM configuration from the debug setting and the extra EIPs enabled on the
 | ||||
| // module parameters. The config generated uses the default JumpTable from the EVM.
 | ||||
| func (k Keeper) VMConfig(msg core.Message, params types.Params, tracer string) vm.Config { | ||||
| 	cfg := params.ChainConfig.EthereumConfig(k.eip155ChainID) | ||||
| 
 | ||||
| func (k Keeper) VMConfig(msg core.Message, params types.Params, tracer vm.Tracer) vm.Config { | ||||
| 	return vm.Config{ | ||||
| 		Debug:       k.debug, | ||||
| 		Tracer:      types.NewTracer(tracer, msg, cfg, k.Ctx().BlockHeight(), k.debug), | ||||
| 		Tracer:      tracer, | ||||
| 		NoRecursion: false, // TODO: consider disabling recursion though params
 | ||||
| 		ExtraEips:   params.EIPs(), | ||||
| 	} | ||||
| @ -161,7 +159,8 @@ func (k *Keeper) ApplyTransaction(tx *ethtypes.Transaction) (*types.MsgEthereumT | ||||
| 	} | ||||
| 
 | ||||
| 	// create an ethereum EVM instance and run the message
 | ||||
| 	evm := k.NewEVM(msg, ethCfg, params, coinbase, k.tracer) | ||||
| 	tracer := types.NewTracer(k.tracer, msg, ethCfg, k.Ctx().BlockHeight(), k.debug) | ||||
| 	evm := k.NewEVM(msg, ethCfg, params, coinbase, tracer) | ||||
| 
 | ||||
| 	txHash := tx.Hash() | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user