Skip to content

Commit

Permalink
Revert "Add check for bridge address on setBlockRewardContract"
Browse files Browse the repository at this point in the history
This reverts commit ad9ac7c
  • Loading branch information
patitonar committed Oct 12, 2018
1 parent ad9ac7c commit 00b4976
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 38 deletions.
1 change: 0 additions & 1 deletion contracts/IBlockReward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ interface IBlockReward {
function addExtraReceiver(uint256 _amount, address _receiver) external;
function mintedTotally() public view returns (uint256);
function mintedTotallyByBridge(address _bridge) public view returns(uint256);
function bridgesAllowed() public pure returns(address[3]);
}
9 changes: 0 additions & 9 deletions contracts/test/BlockReward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ contract BlockReward is IBlockReward {
uint256 public mintedCoins = 0;
mapping(bytes32 => uint256) internal uintStorage;
bytes32 internal constant MINTED_TOTALLY_BY_BRIDGE = "mintedTotallyByBridge";
uint256 public constant bridgesAllowedLength = 3;

function () external payable {
}
Expand All @@ -37,12 +36,4 @@ contract BlockReward is IBlockReward {
bytes32 hash = keccak256(abi.encode(MINTED_TOTALLY_BY_BRIDGE, _bridge));
uintStorage[hash] = uintStorage[hash].add(_amount);
}

function bridgesAllowed() public pure returns(address[bridgesAllowedLength]) {
return([
0x0cDEE95B0Ed18FccEB4c344Df4dd1C1642798a8b,
0x320051BbD4eeE344Bb86F0A858d03595837463eF,
0xce42bdB34189a93c55De250E011c68FaeE374Dd3
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ contract HomeBridgeErcToNative is EternalStorage, BasicBridge, BasicHomeBridge {

function setBlockRewardContract(address _blockReward) public onlyOwner {
require(_blockReward != address(0) && isContract(_blockReward));
require(_isBridgeAllowed(_blockReward, this));
addressStorage[keccak256(abi.encodePacked("blockRewardContract"))] = _blockReward;
}

Expand All @@ -85,16 +84,4 @@ contract HomeBridgeErcToNative is EternalStorage, BasicBridge, BasicHomeBridge {
function setTotalBurntCoins(uint256 _amount) internal {
uintStorage[keccak256(abi.encodePacked("totalBurntCoins"))] = _amount;
}

function _isBridgeAllowed(address _blockReward, address _addr) private pure returns(bool) {
IBlockReward RewardContract = IBlockReward(_blockReward);
address[3] memory bridges = RewardContract.bridgesAllowed();

for (uint256 i = 0; i < bridges.length; i++) {
if (_addr == bridges[i]) {
return true;
}
}
return false;
}
}
15 changes: 0 additions & 15 deletions test/erc_to_native/home_bridge.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,6 @@ contract('HomeBridge_ERC20_to_Native', async (accounts) => {
secondBlockRewardContract.address.should.be.equal(await homeContract.blockRewardContract())
})

it('can update block reward contract only if bridge is allowed', async () => {
ZERO_ADDRESS.should.be.equal(await homeContract.blockRewardContract())
await homeContract.initialize(validatorContract.address, '3', '2', '1', gasPrice, requireBlockConfirmations, blockRewardContract.address).should.be.fulfilled
blockRewardContract.address.should.be.equal(await homeContract.blockRewardContract())

await homeContract.setBlockRewardContract(blockRewardContract.address)
blockRewardContract.address.should.be.equal(await homeContract.blockRewardContract())

const notAllowedHomeBridge = await HomeBridge.new()

await notAllowedHomeBridge.setBlockRewardContract(blockRewardContract.address).should.be.rejectedWith(ERROR_MSG)

ZERO_ADDRESS.should.be.equal(await notAllowedHomeBridge.blockRewardContract())
})

it('cant set maxPerTx > dailyLimit', async () => {
false.should.be.equal(await homeContract.isInitialized())

Expand Down

0 comments on commit 00b4976

Please sign in to comment.