Closed jackykwandesign closed 3 years ago
Hey, thanks a lot for raising the issue.
So your last transaction is not a contract call its just sending eth which does not emit logs so not queryable in blooms. This issue has made me write a little section on this to explain this to users (so thanks):
Blooms do not work with eth transactions (purely sending eth), eth transactions do not emit logs so do not exist in the bloom filter. This is what ethereum did purposely but it means you should query the eth balance every block to make sure it's in sync. Blooms will only work if the transaction emits an event which then ends up in the logs. The bloom filter is there to help you find logs. A contract can be written which does not emit an event and in that case, would not be queryable from a bloom filter. The erc20 token spec requires you to fire an event on approval
and transfer
so blooms will work for approval
and transfer
for ALL erc20 tokens, this will be most people's primary use-case. Saying that this can be used in any way you want with any use-case as long as events are emitted then it's queryable.
You can now see that section in the readme https://github.com/joshstevens19/ethereum-bloom-filters#requirements-for-blooms-to-be-queryable
Thanks!
thanks for your reply, great explanation.
I did some research today and find out that there is no shortcut for pure eth transaction, which my job need to. Since my use case is to monitor a HD wallet with ETH, USDT and BTC, which is EOA and not supported by most of monitor service
So i left a method here for anyone come want to know how to deal with pure ETH.
The old fashion way,
The main time consume job is Infura call and DB call, each infura call require 1-2 sec and DB call require 1 sec. So normally you have 12 - 20 secs to process each block, should be enough since only < 200 transactions @ block Each day around 6500 ETH block generated so a simple Infura free core is enough (100000 Requests @ day)
@jackykwandesign What I would do if I was you would mix it up with both. We do this on our wallet and it works really well.
eth_getBalance
(JSONRPC request) on every new block which comes in with the address of the user's eth address (which you must know)From experience, this flow works very nicely and is not intense.
With 100000
requests a day that's 4166.66666667
an hour so 69.4444444444
a minute, say a client does 4 a minute this approach could handle 17.3 clients running at the same time constantly for 24 hours. So to make it even less intense you could only call eth_balance
every 1 minute, as your USDT will be using blooms and only querying when it needs to. This would mean you're probably going to be able to run 3x 17.3 clients more like 52 clients running constantly for 24 hours without hitting a paid subscription (doubt you ever hit that as clients don't run for 24 hours ever really, user sessions are 1 hour or so). If you did not do blooms for USDT the maths above would be much much more (double) and you only be able to run 8.6 clients for the free plan running at the same time constantly for 24 hours.
Hope it helps! Josh
Also have a look at https://github.com/joshstevens19/ethereum-multicall can group many json rpc calls in 1 to save you even more credits.
This is a test block, Eth mainnet block 11722493 https://etherscan.io/block/11722493
The bloom is
0x15ac582820ce219071f520ac98b0fc458059117dac1099491493a45ad0e48b81051e214c658816f457107a028c1a8b5d862ee083d93a2aa76c8db1b0baee4259594c408aa112a96e4dc3cc8cd3f9c76698464147114614138cc61c48da4b5551fd4089951a304361134dd841636d9cea4f4d1328442a1fd10a7e7f3a122c5da059b9d9068b682684ddeb48140206a4170c0e8c9f85383629e126bce1869e91b68329681bfe59f3027e85f2f4ba11091902458c41882a59402278a30911288256b950a063253e8ab4144c4d72b3bbac8f0465df4b574b53dae81988474c48a0a51eb86810baa2c0458c501df0f1b85300952c00d205cf2c7108ec8676039256fa
Sample data 1 TX: 0xb40818abfc6a5f460922e107a108a49a041d48d29b78f914ae35ffeeccea566c Address: 0xdac17f958d2ee523a2206206994597c13d831ec7 (USDT token contract address)
Sample data 2 TX: 0xbbbfaa43ceaf7e6472ba41ffccea878027d330418d435551f206128557bc527b Address: 0x8d1f2cd09a96701a074783841be8d4ec97ec5f0c (simple address)
simple code for the case
Result:
So is that my understanding of isUserEthereumAddressInBloom wrong or code mistake ?