From 80c8f17e44332736983f2e0e3647cbe05547ae53 Mon Sep 17 00:00:00 2001 From: Tudor Malene Date: Tue, 26 Mar 2024 12:42:24 +0000 Subject: [PATCH] cleanup --- integration/obscurogateway/tengateway_test.go | 5 +---- lib/gethfork/rpc/handler.go | 3 +-- lib/gethfork/rpc/server.go | 2 -- lib/gethfork/rpc/service.go | 2 +- testnet/launcher/eth2network/docker.go | 2 +- tools/walletextension/container_run.sh | 2 +- .../frontend/src/components/providers/wallet-provider.tsx | 6 +++--- tools/walletextension/main/cli.go | 2 +- tools/walletextension/main/main.go | 2 +- tools/walletextension/rpcapi/utils.go | 1 - 10 files changed, 10 insertions(+), 17 deletions(-) diff --git a/integration/obscurogateway/tengateway_test.go b/integration/obscurogateway/tengateway_test.go index 31f474a689..42f612d6bf 100644 --- a/integration/obscurogateway/tengateway_test.go +++ b/integration/obscurogateway/tengateway_test.go @@ -131,9 +131,6 @@ func testMultipleAccountsSubscription(t *testing.T, httpURL, wsURL string, w wal _, err = user0.HTTPClient.ChainID(context.Background()) require.NoError(t, err) - //_, err = user0.WSClient.BalanceAt(context.TODO(), user0.Wallets[0].Address(), nil) - //require.NoError(t, err) - user1, err := NewGatewayUser([]wallet.Wallet{datagenerator.RandomWallet(integration.TenChainID), datagenerator.RandomWallet(integration.TenChainID)}, httpURL, wsURL) require.NoError(t, err) testlog.Logger().Info("Created user with encryption token", "t", user1.tgClient.UserID()) @@ -875,7 +872,7 @@ func subscribeToEvents(addresses []gethcommon.Address, topics [][]gethcommon.Has // Make a subscription filterQuery := ethereum.FilterQuery{ Addresses: addresses, - FromBlock: big.NewInt(2), // todo (@ziga) - without those we get errors - fix that and make them configurable + FromBlock: big.NewInt(2), // ToBlock: big.NewInt(10000), Topics: topics, } diff --git a/lib/gethfork/rpc/handler.go b/lib/gethfork/rpc/handler.go index 7755b776eb..8836f3c6b5 100644 --- a/lib/gethfork/rpc/handler.go +++ b/lib/gethfork/rpc/handler.go @@ -19,7 +19,6 @@ package rpc import ( "context" "encoding/json" - "fmt" "reflect" "strconv" "strings" @@ -389,6 +388,7 @@ func (h *handler) startCallProc(fn func(*callProc)) { ctx, cancel := context.WithCancel(h.rootCtx) defer h.callWG.Done() defer cancel() + // handle the case when normal rpc calls are made over a ws connection if ctx.Value(GWTokenKey{}) == nil { ctx = context.WithValue(ctx, GWTokenKey{}, hexutils.BytesToHex(h.UserID)) } @@ -555,7 +555,6 @@ func (h *handler) handleSubscribe(cp *callProc, msg *jsonrpcMessage) *jsonrpcMes // Parse subscription name arg too, but remove it before calling the callback. argTypes := append([]reflect.Type{stringType}, callb.argTypes...) args, err := parsePositionalArguments(msg.Params, argTypes) - fmt.Printf("Subscribe %s\n", string(msg.Params)) if err != nil { return msg.errorResponse(&invalidParamsError{err.Error()}) } diff --git a/lib/gethfork/rpc/server.go b/lib/gethfork/rpc/server.go index 59af5e072e..686afe5a02 100644 --- a/lib/gethfork/rpc/server.go +++ b/lib/gethfork/rpc/server.go @@ -18,7 +18,6 @@ package rpc import ( "context" - "fmt" "io" "sync" "sync/atomic" @@ -157,7 +156,6 @@ func (s *Server) serveSingleRequest(ctx context.Context, codec ServerCodec) { if err != nil { if err != io.EOF { resp := errorMessage(&invalidMessageError{"parse error"}) - fmt.Printf(">> Parse error %s. requests: %v\n", err, reqs) codec.writeJSON(ctx, resp, true) } return diff --git a/lib/gethfork/rpc/service.go b/lib/gethfork/rpc/service.go index f8e90064fd..38f16bb26f 100644 --- a/lib/gethfork/rpc/service.go +++ b/lib/gethfork/rpc/service.go @@ -198,7 +198,7 @@ func (c *callback) call(ctx context.Context, method string, args []reflect.Value buf := make([]byte, size) buf = buf[:runtime.Stack(buf, false)] log.Error("RPC method " + method + " crashed: " + fmt.Sprintf("%v\n%s", err, buf)) - errRes = &internalServerError{errcodePanic, fmt.Sprintf("method handler crashed:%v\n%s ", err, buf)} + errRes = &internalServerError{errcodePanic, "method handler crashed"} } }() // Run the callback. diff --git a/testnet/launcher/eth2network/docker.go b/testnet/launcher/eth2network/docker.go index 0fc73f23d4..144e13dbf4 100644 --- a/testnet/launcher/eth2network/docker.go +++ b/testnet/launcher/eth2network/docker.go @@ -50,7 +50,7 @@ func (n *Eth2Network) Start() error { } func (n *Eth2Network) IsReady() error { - timeout := 20 * time.Minute + timeout := 20 * time.Minute // this can be reduced when we no longer download the ethereum binaries interval := 2 * time.Second var dial *ethclient.Client var err error diff --git a/tools/walletextension/container_run.sh b/tools/walletextension/container_run.sh index 162cff74bb..8329fce4d1 100755 --- a/tools/walletextension/container_run.sh +++ b/tools/walletextension/container_run.sh @@ -14,7 +14,7 @@ host="0.0.0.0" nodeHost="erpc.sepolia-testnet.ten.xyz" nodePortHTTP=80 nodePortWS=81 -logPath="sys_out" +logPath="wallet_extension_logs.txt" databasePath=".obscuro/gateway_database.db" image="obscuronet/obscuro_gateway_sepolia_testnet:latest" diff --git a/tools/walletextension/frontend/src/components/providers/wallet-provider.tsx b/tools/walletextension/frontend/src/components/providers/wallet-provider.tsx index 22da64e2ab..81ab3481ba 100644 --- a/tools/walletextension/frontend/src/components/providers/wallet-provider.tsx +++ b/tools/walletextension/frontend/src/components/providers/wallet-provider.tsx @@ -67,9 +67,9 @@ export const WalletConnectionProvider = ({ setVersion(await fetchVersion()); } catch (error) { showToast( - ToastType.DESTRUCTIVE, - "Error initializing wallet connection. Please refresh the page." - ); + ToastType.DESTRUCTIVE, + error instanceof Error ? error.message : "Error initializing wallet connection. Please refresh the page." + ); } finally { setLoading(false); } diff --git a/tools/walletextension/main/cli.go b/tools/walletextension/main/cli.go index 0e7f564c4c..dbbe72a9a0 100644 --- a/tools/walletextension/main/cli.go +++ b/tools/walletextension/main/cli.go @@ -33,7 +33,7 @@ const ( nodeWebsocketPortUsage = "The port on which to connect to the Obscuro node via RPC over websockets. Default: 81." logPathName = "logPath" - logPathDefault = "sys_out" + logPathDefault = "wallet_extension_logs.txt" logPathUsage = "The path to use for the wallet extension's log file" databasePathName = "databasePath" diff --git a/tools/walletextension/main/main.go b/tools/walletextension/main/main.go index f07ee53da2..4b200968c0 100644 --- a/tools/walletextension/main/main.go +++ b/tools/walletextension/main/main.go @@ -53,7 +53,7 @@ func main() { } } - logLvl := gethlog.LvlDebug + logLvl := gethlog.LvlError if config.VerboseFlag { logLvl = gethlog.LvlDebug } diff --git a/tools/walletextension/rpcapi/utils.go b/tools/walletextension/rpcapi/utils.go index 65177d7a39..dda9589459 100644 --- a/tools/walletextension/rpcapi/utils.go +++ b/tools/walletextension/rpcapi/utils.go @@ -224,7 +224,6 @@ func withCache[R any](cache cache.Cache, cfg *CacheCfg, cacheKey []byte, onCache } func audit(services *Services, msg string, params ...any) { - println(fmt.Sprintf(msg, params...)) if services.Config.VerboseFlag { services.FileLogger.Info(fmt.Sprintf(msg, params...)) }