Skip to content
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

chore: Update to Istanbul context #568

Merged
merged 2 commits into from
Jan 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@
"repository": "https://github.com/aragon/aragonOS",
"license": "(GPL-3.0-or-later OR MIT)",
"devDependencies": {
"@aragon/truffle-config-v4": "^1.0.0",
"@aragon/truffle-config-v4": "^1.0.1",
"@codechecks/client": "^0.1.5",
"coveralls": "^2.13.3",
"coveralls": "^3.0.9",
"eth-ens-namehash": "^2.0.8",
"eth-gas-reporter": "^0.2.9",
"eth-gas-reporter": "^0.2.14",
"ethereumjs-abi": "^0.6.5",
"ganache-cli": "^6.4.2",
"ganache-cli": "^6.9.0",
"mocha-lcov-reporter": "^1.3.0",
"solidity-coverage": "0.6.2",
"solium": "^1.2.3",
"truffle": "4.1.14",
"truffle-bytecode-manager": "^1.1.1",
"truffle-extract": "^1.2.1",
"web3-eth-abi": "1.0.0-beta.33",
"web3-utils": "1.0.0-beta.33"
"web3-eth-abi": "1.2.5",
"web3-utils": "1.2.5"
},
"dependencies": {
"mkdirp": "^0.5.1",
Expand Down
36 changes: 14 additions & 22 deletions test/contracts/common/depositable_delegate_proxy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { toChecksumAddress } = require('web3-utils')
const { assertAmountOfEvents, assertEvent } = require('../../helpers/assertEvent')(web3)
const { skipCoverage } = require('../../helpers/coverage')
const { decodeEventsOfType } = require('../../helpers/decodeEvent')
const { assertRevert, assertOutOfGas } = require('../../helpers/assertThrow')
const { getBalance } = require('../../helpers/web3')
Expand All @@ -15,7 +16,6 @@ const SEND_ETH_GAS = TX_BASE_GAS + 9999 // <10k gas is the threshold for deposit
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

contract('DepositableDelegateProxy', ([ sender ]) => {
let ethSender, proxy, target, proxyTargetWithoutFallbackBase, proxyTargetWithFallbackBase
Expand Down Expand Up @@ -117,29 +117,21 @@ contract('DepositableDelegateProxy', ([ sender ]) => {
}
}

it('can receive ETH (Constantinople)', async () => {
it('can receive ETH', async () => {
const { gasUsed } = await assertSendEthToProxy({ value, gas: SEND_ETH_GAS })
console.log('Used gas:', gasUsed - TX_BASE_GAS)
})

// TODO: Remove when the targetted EVM has been upgraded to Istanbul (EIP-1884)
it('can receive ETH (Istanbul, EIP-1884)', async () => {
const gas = TX_BASE_GAS + SOLIDITY_TRANSFER_GAS - ISTANBUL_SLOAD_GAS_INCREASE
const { gasUsed } = await assertSendEthToProxy({ value, gas })
const gasUsedIstanbul = gasUsed - TX_BASE_GAS + ISTANBUL_SLOAD_GAS_INCREASE
console.log('Used gas (Istanbul):', gasUsedIstanbul)

assert.isBelow(gasUsedIstanbul, 2300, 'Gas cost under Istanbul cannot be above 2300 gas')
})

// TODO: Remove when the targetted EVM has been upgraded to Istanbul (EIP-1884)
it('cannot receive ETH if sent with a small amount of gas', async () => {
// solidity-coverage seems to be increasing the gas amount to prevent failures
const oogDecrease = process.env.SOLIDITY_COVERAGE ? 600 : 250
// deposit cannot be done with this amount of gas
const gas = TX_BASE_GAS + SOLIDITY_TRANSFER_GAS - ISTANBUL_SLOAD_GAS_INCREASE - oogDecrease
await assertSendEthToProxy({ shouldOOG: true, value, gas })
})
it(
'cannot receive ETH if sent with a small amount of gas',
// Our version of solidity-coverage is not on an istanbul context yet
// TODO: update solidity-coverage
skipCoverage(async () => {
const oogDecrease = 250
// deposit cannot be done with this amount of gas
const gas = TX_BASE_GAS + SOLIDITY_TRANSFER_GAS - oogDecrease
await assertSendEthToProxy({ shouldOOG: true, value, gas })
})
)

it('can receive ETH from contract', async () => {
const { tx } = await ethSender.sendEth(proxy.address, { value })
Expand Down Expand Up @@ -170,4 +162,4 @@ contract('DepositableDelegateProxy', ([ sender ]) => {
itForwardsToImplementationIfGasIsOverThreshold()
})
})
})
})
14 changes: 14 additions & 0 deletions test/helpers/coverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const skipCoverage = test => {
// Required dynamic this binding to attach onto the running test
return function skipCoverage() {
if (process.env.SOLIDITY_COVERAGE === 'true') {
this.skip()
} else {
return test()
}
}
}

module.exports = {
skipCoverage
}
2 changes: 1 addition & 1 deletion truffle-config.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('@aragon/truffle-config-v4/truffle-config')
module.exports = require('@aragon/truffle-config-v4')