Skip to content

Commit

Permalink
fix(evm): debug logging of jsonrpc
Browse files Browse the repository at this point in the history
  • Loading branch information
dessaya committed Sep 20, 2023
1 parent 59f12dc commit c8bee5c
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 31 deletions.
4 changes: 2 additions & 2 deletions components/logger/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package logger

import (
"github.com/iotaledger/hive.go/app"
"github.com/iotaledger/wasp/packages/evm/evmlogger"
)

func init() {
Expand All @@ -14,7 +15,6 @@ func init() {
var Component *app.Component

func configure() error {
initGoEthLogger(Component.App().NewLogger("go-ethereum"))

evmlogger.Init(Component.App().NewLogger("go-ethereum"))
return nil
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package logger
package evmlogger

import (
"strings"

"github.com/ethereum/go-ethereum/log"

"github.com/iotaledger/hive.go/logger"
)

var format = log.TerminalFormat(false)

func initGoEthLogger(waspLogger *logger.Logger) {
func Init(waspLogger *logger.Logger) {
log.Root().SetHandler(log.FuncHandler(func(r *log.Record) error {
s := string(format.Format(r))
s := strings.TrimRight(string(format.Format(r)), "\n")
switch r.Lvl {
case log.LvlCrit, log.LvlError:
waspLogger.Error(s)
Expand Down
21 changes: 0 additions & 21 deletions packages/evm/evmtest/env.go

This file was deleted.

2 changes: 0 additions & 2 deletions packages/evm/jsonrpc/jsonrpctest/jsonrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ type soloTestEnv struct {
}

func newSoloTestEnv(t testing.TB) *soloTestEnv {
evmtest.InitGoEthLogger(t)

var log *logger.Logger
if _, ok := t.(*testing.B); ok {
log = testlogger.NewSilentLogger(t.Name(), true)
Expand Down
2 changes: 2 additions & 0 deletions packages/solo/solo.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/iotaledger/wasp/packages/chain"
"github.com/iotaledger/wasp/packages/cryptolib"
"github.com/iotaledger/wasp/packages/database"
"github.com/iotaledger/wasp/packages/evm/evmlogger"
"github.com/iotaledger/wasp/packages/hashing"
"github.com/iotaledger/wasp/packages/isc"
"github.com/iotaledger/wasp/packages/isc/coreutil"
Expand Down Expand Up @@ -159,6 +160,7 @@ func New(t Context, initOptions ...*InitOptions) *Solo {
opt.Log = testlogger.WithLevel(opt.Log, zapcore.InfoLevel, opt.PrintStackTrace)
}
}
evmlogger.Init(opt.Log)

chainRecordRegistryProvider, err := registry.NewChainRecordRegistryImpl("")
require.NoError(t, err)
Expand Down
2 changes: 2 additions & 0 deletions tools/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/iotaledger/wasp/components/app"
"github.com/iotaledger/wasp/packages/apilib"
"github.com/iotaledger/wasp/packages/cryptolib"
"github.com/iotaledger/wasp/packages/evm/evmlogger"
"github.com/iotaledger/wasp/packages/isc"
"github.com/iotaledger/wasp/packages/kv/codec"
"github.com/iotaledger/wasp/packages/kv/dict"
Expand Down Expand Up @@ -69,6 +70,7 @@ func New(name string, config *ClusterConfig, dataPath string, t *testing.T, log
}
log = testlogger.NewLogger(t)
}
evmlogger.Init(log)

config.setValidatorAddressIfNotSet() // privtangle prefix

Expand Down
3 changes: 0 additions & 3 deletions tools/cluster/tests/evm_jsonrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/stretchr/testify/require"

"github.com/iotaledger/wasp/clients/chainclient"
"github.com/iotaledger/wasp/packages/evm/evmtest"
"github.com/iotaledger/wasp/packages/evm/jsonrpc/jsonrpctest"
"github.com/iotaledger/wasp/packages/isc"
"github.com/iotaledger/wasp/packages/kv"
Expand All @@ -36,8 +35,6 @@ type clusterTestEnv struct {
}

func newClusterTestEnv(t *testing.T, env *ChainEnv, nodeIndex int) *clusterTestEnv {
evmtest.InitGoEthLogger(t)

evmJSONRPCPath := fmt.Sprintf("/v1/chains/%v/evm", env.Chain.ChainID.String())
jsonRPCEndpoint := env.Clu.Config.APIHost(nodeIndex) + evmJSONRPCPath
rawClient, err := rpc.DialHTTP(jsonRPCEndpoint)
Expand Down

0 comments on commit c8bee5c

Please sign in to comment.