From f73d6984692fceeec00211663373c300a3e9ac3b Mon Sep 17 00:00:00 2001 From: vahoo5 Date: Mon, 22 May 2023 16:42:24 +0200 Subject: [PATCH] F --- core/state_processor.go | 7 ++++--- internal/ethapi/api.go | 12 ++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/core/state_processor.go b/core/state_processor.go index 68996fa946..f57c6ebec7 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -161,7 +161,7 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo return applyTransaction(msg, config, gp, statedb, header.Number, header.Hash(), tx, usedGas, vmenv) } -func applyTransactionWithResult(msg *Message, config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, msgTx *Message, usedGas *uint64, evm *vm.EVM) (*types.Receipt, *ExecutionResult, error) { +func applyTransactionWithResult(msg *Message, config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, msgTx *Message, usedGas *uint64, evm *vm.EVM, txHash common.Hash) (*types.Receipt, *ExecutionResult, error) { // Create a new context to be used in the EVM environment. txContext := NewEVMTxContext(msg) evm.Reset(txContext, statedb) @@ -197,14 +197,15 @@ func applyTransactionWithResult(msg *Message, config *params.ChainConfig, bc Cha receipt.BlockHash = header.Hash() receipt.BlockNumber = header.Number receipt.TransactionIndex = uint(statedb.TxIndex()) + receipt.Logs = statedb.GetLogs(txHash, header.Number.Uint64(), header.Hash()) return receipt, result, err } -func ApplyTransactionWithResult(config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, msg *Message, usedGas *uint64, cfg vm.Config) (*types.Receipt, *ExecutionResult, error) { +func ApplyTransactionWithResult(config *params.ChainConfig, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, msg *Message, usedGas *uint64, cfg vm.Config, txHash common.Hash) (*types.Receipt, *ExecutionResult, error) { // Create a new context to be used in the EVM environment blockContext := NewEVMBlockContext(header, bc, author) vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, config, cfg) - receipt, result, err := applyTransactionWithResult(msg, config, bc, author, gp, statedb, header, msg, usedGas, vmenv) + receipt, result, err := applyTransactionWithResult(msg, config, bc, author, gp, statedb, header, msg, usedGas, vmenv, txHash) return receipt, result, err } diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 3b42f748e0..3475588206 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1351,9 +1351,7 @@ func (s *BundleAPI) CallBundle(ctx context.Context, args CallBundleArgs) (map[st var totalGasUsed uint64 gasFees := new(big.Int) for i, tx := range args.Transactions { - fmt.Println("tx", tx) msg, err := tx.ToMessage(0, header.BaseFee) - fmt.Println("msg", msg) if err != nil { return nil, err } @@ -1361,7 +1359,7 @@ func (s *BundleAPI) CallBundle(ctx context.Context, args CallBundleArgs) (map[st randomHash := common.HexToHash("0x" + strconv.Itoa(i)) state.SetTxContext(randomHash, i) - receipt, result, err := core.ApplyTransactionWithResult(s.b.ChainConfig(), s.chain, &coinbase, gp, state, header, msg, &header.GasUsed, vmconfig) + receipt, result, err := core.ApplyTransactionWithResult(s.b.ChainConfig(), s.chain, &coinbase, gp, state, header, msg, &header.GasUsed, vmconfig, randomHash) if err != nil { return nil, fmt.Errorf("err: %w; txhash %s", err, randomHash) } @@ -1370,16 +1368,14 @@ func (s *BundleAPI) CallBundle(ctx context.Context, args CallBundleArgs) (map[st if err != nil { return nil, fmt.Errorf("err: %w; txhash %s", err, randomHash) } - to := "0x" logs := receipt.Logs if logs == nil { logs = []*types.Log{} } jsonResult := map[string]interface{}{ - "txHash": txHash, - "gasUsed": receipt.GasUsed, - "toAddress": to, - "logs": logs, + "txHash": txHash, + "gasUsed": receipt.GasUsed, + "logs": logs, } totalGasUsed += receipt.GasUsed if result.Err != nil {