Let's say deployer A invokes dapp B, which invokes itself, dapp B
on the first invocation of B we should have...
origin address for B: A (this is correct)
caller address for B: A (incorrect: we get B)
contract address for B: B(this is correct)
the second invocation is correct.
Note that the address fetching occurs AFTER the recursion. So what's happening here is the BlockchainRuntime pertaining to the second invocation is overwriting the first BlockchainRuntime, so that the parent is calling into its child's "context".
This bug is happening because DAppExecutor does an attachBlockchainRuntime() call, which overwrites the old reference with a new one. The old reference is not held on to and never restored, so when the calling dApp returns from the call and goes to use its BlockchainRuntime, it is actually using its child's.
Let's say deployer A invokes dapp B, which invokes itself, dapp B
on the first invocation of B we should have... origin address for B: A (this is correct) caller address for B: A (incorrect: we get B) contract address for B: B(this is correct)
the second invocation is correct.
Note that the address fetching occurs AFTER the recursion. So what's happening here is the
BlockchainRuntime
pertaining to the second invocation is overwriting the firstBlockchainRuntime
, so that the parent is calling into its child's "context".This bug is happening because DAppExecutor does an attachBlockchainRuntime() call, which overwrites the old reference with a new one. The old reference is not held on to and never restored, so when the calling dApp returns from the call and goes to use its BlockchainRuntime, it is actually using its child's.