From 77563d6974ecf38ac9fb5cefbd03f59ab02a87e2 Mon Sep 17 00:00:00 2001 From: MaxMustermann2 <82761650+MaxMustermann2@users.noreply.github.com> Date: Thu, 23 Feb 2023 09:29:06 +0000 Subject: [PATCH] store the evm call timeout in rosetta object --- rosetta/rosetta.go | 3 ++- rosetta/services/construction.go | 15 +++++++++------ rosetta/services/construction_check.go | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/rosetta/rosetta.go b/rosetta/rosetta.go index 5ff222a65..a05630057 100644 --- a/rosetta/rosetta.go +++ b/rosetta/rosetta.go @@ -85,7 +85,8 @@ func getRouter(asserter *asserter.Asserter, hmy *hmy.Harmony, limiterEnable bool server.NewNetworkAPIController(services.NewNetworkAPI(hmy), asserter), server.NewConstructionAPIController(services.NewConstructionAPI(hmy), asserter), server.NewCallAPIController( - services.NewCallAPIService(hmy, limiterEnable, rateLimit, hmy.NodeAPI.GetConfig().NodeConfig.RPCServer.EvmCallTimeout), + services.NewCallAPIService(hmy, limiterEnable, rateLimit, + hmy.NodeAPI.GetConfig().NodeConfig.RPCServer.EvmCallTimeout), asserter, ), server.NewEventsAPIController(services.NewEventAPI(hmy), asserter), diff --git a/rosetta/services/construction.go b/rosetta/services/construction.go index 3442d4c62..f2bd6e6c9 100644 --- a/rosetta/services/construction.go +++ b/rosetta/services/construction.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "math/big" + "time" "github.com/coinbase/rosetta-sdk-go/server" "github.com/coinbase/rosetta-sdk-go/types" @@ -24,17 +25,19 @@ const ( // ConstructAPI implements the server.ConstructAPIServicer interface. type ConstructAPI struct { - hmy *hmy.Harmony - signer hmyTypes.Signer - stakingSigner stakingTypes.Signer + hmy *hmy.Harmony + signer hmyTypes.Signer + stakingSigner stakingTypes.Signer + evmCallTimeout time.Duration } // NewConstructionAPI creates a new instance of a ConstructAPI. func NewConstructionAPI(hmy *hmy.Harmony) server.ConstructionAPIServicer { return &ConstructAPI{ - hmy: hmy, - signer: hmyTypes.NewEIP155Signer(new(big.Int).SetUint64(hmy.ChainID)), - stakingSigner: stakingTypes.NewEIP155Signer(new(big.Int).SetUint64(hmy.ChainID)), + hmy: hmy, + signer: hmyTypes.NewEIP155Signer(new(big.Int).SetUint64(hmy.ChainID)), + stakingSigner: stakingTypes.NewEIP155Signer(new(big.Int).SetUint64(hmy.ChainID)), + evmCallTimeout: hmy.NodeAPI.GetConfig().NodeConfig.RPCServer.EvmCallTimeout, } } diff --git a/rosetta/services/construction_check.go b/rosetta/services/construction_check.go index f60296971..c842770ab 100644 --- a/rosetta/services/construction_check.go +++ b/rosetta/services/construction_check.go @@ -270,7 +270,7 @@ func (s *ConstructAPI) ConstructionMetadata( callArgs.To = &contractAddress } evmExe, err := rpc.DoEVMCall( - ctx, s.hmy, callArgs, latest, s.hmy.NodeAPI.GetConfig().NodeConfig.RPCServer.EvmCallTimeout, + ctx, s.hmy, callArgs, latest, s.evmCallTimeout, ) if err != nil { return nil, common.NewError(common.CatchAllError, map[string]interface{}{