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