0

Using ganache-cli (ganache-core v2.1.0, cli v6.1.0)

ganache-cli --blockTime 300 --account="0xC87509A1C067BBDE78BEB793E6FA76530B6382A4C0241E5E4A9EC0A0F44DC0D3,100000000000000000000" -p 9545 -l 6000000 --debug

The contract can be deployed with truffle or with remix, without issue.

Then with remix or myetherwallet an attempt to destroy my contract results in the error Base Fee Exceeds Gas Limit.

I have tried many different options with setting the gas fee in meta mask, the limit in ganache and any gas values in truffle.js. Sometimes upward of 16ETH. It just keeps giving the error. It does work if I use the JavascriptVM in Remix.

Provider: MetaMask (although I can skip this in remix) Browser: Brave

I don't understand why more gas would be required to destroy a contract than to deploy it? Or Even why more than the minimum gas would be required. The contract is so simple, there should not be an issue.

Contract:

pragma solidity 0.4.23;
    contract Test {
    address public owner;
    constructor() public {
        owner = msg.sender;
    }
    function destroy() onlyOwner public {
        selfdestruct(owner);
    }
    modifier onlyOwner() {
        require(msg.sender == owner);
        _;
    }
}

debug:

eth_estimateGas
PUSH1
PUSH1
MSTORE 0x80 0x40
CALLER
PUSH1
DUP1
PUSH2
EXP 0x0 0x100
DUP2
SLOAD 0x0
DUP2
PUSH20
MUL 0x1 0xffffffffffffffffffffffffffffffffffffffff
NOT 0xffffffffffffffffffffffffffffffffffffffff
AND 0x0 0xffffffffffffffffffffffff0000000000000000000000000000000000000000
SWAP1
DUP4
PUSH20
AND 0x627306090abab3a6e1400e9345bc60c78a8bef57 0xffffffffffffffffffffffffffffffffffffffff
MUL 0x1 0x627306090abab3a6e1400e9345bc60c78a8bef57
OR 0x0 0x627306090abab3a6e1400e9345bc60c78a8bef57
SWAP1
SSTORE 0x627306090abab3a6e1400e9345bc60c78a8bef57 0x0
POP 0x627306090abab3a6e1400e9345bc60c78a8bef57
PUSH2
DUP1
PUSH2
PUSH1
CODECOPY 0x27a6 0x53 0x0
PUSH1
RETURN 0x27a6 0x0
net_version
eth_getBlockByNumber
eth_getBlockByNumber
net_version
eth_getTransactionCount
eth_getBlockByNumber
eth_sendRawTransaction
PUSH1
PUSH1
PUSH1
MSTORE 0x80 0x40
CALLER
PUSH1
DUP1
PUSH2
EXP 0x0 0x100
DUP2
SLOAD 0x0
DUP2
PUSH20
MUL 0x1 0xffffffffffffffffffffffffffffffffffffffff
NOT 0xffffffffffffffffffffffffffffffffffffffff
AND 0x0 0xffffffffffffffffffffffff0000000000000000000000000000000000000000
SWAP1
DUP4
PUSH20
AND 0x627306090abab3a6e1400e9345bc60c78a8bef57 0xffffffffffffffffffffffffffffffffffffffff
MUL 0x1 0x627306090abab3a6e1400e9345bc60c78a8bef57
OR 0x0 0x627306090abab3a6e1400e9345bc60c78a8bef57
SWAP1
SSTORE 0x627306090abab3a6e1400e9345bc60c78a8bef57 0x0
POP 0x627306090abab3a6e1400e9345bc60c78a8bef57
PUSH2
DUP1
PUSH2
PUSH1
CODECOPY 0x27a6 0x53 0x0
PUSH1
RETURN 0x27a6 0x0

  Transaction: 0xee86d079272780c95fcc1603908229d82bb636f48a7d2922dd8ba8b5afe2827f
  Contract created: 0x8cdaf0cd259887258bc13a92c0a6da92698644c0
  Gas usage: 2779866
  Block Number: 1
  Block Time: Sun May 06 2018 18:58:45 GMT+0200 (EET)

