thanks in advance for your time and intellectual contribution.
I am working on a project in which we have contracts interacting which each other.
More specifically, there is a "father contract", with functions that should be executed only by the "child contracts" therefore, we need a way to authenticate (to identify in fact) the callers before allowing them to do any action. For the case, the first thing anybody would think is to keep a list of the addresses that are allowed, something like this:
...
mapping(address => bool) allowedAddrs;
...
//adds a new address to the list of allowed contracts
function addChild(address _child) public onlyOnwner{
//here code to verify if the addr is a EOA or a contract
//add the contract to the list
allowedAddrs[_child] = ture;
}
//This is the function that requires authentication/authorazation
function authenticatedFunc() public payable{
require(allowedAddrs[msg.sender] ==true, "Back off cheater" );
// more code here
}
I wonder however if it is safe! Can the address of a smart contract be faked ( cloned)?
What happens if some miner loads the contract at one of the allowed addresses, but with "some customs" and try to interact with this function of my contract? How does the blockchain guarantee that the address calling the function is not "a clone of one of the contracts that I included in the allowed list?