Use correct call depth

This commit is contained in:
nicksavers 2014-10-24 15:44:15 +02:00
parent 7aa2370057
commit b2e20d2f8d
4 changed files with 292 additions and 9 deletions

View File

@ -328,6 +328,11 @@ public enum OpCode {
return opcode;
}
/**
* Returns the mininum amount of items required on the stack for this operation
*
* @return minimum amount of expected items on the stack
*/
public int require() {
return require;
}

View File

@ -4,6 +4,7 @@ import org.ethereum.core.Block;
import org.ethereum.core.Transaction;
import org.ethereum.facade.Repository;
import org.ethereum.manager.WorldManager;
import org.ethereum.util.ByteUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongycastle.util.encoders.Hex;
@ -36,7 +37,7 @@ public class ProgramInvokeFactory {
/*** ADDRESS op ***/
// YP: Get address of currently executing account.
byte[] address = (tx.isContractCreation())? tx.getContractAddress(): tx.getReceiveAddress();
byte[] address = tx.isContractCreation() ? tx.getContractAddress(): tx.getReceiveAddress();
/*** ORIGIN op ***/
// YP: This is the sender of original transaction; it is never a contract.
@ -61,8 +62,7 @@ public class ProgramInvokeFactory {
/*** CALLDATALOAD op ***/
/*** CALLDATACOPY op ***/
/*** CALLDATASIZE op ***/
byte[] data = tx.getData();
if (data == null) data = new byte[]{};
byte[] data = tx.getData() == null ? ByteUtil.EMPTY_BYTE_ARRAY : tx.getData();
/*** PREVHASH op ***/
byte[] lastHash = lastBlock.getHash();
@ -183,12 +183,13 @@ public class ProgramInvokeFactory {
gasLimit.longValue());
}
if(program.invokeData.getCallDeep() >= MAX_CREATE_CALL_DEPTH) {
throw program.new OutOfGasException();
}
int newCallDepth = program.invokeData.getCallDeep() + 1;
if (newCallDepth >= MAX_CREATE_CALL_DEPTH) {
throw program.new OutOfGasException();
}
return new ProgramInvokeImpl(address, origin, caller, balance, gasPrice, gas, callValue,
data, lastHash, coinbase, timestamp, number, difficulty, gasLimit,
repository, program.invokeData.getCallDeep()+1);
repository, newCallDepth);
}
}

View File

