audit request

This commit is contained in:
Roman Storm 2018-07-09 21:19:45 -07:00
parent 3e7560d08e
commit 0c01b48f46
No known key found for this signature in database
GPG Key ID: E3282F1F2CE28E55
3 changed files with 47 additions and 1 deletions

View File

@ -5,6 +5,12 @@ import "../BasicBridge.sol";
import "../../upgradeability/EternalStorage.sol";
import "../BasicHomeBridge.sol";
contract Sacrifice {
constructor(address _recipient) public payable {
selfdestruct(_recipient);
}
}
contract HomeBridgeNativeToErc is EternalStorage, BasicBridge, BasicHomeBridge {
function initialize (
@ -42,7 +48,9 @@ contract HomeBridgeNativeToErc is EternalStorage, BasicBridge, BasicHomeBridge {
}
function onExecuteAffirmation(address _recipient, uint256 _value) internal returns(bool) {
_recipient.transfer(_value);
if (!_recipient.send(_value)) {
(new Sacrifice).value(_value)(_recipient);
}
return true;
}
}

View File

@ -2,6 +2,7 @@ const Web3Utils = require('web3-utils');
const HomeBridge = artifacts.require("HomeBridgeNativeToErc.sol");
const EternalStorageProxy = artifacts.require("EternalStorageProxy.sol");
const BridgeValidators = artifacts.require("BridgeValidators.sol");
const RevertFallback = artifacts.require("RevertFallback.sol");
const {ERROR_MSG, ZERO_ADDRESS} = require('../setup');
const {createMessage, sign, signatureToVRS} = require('../helpers/helpers');
const minPerTx = web3.toBigNumber(web3.toWei(0.01, "ether"));
@ -289,6 +290,31 @@ contract('HomeBridge', async (accounts) => {
balanceBefore.add(value).should.be.bignumber.equal(await web3.eth.getBalance(recipient))
})
it('force withdraw if the recepient has fallback to revert', async () => {
const revertFallbackContract = await RevertFallback.new();
await revertFallbackContract.receiveEth({from: accounts[0], value: halfEther})
await web3.eth.getBalance(revertFallbackContract.address).should.be.bignumber.equal(halfEther)
const transactionHash = "0x106335163828a8eda675cff9c84fa6e6c7cf06bb44cc6ec832e42fe789d01415";
const {logs} = await homeBridge.executeAffirmation(revertFallbackContract.address, halfEther, transactionHash, {from: authorities[0]})
logs[0].event.should.be.equal("SignedForAffirmation");
logs[0].args.should.be.deep.equal({
signer: authorities[0],
transactionHash
});
logs[1].event.should.be.equal("AffirmationCompleted");
logs[1].args.should.be.deep.equal({
recipient: revertFallbackContract.address,
value: halfEther,
transactionHash
})
const homeBalanceAfter = await web3.eth.getBalance(homeBridge.address)
const balanceAfter = await web3.eth.getBalance(revertFallbackContract.address)
balanceAfter.should.be.bignumber.equal(halfEther.add(halfEther))
homeBalanceAfter.should.be.bignumber.equal(0)
})
})
describe('#isAlreadyProcessed', async () => {
it('returns ', async () => {

View File

@ -0,0 +1,12 @@
pragma solidity 0.4.24;
contract RevertFallback {
function () public payable {
revert();
}
function receiveEth() public payable {
}
}