Submitted by hihen
https://github.com/code-423n4/2022-11-canto/blob/2733fdd1bee73a6871c6243f92a007a0b80e4c61/Canto/x/csr/keeper/evm_hooks.go#L49
https://github.com/code-423n4/2022-11-canto/blob/2733fdd1bee73a6871c6243f92a007a0b80e4c61/Canto/x/csr/keeper/evm_hooks.go#L101-L135
Some contracts and some Turnstile tokens (NFTs) will not be able to receive CSR fees forever.
In evmhooks.go, the [PostTxProcessing](https://github.com/code-423n4/2022-11-canto/blob/2733fdd1bee73a6871c6243f92a007a0b80e4c61/Canto/x/csr/keeper/evmhooks.go#L49) will call h.processEvents(ctx, receipt) to handle Register and Assign events from Turnstile contract first:
Notice that the processEvents function does not return any error.
However, it is possible for processEvents to encounter an error:
According to the above implementation of processEvents, it will process all the events emitted by the transaction one by one. If one of them encounters an error, it will return directly without any error, and any subsequent unprocessed events will be ignored.
Suppose we have a transaction containing the following events (by contract calls):
If RegisterEvent() returns an error when handling the first event, then all of the events will not be handled because processEvents() will return after logging the error.
And PostTxProcessing() continues to execute normally because it is unaware of the error.
According to the current implementation of RegisterEvent() and UpdateEvent, they are both easy to encounter an error. Like register() using a recipient that doesnt exist yet.
As a result, none of the C1, C2, C3 contracts will be able to receive any CSR fee because they are not recorded in csr store.
Contracts C1, C2, C3 will never be able to register for CSR because they are marked registered in Turnstile contract (evm store) and will be reverted by onlyUnregistered when calling register() or assign().
And all other contracts calling assign(token1) or assign(token2) will enter the same state as C1/C2/C3, because the assign() will succeed in Turnstile contract but fail in UpdateEvent() (because the store can not find token1 or token2):
VS Code
processEvents() should return the error it encounters, and PostTxProcessing() should return that error too.
tkkwon1998 (Canto) confirmed and commented:
