Increase EVM timeout for eth-calls #191

Merged
prathamesh0 merged 2 commits from pm-increase-evm-timeout into v4 2022-09-21 10:58:20 +00:00
3 changed files with 18 additions and 8 deletions

View File

@ -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 TEST_CONNECT_STRING_LOCAL = postgresql://$(USER)@$(HOST_NAME):$(PORT)/$(TEST_DB)?sslmode=disable
.PHONY: test .PHONY: test
test: | $(GOOSE) test:
go vet ./... go vet ./...
go fmt ./... go fmt ./...
go run github.com/onsi/ginkgo/ginkgo -r --skipPackage=test go run github.com/onsi/ginkgo/ginkgo -r --skipPackage=test
.PHONY: integrationtest .PHONY: integrationtest
integrationtest: | $(GOOSE) integrationtest:
go vet ./... go vet ./...
go fmt ./... go fmt ./...
go run github.com/onsi/ginkgo/ginkgo -r test/ -v go run github.com/onsi/ginkgo/ginkgo -r test/ -v
.PHONY: test_local .PHONY: test_local
test_local: | $(GOOSE) test_local:
go vet ./... go vet ./...
go fmt ./... go fmt ./...
./scripts/run_unit_test.sh ./scripts/run_unit_test.sh

View File

@ -45,6 +45,11 @@ import (
"github.com/cerc-io/ipld-eth-server/v4/pkg/shared" "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 // APIName is the namespace for the watcher's eth api
const APIName = "eth" const APIName = "eth"
@ -927,7 +932,7 @@ func (pea *PublicEthAPI) Call(ctx context.Context, args CallArgs, blockNrOrHash
return hex, err 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 the result contains a revert reason, try to unpack and return it.
if err == nil { if err == nil {
@ -945,7 +950,12 @@ func (pea *PublicEthAPI) Call(ctx context.Context, args CallArgs, blockNrOrHash
return hex, nil return hex, nil
} }
} }
if result != nil {
return result.Return(), err 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) { 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 return
} }
// we use a separate context than the one provided by the client // 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() defer cancel()
var data json.RawMessage var data json.RawMessage
params := statediff.Params{ params := statediff.Params{
@ -1076,7 +1086,7 @@ func (pea *PublicEthAPI) writeStateDiffFor(blockHash common.Hash) {
return return
} }
// we use a separate context than the one provided by the client // 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() defer cancel()
var data json.RawMessage var data json.RawMessage
params := statediff.Params{ params := statediff.Params{

View File

@ -21,7 +21,7 @@ import "fmt"
const ( const (
Major = 4 // Major version component of the current release Major = 4 // Major version component of the current release
Minor = 1 // Minor 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 Meta = "alpha" // Version metadata to append to the version string
) )