Or in other words, will geth --fast download the events logs?


Yes. But you won't get the debug.traceTransaction(...) for the part of the blockchain that is fast synced.

Here is the chaindata size from my fast synced blockchain:

Iota:Ethereum bok$ du -hs chaindata/
 16G    chaindata/

And here is the chaindata size from my non-fast synced blockchain:

bok@Rasterbator:~/.ethereum$ du -hs chaindata/
79G     chaindata/

Verifying that I can get the events from the fast synced chain by retrieving an early The DAO token creation event:

var theDAOABIFragment = [{"anonymous":false,"inputs":[{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"CreatedToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Transfer","type":"event"}];
var theDAOAddress = "0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413";
var theDAOStartingBlock = 1428757;
var theDAO = web3.eth.contract(theDAOABIFragment).at(theDAOAddress);
var theDAOCreatedTokenEvent = theDAO.CreatedToken({}, {fromBlock: theDAOStartingBlock, toBlock: theDAOStartingBlock + 2000});
theDAOCreatedTokenEvent.watch(function(error, result){
  console.log(result.address + "\t" + result.args.amount / 1e16 + "\t" + result.args.to + "\t" +
    result.blockHash + "\t" + result.blockNumber + "\t" + result.event + "\t" + result.logIndex + "\t" +
    result.transactionHash + "\t" + result.transactionIndex);


0xbb9bc244d798123fde783fcc1c72d3bb8c189413  3   0xb504e60998c6f354a0794abd91d85e8bc8436211  0x031d5bac6154ca7616ac62e966da2b50a0aaa1b3bc24958ed9cb52d8c8fc1e2f  1429038 CreatedToken    3 0xc96b0f95a1e7e8c07cd488a05f20f9e8d4003fe8eea0ec7f7f4bf199af3198e1    9
0xbb9bc244d798123fde783fcc1c72d3bb8c189413  50  0x53024f875bc85709af41d1c65c01fb4cc92d5c1c  0x48cf967fc94c2f808d82906c1a56e3e09abc99bb8279266fbace13963dc30a1f  1429053 CreatedToken    0 0x1e9ec3974b89653961cbd996d4f6cfc2845db977a3385761b99ed459c2464740    1
0xbb9bc244d798123fde783fcc1c72d3bb8c189413  50  0x2680a6fe5957d177a9279450d2c040818a1949a8  0x40d4235ceb2da6c0288016596d7b55223afd4efce70ba3369e915c0d8a5aa0b1  1429085 CreatedToken     0 0xcea9c261931268d55e695449794bc73a1d614b069051cdd437c1db3d2b31ae0a   0

But the debug.traceTransaction(...) fails:

> debug.traceTransaction("0xc96b0f95a1e7e8c07cd488a05f20f9e8d4003fe8eea0ec7f7f4bf199af3198e1")
Missing trie node 07e43e11d98fc497ae7b888933c409580e593ecbeeed34865f65a4c2c9f4cd98
    at web3.js:3119:20
    at web3.js:6023:15
    at web3.js:4995:36
    at <anonymous>:1:1
  • Thank you! But how are events and debug.traceTransaction() related? What are the consequences for me of debug.traceTransaction() not working if I just want to get events? – takeshi Oct 20 '16 at 9:23
  • 1
    I've added the debug.traceTransaction(...) information just to show what will be missing from your data when you run a fast sync. And also to demonstrate that events can be extracted while the debug.traceTransaction(...) will fail for the same event - when the data is fast synced. – The Officious BokkyPooBah Oct 20 '16 at 9:25
  • 1
    Events that occured before the --fast sync will require the node to rerun the block in question. For example if an event happened at block 100 and I start --fast syncing at block 200, the node will know the event happened at block 100 but not be able to access the logs until it runs block 100. If you have 50 events in 50 blocks before a fast sync you need to check, the node needs to run 50 blocks. – Aakil Fernandes Jan 5 '17 at 22:31
  • Hi, I have a similar goal: can you advise how to retrieve all the Transfer events on a given block using json rpc? I imagine I have to use eth_getLogs but I dont know what the parameters would be. Thanks – Diego Mar 1 '18 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.