Merge pull request #7393 from ethereum/develop

Merge develop into 0.6.0
This commit is contained in:
chriseth
2019-09-10 12:27:02 +02:00
committed by GitHub
34 changed files with 310 additions and 77 deletions
+2
View File
@@ -299,6 +299,8 @@ BOOST_AUTO_TEST_CASE(valid_opcodes_functional)
"(NUMBER)",
"(DIFFICULTY)",
"(GASLIMIT)",
"(CHAINID)",
"(SELFBALANCE)",
"(POP 0)",
"(MLOAD 0)",
"(MSTORE 0 0)",
@@ -9,6 +9,9 @@ contract C {
function g(bool _value) public pure {
require(_value, "Value is false.");
}
function h() public pure returns (uint) {
assert(false);
}
}
// ====
// EVMVersion: >homestead
@@ -17,3 +20,4 @@ contract C {
// e() -> FAILURE, hex"08c379a0", 0x20, 19, "Transaction failed."
// f(bool): false -> FAILURE, hex"08c379a0", 0x20, 0
// g(bool): false -> FAILURE, hex"08c379a0", 0x20, 15, "Value is false."
// h() -> FAILURE
+5 -2
View File
@@ -126,8 +126,11 @@ string TestFunctionCall::format(
{
boost::optional<ParameterList> abiParams;
if (isFailure && !output.empty())
abiParams = boost::make_optional(ContractABIUtils::failureParameters(output));
if (isFailure)
{
if (!output.empty())
abiParams = boost::make_optional(ContractABIUtils::failureParameters(output));
}
else
abiParams = ContractABIUtils::parametersFromJsonOutputs(
_errorReporter,
@@ -0,0 +1,12 @@
{
let a := and(create2(0, 0, 0x20, 0), 0xffffffffffffffffffffffffffffffffffffffff)
let b := and(0xffffffffffffffffffffffffffffffffffffffff, create2(0, 0, 0x20, 0))
}
// ====
// step: expressionSimplifier
// EVMVersion: >=constantinople
// ----
// {
// let a := create2(0, 0, 0x20, 0)
// let b := create2(0, 0, 0x20, 0)
// }
@@ -0,0 +1,11 @@
{
let a := and(create(0, 0, 0x20), 0xffffffffffffffffffffffffffffffffffffffff)
let b := and(0xffffffffffffffffffffffffffffffffffffffff, create(0, 0, 0x20))
}
// ====
// step: expressionSimplifier
// ----
// {
// let a := create(0, 0, 0x20)
// let b := create(0, 0, 0x20)
// }
@@ -21,11 +21,10 @@
// ----
// {
// {
// let _1 := 0x40
// mstore(_1, add(mload(_1), 0x20))
// let p := mload(_1)
// mstore(_1, add(p, _1))
// mstore(add(p, 96), 2)
// mstore(_1, 0x20)
// let _1 := mload(0x40)
// mstore(0x40, add(_1, 0x20))
// mstore(0x40, add(_1, 96))
// mstore(add(_1, 128), 2)
// mstore(0x40, 0x20)
// }
// }
@@ -10,6 +10,6 @@
// {
// sstore(4, 5)
// sstore(4, 3)
// sstore(8, sload(4))
// sstore(8, 3)
// }
// }
@@ -0,0 +1,18 @@
{
sstore(0, 123213)
for {let x := 0 let y} lt(x, sload(0)) {
x := add(x, 1)} {y := add(x, y)
}
}
// ====
// step: loadResolver
// ----
// {
// let _1 := 123213
// let _2 := 0
// sstore(_2, _1)
// let x := _2
// let y
// for { } lt(x, _1) { x := add(x, 1) }
// { y := add(x, y) }
// }
@@ -31,5 +31,5 @@
// mstore8(calldataload(_5), 4)
// sstore(_5, mload(_2))
// mstore(_2, _17)
// sstore(_5, mload(_2))
// sstore(_5, _17)
// }
@@ -0,0 +1,28 @@
{
function stores() { mstore(0, 1) }
function reads() { sstore(9, mload(7)) }
mstore(2, 9)
reads()
sstore(0, mload(2))
stores()
sstore(0, mload(2))
}
// ====
// step: loadResolver
// ----
// {
// function stores()
// { mstore(0, 1) }
// function reads()
// { sstore(9, mload(7)) }
// let _6 := 9
// let _7 := 2
// mstore(_7, _6)
// reads()
// let _9 := _6
// let _10 := 0
// sstore(_10, _9)
// stores()
// sstore(_10, mload(_7))
// }
+8 -8
View File
@@ -63,8 +63,6 @@ void ProtoConverter::visitType(
std::string varName, paramName;
createDeclAndParamList(_type, _dataType, varName, paramName);
addCheckedVarDef(_dataType, varName, paramName, _value);
// Update right padding of type
m_isLastParamRightPadded = isDataTypeBytesOrString(_dataType);
}
void ProtoConverter::appendVarDeclToOutput(
@@ -451,6 +449,8 @@ void ProtoConverter::visit(DynamicByteArrayType const& _x)
isBytes
)
);
// Update right padding of type
m_isLastDynParamRightPadded = true;
}
// TODO: Implement struct visitor
@@ -658,23 +658,23 @@ void ProtoConverter::visit(ArrayType const& _x)
{
case ArrayType::kInty:
baseType = getIntTypeAsString(_x.inty());
m_isLastParamRightPadded = false;
m_isLastDynParamRightPadded = false;
break;
case ArrayType::kByty:
baseType = getFixedByteTypeAsString(_x.byty());
m_isLastParamRightPadded = false;
m_isLastDynParamRightPadded = false;
break;
case ArrayType::kAdty:
baseType = getAddressTypeAsString(_x.adty());
m_isLastParamRightPadded = false;
m_isLastDynParamRightPadded = false;
break;
case ArrayType::kBoolty:
baseType = getBoolTypeAsString();
m_isLastParamRightPadded = false;
m_isLastDynParamRightPadded = false;
break;
case ArrayType::kDynbytesty:
baseType = bytesArrayTypeAsString(_x.dynbytesty());
m_isLastParamRightPadded = true;
m_isLastDynParamRightPadded = true;
break;
case ArrayType::kStty:
case ArrayType::BASE_TYPE_ONEOF_NOT_SET:
@@ -861,7 +861,7 @@ void ProtoConverter::visit(TestFunction const& _x)
)")
("parameterNames", dev::suffixedVariableNameList(s_varNamePrefix, 0, m_varCounter))
("invalidLengthFuzz", std::to_string(_x.invalid_encoding_length()))
("isRightPadded", isLastParamRightPadded() ? "true" : "false")
("isRightPadded", isLastDynParamRightPadded() ? "true" : "false")
("atLeastOneVar", m_varCounter > 0)
.render();
}
+7 -7
View File
@@ -103,7 +103,7 @@ public:
m_counter(0),
m_varCounter(0),
m_returnValue(1),
m_isLastParamRightPadded(false)
m_isLastDynParamRightPadded(false)
{}
ProtoConverter(ProtoConverter const&) = delete;
@@ -274,9 +274,9 @@ private:
return ((isValueType(_dataType) || m_isStateVar) ? "" : "memory");
}
bool isLastParamRightPadded()
bool isLastDynParamRightPadded()
{
return m_isLastParamRightPadded;
return m_isLastDynParamRightPadded;
}
// Static declarations
@@ -466,10 +466,10 @@ private:
unsigned m_varCounter;
/// Monotonically increasing return value for error reporting
unsigned m_returnValue;
/// Flag that indicates if last parameter passed to a function call
/// is of a type that is going to be right padded by the ABI
/// encoder.
bool m_isLastParamRightPadded;
/// Flag that indicates if last dynamically encoded parameter
/// passed to a function call is of a type that is going to be
/// right padded by the ABI encoder.
bool m_isLastDynParamRightPadded;
static unsigned constexpr s_maxArrayLength = 4;
static unsigned constexpr s_maxArrayDimensions = 4;
static unsigned constexpr s_maxDynArrayLength = 256;
@@ -180,6 +180,8 @@ u256 EVMInstructionInterpreter::eval(
return m_state.address;
case Instruction::BALANCE:
return m_state.balance;
case Instruction::SELFBALANCE:
return m_state.selfbalance;
case Instruction::ORIGIN:
return m_state.origin;
case Instruction::CALLER:
@@ -208,6 +210,8 @@ u256 EVMInstructionInterpreter::eval(
return 0;
case Instruction::GASPRICE:
return m_state.gasprice;
case Instruction::CHAINID:
return m_state.chainid;
case Instruction::EXTCODESIZE:
return u256(keccak256(h256(arg[0]))) & 0xffffff;
case Instruction::EXTCODEHASH:
+2
View File
@@ -70,6 +70,7 @@ struct InterpreterState
std::map<dev::h256, dev::h256> storage;
dev::u160 address = 0x11111111;
dev::u256 balance = 0x22222222;
dev::u256 selfbalance = 0x22223333;
dev::u160 origin = 0x33333333;
dev::u160 caller = 0x44444444;
dev::u256 callvalue = 0x55555555;
@@ -81,6 +82,7 @@ struct InterpreterState
dev::u256 blockNumber = 1024;
dev::u256 difficulty = 0x9999999;
dev::u256 gaslimit = 4000000;
dev::u256 chainid = 0x01;
/// Log of changes / effects. Sholud be structured data in the future.
std::vector<std::string> trace;
/// This is actually an input parameter that more or less limits the runtime.