eth_getBlockByNumber
net_version
eth_getTransactionReceipt
eth_getBlockByNumber
eth_getTransactionByHash
net_version
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBalance
eth_getBlockByNumber
net_version
eth_estimateGas
PUSH1
PUSH1
MSTORE 0x80 0x40
PUSH1
CALLDATASIZE
LT 0x4 0x4
PUSH2
JUMPI 0x0 0x132
PUSH1
CALLDATALOAD 0x0
PUSH29
SWAP1
DIV 0x100000000000000000000000000000000000000000000000000000000 0x83197ef000000000000000000000000000000000000000000000000000000000
PUSH4
AND 0x83197ef0 0xffffffff
DUP1
PUSH3
EQ 0x83197ef0 0xf837d6
PUSH2
JUMPI 0x0 0x134
DUP1
PUSH4
EQ 0x83197ef0 0x68a828c
PUSH2
JUMPI 0x0 0x184
DUP1
PUSH4
EQ 0x83197ef0 0x11dcfb89
PUSH2
JUMPI 0x0 0x1f8
DUP1
PUSH4
EQ 0x83197ef0 0x13036ba5
PUSH2
JUMPI 0x0 0x256
DUP1
PUSH4
EQ 0x83197ef0 0x13b61241
PUSH2
JUMPI 0x0 0x281
DUP1
PUSH4
EQ 0x83197ef0 0x15efc152
PUSH2
JUMPI 0x0 0x2f5
DUP1
PUSH4
EQ 0x83197ef0 0x3601ebf1
PUSH2
JUMPI 0x0 0x320
DUP1
PUSH4
EQ 0x83197ef0 0x36abf6ce
PUSH2
JUMPI 0x0 0x377
DUP1
PUSH4
EQ 0x83197ef0 0x50664326
PUSH2
JUMPI 0x0 0x3a2
DUP1
PUSH4
EQ 0x83197ef0 0x5a7a2d08
PUSH2
JUMPI 0x0 0x503
DUP1
PUSH4
EQ 0x83197ef0 0x83197ef0
PUSH2
JUMPI 0x1 0x568
JUMPDEST
CALLVALUE
DUP1
ISZERO 0x0
PUSH2
JUMPI 0x1 0x574
JUMPDEST
POP 0x0
PUSH2
PUSH2
JUMP 0x1a73
JUMPDEST
PUSH1
DUP1
SWAP1
SLOAD 0x0
SWAP1
PUSH2
EXP 0x0 0x100
SWAP1
DIV 0x1 0x627306090abab3a6e1400e9345bc60c78a8bef57
PUSH20
AND 0x627306090abab3a6e1400e9345bc60c78a8bef57 0xffffffffffffffffffffffffffffffffffffffff
PUSH20
AND 0x627306090abab3a6e1400e9345bc60c78a8bef57 0xffffffffffffffffffffffffffffffffffffffff
CALLER
PUSH20
AND 0x627306090abab3a6e1400e9345bc60c78a8bef57 0xffffffffffffffffffffffffffffffffffffffff
EQ 0x627306090abab3a6e1400e9345bc60c78a8bef57 0x627306090abab3a6e1400e9345bc60c78a8bef57
ISZERO 0x1
ISZERO 0x0
PUSH2
JUMPI 0x1 0x1ace
JUMPDEST
PUSH1
DUP1
SWAP1
SLOAD 0x0
SWAP1
PUSH2
EXP 0x0 0x100
SWAP1
DIV 0x1 0x627306090abab3a6e1400e9345bc60c78a8bef57
PUSH20
AND 0x627306090abab3a6e1400e9345bc60c78a8bef57 0xffffffffffffffffffffffffffffffffffffffff
PUSH20
AND 0x627306090abab3a6e1400e9345bc60c78a8bef57 0xffffffffffffffffffffffffffffffffffffffff
SELFDESTRUCT 0x627306090abab3a6e1400e9345bc60c78a8bef57
net_version
eth_getBlockByNumber
eth_getBlockByNumber
net_version
eth_getBlockByNumber
eth_getTransactionCount
eth_sendRawTransaction
eth_getBlockByNumber
eth_getBlockByNumber
net_version
eth_getBlockByNumber
  • Have you tried rolling back to an earlier compiler before constructor? From eyeballing your code, I see no problems, but I have seen numerous weird issues with the recent compilers. – Rob Hitchens - B9lab May 6 '18 at 18:14
  • I tried the different versions down to 0.4.18 - same result. I also tried testrpc v6.0.3 also same result – Phillip Gibb May 6 '18 at 19:04
  • Works perfectly when I connect to Ropsten via Metamask i.e. create then destroy and it hardly uses any gas (13419) – Phillip Gibb May 6 '18 at 19:11
  • Based on @Phillip's observation, the prime suspect would be your onlyOwner modifier, or rather that possibly you're not testing from the same account used to deploy it (which would be the owner). That would create a situation in which it reverts, by design. – Rob Hitchens - B9lab May 6 '18 at 19:31
  • I only use the same owner, and I have checked that that is correct by executing a call on the public variable 'owner', I have also stripped the onlyOwner check out, which does not make a difference. – Phillip Gibb May 6 '18 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.