From dadde8535c414daa611cdf05eaf7b7ea2435a14d Mon Sep 17 00:00:00 2001 From: prathamesh0 Date: Wed, 14 Sep 2022 14:04:49 +0530 Subject: [PATCH 1/2] Increase EVM timeout for eth-calls --- pkg/eth/api.go | 18 ++++++++++++++---- version/version.go | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pkg/eth/api.go b/pkg/eth/api.go index 1dfde7b2..5fc64393 100644 --- a/pkg/eth/api.go +++ b/pkg/eth/api.go @@ -45,6 +45,11 @@ import ( "github.com/cerc-io/ipld-eth-server/v4/pkg/shared" ) +const ( + defaultEVMTimeout = 30 * time.Second + defaultStateDiffTimeout = 240 * time.Second +) + // APIName is the namespace for the watcher's eth api const APIName = "eth" @@ -927,7 +932,7 @@ func (pea *PublicEthAPI) Call(ctx context.Context, args CallArgs, blockNrOrHash return hex, err } - result, err := DoCall(ctx, pea.B, args, blockNrOrHash, overrides, 5*time.Second, pea.B.Config.RPCGasCap.Uint64()) + result, err := DoCall(ctx, pea.B, args, blockNrOrHash, overrides, defaultEVMTimeout, pea.B.Config.RPCGasCap.Uint64()) // If the result contains a revert reason, try to unpack and return it. if err == nil { @@ -945,7 +950,12 @@ func (pea *PublicEthAPI) Call(ctx context.Context, args CallArgs, blockNrOrHash return hex, nil } } - return result.Return(), err + + if result != nil { + return result.Return(), err + } else { + return nil, err + } } func DoCall(ctx context.Context, b *Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *StateOverride, timeout time.Duration, globalGasCap uint64) (*core.ExecutionResult, error) { @@ -1054,7 +1064,7 @@ func (pea *PublicEthAPI) writeStateDiffAt(height int64) { return } // we use a separate context than the one provided by the client - ctx, cancel := context.WithTimeout(context.Background(), 240*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), defaultStateDiffTimeout) defer cancel() var data json.RawMessage params := statediff.Params{ @@ -1076,7 +1086,7 @@ func (pea *PublicEthAPI) writeStateDiffFor(blockHash common.Hash) { return } // we use a separate context than the one provided by the client - ctx, cancel := context.WithTimeout(context.Background(), 240*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), defaultStateDiffTimeout) defer cancel() var data json.RawMessage params := statediff.Params{ diff --git a/version/version.go b/version/version.go index d6541595..e5a88848 100644 --- a/version/version.go +++ b/version/version.go @@ -21,7 +21,7 @@ import "fmt" const ( Major = 4 // Major version component of the current release Minor = 1 // Minor version component of the current release - Patch = 5 // Patch version component of the current release + Patch = 9 // Patch version component of the current release Meta = "alpha" // Version metadata to append to the version string ) -- 2.45.2 From 202ab0c30382b522cf7e62faf1302b3191b6dfbc Mon Sep 17 00:00:00 2001 From: prathamesh0 Date: Wed, 21 Sep 2022 11:54:45 +0530 Subject: [PATCH 2/2] Remove goose prerequisite from test targets in Makefile --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 8d99d56a..83f82238 100644 --- a/Makefile +++ b/Makefile @@ -51,19 +51,19 @@ TEST_CONNECT_STRING = postgresql://$(DATABASE_USER):$(DATABASE_PASSWORD)@$(DATAB TEST_CONNECT_STRING_LOCAL = postgresql://$(USER)@$(HOST_NAME):$(PORT)/$(TEST_DB)?sslmode=disable .PHONY: test -test: | $(GOOSE) +test: go vet ./... go fmt ./... go run github.com/onsi/ginkgo/ginkgo -r --skipPackage=test .PHONY: integrationtest -integrationtest: | $(GOOSE) +integrationtest: go vet ./... go fmt ./... go run github.com/onsi/ginkgo/ginkgo -r test/ -v .PHONY: test_local -test_local: | $(GOOSE) +test_local: go vet ./... go fmt ./... ./scripts/run_unit_test.sh -- 2.45.2