@ -892,7 +892,6 @@ public class VM {
program.stop();
} break;
case SUICIDE:{
program.stackRequire(1);
DataWord address = program.stackPop();
program.suicide(address);

View File

@ -127,6 +127,134 @@
}
}
},
"ABAcalls2" : {
"callcreates" : [
{
"data" : "0x",
"destination" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
"gasLimit" : "9999999998768",
"value" : "1"
}
],
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "10000000",
"currentNumber" : "0",
"currentTimestamp" : "1",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x6001600056016000576000600060006000600173945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f1",
"data" : "0x",
"gas" : "10000000000000",
"gasPrice" : "100000000000000",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "100000"
},
"gas" : "1003475",
"out" : "0x",
"post" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "999999999999999488",
"code" : "0x6001600056016000576000600060006000600173945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f1",
"nonce" : "0",
"storage" : {
"0x" : "0x01"
}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "512",
"code" : "0x60016000560160005760006000600060006000730f572e5295c57f15886f9b263e2f6d2d6c7b5ec66103e85c03f1",
"nonce" : "0",
"storage" : {
"0x" : "0x0200"
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1000000000000000000",
"code" : "0x6001600056016000576000600060006000600173945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f1",
"nonce" : "0",
"storage" : {
}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "0",
"code" : "0x60016000560160005760006000600060006000730f572e5295c57f15886f9b263e2f6d2d6c7b5ec66103e85c03f1",
"nonce" : "0",
"storage" : {
}
}
}
},
"ABAcalls3" : {
"callcreates" : [
{
"data" : "0x",
"destination" : "945304eb96065b2a98b57a48a06ae28d285a71b5",
"gasLimit" : "998768",
"value" : "1"
}
],
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "10000000",
"currentNumber" : "0",
"currentTimestamp" : "1",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x6001600056016000576000600060006000600173945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f1",
"data" : "0x",
"gas" : "1000000",
"gasPrice" : "100000000000000",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "100000"
},
"gas" : "864457",
"out" : "0x",
"post" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1024558",
"code" : "0x6001600056016000576000600060006000600173945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f1",
"nonce" : "0",
"storage" : {
"0x" : "0x01"
}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "442",
"code" : "0x60016000560160005760006000600060006000730f572e5295c57f15886f9b263e2f6d2d6c7b5ec66103e85c03f1",
"nonce" : "0",
"storage" : {
"0x" : "0x01b9"
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "1025000",
"code" : "0x6001600056016000576000600060006000600173945304eb96065b2a98b57a48a06ae28d285a71b56103e85c03f1",
"nonce" : "0",
"storage" : {
}
},
"945304eb96065b2a98b57a48a06ae28d285a71b5" : {
"balance" : "0",
"code" : "0x60016000560160005760006000600060006000730f572e5295c57f15886f9b263e2f6d2d6c7b5ec66103e85c03f1",
"nonce" : "0",
"storage" : {
}
}
}
},
"ABAcallsSuicide0" : {
"callcreates" : [
{
@ -239,7 +367,7 @@
}
}
},
"CallRecursiveBomb" : {
"CallRecursiveBomb0" : {
"callcreates" : [
{
"data" : "0x",
@ -303,6 +431,156 @@
}
}
},
"CallRecursiveBomb1" : {
"callcreates" : [
{
"data" : "0x",
"destination" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"gasLimit" : "364267",
"value" : "0"
}
],
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "10000000",
"currentNumber" : "0",
"currentTimestamp" : "1",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x600160005601600057600060006000600060003060e05c03f1600157",
"data" : "0x",
"gas" : "364723",
"gasPrice" : "1",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "100000"
},
"gas" : "104246",
"out" : "0x",
"post" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "20000000",
"code" : "0x600160005601600057600060006000600060003060e05c03f1600157",
"nonce" : "0",
"storage" : {
"0x" : "0x03fe",
"0x01" : "0x01"
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "20000000",
"code" : "0x600160005601600057600060006000600060003060e05c03f1600157",
"nonce" : "0",
"storage" : {
}
}
}
},
"CallRecursiveBomb2" : {
"callcreates" : [
{
"data" : "0x",
"destination" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"gasLimit" : "364268",
"value" : "0"
}
],
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "10000000",
"currentNumber" : "0",
"currentTimestamp" : "1",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x600160005601600057600060006000600060003060e05c03f1600157",
"data" : "0x",
"gas" : "364724",
"gasPrice" : "1",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "100000"
},
"gas" : "104551",
"out" : "0x",
"post" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "20000000",
"code" : "0x600160005601600057600060006000600060003060e05c03f1600157",
"nonce" : "0",
"storage" : {
"0x" : "0x03ff",
"0x01" : "0x01"
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "20000000",
"code" : "0x600160005601600057600060006000600060003060e05c03f1600157",
"nonce" : "0",
"storage" : {
}
}
}
},
"CallRecursiveBomb3" : {
"callcreates" : [
{
"data" : "0x",
"destination" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"gasLimit" : "999544",
"value" : "0"
}
],
"env" : {
"currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
"currentDifficulty" : "256",
"currentGasLimit" : "10000000",
"currentNumber" : "0",
"currentTimestamp" : "1",
"previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6"
},
"exec" : {
"address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6",
"caller" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"code" : "0x600160005601600057600060006000600060003060e05c03f1600157",
"data" : "0x",
"gas" : "1000000",
"gasPrice" : "1",
"origin" : "cd1722f3947def4cf144679da39c4c32bdc35681",
"value" : "100000"
},
"gas" : "104551",
"out" : "0x",
"post" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "20000000",
"code" : "0x600160005601600057600060006000600060003060e05c03f1600157",
"nonce" : "0",
"storage" : {
"0x" : "0x03ff",
"0x01" : "0x01"
}
}
},
"pre" : {
"0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : {
"balance" : "20000000",
"code" : "0x600160005601600057600060006000600060003060e05c03f1600157",
"nonce" : "0",
"storage" : {
}
}
}
},
"CallToNameRegistrator0" : {
"callcreates" : [
{