Functional Background:
Contracts for upgradable design pattern: ProofDB.sol : contract to store the data. Proof.sol : contract that contains the business logic. Registry.sol: contract that contains the latest version of Proof.sol
Flow: Frontend application first calls the Registry.sol contract to get the latest veresion of Proof.sol(logic contract). After receiving the latest version it makes calls to respective function. Proof.sol contracts executes the call and sotres the state in ProofDB.sol.
**Migrations script:**
Sequence of deployment:
deployer.deploy(Mortal).then(() => {
return deployer.deploy(ProofDB)
}).then(() => {
return deployer.deploy(Proof, ProofDB.address);
}).then(() => {
return deployer.deploy(Registry, Proof.address);
})
**Code from ProofDB.sol**
Contract ProofDB.sol {
constructor() public {
owner = message.sender;
}
modifier onlyAllowedContractOrOwner {
require (allowedContracts[msg.sender] != true && msg.sender != owner,"Should be a owner");
_;
}
function addAllowedContractOrOwner(address _addr)
public
onlyOwner
returns(bool) {
if( allowedContracts[_addr] == false ) {
allowedContracts[_addr] = true;
allowedContractsKeys.push(_addr);
return true;
}
return false;
}
}
Problem statement:
To ensure the contracts are not vulnarabel to the attack. I want to restrict the access to ProofDB.sol only to selected contracts and owners. How can I do during deployment.How can I invoke ProofDB.sol contract during deployment to pass the list of allowed users and contracts that can access it.
Issue:
- I cannot pass constructor arguments because ProofDB.sol sould be deployed first in the sequence. At that point I do not know the address of Proof.sol.
- Is there a way to pass the allowed contracts and owners to ProofDB.sol during deployment with out doing it manually ?