rpc: fix range filter fromBlock logic (#643)

This commit is contained in:
Thomas Nguy 2021-10-07 18:04:04 +09:00 committed by GitHub
parent 06516f7eb3
commit f9323f6473
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -58,6 +58,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes
* (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.
* (rpc) [tharsis#611](https://github.com/tharsis/ethermint/pull/611) Fix panic on JSON-RPC when querying for an invalid block height.

View File

@ -120,11 +120,15 @@ func (f *Filter) Logs(_ context.Context) ([]*ethtypes.Log, error) {
}
head := header.Number.Int64()
if f.criteria.FromBlock.Int64() == -1 {
if f.criteria.FromBlock.Int64() < 0 {
f.criteria.FromBlock = big.NewInt(head)
} else if f.criteria.FromBlock.Int64() == 0 {
f.criteria.FromBlock = big.NewInt(1)
}
if f.criteria.ToBlock.Int64() == -1 {
if f.criteria.ToBlock.Int64() < 0 {
f.criteria.ToBlock = big.NewInt(head)
} else if f.criteria.ToBlock.Int64() == 0 {
f.criteria.ToBlock = big.NewInt(1)
}
if f.criteria.ToBlock.Int64()-f.criteria.FromBlock.Int64() > maxFilterBlocks {