The issue occurs when an event is emitted, which satisfies the following conditions:
- Ganache's
subscribedTopics
property contains the event identifier of the event (hash of the event signature) - Ganache's
contractCache
contains an entry for the address associated with the event - the contract in the cache does not contain an event matching the event identifier
- Start Ganache UI with the project loaded
- Deploy
EventEmitter
contract withtruffle migrate
- grab the contract address which will be used in the next step - Remove the build project with
rm -rf build
- Comment out
EventEmitter
contract fromDelegateCaller.sol
, update the migration script (as per comments in1_reproduction.js
), redeploy withtruffle migrate
- The migration script
1_reproduction.js
automatically callsDelegateCaller.delegateCall()
function - Click
Events
tab in Ganache-UI
In step 2. subscribedtopics
is populated with the Event from EventEmitter
. subscribedTopics
is additive, so the subscription is not removed when we redeploy without the EventEmitter
contract.
In step 5, the event is emitted, and is associated with the DelegateCaller
address. The preconditions described above are met, specifically:
subscribedTopics
must include the event identifier- The contract cache must have an entry for the address raising the event
The decoder
returns undefined if no event matching the event identifier is found, triggering the whole kerfuffle.