-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty event log #730
Comments
Can you please put all your code? after instantiating the contract object you need to force update it's address to lowercase address (no EIP-55). |
Hi, thanks for your answer I am not forcing the address to lower case, I will try and will post the results. In the meantime, this is the code. I remove the contract_soruce_code because is not related to the question. compiled_sol = compile_source(contract_source_code)
|
Can you try the old api, so I can see if this is a problem specific to the new api? event_filter = mycontract.eventFilter('RegisterCall', filter_params={'fromBlock': 1}) Are you able to see results with a simple block filter? block_filter = w3.eth.filter("latest") If you could post more of your code, it would be helpful. |
@jfdelgad please try this one:
|
Hi Guys putting the address in lower case throw an error because the address is validated when the event filter is created. However, by looking at Eralp answer I realize that I never initialize the address in mycontract as he pointed out. That was the issue. Thanks a lot |
Hi I have again an issue: This works as I commeneted above (give me a warnig about being deprecated), but works fine
I am requested to do use the new api but doesnt work: The list of events is empty
Any ideas what is going on? |
Is the event in block 0? Your second example skipped it. Try this: myfilter = myfilter.events.RegisterCall.createFilter(fromBlock=0, toBlock='latest')
eventlist = myfilter.get_all_entries() |
I'm having a similar problem getting events to work at all. I have a testing method in my contract:
I then call that method via web3.py:
A block filter, however, seems to be working perfectly well. |
Thanks for highlighting that! That's definitely a bug. |
Can you confirm that the transaction has been mined, like: event_filter = root_chain.events.Deposit.createFilter(fromBlock='latest')
txn_hash = root_chain.functions.testDepositEvent().transact({
'from': ACCOUNT1
})
...
w3.eth.getTransactionReceipt(txn_hash)
print(event_filter.get_all_entries()) # [] |
@carver It does seem to be mined. Here's the prettified transaction receipt:
And I'm running ganache-cli v6.1.0 |
Ah, this appears to be a bug with ganache: trufflesuite/ganache#494 |
I still have the problem and I am using plain python with Geth. As I mentioned the old method for the filtering works, the new one doesn't. |
@jfdelgad Have you re-tried with the latest web3 (installed from the master branch) that includes #742, and setting the block number to 0? If you are still having an issue after following these two steps, can you post a complete example demonstrating how to produce the error. A complete example including contract code, any event emitting transactions, and the filter creation and filter polling. Here is a simple example instantiating an event filter with the new api, sending an event emitting transaction, and then checking that the filter caught the transaction: import time
import web3
from solc import compile_source
from web3 import Web3, EthereumTesterProvider
contract_code = '''
contract EmitEvent {
uint8 public _myVar;
event Event(string indexed _var);
function emitEvent() public {
Event("!!!");
}
}
'''
def wait_on_tx_receipt(tx_hash):
start_time = time.time()
while True:
if start_time + 60 < time.time():
raise TimeoutError("Timeout occurred waiting for tx receipt")
if w3.eth.getTransactionReceipt(tx_hash):
return w3.eth.getTransactionReceipt(tx_hash)
compiled_sol = compile_source(contract_code)
contract_interface = compiled_sol['<stdin>:EmitEvent']
w3 = Web3(EthereumTesterProvider())
contract = w3.eth.contract(
abi=contract_interface['abi'],
bytecode=contract_interface['bin'])
tx_hash = contract.constructor().transact(
transaction={
'from': w3.eth.accounts[0],
'gas': 410000})
tx_receipt = w3.eth.getTransactionReceipt(tx_hash)
contract_address = tx_receipt['contractAddress']
# Instatiate contract
emitEvent = w3.eth.contract(address=contract_address, abi=contract_interface['abi'])
# Create log filter instance
_filter = emitEvent.events.Event.createFilter(fromBlock=0)
# Event emitting transaction
tx_hash = emitEvent.functions.emitEvent().transact()
# Wait for transaction to be mined
receipt = wait_on_tx_receipt(tx_hash)
# Poll filter
print(_filter.get_new_entries()) $ python emit_event_example.py
[AttributeDict({'args': AttributeDict({'_var': b"\x91xd\xb8)_k~\x97\x0f4\xc7\xdf'\xaa\xf2\\\xbf\x1d\xc3\xb9\x12\xe9omK\xbd\n\x99\xbeF\xb3"}), 'event': 'Event', 'logIndex': 0, 'transactionIndex': 0, 'transactionHash': HexBytes('0xa2065811d730e217de416fb20ef1a4a9f48ab64d57cd0dc80f37020bf9489ec2'), 'address': '0xF2E246BB76DF876Cef8b38ae84130F4F55De395b', 'blockHash': HexBytes('0xbf64c2de41f858cc697c165ae6adb07a54b85cd73134f7e4f097ce5f28f97644'), 'blockNumber': 2})] |
exact same problem as jfdelgad: I am using python (web3py(4.0.0)), geth RINKEBY via WindowsPowershell...Code I use is (and contract_abi I got from rinkeby.etherscan.io):
EventFilter works perfectly...createFilter returns [] |
Here is a self contained test, borrowing the contract code from the rinkeby address: "0xc778417E063141139Fce010982780140Aa0cD5Ab" Im getting an exception because the topic is incorrect for the event signature:
|
Previously ethereum#730 was not being caught, because the topic parameter was being overrided with the value None
Previously ethereum#730 was not being caught, because the topic parameter was being overrided with the value None
Previously ethereum#730 was not being caught, because the topic parameter was being overrided with the value None
Same problem. (v. 4.1.0)
Most likely I'll be back temporarily to version 3.16.5 |
@SteelStrider are you using ganache? |
Hi ! filter_new = Contracts.eth_contract.events.TestEvent.createFilter(fromBlock=0) At the same time today conducted a test for rinkeby and ran into another error on transact method
ValueError: Could not format value '0xd683010804846765746886676f312e3130856c696e757800000000000000000062d962fb994e8e3b8a5ed527a36cf8bde9af02f904fcfc7a5ec77c525103b6e238f0a9e7fef32597c063d8f2ee29d28481eac08de4557330b8098fb8017484db00' as field 'extraData' And since this test method launches test event I can not say with 100% certainty that under the rinkbi all works just fine... |
Yes, I have confirmed that ganache filters are case-sensitive for the address of the contract, which is a bug in ganache. See trufflesuite/ganache#97 Can you consider using eth-tester instead of ganache? http://web3py.readthedocs.io/en/stable/providers.html#ethereumtesterprovider
We're working on a better error message for that extraData message in #756 -- it would say something like: check out how to add a middleware to use geth-style proof-of-authority: http://web3py.readthedocs.io/en/stable/middleware.html#geth-style-proof-of-authority |
dylanjw: Could the 'Topics' issue you get be coming from the fact that you are using EthereumTesterProvider (I use HTTPProvider)? ... I still get the same issue: he new methodology (createFilter) does not return any results (and EventFilter does)...Does anyone have a workaround? Or is there at least a way to stop the deprecation warnings? |
@ti6oti6o Have you tried using 4.1? The generation of the topic filters is independent of the provider, so the issue would occur with both. Can you paste the output of your filter's for example: >>> _filter = WETH9.events.Deposit.createFilter(fromBlock=0)
>>> _filter.filter_params
{'topics': ['0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c'], 'address': ['0xF2E246BB76DF876Cef8b38ae84130F4F55De395b', '0xF2E246BB76DF876Cef8b38ae84130F4F55De395b'], 'fromBlock': 0, 'toBlock': 'latest'} The broken topic filter generation with 4.0 would result in the following filter params:
|
Here is the filter_params output using the new method:
Here is the filter_params output using the old method:
I haven't tried 4.1 but dont want to as it is unstable and I need a stable version for what I am doing... |
To clarify: |
Why do you say it's unstable? |
ganache has a known bug. Closing as a duplicate of #674 |
Guys, thus still don't work. The old method works though. |
@jfdelgad what web3py version are you on now? |
Updated to the last version and got it working! Thanks. |
same problem with:
contract is: function () payable {
emit Log(msg.sender, players.length);
}
event Log(address indexed _addr, uint indexed _index); python code: def watch(self):
log_filter = self.contract.events.Log.createFilter(fromBlock=0)
#log_filter = self.contract.eventFilter('Log', {'fromBlock': 0})
while True:
log_events = log_filter.get_all_entries()
if not log_events:
time.sleep(3)
print("no log found")
continue
for event in log_events:
self.process_log_event(event)
time.sleep(1) When someone sends ether to the contract address, I can not get the log! |
@DogLi Could you open a new issue, this appears to be different than the issue particular to truffle and checksumed addresses. Also, can you show the instatiation of the contract? Are you able to transact, and get back a receipt? |
I have the same problem, the filter created by the createFilter method returns an empty array, but the old version of eventFilter is no longer supported by the web3.py.
by the way, the simplest filter to select the latest block works well |
A good place to ask for help is https://ethereum.stackexchange.com/questions/tagged/web3.py -- or if no response there, then https://gitter.im/ethereum/web3.py |
I have a simple contract that produces events. The events are registered on mist correctly.
I can interact with the contract without problems but can't get the events. I am simply doing this:
"RegisterCall" is the name of the event in the contract.
Any suggestion will be appreciated.
The text was updated successfully, but these errors were encountered: