Increase EVM timeout for eth-calls (#191)

* Increase EVM timeout for eth-calls

* Remove goose prerequisite from test targets in Makefile
This commit is contained in:
prathamesh0 2022-09-21 16:28:19 +05:30 committed by GitHub
parent fc0d7a6dd6
commit 4d99ecdee3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
.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

View File

@ -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{

View File

@ -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
)