Fix lint errors

This commit is contained in:
Sina Mahmoodi 2024-08-19 18:01:31 +02:00
parent 5d8c058fd4
commit edf9e376ed
3 changed files with 6 additions and 8 deletions

View file

@ -1268,7 +1268,7 @@ func (api *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockN
// //
// Note, this function doesn't make any changes in the state/blockchain and is // Note, this function doesn't make any changes in the state/blockchain and is
// useful to execute and retrieve values. // useful to execute and retrieve values.
func (s *BlockChainAPI) SimulateV1(ctx context.Context, opts simOpts, blockNrOrHash *rpc.BlockNumberOrHash) ([]map[string]interface{}, error) { func (api *BlockChainAPI) SimulateV1(ctx context.Context, opts simOpts, blockNrOrHash *rpc.BlockNumberOrHash) ([]map[string]interface{}, error) {
if len(opts.BlockStateCalls) == 0 { if len(opts.BlockStateCalls) == 0 {
return nil, &invalidParamsError{message: "empty input"} return nil, &invalidParamsError{message: "empty input"}
} else if len(opts.BlockStateCalls) > maxSimulateBlocks { } else if len(opts.BlockStateCalls) > maxSimulateBlocks {
@ -1278,17 +1278,17 @@ func (s *BlockChainAPI) SimulateV1(ctx context.Context, opts simOpts, blockNrOrH
n := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber) n := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber)
blockNrOrHash = &n blockNrOrHash = &n
} }
state, base, err := s.b.StateAndHeaderByNumberOrHash(ctx, *blockNrOrHash) state, base, err := api.b.StateAndHeaderByNumberOrHash(ctx, *blockNrOrHash)
if state == nil || err != nil { if state == nil || err != nil {
return nil, err return nil, err
} }
sim := &simulator{ sim := &simulator{
b: s.b, b: api.b,
state: state, state: state,
base: base, base: base,
chainConfig: s.b.ChainConfig(), chainConfig: api.b.ChainConfig(),
// Each tx and all the series of txes shouldn't consume more gas than cap // Each tx and all the series of txes shouldn't consume more gas than cap
gp: new(core.GasPool).AddGas(s.b.RPCGasCap()), gp: new(core.GasPool).AddGas(api.b.RPCGasCap()),
traceTransfers: opts.TraceTransfers, traceTransfers: opts.TraceTransfers,
validate: opts.Validation, validate: opts.Validation,
fullTx: opts.ReturnFullTransactions, fullTx: opts.ReturnFullTransactions,

View file

@ -3324,7 +3324,7 @@ func TestStateOverrideMovePrecompile(t *testing.T) {
if len(cpy) != len(tt.expectedPrecompiles) { if len(cpy) != len(tt.expectedPrecompiles) {
t.Errorf("test %d: precompile mismatch, want %d, have %d", i, len(tt.expectedPrecompiles), len(cpy)) t.Errorf("test %d: precompile mismatch, want %d, have %d", i, len(tt.expectedPrecompiles), len(cpy))
} }
for k, _ := range tt.expectedPrecompiles { for k := range tt.expectedPrecompiles {
if _, ok := cpy[k]; !ok { if _, ok := cpy[k]; !ok {
t.Errorf("test %d: precompile not found: %s", i, k.String()) t.Errorf("test %d: precompile not found: %s", i, k.String())
} }

View file

@ -245,7 +245,6 @@ func (sim *simulator) processBlock(ctx context.Context, block *simBlock, header,
b := types.NewBlock(header, &types.Body{Transactions: txes, Withdrawals: withdrawals}, receipts, trie.NewStackTrie(nil)) b := types.NewBlock(header, &types.Body{Transactions: txes, Withdrawals: withdrawals}, receipts, trie.NewStackTrie(nil))
repairLogs(callResults, b.Hash()) repairLogs(callResults, b.Hash())
return b, callResults, nil return b, callResults, nil
} }
// repairLogs updates the block hash in the logs present in the result of // repairLogs updates the block hash in the logs present in the result of
@ -272,7 +271,6 @@ func (sim *simulator) sanitizeCall(call *TransactionArgs, state *state.StateDB,
if *gasUsed+uint64(*call.Gas) > blockContext.GasLimit { if *gasUsed+uint64(*call.Gas) > blockContext.GasLimit {
return &blockGasLimitReachedError{fmt.Sprintf("block gas limit reached: %d >= %d", gasUsed, blockContext.GasLimit)} return &blockGasLimitReachedError{fmt.Sprintf("block gas limit reached: %d >= %d", gasUsed, blockContext.GasLimit)}
} }
if err := call.CallDefaults(sim.gp.Gas(), header.BaseFee, sim.chainConfig.ChainID); err != nil { if err := call.CallDefaults(sim.gp.Gas(), header.BaseFee, sim.chainConfig.ChainID); err != nil {
return err return err
} }