Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into filter-cap
Browse files Browse the repository at this point in the history
  • Loading branch information
fedekunze committed Oct 13, 2021
2 parents df72ec5 + 8e12d94 commit 4ab57f3
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

* (rpc) [tharsis#667](https://github.com/tharsis/ethermint/issues/667) Fix ExpandHome restrictions bypass
* (rpc) [tharsis#642](https://github.com/tharsis/ethermint/issues/642) Fix `eth_getLogs` when string is specified in filter's from or to fields
* (evm) [tharsis#616](https://github.com/tharsis/ethermint/issues/616) Fix halt on deeply nested stack of cache context. Stack is now flattened before iterating over the tx logs.
* (rpc, evm) [tharsis#614](https://github.com/tharsis/ethermint/issues/614) Use JSON for (un)marshaling tx `Log`s from events.
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/spf13/viper v1.9.0
github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969
github.com/stretchr/testify v1.7.0
github.com/tendermint/tendermint v0.34.13
github.com/tendermint/tendermint v0.34.14
github.com/tendermint/tm-db v0.6.4
github.com/tyler-smith/go-bip39 v1.1.0
go.etcd.io/bbolt v1.3.6 // indirect
Expand Down Expand Up @@ -98,6 +98,7 @@ require (
github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/lib/pq v1.10.2 // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ github.com/coreos/go-systemd v0.0.0-20190620071333-e64a0ec8b42a/go.mod h1:F5haX7
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cosmos/cosmos-sdk v0.44.1 h1:UspmTMwKNGf6mH8k388v2T5csP9BYpPJkbQ/eG30PtM=
github.com/cosmos/cosmos-sdk v0.44.1/go.mod h1:fwQJdw+aECatpTvQTo1tSfHEsxACdZYU80QCZUPnHr4=
github.com/cosmos/cosmos-sdk v0.44.2 h1:EWoj9h9Q9t7uqS3LyqzZWWwnSEodUJlYDMloDoPBD3Y=
github.com/cosmos/cosmos-sdk v0.44.2/go.mod h1:fwQJdw+aECatpTvQTo1tSfHEsxACdZYU80QCZUPnHr4=
Expand Down Expand Up @@ -1155,8 +1154,9 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk=
github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E=
github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tendermint/tendermint v0.34.13 h1:fu+tsHudbOr5PvepjH0q47Jae59hQAvn3IqAHv2EbC8=
github.com/tendermint/tendermint v0.34.13/go.mod h1:6RVVRBqwtKhA+H59APKumO+B7Nye4QXSFc6+TYxAxCI=
github.com/tendermint/tendermint v0.34.14 h1:GCXmlS8Bqd2Ix3TQCpwYLUNHe+Y+QyJsm5YE+S/FkPo=
github.com/tendermint/tendermint v0.34.14/go.mod h1:FrwVm3TvsVicI9Z7FlucHV6Znfd5KBc/Lpp69cCwtk0=
github.com/tendermint/tm-db v0.6.4 h1:3N2jlnYQkXNQclQwd/eKV/NzlqPlfK21cpRRIx80XXQ=
github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw=
github.com/tetafro/godot v1.4.9/go.mod h1:LR3CJpxDVGlYOWn3ZZg1PgNZdTUvzsZWu8xaEohUpn8=
Expand Down
7 changes: 6 additions & 1 deletion rpc/ethereum/namespaces/debug/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,12 @@ func (a *API) StartCPUProfile(file string) error {
a.logger.Debug("CPU profiling already in progress")
return errors.New("CPU profiling already in progress")
default:
f, err := os.Create(ExpandHome(file))
fp, err := ExpandHome(file)
if err != nil {
a.logger.Debug("failed to get filepath for the CPU profile file", "error", err.Error())
return err
}
f, err := os.Create(fp)
if err != nil {
a.logger.Debug("failed to create CPU profile file", "error", err.Error())
return err
Expand Down
7 changes: 6 additions & 1 deletion rpc/ethereum/namespaces/debug/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ func (a *API) StartGoTrace(file string) error {
a.logger.Debug("trace already in progress")
return errors.New("trace already in progress")
}
f, err := os.Create(ExpandHome(file))
fp, err := ExpandHome(file)
if err != nil {
a.logger.Debug("failed to get filepath for the CPU profile file", "error", err.Error())
return err
}
f, err := os.Create(fp)
if err != nil {
a.logger.Debug("failed to create go trace file", "error", err.Error())
return err
Expand Down
23 changes: 12 additions & 11 deletions rpc/ethereum/namespaces/debug/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,27 @@ func isCPUProfileConfigurationActivated(ctx *server.Context) bool {

// ExpandHome expands home directory in file paths.
// ~someuser/tmp will not be expanded.
func ExpandHome(p string) string {
func ExpandHome(p string) (string, error) {
if strings.HasPrefix(p, "~/") || strings.HasPrefix(p, "~\\") {
home := os.Getenv("HOME")
if home == "" {
if usr, err := user.Current(); err == nil {
home = usr.HomeDir
}
}
if home != "" {
p = home + p[1:]
usr, err := user.Current()
if err != nil {
return p, err
}
home := usr.HomeDir
p = home + p[1:]
}
return filepath.Clean(p)
return filepath.Clean(p), nil
}

// writeProfile writes the data to a file
func writeProfile(name, file string, log log.Logger) error {
p := pprof.Lookup(name)
log.Info("Writing profile records", "count", p.Count(), "type", name, "dump", file)
f, err := os.Create(ExpandHome(file))
fp, err := ExpandHome(file)
if err != nil {
return err
}
f, err := os.Create(fp)
if err != nil {
return err
}
Expand Down
5 changes: 4 additions & 1 deletion rpc/ethereum/pubsub/pubsub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package pubsub

import (
"log"
"sort"
"sync"
"testing"
"time"
Expand All @@ -21,7 +22,9 @@ func TestAddTopic(t *testing.T) {
err = q.AddTopic("lol", make(<-chan coretypes.ResultEvent))
require.Error(t, err)

require.EqualValues(t, []string{"kek", "lol"}, q.Topics())
topics := q.Topics()
sort.Strings(topics)
require.EqualValues(t, []string{"kek", "lol"}, topics)
}

func TestSubscribe(t *testing.T) {
Expand Down
7 changes: 6 additions & 1 deletion server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,12 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
var cpuProfileCleanup func()

if cpuProfile := ctx.Viper.GetString(srvflags.CPUProfile); cpuProfile != "" {
f, err := os.Create(ethdebug.ExpandHome(cpuProfile))
fp, err := ethdebug.ExpandHome(cpuProfile)
if err != nil {
ctx.Logger.Debug("failed to get filepath for the CPU profile file", "error", err.Error())
return err
}
f, err := os.Create(fp)
if err != nil {
return err
}
Expand Down

0 comments on commit 4ab57f3

Please sign in to comment.