Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- [\#376](https://github.com/cosmos/evm/pull/376) Fix precompile initialization for local node development script
- [\#384](https://github.com/cosmos/evm/pull/384) Fix debug_traceTransaction RPC failing with block height mismatch errors
- [\#441](https://github.com/cosmos/evm/pull/441) Align precompiles map with available static check to Prague.
- [\#452](https://github.com/cosmos/evm/pull/452) Cleanup unused cancel function in filter.
- [\#454](https://github.com/cosmos/evm/pull/454) Align multi decode functions instead of string contains check in HexAddressFromBech32String.

### IMPROVEMENTS
Expand Down
2 changes: 0 additions & 2 deletions rpc/namespaces/ethereum/eth/filters/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ type filter struct {
typ filters.Type
deadline *time.Timer // filter is inactive when deadline triggers
crit filters.FilterCriteria
cancel context.CancelFunc
offset int // offset for stream subscription
}

Expand Down Expand Up @@ -128,7 +127,6 @@ func (api *PublicFilterAPI) timeoutLoop() {
for id, f := range api.filters {
select {
case <-f.deadline.C:
f.cancel()
delete(api.filters, id)
default:
continue
Expand Down
40 changes: 40 additions & 0 deletions rpc/namespaces/ethereum/eth/filters/api_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package filters

import (
"sync"
"testing"
"time"

"github.com/ethereum/go-ethereum/eth/filters"
"github.com/ethereum/go-ethereum/rpc"
"github.com/stretchr/testify/require"
)

func TestTimeoutLoop_PanicOnNilCancel(t *testing.T) {
api := &PublicFilterAPI{
filters: make(map[rpc.ID]*filter),
filtersMu: sync.Mutex{},
deadline: 10 * time.Millisecond,
}
api.filters[rpc.NewID()] = &filter{
typ: filters.BlocksSubscription,
deadline: time.NewTimer(0),
}
done := make(chan struct{})
go func() {
defer func() {
if r := recover(); r == nil {
t.Errorf("cancel panic")
}
close(done)
}()
api.timeoutLoop()
}()
panicked := false
select {
case <-done:
panicked = true
case <-time.After(100 * time.Millisecond):
}
require.False(t, panicked)
}
Loading