Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Trace Filter is not working properly (filtering fromAddress) #2751

Closed
ngotchac opened this issue Oct 20, 2016 · 2 comments
Closed

Trace Filter is not working properly (filtering fromAddress) #2751

ngotchac opened this issue Oct 20, 2016 · 2 comments
Labels
F2-bug 🐞 The client fails to follow expected behavior. M4-core ⛓ Core client code / Rust.

Comments

@ngotchac
Copy link
Contributor

When trying to use the trace_filter call with the fromAddress filter, some unrelated transactions are returned.

Eg. for address 0xe1a1531a6667fa8ba694692362fc679105ff2677 on Testnet.

There should be only one IN transaction : https://testnet.etherscan.io/address/0xe1a1531a6667fa8ba694692362fc679105ff2677

However, running

curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"trace_filter","params":[{"fromBlock":"0x0","fromAddress":["0xE1A1531A6667FA8ba694692362Fc679105ff2677"]}],"id":74}' localhost:8545 | python -mjson.tool

will return 2 contract creation transactions unrelated to the account 0xe1a1531a6667fa8ba694692362fc679105ff2677 (0xdf92bf2 and 0x85893ad).

It seems that it returns every contract creation transactions (filter.rs#L130 with no to_address filter), in blocks matching the toAddress filter...

@ngotchac ngotchac added F2-bug 🐞 The client fails to follow expected behavior. M4-core ⛓ Core client code / Rust. labels Oct 20, 2016
@ngotchac
Copy link
Contributor Author

This seems to fix the issue...

diff --git a/ethcore/src/types/trace_types/filter.rs b/ethcore/src/types/trace_types/filter.rs
index 2d35718..7eba18c 100644
--- a/ethcore/src/types/trace_types/filter.rs
+++ b/ethcore/src/types/trace_types/filter.rs
@@ -42,7 +42,12 @@ impl From<Vec<Address>> for AddressesFilter {
 impl AddressesFilter {
    /// Returns true if address matches one of the searched addresses.
    pub fn matches(&self, address: &Address) -> bool {
-       self.matches_all() || self.list.contains(address)
+       self.matches_all() || self.stricly_matches(address)
+   }
+
+   /// Returns true if address matches at least one of the searched addresses.
+   pub fn stricly_matches(&self, address: &Address) -> bool {
+       self.list.contains(address)
    }

    /// Returns true if this address filter matches everything.
@@ -127,7 +132,7 @@ impl Filter {
        };

        action || match trace.result {
-           Res::Create(ref create) => self.to_address.matches(&create.address),
+           Res::Create(ref create) => self.to_address.stricly_matches(&create.address),
            _ => false
        }
    }

@jacogr
Copy link
Contributor

jacogr commented Oct 20, 2016

Make a PR :)

ngotchac added a commit that referenced this issue Oct 20, 2016
  Don't test contract address against empty array in trace filtering
ngotchac added a commit that referenced this issue Oct 20, 2016
gavofyork pushed a commit that referenced this issue Oct 20, 2016
* (#2751) Trace filtering fix:
  Don't test contract address against empty array in trace filtering

* Fixes spaces/typo

* Simplify the Trace Filtering (#2751)

* Removed unused `strictly_matches` fn
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
F2-bug 🐞 The client fails to follow expected behavior. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

No branches or pull requests

2 participants