diff --git a/Makefile b/Makefile index 74b82829590d2fdf0be983d30c2239d59cb16775..a354e4075b722f264f77ea8b08b24ab3cab4faba 100644 --- a/Makefile +++ b/Makefile @@ -129,7 +129,7 @@ lintci: lintci-deps: rm -f ./build/bin/golangci-lint - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.41.1 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./build/bin v1.42.1 clean: env GO111MODULE=on go clean -cache diff --git a/cmd/rpcdaemon/cli/config.go b/cmd/rpcdaemon/cli/config.go index f39e68e269112ff93e9168711169edcd767232b2..814dd000f25cb021db3702644b5d1da4787dcd4e 100644 --- a/cmd/rpcdaemon/cli/config.go +++ b/cmd/rpcdaemon/cli/config.go @@ -69,7 +69,7 @@ var rootCmd = &cobra.Command{ func RootCommand() (*cobra.Command, *Flags) { utils.CobraFlags(rootCmd, append(debug.Flags, utils.MetricFlags...)) - cfg := &Flags{} + cfg := &Flags{StateCache: kvcache.DefaultCoherentConfig} rootCmd.PersistentFlags().StringVar(&cfg.PrivateApiAddr, "private.api.addr", "127.0.0.1:9090", "private api network address, for example: 127.0.0.1:9090") rootCmd.PersistentFlags().StringVar(&cfg.Datadir, "datadir", "", "path to Erigon working directory") rootCmd.PersistentFlags().StringVar(&cfg.Chaindata, "chaindata", "", "path to the database") diff --git a/cmd/rpcdaemon/commands/eth_api.go b/cmd/rpcdaemon/commands/eth_api.go index 78c03e055872cdf8c65212db7a5958f3611055be..07ecbb824650217f775847eb3d604b46e5a0e872 100644 --- a/cmd/rpcdaemon/commands/eth_api.go +++ b/cmd/rpcdaemon/commands/eth_api.go @@ -8,16 +8,15 @@ import ( lru "github.com/hashicorp/golang-lru" "github.com/holiman/uint256" + "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/kvcache" - "github.com/ledgerwatch/erigon/consensus/misc" - - "github.com/ledgerwatch/erigon-lib/gointerfaces/txpool" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/filters" "github.com/ledgerwatch/erigon/cmd/rpcdaemon/services" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/common/hexutil" "github.com/ledgerwatch/erigon/common/math" + "github.com/ledgerwatch/erigon/consensus/misc" "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/types" ethFilters "github.com/ledgerwatch/erigon/eth/filters" @@ -110,10 +109,15 @@ type BaseAPI struct { } func NewBaseApi(f *filters.Filters, stateCache kvcache.Cache, singleNodeMode bool) *BaseAPI { - var blocksLRU *lru.Cache + blocksLRUSize := 128 // ~32Mb if !singleNodeMode { - blocksLRU, _ = lru.New(256) + blocksLRUSize = 512 + } + blocksLRU, err := lru.New(blocksLRUSize) + if err != nil { + panic(err) } + return &BaseAPI{filters: f, stateCache: stateCache, blocksLRU: blocksLRU} } diff --git a/cmd/rpcdaemon/commands/eth_call.go b/cmd/rpcdaemon/commands/eth_call.go index 57052c7e19b664c7e903b2c648d003f7732e0da5..28dba7ed53ba7ce5e3da741c55c68444f5b97260 100644 --- a/cmd/rpcdaemon/commands/eth_call.go +++ b/cmd/rpcdaemon/commands/eth_call.go @@ -18,6 +18,7 @@ import ( "github.com/ledgerwatch/erigon/internal/ethapi" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rpc" + "github.com/ledgerwatch/erigon/turbo/rpchelper" "github.com/ledgerwatch/erigon/turbo/transactions" "github.com/ledgerwatch/log/v3" ) @@ -43,7 +44,20 @@ func (api *APIImpl) Call(ctx context.Context, args ethapi.CallArgs, blockNrOrHas if api.TevmEnabled { contractHasTEVM = ethdb.GetHasTEVM(tx) } - result, err := transactions.DoCall(ctx, args, tx, blockNrOrHash, overrides, api.GasCap, chainConfig, api.filters, api.stateCache, contractHasTEVM) + + blockNumber, hash, err := rpchelper.GetCanonicalBlockNumber(blockNrOrHash, tx, api.filters) // DoCall cannot be executed on non-canonical blocks + if err != nil { + return nil, err + } + block, err := api.BaseAPI.blockWithSenders(tx, hash, blockNumber) + if err != nil { + return nil, err + } + if block == nil { + return nil, nil + } + + result, err := transactions.DoCall(ctx, args, tx, blockNrOrHash, block, overrides, api.GasCap, chainConfig, api.stateCache, contractHasTEVM) if err != nil { return nil, err } @@ -181,8 +195,21 @@ func (api *APIImpl) EstimateGas(ctx context.Context, args ethapi.CallArgs, block executable := func(gas uint64) (bool, *core.ExecutionResult, error) { args.Gas = (*hexutil.Uint64)(&gas) - result, err := transactions.DoCall(ctx, args, dbtx, rpc.BlockNumberOrHash{BlockNumber: &lastBlockNum}, nil, - api.GasCap, chainConfig, api.filters, api.stateCache, contractHasTEVM) + numOrHash := rpc.BlockNumberOrHash{BlockNumber: &lastBlockNum} + blockNumber, hash, err := rpchelper.GetCanonicalBlockNumber(numOrHash, dbtx, api.filters) // DoCall cannot be executed on non-canonical blocks + if err != nil { + return false, nil, err + } + block, err := api.BaseAPI.blockWithSenders(dbtx, hash, blockNumber) + if err != nil { + return false, nil, err + } + if block == nil { + return false, nil, nil + } + + result, err := transactions.DoCall(ctx, args, dbtx, numOrHash, block, nil, + api.GasCap, chainConfig, api.stateCache, contractHasTEVM) if err != nil { if errors.Is(err, core.ErrIntrinsicGas) { // Special case, raise gas limit diff --git a/cmd/rpctest/main.go b/cmd/rpctest/main.go index f00d5351dcc36cbb5dc2654ba45db204fe889327..cb8a7d099c5c2c6a2276057684d8b33360007fcf 100644 --- a/cmd/rpctest/main.go +++ b/cmd/rpctest/main.go @@ -22,6 +22,7 @@ func main() { erigonURL string blockFrom uint64 blockTo uint64 + latest bool recordFile string errorFile string ) @@ -35,6 +36,9 @@ func main() { cmd.Flags().Uint64Var(&blockFrom, "blockFrom", 2000000, "Block number to start test generation from") cmd.Flags().Uint64Var(&blockTo, "blockTo", 2101000, "Block number to end test generation at") } + withLatest := func(cmd *cobra.Command) { + cmd.Flags().BoolVar(&latest, "latest", false, "Exec on latest ") + } withNeedCompare := func(cmd *cobra.Command) { cmd.Flags().BoolVar(&needCompare, "needCompare", false, "need compare with geth") } @@ -55,10 +59,10 @@ func main() { Short: "", Long: ``, Run: func(cmd *cobra.Command, args []string) { - rpctest.BenchEthCall(erigonURL, gethURL, needCompare, blockFrom, blockTo, recordFile, errorFile) + rpctest.BenchEthCall(erigonURL, gethURL, needCompare, latest, blockFrom, blockTo, recordFile, errorFile) }, } - with(benchEthCallCmd, withErigonUrl, withGethUrl, withNeedCompare, withBlockNum, withRecord, withErrorFile) + with(benchEthCallCmd, withErigonUrl, withGethUrl, withNeedCompare, withBlockNum, withRecord, withErrorFile, withLatest) var bench1Cmd = &cobra.Command{ Use: "bench1", diff --git a/cmd/rpctest/rpctest/bench_ethcall.go b/cmd/rpctest/rpctest/bench_ethcall.go index 39a8b30acb377cb22af6523575b9fd754b2acb6d..3358f98c5919c0387d13279140ffd725d690e498 100644 --- a/cmd/rpctest/rpctest/bench_ethcall.go +++ b/cmd/rpctest/rpctest/bench_ethcall.go @@ -15,7 +15,7 @@ import ( // false value - to generate vegeta files, it's faster but we can generate vegeta files for Geth and Erigon // recordFile stores all eth_call returned with success // errorFile stores information when erigon and geth doesn't return same data -func BenchEthCall(erigonURL, gethURL string, needCompare bool, blockFrom uint64, blockTo uint64, recordFile string, errorFile string) { +func BenchEthCall(erigonURL, gethURL string, needCompare, latest bool, blockFrom, blockTo uint64, recordFile string, errorFile string) { setRoutes(erigonURL, gethURL) var client = &http.Client{ Timeout: time.Second * 600, @@ -103,7 +103,12 @@ func BenchEthCall(erigonURL, gethURL string, needCompare bool, blockFrom uint64, reqGen.reqID++ nTransactions = nTransactions + 1 - request := reqGen.ethCall(tx.From, tx.To, &tx.Gas, &tx.GasPrice, &tx.Value, tx.Input, bn-1) + var request string + if latest { + request = reqGen.ethCallLatest(tx.From, tx.To, &tx.Gas, &tx.GasPrice, &tx.Value, tx.Input) + } else { + request = reqGen.ethCall(tx.From, tx.To, &tx.Gas, &tx.GasPrice, &tx.Value, tx.Input, bn-1) + } errCtx := fmt.Sprintf(" bn=%d hash=%s", bn, tx.Hash) if err := requestAndCompare(request, "eth_call", errCtx, reqGen, needCompare, rec, errs, resultsCh); err != nil { diff --git a/cmd/rpctest/rpctest/request_generator.go b/cmd/rpctest/rpctest/request_generator.go index ece3bc463193056ab279c7253627fc407d6132ac..4dcbe3c4da15364039df181b5ee5285a0c24ff30 100644 --- a/cmd/rpctest/rpctest/request_generator.go +++ b/cmd/rpctest/rpctest/request_generator.go @@ -241,6 +241,28 @@ func (g *RequestGenerator) ethCall(from common.Address, to *common.Address, gas return sb.String() } +func (g *RequestGenerator) ethCallLatest(from common.Address, to *common.Address, gas *hexutil.Big, gasPrice *hexutil.Big, value *hexutil.Big, data hexutil.Bytes) string { + var sb strings.Builder + fmt.Fprintf(&sb, `{ "jsonrpc": "2.0", "method": "eth_call", "params": [{"from":"0x%x"`, from) + if to != nil { + fmt.Fprintf(&sb, `,"to":"0x%x"`, *to) + } + if gas != nil { + fmt.Fprintf(&sb, `,"gas":"%s"`, gas) + } + if gasPrice != nil { + fmt.Fprintf(&sb, `,"gasPrice":"%s"`, gasPrice) + } + if len(data) > 0 { + fmt.Fprintf(&sb, `,"data":"%s"`, data) + } + if value != nil { + fmt.Fprintf(&sb, `,"value":"%s"`, value) + } + fmt.Fprintf(&sb, `},"latest"], "id":%d}`, g.reqID) + return sb.String() +} + func (g *RequestGenerator) call(target string, method, body string, response interface{}) CallResult { start := time.Now() err := post(g.client, routes[target], body, response) diff --git a/core/state/cached_reader2.go b/core/state/cached_reader2.go index 1f841330c1964ffcdb1923912112f21d9b3a1d64..bb438a618cdafd7bead7e9fb0d3cc39e0a59f7d3 100644 --- a/core/state/cached_reader2.go +++ b/core/state/cached_reader2.go @@ -25,7 +25,7 @@ func NewCachedReader2(cache kvcache.CacheView, tx kv.Tx) *CachedReader2 { // ReadAccountData is called when an account needs to be fetched from the state func (r *CachedReader2) ReadAccountData(address common.Address) (*accounts.Account, error) { - enc, err := r.cache.Get(address.Bytes()) + enc, err := r.cache.Get(address[:]) if err != nil { return nil, err } @@ -55,7 +55,7 @@ func (r *CachedReader2) ReadAccountCode(address common.Address, incarnation uint if bytes.Equal(codeHash.Bytes(), emptyCodeHash) { return nil, nil } - code, err := r.db.GetOne(kv.Code, codeHash.Bytes()) + code, err := r.cache.GetCode(codeHash.Bytes()) if len(code) == 0 { return nil, nil } diff --git a/crypto/blake2b/blake2bAVX2_amd64.go b/crypto/blake2b/blake2bAVX2_amd64.go index 0d52b186990b0065bda71ebfab79f2b96c665776..3a85d0e73a6bac61d03b11f2ddfc275d5c0e11c7 100644 --- a/crypto/blake2b/blake2bAVX2_amd64.go +++ b/crypto/blake2b/blake2bAVX2_amd64.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build go1.7 && amd64 && !gccgo && !appengine // +build go1.7,amd64,!gccgo,!appengine package blake2b diff --git a/crypto/blake2b/register.go b/crypto/blake2b/register.go index efd689af4b49cd22a4b42bf865998d3888670613..9d8633963cb6e16a26236c24535ee6c61f7b8aec 100644 --- a/crypto/blake2b/register.go +++ b/crypto/blake2b/register.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build go1.9 // +build go1.9 package blake2b diff --git a/crypto/bn256/bn256_fast.go b/crypto/bn256/bn256_fast.go index 9e4935d370f5bc19d60637be0926448c5526a2ff..e8b9a4adf372b390f53dcf968707c4ea48f16f40 100644 --- a/crypto/bn256/bn256_fast.go +++ b/crypto/bn256/bn256_fast.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file. +//go:build amd64 || arm64 // +build amd64 arm64 // Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve. diff --git a/crypto/bn256/cloudflare/gfp_decl.go b/crypto/bn256/cloudflare/gfp_decl.go index be1b80906325234ad9cb28f1b318a682c0ccbd7d..652089de21bf8571afd059f66b4335f138ace824 100644 --- a/crypto/bn256/cloudflare/gfp_decl.go +++ b/crypto/bn256/cloudflare/gfp_decl.go @@ -1,3 +1,4 @@ +//go:build (amd64 && !generic) || (arm64 && !generic) // +build amd64,!generic arm64,!generic package bn256 diff --git a/crypto/signature_cgo.go b/crypto/signature_cgo.go index d7d895e49834be0dd536e6b72354004e73ac272d..3b7d0fd33f4cd74f352e5491ab0859a9d183985b 100644 --- a/crypto/signature_cgo.go +++ b/crypto/signature_cgo.go @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. +//go:build !nacl && !js && cgo && !gofuzz // +build !nacl,!js,cgo,!gofuzz package crypto diff --git a/eth/backend.go b/eth/backend.go index bde8a588b7b310d92dfd168ffafb13642f7b78bd..40475ad0e3006e6403bebeade8211b15207e3588 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -499,17 +499,19 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere } if backend.config.TxPool.V2 { - if err := backend.txPool2DB.View(context.Background(), func(tx kv.Tx) error { - pendingBaseFee := misc.CalcBaseFee(chainConfig, hh) - return backend.txPool2.OnNewBlock(context.Background(), &remote.StateChangeBatch{ - PendingBlockBaseFee: pendingBaseFee.Uint64(), - DatabaseViewID: tx.ViewID(), - ChangeBatch: []*remote.StateChange{ - {BlockHeight: hh.Number.Uint64(), BlockHash: gointerfaces.ConvertHashToH256(hh.Hash())}, - }, - }, txpool2.TxSlots{}, txpool2.TxSlots{}, tx) - }); err != nil { - return nil, err + if hh != nil { + if err := backend.txPool2DB.View(context.Background(), func(tx kv.Tx) error { + pendingBaseFee := misc.CalcBaseFee(chainConfig, hh) + return backend.txPool2.OnNewBlock(context.Background(), &remote.StateChangeBatch{ + PendingBlockBaseFee: pendingBaseFee.Uint64(), + DatabaseViewID: tx.ViewID(), + ChangeBatch: []*remote.StateChange{ + {BlockHeight: hh.Number.Uint64(), BlockHash: gointerfaces.ConvertHashToH256(hh.Hash())}, + }, + }, txpool2.TxSlots{}, txpool2.TxSlots{}, tx) + }); err != nil { + return nil, err + } } } else { if hh != nil { diff --git a/ethdb/olddb/database_test.go b/ethdb/olddb/database_test.go index 3294936571adbae9b291e17665e72b2ce6a539ed..de4987018cf9b2a2210dd401b097192aa9b9e621 100644 --- a/ethdb/olddb/database_test.go +++ b/ethdb/olddb/database_test.go @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. +//go:build !js // +build !js package olddb diff --git a/go.mod b/go.mod index 9d52f8b4a2dc306bcb03203066bf93fbee8d45fc..e7d4be84d961efe0db6f20f60d55bc4422f21dcd 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/julienschmidt/httprouter v1.3.0 github.com/kevinburke/go-bindata v3.21.0+incompatible - github.com/ledgerwatch/erigon-lib v0.0.0-20211011173149-083ee839067f + github.com/ledgerwatch/erigon-lib v0.0.0-20211012041733-a745f2391c49 github.com/ledgerwatch/log/v3 v3.3.1 github.com/ledgerwatch/secp256k1 v0.0.0-20210626115225-cd5cd00ed72d github.com/logrusorgru/aurora/v3 v3.0.0 diff --git a/go.sum b/go.sum index 2b25dce6aabaad11edb916238edf2f8b7431f03b..e51ccb946e910c0d31a15a0be7a11177774f1c1b 100644 --- a/go.sum +++ b/go.sum @@ -497,8 +497,8 @@ github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3P github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= -github.com/ledgerwatch/erigon-lib v0.0.0-20211011173149-083ee839067f h1:gxkNMQ0Bx4+VzT83xMvKshvvSrD2tkz4pzLM/RBSyoQ= -github.com/ledgerwatch/erigon-lib v0.0.0-20211011173149-083ee839067f/go.mod h1:kM8TzB/YifxKol66U0bNLsmdopypP+ag6REvUGU62s4= +github.com/ledgerwatch/erigon-lib v0.0.0-20211012041733-a745f2391c49 h1:cpbGDRm6kkCvcZ9WjejziSTqgxRqYGvZcpIG5AmJxe8= +github.com/ledgerwatch/erigon-lib v0.0.0-20211012041733-a745f2391c49/go.mod h1:kM8TzB/YifxKol66U0bNLsmdopypP+ag6REvUGU62s4= github.com/ledgerwatch/log/v3 v3.3.1 h1:HmvLeTEvtCtqSvtu4t/a5MAdcLfeBcbIeowXbLYuzLc= github.com/ledgerwatch/log/v3 v3.3.1/go.mod h1:S3VJqhhVX32rbp1JyyvhJou12twtFwNEPESBgpbNkRk= github.com/ledgerwatch/secp256k1 v0.0.0-20210626115225-cd5cd00ed72d h1:/IKMrJdfRsoYNc36PXqP4xMH3vhW/8IQyBKGQbKZUno= diff --git a/internal/debug/loudpanic.go b/internal/debug/loudpanic.go index 572ebcefa14f5d366fe8242aca8a4e40f4efa8ad..86e6bc88f83f2df82e60975aa967c29674614121 100644 --- a/internal/debug/loudpanic.go +++ b/internal/debug/loudpanic.go @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. +//go:build go1.6 // +build go1.6 package debug diff --git a/internal/debug/signal.go b/internal/debug/signal.go index 0f5f1e3849b2b07dfc166e8eac782a5c7e32b541..a8380d59e4ac2f031ffac7ce0802f14a2cd5417a 100644 --- a/internal/debug/signal.go +++ b/internal/debug/signal.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package debug diff --git a/internal/debug/trace.go b/internal/debug/trace.go index 35d791ec2576d0eb5cd6942a42d551eeed9d7fd9..367b5727e35fabc11fb8f752b586084763543867 100644 --- a/internal/debug/trace.go +++ b/internal/debug/trace.go @@ -14,7 +14,8 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. -//+build go1.5 +//go:build go1.5 +// +build go1.5 package debug diff --git a/metrics/cpu_enabled.go b/metrics/cpu_enabled.go index f4e01cc67ccabda1ff9c1a1bc67a0554bea58301..4996d0f7b7071cccf821306161120fa63cf68188 100644 --- a/metrics/cpu_enabled.go +++ b/metrics/cpu_enabled.go @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. +//go:build !ios // +build !ios package metrics diff --git a/metrics/cpu_syscall.go b/metrics/cpu_syscall.go index 4ec9c8967151a745606ffc17f02ec17be04db890..ca74ff5fddf026a7ef78b84521b8b044c39371d4 100644 --- a/metrics/cpu_syscall.go +++ b/metrics/cpu_syscall.go @@ -14,6 +14,7 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. +//go:build !windows // +build !windows package metrics diff --git a/metrics/runtime_cgo.go b/metrics/runtime_cgo.go index e3391f4e89fa1c457ed83e3789bf559214ccbec8..7d0af4f7e4cd9321564abd46a163e73c6b77a14c 100644 --- a/metrics/runtime_cgo.go +++ b/metrics/runtime_cgo.go @@ -1,5 +1,5 @@ -// +build cgo -// +build !appengine +//go:build cgo && !appengine +// +build cgo,!appengine package metrics diff --git a/metrics/syslog.go b/metrics/syslog.go index a0ed4b1b2364910231e42a4b5141fef68de2919f..551a2bd0f072c930b7d6cdc328288abf772a9891 100644 --- a/metrics/syslog.go +++ b/metrics/syslog.go @@ -1,3 +1,4 @@ +//go:build !windows // +build !windows package metrics diff --git a/p2p/netutil/toobig_notwindows.go b/p2p/netutil/toobig_notwindows.go index 47b64385723ce8c821e106390edab2bbba0e9b83..f9f936ae568cb5d4a22781c5081d2bf68eb7bb90 100644 --- a/p2p/netutil/toobig_notwindows.go +++ b/p2p/netutil/toobig_notwindows.go @@ -14,7 +14,8 @@ // You should have received a copy of the GNU Lesser General Public License // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. -//+build !windows +//go:build !windows +// +build !windows package netutil diff --git a/turbo/transactions/call.go b/turbo/transactions/call.go index ea18b1f2b5c8e10afe9edc8e081b07880b020938..41364db832d75095667d4219be5ce29f499260ce 100644 --- a/turbo/transactions/call.go +++ b/turbo/transactions/call.go @@ -9,7 +9,6 @@ import ( "github.com/holiman/uint256" "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/kvcache" - "github.com/ledgerwatch/erigon/cmd/rpcdaemon/filters" "github.com/ledgerwatch/erigon/common" "github.com/ledgerwatch/erigon/core" "github.com/ledgerwatch/erigon/core/rawdb" @@ -19,15 +18,12 @@ import ( "github.com/ledgerwatch/erigon/internal/ethapi" "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rpc" - "github.com/ledgerwatch/erigon/turbo/rpchelper" "github.com/ledgerwatch/log/v3" ) const callTimeout = 5 * time.Minute -func DoCall(ctx context.Context, args ethapi.CallArgs, tx kv.Tx, blockNrOrHash rpc.BlockNumberOrHash, - overrides *map[common.Address]ethapi.Account, gasCap uint64, chainConfig *params.ChainConfig, - filters *filters.Filters, stateCache kvcache.Cache, contractHasTEVM func(hash common.Hash) (bool, error)) (*core.ExecutionResult, error) { +func DoCall(ctx context.Context, args ethapi.CallArgs, tx kv.Tx, blockNrOrHash rpc.BlockNumberOrHash, block *types.Block, overrides *map[common.Address]ethapi.Account, gasCap uint64, chainConfig *params.ChainConfig, stateCache kvcache.Cache, contractHasTEVM func(hash common.Hash) (bool, error)) (*core.ExecutionResult, error) { // todo: Pending state is only known by the miner /* if blockNrOrHash.BlockNumber != nil && *blockNrOrHash.BlockNumber == rpc.PendingBlockNumber { @@ -35,10 +31,7 @@ func DoCall(ctx context.Context, args ethapi.CallArgs, tx kv.Tx, blockNrOrHash r return state, block.Header(), nil } */ - blockNumber, hash, err := rpchelper.GetCanonicalBlockNumber(blockNrOrHash, tx, filters) // DoCall cannot be executed on non-canonical blocks - if err != nil { - return nil, err - } + blockNumber := block.NumberU64() var stateReader state.StateReader if num, ok := blockNrOrHash.Number(); ok && num == rpc.LatestBlockNumber { cacheView, err := stateCache.View(ctx, tx) @@ -51,10 +44,7 @@ func DoCall(ctx context.Context, args ethapi.CallArgs, tx kv.Tx, blockNrOrHash r } state := state.New(stateReader) - header := rawdb.ReadHeader(tx, hash, blockNumber) - if header == nil { - return nil, fmt.Errorf("block %d(%x) not found", blockNumber, hash) - } + header := block.Header() // Override the fields of specified contracts before execution. if overrides != nil {