-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update security roles on v2 contracts #117
Conversation
contracts/upgradeable_contracts/native_to_erc20/ForeignBridgeNativeToErc.sol
Show resolved
Hide resolved
In general, I am OK with changes. Let's prepare a gist files for the |
Here are the Gist files for each contract. I also described one method for each contract to be called when upgrading the contract to make the necessary updates for limits and new Owner role. Please check the values of the limits and update them as needed, also regarding the Owner, another option is to receive the new owner address as a parameter instead of using current validatorContract's owner. Once we agree on the details of methods, I'll add them to the gist files. Home Bridge Gist: https://gist.github.com/patitonar/39ac4d337420864bc912123f72bc41f7 // Method for Home Bridge
function upgradeToV220() public onlyProxyOwner {
require(!boolStorage[keccak256(abi.encodePacked("isUpgradedToV220"))]);
setOwner(validatorContract().owner());
uintStorage[keccak256(abi.encodePacked("executionDailyLimit"))] = 1000000 ether;
emit ExecutionDailyLimitChanged(3000000 ether);
uintStorage[keccak256(abi.encodePacked("executionMaxPerTx"))] = 100000 ether;
boolStorage[keccak256("isUpgradedToV220")] = true;
} Foreign Bridge Gist: https://gist.github.com/patitonar/36a6e03c3ca13b912064b7742b5c3f5c // Method for Foreign Bridge
function upgradeToV220() public onlyProxyOwner {
require(!boolStorage[keccak256(abi.encodePacked("isUpgradedToV220"))]);
setOwner(validatorContract().owner());
uintStorage[keccak256(abi.encodePacked("maxPerTx"))] = 100000 ether;
uintStorage[keccak256(abi.encodePacked("executionDailyLimit"))] = 1000000 ether;
emit ExecutionDailyLimitChanged(3000000 ether);
uintStorage[keccak256(abi.encodePacked("executionMaxPerTx"))] = 100000 ether;
boolStorage[keccak256("isUpgradedToV220")] = true;
} |
Thanks!
Should be with the value 1000000 ether as well in both methods.
Let's do in this way. |
Fixed the methods and added them into the Gist files. Here are the updated version: // Method for Home Bridge
function upgradeToV220(address _newOwner) public onlyProxyOwner {
require(!boolStorage[keccak256(abi.encodePacked("isUpgradedToV220"))]);
setOwner(_newOwner);
uintStorage[keccak256(abi.encodePacked("executionDailyLimit"))] = 1000000 ether;
emit ExecutionDailyLimitChanged(1000000 ether);
uintStorage[keccak256(abi.encodePacked("executionMaxPerTx"))] = 100000 ether;
boolStorage[keccak256("isUpgradedToV220")] = true;
} // Method for Foreign Bridge
function upgradeToV220(address _newOwner) public onlyProxyOwner {
require(!boolStorage[keccak256(abi.encodePacked("isUpgradedToV220"))]);
setOwner(_newOwner);
uintStorage[keccak256(abi.encodePacked("maxPerTx"))] = 100000 ether;
uintStorage[keccak256(abi.encodePacked("executionDailyLimit"))] = 1000000 ether;
emit ExecutionDailyLimitChanged(1000000 ether);
uintStorage[keccak256(abi.encodePacked("executionMaxPerTx"))] = 100000 ether;
boolStorage[keccak256("isUpgradedToV220")] = true;
} Next step is to test performing an upgrade of the contracts, test that we can send back tokens that exceed the limit and the new security roles. |
@akolotov I found an issue while testing. This same issue affects security roles upgrades also v1 contracts. Previouly I described an issue regarding The solution implemented to that issue, was to change the order of inheritance between The Given this, I think a possible solution is to introduce an admin role for Bridge contracts (similar to Does this solution sound good? Any other option you can think of? |
Honestly, I don't like it. Let me think more about this. |
@patitonar I have an idea. I did not tried this but what address will be assigned to Could you try this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
I performed the test with the new roles and the new limits functionality. Everything worked as expected. Only one issue was found regarding functionality (setExecutionMaxPerTx) and was fixed.
For the contract upgrade, I had to call The reason is that Are the upgrade steps OK or should we refactor |
Was the gist updated with the fix? |
Yes, both Gist files were updated. On Home Bridge Gist: https://gist.github.com/patitonar/39ac4d337420864bc912123f72bc41f7 |
No, that's OK since the upgrade procedure is not trivial anyway:
|
So, let's finish changes for the contracts v1.x and distribute the changes to other modes of the bridge. |
During the upgrade we have found that function upgradeToV220(address _newOwner) public onlyProxyOwner { uses Can you share why we did not catch this during the testing? |
@akolotov As you mentioned, correct version of Home: function upgradeToV220(address _newOwner) public onlyIfOwnerOfProxy {
require(!boolStorage[keccak256(abi.encodePacked("isUpgradedToV220"))]);
setOwner(_newOwner);
uintStorage[keccak256(abi.encodePacked("executionDailyLimit"))] = 1000000 ether;
emit ExecutionDailyLimitChanged(1000000 ether);
uintStorage[keccak256(abi.encodePacked("executionMaxPerTx"))] = 100000 ether;
boolStorage[keccak256("isUpgradedToV220")] = true;
} Foreign: function upgradeToV220(address _newOwner) public onlyIfOwnerOfProxy {
require(!boolStorage[keccak256(abi.encodePacked("isUpgradedToV220"))]);
setOwner(_newOwner);
uintStorage[keccak256(abi.encodePacked("maxPerTx"))] = 100000 ether;
uintStorage[keccak256(abi.encodePacked("executionDailyLimit"))] = 1000000 ether;
emit ExecutionDailyLimitChanged(1000000 ether);
uintStorage[keccak256(abi.encodePacked("executionMaxPerTx"))] = 100000 ether;
boolStorage[keccak256("isUpgradedToV220")] = true;
} These correct versions of What I think happened is that, after fixing the issue that was found during the test (on method To avoid this situation next time I think we should:
I have fixed the methods |
Ok, thanks! We already deployed the contracts to the ETH mainnet and the xDai chain. |
@akolotov Applied changes to other modes, updated deploy scripts, |
The upgraded version of contracts was applied to the ETH mainnet and the xDai chain: |
Closes #111
Since we are going to perform one upgrade on deployed contracts of ERC20-To-Native, this PR includes changes from #112.
To review specific changes from this PR, refer to commit abbde31
Once we agree on changes, these are the next steps:
.env.example
anddeploy/README.md
file