From 0e6f3e44e001c583028ce8ba486cd3bbb1f5ed2e Mon Sep 17 00:00:00 2001 From: Lucca Martins Date: Mon, 3 Feb 2025 13:35:31 -0300 Subject: [PATCH] fix lint --- core/blockchain.go | 6 +-- core/state_processor.go | 1 - core/vm/evm.go | 4 +- core/vm/interpreter.go | 1 - eth/backend.go | 4 +- eth/tracers/api.go | 82 ----------------------------------- internal/cli/server/config.go | 2 +- 7 files changed, 8 insertions(+), 92 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 90443f7ac8..936a7b7e3c 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -78,8 +78,8 @@ var ( storageUpdateTimer = metrics.NewRegisteredResettingTimer("chain/storage/updates", nil) storageCommitTimer = metrics.NewRegisteredResettingTimer("chain/storage/commits", nil) - accountReadSingleTimer = metrics.NewRegisteredResettingTimer("chain/account/single/reads", nil) - storageReadSingleTimer = metrics.NewRegisteredResettingTimer("chain/storage/single/reads", nil) + accountReadSingleTimer = metrics.NewRegisteredResettingTimer("chain/account/single/reads", nil) //nolint:golint,unused + storageReadSingleTimer = metrics.NewRegisteredResettingTimer("chain/storage/single/reads", nil) //nolint:golint,unused snapshotCommitTimer = metrics.NewRegisteredResettingTimer("chain/snapshot/commits", nil) triedbCommitTimer = metrics.NewRegisteredResettingTimer("chain/triedb/commits", nil) @@ -92,7 +92,7 @@ var ( blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil) blockValidationTimer = metrics.NewRegisteredTimer("chain/validation", nil) - blockCrossValidationTimer = metrics.NewRegisteredResettingTimer("chain/crossvalidation", nil) + blockCrossValidationTimer = metrics.NewRegisteredResettingTimer("chain/crossvalidation", nil) //nolint:golint,unused blockExecutionTimer = metrics.NewRegisteredTimer("chain/execution", nil) blockWriteTimer = metrics.NewRegisteredTimer("chain/write", nil) blockExecutionParallelCounter = metrics.NewRegisteredCounter("chain/execution/parallel", nil) diff --git a/core/state_processor.go b/core/state_processor.go index aa3e54f5da..106b0e80b2 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -88,7 +88,6 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg } // Iterate over and process the individual transactions for i, tx := range block.Transactions() { - msg, err := TransactionToMessage(tx, signer, header.BaseFee) if err != nil { return nil, fmt.Errorf("could not apply tx %d [%v]: %w", i, tx.Hash().Hex(), err) diff --git a/core/vm/evm.go b/core/vm/evm.go index 35d814c389..ee9556ee23 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -556,7 +556,7 @@ func (evm *EVM) initNewContract(contract *Contract, address common.Address, valu } // Check whether the max code size has been exceeded, assign err if the case. - if err == nil && evm.chainRules.IsEIP158 { + if evm.chainRules.IsEIP158 { if evm.chainConfig.Bor != nil && evm.chainConfig.Bor.IsAhmedabad(evm.Context.BlockNumber) { if len(ret) > params.MaxCodeSizePostAhmedabad { err = ErrMaxCodeSizeExceeded @@ -583,7 +583,7 @@ func (evm *EVM) initNewContract(contract *Contract, address common.Address, valu } evm.StateDB.SetCode(address, ret) - return ret, nil + return ret, err } // Create creates a new contract using code as deployment code. diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 3a1ab04f6f..7365b85d65 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -310,7 +310,6 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( // the execution of one of the operations or until the done flag is set by the // parent context. for { - if debug { // Capture pre-execution values for tracing. logged, pcCopy, gasCopy = false, pc, contract.Gas diff --git a/eth/backend.go b/eth/backend.go index 604c140e9d..6cb8390b67 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -258,9 +258,9 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { // check if Parallel EVM is enabled // if enabled, use parallel state processor if config.ParallelEVM.Enable { - eth.blockchain, err = core.NewParallelBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit, checker, config.ParallelEVM.SpeculativeProcesses) + eth.blockchain, err = core.NewParallelBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TransactionHistory, checker, config.ParallelEVM.SpeculativeProcesses) } else { - eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TxLookupLimit, checker) + eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, &overrides, eth.engine, vmConfig, eth.shouldPreserve, &config.TransactionHistory, checker) } // POS-2798: NewOracle function definition was changed to accept (startPrice *big.Int) diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 269a63f998..2ffaf13761 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -1010,88 +1010,6 @@ txloop: } } -// traceBlockParallel is for tracers that have a high overhead (read JS tracers). One thread -// runs along and executes txes without tracing enabled to generate their prestate. -// Worker threads take the tasks and the prestate and trace them. -func (api *API) traceBlockParallel(ctx context.Context, block *types.Block, statedb *state.StateDB, config *TraceConfig) ([]*txTraceResult, error) { - // Execute all the transaction contained within the block concurrently - var ( - txs = block.Transactions() - blockHash = block.Hash() - signer = types.MakeSigner(api.backend.ChainConfig(), block.Number(), block.Time()) - results = make([]*txTraceResult, len(txs)) - pend sync.WaitGroup - ) - threads := runtime.NumCPU() - if threads > len(txs) { - threads = len(txs) - } - jobs := make(chan *txTraceTask, threads) - for th := 0; th < threads; th++ { - pend.Add(1) - go func() { - defer pend.Done() - // Fetch and execute the next transaction trace tasks - for task := range jobs { - msg, _ := core.TransactionToMessage(txs[task.index], signer, block.BaseFee()) - txctx := &Context{ - BlockHash: blockHash, - BlockNumber: block.Number(), - TxIndex: task.index, - TxHash: txs[task.index].Hash(), - } - // Reconstruct the block context for each transaction - // as the GetHash function of BlockContext is not safe for - // concurrent use. - // See: https://github.com/ethereum/go-ethereum/issues/29114 - blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) - res, err := api.traceTx(ctx, txs[task.index], msg, txctx, blockCtx, task.statedb, config) - if err != nil { - results[task.index] = &txTraceResult{TxHash: txs[task.index].Hash(), Error: err.Error()} - continue - } - results[task.index] = &txTraceResult{TxHash: txs[task.index].Hash(), Result: res} - } - }() - } - - // Feed the transactions into the tracers and return - var failed error - blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) -txloop: - for i, tx := range txs { - // Send the trace task over for execution - task := &txTraceTask{statedb: statedb.Copy(), index: i} - select { - case <-ctx.Done(): - failed = ctx.Err() - break txloop - case jobs <- task: - } - - // Generate the next state snapshot fast without tracing - msg, _ := core.TransactionToMessage(tx, signer, block.BaseFee()) - statedb.SetTxContext(tx.Hash(), i) - vmenv := vm.NewEVM(blockCtx, core.NewEVMTxContext(msg), statedb, api.backend.ChainConfig(), vm.Config{}) - if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit)); err != nil { - failed = err - break txloop - } - // Finalize the state so any modifications are written to the trie - // Only delete empty objects if EIP158/161 (a.k.a Spurious Dragon) is in effect - statedb.Finalise(vmenv.ChainConfig().IsEIP158(block.Number())) - } - - close(jobs) - pend.Wait() - - // If execution failed in between, abort - if failed != nil { - return nil, failed - } - return results, nil -} - // standardTraceBlockToFile configures a new tracer which uses standard JSON output, // and traces either a full block or an individual transaction. The return value will // be one filename per transaction traced. diff --git a/internal/cli/server/config.go b/internal/cli/server/config.go index 5960fdeab0..69f102a742 100644 --- a/internal/cli/server/config.go +++ b/internal/cli/server/config.go @@ -1118,7 +1118,7 @@ func (c *Config) buildEth(stack *node.Node, accountManager *accounts.Manager) (* n.TrieDirtyCache = calcPerc(c.Cache.PercGc) n.NoPrefetch = c.Cache.NoPrefetch n.Preimages = c.Cache.Preimages - n.TxLookupLimit = c.Cache.TxLookupLimit + n.TransactionHistory = c.Cache.TxLookupLimit n.TrieTimeout = c.Cache.TrieTimeout n.TriesInMemory = c.Cache.TriesInMemory n.FilterLogCacheSize = c.Cache.FilterLogCacheSize