2

I wrote a smart contract and deploy it in my private ethereum network

this contract method had been called many times, and it ran well util these days when our website api is attacked.

here is contract method:

function batchTransfer(
    uint64 _requestId,
    uint16 _count,
    address[] _receivers,
    uint256[] _amounts
)
external
payable
onlyAdmin
{
    require(_count == _receivers.length);
    require(_count == _amounts.length);

    uint sum = _sum(_amounts);
    require(sum <= msg.value);

    for(uint16 i = 0; i < _count; i++) {
        if(msg.sender != _receivers[i]) {
            _receivers[i].transfer(_amounts[i]);
        }
    }
    msg.sender.transfer(msg.value - sum);

    BatchTransfer(_requestId, msg.sender, sum, _count);
}

this method is a batch transfer method.

and _count max 100

gas limt is 3,000,000

when in HIGH concurrency condition, FAIL.

ethereum log 'out of gas'.

query by transactionHash:

eth.getTransactionReceipt("0x821db62fcc95c30db902a7173e42a0a00079787e1e4f65b453a668a129ed32db")
{
  blockHash: "0x773a01a6ddff0c9bb5804ba6580fb4d5bdcd692e939a4fdfa89c608ce966dd5c",
  blockNumber: 413423,
  contractAddress: null,
  cumulativeGasUsed: 10935074,
  from: "0x5eeaf2f57fbc5b50ad98493f02cbf173860a37fd",
  gasUsed: 3000000,
  logs: [],
  logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  status: "0x0",
  to: "0x6f909df22acf8ad94a38603981e9b9317c1cec2d",
  transactionHash: "0x821db62fcc95c30db902a7173e42a0a00079787e1e4f65b453a668a129ed32db",
  transactionIndex: 23
}

This transaction wrote into block successfully.


BUT in LOW concurrency condition, I called this method again.

it will SUCCESS!!!

NOTICE

  • ALL INPUT PARAMS ARE SAME!
  • no 'out of gas'
  • no exceed block gas limit
  • no exceed queue
  • some blocks contain both success and fail transactions
Kerwong
  • 398
  • 1
  • 4
  • 7
  • 1
    The cumulative gas in your failed transaction is very high (nearly 11 million). What is your gas limit set to in your genesis config? Do any of the transactions in that block succeed? Also, are any of the addresses being transferred to in the loop a contract address (if so, and only one of the transfers fails, it would cause the entire transaction to fail consuming all 3 million gas sent to it). – Adam Kipnis Apr 12 '18 at 17:17
  • @AdamKipnis block gas limit, I set in genesis config, is 100 million. part of transactions in that block succeed and others failed. And I'm quite sure that the failed not due to block gas limit. And, I think there is no contract address in the batch, because If i run the transaction again manually, it will success. Only in high concurrency conditioin fail. – Kerwong Apr 13 '18 at 02:33

0 Answers0