delegatable/delegatable-eth

Big Weird Mystery

Closed this issue · 1 comments

Currently our tests are failing for the weirdest reason.

The tests are built around initializing YourContract which inherits from our main product, Delegatable.

I seem to have the basic signature recovery in Delegatable working, which should allow the delegation test to trigger the setPurpose function, and it does seem to call this function, but it silently fails upon the assignment line purpose = newPurpose if any other lines are called first. The test file is not calling the setPurpose method directly, but it is being triggered by a delegation invocation in the test here.

If I comment out all other lines in that function, the assignment works. If I add any other line back in, the assignment silently fails. It does not revert, it simply does not assign. It emits no logs, no revert reasons, nothing.

I've removed the hardhat console.log calls so these contracts can more easily be moved to other test environments. I'm pretty baffled now, and hope someone can help me figure this out.

If you're curious what this module is about, the readme is a good place to start.

From Pat:

:24
I think I see your issue
9:24
A .call() in solidity will catch the exception and return TRUE/FALSE.
9:25
So it looks like:
Delegatable.Invoke -> Delegatable.execute -> YourContract.setPurpose
SetPurpose is failing and returns FALSE. Delegatable.execute is ignoring the false and just continuing on
9:25
so the transaction will succeed, but the internal transaction for that failed
9:26
You may want to emit an event in Delegatable.invoke() to check the value of ‘success’
9:27
(I suspect… it is failing… because delegatable is calling itself? And msg.sender === address(this)… which will be different to the value of owner)

Remix is complaining about the invoke function. There is some unreachable code. Maybe you are missing a curly bracket? I’d advise just deleting most of it (signature checking) and just make sure the invoke() -> execute() function works first. i.e., that it can call setPurpose() OK.
Emit an event for the .call()’s ‘success’ and make sure it is passing.
Check the values of msg.sender, currentContextAddress, owner, in the Purpose contract. There may be a mismatch there.
Add the boiler plate signature checking code back in.