Skip to content

Commit

Permalink
Added Update on Correcting this Issue
Browse files Browse the repository at this point in the history
  • Loading branch information
arturoBeccar authored Nov 21, 2023
1 parent 5faa774 commit 117df19
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test-cases/caller-is-origin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ In this scenario, Test 1 fails because the `caller_is_origin` implementation pan

The function depends on features also required by [`gas_left`](https://paritytech.github.io/ink/ink_env/fn.gas_left.html) and [`invoke_contract`](https://paritytech.github.io/ink/ink_env/fn.invoke_contract.html); namely, storage and retrieval of secondary contracts, and gas calculations. Assuming that those features are already in place, the function is fairly trivial. It should not take more than a few minutes to implement.
On-chain implementation at `frame/contracts/src/exec.rs:1385`.

## Update on Correcting this Issue

In our proposed implementation in [PR #1991](https://github.com/paritytech/ink/pull/1991), we have added the `depth` field to the `ExecContext` struct to detect caller changes whenever calls are made between contracts.

Basically every time the callee changes in the `instantiate_contract()` or `invoke_contract()` function calls, 1 is added to `depth`. And when the callee returns to the previous one, 1 is subtracted.

The `caller_is_origin()` function compares the value of depth to zero to check if the current contract caller is the origin of the entire call stack.

0 comments on commit 117df19

Please sign in to comment.