Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
izqui committed Sep 2, 2019
1 parent 1975607 commit 948acea
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions contracts/common/DepositableDelegateProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ contract DepositableDelegateProxy is DepositableStorage, DelegateProxy {
// Only accept the deposit and emit an event if all of the following are true:
// the proxy accepts deposits (isDepositable), msg.data.length == 0, and msg.value > 0
if and(and(sload(isDepositablePosition), iszero(calldatasize)), gt(callvalue, 0)) {
// Equivalent Solidity code for emitting the event:
// emit ProxyDeposit(msg.sender, msg.value);

let logData := mload(0x40) // free memory pointer
mstore(logData, caller) // add 'msg.sender' to the log data (first event param)
mstore(add(logData, 0x20), callvalue) // add 'msg.value' to the log data (second event param)
Expand Down
3 changes: 2 additions & 1 deletion test/contracts/apps/app_funds.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const UnsafeAppStubDepositable = artifacts.require('UnsafeAppStubDepositable')

const APP_ID = hash('stub.aragonpm.test')
const EMPTY_BYTES = '0x'
const SEND_ETH_GAS = 31000 // 21k base tx cost + 10k limit on depositable proxies
const TX_BASE_GAS = 21000
const SEND_ETH_GAS = TX_BASE_GAS + 9999 // <10k gas is the threshold for depositing

contract('App funds', ([permissionsRoot]) => {
let aclBase, kernelBase
Expand Down
3 changes: 2 additions & 1 deletion test/contracts/apps/recovery_to_vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const KernelDepositableMock = artifacts.require('KernelDepositableMock')

const APP_ID = hash('stub.aragonpm.test')
const EMPTY_BYTES = '0x'
const SEND_ETH_GAS = 31000 // 21k base tx cost + 10k limit on depositable proxies
const TX_BASE_GAS = 21000
const SEND_ETH_GAS = TX_BASE_GAS + 9999 // <10k gas is the threshold for depositing

contract('Recovery to vault', ([permissionsRoot]) => {
let aclBase, appBase, appConditionalRecoveryBase
Expand Down
11 changes: 6 additions & 5 deletions test/contracts/common/depositable_delegate_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const ProxyTargetWithoutFallback = artifacts.require('ProxyTargetWithoutFallback
const ProxyTargetWithFallback = artifacts.require('ProxyTargetWithFallback')

const TX_BASE_GAS = 21000
const SEND_ETH_GAS = TX_BASE_GAS + 9999 // 10k gas is the threshold for depositing
const SEND_ETH_GAS = TX_BASE_GAS + 9999 // <10k gas is the threshold for depositing
const PROXY_FORWARD_GAS = TX_BASE_GAS + 2e6 // high gas amount to ensure that the proxy forwards the call
const FALLBACK_SETUP_GAS = process.env.SOLIDITY_COVERAGE ? 5000 : 100 // rough estimation of how much gas it spends before executing the fallback code
const SOLIDITY_TRANSFER_GAS = 2300
const ISTANBUL_SLOAD_GAS_INCREASE = 600
Expand All @@ -35,7 +36,7 @@ contract('DepositableDelegateProxy', ([ sender ]) => {
context('when implementation address is set', () => {
const itSuccessfullyForwardsCall = () => {
it('forwards call with data', async () => {
const receipt = await target.ping()
const receipt = await target.ping({ gas: PROXY_FORWARD_GAS })
assertAmountOfEvents(receipt, 'Pong')
})
}
Expand All @@ -61,18 +62,18 @@ contract('DepositableDelegateProxy', ([ sender ]) => {
itSuccessfullyForwardsCall()

it('reverts when sending ETH', async () => {
await assertRevert(target.sendTransaction({ value: 1 }))
await assertRevert(target.sendTransaction({ value: 1, gas: PROXY_FORWARD_GAS }))
})
})
})

context('when implementation address is not set', () => {
it('reverts when a function is called', async () => {
await assertRevert(target.ping())
await assertRevert(target.ping({ gas: PROXY_FORWARD_GAS }))
})

it('reverts when sending ETH', async () => {
await assertRevert(target.sendTransaction({ value: 1 }))
await assertRevert(target.sendTransaction({ value: 1, gas: PROXY_FORWARD_GAS }))
})
})
}
Expand Down
3 changes: 2 additions & 1 deletion test/contracts/kernel/kernel_funds.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const KernelProxy = artifacts.require('KernelProxy')
// Mocks
const KernelDepositableMock = artifacts.require('KernelDepositableMock')

const SEND_ETH_GAS = 31000 // 21k base tx cost + 10k limit on depositable proxies
const TX_BASE_GAS = 21000
const SEND_ETH_GAS = TX_BASE_GAS + 9999 // <10k gas is the threshold for depositing

contract('Kernel funds', ([permissionsRoot]) => {
let aclBase
Expand Down

0 comments on commit 948acea

Please sign in to comment.